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

1822 lines
83 KiB
PHP

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
$title_message = '(스크린) 견적 산출내역서 ';
$title_message_sub = '견 적 서 (스크린)' ;
$tablename = 'estimate';
$item ='(스크린) 견적 산출내역서 ';
$emailTitle ='견적서';
$subTitle = '자동방화셔터 스크린인정제품';
?>
<?php include $_SERVER['DOCUMENT_ROOT'] . '/' . $tablename . '/common/estimate_head.php'; ?> <!-- head 정보 불러오기 -->
<?php
// 전체 SET 내역 표시 일련번호, 종류, 부호, 제품명, 오픈사이즈 등 전체금액 나오는 부분
if(True) {
$data = [];
$counter = 0;
$index = 0;
$sums = []; // 각 행의 합을 저장할 배열
// 전체 반복 찾기
foreach ($decodedEstimateList as $item) {
if (isset($item['col5']) && !empty($item['col5'])) {
// 각 행별 합계 재계산
// 검사비 10만원 처음 들어감
$sums[$counter] = 100000 ;
$su = floatval($item['col14']);
$itemTitle = floatval($item['col5']);
if($itemTitle == '실리카')
$itemTitle = '스크린';
else
$itemTitle = '와이어';
// 행의 나머지 데이터를 설정
$row = [];
$row['col1'] = $counter + 1;
$row['col2'] = $itemTitle ;
$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['col14']; // 수량
$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++;
$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>';
echo '<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['col14']); // 수량
// 데이터베이스 테이블 이름 설정 (셔터박스)
$tablename = 'bendingfee';
try {
$sql = "SELECT * FROM " . $DB . "." . $tablename;
$stmh = $pdo->prepare($sql);
$stmh->execute();
$count = $stmh->rowCount();
if ($count < 1) {
print "검색결과가 없습니다.<br>";
} else {
// 셔터박스 단가 정보를 저장할 배열
$shutterBoxprices = [];
// 정규표현식 패턴 (숫자 형식만 매칭)
$pattern = '/\d{3}\*\d{3}/';
// echo '<pre>';
// print_r($row);
// echo '</pre>';
// 전체 데이터를 반복 처리
while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
$firstitem = isset($row['firstitem']) ? $row['firstitem'] : '';
$seconditem = isset($row['seconditem']) ? $row['seconditem'] : '';
$proditem = isset($row['proditem']) ? $row['proditem'] : ''; // 셔터박스 데이터 (단순 문자열)
// 첫 번째 아이템이 '케이스'인 경우
if ($seconditem == '케이스') {
// $proditem에서 개행 문자를 제거하고 정리
$proditem_clean = preg_replace("/\r|\n/", '', $proditem);
// 정규식 패턴을 이용해 숫자 추출 (예: '500*350')
if (preg_match($pattern, $proditem_clean, $matches)) {
$extract = $matches[0]; // '500*350' 형식의 패턴 추출
// echo '$extract' . $extract;
// $row['unitprice'] 값이 존재하고, 콤마 제거 후 유효한지 확인
if (isset($row['unitprice']) && $row['unitprice'] !== '') {
$unitprice_clean = preg_replace('/[^0-9.]/', '', $row['unitprice']); // 단가에서 숫자와 소수점만 남기기
// floatval()로 변환된 값이 0보다 큰지 확인
if (floatval($unitprice_clean) > 0) {
// 변환된 값으로 배열에 저장
$shutterBoxprices[$extract] = floatval($unitprice_clean);
}
}
}
}
}
// // 결과 출력 (확인용)
// echo '<pre>';
// print_r($shutterBoxprices);
// echo '</pre>';
}
} catch (PDOException $Exception) {
print "오류: " . $Exception->getMessage();
}
// 각 행별 합계 재계산
// 검사비 10만원 처음 들어감
$inspectionFee = 100000 ;
// 주자재 계산
$tablename = 'price_raw_materials';
$query = "SELECT itemList FROM {$DB}.$tablename 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;
}
// col12도 숫자형으로 변환
$area = floatval($column['col12']);
// 견적서 엑셀을 보면 스크린일때 높이를 900 더해준다. 기준 산출기준서에는 +350인데, 견적서는 +900적용 주의
// 그러므로, 여기서는 다시 계산해야 한다. ( +550 더해준다.)
// 견적서 및 발주서의 금액은 세로 + 900 적용함
$calculateHeight = floatval($column['col9']) + 900 ;
$area = floatval($column['col10']) * $calculateHeight / 1000000 ;
// 모터가격 계산
$tablename = 'price_motor';
$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);
$motorSpec =calculateMotorSpec($column , $column['col13'] ,$column['col58']);
// print_r($motorSpec);
$price = getPriceForMotor($motorSpec, $itemList);
$motorUnit_price = $price;
// 매립 연동제어기 가격 계산
$price1 = calculateControllerSpec($column['col15'], $itemList, '매립형');
$sums[$counter] += $price; // 매립 연동제어기 가격 합산
// 노출 연동제어기 가격 계산
$price2 = calculateControllerSpec($column['col16'], $itemList, '노출형');
$sums[$counter] += $price; // 노출 연동제어기 가격 합산
$price_controller = $price1 + $price2;
// 뒷박스 계산
$price = calculateControllerSpec($column['col17'], $itemList, '뒷박스');
// echo "뒷박스 가격: " . $price . "\n";
$price_controller += $price;
// 모터 받침용 앵글 가계
$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);
// 스크린용 앵글 가격가져오기
$price_angle = calculateAngle($column['col14'], $itemList, '스크린용'); // 수량, 리스트, 스크린용
// print_r($itemList );
// print_r($price_angle );
// 4인치 3T (스크린용) 철재는 4T
$mainangle_price = calculateMainAngle($column['col14'], $itemList, '앵글3T' , '2.5' );
$mainangle_surang = intval(str_replace(',', '', $column['col71'])); // 앵글 수량
// BOM에서 제품코드별로 가져와야 합니다.
$tablename = 'bendingfee';
$query = "SELECT * FROM {$DB}.$tablename WHERE is_deleted IS NULL OR is_deleted = 0 ORDER BY NUM";
$stmt = $pdo->prepare($query);
$stmt->execute();
// 가이드레일 단가
$guidrail_price = 0 ;
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$firstitem = $row['firstitem'];
$seconditem = $row['seconditem'];
$prodcode = $row['prodcode'];
$proditem = $row['proditem'];
$material = $row['material'];
$itemcode = $row['itemcode'];
$unit = $row['unit'];
$unitprice = $row['unitprice'];
// '마감'이라는 단어 제거 후 비교
$col7_clean = str_replace('마감', '', $column['col7']);
// 조건에 맞는 경우 guidrail_price 설정 코드, 가이드레일, 형태(벽면,측면,혼합), 마감재질
if ($prodcode == $column['col4'] && $seconditem == '가이드레일' && $proditem == $column['col6'] && $col7_clean == $material ) { // col6은 벽면형 측면형
$guidrail_price = floatval(str_replace(',', '', $unitprice));
}
}
if($guidrail_price < 1 )
{
$shutterboxMsg .= '가이드레일 단가가 정의되지 않았습니다. 단가를 생성해주세요. [절곡BOM] 메뉴 이용! ';
$shutterboxMsg .= '$prodcode : ' . $prodcode . ' ';
$shutterboxMsg .= '$seconditem : ' . $seconditem . ' ';
$shutterboxMsg .= '$material : ' . $material . ' ';
$shutterboxMsg .= '$proditem : ' . $proditem . ' ';
$shutterboxMsg .= '$col7_clean :' . $col7_clean . ' ';
}
// echo '<pre>';
// print_r($guidrail_price);
// echo '</pre>';
// 셔터박스 크기
if ($column['col36'] === 'custom') {
$dimension = $column['col36_custom']; // 사용자 제작 사이즈
} else {
$dimension = $column['col36']; // 케이스 500*380
}
// echo '<pre>';
// print_r($dimension);
// echo '</pre>';
// 단가 계산
if (array_key_exists($dimension, $shutterBoxprices)) {
$price = ($shutterBoxprices[$dimension] / 1000) ;
} else {
$price = 0; // 조건이 맞지 않는 경우 0으로 설정
}
// 데이터베이스 테이블 이름 설정 (하단마감재 3가지 합계 하장바+L바+평철)
try {
$sqltmp = "SELECT * FROM {$DB}.bendingfee ";
$stmhtmp = $pdo->prepare($sqltmp);
$stmhtmp->execute();
$count = $stmhtmp->rowCount();
if ($count > 0) {
$bottomBarPrices = 0;
// 전체 데이터를 반복 처리
$itemsep = substr($column['col4'], 0, 2) === 'KS' ? '스크린' : '철재'; // E8은 'KS'로 시작하는지 확인
$ETprocode = $column['col4'];
$itemfinal = str_replace('마감', '', $column['col7']);
$bottomBarPrices = 0;
$LBarPrices = 0;
$bottomPlatePrices = 0;
while ($rowtmp = $stmhtmp->fetch(PDO::FETCH_ASSOC)) {
$firstitem = $rowtmp['firstitem'] ?? '';
$seconditem = $rowtmp['seconditem'] ?? '';
$proditem = $rowtmp['proditem'] ?? '';
$prodcode = $rowtmp['prodcode'] ?? '';
$material = $rowtmp['material'] ?? '';
$memo = $rowtmp['memo'] ?? '';
// '마감'이라는 단어 제거 후 비교
$col7_clean = str_replace('마감', '', $column['col7']);
if ($prodcode == $column['col4'] && $proditem == '하장바' && $col7_clean == $material) {
// $proditem에서 개행 문자를 제거하고 정리
$proditem_clean = preg_replace("/\r|\n/", '', $proditem);
if (isset($rowtmp['unitprice']) && $rowtmp['unitprice'] !== '') {
$unitprice_clean = preg_replace('/[^0-9.]/', '', $rowtmp['unitprice']);
if (floatval($unitprice_clean) > 0) {
$bottomBarPrices = floatval($unitprice_clean);
}
}
}
if ($proditem == 'L바' && strpos($memo, $column['col4']) !== true) {
$proditem_clean = preg_replace("/\r|\n/", '', $proditem);
if (isset($rowtmp['unitprice']) && $rowtmp['unitprice'] !== '') {
$unitprice_clean = preg_replace('/[^0-9.]/', '', $rowtmp['unitprice']);
if (floatval($unitprice_clean) > 0) {
$LBarPrices = floatval($unitprice_clean);
}
}
}
if ($proditem == '보강평철' && strpos($memo, $column['col4']) !== true) {
$proditem_clean = preg_replace("/\r|\n/", '', $proditem);
if (isset($rowtmp['unitprice']) && $rowtmp['unitprice'] !== '') {
$unitprice_clean = preg_replace('/[^0-9.]/', '', $rowtmp['unitprice']);
if (floatval($unitprice_clean) > 0) {
$bottomPlatePrices = floatval($unitprice_clean);
}
}
}
if ($proditem == '가이드레일용 연기차단재') {
if (isset($rowtmp['unitprice']) && $rowtmp['unitprice'] !== '') {
$unitprice_clean = preg_replace('/[^0-9.]/', '', $rowtmp['unitprice']);
if (floatval($unitprice_clean) > 0) {
$guiderailSmokeBanPrices = floatval($unitprice_clean);
}
}
}
if ($proditem == '셔터박스용 연기차단재') {
if (isset($rowtmp['unitprice']) && $rowtmp['unitprice'] !== '') {
$unitprice_clean = preg_replace('/[^0-9.]/', '', $rowtmp['unitprice']);
if (floatval($unitprice_clean) > 0) {
$boxSmokeBanPrices = floatval($unitprice_clean);
}
}
}
if ($proditem == '마구리 ' . $column['col45']) { // 품목명 + 마구리외형 크기 (예시 : 마구리 785*655)
if (isset($rowtmp['unitprice']) && $rowtmp['unitprice'] !== '') {
$unitprice_clean = preg_replace('/[^0-9.]/', '', $rowtmp['unitprice']);
if (floatval($unitprice_clean) > 0) {
$maguriPrices = floatval($unitprice_clean);
}
}
}
}
}
} catch (PDOException $Exception) {
print "오류: " . $Exception->getMessage();
}
// $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"> 검사비 </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++;
}
// 주자재(스크린) 가격
$screen_price = floatval($price_raw_materials * round($area,2)) ;
$subtotal += $screen_price * $su;
if($screen_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($screen_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($screen_price * $su,2) . '</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['col36'] === 'custom') {
$shutterBox = $column['col36_custom']; // 사용자 제작 사이즈
} else {
$shutterBox = $column['col36']; // 케이스 500*380
}
$shutter_price = round($shutterBoxprices[$shutterBox],2);
$basicbox_price = round($shutterBoxprices['500*380'],2); // 기본 500*380 가격;
list($boxwidth, $boxheight) = explode('*', $shutterBox);
// echo '<br>';
// echo '<pre>';
// print_r($shutterBoxprices);
// echo '</pre>';
if ($shutter_price < 1) {
$basicbox_pricePermeter = $basicbox_price/(500*380/1000);
$shutter_price = $basicbox_pricePermeter * floatval($boxwidth) * floatval($boxheight) / 1000;
if($basicbox_price>$shutter_price )
$shutter_price = $basicbox_price ;
$shutterboxMsg = $shutterBox . ' 셔터박스 크기 정의 없음, m당 기본사이즈 500*380 가격 (크기가 작아도 최소가격은 표준가격임) : ' . number_format($basicbox_price) . '(원)' ;
$shutterboxMsg .= ' m당 단가 : ' . number_format($basicbox_pricePermeter) . '(원)' ;
$shutterboxMsg .= ' m단위로 설정된 단가 : ' . number_format($shutter_price) . '(원)' ;
// echo $shutterBox . ' 셔터박스 크기에 대한 단가가 정의되지 않았습니다. 단가를 생성해주세요. [절곡BOM] 메뉴 이용! <br> '. ' 1m당 기본사이즈 500*380 가격 : ' . number_format($basicbox_price) . '(원)' ;
// echo '<br> m당 단가 : ' . number_format($basicbox_pricePermeter) . '(원)' ;
// echo '<br> m단위로 설정된 단가 : ' . number_format($shutter_price) . '(원)' ;
}
$total_length = round(floatval($column['col37']) / 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="' . $dimension . '" 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_ea = intval($column['col47']);
$total_length = round(floatval($column['col37']) / 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 ) . '" 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['col45'] . '" 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['col22'] . '" 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['col23']) / 1000,2);
$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['col23']) / 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 * 2) . '" 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 * 2) . '</td>';
echo '</tr>';
$rowCount++;
}
// 하단마감재(하장바)
// 혼합형이 아니면 1SET는 *2를 적용
$total_length = intval($column['col48']) * $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++;
}
// 하단마감재(L바)
// 혼합형이 아니면 1SET는 *2를 적용
$total_length = intval($column['col51']) * $su; // 2개가 1SET , 하지만 단가가 2개가 1세트로 계산된 단가임 주의요함
$total_length = $total_length / 1000;
$subtotal += $LBarPrices * $total_length;
if ($total_length > 0 ) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
echo '<td class="text-center"> L바 </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="2개가 1SET 단가로 적용" 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($LBarPrices) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($LBarPrices * $total_length) . '</td>';
echo '</tr>';
$rowCount++;
}
// 하단마감재(보강평철)
// 조건에 따른 가격 계산
$total_length = intval($column['col54']) * $su;
$total_length = $total_length / 1000;
$subtotal += $bottomPlatePrices * $total_length * $su;
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="2000" 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($bottomPlatePrices) . '" data-row="' . $counter . '" data-type="unit_price" oninput="inputNumber(this)" /></td>';
// 합계 필드 (자동 계산, 입력 불가)
echo '<td class="text-end total-price" id="total-price-' . $counter . '">' . number_format($bottomPlatePrices * $total_length * $su) . '</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['col59'], $itemList, '3', '300', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col60'], $itemList, '4', '3000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col61'], $itemList, '4', '4500', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col62'], $itemList, '4', '6000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col63'], $itemList, '5', '6000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col64'], $itemList, '5', '7000', $sum_shaft_price, $shaft_counts);
addShaftPrice($column['col65'], $itemList, '5', '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);
$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++;
}
// 무게평철12T (2000)
// 무게평철 기준 단가 (2000mm당 12000원)
$basePrice = 12000;
$size = intval(str_replace(',', '', $column['col8'])) * 2; // 스크린 길이 * 2
$itemsep = (substr($column['col4'], 0, 2) === 'KS' || substr($column['col4'], 0, 2) === 'KW') ? '스크린' : '철재';
// 단계별 가격 계산 및 수량 저장을 위한 배열
$weight_plate_counts = [];
$priceFactor = 0;
// 스크린 하단 무게평철의 단계별 가격 계산 및 수량 저장
if ($itemsep == '스크린') {
if ($size <= 2000) {
$priceFactor = 1;
} elseif ($size <= 4000) {
$priceFactor = 2;
} elseif ($size <= 6000) {
$priceFactor = 3;
} elseif ($size <= 8000) {
$priceFactor = 4;
} elseif ($size <= 10000) {
$priceFactor = 5;
} elseif ($size <= 12000) {
$priceFactor = 6;
} elseif ($size <= 14000) {
$priceFactor = 7;
} elseif ($size <= 16000) {
$priceFactor = 8;
} elseif ($size <= 18000) {
$priceFactor = 9;
} elseif ($size <= 20000) {
$priceFactor = 10;
}
$priceFactor *= $su;
// 단계별 개수 저장
if ($priceFactor > 0) {
$weight_plate_counts[2000] = $priceFactor ; // 2000, 2000 x 1, ...,형식으로 저장
}
}
// 최종 단가 계산
$weight_plate_price = $basePrice * $priceFactor;
// 무게평철 수량을 텍스트로 변환
$weight_plate_count_text = [];
foreach ($weight_plate_counts as $length => $count) {
$weight_plate_count_text[] = "{$length}x{$count}EA";
}
$weight_plate_count_text = implode(', ', $weight_plate_count_text);
$total_length = intval(str_replace(',', '', $column['col57']));
$subtotal += $weight_plate_price ;
if ($weight_plate_price > 0) {
echo '<tr class="calculation-row" data-serial="' . $counter . '">';
// 항목 이름
echo '<td class="text-center"> 무게평철12T (2000) </td>';
// 수량 입력 필드
echo '<td class="text-center"><input type="text" class="noborder-input text-center su-input number-input" value="' . number_format($total_length) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center"> EA </td>';
// 산출식 입력 필드 (무게평철 수량 텍스트)
echo '<td class="text-end"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $weight_plate_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($weight_plate_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($weight_plate_price) . '</td>';
echo '</tr>';
$rowCount++;
}
// 환봉(3000) 기준 단가 (3000mm당 2000원)
$round_bar_price = 2000;
$round_bar_surang = intval(str_replace(',', '', $column['col70']));
// 3000mm 길이의 환봉 개수 저장
$round_bar_counts = [];
if ($round_bar_surang > 0) {
$round_bar_counts[3000] = $round_bar_surang;
}
// 환봉 수량을 텍스트로 변환
$round_bar_count_text = [];
foreach ($round_bar_counts as $length => $count) {
$round_bar_count_text[] = "{$length}x{$count}EA";
}
$round_bar_count_text = implode(', ', $round_bar_count_text);
if ($round_bar_surang < 1) {
$round_bar_price = 0;
}
$subtotal += $round_bar_price * $round_bar_surang;
if ($round_bar_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($round_bar_surang) . '" data-row="' . $counter . '" data-type="su" oninput="inputNumber(this)" /></td>';
// 단위 필드 (SET은 input에서 제외)
echo '<td class="text-center"> EA </td>';
// 산출식 입력 필드 (환봉 수량 텍스트)
echo '<td class="text-end"><input type="text" class="noborder-input text-end calc-formula-input" value="' . $round_bar_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($round_bar_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($round_bar_price * $round_bar_surang) . '</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['col68']));
$pipe_price_6000_surang = intval(str_replace(',', '', $column['col69']));
// 각 파이프 수량을 텍스트로 변환
$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, '앵글3T', '2.5');
$mainangle_surang = intval(str_replace(',', '', $column['col71'])); // 수량
// 앵글 수량을 텍스트로 변환
$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>';
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'] ?? ''; // 실리카
$row['col4'] = $item['col7'] ?? ''; // SUS
$row['col5'] = $item['col6']; // 벽마감표시
$row['col6'] = $item['col8']; // 오픈 가로
$row['col7'] = $item['col9']; // 오픈 세로
$row['col8'] = $item['col10']; // 제작 가로
$row['col9'] = $item['col11']; // 제작 세로
$row['col10'] = $item['col14']; // 수량
if ($item['col36'] === 'custom') {
$row['col11'] = $item['col36_custom']; // 사용자 제작 사이즈
} else {
$row['col11'] = $item['col36']; // 케이스 500*380
}
// $data 배열에 행을 추가합니다.
$data[] = $row;
}
}
echo '<br>';
echo '<div class="listview">';
echo '<div class=" d-flex align-items-center justify-content-center ">';
echo '<h3> 소요자재 내역 </h3> </div>';
echo '<div class=" d-flex align-items-center justify-content-center ">';
echo '<table 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 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($decodedEstimateList);
// 각 합계 값을 변수에 저장
$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'];
$col12_sum = $specifications['col12_sum'];
echo ' <div class="d-flex align-items-center justify-content-center " >';
echo '<table class="table" 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; //
foreach ($decodedEstimateList as $item) {
$ValidLength = floatval($item['col23']); // 가이드레일의 제작 길이
$surang = floatval($item['col14']); // 수량
// 가이드레일
$row3_1_sum += floatval($item['col24']);
$row3_2_sum += floatval($item['col25']);
$row3_3_sum += floatval($item['col26']);
$row3_4_sum += floatval($item['col27']);
$row3_5_sum += floatval($item['col28']);
// 케이스
$row5_1_sum += floatval($item['col38']);
$row5_2_sum += floatval($item['col39']);
$row5_3_sum += floatval($item['col40']);
$row5_4_sum += floatval($item['col41']);
$row5_5_sum += floatval($item['col42']);
$row5_6_sum += floatval($item['col43']);
// 5열 7행 상부덮개, 마구리
$row5_7_sum += floatval($item['col44']);
$row5_8_sum += floatval($item['col46']);
// 레일용 연기차단재/ 케이스용 연기차단재
$row10_1_sum += floatval($item['col31']); // 레일용 연기차단제 5종류 나열
$row10_2_sum += floatval($item['col32']);
$row10_3_sum += floatval($item['col33']);
$row10_4_sum += floatval($item['col34']);
$row10_5_sum += floatval($item['col35']);
$row10_6_sum += floatval($item['col47']); // 케이스용 연기차단제
$row7_1_sum += floatval($item['col44']);
$row8_1_sum += floatval($item['col45']);
$row7_2_sum += floatval($item['col47']);
$row8_2_sum += floatval($item['col48']);
$row7_3_sum += floatval($item['col50']);
$row8_3_sum += floatval($item['col51']);
}
// 테이블 출력
echo '<div class="d-flex align-items-center justify-content-center">';
echo '<table class="table" 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" class="text-center"> 하단보강엘바 <br> (EGI 1.2T) </th>';
echo '<th rowspan="3" class="text-center text-primary fw-bold">' . ($row7_2_sum ?: '') . '</th>';
echo '<th rowspan="3" class="text-center text-primary fw-bold">' . ($row8_2_sum ?: '') . '</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 class="text-center" rowspan="3" colspan="2" ></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>';
echo '<th class="text-center">상부덮개</th>';
echo '<th class="text-center text-primary fw-bold">' . ($row5_7_sum ?: '') . '</th>';
echo '<th rowspan="2" class="text-center"> 하단보강평철 </th>';
echo '<th rowspan="2" class="text-center text-primary fw-bold">' . ($row7_3_sum ?: '') . '</th>';
echo '<th rowspan="2" class="text-center text-primary fw-bold">' . ($row8_3_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>';
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) {
// 누적 합계 계산 2인치 500 없어서 숫자 맞지 않음
$row2_4_sum += floatval($item['col59']); // 300 샤프트
$row3_4_sum += floatval($item['col60']); // 3000 샤프트
$row4_4_sum += floatval($item['col61']); // 4500 샤프트
$row5_4_sum += floatval($item['col62']); // 6000 샤프트
$row6_4_sum += floatval($item['col63']); // 6000 샤프트
$row7_4_sum += floatval($item['col64']); // 7000 샤프트
$row8_4_sum += floatval($item['col65']); // 8200 샤프트
$row2_7_sum += floatval($item['col57']); // 2열 7행 무게평철
$row4_7_sum += floatval($item['col70']); // 4열 7행 환봉
$row6_7_sum += floatval($item['col68']); // 6열 7행 각파이프 3000
$row7_7_sum += floatval($item['col69']); // 7열 7행 각파이프 6000
$row8_7_sum += floatval($item['col71']); // 8열 7행 앵글 2500
}
echo '<div class=" d-flex align-items-center justify-content-center">';
echo '<table class="table" style="border-collapse: collapse;">';
echo '<thead>';
echo '<tr>';
echo '<th rowspan="7" class="text-center"> 2.4 <br> 부자재 </th>';
echo '<th colspan="12" class="text-center"> 감기샤프트 </th>';
echo '</tr>';
echo '<tr>'; // 2행
echo '<th colspan="2" class="text-center">2인치(보조)</th>';
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 '</tr>';
echo '<tr>'; // 3행
echo '<th class="text-center">300</th>';
echo '<th class="text-center">500</th>';
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 '</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 '<th class="text-center text-primary fw-bold">' . ($row13_4_sum ?: '') . '</th>';
echo '</tr>';
echo '<tr>'; // 5행
echo '<th colspan="2" class="text-center"> 무게평철 <br> (50*12T) </th>';
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 '</tr>';
echo '<tr>'; // 6행
echo '<th colspan="2" class="text-center"> 2000 </th>';
echo '<th colspan="2" class="text-center"> 3000 </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 '</tr>';
echo '<tr>'; // 7행
echo '<th colspan="2" class="text-center text-primary fw-bold">' . ($row2_7_sum ?: '') . '</th>';
echo '<th colspan="2" class="text-center text-primary fw-bold">' . ($row4_7_sum ?: '') . '</th>';
echo '<th colspan="1" class="text-center text-primary fw-bold">' . ($row6_7_sum ?: '') . '</th>';
echo '<th colspan="1" class="text-center text-primary fw-bold">' . ($row7_7_sum ?: '') . '</th>';
echo '<th colspan="2" class="text-center text-primary fw-bold">' . ($row8_7_sum ?: '') . '</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>';
}
?>
</div> <!-- end of container -->
<div class="container mb-5 mt-2">
<div class="d-flex align-items-center justify-content-center mb-5">
</div>
</div>
<?php include $_SERVER['DOCUMENT_ROOT'] . '/estimate/common/lastJS.php'; ?> <!--마지막에 추가되는 견적관련 JS -->
</body>
</html>