first commit 2

This commit is contained in:
hmw1001
2026-06-11 18:47:38 +09:00
parent c768729ce6
commit 6f534e33a6
11095 changed files with 1595758 additions and 0 deletions
@@ -0,0 +1,235 @@
<?php
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=견적서_".date('Ymd_His').".xls");
header("Content-Description: PHP5 Generated Data");
header("Content-charset=utf-8");
include_once('./_common.php');
// 1. 견적서 기본 정보 가져오기
$wr_id = isset($_GET['wr_id']) ? intval($_GET['wr_id']) : 0;
if (!$wr_id) die('잘못된 접근입니다.');
// 🔧 estimate 테이블에서 데이터 가져오기
$sql = "SELECT * FROM estimate WHERE wr_id = '{$wr_id}' AND is_deleted = 0";
$row = sql_fetch($sql);
if (!$row) die('존재하지 않는 견적서입니다.');
// 🔧 게시글 정보도 가져오기
$write_table = $g5['write_prefix'] . 'order'; // bo_table이 order라고 가정
$write_data = sql_fetch("SELECT * FROM {$write_table} WHERE wr_id = '{$wr_id}'");
if (!$write_data) die('게시글 정보를 찾을 수 없습니다.');
// 2. 견적 항목 가져오기
$id = $row['id'];
$sql2 = "SELECT * FROM estimate_item WHERE estimate_id = '{$id}' AND is_deleted = 0 ORDER BY no ASC";
$result2 = sql_query($sql2);
$seller_company = "(주)하이플랫폼";
$seller_address = "주소 : 서울시 동작구 사당로 20바길 19, 401";
$seller_ceo = "대표 : 권 재 원";
$seller_phone = "TEL : 010-8000-6456";
// 헤더 정의 - order2.php와 동일한 순서
$headers = array("No", "집형태", "위치", "품명", "규격", "창재질", "색상", "유리두께", "유리색상", "유리", "창비율", "창호형태", "교체위치", "시정장치", "시공여부", "수량", "단가", "금액");
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
td,th {mso-number-format:'\@'; font-family:'맑은 고딕',Malgun Gothic;}
.title {font-size:2em; font-weight:900; text-align:center;}
.underbar { border-bottom:1.5pt solid #222; }
</style>
<table border="0" style="width:100%;margin-bottom:24px;">
<tr>
<td class="title" colspan="8" style="text-align:center;font-size:2em;font-weight:900;">견적 사양서</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td style="width:40%;vertical-align:top;">
<table border="0" style="width:100%;">
<tr style="border-bottom:1px solid #222;">
<td colspan="2" style="width:100px;">업체명 :</td>
<td colspan="4" style="width:400px;">
<?=htmlspecialchars($row['company_name'] ?: '')?> 귀하
</td>
</tr>
<tr style="border-bottom:1px solid #222;">
<td colspan="2">현장명 :</td>
<td colspan="4" >
<?=htmlspecialchars($row['site_name'])?>
</td>
</tr>
<tr style="border-bottom:1px solid #222;">
<td colspan="2">견적일자 :</td>
<td colspan="4">
<?=htmlspecialchars($row['estimate_date'])?>
</td>
</tr>
</table>
</td>
<td style="width:20%" colspan="3"></td>
<td style="width:40%;vertical-align:top;">
<table border="0" style="width:100%;">
<tr><td colspan=5 style="font-weight:bold;"><?=$seller_company?></td></tr>
<tr><td colspan=5><?=$seller_address?></td></tr>
<tr><td colspan=5><?=$seller_ceo?> <img src="https://jmhc2021.cafe24.com/program/sign.png" style="height:30px;margin-bottom:-10px;"></td></tr>
<tr><td colspan=5><?=$seller_phone?></td></tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
<div>하기와 같이 견적합니다</div>
<table border="1" cellpadding="4" cellspacing="0">
<thead>
<tr>
<?php foreach($headers as $h) echo "<th style='background:#eee'>{$h}</th>"; ?>
</tr>
</thead>
<tbody>
<?php
$sum = 0;
$row_index = 1;
// order2.php와 일치하는 데이터 매핑
while($item = sql_fetch_array($result2)) {
echo "<tr>";
// No - 순서대로 번호 부여
echo "<td>{$row_index}</td>";
// 집형태 - 게시글의 wr_2에서 가져옴 또는 item의 house_type
$house_type = !empty($item['house_type']) ? $item['house_type'] : $write_data['wr_2'];
echo "<td>".htmlspecialchars($house_type ?: '')."</td>";
// 위치 (location 또는 windowsposion)
$location = !empty($item['location']) ? $item['location'] : (!empty($item['windowsposion']) ? $item['windowsposion'] : '');
echo "<td>".htmlspecialchars($location)."</td>";
// 품명
echo "<td>".htmlspecialchars($item['product'])."</td>";
// 규격 (폭 x 높이)
$width = !empty($item['spec_width']) ? $item['spec_width'] : (!empty($item['width']) ? $item['width'] : '');
$height = !empty($item['spec_height']) ? $item['spec_height'] : (!empty($item['height']) ? $item['height'] : '');
echo "<td style='width:100px'>".htmlspecialchars($width)." × ".htmlspecialchars($height)."</td>";
// 창재질 - 게시글의 wr_4에서 가져옴 또는 기본값
$window_material = !empty($item['window_material']) ? $item['window_material'] : $write_data['wr_4'];
echo "<td>".htmlspecialchars($window_material ?: 'PVC(폴리염화비닐)')."</td>";
// 색상
echo "<td style='width:50px'>".htmlspecialchars($item['color'])."</td>";
// 유리두께
echo "<td style='width:50px'>".htmlspecialchars($item['glass_thickness'])."</td>";
// 유리색상
echo "<td>".htmlspecialchars($item['glass_color'])."</td>";
// 유리 (복층유리/단층유리/삼중유리)
$glass = !empty($item['glass_type']) ? $item['glass_type'] : (!empty($item['glass']) ? $item['glass'] : '');
echo "<td>".htmlspecialchars($glass)."</td>";
// 창비율
echo "<td>".htmlspecialchars($item['windowRatio'])."</td>";
// 창호형태
echo "<td>".htmlspecialchars($item['windowType'])."</td>";
// 교체위치
echo "<td style='width:50px'>".htmlspecialchars($item['replacePart'])."</td>";
// 시정장치 (손잡이)
echo "<td>".htmlspecialchars($item['handle'])."</td>";
// 시공여부
echo "<td style='width:50px'>".htmlspecialchars($item['install'])."</td>";
// 수량
echo "<td style='width:30px'>".htmlspecialchars($item['qty'])."</td>";
// 단가
echo "<td style='text-align:right'>".number_format((int)$item['price'])."</td>";
// 금액
echo "<td style='text-align:right;font-weight:bold'>".number_format((int)$item['amount'])."</td>";
$sum += (int)$item['amount'];
$row_index++;
echo "</tr>";
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="<?=count($headers)-1?>" style="text-align:center;font-weight:bold;background:#ccc">합계</td>
<td style='text-align:right;font-weight:bold;background:#ccc;color:#d9534f;font-size:1.1em;'><?=number_format($sum)?> 원</td>
</tr>
<tr>
<td colspan="<?=count($headers)?>" style="text-align:left;padding:15px;">
<strong>비고</strong><br>
** 시공비 견적은 창호전문상담가의 방문으로 가능합니다.<br>
** 본 견적서는 <?=date('Y년 m월 d일')?> 기준으로 작성되었습니다.<br>
** 견적 유효기간: 견적일로부터 30일<br>
** 시장 상황에 따라 가격이 변동될 수 있습니다.
</td>
</tr>
</tfoot>
</table>
<!-- 추가 정보 테이블 -->
<table border="1" cellpadding="8" cellspacing="0" style="margin-top:30px;width:100%;">
<tr style="background:#f8f9fa;">
<th colspan="4" style="text-align:center;font-size:1.2em;font-weight:bold;">견적 요청 정보</th>
</tr>
<tr>
<th style="width:15%;background:#e9ecef;">고객명</th>
<td style="width:35%;"><?=htmlspecialchars($write_data['wr_name'] ?: '')?></td>
<th style="width:15%;background:#e9ecef;">연락처</th>
<td style="width:35%;">***-****-****</td>
</tr>
<tr>
<th style="background:#e9ecef;">주소</th>
<td colspan="3">
<?php
// 개인정보 보호를 위한 주소 마스킹
$address = ($write_data['wr_6'] ?: '') . ' ' . ($write_data['wr_7'] ?: '');
if (strlen(trim($address)) > 10) {
echo substr($address, 0, 10) . '***';
} else {
echo '***';
}
?>
</td>
</tr>
<tr>
<th style="background:#e9ecef;">요청사항</th>
<td colspan="3">
<?php
$content = strip_tags($write_data['wr_content'] ?: '');
// 개인정보 필터링
$content = preg_replace('/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/', '***@***.***', $content);
$content = preg_replace('/(\d{2,3})-?(\d{3,4})-?(\d{4})/', '***-****-****', $content);
echo htmlspecialchars(mb_substr($content, 0, 200)) . (mb_strlen($content) > 200 ? '...' : '');
?>
</td>
</tr>
</table>
<div style="margin-top:30px;padding:15px;border:2px solid #007bff;background:#f8f9ff;">
<h4 style="color:#007bff;margin:0 0 10px 0;">📋 견적처 정보</h4>
<p style="margin:0;line-height:1.6;">
<strong><?=$seller_company?></strong><br>
<?=$seller_address?><br>
<?=$seller_ceo?><br>
<?=$seller_phone?><br>
<strong>견적일자:</strong> <?=htmlspecialchars($row['estimate_date'])?><br>
<strong>견적번호:</strong> EST-<?=str_pad($wr_id, 6, '0', STR_PAD_LEFT)?>
</p>
</div>