1575 lines
61 KiB
PHP
1575 lines
61 KiB
PHP
|
|
<?php
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||
|
|
$title_message = '견 적 서 (스크린)';
|
||
|
|
$tablename = 'estimate';
|
||
|
|
$item ='견 적 서 (스크린)';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||
|
|
?>
|
||
|
|
<title> <?=$title_message?> </title>
|
||
|
|
<link rel="stylesheet" href="css/style.css">
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<?php
|
||
|
|
|
||
|
|
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
|
||
|
|
$option = isset($_REQUEST['option']) ? $_REQUEST['option'] : ''; // 견적서와 산출서의 다른점을 표현하는 것
|
||
|
|
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/estimate/fetch_unitprice.php");
|
||
|
|
$pdo = db_connect();
|
||
|
|
try {
|
||
|
|
$sql = "select * from {$DB}.{$tablename} where num = ? ";
|
||
|
|
$stmh = $pdo->prepare($sql);
|
||
|
|
$stmh->bindValue(1, $num, PDO::PARAM_STR);
|
||
|
|
$stmh->execute();
|
||
|
|
$count = $stmh->rowCount();
|
||
|
|
if ($count < 1) {
|
||
|
|
print "검색결과가 없습니다.<br>";
|
||
|
|
} else {
|
||
|
|
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
||
|
|
include "_row.php";
|
||
|
|
|
||
|
|
// $korean = number_to_korean($totalprice);
|
||
|
|
}
|
||
|
|
} catch (PDOException $Exception) {
|
||
|
|
print "오류: " . $Exception->getMessage();
|
||
|
|
}
|
||
|
|
|
||
|
|
$tableName = 'price_raw_materials';
|
||
|
|
// JSON 문자열을 PHP 배열로 디코딩합니다.
|
||
|
|
$decodedEstimateList = json_decode($estimateList, true);
|
||
|
|
|
||
|
|
// 디코딩된 데이터가 배열인지 확인합니다.
|
||
|
|
if (!is_array($decodedEstimateList)) {
|
||
|
|
echo "데이터가 정상적이지 않습니다. 확인바랍니다.";
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|
||
|
|
|
||
|
|
<div class="container mt-2">
|
||
|
|
<div class="d-flex align-items-center justify-content-end mt-1 m-2">
|
||
|
|
<button class="btn btn-dark btn-sm me-1" onclick="generatePDF()"> PDF 저장 </button>
|
||
|
|
<!-- <button class="btn btn-dark btn-sm me-1" onclick="sendmail();"> <i class="bi bi-envelope-arrow-up"></i> 전송 </button> -->
|
||
|
|
<button class="btn btn-secondary btn-sm" onclick="self.close();"> <i class="bi bi-x-lg"></i> 닫기 </button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="content-to-print">
|
||
|
|
<br>
|
||
|
|
<div class="container mt-3">
|
||
|
|
<div class="d-flex align-items-center justify-content-center m-1">
|
||
|
|
<table class="table" style="border-collapse: collapse;">
|
||
|
|
<tbody>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center fw-bold" style="width:8%;" >작성일자</td>
|
||
|
|
<td rowspan="2" class="text-center align-middle fw-bold fs-2" style="width:60%; border-top:none; border-bottom:none;" > <?=$title_message?> </td>
|
||
|
|
<td class="text-center fw-bold" style="width:10%;" >견적번호</td>
|
||
|
|
</tr>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center" > <?=$indate?> </td>
|
||
|
|
<td class="text-center fw-bold text-primary" > <?=$pjnum?> </td>
|
||
|
|
</tr>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
<div class="d-flex align-items-center justify-content-center m-1">
|
||
|
|
<table class="table" style="border-collapse: collapse;">
|
||
|
|
<tbody>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center fw-bold yellowBold " style="width:10%;">업체명</td>
|
||
|
|
<td class="text-center yellowBold " style="width:40%;"> <?=$secondord?> (귀하) </td>
|
||
|
|
<td rowspan="5" class="text-center align-middle fw-bold" style="width:5%; border-top:none; border-bottom:none;" >공 급 자</td>
|
||
|
|
<td class="text-center fw-bold lightgray " > 상호 </td>
|
||
|
|
<td class="text-center fw-bold" colspan="3" >㈜ 경동기업 </td>
|
||
|
|
|
||
|
|
</tr>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center fw-bold">제품명</td>
|
||
|
|
<td class="text-center" > 자동방화셔터 스크린인정제품 </td>
|
||
|
|
<td class="text-center fw-bold lightgray " style="width:10%;" >등록번호</td>
|
||
|
|
<td class="text-center" style="width:10%;"> 139-87-00333 </td>
|
||
|
|
<td class="text-center fw-bold lightgray " >대표자</td>
|
||
|
|
<td class="text-center fw-bold">
|
||
|
|
<div class="d-flex align-items-center justify-content-center ">
|
||
|
|
이 경 호
|
||
|
|
<!-- <img src="../img/daehanstamp.png" alt="도장" style="width:45px; height:45px;"> -->
|
||
|
|
</div>
|
||
|
|
</td>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center fw-bold">현장명</td>
|
||
|
|
<td class="text-center fw-bold" > <?=$outworkplace?></td>
|
||
|
|
<td class="text-center fw-bold lightgray " > 사업장주소 </td>
|
||
|
|
<td colspan="3" class="text-center"> 경기도 김포시 통진읍 옹정로 45-22</td>
|
||
|
|
</tr>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center fw-bold">담당자</td>
|
||
|
|
<td class="text-center"><?=$secondordman?></td>
|
||
|
|
<td class="text-center fw-bold lightgray " > 업 태 </td>
|
||
|
|
<td class="text-center" > 제조업 </td>
|
||
|
|
<td class="text-center fw-bold lightgray " >종목</td>
|
||
|
|
<td class="text-center" > 방화셔터, 금속창호 </td>
|
||
|
|
|
||
|
|
</tr>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center fw-bold">연락처</td>
|
||
|
|
<td class="text-center"><?=$secondordmantel?></td>
|
||
|
|
<td class="text-center fw-bold lightgray " > TEL. </td>
|
||
|
|
<td class="text-center" > 031-983-5130</td>
|
||
|
|
<td class="text-center fw-bold lightgray " > FAX </td>
|
||
|
|
<td class="text-center" > 02-6911-6315 </td>
|
||
|
|
</tr>
|
||
|
|
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
<div class="d-flex align-items-center justify-content-center m-1">
|
||
|
|
<table class="table" style="border-collapse: collapse;">
|
||
|
|
<tbody>
|
||
|
|
<tr>
|
||
|
|
<td class="text-center fw-bold" style="width:250px;" >
|
||
|
|
합계금액(부가세 별도) <br>
|
||
|
|
아래와 같이 견적합니다
|
||
|
|
</td>
|
||
|
|
<td class="text-center align-middle fs-6 fw-bold" style="width:50px;"> 금 </td>
|
||
|
|
<td rowspan="5" class="text-end align-middle fw-bold fs-6" style="width:500px;" > <span id="koreantotalsum"> </span> </td>
|
||
|
|
<td class="text-center fw-bold align-middle fs-6" style="width:50px;" > 원 </td>
|
||
|
|
<td class="align-middle text-end fs-6 fw-bold" style="width:250px;"> ( ₩ <span id="totalsum"> </span> )</td>
|
||
|
|
</tr>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<?php
|
||
|
|
// SET 금액 표기
|
||
|
|
if(True) {
|
||
|
|
$data = [];
|
||
|
|
$counter = 0;
|
||
|
|
$index = 0;
|
||
|
|
$sums = []; // 각 행의 합을 저장할 배열
|
||
|
|
|
||
|
|
|
||
|
|
// 데이터베이스 테이블 이름 설정 (마구리)
|
||
|
|
$tablename = 'bendingfee';
|
||
|
|
|
||
|
|
try {
|
||
|
|
// 데이터 조회 쿼리 (전체 데이터를 가져옴)
|
||
|
|
$sql = "SELECT * FROM " . $DB . "." . $tablename;
|
||
|
|
$stmh = $pdo->prepare($sql);
|
||
|
|
$stmh->execute();
|
||
|
|
$count = $stmh->rowCount();
|
||
|
|
|
||
|
|
if ($count < 1) {
|
||
|
|
print "검색결과가 없습니다.<br>";
|
||
|
|
} else {
|
||
|
|
// 마구리 단가 정보를 저장할 배열
|
||
|
|
$maguriPrices = [];
|
||
|
|
|
||
|
|
// 정규표현식 패턴 (숫자 형식만 매칭)
|
||
|
|
$pattern = '/\d{3}\*\d{3}/';
|
||
|
|
// 전체 데이터를 반복 처리
|
||
|
|
while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||
|
|
$firstitem = isset($row['firstitem']) ? $row['firstitem'] : '';
|
||
|
|
$unitList = isset($row['unitList']) ? json_decode($row['unitList'], true) : [];
|
||
|
|
|
||
|
|
// 첫 번째 아이템이 '케이스(셔터박스)'이고, unitList가 유효한 배열인 경우
|
||
|
|
if ($firstitem == '케이스(셔터박스)' && is_array($unitList) && count($unitList) > 0) {
|
||
|
|
foreach ($unitList as $item) {
|
||
|
|
// $item['col1']에서 개행 문자를 제거
|
||
|
|
$col1_clean = preg_replace("/\r|\n/", '', $item['col1']);
|
||
|
|
preg_match($pattern, $col1_clean, $matches);
|
||
|
|
|
||
|
|
// '마구리' 단어가 col1_clean에 포함되어 있고, 숫자 패턴이 포함된 경우 처리
|
||
|
|
if (strpos($col1_clean, '마구리') !== false && preg_match($pattern, $col1_clean)) {
|
||
|
|
|
||
|
|
$extract = $matches[0];
|
||
|
|
// $item['col12']가 존재하고, 콤마 제거 후 유효한지 확인
|
||
|
|
if (isset($item['col12']) && $item['col12'] !== '' && $item['col12'] !== '-') {
|
||
|
|
// $item['col12']에서 모든 공백, 특수문자 제거 (콤마, 공백 등)
|
||
|
|
$col12_clean = preg_replace('/[^0-9.]/', '', $item['col12']);
|
||
|
|
|
||
|
|
// // 연산을 위한 데이터로 저장된 배열을 확인 (필요시)
|
||
|
|
// echo '<pre>';
|
||
|
|
// print_r($extract); // 필요시 배열을 출력해서 확인
|
||
|
|
// echo "원본 col12: " . $item['col12'] . "\n";
|
||
|
|
// echo "정리된 col12_clean: " . $col12_clean . "\n";
|
||
|
|
// echo '</pre>';
|
||
|
|
|
||
|
|
// floatval()로 변환된 값이 0보다 큰지 확인
|
||
|
|
if (floatval($col12_clean) > 0) {
|
||
|
|
// 패턴에서 숫자 두 개를 추출하여 각각 5씩 감소
|
||
|
|
$numbers = explode('*', $extract);
|
||
|
|
$first_number = intval($numbers[0]) - 5; // 첫 번째 숫자에서 5 감소
|
||
|
|
$second_number = intval($numbers[1]) - 5; // 두 번째 숫자에서 5 감소
|
||
|
|
$adjusted_extract = $first_number . '*' . $second_number; // 변환된 값을 결합
|
||
|
|
|
||
|
|
// 변환된 값으로 배열에 저장
|
||
|
|
$maguriPrices[$adjusted_extract] = floatval($col12_clean);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// // 연산을 위한 데이터로 저장된 배열을 확인
|
||
|
|
// echo '<pre>';
|
||
|
|
// print_r($maguriPrices); // 최종 저장된 배열 출력
|
||
|
|
// echo '</pre>';
|
||
|
|
}
|
||
|
|
} catch (PDOException $Exception) {
|
||
|
|
print "오류: " . $Exception->getMessage();
|
||
|
|
}
|
||
|
|
|
||
|
|
// 데이터베이스 테이블 이름 설정 (셔터박스)
|
||
|
|
$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}/';
|
||
|
|
|
||
|
|
// 전체 데이터를 반복 처리
|
||
|
|
while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||
|
|
$firstitem = isset($row['firstitem']) ? $row['firstitem'] : '';
|
||
|
|
$proditem = isset($row['proditem']) ? $row['proditem'] : ''; // 셔터박스 데이터 (단순 문자열)
|
||
|
|
|
||
|
|
// 첫 번째 아이템이 '케이스(셔터박스)'인 경우
|
||
|
|
if ($firstitem == '케이스(셔터박스)') {
|
||
|
|
// $proditem에서 개행 문자를 제거하고 정리
|
||
|
|
$proditem_clean = preg_replace("/\r|\n/", '', $proditem);
|
||
|
|
|
||
|
|
// 정규식 패턴을 이용해 숫자 추출 (예: '500*350')
|
||
|
|
if (preg_match($pattern, $proditem_clean, $matches)) {
|
||
|
|
$extract = $matches[0]; // '500*350' 형식의 패턴 추출
|
||
|
|
|
||
|
|
// $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();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// // 마감별 하장바 단가
|
||
|
|
// $bottomBarPrices = [
|
||
|
|
// 'KSS01' => 12276,
|
||
|
|
// 'KWSS01' => 12276,
|
||
|
|
// 'KWWS01' => 12276,
|
||
|
|
// 'EGI마감' => 5346,
|
||
|
|
// 'SUS마감' => 17484,
|
||
|
|
// 'KTE01_EGI' => 5805,
|
||
|
|
// 'KTE01_SUS' => 13761,
|
||
|
|
// ];
|
||
|
|
|
||
|
|
|
||
|
|
// 전체 반복 찾기
|
||
|
|
foreach ($decodedEstimateList as $item) {
|
||
|
|
if (isset($item['col5']) && !empty($item['col5'])) {
|
||
|
|
// 각 행별 합계 초기화
|
||
|
|
// 검사비 10만원 처음 들어감
|
||
|
|
$sums[$counter] = 100000 ;
|
||
|
|
|
||
|
|
// 주자재 계산
|
||
|
|
$tableName = 'price_raw_materials';
|
||
|
|
$price = fetchPricesFromTable($tableName, [$item['col5']]);
|
||
|
|
|
||
|
|
// 쉼표를 제거하고 숫자형으로 변환
|
||
|
|
$price = floatval(str_replace(',', '', $price));
|
||
|
|
// col12도 숫자형으로 변환
|
||
|
|
$area = floatval($item['col12']);
|
||
|
|
// 견적서 엑셀을 보면 스크린일때 높이를 900 더해준다. 기준 산출기준서에는 +350인데, 견적서는 +900적용 주의
|
||
|
|
// 그러므로, 여기서는 다시 계산해야 한다. ( +550 더해준다.)
|
||
|
|
$area = floatval($item['col10']) * (floatval($item['col11']) + 550) / 1000000 ;
|
||
|
|
$sums[$counter] += ($price * $area); // 합산
|
||
|
|
|
||
|
|
// 모터가격 계산
|
||
|
|
$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);
|
||
|
|
|
||
|
|
$result = calculateMotorSpec($decodedEstimateList, $item['col15'], $item['col16']);
|
||
|
|
$price = getPriceForMotor($result, $itemList);
|
||
|
|
$sums[$counter] += $price; // 모터 가격 합산
|
||
|
|
|
||
|
|
// 매립 연동제어기 가격 계산
|
||
|
|
$price = calculateControllerSpec($item['col15'], $itemList, '매립형');
|
||
|
|
$sums[$counter] += $price; // 매립 연동제어기 가격 합산
|
||
|
|
|
||
|
|
// 노출 연동제어기 가격 계산
|
||
|
|
$price = calculateControllerSpec($item['col16'], $itemList, '노출형');
|
||
|
|
$sums[$counter] += $price; // 노출 연동제어기 가격 합산
|
||
|
|
|
||
|
|
// 뒷박스 계산
|
||
|
|
$price = calculateControllerSpec($item['col17'], $itemList, '뒷박스');
|
||
|
|
// echo "뒷박스 가격: " . $price . "\n";
|
||
|
|
$sums[$counter] += $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 = calculateAngle($item['col2'], $itemList, '스크린용');
|
||
|
|
$sums[$counter] += $price; // 매립 연동제어기 가격 합산
|
||
|
|
|
||
|
|
// 절단판
|
||
|
|
$tablename = 'price_bend';
|
||
|
|
|
||
|
|
$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 = calculateGuidrail($item['col11'], $itemList, 'SUS','H/L304');
|
||
|
|
$sums[$counter] += $price; // 매립 연동제어기 가격 합산
|
||
|
|
|
||
|
|
// 셔터박스 단가는 엑셀표를 참고한다. 절단판 세부 내용은 문의해야 한다.
|
||
|
|
// $shutterBoxprices = [
|
||
|
|
// '500*350' => 54837,
|
||
|
|
// '500*380' => 56457,
|
||
|
|
// '650*500' => 71739,
|
||
|
|
// '650*550' => 74439,
|
||
|
|
// '700*550' => 77139,
|
||
|
|
// '700*600' => 79839,
|
||
|
|
// '780*600' => 84159,
|
||
|
|
// '780*650' => 86859,
|
||
|
|
// ];
|
||
|
|
|
||
|
|
// 셔터박스 크기
|
||
|
|
if ($item['col31'] === 'custom') {
|
||
|
|
$dimension = $item['col31_custom']; // 사용자 제작 사이즈
|
||
|
|
} else {
|
||
|
|
$dimension = $item['col31']; // 케이스 500*380
|
||
|
|
}
|
||
|
|
|
||
|
|
$basePrice = intval(str_replace(',', '', $item['col32']));
|
||
|
|
|
||
|
|
// 단가 계산
|
||
|
|
if (array_key_exists($dimension, $shutterBoxprices)) {
|
||
|
|
$price = $basePrice * ($shutterBoxprices[$dimension] / 1000);
|
||
|
|
} else {
|
||
|
|
$price = 0; // 조건이 맞지 않는 경우 0으로 설정
|
||
|
|
}
|
||
|
|
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
// 마구리 단가 정보
|
||
|
|
// $maguriPrices = [
|
||
|
|
// '500*350' => 14865,
|
||
|
|
// '500*380' => 15845,
|
||
|
|
// '650*500' => 24666,
|
||
|
|
// '650*550' => 26704,
|
||
|
|
// '700*550' => 28473,
|
||
|
|
// '700*600' => 30646,
|
||
|
|
// '780*600' => 33692,
|
||
|
|
// '780*650' => 36081,
|
||
|
|
// ];
|
||
|
|
|
||
|
|
|
||
|
|
// 마구리 단가 계산
|
||
|
|
if (array_key_exists($dimension, $maguriPrices)) {
|
||
|
|
$maguriPrice = $maguriPrices[$dimension];
|
||
|
|
} else {
|
||
|
|
$maguriPrice = 0; // 조건이 맞지 않는 경우 0으로 설정
|
||
|
|
}
|
||
|
|
|
||
|
|
$sums[$counter] += $maguriPrice;
|
||
|
|
|
||
|
|
// 셔터박스 연기차단제
|
||
|
|
$price = 0;
|
||
|
|
$dimension = intval($item['col42']);
|
||
|
|
$basePrice = 8590 ;
|
||
|
|
|
||
|
|
// 단가 계산
|
||
|
|
$price = $basePrice * $dimension ;
|
||
|
|
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
|
||
|
|
// 마감별 하장바 단가
|
||
|
|
// $bottomBarPrices = [
|
||
|
|
// 'KSS01' => 12276,
|
||
|
|
// 'KWSS01' => 12276,
|
||
|
|
// 'KWWS01' => 12276,
|
||
|
|
// 'EGI마감' => 5346,
|
||
|
|
// 'SUS마감' => 17484,
|
||
|
|
// 'KTE01_EGI' => 5805,
|
||
|
|
// 'KTE01_SUS' => 13761,
|
||
|
|
// ];
|
||
|
|
|
||
|
|
|
||
|
|
// 데이터베이스 테이블 이름 설정 (하단마감재 3가지 합계 하장바+L바+평철)
|
||
|
|
|
||
|
|
try {
|
||
|
|
$sqltmp = "SELECT * FROM {$DB}.bendingfee ";
|
||
|
|
$stmhtmp = $pdo->prepare($sqltmp);
|
||
|
|
$stmhtmp->execute();
|
||
|
|
$count = $stmhtmp->rowCount();
|
||
|
|
|
||
|
|
if ($count > 0 ) {
|
||
|
|
// 셔터박스 단가 정보를 저장할 배열
|
||
|
|
$bottomBarPrices = 0;
|
||
|
|
// 전체 데이터를 반복 처리
|
||
|
|
|
||
|
|
$itemsep = substr($item['col4'], 0, 2) === 'KS' ? '스크린용' : '철재용'; // E8은 'KS'로 시작하는지 확인
|
||
|
|
$itemfinal = str_replace('마감', '', $item['col7']);
|
||
|
|
|
||
|
|
while ($rowtmp = $stmhtmp->fetch(PDO::FETCH_ASSOC)) {
|
||
|
|
|
||
|
|
$firstitem = isset($rowtmp['firstitem']) ? $rowtmp['firstitem'] : '';
|
||
|
|
$seconditem = isset($rowtmp['seconditem']) ? $rowtmp['seconditem'] : '';
|
||
|
|
$proditem = isset($rowtmp['proditem']) ? $rowtmp['proditem'] : ''; // 셔터박스 데이터 (단순 문자열)
|
||
|
|
$material = isset($rowtmp['material']) ? $rowtmp['material'] : '';
|
||
|
|
$memo = isset($rowtmp['memo']) ? $rowtmp['memo'] : '';
|
||
|
|
|
||
|
|
if ($firstitem == '하단마감재' && $seconditem == $itemsep && strpos($memo, $item['col4']) !== true ) {
|
||
|
|
// $proditem에서 개행 문자를 제거하고 정리
|
||
|
|
$proditem_clean = preg_replace("/\r|\n/", '', $proditem);
|
||
|
|
// $rowtmp['unitprice'] 값이 존재하고, 콤마 제거 후 유효한지 확인
|
||
|
|
if (isset($rowtmp['unitprice']) && $rowtmp['unitprice'] !== '') {
|
||
|
|
$unitprice_clean = preg_replace('/[^0-9.]/', '', $rowtmp['unitprice']); // 단가에서 숫자와 소수점만 남기기
|
||
|
|
|
||
|
|
// floatval()로 변환된 값이 0보다 큰지 확인
|
||
|
|
if (floatval($unitprice_clean) > 0) {
|
||
|
|
// 변환된 값으로 배열에 저장
|
||
|
|
$bottomBarPrices = floatval($unitprice_clean);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// // 연산을 위한 데이터로 저장된 배열을 확인
|
||
|
|
// echo '<pre>';
|
||
|
|
// print_r($bottomBarPrices); // 최종 저장된 배열 출력
|
||
|
|
// echo '</pre>';
|
||
|
|
}
|
||
|
|
} catch (PDOException $Exception) {
|
||
|
|
print "오류: " . $Exception->getMessage();
|
||
|
|
}
|
||
|
|
|
||
|
|
$basePrice = intval(str_replace(',', '', $item['col43'])); // 기장 size를 의미함
|
||
|
|
|
||
|
|
// 조건에 따른 가격 계산
|
||
|
|
$price = 0;
|
||
|
|
$price = $basePrice * ($bottomBarPrices / 1000);
|
||
|
|
|
||
|
|
// echo "하장바 Price: " . number_format($price);
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
// // 마감별 엘바 단가 (3개 단가를 통합함)
|
||
|
|
// $bottomBarPrices = [
|
||
|
|
// 'KSS01' => 4158,
|
||
|
|
// 'KWSS01' => 4158,
|
||
|
|
// 'KWWS01' => 4158,
|
||
|
|
// 'EGI마감' => 4158,
|
||
|
|
// 'SUS마감' => 4158,
|
||
|
|
// 'KTE01_EGI' => 4158,
|
||
|
|
// 'KTE01_SUS' => 4158,
|
||
|
|
// ];
|
||
|
|
|
||
|
|
// $basePrice = intval(str_replace(',', '', $item['col46'])); // 기장 size를 의미함
|
||
|
|
|
||
|
|
// $itemsep = substr($item['col4'], 0, 2) === 'KS' ? '스크린' : '철재'; // E8은 'KS'로 시작하는지 확인
|
||
|
|
// $itemfinal = $item['col7'];
|
||
|
|
// // 조건에 따른 가격 계산
|
||
|
|
// $price = 0;
|
||
|
|
// if (in_array($item['col4'], ['KSS01', 'KSE01', 'KWSS01', 'KWWS01'])) {
|
||
|
|
// // KSS01, KWSS01, KWWS01 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['KSS01'] / 1000);
|
||
|
|
// } elseif ($itemsep == '스크린' && $itemfinal == 'EGI마감') {
|
||
|
|
// // 스크린 + EGI마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['EGI마감'] / 1000);
|
||
|
|
// } elseif ($item['col4'] == 'KWE01' && $itemfinal == 'SUS마감') {
|
||
|
|
// // KWE01 + SUS마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['SUS마감'] / 1000);
|
||
|
|
// } elseif ($item['col4'] == 'KTE01' && $itemfinal == 'EGI마감') {
|
||
|
|
// // KTE01 + EGI마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['KTE01_EGI'] / 1000);
|
||
|
|
// } elseif ($item['col4'] == 'KTE01' && $itemfinal == 'SUS마감') {
|
||
|
|
// // KTE01 + SUS마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['KTE01_SUS'] / 1000);
|
||
|
|
// } else {
|
||
|
|
// $price = 0; // 조건이 맞지 않는 경우 0으로 설정
|
||
|
|
// }
|
||
|
|
|
||
|
|
// // echo " 엘바 Price: " . number_format($price) . "<br>";
|
||
|
|
// $sums[$counter] += $price;
|
||
|
|
|
||
|
|
|
||
|
|
// // 보강평철 단가
|
||
|
|
// $basicUnit = 1100;
|
||
|
|
// $bottomBarPrices = [
|
||
|
|
// 'KSS01' => $basicUnit,
|
||
|
|
// 'KWSS01'=> $basicUnit,
|
||
|
|
// 'KWWS01'=> $basicUnit,
|
||
|
|
// 'EGI마감'=> $basicUnit,
|
||
|
|
// 'SUS마감'=> $basicUnit,
|
||
|
|
// 'KTE01_EGI' => $basicUnit,
|
||
|
|
// 'KTE01_SUS' => $basicUnit,
|
||
|
|
// ];
|
||
|
|
|
||
|
|
// $basePrice = intval(str_replace(',', '', $item['col49'])); // 기장 size를 의미함
|
||
|
|
|
||
|
|
// $itemsep = substr($item['col4'], 0, 2) === 'KS' ? '스크린' : '철재'; // E8은 'KS'로 시작하는지 확인
|
||
|
|
// $itemfinal = $item['col7'];
|
||
|
|
// // 조건에 따른 가격 계산
|
||
|
|
// $price = 0;
|
||
|
|
// if (in_array($item['col4'], ['KSS01', 'KSE01', 'KWSS01', 'KWWS01'])) {
|
||
|
|
// // KSS01, KWSS01, KWWS01 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['KSS01'] / 1000);
|
||
|
|
// } elseif ($itemsep == '스크린' && $itemfinal == 'EGI마감') {
|
||
|
|
// // 스크린 + EGI마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['EGI마감'] / 1000);
|
||
|
|
// } elseif ($item['col4'] == 'KWE01' && $itemfinal == 'SUS마감') {
|
||
|
|
// // KWE01 + SUS마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['SUS마감'] / 1000);
|
||
|
|
// } elseif ($item['col4'] == 'KTE01' && $itemfinal == 'EGI마감') {
|
||
|
|
// // KTE01 + EGI마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['KTE01_EGI'] / 1000);
|
||
|
|
// } elseif ($item['col4'] == 'KTE01' && $itemfinal == 'SUS마감') {
|
||
|
|
// // KTE01 + SUS마감 조건
|
||
|
|
// $price = $basePrice * ($bottomBarPrices['KTE01_SUS'] / 1000);
|
||
|
|
// } else {
|
||
|
|
// $price = 0; // 조건이 맞지 않는 경우 0으로 설정
|
||
|
|
// }
|
||
|
|
|
||
|
|
// // echo " 보강평철 Price: " . number_format($price) . "<br>";
|
||
|
|
// $sums[$counter] += $price;
|
||
|
|
|
||
|
|
// 샤프트
|
||
|
|
$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);
|
||
|
|
|
||
|
|
$price = calculateShaft($item['col54'], $itemList, '3' , '300' ); //3인치 300
|
||
|
|
// echo " 샤프트 Price: " . number_format($price) . "<br>";
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
$price = calculateShaft($item['col55'], $itemList, '4' , '3000' ); //4인치 3000
|
||
|
|
// echo " 샤프트 Price: " . number_format($price) . "<br>";
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
$price = calculateShaft($item['col56'], $itemList, '4' , '4500' );
|
||
|
|
// echo " 샤프트 Price: " . number_format($price) . "<br>";
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
$price = calculateShaft($item['col57'], $itemList, '4' , '6000' );
|
||
|
|
// echo " 샤프트 Price: " . number_format($price) . "<br>";
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
$price = calculateShaft($item['col58'], $itemList, '5' , '6000' );
|
||
|
|
// echo " 샤프트 Price: " . number_format($price) . "<br>";
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
$price = calculateShaft($item['col59'], $itemList, '5' , '7000' );
|
||
|
|
// echo " 샤프트 Price: " . number_format($price) . "<br>";
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
$price = calculateShaft($item['col60'], $itemList, '5' , '8200' );
|
||
|
|
// echo " 샤프트 Price: " . number_format($price) . "<br>";
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
// 기준 단가 (2000mm당 12000원)
|
||
|
|
$basePrice = 12000;
|
||
|
|
$size = intval(str_replace(',', '', $item['col8'])) * 2; // 스크린 길이 * 2
|
||
|
|
$itemsep = substr($item['col4'], 0, 2) === 'KS' ? '스크린' : '철재'; // E8은 'KS'로 시작하는지 확인
|
||
|
|
|
||
|
|
// 스크린 하단 평철의 단계별 가격 계산
|
||
|
|
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;
|
||
|
|
} else {
|
||
|
|
$priceFactor = 0; // 조건에 맞지 않는 경우 0으로 설정
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
$priceFactor = 0; // E8이 '스크린'이 아닌 경우 0으로 설정
|
||
|
|
}
|
||
|
|
// 최종 단가 계산
|
||
|
|
$price = $basePrice * $priceFactor;
|
||
|
|
|
||
|
|
// 결과 출력
|
||
|
|
// echo "<br> 스크린평철 Price: " . number_format($price);
|
||
|
|
$sums[$counter] += $price;
|
||
|
|
|
||
|
|
// 각파이프 계산
|
||
|
|
$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);
|
||
|
|
// 3000mm 각파이프 계산
|
||
|
|
$price = calculatePipe($itemList, '1.4', '3000');
|
||
|
|
if ($item['col63'] > 0) {
|
||
|
|
$sums[$counter] += $price * intval($item['col63']);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 6000mm 각파이프 계산
|
||
|
|
$price = calculatePipe($itemList, '1.4', '6000');
|
||
|
|
if ($item['col64'] > 0) {
|
||
|
|
$sums[$counter] += $price * intval($item['col64']);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 행의 나머지 데이터를 설정
|
||
|
|
$row = [];
|
||
|
|
$row['col1'] = $counter + 1;
|
||
|
|
$row['col2'] = '스크린'; // 예시로 고정된 값
|
||
|
|
$row['col3'] = $item['col3'] ?? ''; // col2는 item의 col3 값을 사용
|
||
|
|
$row['col4'] = $item['col4'] ?? ''; // col3은 item의 col4 값을 사용
|
||
|
|
$row['col5'] = $item['col8']; // 필요한 값으로 설정
|
||
|
|
$row['col6'] = $item['col9'];
|
||
|
|
$row['col7'] = $item['col14']; // 수량
|
||
|
|
$row['col8'] = 'SET'; // 빈 값으로 초기화 (필요에 따라 채움)
|
||
|
|
$row['col9'] = number_format($sums[$counter]); // 합산된 결과를 표시
|
||
|
|
$row['col10'] = number_format(floatval(str_replace(',', '', $sums[$counter])) * floatval(str_replace(',', '', $item['col14'])));
|
||
|
|
|
||
|
|
|
||
|
|
// $data 배열에 행을 추가합니다.
|
||
|
|
$data[] = $row;
|
||
|
|
$counter++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
echo '<div class="d-flex align-items-center justify-content-center m-1">';
|
||
|
|
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 rowspan="2" class="text-center">제품명</th>';
|
||
|
|
echo '<th colspan="2" class="text-center">오픈사이즈</th>';
|
||
|
|
echo '<th rowspan="2" lass="text-center">수량</th>';
|
||
|
|
echo '<th rowspan="2" lass="text-center">단위</th>';
|
||
|
|
echo '<th rowspan="2" lass="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>';
|
||
|
|
for ($i = 1; $i <= 10; $i++) {
|
||
|
|
switch ($i) {
|
||
|
|
case 1:
|
||
|
|
// col1에만 HTML 태그를 해석하도록 출력
|
||
|
|
echo '<td class="text-center ">' . $row['col1'] . '</td>';
|
||
|
|
break;
|
||
|
|
case 4:
|
||
|
|
// col3에만 HTML 태그를 해석하도록 출력
|
||
|
|
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 ">' . htmlspecialchars($row['col' . $i]) . '</td>';
|
||
|
|
break;
|
||
|
|
case 9:
|
||
|
|
echo '<td class="text-end text-dark" >' . htmlspecialchars($row['col' . $i]) . '</td>';
|
||
|
|
break;
|
||
|
|
case 10:
|
||
|
|
echo '<td class="text-end text-primary fw-bold ">' . htmlspecialchars($row['col' . $i]) . '</td>';
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
echo '<td class="text-center ">' . htmlspecialchars($row['col' . $i]) . '</td>';
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 쉼표를 제거하고 숫자형으로 변환하여 합계 계산
|
||
|
|
$col7_sum += floatval(str_replace(',', '', $row['col7']));
|
||
|
|
$col10_sum += floatval(str_replace(',', '', $sums[$row_count]));
|
||
|
|
|
||
|
|
echo '</tr>';
|
||
|
|
$row_count ++ ;
|
||
|
|
}
|
||
|
|
// 소계 행 추가
|
||
|
|
echo '<tr>';
|
||
|
|
echo '<td class="text-center" colspan="6">소계</td>';
|
||
|
|
echo '<td class="text-center text-primary fw-bold">' . number_format($col7_sum) . '</td>';
|
||
|
|
echo '<td class="text-center" colspan="2"></td>';
|
||
|
|
echo '<td class="text-end text-primary fw-bold">' . number_format($col10_sum) . '</td>';
|
||
|
|
echo '</tr>';
|
||
|
|
|
||
|
|
echo '</tbody>';
|
||
|
|
echo '</table>';
|
||
|
|
echo '</div>';
|
||
|
|
|
||
|
|
$total_sum = floor($col10_sum);
|
||
|
|
$korean_total_sum = number_to_korean($total_sum);
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// 세부내역서
|
||
|
|
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['col31'] === 'custom') {
|
||
|
|
$row['col11'] = $item['col31_custom']; // 사용자 제작 사이즈
|
||
|
|
} else {
|
||
|
|
$row['col11'] = $item['col31']; // 케이스 500*380
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// $data 배열에 행을 추가합니다.
|
||
|
|
$data[] = $row;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
echo '<div class="d-flex align-items-center justify-content-center m-1">';
|
||
|
|
echo '<h3> 세부내역서 </h3></div>';
|
||
|
|
echo '<div class="d-flex align-items-center justify-content-center m-1">';
|
||
|
|
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 m-1">';
|
||
|
|
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) {
|
||
|
|
$AC8 = floatval($item['col23']); // 셔터의 유효 길이
|
||
|
|
$surang = floatval($item['col14']); // 수량
|
||
|
|
|
||
|
|
// row3_1 계산
|
||
|
|
if ($AC8 <= 2438 || ($AC8 > 4300 && $AC8 <= 5438)) {
|
||
|
|
$row3_1 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row3_1 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row3_2 계산
|
||
|
|
if (($AC8 > 2438 && $AC8 <= 3000) || ($AC8 > 4300 && $AC8 <= 5438)) {
|
||
|
|
$row3_2 = 2 * $surang ;
|
||
|
|
} elseif ($AC8 > 5438 && $AC8 <= 6000) {
|
||
|
|
$row3_2 = 4;
|
||
|
|
} elseif ($AC8 > 6000 && $AC8 <= 7300) {
|
||
|
|
$row3_2 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row3_2 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row3_3 계산
|
||
|
|
if (($AC8 > 3000 && $AC8 <= 3500) || ($AC8 > 6000 && $AC8 <= 6500)) {
|
||
|
|
$row3_3 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row3_3 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row3_4 계산
|
||
|
|
if (($AC8 > 3500 && $AC8 <= 4000) || ($AC8 > 6500 && $AC8 <= 7000)) {
|
||
|
|
$row3_4 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row3_4 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row3_5 계산
|
||
|
|
if (($AC8 > 4000 && $AC8 <= 4300) || ($AC8 > 7000 && $AC8 <= 7300)) {
|
||
|
|
$row3_5 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row3_5 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 누적 합계 계산
|
||
|
|
$row3_1_sum += $row3_1 * $surang ;
|
||
|
|
$row3_2_sum += $row3_2 * $surang ;
|
||
|
|
$row3_3_sum += $row3_3;
|
||
|
|
$row3_4_sum += $row3_4;
|
||
|
|
$row3_5_sum += $row3_5;
|
||
|
|
|
||
|
|
$AQ8 = floatval($item['col32']); // 셔터의 유효 길이
|
||
|
|
|
||
|
|
// row5_1 계산
|
||
|
|
if ($AQ8 <= 1219 || ($AQ8 > 4150 && $AQ8 <= 4219) || ($AQ8 > 4219 && $AQ8 <= 4719) ||
|
||
|
|
($AQ8 > 4876 && $AQ8 <= 5219) || ($AQ8 > 5219 && $AQ8 <= 5369) || ($AQ8 > 9026 && $AQ8 <= 9219)) {
|
||
|
|
$row5_1 = 1 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row5_1 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row5_2 계산
|
||
|
|
if (($AQ8 > 1219 && $AQ8 <= 2438) || ($AQ8 > 4719 && $AQ8 <= 4876)) {
|
||
|
|
$row5_2 = 1 * $surang ;
|
||
|
|
} elseif (($AQ8 > 5369 && $AQ8 <= 5938) || ($AQ8 > 6000 && $AQ8 <= 6438) ||
|
||
|
|
($AQ8 > 6500 && $AQ8 <= 6588) || ($AQ8 > 8300 && $AQ8 <= 8376)) {
|
||
|
|
$row5_2 = 1 * $surang ;
|
||
|
|
} elseif (($AQ8 > 8438 && $AQ8 <= 8876) || ($AQ8 > 9000 && $AQ8 <= 9026) ||
|
||
|
|
($AQ8 > 9219 && $AQ8 <= 9438) || ($AQ8 > 10150 && $AQ8 <= 10738)) {
|
||
|
|
$row5_2 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row5_2 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row5_3 계산
|
||
|
|
if (($AQ8 > 2438 && $AQ8 <= 3000) || ($AQ8 > 4150 && $AQ8 <= 4219) ||
|
||
|
|
($AQ8 > 5369 && $AQ8 <= 5438) || ($AQ8 > 5938 && $AQ8 <= 6000) ||
|
||
|
|
($AQ8 > 6438 && $AQ8 <= 6500) || ($AQ8 > 7000 && $AQ8 <= 7150)) {
|
||
|
|
$row5_3 = 1 * $surang ;
|
||
|
|
} elseif (($AQ8 > 8376 && $AQ8 <= 8438) || ($AQ8 > 8876 && $AQ8 <= 9000) ||
|
||
|
|
($AQ8 > 9438 && $AQ8 <= 10150) || ($AQ8 > 10738 && $AQ8 <= 11000)) {
|
||
|
|
$row5_3 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row5_3 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row5_4 계산
|
||
|
|
if (($AQ8 > 3000 && $AQ8 <= 3500) || ($AQ8 > 4219 && $AQ8 <= 4719) ||
|
||
|
|
($AQ8 > 5438 && $AQ8 <= 5938) || ($AQ8 > 6438 && $AQ8 <= 6500) ||
|
||
|
|
($AQ8 > 6588 && $AQ8 <= 7000) || ($AQ8 > 7150 && $AQ8 <= 7650)) {
|
||
|
|
$row5_4 = 1 * $surang ;
|
||
|
|
} elseif (($AQ8 > 8300 && $AQ8 <= 8376) || ($AQ8 > 9219 && $AQ8 <= 9438)) {
|
||
|
|
$row5_4 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row5_4 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row5_5 계산
|
||
|
|
if (($AQ8 > 3500 && $AQ8 <= 4000) || ($AQ8 > 4876 && $AQ8 <= 5219) ||
|
||
|
|
($AQ8 > 6000 && $AQ8 <= 6438) || ($AQ8 > 7150 && $AQ8 <= 7500) ||
|
||
|
|
($AQ8 > 7650 && $AQ8 <= 8000) || ($AQ8 > 8000 && $AQ8 <= 8150)) {
|
||
|
|
$row5_5 = 1 * $surang ;
|
||
|
|
} elseif (($AQ8 > 8438 && $AQ8 <= 8876) || ($AQ8 > 9026 && $AQ8 <= 9219) ||
|
||
|
|
($AQ8 > 9500 && $AQ8 <= 10000) || ($AQ8 > 10150 && $AQ8 <= 10438) ||
|
||
|
|
($AQ8 > 10738 && $AQ8 <= 11000)) {
|
||
|
|
$row5_5 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row5_5 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row5_6 계산
|
||
|
|
if (($AQ8 > 4000 && $AQ8 <= 4150) || ($AQ8 > 5219 && $AQ8 <= 5369) ||
|
||
|
|
($AQ8 > 6500 && $AQ8 <= 6588) || ($AQ8 > 7000 && $AQ8 <= 7150) ||
|
||
|
|
($AQ8 > 7500 && $AQ8 <= 7650) || ($AQ8 > 8000 && $AQ8 <= 8150)) {
|
||
|
|
$row5_6 = 1 * $surang ;
|
||
|
|
} elseif (($AQ8 > 8150 && $AQ8 <= 8300) || ($AQ8 > 9000 && $AQ8 <= 9026) ||
|
||
|
|
($AQ8 > 10000 && $AQ8 <= 10150) || ($AQ8 > 10438 && $AQ8 <= 10738)) {
|
||
|
|
$row5_6 = 2 * $surang ;
|
||
|
|
} else {
|
||
|
|
$row5_6 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// row5_7과 row5_8 계산 (각 열의 합)
|
||
|
|
$row5_7_sum += floatval($item['col39']);
|
||
|
|
$row5_8_sum += floatval($item['col41']);
|
||
|
|
$row10_1_sum += floatval($item['col30']); // 레일용 연기차단제 산출해야 함.
|
||
|
|
$row10_2_sum += floatval($item['col42']); // 케이스용 연기차단제
|
||
|
|
|
||
|
|
// 누적 합계 계산
|
||
|
|
$row5_1_sum += $row5_1;
|
||
|
|
$row5_2_sum += $row5_2;
|
||
|
|
$row5_3_sum += $row5_3;
|
||
|
|
$row5_4_sum += $row5_4;
|
||
|
|
$row5_5_sum += $row5_5;
|
||
|
|
$row5_6_sum += $row5_6;
|
||
|
|
|
||
|
|
$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 m-1">';
|
||
|
|
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="2" 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 '</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="3" class="text-center">레일용</th>';
|
||
|
|
echo '<th rowspan="3" 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 '</tr>';
|
||
|
|
echo '<tr>';
|
||
|
|
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 '</tr>';
|
||
|
|
echo '<tr>';
|
||
|
|
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="3" class="text-center">케이스용</th>';
|
||
|
|
echo '<th rowspan="3" class="text-center text-primary fw-bold">' . ($row10_2_sum ?: '') . '</th>';
|
||
|
|
echo '</tr>';
|
||
|
|
echo '<tr>';
|
||
|
|
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 '</tr>';
|
||
|
|
echo '<tr>';
|
||
|
|
echo '<th class="text-center"></th>';
|
||
|
|
echo '<th class="text-center"></th>';
|
||
|
|
echo '<th class="text-center">4150</th>';
|
||
|
|
echo '<th class="text-center text-primary fw-bold">' . ($row5_6_sum ?: '') . '</th>';
|
||
|
|
echo '</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 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"></th>';
|
||
|
|
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;
|
||
|
|
$row6_7_sum = 0;
|
||
|
|
$row7_7_sum = 0;
|
||
|
|
$row8_7_sum = 0;
|
||
|
|
|
||
|
|
foreach ($decodedEstimateList as $item) {
|
||
|
|
// 무게평철
|
||
|
|
$col52 = floatval($item['col52']);
|
||
|
|
// 환봉
|
||
|
|
$col65 = floatval($item['col65']);
|
||
|
|
|
||
|
|
$col54 = floatval($item['col54']);
|
||
|
|
$col55 = floatval($item['col55']);
|
||
|
|
$col56 = floatval($item['col56']);
|
||
|
|
$col57 = floatval($item['col57']);
|
||
|
|
$col58 = floatval($item['col58']);
|
||
|
|
$col59 = floatval($item['col59']);
|
||
|
|
$col60 = floatval($item['col60']);
|
||
|
|
$col61 = floatval($item['col61']);
|
||
|
|
$col62 = floatval($item['col62']);
|
||
|
|
$col63 = floatval($item['col63']);
|
||
|
|
$col64 = floatval($item['col64']);
|
||
|
|
$col66 = floatval($item['col66']);
|
||
|
|
$col4 = $item['col4'];
|
||
|
|
$col8 = floatval($item['col8']);
|
||
|
|
$col53 = floatval($item['col53']);
|
||
|
|
|
||
|
|
// 초기화
|
||
|
|
$shaft6_1 = $shaft6_2 = $shaft6_3 = $shaft6_4 = 0;
|
||
|
|
|
||
|
|
// E8 계산
|
||
|
|
$E8 = (substr($col4, 0, 2) === 'KS') ? '스크린' : '철재';
|
||
|
|
|
||
|
|
// $shaft6_1 (이전 col61) 계산
|
||
|
|
if ($E8 === '스크린' && $col53 == 6 && $col8 > 8250 && $col8 <= 10200) {
|
||
|
|
$shaft6_1 = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
// $shaft6_2 (이전 col62) 계산
|
||
|
|
if ($E8 === '철재' && $col53 == 6 && $col8 <= 6000) {
|
||
|
|
$shaft6_2 = 1;
|
||
|
|
} elseif ($E8 === '스크린' && $col53 == 6 && $col8 > 8250 && $col8 <= 9050) {
|
||
|
|
$shaft6_2 = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
// $shaft6_3 (이전 col63) 계산
|
||
|
|
if ($E8 === '철재' && $col53 == 6 && $col8 > 6000 && $col8 <= 7000) {
|
||
|
|
$shaft6_3 = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
// $shaft6_4 (이전 col64) 계산
|
||
|
|
if ($E8 === '철재' && $col53 == 6 && $col8 > 7000 && $col8 <= 7800) {
|
||
|
|
$shaft6_4 = 1;
|
||
|
|
} elseif ($E8 === '스크린' && $col53 == 6 && $col8 > 7550 && $col8 <= 8250) {
|
||
|
|
$shaft6_4 = 1;
|
||
|
|
} elseif ($E8 === '스크린' && $col53 == 6 && $col8 > 9050 && $col8 <= 10550) {
|
||
|
|
$shaft6_4 = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
// $col54_500 계산
|
||
|
|
$col54_500 = ($E8 === '스크린' && $col53 == 6 && $col8 > 7550) ? 1 : 0;
|
||
|
|
|
||
|
|
// 누적 합계 계산 2인치 500 없어서 숫자 맞지 않음
|
||
|
|
$row2_4_sum += $col54;
|
||
|
|
$row3_4_sum += $col54_500;
|
||
|
|
$row4_4_sum += $col55;
|
||
|
|
$row5_4_sum += $col56;
|
||
|
|
$row6_4_sum += $col57;
|
||
|
|
$row7_4_sum += $col58;
|
||
|
|
$row8_4_sum += $col59;
|
||
|
|
$row9_4_sum += $col60;
|
||
|
|
$row10_4_sum += $shaft6_1;
|
||
|
|
$row11_4_sum += $shaft6_2;
|
||
|
|
$row12_4_sum += $shaft6_3;
|
||
|
|
$row13_4_sum += $shaft6_4;
|
||
|
|
$row2_7_sum += $col52; // 무게평철
|
||
|
|
$row4_7_sum += $col65;
|
||
|
|
$row6_7_sum += $col63;
|
||
|
|
$row7_7_sum += $col64;
|
||
|
|
$row8_7_sum += $col66;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 테이블 출력
|
||
|
|
echo '<div class="d-flex align-items-center justify-content-center m-1">';
|
||
|
|
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 (True) {
|
||
|
|
|
||
|
|
// 테이블 출력
|
||
|
|
echo '<div class="d-flex align-items-center justify-content-center mt-2 mb-5 m-1">';
|
||
|
|
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>
|
||
|
|
</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>
|
||
|
|
|
||
|
|
</body>
|
||
|
|
</html>
|
||
|
|
|
||
|
|
<!-- 페이지로딩 -->
|
||
|
|
<script>
|
||
|
|
$(document).ready(function(){
|
||
|
|
var loader = document.getElementById('loadingOverlay');
|
||
|
|
loader.style.display = 'none';
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
function generatePDF() {
|
||
|
|
var workplace = '<?php echo $outworkplace; ?>';
|
||
|
|
var deadline = '<?php echo $indate; ?>';
|
||
|
|
var deadlineDate = new Date(deadline);
|
||
|
|
var formattedDate = "(" + String(deadlineDate.getFullYear()).slice(-2) + "." + ("0" + (deadlineDate.getMonth() + 1)).slice(-2) + "." + ("0" + deadlineDate.getDate()).slice(-2) + ")";
|
||
|
|
var result = 'KD견적서(' + workplace +')' + formattedDate + '.pdf';
|
||
|
|
|
||
|
|
var element = document.getElementById('content-to-print');
|
||
|
|
var opt = {
|
||
|
|
margin: [15, 8, 17, 8], // Top, right, bottom, left margins
|
||
|
|
filename: result,
|
||
|
|
image: { type: 'jpeg', quality: 0.98 },
|
||
|
|
html2canvas: { scale: 2 },
|
||
|
|
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
|
||
|
|
pagebreak: { mode: [''] }
|
||
|
|
};
|
||
|
|
html2pdf().from(element).set(opt).save();
|
||
|
|
}
|
||
|
|
|
||
|
|
function generatePDF_server(callback) {
|
||
|
|
var workplace = '<?php echo $workplacename; ?>';
|
||
|
|
var item = '<?php echo $item; ?>';
|
||
|
|
var deadline = '<?php echo $deadline; ?>';
|
||
|
|
var deadlineDate = new Date(deadline);
|
||
|
|
var formattedDate = "(" + String(deadlineDate.getFullYear()).slice(-2) + "." + ("0" + (deadlineDate.getMonth() + 1)).slice(-2) + "." + ("0" + deadlineDate.getDate()).slice(-2) + ")";
|
||
|
|
var result = 'DH ' + item +'(' + workplace + ')' + formattedDate + '.pdf';
|
||
|
|
|
||
|
|
var element = document.getElementById('content-to-print');
|
||
|
|
var opt = {
|
||
|
|
margin: [15, 8, 17, 8], // Top, right, bottom, left margins
|
||
|
|
filename: result,
|
||
|
|
image: { type: 'jpeg', quality: 0.98 },
|
||
|
|
html2canvas: { scale: 2 },
|
||
|
|
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
|
||
|
|
pagebreak: { mode: [''] }
|
||
|
|
};
|
||
|
|
|
||
|
|
html2pdf().from(element).set(opt).output('datauristring').then(function (pdfDataUri) {
|
||
|
|
var pdfBase64 = pdfDataUri.split(',')[1]; // Base64 인코딩된 PDF 데이터 추출
|
||
|
|
var formData = new FormData();
|
||
|
|
formData.append('pdf', pdfBase64);
|
||
|
|
formData.append('filename', result);
|
||
|
|
|
||
|
|
$.ajax({
|
||
|
|
type: 'POST',
|
||
|
|
url: 'save_pdf.php', // PDF 파일을 저장하는 PHP 파일
|
||
|
|
data: formData,
|
||
|
|
processData: false,
|
||
|
|
contentType: false,
|
||
|
|
success: function (response) {
|
||
|
|
var res = JSON.parse(response);
|
||
|
|
if (callback) {
|
||
|
|
callback(res.filename); // 서버에 저장된 파일 경로를 콜백으로 전달
|
||
|
|
}
|
||
|
|
},
|
||
|
|
error: function (xhr, status, error) {
|
||
|
|
Swal.fire('Error', 'PDF 저장에 실패했습니다.', 'error');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function sendmail() {
|
||
|
|
var secondordnum = '<?php echo $secondordnum; ?>'; // 서버에서 가져온 값
|
||
|
|
var item = '<?php echo $item; ?>';
|
||
|
|
// console.log('secondordnum', secondordnum);
|
||
|
|
|
||
|
|
if (typeof ajaxRequest !== 'undefined' && ajaxRequest !== null) {
|
||
|
|
ajaxRequest.abort();
|
||
|
|
}
|
||
|
|
|
||
|
|
ajaxRequest = $.ajax({
|
||
|
|
type: 'POST',
|
||
|
|
url: 'get_companyCode.php', // 파일 이름 수정
|
||
|
|
data: { secondordnum: secondordnum },
|
||
|
|
dataType: 'json',
|
||
|
|
success: function(response) {
|
||
|
|
console.log('response : ', response);
|
||
|
|
if (response.error) {
|
||
|
|
Swal.fire('Error', response.error, 'error');
|
||
|
|
} else {
|
||
|
|
var email = response.email;
|
||
|
|
var vendorName = response.vendor_name;
|
||
|
|
|
||
|
|
Swal.fire({
|
||
|
|
title: '이메일 보내기',
|
||
|
|
text: '거래처(' + vendorName + ') Email : (' + email + ') 이메일 전송 하시겠습니까?',
|
||
|
|
icon: 'warning',
|
||
|
|
showCancelButton: true,
|
||
|
|
confirmButtonText: '보내기',
|
||
|
|
cancelButtonText: '취소',
|
||
|
|
reverseButtons: true
|
||
|
|
}).then((result) => {
|
||
|
|
if (result.isConfirmed) {
|
||
|
|
generatePDF_server(function(filename) {
|
||
|
|
sendEmail(email, vendorName, item, filename);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
error: function(xhr, status, error) {
|
||
|
|
Swal.fire('Error', '전송중 오류가 발생했습니다.', 'error');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function sendEmail(recipientEmail,vendorName, item, filename) {
|
||
|
|
// 이메일 전송 코드 작성 (예: PHP를 호출하여 이메일 전송)
|
||
|
|
if (typeof ajaxRequest !== 'undefined' && ajaxRequest !== null) {
|
||
|
|
ajaxRequest.abort();
|
||
|
|
}
|
||
|
|
var deadline = '<?php echo $deadline; ?>';
|
||
|
|
var deadlineDate = new Date(deadline);
|
||
|
|
var formattedDate = "(" + String(deadlineDate.getFullYear()).slice(-2) + "." + ("0" + (deadlineDate.getMonth() + 1)).slice(-2) + "." + ("0" + deadlineDate.getDate()).slice(-2) + ")";
|
||
|
|
|
||
|
|
ajaxRequest = $.ajax({
|
||
|
|
type: 'POST',
|
||
|
|
url: 'send_email.php', // 이메일 전송을 처리하는 PHP 파일
|
||
|
|
data: { email: recipientEmail, vendorName : vendorName, filename: filename, item : item, formattedDate :formattedDate },
|
||
|
|
success: function(response) {
|
||
|
|
console.log(response);
|
||
|
|
Swal.fire('Success', '정상적으로 전송되었습니다.', 'success');
|
||
|
|
},
|
||
|
|
error: function(xhr, status, error) {
|
||
|
|
Swal.fire('Error', '전송에 실패했습니다. 확인바랍니다.', 'error');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// 페이지가 완전히 로드된 후 실행
|
||
|
|
$(document).ready(function(){
|
||
|
|
var koreanTotalSum = '<?php echo $korean_total_sum; ?>';
|
||
|
|
var totalSum = Number('<?php echo $total_sum; ?>');
|
||
|
|
|
||
|
|
// ID가 'koreantotalsum'인 요소에 한글로 변환된 금액 표시
|
||
|
|
document.getElementById('koreantotalsum').innerText = koreanTotalSum;
|
||
|
|
|
||
|
|
// ID가 'totalsum'인 요소에 숫자 형식으로 변환된 금액 표시
|
||
|
|
document.getElementById('totalsum').innerText = totalSum.toLocaleString();
|
||
|
|
});
|
||
|
|
|
||
|
|
</script>
|