'1219', 'quantity' => intval($item['col38'])], ['length' => '2438', 'quantity' => intval($item['col39'])], ['length' => '3000', 'quantity' => intval($item['col40'])], ['length' => '3500', 'quantity' => intval($item['col41'])], ['length' => '4000', 'quantity' => intval($item['col42'])], ['length' => '4150', 'quantity' => intval($item['col43'])] ]; // 동일한 `size` 값이 이미 존재하는지 확인 $existingKey = array_search($boxSize, array_column($box_data, 'size')); if ($existingKey === false) { // 새로운 사이즈 추가 $box_data[] = [ 'size' => $boxSize, 'sum' => 1, 'cover' => $cover, 'fincover' => $fincover, 'boxdirection' => $boxdirection, 'boxfrontbottom' => $boxfrontbottom, 'boxrailwidth' => $boxrailwidth, 'length_data' => array_map(function ($length) { return ['length' => $length['length'], 'sum' => $length['quantity']]; }, $boxLengths) ]; } else { // 기존 데이터에 값 누적 $box_data[$existingKey]['sum'] += 1; $box_data[$existingKey]['cover'] += $cover; $box_data[$existingKey]['fincover'] += $fincover; // 길이 데이터 누적 foreach ($boxLengths as $index => $length) { $box_data[$existingKey]['length_data'][$index]['sum'] += $length['quantity']; } } } function fetchImageData($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // HTTPS 인증 무시 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // 연결 시간 초과 설정 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // 리다이렉트 따라가기 $imageData = curl_exec($ch); // if (curl_errno($ch)) { // echo "DEBUG: cURL 오류 -> " . curl_error($ch) . "
"; // } curl_close($ch); return $imageData; } function drawImage($sourcePath, $savePath, $textData, $fontSize = 3) { // URL을 로컬 경로로 변환 $documentRoot = $_SERVER['DOCUMENT_ROOT']; global $root_dir; $relativePath = str_replace($root_dir, '', $savePath); $localSavePath = $documentRoot . $relativePath; // echo "DEBUG: 변환된 로컬 저장 경로 -> {$localSavePath}
"; // 폴더 생성 $saveDir = dirname($localSavePath); if (!is_dir($saveDir)) { if (!mkdir($saveDir, 0777, true)) { echo "DEBUG: 폴더 생성 실패 -> {$saveDir}
"; return false; } } else { chmod($saveDir, 0777); // echo "DEBUG: 폴더 권한 설정 -> {$saveDir}
"; } // 원본 이미지 데이터 가져오기 (cURL 사용) // echo "DEBUG: 원본 이미지 경로 -> {$sourcePath}
"; $imageData = fetchImageData($sourcePath); if (!$imageData) { // echo "DEBUG: 원본 이미지 데이터를 가져올 수 없습니다.
"; return false; } // echo "DEBUG: 원본 이미지 데이터 로드 성공
"; // 이미지 로드 및 작업 $tempImage = tempnam(sys_get_temp_dir(), 'image'); file_put_contents($tempImage, $imageData); $image = @imagecreatefromjpeg($tempImage); unlink($tempImage); if (!$image) { echo "DEBUG: JPEG 이미지를 로드할 수 없습니다.
"; return false; } // echo "DEBUG: 이미지 리소스 생성 성공
"; // 텍스트 추가 $textColor = imagecolorallocate($image, 255, 0, 0); // 빨간색 foreach ($textData as $textItem) { if (isset($textItem['text'], $textItem['x'], $textItem['y'])) { imagestring( $image, $fontSize, intval($textItem['x']), intval($textItem['y']), $textItem['text'], $textColor ); // echo "DEBUG: 텍스트 추가 -> '{$textItem['text']}' @ ({$textItem['x']}, {$textItem['y']})
"; } } // 이미지 저장 $result = @imagejpeg($image, $localSavePath); // if ($result) { // echo "DEBUG: 이미지 저장 성공 -> {$localSavePath}
"; // } else { // echo "DEBUG: 이미지 저장 실패 -> {$localSavePath}
"; // } imagedestroy($image); return $result ? $localSavePath : false; } ?> '; // print_r($box); // echo ''; ?>
$boxheight , 'x' => 15, 'y' => 85], ['text' => $TopcoverSize, 'x' => 100, 'y' => 2], ['text' => $box['boxfrontbottom'] , 'x' => 25, 'y' => 170], ['text' => $box['boxrailwidth'] , 'x' => 55, 'y' => 210], ['text' => ($boxwidth-$box['boxfrontbottom']-$box['boxrailwidth']-140) , 'x' => 120, 'y' => 175], ['text' => ($boxheight) , 'x' => 176, 'y' => 90], ['text' => ($boxwidth+5) , 'x' => 100, 'y' => 225], ['text' => ($boxheight+5) , 'x' => 135, 'y' => 250], ]; } else if($box['boxdirection'] == '후면') { // 점검구 후면 이미지 생성 $sourcePath = $WebSite . 'img/box/source/box_rear.jpg'; $saveName = 'box_' . str_replace('*', 'x', $box['size']) . '_rear.jpg'; $savePath = $WebSite . 'img/box/' . $saveName; list($boxwidth, $boxheight) = explode('*', $box['size']); $TopcoverSize = $boxwidth - 111; // 텍스트로 추가할 값 $textData = [ ['text' => $boxheight , 'x' => 15, 'y' => 85], ['text' => $TopcoverSize, 'x' => 100, 'y' => 2], ['text' => $box['boxfrontbottom'] , 'x' => 25, 'y' => 170], ['text' => $box['boxrailwidth'] , 'x' => 55, 'y' => 210], ['text' => ($boxwidth-$box['boxfrontbottom']-$box['boxrailwidth']) , 'x' => 120, 'y' => 165], ['text' => ($boxheight-140) , 'x' => 192, 'y' => 90], ['text' => ($boxwidth+5) , 'x' => 100, 'y' => 225], ['text' => ($boxheight+5) , 'x' => 135, 'y' => 250], ]; } else // 없으면 양면으로 추정함 ($box['boxdirection'] == '양면') { // 점검구 양면 이미지 생성 $sourcePath = $WebSite . 'img/box/source/box_both.jpg'; $saveName = 'box_' . str_replace('*', 'x', $box['size']) . '_both.jpg'; $savePath = $WebSite . 'img/box/' . $saveName; list($boxwidth, $boxheight) = explode('*', $box['size']); $TopcoverSize = $boxwidth - 111; // 텍스트로 추가할 값 // 여러 텍스트 데이터 $textData = [ ['text' => $boxheight , 'x' => 15, 'y' => 85], ['text' => $TopcoverSize, 'x' => 100, 'y' => 2], ['text' => $box['boxfrontbottom'] , 'x' => 25, 'y' => 170], ['text' => $box['boxrailwidth'] , 'x' => 55, 'y' => 210], ['text' => ($boxwidth-$box['boxfrontbottom']-$box['boxrailwidth']-140) , 'x' => 120, 'y' => 175], ['text' => ($boxheight-140) , 'x' => 192, 'y' => 90], ['text' => ($boxwidth+5) , 'x' => 100, 'y' => 225], ['text' => ($boxheight+5) , 'x' => 135, 'y' => 250], ]; } drawImage($sourcePath, $savePath, $textData, 4); // 길이 데이터 필터링 $filteredLengths = array_filter($box['length_data'], function ($length) { return $length['sum'] > 0; }); // echo '
';
						// print_r($filteredLengths);
						// echo '
'; $rowspan = count($filteredLengths); // 유효 길이의 개수만큼 rowspan 계산 $innerCount = 0; ?> $length): $innerCount ++ ; ?>
셔터박스 (점검구:)
셔터박스
①전면부 ②린텔부 ③하부점검구 ④후면코너부 ⑤후면점검구 ⑥상부덮개 ⑦측면부(마구리)