<?php
//$headerTag
//$item
//$hasMoreRemark
//$make
//$models
//$fontBold
//$font
//$fontUni
//'①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨'

$headCfg = $this->modelHeader[$headerTag];
$fname = md5(json_encode($item)) . '.png';
$outfilename = $this->tmpDir . '/' . $fname;
$outurl = \mvc::$cfg['path']['cache'] . '/tmp_pdf_ss/' . $fname;
if ($row > 1) {
    $row = $this->setBreak($sheet, $row - 1, 'Header') + 1;
}
$this->insertModelHeaderText($sheet, $row, $item);
$this->setBgColor($sheet, $row, 'FFFFFF');

//if (!file_exists($outfilename)) {
$image = imagecreatefrompng($headCfg['filename']);
$white = imagecolorallocate($image, 255, 255, 255);
if ($hasMoreRemark) {

}
$angle = 0;
//make
$fontSize = 50;
$size = $this->imageTextSize($fontSize, $angle, $fontBold, $make);
$x = 290;
$y = 20 + $size['height'];
$y = 70;
imagettftext($image, $fontSize, 0 , $x, $y, $white, $fontBold, $make);


//1
$x = 280;
$y = 88;
$areaHeight = 84;
$targetWidth = 2000;
if ($hasMoreRemark) {
    $x = $x - 5;
    $size = $this->insertTextFitWidthByImage($targetWidth, $angle, $fontUni, '①', $image, $x, $y, $areaHeight);
    $x = $x + $size['width'] + 25;
    $targetWidth = $targetWidth - $size['width'] + 25;
}
$this->insertTextFitWidthByImage($targetWidth, $angle, $font, $models[0], $image, $x, $y, $areaHeight);

//2
$x = 270;
$y = 176;
$areaHeight = 84;
$targetWidth = 2000;
if ($hasMoreRemark) {
    $x = $x - 5;
    $size = $this->insertTextFitWidthByImage($targetWidth, $angle, $fontUni, '②', $image, $x, $y, $areaHeight);
    $x = $x + $size['width'] + 25;
    $targetWidth = $targetWidth - $size['width'] + 25;
}
$this->insertTextFitWidthByImage($targetWidth, $angle, $font, $models[1], $image, $x, $y, $areaHeight);

//
imagepng($image, $outfilename, 0);
imagedestroy($image);


$this->insertImage($sheet, $outfilename, $headCfg['width'], $headCfg['height'], $col, $row, 0, 10);
$this->setRowHeight($sheet, $row, $headCfg['height'] * PT_SALC + 25);
$isBreak = $this->addRowNum($sheet, 'Header');

//echo '<img src="'. $outurl.'">';
//exit;
