<?php

$aValue = [
    'header' => [
        'style' => 'remarkGuide',
        'title' => '封面',
        'remark' => '',
        'value' => [
            'compute' => false, // 是否需要计算页码
            'imglist' => [
                dirname(__DIR__). '/image/kty46e1olb.jpg',
                dirname(__DIR__). '/image/rule.jpg',
            ],
        ]
    ],

    'general' => [
        'style' => 'generalGuide',
        'title' => 'GENERAL INDEX',
        'remark' => 'GENERAL INDEX',
        'compute' => true,
        'value' => []
    ],

    'vehicle' => [
        'style' => 'vehicleGuide',
        'title' => 'Vehicle Index',
        'remark' => 'Vehicle Index',
        'compute' => true,
        'value' => []
    ],
];

// 轮毂参数页 & 轮毂附件配置页
$aLabel = [
    'Hub Assemblies' => ['style' => 'hubAssembliesByWheel'],
    'BraKe Disc/Brake Drum' => ['style' => 'brakeByWheel'],
    'Drive Shaft' => ['style' => 'driveShaftByWheel'],
    'Bearing Kits' => ['style' => 'bearingKitsByWheel'],
    'Stub Axle' => ['style' => 'stubAxleByWheel'],
];

foreach ($aLabel as $sLabel => $aStyle)
{
    $aData = [];
    $aTool = [];
    switch ($aStyle['style'])
    {
        case 'brakeByWheel':
        case 'driveShaftByWheel':
        case 'hubAssembliesByWheel':
        case 'stubAxleByWheel':
            $sData = rand(1, 100);
            for ($sRun = 0; $sRun < $sData; $sRun ++)
            {
                // 轮毂参数
                $aTemp = ['col1' => $sRun + 1, 'col2' => '9228006K', 'col3' => $sRun, 'col4' => 97, 'col5'=> 'Ф10.5(4)', 'col6' => '56', 'col7' => '12', 'col8' => 28, 'col9' => $sRun];
                if (($aStyle['style'] == 'driveShaftByWheel') || ($aStyle['style'] == 'stubAxleByWheel')) {
                    $aTemp['col10'] = 'col10';
                }
                $aData[] = $aTemp;

                // 轮毂附件配置
                $aTool[] = ['col1' => $sRun + 1, 'col2' => '9336017K', 'col3' => 1, 'col4' => 2, 'col5' => 3, 'col6' => 4, 'col7' => 5, 'col8' => 6, 'col9' => 7, 'col10' => 8, 'col11' => 9, 'col12' => 10, 'col13' => 11, 'col14' => 12, 'col15' => 13];
            }
            break;

        case 'bearingKitsByWheel':
            /*
            $sData = rand(1, 200);
            for ($sRun = 0; $sRun < $sData; $sRun ++)
            {
                $aTemp = ['col1' => $sRun + 1, 'col2' => '9228006K--'. $sRun, 'col3' => $sRun, 'col4' => 97, 'col5'=> 'Ф10.5(4)', 'col6' => '56', 'col7' => '12'];
                $aData[] = $aTemp;

                // 轮毂附件配置
                $aTool[] = ['col1' => $sRun + 1, 'col2' => '9336017K', 'col3' => 1, 'col4' => 2, 'col5' => 3, 'col6' => 4, 'col7' => 5, 'col8' => 6, 'col9' => 7, 'col10' => 8, 'col11' => 9, 'col12' => 10, 'col13' => 11, 'col14' => 12, 'col15' => 13, 'col16' => 14];
            }
            */

            for ($sRun = 0; $sRun < 23; $sRun ++)
            {
                $aTemp = [];
                $sData = rand(1, 10);
                for ($sRow = 1; $sRow <= $sData; $sRow ++) {
                    $aTemp[] = ['col1' => $sRow, 'col2' => 97, 'col3' => 'Ф10.5(4)', 'col4' => '56', 'col5' => sprintf('%s-%s', $sRun, $sRow)];
                }
                $aData[] = ['stream' => $sRun + 1, 'product' => 'GK6537', 'value' => $aTemp];

                // 轮毂附件配置
                $aTool[] = ['col1' => $sRun + 1, 'col2' => '9336017K', 'col3' => 1, 'col4' => 2, 'col5' => 3, 'col6' => 4, 'col7' => 5, 'col8' => 6, 'col9' => 7, 'col10' => 8, 'col11' => 9, 'col12' => 10, 'col13' => 11, 'col14' => 12, 'col15' => 13, 'col16' => 14];
            }
            break;
    }
    
    $aValue[sprintf('param_%s', $aStyle['style'])] = array_merge($aStyle, [
        'title' => $sLabel,
        'remark' => sprintf('%s Basic Dimension Table-GSP to Dimension', $sLabel),
        'compute' => true,
        'value' => $aData
    ]);

    if ($aTool)
    {
        $aValue[sprintf('tools_%s', $aStyle['style'])] = [
            'style' => ($aStyle['style'] == 'bearingKitsByWheel') ? 'tools2Guide' : 'tools1Guide',
            'title' => $sLabel,
            'remark' => sprintf('%s Contents of Complete Kits', $sLabel),
            'compute' => true,
            'value' => $aTool
        ];
    }
}

