Files
firstgarden-web-gnu/adm/fg_admin/orderlist_ticket.php

410 lines
19 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$sub_menu = '998411';
include_once('./_common.php');
auth_check($auth[$sub_menu], "r");
$g5['title'] = '매표소 주문확인';
include_once (G5_ADMIN_PATH.'/admin.head.php');
include_once(G5_PLUGIN_PATH.'/jquery-ui/datepicker.php');
$where = array();
// 퍼스트가든용
// 특정 카테고리만 노출 제외를 위한 부분
$ca_id = "30"; // 분류 선택
$sel_ca_id = "ca_id = $ca_id "; // 특정 카테고리 노출만 하려면 NOT을 지운다. 카테고리는 '분류관리'에서 확인, 최상위 카테고리 기준. 값을 추가할땐 or 을 사용하면 될듯.
$tot_ct_qty = 0;
$where[] = "$sel_ca_id"; // 배열에 검색문을 넣어준다
$od_status = '입금'; //입금처리 된것만 출력한다.
$where[] = " a.od_status = '{$od_status}' ";
// 퍼스트가든용 끝
include_once ('orderlist_head.php');
$sql_search = "";
if ($search != "") {
if ($sel_field != "") {
$where[] = " $sel_field like '%$search%' ";
}
if ($save_search != $search) {
$page = 1;
}
}
if ($where) {
$sql_search = ' WHERE '.implode(' AND ', $where);
}
if ($sel_field == "") $sel_field = "a.od_id";
if ($sort1 == "") $sort1 = "a.od_id";
if ($sort2 == "") $sort2 = "desc";
// 상품명, 단가, 수량, 카테고리를 불러오기 위해 DB를 합친다
$sql_common = " FROM {$g5['g5_shop_order_table']} AS a
LEFT JOIN {$g5['g5_shop_cart_table']} AS b ON a.od_id = b.od_id
LEFT JOIN {$g5['g5_shop_item_table']} AS c ON b.it_id = c.it_id
LEFT JOIN {$g5['g5_shop_item_option_table']} AS d ON c.it_id = d.it_id AND b.io_id = d.io_id
";
$sql_common .= $sql_search;
$sql = " SELECT count(a.od_id) AS cnt " . $sql_common ;
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = 100; // 페이지 당 출력 개수
if( !isset($rows) ) $rows = $config['cf_page_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
// 상품명, 수량, 단가, 카테고리를 가져옴
$sql = " SELECT a.*,
(a.od_cart_coupon + a.od_coupon + a.od_send_coupon) as couponprice,
b.it_name,
b.ct_qty,
b.ct_price,
b.ct_option,
b.io_id,
c.ca_id,
c.it_1,
c.it_2,
d.io_price
$sql_common
ORDER BY $sort1 $sort2
LIMIT $from_record, $rows ";
$result = sql_query($sql);
$qstr1 = "od_status=".urlencode($od_status)."&amp;
od_settle_case=".urlencode($od_settle_case)."&amp;
od_misu=$od_misu&amp
;od_cancel_price=$od_cancel_price&amp;
od_refund_price=$od_refund_price&amp;
od_receipt_point=$od_receipt_point&amp;
od_coupon=$od_coupon&amp;
fr_date=$fr_date&amp;
to_date=$to_date&amp;
sel_field=$sel_field&amp;
search=$search&amp;
save_search=$search";
if($default['de_escrow_use'])
$qstr1 .= "&amp;od_escrow=$od_escrow";
$qstr = "$qstr1&amp;sort1=$sort1&amp;sort2=$sort2&amp;page=$page";
$listall = '<a href="'.$_SERVER['SCRIPT_NAME'].'" class="ov_listall">전체목록</a>';
// 주문삭제 히스토리 테이블 필드 추가
if(!sql_query(" SELECT mb_id FROM {$g5['g5_shop_order_delete_table']} LIMIT 1 ", false)) {
sql_query(" ALTER TABLE `{$g5['g5_shop_order_delete_table']}`
ADD `mb_id` varchar(20) NOT NULL DEFAULT '' AFTER `de_data`,
ADD `de_ip` varchar(255) NOT NULL DEFAULT '' AFTER `mb_id`,
ADD `de_datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `de_ip` ", true);
}
?>
<style>
#container { height: unset;}
.search_and_export_wrap {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 20px;
margin-bottom: 20px;
}
.search_and_export_wrap form {
flex: 1;
}
.export_btn_wrap {
display: flex;
gap: 10px;
align-items: flex-start;
}
.export_btn_wrap button {
white-space: nowrap;
}
</style>
<div class="search_and_export_wrap">
<form name="frmorderlist" class="local_sch01 local_sch">
<input type="hidden" name="doc" value="<?php echo $doc; ?>">
<input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
<input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">
<input type="hidden" name="save_search" value="<?php echo $search; ?>">
<label for="sel_field" class="sound_only">검색대상</label>
<select name="sel_field" id="sel_field">
<option value="od_hp" <?php echo get_selected($sel_field, 'od_hp'); ?> selected>연락처</option>
<option value="od_name" <?php echo get_selected($sel_field, 'od_name'); ?>>주문자</option>
<option value="od_id" <?php echo get_selected($sel_field, 'od_id'); ?>>주문번호</option>
</select>
<label for="search" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
<input type="text" name="search" value="<?php echo $search; ?>" id="search" class="frm_input" autocomplete="off">
<input type="submit" value="검색" class="btn_submit">
</form>
<div class="export_btn_wrap">
<form method="post" action="orderlist_ticket_ex.php" target="_blank">
<input type="hidden" name="sql_common" value="<?php echo htmlspecialchars($sql_common); ?>">
<input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
<input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
<button type="submit" class="btn btn_submit" style="background-color: #4CAF50;">엑셀 다운로드</button>
</form>
</div>
</div>
<!--
<form class="local_sch03 local_sch">
<div class="sch_last"">
<strong>주문일자</strong>
<input type="text" id="fr_date" name="fr_date" value="<?php echo $fr_date; ?>" class="frm_input" size="10" maxlength="10"> ~
<input type="text" id="to_date" name="to_date" value="<?php echo $to_date; ?>" class="frm_input" size="10" maxlength="10">
<button type="button" onclick="javascript:set_date('오늘');">오늘</button>
<button type="button" onclick="javascript:set_date('어제');">어제</button>
<button type="button" onclick="javascript:set_date('이번주');">이번주</button>
<button type="button" onclick="javascript:set_date('이번달');">이번달</button>
<button type="button" onclick="javascript:set_date('지난주');">지난주</button>
<button type="button" onclick="javascript:set_date('지난달');">지난달</button>
<button type="button" onclick="javascript:set_date('전체');">전체</button>
<input type="submit" value="검색" class="btn_submit">
</div>
</form>
-->
<!-- 엑셀변환 작업중
<div>
<form method="post" action="orderlist_ticket_ex.php">
<input type="hidden" name="sql_common" value="<?=$sql_common?>">
<input type="hidden" name="sort1" value="<?=$sort1?>">
<input type="hidden" name="sort2" value="<?=$sort2?>">
<input type="hidden" name="from_record" value="<?=$from_record?>">
<input type="hidden" name="rows" value="<?=$rows?>" >
<input type="submit" value="엑셀저장" class="list_excel">
</form>
</div>
-->
<!-- 크리스마스용 판매확인 -->
<?php
$count_sql = "SELECT a.*, (a.od_cart_coupon + a.od_coupon + a.od_send_coupon) as couponprice, b.it_name, b.ct_qty, b.ct_price, b.ct_option, b.io_id, c.ca_id, c.it_1, c.it_2, d.io_price
FROM {$g5['g5_shop_order_table']} AS a
LEFT JOIN {$g5['g5_shop_cart_table']} AS b ON a.od_id = b.od_id
LEFT JOIN {$g5['g5_shop_item_table']} AS c ON b.it_id = c.it_id
LEFT JOIN {$g5['g5_shop_item_option_table']} AS d ON c.it_id = d.it_id AND b.io_id = d.io_id";
//$test = $count_sql.' WHERE b.it_name = "2024 크리스마스 이브 - 캔들라이트 콘서트" AND b.io_id = "R석일반"';
function cntQuery($count_sql,$where){
$query = sql_query($count_sql.$where);
if (sql_num_rows($query)) {
foreach ($query as $row) {
if (!isset($result)) $result = $row['ct_qty'];
else $result += $row['ct_qty'];
}
return $result;
} else {
return 0;
}
}
// 크리스마스 수량 취합하기
$eve_id = "1764036560";
$xmas_id = "1764036885";
$xmas_eve_r = cntQuery($count_sql," WHERE a.od_status = '입금' AND b.it_id = '{$eve_id}' AND b.io_id = 'R일반'");
$xmas_eve_s = cntQuery($count_sql," WHERE a.od_status = '입금' AND b.it_id = '{$eve_id}' AND b.io_id = 'S일반'");
$xmas_eve_a = cntQuery($count_sql," WHERE a.od_status = '입금' AND b.it_id = '{$eve_id}' AND b.io_id = 'A일반'");
$xmas_eve_36 = cntQuery($count_sql," WHERE a.od_status = '입금' AND b.it_id = '{$eve_id}' AND (b.io_id = 'R36개월미만 OR b.io_id = S석36개월미만' OR b.io_id = 'A석36개월미만')");
$xmas_eve_total = $xmas_eve_r + $xmas_eve_s + $xmas_eve_a + $xmas_eve_36;
$xmas_n = cntQuery($count_sql," WHERE a.od_status = '입금' AND b.it_id = '{$xmas_id}' AND b.io_id = '대인'");
$xmas_s = cntQuery($count_sql," WHERE a.od_status = '입금' AND b.it_id = '{$xmas_id}' AND b.io_id = '소인'");
$xmas_36 = cntQuery($count_sql," WHERE a.od_status = '입금' AND b.it_id = '{$xmas_id}' AND b.io_id = '36개월미만'");
$xmas_total = $xmas_n + $xmas_s + $xmas_36;
?>
<div class="tbl_head01 tbl_wrap">
<h2>크리스마스주문내역 Total</h2>
<p><b>전체 주문수량 : <?=$xmas_total+$xmas_eve_total?></b>
<div class="table_wrap" style="display: flex;flex-direction: row;justify-content: space-around;">
<div style="width: 49.5%">
<h3>크리스마스 이브</h3>
<table>
<thead>
<tr>
<th>R석</th>
<th>S석</th>
<th>A석</th>
<th>유아</th>
<th><b>계</b></th>
</tr>
</thead>
<tbody>
<tr>
<td><?=$xmas_eve_r?></td>
<td><?=$xmas_eve_s?></td>
<td><?=$xmas_eve_a?></td>
<td><?=$xmas_eve_36?></td>
<td><b><?=$xmas_eve_total?></b></td>
</tr>
</tbody>
</table>
</div>
<div style="width: 49.5%">
<h3>크리스마스</h3>
<table>
<thead>
<tr>
<th>대인</th>
<th>소인</th>
<th>유아</th>
<th><b>계</b></th>
</tr>
</thead>
<tbody>
<tr>
<td><?=$xmas_n?></td>
<td><?=$xmas_s?></td>
<td><?=$xmas_36?></td>
<td><b><?=$xmas_total?></b></td>
</tr>
</tbody>
</table>
</div>
</div>
<p>미사용 주문 수량에 대해서만 합산합니다. </p>
</div>
<!-- 크리스마스용 판매확인 끝 -->
<form name="forderlist" id="forderlist" onsubmit="return forderlist_submit(this);" method="post" autocomplete="off">
<input type="hidden" name="search_od_status" value="<?php echo $od_status; ?>">
<!-- 목록 시작 -->
<div class="tbl_head01 tbl_wrap">
<table id="sodr_list">
<caption>주문 내역 목록</caption>
<thead>
<tr>
<!-- 체크박스 제거
<th scope="col">
<label for="chkall" class="sound_only">주문 전체</label>
<input type="checkbox" name="chkall" value="1" id="chkall" onclick="check_all(this.form)">
</th>
-->
<!-- <th scope="col" id="th_ordnum" style="width:200px;"><a href="<?php echo title_sort("od_id", 1)."&amp;$qstr1"; ?>">주문번호</a></th>-->
<th scope="col" id="th_odrer">주문일</th>
<th scope="col" id="th_odrer">주문자</th>
<th scope="col" id="th_odrertel">주문자전화</th>
<th scope="col" id="th_odrer" style="width:240px;">상품명</th>
<th scope="col" id="th_odrer">옵션</th>
<th scope="col" style="width:85px;">단가</th>
<th scope="col" style="width:62px;">주문수량</th>
<th scope="col" style="width:85px;">합계</th>
<!-- <th scope="col">입금합계</th>-->
<th scope="col" style="min-width:62px;">사용처리</th>
<th scope="col" style="min-width:62px;">상세</th>
</tr>
</thead>
<tbody>
<?php
$chk_od_id == "false";
for ($i=0; $row=sql_fetch_array($result); $i++) {
$mb_nick = get_sideview($row['mb_id'], get_text($row['od_name']), $row['od_email'], '');
?>
<!-- 목록 내용 시작 -->
<tr class="orderlist<?php echo ' '.$bg; ?>">
<!-- 체크박스 제거
<td class="td_chk">
<input type="hidden" name="od_id[<?php echo $i ?>]" value="<?php echo $row['od_id'] ?>" id="od_id_<?php echo $i ?>">
<label for="chk_<?php echo $i; ?>" class="sound_only">주문번호 <?php echo $row['od_id']; ?></label>
<input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i ?>">
</td>
-->
<!-- 주문번호 표시안함
<td headers="th_ordnum" class="td_odrnum2">
<?php if ($is_admin == 'super'){ ?>
<a href="<?php echo G5_SHOP_URL; ?>/orderinquiryview.php?od_id=<?php echo $row['od_id']; ?>&amp;uid=<?php echo $uid; ?>" class="orderitem"><?php echo $disp_od_id; ?></a>
<?php } else { echo $disp_od_id; }?>
<?php echo $od_mobile; ?>
<?php echo $od_paytype; ?>
</td>
-->
<td headers="th_ordnum" class="td_odrnum2"><?php if ($row['od_id'] != $chk_od_id ) { echo substr($row['od_receipt_time'],0,10); }?></td>
<td headers="th_odrer" class="td_name"><?php if ($row['od_id'] != $chk_od_id ) { echo $mb_nick; }?></td>
<td headers="th_odrertel" class="td_hp" style="text-align:center;"><?php if ($row['od_id'] != $chk_od_id ) { echo add_hyphen(get_text($row['od_hp'])); }?></td>
<td headers="th_ordnum" class="td_odrnum2"><?php if ($row['od_id'] != $chk_od_id ) { echo $row['it_name']; } ?></td>
<td heardrs="th_ordnum" class="td_odrnum2"><?php echo ($row['io_id']) ? $row['io_id'] : '' ?> </td>
<td headers="th_odrcnt"><?php echo ($row['io_price']) ? number_format($row['ct_price']+$row['io_price']) : number_format($row['ct_price']) ?></td>
<td headers="th_odrcnt"><?php echo $row['ct_qty']; ?></td>
<td class="td_num td_numsum">
<?php echo number_format(($row['ct_price'] + $row['io_price']) * $row['ct_qty']); ?>
<?php // echo number_format($row['od_cart_price'] + $row['od_send_cost'] + $row['od_send_cost2']); // 같은 승인번호의 결제건 여러개가 있는 경우 금액이 알아보기 불편함 ?></td>
<!-- <td class="td_num_right"><?php echo number_format($row['od_receipt_price']); ?></td>-->
<td class="td_mng td_mng_s">
<?php
// 사용처리
// 사용처리 버튼 출력을 위한 부분
if ($row['it_2'] && (substr($row['od_receipt_time'],0,10) == date('Y-m-d'))) { // 당일주문 사용불가 대상 & 당일주문 체크
echo '사용불가<br>당일주문';
// 상태가 '입금' 이 아니면서 유효기간이 지났거나 주문 상태가 취소인 경우
} else if ($row['od_status'] != '입금' || $row['it_1'] < date("ymd") && !isset($row['it_1']) || $row['od_status'] == '취소') {
echo "사용불가<br>(";
if( $row['od_status'] == '취소' ) echo "취소)"; // 취소라면
else echo "유효일자:".$row['it_1'].")"; // 유효일자가 지났다면
} else if ($row['od_id'] === $chk_od_id) { // 동일 주문번호에는 출력하지 않음
} else { // 위 조건에 해당하지 않으면 사용처리 버튼 출력
?>
<a href="orderliveupdate.php?bo=u&od_id=<?php echo $row['od_id']; ?>&st=<?php echo $row['od_status'];?>" class="mng_mod btn btn_04"><span class="sound_only"><?php echo $row['od_id']; ?></span>사용</a>
<?php } //사용처리 버튼 끝 ?>
</td>
<td class="td_mng td_mng_s">
<?php if ($row['od_id'] != $chk_od_id ) { ?>
<a href="./orderform.php?od_id=<?php echo $row['od_id']; ?>&amp;<?php echo $qstr; ?>" class="mng_mod btn btn_02"><span class="sound_only"><?php echo $row['od_id']; ?> </span>보기</a>
<?php } ?>
</td>
</tr>
<?php
// 합계 처리
$tot_itemcount += $row['od_cart_count'];
$tot_orderprice += (($row['ct_price'] + $row['io_price']) * $row['ct_qty']);
// $tot_orderprice += ($row['od_cart_price'] + $row['od_send_cost'] + $row['od_send_cost2']);
$tot_ordercancel += $row['od_cancel_price'];
$tot_receiptprice += $row['od_receipt_price'];
$tot_couponprice += $row['couponprice'];
$tot_ct_qty += $row['ct_qty'];
// 주문번호 체크용
$chk_od_id = $row['od_id'];
}
sql_free_result($result);
if ($i == 0)
echo '<tr><td colspan="11" class="empty_table">자료가 없습니다.</td></tr>';
?>
</tbody>
<tfoot>
<tr class="orderlist">
<th scope="row" colspan="6">합 계</th>
<td><?php echo $tot_ct_qty //number_format($tot_itemcount); ?>건</td>
<td><?php echo number_format($tot_orderprice); ?></td>
<!-- <td><?php echo number_format($tot_receiptprice); ?></td>-->
<td colspan="2"></td>
</tr>
</tfoot>
</table>
</div>
<div class="local_desc02 local_desc">
<p style="font-weight:bold;">
&lt;사용&gt;버튼을 클릭하면 티켓 사용처리가 완료됩니다. 부분사용, 부분취소가 불가능하므로 이용수량이 다른 경우 고객님께 꼭 확인해주시기 바랍니다.
</p>
</div>
</form>
<?php echo get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, "{$_SERVER['SCRIPT_NAME']}?$qstr&amp;page="); ?>
<?php
include_once ('orderlist_tail.php');
include_once (G5_ADMIN_PATH.'/admin.tail.php');