0, '4인치_4500' => 0, '4인치_6000' => 0, '5인치_6000' => 0, '5인치_7000' => 0, '5인치_8200' => 0, ]; // 부속자재 데이터 $subs_data = [ '각파이프_3000' => 0, '각파이프_6000' => 0, '앵글_2500' => 0, '마환봉_3000' => 0, ]; // 누적 처리 foreach ($eList as $item) { // 2인치, 3인치일 경우만 동적 shaft_data 처리 $inch = isset($item['col59_inch']) ? $item['col59_inch'] : '2인치'; $length = isset($item['col59_length']) ? $item['col59_length'] : '300'; $qty = isset($item['col59']) ? intval($item['col59']) : 0; if (in_array($inch, ['2인치', '3인치'])) { $shaft_key = "{$inch}_{$length}"; if (!isset($shaft_data[$shaft_key])) { $shaft_data[$shaft_key] = 0; } $shaft_data[$shaft_key] += $qty; } // 기존 방식 고정 컬럼들 (4~5인치 감기샤프트) $fixed_shaft['4인치_3000'] += intval($item['col60']); $fixed_shaft['4인치_4500'] += intval($item['col61']); $fixed_shaft['4인치_6000'] += intval($item['col62']); $fixed_shaft['5인치_6000'] += intval($item['col63']); $fixed_shaft['5인치_7000'] += intval($item['col64']); $fixed_shaft['5인치_8200'] += intval($item['col65']); // 부속자재 $subs_data['각파이프_3000'] += intval($item['col68']); $subs_data['각파이프_6000'] += intval($item['col69']); $subs_data['마환봉_3000'] += intval($item['col70']); $subs_data['앵글_2500'] += intval($item['col71']); } // 출력 시작 echo '
'; // 감기샤프트 출력 echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // 감기샤프트 데이터 출력 전: 정렬 uksort($shaft_data, function($a, $b) { // 1. 인치 숫자 추출 (2인치 → 2, 4인치 → 4 등) preg_match('/(\d+)인치/', $a, $matchA); preg_match('/(\d+)인치/', $b, $matchB); $inchA = isset($matchA[1]) ? intval($matchA[1]) : 0; $inchB = isset($matchB[1]) ? intval($matchB[1]) : 0; if ($inchA !== $inchB) { return $inchA - $inchB; } // 2. 길이 숫자 추출 (ex: _3000 → 3000) preg_match('/_(\d+)/', $a, $lenA); preg_match('/_(\d+)/', $b, $lenB); $lengthA = isset($lenA[1]) ? intval($lenA[1]) : 0; $lengthB = isset($lenB[1]) ? intval($lenB[1]) : 0; return $lengthA - $lengthB; }); // 동적 2/3인치 출력 foreach ($shaft_data as $label => $quantity) { if ($quantity > 0) { echo ''; echo ''; echo ''; echo ''; } } // 고정 4/5인치 출력 foreach ($fixed_shaft as $label => $quantity) { if ($quantity > 0) { echo ''; echo ''; echo ''; echo ''; } } echo ''; echo '
감기샤프트
규격수량
' . str_replace('_', ' ', $label) . '' . $quantity . '
' . str_replace('_', ' ', $label) . '' . $quantity . '
'; echo '
'; // 감기샤프트 끝 // 부속자재 출력 echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // 각파이프 (rowspan) $pipe_rowspan = 0; if ($subs_data['각파이프_3000'] > 0) $pipe_rowspan++; if ($subs_data['각파이프_6000'] > 0) $pipe_rowspan++; if ($pipe_rowspan > 0) { echo ''; echo ''; if ($subs_data['각파이프_3000'] > 0) { echo ''; echo ''; echo ''; if ($subs_data['각파이프_6000'] > 0) echo ''; } if ($subs_data['각파이프_6000'] > 0) { echo ''; echo ''; echo ''; } } // 앵글 if ($subs_data['앵글_2500'] > 0) { echo ''; echo ''; echo ''; echo ''; echo ''; } // 마환봉 if ($subs_data['마환봉_3000'] > 0) { echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; echo '
부속자재
구성품길이수량
각파이프3000' . $subs_data['각파이프_3000'] . '
6000' . $subs_data['각파이프_6000'] . '
앵글
(40*40*3T)
2500' . $subs_data['앵글_2500'] . '
마환봉
(6mm)
3000' . $subs_data['마환봉_3000'] . '
'; echo '
'; // 부속자재 끝 echo '
'; // 전체 row 끝 } ?>