<?php
//拉杆球头, 单拉杆
$maxInsertRowsCount = 0;
$hasCenterPro = !empty($centerItems); //是否有中间产品


$col_L = $hasCenterPro ? 1 : 3;
$col_R = $hasCenterPro ? 9 : 7;

//先绘左右，再绘中间，左右是高度
if ($leftItem) {
    if ($isLR) {
        $style = [
            'image' => [
                'col' => $col_L,
                'top' => true,
                'offsetX' => 32,
                'height' => 80,
            ],
        ];
        $back = $this->insertAny($sheet, $this->rowNum, $leftItem, $style);
        if ($back > $maxInsertRowsCount) $maxInsertRowsCount = $back;
        $style = [
            'image' => [
                'col' => false,
                'top' => true,
                'height' => 80,

                'flip' => true,
                'flipCol' => $col_R,
                'flipOffsetX' => 32,
            ],
        ];
        $back = $this->insertAny($sheet, $this->rowNum, $leftItem, $style);
        if ($back > $maxInsertRowsCount) $maxInsertRowsCount = $back;
    } else {
        $style = [
            'image' => [
                'col' => $col_L,
                'top' => true,
                'offsetX' => 32,
                'height' => 80,
            ],
        ];
        $skips[] = $currentKey;
        $back = $this->insertAny($sheet, $this->rowNum, $leftItem, $style, $rightItem);
        if ($rightItem) {
            $style = [
                'image' => [
                    'col' => $col_R,
                    'top' => true,
                    'offsetX' => 0,
                    'height' => 80,
                ],
            ];
            $back = $this->insertAny($sheet, $this->rowNum, $rightItem, $style);
            if ($back > $maxInsertRowsCount) $maxInsertRowsCount = $back;
        }
    }
}


if ($hasCenterPro) {
    if ($centerIsLR) {
        $style = [
            'image' => [
                'col' => 5,
                'top' => true,
                'offsetX' => -20,
                'height' => 80,

                'flipRight' => true,
                'flip' => true,
                'flipCol' => 6,
                'flipOffsetX' => -0,
            ],
        ];
        $back = $this->insertAny($sheet, $this->rowNum, $centerLeftItem, $style);
        if ($back > $maxInsertRowsCount) $maxInsertRowsCount = $back;
    } else {
        if($centerLeftItem) {
            $style = [
                'image' => [
                    'col' => 4,
                    'top' => true,
                    'offsetX' => 32,
                    'height' => 80,
                ],
            ];
            $skips[] = $currentKey;
            $back = $this->insertAny($sheet, $this->rowNum, $centerLeftItem, $style);
            if ($rightItem) {
                $style = [
                    'image' => [
                        'col' => 6,
                        'top' => true,
                        'offsetX' => 0,
                        'height' => 80,
                    ],
                ];
                $back = $this->insertAny($sheet, $this->rowNum, $centerRightItem, $style);
                if ($back > $maxInsertRowsCount) $maxInsertRowsCount = $back;
            }
        }
    }
}
