Merge branch 'master' of github.com:gnuboard/yc4s

This commit is contained in:
whitedot
2013-05-27 13:53:59 +09:00
4 changed files with 80 additions and 116 deletions

View File

@ -676,47 +676,24 @@ function get_item_supply($it_id, $subject)
return $str;
}
// 인수는 $it_id, $it_opt1, ..., $it_opt6 까지 넘어옴
function print_item_options()
function print_item_options($it_id, $uq_id)
{
global $g4;
$it_id = func_get_arg(0);
$sql = " select it_opt1_subject,
it_opt2_subject,
it_opt3_subject,
it_opt4_subject,
it_opt5_subject,
it_opt6_subject
from {$g4['shop_item_table']}
where it_id = '$it_id' ";
$it = sql_fetch($sql);
$sql = " select ct_option from {$g4['shop_cart_table']} where it_id = '$it_id' and uq_id = '$uq_id' order by ct_num asc ";
$result = sql_query($sql);
$it_name = $str_split = '';
for ($i=1; $i<=6; $i++)
{
if ($i == 1) $str_split .= '<span class="sound_only">상품옵션 </span>';
$it_opt = trim(func_get_arg($i));
// 상품옵션에서 0은 제외되는 현상을 수정
if ($it_opt==null) continue;
$it_name .= $str_split;
$it_opt_subject = $it['it_opt'.$i.'_subject'];
$opt = explode( ';', $it_opt );
$it_name .= $it_opt_subject.' = '.$opt[0];
if ($opt[1] != 0)
{
$it_name .= ' (';
//if (ereg("[+]", $opt[1]) == true)
if (preg_match("/[+]/", $opt[1]) == true)
$it_name .= '+';
$it_name .= display_price($opt[1]).')';
}
$str_split = '<br>';
$str = '';
for($i=0; $row=sql_fetch_array($result); $i++) {
if($i == 0)
$str .= '<ul>'.PHP_EOL;
$str .= '<li>'.$row['ct_option'].'</li>'.PHP_EOL;
}
return $it_name;
if($i > 0)
$str .= '</ul>';
return $str;
}
function it_name_icon($it, $it_name="", $url=1)

View File

@ -20,13 +20,13 @@ else
<tr>
<th scope="col">상품이미지</th>
<th scope="col">상품명</th>
<th scope="col">수량</th>
<th scope="col">수량</th>
<th scope="col">판매가</th>
<th scope="col">소계</th>
<th scope="col">포인트</th>
<?php
if ($s_page == 'cart.php')
echo '<th scope="col">삭제</th>';
echo '<th scope="col"><input type="checkbox" name="ct_all" value="1"></th>';
else if ($s_page == 'orderinquiryview.php')
echo '<th scope="col">상태</th>';
?>
@ -43,23 +43,16 @@ $goods_count = -1;
// $s_uq_id 로 현재 장바구니 자료 쿼리
$sql = " select a.ct_id,
a.it_id,
a.it_name,
a.it_opt1,
a.it_opt2,
a.it_opt3,
a.it_opt4,
a.it_opt5,
a.it_opt6,
a.ct_price,
a.ct_point,
a.ct_qty,
a.ct_status,
b.it_id,
b.ca_id
from {$g4['shop_cart_table']} a,
{$g4['shop_item_table']} b
from {$g4['shop_cart_table']} a left join {$g4['shop_item_table']} b on ( a.it_id = b.it_id )
where a.uq_id = '$s_uq_id'
and a.it_id = b.it_id
and a.ct_num = '0'
order by a.ct_id ";
$result = sql_query($sql);
@ -67,6 +60,14 @@ $good_info = '';
for ($i=0; $row=mysql_fetch_array($result); $i++)
{
// 합계금액 계산
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
SUM(ct_point * ct_qty) as point,
SUM(ct_qty) as qty
from {$g4['shop_cart_table']}
where it_id = '{$row['it_id']}' ";
$sum = sql_fetch($sql);
if (!$goods)
{
//$goods = addslashes($row[it_name]);
@ -102,38 +103,33 @@ for ($i=0; $row=mysql_fetch_array($result); $i++)
}
$it_name = $a1 . stripslashes($row['it_name']) . $a2;
if ($row['it_opt1'] || $row['it_opt2'] || $row['it_opt3'] || $row['it_opt4'] || $row['it_opt5'] || $row['it_opt6']) { // 상품에 옵션이 있다면
$it_name .= '<div class="sod_bsk_itopt">'.print_item_options($row['it_id'], $row['it_opt1'], $row['it_opt2'], $row['it_opt3'], $row['it_opt4'], $row['it_opt5'], $row['it_opt6']).'</div>';
$it_options = print_item_options($row['it_id'], $s_uq_id);
if($it_options) {
$mod_options = '';
if($s_page == 'cart.php')
$mod_options = '<button type="button" class="mod_options">선택사항수정</button>';
$it_name .= '<div class="sod_bsk_itopt">'.$it_options.$mod_options.'</div>';
}
$point = $row['ct_point'] * $row['ct_qty'];
$sell_amount = $row['ct_price'] * $row['ct_qty'];
$point = $sum['point'];
$sell_amount = $sum['price'];
?>
<tr>
<td class="sod_bsk_img"><?php echo $image; ?></td>
<td>
<input type="hidden" name="ct_id[<?php echo $i; ?>]" value="<?php echo $row['ct_id']; ?>">
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
<input type="hidden" name="it_name[<?php echo $i; ?>]" value="<?php echo get_text($row['it_name']); ?>">
<?php echo $it_name; ?>
</td>
<?php
// 수량, 입력(수량)
if ($s_page == "cart.php")
echo '<td class="td_num"><input type="text" name="ct_qty['.$i.']" value="'.$row['ct_qty'].'" id="ct_qty_'.$i.'" class="frm_input" size="4" maxlength="6" autocomplete="off"></td>';
else
echo '<td class="td_num">'.$row['ct_qty'].'</td>';
?>
<td class="td_num"><?php echo number_format($sum['qty']); ?></td>
<td class="td_bignum"><?php echo number_format($row['ct_price']); ?></td>
<td class="td_bignum"><?php echo number_format($sell_amount); ?></td>
<td class="td_bignum"><?php echo number_format($point); ?></td>
<?php
if ($s_page == 'cart.php')
echo '<td class="td_smallmng"><a href="./cartupdate.php?act=d&amp;ct_id='.$row['ct_id'].'">삭제</a></td>';
echo '<td class="td_smallmng"><input type="checkbox" name="ct_chk['.$i.']" value="1"></td>';
else if ($s_page == 'orderinquiryview.php')
echo '<td class="td_smallmng">'.$row['ct_status'].'</td>';
?>
@ -224,7 +220,7 @@ if ($tot_amount > 0) {
<p>장바구니의 상품을 주문하시려면 <strong>주문하기</strong>를 클릭하세요. <strong>비우기</strong>는 장바구니의 상품을 모두 비웁니다.</p>
<a href="<?php echo G4_SHOP_URL; ?>/list.php?ca_id=<?php echo $continue_ca_id; ?>" class="btn01">쇼핑 계속하기</a>
<a href="javascript:form_check('buy');" class="btn02">주문하기</a>
<a href="javascript:form_check('allupdate');" class="btn01">수량변경</a>
<a href="javascript:form_check('seldelete');" class="btn01">선택삭제</a>
<a href="javascript:form_check('alldelete');" class="btn01">비우기</a>
<?php } ?>
</div>
@ -237,6 +233,20 @@ if ($s_page == 'cart.php') {
if ($i != 0) {
?>
<script>
$(function() {
// 선택사항수정
$(".mod_options").click(function() {
});
// 모두선택
$("input[name=ct_all]").click(function() {
if($(this).is(":checked"))
$("input[name='ct_chk[]']").attr("checked", true);
else
$("input[name='ct_chk[]']").attr("checked", false);
});
});
function form_check(act) {
var f = document.frmcartlist;
var cnt = f.records.value;
@ -261,35 +271,13 @@ function form_check(act) {
f.action = "./cartupdate.php";
f.submit();
}
else if (act == "allupdate")
else if (act == "seldelete")
{
for (i=0; i<cnt; i++)
{
//if (f.elements("ct_qty[" + i + "]").value == "")
if (document.getElementById('ct_qty_'+i).value == '')
{
alert("수량을 입력해 주십시오.");
//f.elements("ct_qty[" + i + "]").focus();
document.getElementById('ct_qty_'+i).focus();
return;
}
//else if (isNaN(f.elements("ct_qty[" + i + "]").value))
else if (isNaN(document.getElementById('ct_qty_'+i).value))
{
alert("수량을 숫자로 입력해 주십시오.");
//f.elements("ct_qty[" + i + "]").focus();
document.getElementById('ct_qty_'+i).focus();
return;
}
//else if (f.elements("ct_qty[" + i + "]").value < 1)
else if (document.getElementById('ct_qty_'+i).value < 1)
{
alert("수량은 1 이상 입력해 주십시오.");
//f.elements("ct_qty[" + i + "]").focus();
document.getElementById('ct_qty_'+i).focus();
return;
}
if($("input[name^=ct_chk]:checked").size() < 1) {
alert("삭제하실 상품을 하나이상 선택해 주십시오.");
return false;
}
f.act.value = act;
f.action = "./cartupdate.php";
f.submit();

View File

@ -43,32 +43,19 @@ else if ($act == "alldelete") // 모두 삭제이면
where uq_id = '$tmp_uq_id' ";
sql_query($sql);
}
else if ($act == "allupdate") // 수량 변경이면 : 모두 수정이면
else if ($act == "seldelete") // 선택삭제
{
$fldcnt = count($_POST['ct_id']);
$fldcnt = count($_POST['it_id']);
if(!$fldcnt)
alert("삭제하실 상품을 하나이상 선택해 주십시오.");
// 수량 변경, 재고등을 검사
$error = "";
for ($i=0; $i<$fldcnt; $i++)
{
// 재고 구함
$stock_qty = get_it_stock_qty($_POST['it_id'][$i]);
// 변경된 수량이 재고수량보다 크면 오류
if ($_POST['ct_qty'][$i] > $stock_qty)
$error .= "{$_POST['it_name'][$i]} 의 재고수량이 부족합니다. 현재 재고수량 : $stock_qty\\n\\n";
}
// 오류가 있다면 오류메세지 출력
if ($error != "") { alert($error); }
for ($i=0; $i<$fldcnt; $i++)
{
$sql = " update {$g4['shop_cart_table']}
set ct_qty = '{$_POST['ct_qty'][$i]}'
where ct_id = '{$_POST['ct_id'][$i]}'
and uq_id = '$tmp_uq_id' ";
sql_query($sql);
for($i=0; $i<$fldcnt; $i++) {
$ct_chk = $_POST['ct_chk'][$i];
if($ct_chk) {
$it_id = $_POST['it_id'][$i];
$sql = " delete from {$g4['shop_cart_table']} where it_id = '$it_id' and uq_id = '$tmp_uq_id' ";
sql_query($sql);
}
}
}
else if ($act == "multi") // 온라인견적(등)에서 여러개의 상품이 한꺼번에 들어옴.
@ -142,6 +129,9 @@ else // 장바구니에 담기
if (!$_POST['it_id'])
alert('장바구니에 담을 상품을 선택하여 주십시오.');
if($_POST['io_type'][0] != 0)
alert('상품의 선택옵션을 선택해 주십시오.');
for($i=0; $i<count($_POST['ct_qty']); $i++) {
if ($_POST['ct_qty'][$i] < 1)
alert('수량은 1 이상 입력해 주십시오.');

View File

@ -244,7 +244,16 @@ else
<!-- ########## 상품 선택옵션/추가옵션에 따른 출력 - 지운아빠 2013-05-24 -->
<!-- 스크린리더에서만 출력할 예정 -->
<p id="sit_opt_info">
상품 선택옵션 n 개, 추가옵션 n 개
<?php
$sql = " select count(*) as cnt from {$g4['shop_item_option_table']} where it_id = '{$it['it_id']}' and io_type = '0' and io_use = '1' ";
$row = sql_fetch($sql);
$opt_count = $row['cnt'];
$sql = " select count(*) as cnt from {$g4['shop_item_option_table']} where it_id = '{$it['it_id']}' and io_type = '1' and io_use = '1' ";
$row = sql_fetch($sql);
$spl_count = $row['cnt'];
?>
상품 선택옵션 <?php echo $opt_count; ?> 개, 추가옵션 <?php echo $spl_count; ?> 개
</p>
<!-- ########## 상품 선택옵션/추가옵션에 따른 출력 끝 -->
<?php if ($score = get_star_image($it['it_id'])) { ?>
@ -958,7 +967,7 @@ else
return;
}
if($("input[name='io_id[]']").size() < 1)
if($(".sit_opt_list").size() < 1)
{
alert("상품의 선택옵션을 선택해 주십시오.");
return false;