Files
sam-kd/estimate/slat_view_modified.php
hskwon aca1767eb9 초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경
- DB 연결 하드코딩 → .env 기반으로 변경
- MySQL strict mode DATE 오류 수정
2025-12-10 20:14:31 +09:00

1135 lines
54 KiB
PHP

<?php
// 전체 SET 내역 표시 일련번호, 종류, 부호, 제품명, 오픈사이즈 등 전체금액 나오는 부분
// echo '<pre>';
// print_r($decodedEstimateList);
// echo '</pre>';
if(True) {
$data = [];
$counter = 0;
$index = 0;
$sums = []; // 각 행의 합을 저장할 배열
// 검사비 5만원 처음 들어감
$inspectionFee = 50000 ;
// 전체 반복 찾기
foreach ($decodedEstimateList as $item) {
if (isset($item['col5']) && !empty($item['col5'])) {
// 각 행별 합계 재계산
// 검사비 10만원 처음 들어감 5만원으로 수정
$sums[$counter] = $inspectionFee ;
$su = floatval($item['col14']);
// 행의 나머지 데이터를 설정
$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">일련번호</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>';
echo '<th class="text-center">합계</th>';
echo '</tr>';
echo '<tr>';
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 . '">';
for ($i = 1; $i <= 10; $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" data-serial="' . $row_count . '" ></td>'; // 단가가 들어가는 셀
break;
case 10:
echo '<td class="text-end text-primary fw-bold subtotal-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>';
echo '<td id="subtotal" class="text-end text-primary fw-bold grand-total"></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> 세부 산출내역서 </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">일련번호</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']; // 벽면형(120*70), 혼합형(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 = 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 KDSS01은 다른규격 가져옴
if ($prodcode == $modelCode && $seconditem == 'L-BAR' && $unitprice_value > 0) {
$LBarPrices = $unitprice_value;
}
// 마구리 (ex: 마구리 650*550)
if ($seconditem == '마구리 ' . $maguriCol && $unitprice_value > 0) {
$maguriPrices = $unitprice_value;
}
}
// 가이드레일 단가 계산
$baseKey = $modelCode . '|' . $finishing; // 기본 키 생성
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 {
// 벽면형 또는 측면형 처리 (예: 벽면형(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();
}
// 각 행별 합계 재계산
// 주자재 계산
$tablename_mainslat = 'price_raw_materials';
$query = "SELECT itemList FROM {$DB}.$tablename_mainslat WHERE is_deleted IS NULL OR is_deleted = 0 ";
$stmt = $pdo->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // 모든 행을 가져옴
$price_raw_materials = 0;
$price_jointbar = 0;
// 모든 행을 순회하면서 원하는 데이터를 찾음
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;
}
// col12도 숫자형으로 변환
$area = floatval($column['col12']);
// 견적서 엑셀을 보면 철재스라트일때 높이를 900 더해준다. 기준 산출기준서에는 +350인데, 견적서는 +900적용 주의
// 그러므로, 여기서는 다시 계산해야 한다. ( +550 더해준다.)
// 철재 견적서 및 발주서의 금액은 세로 + 400 적용함
$calculateHeight = floatval($column['col9']) + 400 ;
$area = floatval($column['col10']) * $calculateHeight / 1000000 ;
// 모터가격 계산
$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']);
// print_r($result);
$price = getPriceForMotor($motorSpec, $itemList);
$motorUnit_price = $price;
// 매립 연동제어기 가격 계산
$price1 = calculateControllerSpec($column['col16'], $itemList, '매립형');
$sums[$counter] += $price; // 매립 연동제어기 가격 합산
// 노출 연동제어기 가격 계산
$price2 = calculateControllerSpec($column['col17'], $itemList, '노출형');
$sums[$counter] += $price; // 노출 연동제어기 가격 합산
$price_controller = $price1 + $price2;
// 뒷박스 계산
$price = calculateControllerSpec($column['col18'], $itemList, '뒷박스');
// echo "뒷박스 가격: " . $price . "\n";
$price_controller += $price;
// 모터 받침용 앵글 가계
$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_angle = 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에서 제품코드별로 가져와야 합니다.
$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 )
{
$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],2);
$basicbox_price = round($shutterBoxprices['650*550'],2); // 기본650*550 가격;
list($boxwidth, $boxheight) = explode('*', $shutterBox);
if ($shutter_price < 1) {
$shutterboxMsg .= $shutterBox . ' 단가표에 케이스 크기 정의 필요함!' ;
}
// 단가 계산
if (array_key_exists($shutterBox, $shutterBoxprices)) {
$price = $su * ($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="dynamicRowspanCompare-' . $counter . '">' . $column['col1'] . '</td>'; // 일련번호 자동통합 주의
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>';
// 단위 및 기타 필드
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 = floatval($price_raw_materials * round($area,2)) ;
$subtotal += $slat_price * $su;
if($slat_price > 0 )
{
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
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>';
// 단위 및 기타 필드
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 ($price_quartz > 0) {
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
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>';
// 단위 및 기타 필드
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($price_jointbar > 0 )
{
// calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가
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( 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">모터</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;
$subtotal += $controller_price * $su;
if ($controller_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">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_price * $su) . '</td>';
echo '</tr>';
$rowCount++;
}
// 케이스
if ($column['col37'] === 'custom') {
$shutterBox = $column['col37_custom']; // 사용자 제작 사이즈
} else {
$shutterBox = $column['col37']; // 케이스 500*380
}
$shutter_price = round($shutterBoxprices[$shutterBox],2);
// echo '<br>';
// print_r($shutter_price);
// echo '<br>';
if ($shutter_price < 1) {
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 += $shutter_price * $total_length ;
if($total_length > 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">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 = ceil($boxSmokeBanPrices);
$total_length = round(floatval($column['col38']) / 1000, 2);
$subtotal += $boxSmokeBanPrices * $total_length ;
if($total_length > 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-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 )
{
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">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_angle = ceil($price_angle);
$angle_price = $price_angle;
$subtotal += $angle_price * $su * 4;
if($angle_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 * 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참조
$total_length = round(floatval($column['col24']) / 1000,2) * $su;
$guidrail_price = ceil($guidrail_price);
$subtotal += $guidrail_price * $total_length;
// print_r($guidrail_price * $total_length);
if ($total_length > 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"> 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($guidrail_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($guidrail_price * $total_length) . '</td>';
echo '</tr>';
$rowCount++;
}
//가이드레일용 연기차단재 레일 높이 + 250 적용해서 만드는 것임
$total_length = round(floatval($column['col24']) / 1000, 2);
$guiderailSmokeBanPrices = ceil($guiderailSmokeBanPrices);
$subtotal += $guiderailSmokeBanPrices * $total_length * 2 ;
if ($total_length > 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"> 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($guiderailSmokeBanPrices * $total_length ) . '</td>';
echo '</tr>';
$rowCount++;
}
// 하단마감재(하장바)
$total_length = intval($column['col49']) * $su; // 전체 길이에 대해서 곱해준다. 견적서는 몇가지가 이렇게 적용됨 길이 * 면적단가 =
$total_length = round($total_length / 1000,2);
$bottomBarPrices = ceil($bottomBarPrices);
$subtotal += ceil($bottomBarPrices * $total_length);
if ($total_length > 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"> 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', '8200', $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,2)) ;
array_push($subtotal_surang_array, $su) ;
array_push($row_array, $rowCount) ;
// 전체 합계에 소계를 더함
$total_sum += round($subtotal,2);
$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>';
$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);
?>
</div> <!-- end of container -->