// 轮毂车型
$aModel = [];
$aTests = require __DIR__. '/model.php';
foreach ($aTests as $aVal)
{
    $aData = [];
    $sCount = rand(1, 9);
    for ($sRun = 0; $sRun < $sCount; $sRun ++)
    {
        $aData[] = [
            'col1' => '1990.12-1994.07', 'col2' => 'Saloon 937 A2.000',
            'col3' => '中文Date from:2004.10', 'col4' => 'R', 'col5' => 'L/R', 'col6' => '9230118K', 'col7' => '48'
        ];
    }
    $aModel[] = array_merge($aVal, ['value' => $aData]);
}
$aValue['model'] = ['style' => 'modelGuideByWheel', 'title' => 'Application', 'remark' => 'Application', 'compute' => true, 'value' => $aModel];

// 图片
$sData = rand(1, 2);
foreach ($aLabel as $sLabel => $aStyle)
{
    $aData = [];
    for ($sRun = 0; $sRun < $sData; $sRun ++)
    {
        $aData[] = [
            'col1' => sprintf('GK%s', substr('0000'. $sRun, -4)),
            'col2' => [
                ['brand' => 'MERCEDES-BENZ', 'number' => '9063502410'],
                ['brand' => 'MERCEDES-BENZ', 'number' => '9063502410'],
            ],
            'col3' => sprintf('%s/pic/123.bmp', dirname(__DIR__)),
        ];
    }

    $aValue[sprintf('photo_%s', $aStyle['style'])] = [
        'style' => 'photoGuideBySuspension', 'title' => $sLabel, 'remark' => 'Cross References List And Photo', 'compute' => true, 'value' => $aData
    ];
}

// 交叉号
$aData = [];
$aBrand = ['OE1', 'OE2', 'OE3', 'OE4', 'OE5', 'OE6', 'OE7'];
foreach ($aBrand as $sBrand)
{
    $sRand = rand(5, 300);
    for ($sRun = 1; $sRun < $sRand; $sRun ++) {
        $aData[] = ['col' => $sBrand, 'col1' => 'VKBA'. substr('0000'.$sRun, -4), 'col2' => '9235001K'];
    }
}
$aValue['cross'] = ['style' => 'cross1Guide', 'title' => 'Cross Reference List', 'remark' => 'Cross Reference List', 'compute' => true, 'value' => $aData];

// 新号码
$aData = [];
for ($sRun = 201321; $sRun < 201821; $sRun ++) {
    $aData[] = $sRun;
}
$aValue['new'] = ['style' => 'new1Guide', 'title' => 'New applications (compared with catalogue 2020)', 'remark' => 'New applications (compared with catalogue 2020)', 'compute' => true, 'value' => $aData];
$aValue['footer'] = [
    'style' => 'remarkGuide',
    'title' => '封底',
    'remark' => '封底',
    'value' => [
        'compute' => false, // 是否需要计算页码
        'imglist' => [
            dirname(__DIR__). '/image/footer.jpg',
        ],
    ]
];

return $aValue;


