'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $col7_sum = 0; // col7 수량 합계 $col89_sum = 0; // col8 + col9 합계 $col10_sum = 0; $row_count = 0; foreach ($data as $row) { echo ''; for ($i = 1; $i <= 10; $i++) { switch ($i) { case 1: echo ''; break; case 4: echo ''; break; case 6: echo ''; break; case 7: echo ''; break; case 9: echo ''; // 단가가 들어가는 셀 break; case 10: echo ''; // 합계 금액이 들어가는 셀 break; default: echo ''; break; } } echo ''; $row_count++; $estimateSurang = $col7_sum += intval($row['col7']); } // 소계 행 추가 echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
일련번호종류부호제품명오픈사이즈수량단위단가합계
가로세로금액
' . $row['col1'] . '' . htmlspecialchars($row['col' . $i]) . '' . htmlspecialchars($row['col' . $i]) . '' . htmlspecialchars($row['col' . $i]) . '' . htmlspecialchars($row['col' . $i]) . '
소계' . $col7_sum. '
'; echo ''; } // 세부 산출내역서 echo '
'; echo '
'; echo '
'; echo '

세부 산출내역서

'; echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $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']); // 수량 // 가이드레일 및 기타 부품 단가 초기화 $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['col45']; // 마구리 size (스크린 45위치, 철재 46위치) // 데이터베이스 테이블 이름 설정 (BDmodels) $tablename = 'BDmodels'; try { $sql = "SELECT * FROM " . $DB . "." . $tablename; $stmh = $pdo->prepare($sql); $stmh->execute(); $count = $stmh->rowCount(); if ($count < 1) { print "검색결과가 없습니다.
"; } 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; } // 보강평철 if ($seconditem == '보강평철' && $unitprice_value > 0) { $bottomPlatePrices = $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 = '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(); // echo '
';
// print_r($guidrail_price);
// echo '
'; // 케이스 크기 if ($column['col36'] === 'custom') { $dimension = $column['col36_custom']; // 사용자 제작 사이즈 } else { $dimension = $column['col36']; // 케이스 500*380 } // echo '
';
// print_r($dimension);
// echo '
'; // 단가 계산 if (array_key_exists($dimension, $shutterBoxprices)) { $price = ($shutterBoxprices[$dimension] / 1000) ; } else { $price = 0; // 조건이 맞지 않는 경우 0으로 설정 } // $data 배열에 행을 추가합니다. $data[] = $row; $rowCount = 1; // 일련번호, 검사비 $subtotal += $inspectionFee * $su; if($inspectionFee > 0 ) { // calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가 echo ''; echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 및 기타 필드 echo ''; // 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드) echo ''; // 면적(㎡) 길이(㎜) 입력 필드 echo ''; // 면적(㎡) 길이(㎜) 단가 입력 필드 echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } // 주자재(스크린) 가격 $screen_price = floatval($price_raw_materials * round($area,2)) ; $subtotal += $screen_price * $su; if($screen_price > 0 ) { // calculation-row 클래스와 일련번호(serial)를 가진 tr 태그 추가 echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 및 기타 필드 echo ''; // 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드) echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 echo ''; // 스크린 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } // 모터 $subtotal += $motorUnit_price * $su; if ($motorUnit_price > 0) { echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input이 아님) echo ''; // 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드) echo ''; // 면적(㎡) 입력 필드 (없으면 빈 입력) echo ''; // 원자재 단가 입력 필드 (없으면 빈 입력) echo ''; // 모터 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } // 연동제어기 $controller_price = $price_controller; $subtotal += $controller_price * $su; if ($controller_price > 0 ) { echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input이 아님) echo ''; // 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드) echo ''; // 면적(㎡) 입력 필드 (없으면 빈 입력) echo ''; // 원자재 단가 입력 필드 (없으면 빈 입력) echo ''; // 연동제어기 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 '
'; // echo '
';
// print_r($shutterBoxprices);
// echo '
'; 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] 메뉴 이용!
'. ' 1m당 기본사이즈 500*380 가격 : ' . number_format($basicbox_price) . '(원)' ; // echo '
m당 단가 : ' . number_format($basicbox_pricePermeter) . '(원)' ; // echo '
m단위로 설정된 단가 : ' . number_format($shutter_price) . '(원)' ; } $total_length = round(floatval($column['col37']) / 1000,2); // print_r($total_length); // echo '
'; // print_r($shutter_price * $total_length); $subtotal += $shutter_price * $total_length ; if($total_length > 0 ) { echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input이 아님) echo ''; // 산출식 입력 필드 (예: 수량 * 단가 등으로 계산하는 필드) echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 echo ''; // 케이스 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } //마구리 $subtotal += $maguriPrices * $su; if($maguriPrices > 0 ) { echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } // 모터 받침용 앵글 $price_angle = ceil($price_angle); $angle_price = $price_angle; $subtotal += $angle_price * $su * 4; if($angle_price > 0 ) { echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (EA는 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 (빈 값) echo ''; // 원자재 단가 입력 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } //가이드레일용 연기차단재 레일 높이 + 250 적용해서 만드는 것임 $total_length = round(floatval($column['col23']) / 1000, 2); $guiderailSmokeBanPrices = ceil($guiderailSmokeBanPrices); $subtotal += $guiderailSmokeBanPrices * $total_length * 2 ; if ($total_length > 0 ) { echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } // 하단마감재(보강평철) // 조건에 따른 가격 계산 $total_length = intval($column['col54']) * $su; $total_length = $total_length / 1000; $subtotal += $bottomPlatePrices * $total_length * $su; if ($total_length > 0 ) { echo ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 echo ''; // 면적(㎡) 입력 필드 echo ''; // 원자재 단가 입력 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 (샤프트 수량 텍스트) echo ''; // 면적(㎡) 필드 (빈 값) echo ''; // 원자재 단가 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 = intval($column['col57']); // 무게평철 수량 // // 스크린 하단 무게평철의 단계별 가격 계산 및 수량 저장 // 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_counts[2000] = $priceFactor ; // 최종 단가 계산 $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 ''; // 항목 이름 echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 (무게평철 수량 텍스트) echo ''; // 면적(㎡) 필드 (빈 값) echo ''; // 원자재 단가 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; // 항목 이름 echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (SET은 input에서 제외) echo ''; // 산출식 입력 필드 (환봉 수량 텍스트) echo ''; // 면적(㎡) 필드 (빈 값) echo ''; // 원자재 단가 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; // 항목 이름 echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (EA) echo ''; // 산출식 입력 필드 (각파이프 수량 텍스트) echo ''; // 면적(㎡) 필드 (빈 값) echo ''; // 원자재 단가 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; // 항목 이름 echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (EA) echo ''; // 산출식 입력 필드 (각파이프 수량 텍스트) echo ''; // 면적(㎡) 필드 (빈 값) echo ''; // 원자재 단가 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $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 ''; // 항목 이름 echo ''; // 수량 입력 필드 echo ''; // 단위 필드 (EA) echo ''; // 산출식 입력 필드 (앵글 수량 텍스트) echo ''; // 면적(㎡) 필드 (빈 값) echo ''; // 원자재 단가 필드 (빈 값) echo ''; // 단가 입력 필드 echo ''; // 합계 필드 (자동 계산, 입력 불가) echo ''; echo ''; $rowCount++; } echo ''; echo ''; echo ''; echo ''; 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 ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
일련번호항목수량단위산출식면적(㎡)
길이(㎜)
면적(㎡)
길이(㎜) 단가
단가합계
' . $column['col1'] . ' 검사비 SET ' . number_format($inspectionFee * $su) . '
주자재(스크린) SET ' . number_format($screen_price * $su,2) . '
모터SET' . number_format($motorUnit_price * $su) . '
매립/노출 연동제어기(뒷박스 있는 경우 포함)SET' . number_format($controller_price * $su) . '
케이스SET' . number_format($shutter_price * $total_length) . '
케이스용 연기차단재' . number_format($boxSmokeBanPrices * $total_length ) . '
케이스 마구리SET' . number_format($maguriPrices * $su) . '
모터 받침용 앵글EA' . number_format($angle_price * $su * 4) . '
가이드레일 SET ' . number_format($guidrail_price * $total_length) . '
레일용 연기차단재 SET ' . number_format($guiderailSmokeBanPrices * $total_length * 2) . '
하장바 SET ' . number_format(ceil($bottomBarPrices * $total_length)) . '
L바 SET ' . number_format($LBarPrices * $total_length) . '
보강평철 SET ' . number_format($bottomPlatePrices * $total_length * $su) . '
감기샤프트 ' . number_format($sum_shaft_price) . '
무게평철12T (2000) EA ' . number_format($weight_plate_price) . '
환봉(3000) EA ' . number_format($round_bar_price * $round_bar_surang) . '
각파이프(3000) EA ' . number_format($pipe_price_3000 * $pipe_price_3000_surang) . '
각파이프(6000) EA ' . number_format($pipe_price_6000 * $pipe_price_6000_surang) . '
앵글3T (2500) EA ' . number_format($mainangle_price * $mainangle_surang) . '
소계
전체 합계
'; echo '
'; echo '
'; $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); ?>