주문폼 배송지 처리 코드 수정

This commit is contained in:
chicpro
2013-09-30 12:01:11 +09:00
parent 2d67692225
commit 446570b3d4
4 changed files with 57 additions and 68 deletions

View File

@ -26,7 +26,7 @@ $sql = " select *
where mb_id = '{$member['mb_id']}'
order by
ad_default desc,
ad_id desc
ad_id desc
limit $from_record, $rows";
$result = sql_query($sql);
@ -45,7 +45,7 @@ if (G5_IS_MOBILE) {
$g5['title'] = '배송지 목록';
include_once(G5_PATH.'/head.sub.php');
$order_action_url = G5_HTTPS_SHOP_URL.'/orderaddress_update.php';
$order_action_url = G5_HTTPS_SHOP_URL.'/orderaddressupdate.php';
?>
<form name="forderaddress" method="post" action="<?php echo $order_action_url; ?>" autocomplete="off">
@ -77,10 +77,10 @@ $order_action_url = G5_HTTPS_SHOP_URL.'/orderaddress_update.php';
?>
<tr>
<td class="td_chk"><label for="chk_<?php echo $i;?>" class="sound_only">배송지선택</label>
<input type="hidden" name="ad_id[]" value="<?php echo $row['ad_id'];?>">
<input type="hidden" name="ad_id[<?php echo $i; ?>]" value="<?php echo $row['ad_id'];?>">
<input type="checkbox" name="chk[]" value="<?php echo $i;?>" id="chk_<?php echo $i;?>">
</td>
<td class="td_name"><input type="text" name="ad_subject[]" id="ad_subject" class="frm_input" size="12" maxlength="20" value="<?php echo $row['ad_subject']; ?>"></td>
<td class="td_name"><input type="text" name="ad_subject[<?php echo $i; ?>]" id="ad_subject" class="frm_input" size="12" maxlength="20" value="<?php echo $row['ad_subject']; ?>"></td>
<td class="td_default"><label for="ad_default<?php echo $i;?>" class="sound_only">기본배송지</label><input type="radio" name="ad_default" value="<?php echo $row['ad_id'];?>" id="ad_default<?php echo $i;?>" <?php if($row['ad_default']) echo 'checked="checked"';?>></td>
<td class="td_smallname"><?php echo $row['ad_name']; ?></td>
<td class="td_bignum"><?php echo $row['ad_tel']; ?><br><?php echo $row['ad_hp']; ?></td>
@ -139,16 +139,16 @@ $(function() {
});
// 전체선택 부분
$("#chk_all").on("change", function() {
if ($(this).attr("checked")){
$("input[type='checkbox']:not(checked)").attr("checked", true);
}else{
$("input[type='checkbox']:checked").attr("checked", false);
$("#chk_all").on("click", function() {
if($(this).is(":checked")) {
$("input[name^='chk[']").attr("checked", true);
} else {
$("input[name^='chk[']").attr("checked", false);
}
});
$("#btn_submit").on("click", function() {
if( $(":checkbox:checked").length==0 ){
if($("input[name^='chk[']:checked").length==0 ){
alert("수정하실 항목을 하나 이상 선택하세요.");
return false;
}

View File

@ -1,47 +1,36 @@
<?php
include_once('./_common.php');
if (!count($_POST['chk'])) {
if($is_guest)
die_utf8('회원 로그인 후 이용해 주십시오.');
$count = count($_POST['chk']);
if (!$count) {
alert('수정하실 항목을 하나이상 선택하세요.');
exit;
}
if ($is_member && count($_POST['chk'])) {
for ($i=0; $i<count($_POST['chk']); $i++)
if ($is_member && $count) {
for ($i=0; $i<$count; $i++)
{
// 실제 번호를 넘김
$k = $_POST['chk'][$i];
// 기본배송지 값이 안넘어올때 (기본배송지를 설정 안했을시)
$sql = " update `{$g5['g5_shop_order_address_table']}` ";
// 기본배송지 값이 있지만 선택한 배송지와 기존의 기본배송지가 다를때
if ($_POST['ad_id'][$k] != $_POST['ad_default']){
$sql .= " set ad_subject = '{$_POST['ad_subject'][$k]}'
where ad_id = '{$_POST['ad_id'][$k]}'
and mb_id = '{$member['mb_id']}' ";
sql_query($sql);
}
// 체크한 값이 기본배송지로 선택 되었다면
else if ($_POST['ad_id'][$k] == $_POST['ad_default']){
$sql .= " set ad_default = '0'
where mb_id = '{$member['mb_id']}' ";
sql_query($sql);
$sql = " update `{$g5['g5_shop_order_address_table']}`
set ad_subject = '{$_POST['ad_subject'][$k]}',
ad_default = '1'
where ad_id = '{$_POST['ad_id'][$k]}'
and mb_id = '{$member['mb_id']}' ";
sql_query($sql);
}else{
$sql .= " set ad_subject = '{$_POST['ad_subject'][$k]}'
where ad_id = '{$_POST['ad_id'][$k]}'
and mb_id = '{$member['mb_id']}' ";
sql_query($sql);
$sql = " update {$g5['g5_shop_order_address_table']}
set ad_subject = '{$_POST['ad_subject'][$k]}' ";
if($_POST['ad_default'] && $_POST['ad_id'][$k] == $_POST['ad_default']) {
sql_query(" update {$g5['g5_shop_order_address_table']} set ad_default = '0' where mb_id = '{$member['mb_id']}' ");
$sql .= ", ad_default = '1' ";
}
$sql .= " where ad_id = '{$_POST['ad_id'][$k]}'
and mb_id = '{$member['mb_id']}' ";
sql_query($sql);
}
}
goto_url(G5_SHOP_URL.'/orderaddress.php?od_id='.$od_id.'&amp;uid='.$uid);
goto_url(G5_SHOP_URL.'/orderaddress.php');
?>

View File

@ -293,7 +293,7 @@ function get_intall_file()
alert('장바구니가 비어 있습니다.', G5_SHOP_URL.'/cart.php');
} else {
// 배송비 계산
$send_cost = get_sendcost($tot_sell_price, $s_cart_id);
$send_cost = get_sendcost($s_cart_id);
}
// 복합과세처리
@ -664,7 +664,7 @@ function get_intall_file()
$sep = chr(30);
// 주문자와 동일
$addr_list .= '<input type="radio" name="ad_sel_addr" id="ad_sel_addr_same">'.PHP_EOL;
$addr_list .= '<input type="radio" name="ad_sel_addr" value="same">'.PHP_EOL;
$addr_list .= '<label for="ad_sel_addr_same">주문자와 동일</label>'.PHP_EOL;
// 기본배송지
@ -683,6 +683,7 @@ function get_intall_file()
$sql = " select *
from {$g5['g5_shop_order_address_table']}
where mb_id = '{$member['mb_id']}'
and ad_default = '0'
order by ad_id desc
limit 2 ";
$result = sql_query($sql);
@ -1264,8 +1265,10 @@ $(function() {
// 배송지선택
$("input[name=ad_sel_addr]").on("click", function() {
var addr = $(this).val().split(String.fromCharCode(30));
if ($(this).attr("id") == "ad_sel_addr_same"); // 이 아이디가 ad_sel_addr_same 일때는 아무런 실행도 하지 않는다.
else{ // 아닐땐 실행
if (addr[0] == "same") {
gumae2baesong();
} else {
if(addr[0] == "new") {
for(i=0; i<8; i++) {
addr[i] = "";
@ -1659,7 +1662,7 @@ function forderform_check(f)
}
// 구매자 정보와 동일합니다.
$("#ad_sel_addr_same").on("click", function(){
function gumae2baesong() {
var f = document.forderform;
f.od_b_name.value = f.od_name.value;
@ -1671,7 +1674,7 @@ $("#ad_sel_addr_same").on("click", function(){
f.od_b_addr2.value = f.od_addr2.value;
calculate_sendcost(String(f.od_b_zip1.value) + String(f.od_b_zip2.value));
});
}
// 구매자 정보와 동일 함수 끝
<?php if ($default['de_hope_date_use']) { ?>

View File

@ -579,34 +579,30 @@ if (get_session('ss_direct'))
if($is_member) {
$sql = " select * from {$g5['g5_shop_order_address_table']}
where mb_id = '{$member['mb_id']}'
and ad_name = '{$_POST['od_b_name']}'
and ad_tel = '{$_POST['od_b_tel']}'
and ad_hp = '{$_POST['od_b_hp']}'
and ad_zip1 = '{$_POST['od_b_zip1']}'
and ad_zip2 = '{$_POST['od_b_zip2']}'
and ad_addr1 = '{$_POST['od_b_addr1']}'
and ad_addr2 = '{$_POST['od_b_addr2']}' ";
and ad_name = '$od_b_name'
and ad_tel = '$od_b_tel'
and ad_hp = '$od_b_hp'
and ad_zip1 = '$od_b_zip1'
and ad_zip2 = '$od_b_zip2'
and ad_addr1 = '$od_b_addr1'
and ad_addr2 = '$od_b_addr2' ";
$row = sql_fetch($sql);
// 기본배송지로 할시
// 기본배송지 체크
if($ad_default) {
$sql = " update {$g5['g5_shop_order_address_table']}
set ad_default = '0'
where mb_id = '{$member['mb_id']}' ";
sql_query($sql);
if($row['ad_id']){
$sql = " update {$g5['g5_shop_order_address_table']}
set ad_default = '1'
where mb_id = '{$member['mb_id']}'
and ad_id = '{$row['ad_id']}' ";
sql_query($sql);
}
}
// 카운트 된 값이 없으면 새로 배송지 추가 저장
if(!$row['ad_id']){
if($row['ad_id']){
$sql = " update {$g5['g5_shop_order_address_table']}
set ad_default = '1',
ad_subject = '$ad_subject'
where mb_id = '{$member['mb_id']}'
and ad_id = '{$row['ad_id']}' ";
} else {
$sql = " insert into {$g5['g5_shop_order_address_table']}
set mb_id = '{$member['mb_id']}',
ad_subject = '$ad_subject',
@ -618,8 +614,9 @@ if($is_member) {
ad_zip2 = '$od_b_zip2',
ad_addr1 = '$od_b_addr1',
ad_addr2 = '$od_b_addr2' ";
sql_query($sql);
}
sql_query($sql);
}
goto_url(G5_SHOP_URL.'/orderinquiryview.php?od_id='.$od_id.'&amp;uid='.$uid);