Files
sam-kd/estimate/slat_view_original.php

1774 lines
80 KiB
PHP
Raw Permalink Normal View History

<?php
// 전체 SET 내역 표시 일련번호, 종류, 부호, 제품명, 오픈사이즈 등 전체금액 나오는 부분
// echo '<pre>';
// print_r($decodedEstimateList);
// echo '</pre>';
if(True) {
$data = [];
$counter = 0;
$index = 0;
$sums = []; // 각 행의 합을 저장할 배열
// 전체 반복 찾기
foreach ($decodedEstimateList as $item) {
if (isset($item['col5']) && !empty($item['col5'])) {
// 각 행별 합계 재계산
// 검사비 10만원 처음 들어감 5만원으로 수정
$sums[$counter] = $inspectionFee ;
$su = floatval($item['col15']); // 수량
// 행의 나머지 데이터를 설정
$row = [];
$row['col1'] = $counter + 1;
$row['col2'] = '철재'; // 예시로 고정된 값
$row['col3'] = $item['col3'] ?? ''; // col2는 item의 col3 값을 사용
$row['col4'] = $item['col4'] ?? ''; // col3은 item의 col4 값을 사용
$row['col5'] = $item['col8']; // 필요한 값으로 설정
$row['col6'] = $item['col9'];
$row['col7'] = $item['col15']; // 수량
$row['col8'] = 'SET'; // 빈 값으로 재계산 (필요에 따라 채움)
// $data 배열에 행을 추가합니다.
$data[] = $row;
$counter++;
}
}
echo '<div class="d-flex align-items-center justify-content-center ">';
echo '<table id="tableDetail" class="table" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th rowspan="2" class="text-center">일련<br>번호</th>';
echo '<th rowspan="2" class="text-center">종류</th>';
echo '<th rowspan="2" class="text-center">부호</th>';
echo '<th rowspan="2" class="text-center">제품명</th>';
echo '<th colspan="2" class="text-center">오픈사이즈</th>';
echo '<th rowspan="2" class="text-center">수량</th>';
echo '<th rowspan="2" class="text-center">단위</th>';
echo '<th rowspan="2" class="text-center">단가</th>';
if($selectWork !== '거래명세표') { // 견적서
echo '<th class="text-center">합계</th>';
} else { // 거래명세표
echo '<th colspan="3" class="text-center">금액</th>';
}
echo '</tr>';
echo '<tr>';
echo '<th class="text-center">가로</th>';
echo '<th class="text-center">세로</th>';
if($selectWork !== '거래명세표') { // 견적서
echo '<th class="text-center">금액</th>';
} else { // 거래명세표
echo '<th class="text-center">공급가액</th>';
echo '<th class="text-center">부가세</th>';
echo '<th class="text-center">합계</th>';
}
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$col7_sum = 0; // col7 수량 합계
$col89_sum = 0; // col8 + col9 합계
$col10_sum = 0;
$row_count = 0;
foreach ($data as $row) {
echo '<tr class="calculation-row calculation-firstrow" data-row="' . $row_count . '" data-serial="' . $row_count . '">';
if($selectWork !== '거래명세표') { // 견적서
$innercount = 10;
} else { // 거래명세표
$innercount = 12;
}
for ($i = 1; $i <= $innercount; $i++) {
switch ($i) {
case 1:
echo '<td class="text-center ">' . $row['col1'] . '</td>';
break;
case 4:
echo '<td class="text-center yellowBold ">' . htmlspecialchars($row['col' . $i]) . '</td>';
break;
case 6:
echo '<td class="text-center text-primary fw-bold ">' . htmlspecialchars($row['col' . $i]) . '</td>';
break;
case 7:
echo '<td class="text-center text-primary fw-bold total-su-input" data-serial="' . $row_count . '">' . htmlspecialchars($row['col' . $i]) . '</td>';
break;
case 9:
echo '<td class="text-end text-dark total-unit-price-input" data-serial="' . $row_count . '" ></td>'; // 단가가 들어가는 셀
break;
case 10:
echo '<td class="text-end subtotal-cell" data-serial="' . $row_count . '" ></td>'; // 공급가액
break;
case 11:
echo '<td class="text-end vat-cell" data-serial="' . $row_count . '" ></td>'; // VAT
break;
case 12:
echo '<td class="text-end text-primary subtotalamount-cell" data-serial="' . $row_count . '" ></td>'; // 합계 금액
break;
default:
echo '<td class="text-center ">' . htmlspecialchars($row['col' . $i]) . '</td>';
break;
}
}
echo '</tr>';
$row_count++;
$estimateSurang = $col7_sum += intval($row['col7']); // 견적수량 합계코드
}
// 소계 행 추가
echo '<tr>';
echo '<td class="text-center" colspan="6">소계</td>';
echo '<td class="text-center text-primary fw-bold">' . $col7_sum. '</td>';
echo '<td class="text-center" colspan="2"></td>';
if($selectWork !== '거래명세표') { // 견적서
echo '<td id="subtotal" class="text-end fw-bold grand-total"></td>';
} else { // 거래명세표
echo '<td id="subtotal" class="text-end fw-bold grand-total"></td>';
echo '<td id="subtotalvat" class="text-end fw-bold grand-vat"></td>';
echo '<td id="subtotalamount" class="text-end text-primary fw-bold grand-sum"></td>';
}
echo '</tr>';
if($option == 'option') {
echo '<tr>';
echo '<td colspan="1">';
echo '비고';
echo '</td>';
echo '<td colspan="'. ($innercount-1) .'" class="text-start fw-bold" style="white-space: normal; word-wrap: break-word;">'; // 거래명세표는 col 9, col11 적용
echo '<div class="d-flex flex-wrap">';
echo $comment;
echo '</div>';
echo '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
echo '</div>';
}
// 세부 산출내역서
echo '<br> <div class="Estimateview">';
echo '<div class="d-flex align-items-center justify-content-center mt-2 mb-2">';
echo '<h3 class="mb-2"> 세부 산출내역서 </h3></div>';
echo '<div id="shutterboxMsg" class="d-flex align-items-center justify-content-center mt-2 mb-2" style="display:none;">';
echo '</div>';
echo '<div class="d-flex align-items-center justify-content-center ">';
echo '<table id="detailTable" class="table p-3" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th class="text-center lightgray w50px">일련<br>번호</th>';
echo '<th class="text-center lightgray w300px">항목</th>';
echo '<th class="text-center lightgray w50px">수량</th>';
echo '<th class="text-center lightgray w50px">단위</th>';
echo '<th class="text-center lightgray w250px">산출식</th>';
echo '<th class="text-center lightgray w80px">면적(㎡) <br> 길이(㎜)</th>';
echo '<th class="text-center lightgray w100px">면적(㎡) <br> 길이(㎜) 단가</th>';
echo '<th class="text-center lightgray w100px">단가</th>';
echo '<th class="text-center lightgray w120px">합계</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$row_count = 0;
$total_sum = 0; // 전체 합계를 계산할 변수
$counter = 0;
$index = 0;
$subtotal_array = [] ; // 소계 누계
$subtotal_surang_array = [] ; // 수량 누계
$row_array = [] ; // 각 행별 행카운트
// 전체 반복 찾기
foreach ($decodedEstimateList as $column) {
$subtotal = 0; // 각 일련번호별 소계
$rowCount = 0; // 행의 수
if (isset($column['col5']) && !empty($column['col5'])) {
$su = floatval($column['col15']); // 수량
// 가이드레일 및 기타 부품 단가 초기화
$guidrail_price = 0;
$bottomBarPrices = 0; // 하단마감재 단가
$LBarPrices = 0; // L바 단가
$bottomPlatePrices = 0; // 평철 단가
$guiderailSmokeBanPrices = 0; // 가이드레일용 연기차단재 단가
$boxSmokeBanPrices = 0; // 케이스용 연기차단재 단가
$maguriPrices = 0; // 마구리 단가
$finishing = $column['col7']; // 마감 (SUS, EGI)
$guideType = $column['col6']; // 벽면형(130*75), 혼합형(130*75)(130*125)
$modelCode = $column['col4']; // 모델코드
$maguriCol = $column['col46']; // 마구리 size (스크린 45위치, 철재 46위치)
// $col7_clean = str_replace('', '', $column['col7']); // 마감유형
// 데이터베이스 테이블 이름 설정 (BDmodels)
$tablename = 'BDmodels';
try {
$sql = "SELECT * FROM " . $DB . "." . $tablename;
$stmh = $pdo->prepare($sql);
$stmh->execute();
$count = $stmh->rowCount();
if ($count < 1) {
print "검색결과가 없습니다.<br>";
} else {
// 케이스 단가 정보를 저장할 배열
$shutterBoxprices = [];
// 가이드레일 단가를 저장할 배열 (모델코드, 마감, spec 기준으로 저장)
$guidrailPrices = [];
// 정규표현식 패턴 (숫자 형식만 매칭)
$pattern = '/\d{2,4}\*\d{2,4}/';
// 전체 데이터를 반복 처리
while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
$prodcode = $row['model_name'] ?? ''; // 모델코드
$spec = $row['spec'] ?? ''; // '120*70' 형태
$seconditem = $row['seconditem'] ?? ''; // 제품 분류
$load_finishingType = $row['finishing_type'] ?? ''; // 마감형태
$unitprice = $row['unitprice'] ?? 0;
// 단가에서 숫자와 소수점만 남기기
$unitprice_clean = preg_replace('/[^0-9.]/', '', $unitprice);
$unitprice_value = round(floatval($unitprice_clean));
// 케이스 단가 저장
if ($seconditem == '케이스' && $unitprice_value > 0) {
$shutterBoxprices[$spec] = $unitprice_value;
}
// 가이드레일 단가 저장 (모델코드 + 마감 + spec 기준으로 저장)
if ($seconditem == '가이드레일') {
$key = $prodcode . '|' . $load_finishingType . '|' . $spec;
$guidrailPrices[$key] = $unitprice_value;
}
// 하단마감재 단가 설정
if ($prodcode == $modelCode && $seconditem == '하단마감재' && $finishing == $load_finishingType) {
if ($unitprice_value > 0) {
$bottomBarPrices = $unitprice_value;
}
}
// 가이드레일용 연기차단재
if ($seconditem == '가이드레일용 연기차단재' && $unitprice_value > 0) {
$guiderailSmokeBanPrices = $unitprice_value;
}
// 케이스용 연기차단재
if ($seconditem == '케이스용 연기차단재' && $unitprice_value > 0) {
$boxSmokeBanPrices = $unitprice_value;
}
// L-BAR
if ($seconditem == 'L-BAR' && $unitprice_value > 0) {
$LBarPrices = $unitprice_value;
}
// 마구리 (마구리+규격 650*550)
if ($seconditem == '마구리' && $spec == $maguriCol && $unitprice_value > 0) {
$maguriPrices = $unitprice_value;
}
}
// 가이드레일 단가 계산
$baseKey = $modelCode . '|' . $finishing; // 기본 키 생성
$guidrail_price = 0;
if($steel == '1') {
if (strpos($guideType, '혼합') !== false) {
// 혼합형 처리 (예: 혼합형(130*75)(130*125))
preg_match_all($pattern, $guideType, $matches);
if (!empty($matches[0]) && count($matches[0]) == 2) {
$wallKey = $baseKey . '|' . $matches[0][0];
$sideKey = $baseKey . '|' . $matches[0][1];
$wallPrice = $guidrailPrices[$wallKey] ?? 0;
$sidePrice = $guidrailPrices[$sideKey] ?? 0;
$guidrail_price = ($wallPrice + $sidePrice); // 1개 세트 가격
}
} else if (strpos($guideType, '벽면') !== false) {
// 벽면형 또는 측면형 처리 (예: 벽면형(120*70))
preg_match($pattern, $guideType, $match);
if (!empty($match[0])) {
$guideSpec = $match[0];
$guideKey = $baseKey . '|' . $guideSpec;
$guidrail_price = ($guidrailPrices[$guideKey] ?? 0) * 2; // 2개 세트 가격
}
}
}
}
} catch (PDOException $Exception) {
print "오류: " . $Exception->getMessage();
}
// 가이드레일 단가 출력
// echo $guidrail_price;
// 각 행별 합계 재계산
// 주자재 계산
$tablename_mainslat = 'price_raw_materials';
$query = "SELECT itemList FROM {$DB}.$tablename_mainslat WHERE is_deleted IS NULL OR is_deleted = 0 ORDER BY registedate DESC LIMIT 1"; // 최신 1개의 데이터만 가져오기
$stmt = $pdo->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // 모든 행을 가져옴
$price_raw_materials = 0;
$price_jointbar = 0;
// 모든 행을 순회하면서 원하는 데이터를 찾음
if($slatcheck == '1') {
foreach ($rows as $row) {
$itemList = json_decode($row['itemList'], true);
$price_raw_materials = slatPrice($itemList, '슬랫', '방화');
if(!empty($price_raw_materials) )
break;
}
// 모든 행을 순회하면서 원하는 데이터를 찾음
foreach ($rows as $row) {
$itemList = json_decode($row['itemList'], true);
$price_jointbar = slatPrice($itemList, '슬랫', '조인트바');
if(!empty($price_jointbar))
break;
}
}
else {
$price_raw_materials = 0;
}
// 조인트바 수량이 없으면 가격 0으로 처리
if(intval($column['col76']) < 1 )
$price_jointbar = 0;
// col12도 숫자형으로 변환
$area = floatval($column['col12']);
// 철재 견적서 및 발주서의 금액은 세로 + 400 적용함
$height = !empty($column['col11_SH']) ? floatval($column['col11_SH']) : floatval($column['col11']);
$width = !empty($column['col10_SW']) ? floatval($column['col10_SW']) : floatval($column['col10']);
$calculateHeight = $height + 50; // 기본 350 + 50 = 400 개념임
$area = $width * $calculateHeight / 1000000;
// 모터가격 계산
// 모터단가 초기화
$motorUnit_price = 0;
if($motor == '1') {
$tablename_motor = 'price_motor';
$query = "SELECT itemList FROM {$DB}.$tablename_motor where ( is_deleted IS NULL or is_deleted = 0 ) ORDER BY NUM LIMIT 1 ";
$stmt = $pdo->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$itemList = json_decode($row['itemList'], true);
// $motorSpec = calculateMotorSpec($column , $column['col13'] , $column['col59']);
// 400K에서 숫자만 남김
$motorSpec = $column['col20'];
$motorSpec = preg_replace('/[a-zA-Z]/', '', $motorSpec);
// print_r($motorSpec);
$price = getPriceForMotor($motorSpec, $itemList);
// 모터 공급사 확인
$motor_supplier = $column['col19_brand'];
if ($motor_supplier === '경동(견적가포함)') {
$su = floatval($column['col15']); // 수량
$motorUnit_price = round($price);
// 모터 가격 합산
$sums[$counter] += $motorUnit_price * $su;
}
}
// 매립 연동제어기 가격 계산
$price_controller = 0;
$price1 = calculateControllerSpec($column['col16'], $itemList, '매립형');
if($price1 > 0 && !empty($column['col16']))
{
$price_controller += $price1;
$controller_amount += $price1 * intval($column['col16']); // 매립형 개수 곱하기
$sums[$counter] += $controller_amount; // 매립 연동제어기 가격 합산
}
// 노출 연동제어기 가격 계산
$price2 = calculateControllerSpec($column['col17'], $itemList, '노출형');
if($price2 > 0 && !empty($column['col17']))
{
$price_controller += $price2;
$controller_amount += $price2 * intval($column['col17']); // 노출형 개수 곱하기
$sums[$counter] += $controller_amount; // 노출 연동제어기 가격 합산
}
// 뒷박스 계산
$backbox_price = 0;
$backbox_price = calculateControllerSpec($column['col18'], $itemList, '뒷박스');
if($backbox_price > 0 && !empty($column['col18']))
{
$price_controller += $backbox_price;
$controller_amount += $backbox_price;
$sums[$counter] += $controller_amount;
}
// var_dump($column['col18']);
// var_dump($price_controller);
// 모터 받침용 앵글 가계
$tablename_angle = 'price_angle';
$query = "SELECT itemList FROM {$DB}.$tablename_angle where is_deleted IS NULL or is_deleted = 0 ORDER BY NUM LIMIT 1";
$stmt = $pdo->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$itemList = json_decode($row['itemList'], true);
// 철재스라트용 앵글 가격가져오기
$price_bottomangle = calculateAngleBracket($column['col15'], $itemList, $column['col21']); // 브라켓크기 전달
// print_r($itemList );
// print_r($price_angle );
// 4인치 3T (철재스라트용) 철재는 4T
$mainangle_price = calculateMainAngle($column['col15'], $itemList, '앵글4T' , '2.5' ); // 4T 철재
$mainangle_surang = intval(str_replace(',', '', $column['col77'])); // 수량
// BOM에서 제품코드별로 가져와야 합니다.
if($steel == '1') {
$tablename = 'BDmodels';
$query = "SELECT * FROM {$DB}.$tablename WHERE is_deleted IS NULL OR is_deleted = 0 ORDER BY NUM";
$stmt = $pdo->prepare($query);
$stmt->execute();
if($guidrail_price < 1 && !empty($column['col6']) && $column['col7']=='(없음)')
{
$shutterboxMsg .=
' <div class="d-flex align-items-center justify-content-center mb-2">
<div class="alert alert-danger mb-2" role="alert">
가이드레일 단가가 정의되지 않았습니다. 단가를 생성해주세요. [절곡BOM] 메뉴 이용!
</div>
</div> ';
}
// 케이스
if ($column['col37'] === 'custom') {
$shutterBox = $column['col37_custom']; // 사용자 제작 사이즈
} else {
$shutterBox = $column['col37']; // 케이스 500*380
}
$shutter_price = round($shutterBoxprices[$shutterBox]);
$basicbox_price = round($shutterBoxprices['650*550']); // 기본650*550 가격;
list($boxwidth, $boxheight) = explode('*', $shutterBox);
if ($shutter_price < 1 && !empty($shutterBox)) {
$shutterboxMsg .= $shutterBox . ' 단가표에 케이스 크기 정의 필요함!' ;
}
}
else {
$shutterboxMsg = '';
}
// 계산
if (array_key_exists($shutterBox, $shutterBoxprices)) {
$price = $su * round($shutterBoxprices[$shutterBox] / 1000) ;
} else {
$price = 0; // 조건이 맞지 않는 경우 0으로 설정
}
// $data 배열에 행을 추가합니다.
$data[] = $row;
$rowCount = 1;
// 일련번호, 검사비
$subtotal += $inspectionFee * $su;
if($inspectionFee > 0 )
{
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center" id="dynamicRowspan-' . $counter . '">' . $column['col1'] . '</td>';
echo '<td class="text-center item-name"> 검사비 </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 및 기타 필드
echo '<td class="text-center"> SET </td>';
// 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드)
echo '<td class="text-center"><input type="text" class="text-left noborder-input calc-formula-input" value="" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 길이(㎜) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 면적(㎡) 길이(㎜) 단가 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-price-input number-input" value="" data-row="' . $counter . '" data-type="area_price" oninput="inputNumber(this)" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($inspectionFee) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($inspectionFee * $su) . '</td>';
echo '</tr>';
$rowCount++;
}
// 주자재(철재스라트) 가격
$slat_price = round(floatval($price_raw_materials * round($area,2))) ;
$subtotal += $slat_price * $su;
if($slat_price > 0 )
{
if($inspectionFee < 1) { // 검사비가 없을때 1열을 만들어줘야 한다
echo '<tr class="calculation-row" data-serial="' . $counter . '">'; // 검사비가 포함되어야 하면 data-serial="' . $counter . '">';로 선언해야 한다.
echo '<td class="text-center" id="dynamicRowspan-' . $counter . '">' . ($counter+1) . '</td>';
echo '<td class="text-center item-name"> 스라트 </td>';
}
else {
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
echo '<tr class="calculation-row" data-serial="' . $counter . '">'; // 검사비가 포함되어야 하면 data-serial="' . $counter . '">';로 선언해야 한다.
echo '<td class="text-center item-name"> 스라트 </td>';
}
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 및 기타 필드
echo '<td class="text-center"> SET </td>';
// 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드)
echo '<td class="text-center"><input type="text" class="text-left noborder-input calc-formula-input" value="" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="' . number_format($area, 2) . '" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="' . number_format($price_raw_materials) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 철재스라트 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($slat_price) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($slat_price * $su,2) . '</td>';
echo '</tr>';
$rowCount++;
}
// 투시창 가격
if (intval($column['col14']) > 0 && intval($column['col14']) == 1) {
$price_quartz = 500000;
} else if (intval($column['col14']) > 0 && intval($column['col14']) == 2) {
$price_quartz = 800000;
} else if (intval($column['col14']) > 0 && intval($column['col14']) == 3) {
$price_quartz = 1000000;
} else {
$price_quartz = 0;
}
$subtotal += $price_quartz;
if($debug)print_r($subtotal . '<br>') ;
if ($price_quartz > 0) {
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name"> 투시창 </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 및 기타 필드
echo '<td class="text-center"> 식 </td>';
// 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드)
echo '<td class="text-center"><input type="text" class="text-end noborder-input calc-formula-input" value="' . $column['col14'] . ' EA" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 철재스라트 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($price_quartz) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($price_quartz) . '</td>';
echo '</tr>';
$rowCount++;
}
// 조인트바 가격
$subtotal += (intval($price_jointbar) * floatval($column['col76']) * $su );
if($debug)print_r($subtotal . '<br>') ;
if($price_jointbar > 0 )
{
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name"> 조인트바 </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format( floatval($column['col76']) ) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 및 기타 필드
echo '<td class="text-center"> SET </td>';
// 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드)
echo '<td class="text-center"><input type="text" class="text-end noborder-input calc-formula-input" value="300" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 철재스라트 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format( intval($price_jointbar) ) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($price_jointbar * floatval($column['col76']) ) . '</td>';
echo '</tr>';
$rowCount++;
}
// 모터
$subtotal += $motorUnit_price * $su;
if ($motorUnit_price > 0) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name">모터</td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input이 아님)
echo '<td class="text-center">SET</td>';
// 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드)
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $motorSpec . 'KG" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드 (없으면 빈 입력)
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드 (없으면 빈 입력)
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 모터 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($motorUnit_price) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($motorUnit_price * $su) . '</td>';
echo '</tr>';
$rowCount++;
}
// 연동제어기
$controller_price = $price_controller;
$controller_su = max(intval($column['col16']), intval($column['col17']),intval($column['col18']));
$subtotal += $controller_price;
if ($controller_price > 0 ) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
// 뒷박스 유무에 따라 다른 문장 출력
if($backbox_price > 0) {
echo '<td class="text-center item-name">매립/노출 연동제어기(뒷박스 포함)</td>';
}
else {
echo '<td class="text-center item-name">매립/노출 연동제어기</td>';
}
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($controller_su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input이 아님)
echo '<td class="text-center">SET</td>';
// 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드)
echo '<td class="text-center"><input type="text" class="noborder-input text-left calc-formula-input" value="" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드 (없으면 빈 입력)
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드 (없으면 빈 입력)
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 연동제어기 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($controller_price) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($controller_amount) . '</td>';
echo '</tr>';
$rowCount++;
}
// 케이스
if ($shutter_price < 1 && !empty($shutterBox)) {
echo ' <div class="d-flex align-items-center justify-content-center mb-2">
<div class="alert alert-danger mb-2" role="alert">
케이스 크기에 대한 단가가 정의되지 않았습니다. 단가를 생성해주세요. [절곡BOM] 메뉴 이용!
</div>
</div> ';
}
$total_length = round(floatval($column['col38']) / 1000,2);
// print_r($total_length);
// echo '<br>';
// print_r($shutter_price * $total_length);
$subtotal += round($shutter_price * $total_length) ;
if($total_length > 0 && !empty($shutterBox)) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name">케이스</td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input이 아님)
echo '<td class="text-center">SET</td>';
// 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드)
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $shutterBox . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="' . number_format($total_length, 2) . '" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="' . number_format($shutter_price) . '" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 케이스 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($shutter_price * $total_length) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($shutter_price * $total_length) . '</td>';
echo '</tr>';
$rowCount++;
}
// 케이스 연기차단재 1식으로 표현함 수량과 관계없이 연산해야 함.
$boxSmokeBanPrices = round($boxSmokeBanPrices);
$total_length = round(floatval($column['col38']) / 1000, 2);
$subtotal += $boxSmokeBanPrices * $total_length ;
if($total_length > 0 && !empty($column['col48'])) { // 케이스 연기차단재 col48
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name">케이스용 연기차단재</td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center"> 식 </td>';
// 산출식 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="W80" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="' . number_format($total_length , 2) . '" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="' . number_format($boxSmokeBanPrices) . '" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($boxSmokeBanPrices * $total_length) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($boxSmokeBanPrices * $total_length ) . '</td>';
echo '</tr>';
$rowCount++;
}
//마구리
$subtotal += $maguriPrices * $su;
if($maguriPrices > 0 && !empty($column['col47']))
{
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name">케이스 마구리</td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center">SET</td>';
// 산출식 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $column['col46'] . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($maguriPrices) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($maguriPrices * $su) . '</td>';
echo '</tr>';
$rowCount++;
}
// 모터 받침용 앵글
$price_bottomangle = round($price_bottomangle);
$angle_price = $price_bottomangle;
$subtotal += $angle_price * $su * 4;
if($angle_price > 0 && !empty($column['col23']))
{
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name">모터 받침용 앵글</td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su * 4) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (EA는 input에서 제외)
echo '<td class="text-center">EA</td>';
// 산출식 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $column['col23'] . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드 (빈 값)
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($angle_price) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($angle_price * $su * 4) . '</td>';
echo '</tr>';
$rowCount++;
}
// 가이드레일
// 혼합형이 아니면 1SET는 *2를 적용 혼합형은 예외임 단가는 이미 2개를 1세트로 단가표가 구성되어 있으니 유의할 것 절곡BOM참조
// 1) 총 길이(m) — 수량 제외
$total_length = round(floatval($column['col24']) / 1000, 2);
// 2) 단가(1SET 당)
$unit_price = round($guidrail_price) ;
// 3) 총액 = 단가 * 수량
$line_total = round($unit_price * $total_length * $su);
$subtotal += $line_total;
// print_r($guidrail_price * $total_length);
if ($guidrail_price > 0 && (!empty($column['col6']) && $column['col6']!=='(없음)')) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name"> 가이드레일 </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center"> SET </td>';
// 산출식 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $column['col6'] . ' ' . $column['col7'] . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="' . number_format($total_length, 2) . '" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드 (빈 값)
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($unit_price) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($line_total ) . '</td>';
echo '</tr>';
$rowCount++;
}
//가이드레일용 연기차단재 레일 높이 + 250 적용해서 만드는 것임
$total_length = floatval($column['col24']) / 1000 ;
$guiderailSmokeBanPricesTotal = round($guiderailSmokeBanPrices * $total_length ); // 철재는 하나, 스크린은 2개
$subtotal += $guiderailSmokeBanPricesTotal ;
// 해당열의 값이 없는지 검사해서 추가함
if ($total_length > 0 && (!empty($column['col32']) || !empty($column['col33']) || !empty($column['col34']) || !empty($column['col35']) || !empty($column['col36']))) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name"> 레일용 연기차단재 </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center"> SET </td>';
// 산출식 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="W50" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="' . number_format($total_length , 2) . '" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드 (빈 값)
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="' . number_format($guiderailSmokeBanPrices) . '" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($guiderailSmokeBanPrices * $total_length) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($guiderailSmokeBanPricesTotal ) . '</td>';
echo '</tr>';
$rowCount++;
}
// 하단마감재(하장바)
$total_length = intval($column['col49']) ; // 전체 길이에 대해서 곱해준다. 견적서는 몇가지가 이렇게 적용됨 길이 * 면적단가 =
$total_length = round($total_length / 1000,2);
$bottomBarPrices = round($bottomBarPrices);
$subtotal += ceil($bottomBarPrices * $total_length);
if ($total_length > 0 && (!empty($column['col50']) || !empty($column['col51']))) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center item-name"> 하장바 </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center"> SET </td>';
// 산출식 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-end calc-formula-input" value="'. $column['col7'] . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="' . number_format($total_length, 2) . '" data-row="' . $counter . '" data-type="area_length" oninput="inputNumber(this)" /></td>';
// 원자재 단가 입력 필드 (빈 값)
echo '<td class="text-end"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" oninput="inputNumber(this)" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($bottomBarPrices) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format(ceil($bottomBarPrices * $total_length)) . '</td>';
echo '</tr>';
$rowCount++;
}
// 감기샤프트
$tablename = 'price_shaft';
$query = "SELECT itemList FROM {$DB}.$tablename WHERE is_deleted IS NULL OR is_deleted = 0 ORDER BY NUM LIMIT 1";
$stmt = $pdo->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$itemList = json_decode($row['itemList'], true);
$sum_shaft_price = 0;
$shaft_counts = []; // 각 사이즈별 카운트를 저장할 배열
// 각각의 샤프트 계산
addShaftPrice($column['col61'], $itemList, '4', '3000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col62'], $itemList, '4', '4500', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col63'], $itemList, '4', '6000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col64'], $itemList, '5', '6000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col65'], $itemList, '5', '7000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col66'], $itemList, '5', '8200', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col67'], $itemList, '6', '3000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col68'], $itemList, '6', '6000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col69'], $itemList, '6', '7000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col70'], $itemList, '6', '8000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col71'], $itemList, '8', '8200', $sum_shaft_price, $shaft_counts);
// 샤프트 수량을 텍스트로 변환
$shaft_count_text = [];
foreach ($shaft_counts as $length => $count) {
$countstr = $count * $su;
$shaft_count_text[] = "{$length}x{$countstr}EA";
}
$shaft_count_text = implode(', ', $shaft_count_text);
$total_ea = intval($column['col59']);
$subtotal += $sum_shaft_price;
if ($sum_shaft_price > 0 ) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center"> 감기샤프트 </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($su) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center"> 식 </td>';
// 산출식 입력 필드 (샤프트 수량 텍스트)
echo '<td class="text-end"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $shaft_count_text . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" /></td>';
// 원자재 단가 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($sum_shaft_price/$su) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($sum_shaft_price) . '</td>';
echo '</tr>';
$rowCount++;
}
// 각파이프 3000 계산
$tablename = 'price_pipe';
$query = "SELECT itemList FROM {$DB}.$tablename WHERE is_deleted IS NULL OR is_deleted = 0 ORDER BY NUM LIMIT 1";
$stmt = $pdo->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$itemList = json_decode($row['itemList'], true);
// 각 파이프 가격 계산
$pipe_price_3000 = calculatePipe( $itemList, '1.4', '3000');
$pipe_price_6000 = calculatePipe( $itemList, '1.4', '6000');
// 각 파이프 수량 계산
$pipe_price_3000_surang = intval(str_replace(',', '', $column['col74']));
$pipe_price_6000_surang = intval(str_replace(',', '', $column['col75']));
// 각 파이프 수량을 텍스트로 변환
$pipe_counts = [];
if ($pipe_price_3000_surang > 0) {
$pipe_counts[] = "3000x{$pipe_price_3000_surang}EA";
}
$pipe_count_text = implode(', ', $pipe_counts);
if ($pipe_price_3000_surang < 1) {
$pipe_price_3000 = 0;
}
if ($pipe_price_3000_surang > 0) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
// 항목 이름
echo '<td class="text-center"> 각파이프(3000) </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($pipe_price_3000_surang) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (EA)
echo '<td class="text-center"> EA </td>';
// 산출식 입력 필드 (각파이프 수량 텍스트)
echo '<td class="text-end"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $pipe_count_text . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" /></td>';
// 원자재 단가 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($pipe_price_3000) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($pipe_price_3000 * $pipe_price_3000_surang) . '</td>';
echo '</tr>';
$rowCount++;
}
// 각 파이프 수량을 텍스트로 변환
$pipe_counts = [];
if ($pipe_price_6000_surang > 0) {
$pipe_counts[] = "6000x{$pipe_price_6000_surang}EA";
}
$pipe_count_text = implode(', ', $pipe_counts);
if ($pipe_price_6000_surang < 1) {
$pipe_price_6000 = 0;
}
$subtotal += ($pipe_price_3000 * $pipe_price_3000_surang + $pipe_price_6000 * $pipe_price_6000_surang);
if ($pipe_price_6000_surang > 0) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
// 항목 이름
echo '<td class="text-center"> 각파이프(6000) </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($pipe_price_6000_surang) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (EA)
echo '<td class="text-center"> EA </td>';
// 산출식 입력 필드 (각파이프 수량 텍스트)
echo '<td class="text-end"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $pipe_count_text . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" /></td>';
// 원자재 단가 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($pipe_price_6000) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($pipe_price_6000 * $pipe_price_6000_surang) . '</td>';
echo '</tr>';
$rowCount++;
}
$tablename = 'price_angle';
$query = "SELECT itemList FROM {$DB}.$tablename WHERE is_deleted IS NULL OR is_deleted = 0 ORDER BY NUM LIMIT 1";
$stmt = $pdo->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$itemList = json_decode($row['itemList'], true);
// 4인치 3T (철재스라트용), 철재는 4T
$mainangle_price = calculateMainAngle(1, $itemList, '앵글4T', '2.5');
$mainangle_surang = intval(str_replace(',', '', $column['col77'])); // 수량
// 앵글 수량을 텍스트로 변환
$angle_counts = [];
if ($mainangle_surang > 0) {
$angle_counts[] = "2500x{$mainangle_surang}EA";
}
$angle_count_text = implode(', ', $angle_counts);
if ($mainangle_surang < 1) {
$mainangle_price = 0;
}
// 앵글
$subtotal += $mainangle_price * $mainangle_surang;
if ($mainangle_surang > 0) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
// 항목 이름
echo '<td class="text-center"> 앵글3T (2500) </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($mainangle_surang) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (EA)
echo '<td class="text-center"> EA </td>';
// 산출식 입력 필드 (앵글 수량 텍스트)
echo '<td class="text-end"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $angle_count_text . '" data-row="' . $counter . '" data-type="formula" /></td>';
// 면적(㎡) 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-center area-length-input number-input" value="" data-row="' . $counter . '" data-type="area_length" /></td>';
// 원자재 단가 필드 (빈 값)
echo '<td class="text-center"><input type="text" class="noborder-input text-end area-price-input number-input" value="" data-row="' . $counter . '" data-type="raw_materials_price" /></td>';
// 단가 입력 필드
echo '<td class="text-end"><input type="text" class="noborder-input text-end unit-price-input number-input" value="' . number_format($mainangle_price) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($mainangle_price * $mainangle_surang) . '</td>';
echo '</tr>';
$rowCount++;
}
echo '<tr data-serial="' . $counter . '" class="subtotal-row">';
echo '<td class="text-center" colspan="7"><strong>소계</strong></td>';
echo '<td class="text-end fw-bold subtotal-cell" data-serial="' . $counter . '"> </td>';
echo '</tr>';
array_push($subtotal_array, round($subtotal)) ;
array_push($subtotal_surang_array, $su) ;
array_push($row_array, $rowCount) ;
// 전체 합계에 소계를 더함
$total_sum += round($subtotal);
$rowCount++;
}
$counter++ ; // 전체 행카운트
}
echo '</tbody>';
echo '<tfoot>';
echo '<tr class="grand-total-row">';
echo '<td class="text-center lightgray" colspan="8"><strong>전체 합계</strong></td>';
echo '<td class="text-end lightgray fw-bold grand-total"> </td>';
echo '</tr>';
echo '</tfoot>';
echo '</table>';
echo '</div>';
echo '</div>';
$row_array_json = json_encode($row_array);
$korean_total_sum = number_to_korean($total_sum);
// PHP 배열을 JSON으로 변환
$subtotal_json = json_encode($subtotal_array);
$subtotal_surang_json = json_encode($subtotal_surang_array);
// 세부내역서 ###########################################################################################################
// 세부내역서 ###########################################################################################################
// 세부내역서 ###########################################################################################################
if (True) {
$data = [];
$counter = 0;
foreach ($decodedEstimateList as $item) {
if (isset($item['col5']) && !empty($item['col5'])) {
$counter++;
// 각 col 값을 배열에 추가합니다.
$row = [];
$row['col1'] = '2.1 <br> 본체(철재스라트)';
$row['col2'] = $item['col3'] ?? ''; // 부호
$row['col3'] = $item['col5'] ?? ''; // 실리카
if($steel == '1') {
$row['col4'] = $item['col7'] ?? ''; // SUS
$row['col5'] = $item['col6']; // 벽마감표시
}
else {
$row['col4'] = '';
$row['col5'] = '';
}
$row['col6'] = $item['col8']; // 오픈 가로
$row['col7'] = $item['col9']; // 오픈 세로
$row['col8'] = $item['col10']; // 제작 가로
$row['col9'] = $item['col11']; // 제작 세로
$row['col10'] = $item['col15']; // 수량
if($steel == '1') {
if ($item['col37'] === 'custom' ) {
$row['col11'] = $item['col37_custom']; // 사용자 제작 사이즈
} else {
$row['col11'] = $item['col37']; // 철재 케이스
}
}
else {
$row['col11'] = '';
}
// $data 배열에 행을 추가합니다.
$data[] = $row;
}
}
echo '<br>';
echo '<div class=" d-flex align-items-center justify-content-center listview">';
echo '<h3 class="listview vendor-send mb-2"> 소요자재 내역 </h3></div>';
echo '<div class="d-flex align-items-center justify-content-center listview vendor-send">';
echo '<table class="table avoid-break vendor-send" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th rowspan="2" class="text-center">구분</th>';
echo '<th rowspan="2" class="text-center">부호</th>';
echo '<th rowspan="2" class="text-center">종류</th>';
echo '<th colspan="2" class="text-center">가이드레일</th>';
echo '<th colspan="2" class="text-center">오픈사이즈</th>';
echo '<th colspan="2" class="text-center yellowredBold">제작사이즈</th>';
echo '<th rowspan="2" class="text-center ">수량</th>';
echo '<th rowspan="2" class="text-center blueBold ">케이스</th>';
echo '</tr>';
echo '<tr>';
echo '<th class="text-center">마감유형</th>';
echo '<th class="text-center">설치유형</th>';
echo '<th class="text-center">가로</th>';
echo '<th class="text-center">세로</th>';
echo '<th class="text-center yellowredBold">가로</th>';
echo '<th class="text-center yellowredBold">세로</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$col7_sum = 0; // col7 합계
$col10_sum = 0; // col10 합계
$col89_sum = 0; // col8 + col9 합계
$rowspan_applied = false; // rowspan이 적용되었는지 확인하는 플래그
$row_count = count($data); // 총 행 수
foreach ($data as $row) {
echo '<tr>';
// 첫 번째 열에만 rowspan 적용
if (!$rowspan_applied) {
echo '<td class="text-center fw-bold" rowspan="' . $row_count . '">' . $row['col1'] . '</td>';
$rowspan_applied = true;
}
// 나머지 열 출력 (색상을 부여하는 코드)
for ($i = 2; $i <= 11; $i++) { // col1은 이미 출력했으므로 col2부터 시작
switch ($i) {
case 9:
case 8:
// col3에 yellowBold 클래스를 적용하여 출력
echo '<td class="text-center text-primary yellowBold">' . htmlspecialchars($row['col' . $i]) . '</td>';
break;
case 11:
// col5에 blueBold 클래스를 적용하여 출력 (예시로 추가)
echo '<td class="text-center text-primary greenredBold">' . htmlspecialchars($row['col' . $i]) . '</td>';
break;
default:
// 기본적으로 fw-bold 클래스를 적용하여 출력
echo '<td class="text-center text-primary fw-bold">' . htmlspecialchars($row['col' . $i]) . '</td>';
break;
}
}
// 쉼표를 제거하고 숫자형으로 변환하여 합계 계산
$col7_sum += floatval(str_replace(',', '', $row['col7']));
$col10_sum += floatval(str_replace(',', '', $row['col10']));
$col89_sum += floatval(str_replace(',', '', $row['col8'])) + floatval(str_replace(',', '', $row['col9']));
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
echo '</div>';
}
// 모터 부분
if(True) {
// 함수 호출을 통해 계산된 값을 가져옴
$specifications = calculateMotorSpecifications_slat($decodedEstimateList); // 철재용 모터
// 초기화
$col1_sum = $col2_sum = $col3_sum = $col4_sum = $col5_sum = $col6_sum = 0;
$col7_sum = $col8_sum = $col9_sum = $col10_sum = $col11_sum = $col12_sum = 0;
$motor_supplier = $column['col19_brand'];
if ($motor_supplier === '경동(견적가포함)' || $motor_supplier === '대한') {
// 각 합계 값을 변수에 저장
$col1_sum = $specifications['col1_sum'];
$col2_sum = $specifications['col2_sum'];
$col3_sum = $specifications['col3_sum'];
$col4_sum = $specifications['col4_sum'];
$col5_sum = $specifications['col5_sum'];
$col6_sum = $specifications['col6_sum'];
$col7_sum = $specifications['col7_sum'];
$col8_sum = $specifications['col8_sum'];
$col9_sum = $specifications['col9_sum'];
$col10_sum = $specifications['col10_sum'];
$col11_sum = $specifications['col11_sum'];
}
if($motor == '1') { // 모터체크박스
$col12_sum = $specifications['col12_sum'];
}
else {
$col12_sum = 0;
}
echo ' <div class="d-flex align-items-center justify-content-center " >';
echo '<table class="table avoid-break Novendor-send" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th rowspan="3" class="text-center"> 2.2 <br> 모터 </th>';
echo '<th colspan="7" class="text-center"> 모터종류(KG)</th>';
echo '<th colspan="3" class="text-center"> 연동제어기 </th>';
echo '<th class="text-center">브라켓트</th>';
echo '<th class="text-center">앵글</th>';
echo '</tr>';
echo '<tr>';
echo '<th class="text-center">150</th>';
echo '<th class="text-center">300</th>';
echo '<th class="text-center">400</th>';
echo '<th class="text-center">500</th>';
echo '<th class="text-center">600</th>';
echo '<th class="text-center">800</th>';
echo '<th class="text-center">1000</th>';
echo '<th class="text-center">매립</th>';
echo '<th class="text-center">노출</th>';
echo '<th class="text-center">뒷박스</th>';
echo '<th class="text-center">수량</th>';
echo '<th class="text-center">수량</th>';
echo '</tr>';
echo '<tr>';
echo '<th class="text-center text-primary fw-bold">' . ($col1_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col2_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col3_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col5_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col6_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col7_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col8_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col9_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col10_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col11_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($col12_sum ?: '') . '</th>';
echo '</tr>';
echo '</thead>';
echo '</table>';
echo '</div>';
}
// 절곡 부분
if (True) {
$data = [];
// 누적 합계를 저장할 변수들
$row3_1_sum = 0;
$row3_2_sum = 0;
$row3_3_sum = 0;
$row3_4_sum = 0;
$row3_5_sum = 0;
// 누적 합계를 저장할 변수들
$row5_1_sum = 0;
$row5_2_sum = 0;
$row5_3_sum = 0;
$row5_4_sum = 0;
$row5_5_sum = 0;
$row5_6_sum = 0;
$row5_7_sum = 0; // col39의 합 상부덮개
$row5_8_sum = 0; // col41의 합
$row7_1_sum = 0; // 하단마감재
$row7_2_sum = 0; //
$row7_3_sum = 0; //
$row8_1_sum = 0; // 하단마감재
$row8_2_sum = 0; //
$row8_3_sum = 0; //
$row10_1_sum = 0;
$row10_2_sum = 0;
$row10_3_sum = 0;
$row10_4_sum = 0;
$row10_5_sum = 0;
$row10_6_sum = 0;
foreach ($decodedEstimateList as $item) {
$ValidLength = floatval($item['col24']); // 가이드레일 사이즈
$surang = floatval($item['col15']); // 수량
// 가이드레일
$row3_1_sum += floatval($item['col25']);
$row3_2_sum += floatval($item['col26']);
$row3_3_sum += floatval($item['col27']);
$row3_4_sum += floatval($item['col28']);
$row3_5_sum += floatval($item['col29']);
// 케이스
$row5_1_sum += floatval($item['col39']);
$row5_2_sum += floatval($item['col40']);
$row5_3_sum += floatval($item['col41']);
$row5_4_sum += floatval($item['col42']);
$row5_5_sum += floatval($item['col43']);
$row5_6_sum += floatval($item['col44']);
// 5열 7행 상부덮개, 마구리
$row5_7_sum += floatval($item['col45']);
$row5_8_sum += floatval($item['col47']);
// 레일용 연기차단재/ 케이스용 연기차단재
$row10_1_sum += floatval($item['col32']); // 레일용 연기차단제 5종류 나열
$row10_2_sum += floatval($item['col33']);
$row10_3_sum += floatval($item['col34']);
$row10_4_sum += floatval($item['col35']);
$row10_5_sum += floatval($item['col36']);
$row10_6_sum += floatval($item['col48']); // 케이스용 연기차단제
// 하장바
$row7_1_sum += floatval($item['col50']);
$row8_1_sum += floatval($item['col51']);
}
// 테이블 출력
echo '<div class="d-flex align-items-center justify-content-center">';
echo '<table class="table avoid-break Novendor-send" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th rowspan="10" class="text-center"> 2.3 <br> 절곡 </th>';
echo '<th colspan="2" class="text-center"> (1) 가이드레일 <br> (EGI 1.6T/ SUS 1.2T) </th>';
echo '<th colspan="2" class="text-center"> (2) 케이스 <br> (EGI 1.6T) </th>';
echo '<th colspan="3" class="text-center"> (3) 하단마감재 <br> (SUS 1.2T) </th>';
echo '<th colspan="3" class="text-center"> (4) 연기차단재 </th>';
echo '</tr>';
echo '<tr>'; // 2행
echo '<th class="text-center">사이즈</th>';
echo '<th class="text-center">수량</th>';
echo '<th class="text-center">사이즈</th>';
echo '<th class="text-center">수량</th>';
echo '<th class="text-center">분류</th>';
echo '<th class="text-center">3000</th>';
echo '<th class="text-center">4000</th>';
echo '<th class="text-center">분류</th>';
echo '<th class="text-center">사이즈</th>';
echo '<th class="text-center">수량</th>';
echo '</tr>';
echo '<tr>'; // 3행
echo '<th class="text-center">2438</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row3_1_sum ?: '') . '</th>';
echo '<th class="text-center">1219</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_1_sum ?: '') . '</th>';
echo '<th rowspan="3" class="text-center"> 하단마감재 <br> (SUS 1.2T) </th>';
echo '<th rowspan="3" class="text-center text-primary fw-bold">' . ($row7_1_sum ?: '') . '</th>';
echo '<th rowspan="3" class="text-center text-primary fw-bold">' . ($row8_1_sum ?: '') . '</th>';
echo '<th rowspan="5" class="text-center">레일용</th>';
echo '<th rowspan="1" class="text-center text-dark fw-bold">2438 </th>';
echo '<th rowspan="1" class="text-center text-primary fw-bold">' . ($row10_1_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 4행
echo '<th class="text-center">3000</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row3_2_sum ?: '') . '</th>';
echo '<th class="text-center">2438</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_2_sum ?: '') . '</th>';
echo '<th rowspan="1" class="text-center text-dark fw-bold"> 3000 </th>';
echo '<th rowspan="1" class="text-center text-primary fw-bold">' . ($row10_2_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 5행
echo '<th class="text-center">3500</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row3_3_sum ?: '') . '</th>';
echo '<th class="text-center">3000</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_3_sum ?: '') . '</th>';
echo '<th rowspan="1" class="text-center text-dark fw-bold"> 3500 </th>';
echo '<th rowspan="1" class="text-center text-primary fw-bold">' . ($row10_3_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 6행
echo '<th class="text-center">4000</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row3_4_sum ?: '') . '</th>';
echo '<th class="text-center">3500</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_4_sum ?: '') . '</th>';
echo '<th rowspan="3" colspan="3" class="text-center"> </th>';
echo '<th rowspan="1" class="text-center text-dark fw-bold"> 4000 </th>';
echo '<th rowspan="1" class="text-center text-primary fw-bold">' . ($row10_4_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 7행
echo '<th class="text-center">4300</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row3_5_sum ?: '') . '</th>';
echo '<th class="text-center">4000</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_5_sum ?: '') . '</th>';
echo '<th rowspan="1" class="text-center text-dark fw-bold"> 4300 </th>';
echo '<th rowspan="1" class="text-center text-primary fw-bold">' . ($row10_5_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 8행
echo '<th rowspan="3" colspan="2" class="text-center"> </th>';
echo '<th class="text-center">4150</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_6_sum ?: '') . '</th>';
echo '<th rowspan="1" class="text-center">케이스용</th>';
echo '<th rowspan="1" class="text-center">3000</th>';
echo '<th rowspan="1" class="text-center text-primary fw-bold">' . ($row10_6_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 9행
echo '<th class="text-center">상부덮개</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_7_sum ?: '') . '</th>';
echo '<th rowspan="3" colspan="5" class="text-center"> </th>';
echo '</tr>';
echo '<tr>'; // 10행
echo '<th class="text-center">마구리</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_8_sum ?: '') . '</th>';
echo '</tr>';
echo '</thead>';
echo '</table>';
echo '</div>';
}
// 부자재 (감기샤프트 등) 부분
if (True) {
$data = [];
$row2_4_sum = 0;
$row3_4_sum = 0;
$row4_4_sum = 0;
$row5_4_sum = 0;
$row6_4_sum = 0;
$row7_4_sum = 0;
$row8_4_sum = 0;
$row9_4_sum = 0;
$row10_4_sum = 0;
$row11_4_sum = 0;
$row12_4_sum = 0;
$row13_4_sum = 0;
$row2_7_sum = 0;
$row4_7_sum = 0;
$row5_7_sum = 0;
$row6_7_sum = 0;
$row7_7_sum = 0;
$row8_7_sum = 0;
foreach ($decodedEstimateList as $item) {
// 조인트바
$col76 = floatval($item['col76']);
// 각파이프
$col74 = floatval($item['col74']);
$col75 = floatval($item['col75']);
// 앵글
$col77 = floatval($item['col77']);
$col61 = floatval($item['col61']);
$col62 = floatval($item['col62']);
$col63 = floatval($item['col63']);
$col64 = floatval($item['col64']);
$col65 = floatval($item['col65']);
$col66 = floatval($item['col66']);
$col67 = floatval($item['col67']);
$col68 = floatval($item['col68']);
$col69 = floatval($item['col69']);
$col70 = floatval($item['col70']);
$col71 = floatval($item['col71']);
$row2_4_sum += $col61;
$row3_4_sum += $col62;
$row4_4_sum += $col63;
$row5_4_sum += $col64;
$row6_4_sum += $col65;
$row7_4_sum += $col66;
$row8_4_sum += $col67;
$row9_4_sum += $col68;
$row10_4_sum += $col69;
$row11_4_sum += $col70;
$row12_4_sum += $col71;
// 부속자재
$row2_7_sum += $col76; // 조인트바
$row4_7_sum += $col74; // 각파이프 3000
$row5_7_sum += $col75; // 각파이프 6000
$row6_7_sum += $col77; // 앵글 2500
}
echo '<div class=" d-flex align-items-center justify-content-center">';
echo '<table class="table avoid-break Novendor-send" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th rowspan="7" class="text-center"> 2.4 <br> 부자재 </th>';
echo '<th colspan="11" class="text-center"> 감기샤프트 </th>';
echo '</tr>';
echo '<tr>'; // 2행
echo '<th colspan="3" class="text-center">4인치</th>';
echo '<th colspan="3" class="text-center">5인치</th>';
echo '<th colspan="4" class="text-center">6인치</th>';
echo '<th colspan="1" class="text-center">8인치</th>';
echo '</tr>';
echo '<tr>'; // 3행
echo '<th class="text-center">3000</th>';
echo '<th class="text-center">4500</th>';
echo '<th class="text-center">6000</th>';
echo '<th class="text-center">6000</th>';
echo '<th class="text-center">7000</th>';
echo '<th class="text-center">8200</th>';
echo '<th class="text-center">3000</th>';
echo '<th class="text-center">6000</th>';
echo '<th class="text-center">7000</th>';
echo '<th class="text-center">8000</th>';
echo '<th class="text-center">8200</th>';
echo '</tr>';
echo '<tr>'; // 4행
echo '<th class="text-center text-primary fw-bold">' . ($row2_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row3_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row4_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row6_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row7_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row8_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row9_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row10_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row11_4_sum ?: '') . '</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row12_4_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 5행
echo '<th colspan="2" class="text-center"> 조인트바 </th>';
echo '<th colspan="2" class="text-center"> 각파이프 </th>';
echo '<th colspan="2" class="text-center"> 앵글 </th>';
echo '<th colspan="6" class="text-center"> </th>';
echo '</tr>';
echo '<tr>'; // 6행
echo '<th colspan="2" class="text-center"> 300 </th>';
echo '<th class="text-center"> 3000 </th>';
echo '<th class="text-center"> 6000 </th>';
echo '<th colspan="2" class="text-center"> 2500 </th>';
echo '<th colspan="6" class="text-center"> </th>';
echo '</tr>';
echo '<tr>'; // 7행
echo '<th colspan="2" class="text-center text-primary fw-bold">' . ($row2_7_sum ?: '') . '</th>';
echo '<th colspan="1" class="text-center text-primary fw-bold">' . ($row4_7_sum ?: '') . '</th>';
echo '<th colspan="1" class="text-center text-primary fw-bold">' . ($row5_7_sum ?: '') . '</th>';
echo '<th colspan="2" class="text-center text-primary fw-bold">' . ($row7_7_sum ?: '') . '</th>';
echo '<th colspan="6" class="text-center"> </th>';
echo '</tr>';
echo '</thead>';
echo '</table>';
echo '</div>';
}
// 비고
if($option == 'option') {
echo '<div class="d-flex align-items-center justify-content-center mt-1 mb-5 ">';
echo '<table class="table" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th class="text-center"> 특이사항 </th>';
echo '<th colspan="5" class="text-start">
해당 견적서의 유효기간은 <span class="text-danger" style="text-decoration: underline;"> 발행일 기준 1개월 </span> 입니다. <br>
견적금액의 50% 입금하시면 발주가 진행됩니다.
</th>';
echo '</tr>';
echo '<tr>'; // 2행
echo '<th class="text-center">결제방법</th>';
echo '<th class="text-center">계좌이체</th>';
echo '<th colspan="2" class="text-center">계좌정보</th>';
echo '<th colspan="2" class="text-center">국민은행 796801-00-039630</th>';
echo '</tr>';
echo '<tr>'; // 3행
echo '<th class="text-center">담당자</th>';
echo '<th class="text-center"> ' . $orderman . ' ' . $position . '</th>';
echo '<th colspan="1" class="text-center">연락처</th>';
echo '<th colspan="1" class="text-center">070-4351-5275</th>';
echo '<th colspan="1" class="text-center">E-mail</th>';
echo '<th colspan="1" class="text-center"> <span class="text-primary" > kd5130@naver.com </span> </th>';
echo '</tr>';
echo '</thead>';
echo '</table>';
echo '</div>';
echo '</div>';
}
?>