查看文件: index_shoppingcar.php
大小: 16.08 KB
类型: application/octet-stream
<?php require_once('./Connections/BE2.php'); ?> <?php if (!isset($_SESSION)){ session_start(); } if(! isset($_SESSION['login_memid']) || $_SESSION['login_memid']==""){ ?> <script>alert('請記的先登入');location.href = '/';</script> <? exit; } ?> <? if ( isset($_GET["delid"]) ) { $delSQL = sprintf("delete from order_tmp where ccid='%s' AND p_sess='1'",$_GET["delid"] ); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($delSQL, $BE2) or die(mysql_error()); } else if ( isset($_GET["addcount"]) ) { $upSQL = sprintf("update order_tmp Set p_count='%s' where ccid='%s' AND p_sess='1'",$_GET["addcount"]); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($upSQL, $BE2) or die(mysql_error()); } //$colname_Rt2 = session_id() ;// $_SESSION['login_memid']; $colname_Rt2 = $_SESSION['login_memid']; mysql_select_db($database_BE2, $BE2); //$row_Rt2 b.p_title //today $row_Rqr1['p_check_time2']; //商品已過期 AND b.p_check_time2>'%s' $dday=date('Y-m-d'); $query_Rt2 = sprintf("SELECT a.*,b.p_title,b.p_new,b.company_num,b.meta_img,b.p_tag,c.company_title,c.com_express,c.com_express_max FROM order_tmp as a,product_data as b,company as c WHERE a.mem_auto=b.mem_auto AND b.company_num=c.coid AND b.p_check_time2>'%s' AND a.p_sess= '1' AND a.member_id='%s' ORDER BY a.ccid DESC",$dday, $colname_Rt2); $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); // if($_SERVER["REMOTE_ADDR"]=="220.130.43.118"){ echo $query_Rt2."<br>";} ?> <style type="text/css"> #Ly { width:100%; width:screen.width; cursor:auto; left:0px; position: fixed; height:70px; bottom:0; z-index:3; color: #fff; background-color: #0033FF; font-size:25px; font-weight: bold; } </style> <? if($totalRows_Rt2>0){ ?> <div class="container g-pt-80 g-pb-70"> <div id="stepFormSteps"> <!-- Shopping Cart --> <div id="step1" class="active"> <div class="row"> <div class="col-md-12 g-mb-30"> <!-- Products Block --> <form name="form5" id="form5" method="post" action="/orderinfo.html" onsubmit="return checkForm5(this);" autocomplete='off' > <div class="g-overflow-x-scroll g-overflow-x-visible--lg"> <? /* /shopcart.html */ ?> <table class="text-center w-100"> <thead class="h6 g-brd-bottom g-brd-gray-light-v3 g-color-black text-uppercase"> <tr> <th width="60"></th> <th width="108" class="g-font-weight-400 text-left g-pb-20">商品</th> <th width="92" class="g-font-weight-400 g-width-130 g-pb-20">價格</th> <th width="38" class="g-font-weight-400 g-width-50 g-pb-20">數量</th> <th width="38" class="g-font-weight-400 g-width-130 g-pb-20">總計</th> <th width="1"></th> </tr> </thead> <tbody> <?php $p1=0; $p2=0; //sum $order_express=0; $coid=0; //tab $coid_count=0; $coid_total=$totalRows_Rt2; do { if($order_express==0){ $order_express= $row_Rt2['p_express']; } ?> <? if($row_Rt2['coid']<>$coid){ ?> <? if($coid>0){ ?> <tr class="g-brd-bottom g-brd-gray-light-v3"> <td colspan="6" class= "text-right" > <input name="cta_<?= $coid_count?>" id="cta_<?= $coid_count?>" type="hidden" value="0" /> <div id="ctol_<?= $coid_count?>"><?= '金額 : 0' ?></div></td> </tr> <? }?> <? $coid_count++; ?> <tr class="g-brd-bottom g-brd-gray-light-v3"> <td colspan="6" class="text-left" > <input name="ccidm_<?= $coid_count?>" id="ccidm_<?= $coid_count ?>" type="checkbox" value="<?= $row_Rt2['coid']?>" onclick="set_cart_msel(<?= $coid_count?>,this)" /> 店舖 <?= $row_Rt2['coid']?> : <?= $row_Rt2['company_title']?> /本店鋪基本運費 $<?= $row_Rt2['com_express'] ?> <input name="cexp_<?= $coid_count?>" id="cexp_<?= $coid_count ?>" type="hidden" value="<?= $row_Rt2['com_express']?>" /> <?= $row_Rt2['com_express_max']>0?"本店鋪免運金額 $".$row_Rt2['com_express_max']:'' ?> <input name="cexpmax_<?= $coid_count?>" id="cexpmax_<?= $coid_count ?>" type="hidden" value="<?= $row_Rt2['com_express_max']?>" /> <input name="cexpdiff_<?= $coid_count?>" id="cexpdiff_<?= $coid_count ?>" type="hidden" value="0" /> <input name="ctcount_<?= $coid_count ?>" id="ctcount_<?= $coid_count ?>" type="hidden" value="0" /> </td> </tr> <? $coid=$row_Rt2['coid']; } ?> <? $imagepath = "/admin/upload_image/".$row_Rt2['meta_img']; if($row_Rt2['p_new']==1){ $imagepath = "/admin/upload2_image/".sprintf("%07d",$row_Rt2['company_num']).'/'.$row_Rt2['meta_img'].'.'.$row_Rt2['p_tag']; } ?> <tr class="g-brd-bottom g-brd-gray-light-v3"> <td colspan="2" class="g-color-gray-dark-v2 g-font-size-14 text-left"> <input name="ccid<?= $coid_count?>[]" id="ccid<?= $coid_count?>[]" type="checkbox" value="<?= $row_Rt2['ccid']?>" onclick="set_cart_ssel(<?= $coid_count?>,<?= $row_Rt2['ccid']?>,this)" /> <img class="d-inline-block g-width-60 mr-4" src="<?= $imagepath ?>" alt=""> <?= $row_Rt2['p_title'];?> </td> <td class="g-color-gray-dark-v2 g-font-size-16"> <input name="cp_<?= $row_Rt2['ccid'] ?>" id="cp_<?= $row_Rt2['ccid'] ?>" type="hidden" value="<?= $row_Rt2['p_money']?>" /> <?= $row_Rt2['p_money']?> </td> <td> <select class="custom-select mr-sm-3 mb-3 mb-lg-0" name="p_count" id="p_count" onChange="MM_total2('<?= $row_Rt2['ccid'];?>',this,<?= $coid_count?>)"> <? for($i=1;$i<101;$i++){ ?> <option value="<?= $i ?>" <?= $row_Rt2['p_count']==$i?"selected":"" ;?> ><?= $i ?></option> <? }?> </select> </td> <td class="g-color-gray-dark-v2 g-font-size-14"><? $p1=$row_Rt2['p_count']*$row_Rt2['p_money']; $p2+=$p1; ?> <input name="ct_<?= $row_Rt2['ccid'] ?>" id="ct_<?= $row_Rt2['ccid'] ?>" type="hidden" value="<?= $p1?>" /> <div id="cth_<?= $row_Rt2['ccid'] ?>"><?= $p1;?></div></td> <td class="g-color-gray-dark-v2 g-font-size-16"> <i class="mt-auto fa fa-trash" onclick="if(window.confirm('確定刪除'))location.href='/shoppingcar.html?delid=<?= $row_Rt2['ccid']?>';"></i> <? /* <a href="/shoppingcar.html" onclick="if(window.confirm('確定刪除'))location.href='/shoppingcar.html?delid=<?= $row_Rt2['ccid']?>';"><i class="mt-auto fa fa-trash"></i></a> */ ?> </td> </tr> <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); ?> <tr class="g-brd-bottom g-brd-gray-light-v3"> <td colspan="6" class= "text-right" ><div id="ctol_<?= $coid_count?>"><?= '金額 :$ 0' ?></div> <input name="cta_<?= $coid_count?>" id="cta_<?= $coid_count?>" type="hidden" value="0" /> <input name="comcount" id="comcount" type="hidden" value="<?= $coid_count?>" /> </td> </tr> </tbody> </table> </div> <!-- End Products Block --> <table class="table table-bordered g-mt-20"> <tr> <td width="217"> <div class="row"> <div class="col-md-3"> <label>商品總金額:$</label><input name="order_moneyALL" id="order_moneyALL" type="text" value="0" readonly="readonly" size="5"> </div> <input name="order_express" id="order_express" type="hidden" size="5" value="0" > <div class="col-md-3"> <? $p2=$p2+$order_express; ?> <label>結帳總金額:$<font size="4" color="#0000FF"><input name="pay_money" id="pay_money" type="text" size="6" value="0" readonly="readonly"></font></label> </div> <div class="col-md-3 col-md-3 col-sm-3 "> <input id="submit" name="submit" type="submit" value="結算" /> <input id="company_count" name="company_count" type="hidden" value="0" /> </div> </div> </td> </tr> </table> </form> </div> </div> </div> <!-- End Shopping Cart --> </div> </div> <? // if($wine<>'Y'){ echo 'style="display:none"' ;}?> <div id="Ly" > <div class="col-md-3 col-md-3 col-sm-3 "><div id="buy_obj">已選商品 0件</div> </div> <div class="col-md-7 col-md-7 col-sm-7 "><div id="buy_exp"> 合計金額 : $0 </div> </div> </div> </div> <? } ?> <script language="JavaScript"> <!-- $('input[type=checkbox]').each(function() { this.checked = false; }); function checkForm5(my){ // var chk1 = document.getElementById("chkread").checked ; // alert($("#order_moneyALL").val()); var comcount=<?= $coid_count?>; var sscom=0; for(i=1;i<=comcount;i++){ if($("#cta_"+i).val()>0){ sscom= sscom*1+1;} } if ( sscom>1){ alert("多家店鋪,請勿同時結帳..\n "); return false; } if ( $("#order_moneyALL").val()==0){ alert("請選取購買商品..\n "); return false; } return true; } function set_cart_msel(sid,selObj){ var elem ="input[name='ccid"+sid+"[]']:checked"; var list = $(elem).map(function () { return this.value; }).get(); var checkBox = document.getElementById('ccidm_'+sid); if($("#ccidm_"+sid).is(":checked")) { if (list == ''){ var elem2 ="input[name='ccid"+sid+"[]']"; $(elem2).map(function () { return $(this).prop("checked","checked"); }) } } else{ $(elem).map(function () { return $(this).prop("checked",false); }) } set_sum(sid ); } function MM_total2(targ,selObj,sid){ //v3.0 var url="ajax_update_order.php"; var cp= $('#cp_'+targ).val()* selObj.options[selObj.selectedIndex].value; $.post(url,{"ccid":targ,"pcount":selObj.options[selObj.selectedIndex].value}, function(data){ if (data) { // location.reload(); $("#ct_"+targ).val( cp); $("#cth_"+targ).html( cp); set_sum(sid ); } }); } function set_sum(sid){ var comcount=<?= $coid_count?>; var elem ="input[name='ccid"+sid+"[]']:checked"; var list = []; var cexp=0; $(elem).map(function () { list.push($(this).val()); }); if(list.length==0){ $("#ctol_"+sid).html('金額 :$ 0'); $("#cta_"+sid).val(0); $("#ctcount_"+sid).val(0); }else{ var c=0; for(i=0;i<list.length;i++){ //alert(i+" >> ct_"+list[i]) ; c = $("#ct_"+list[i]).val()*1 +c; } $("#ctcount_"+sid).val(list.length); $("#ctol_"+sid).html('金額 :$ '+c); $("#cta_"+sid).val(c); } c=0; cexp=0; var ckexp=0; var ctcount=0; var company_count=0; for(i=1;i<=comcount;i++){ //alert(i+" >> ct_"+list[i]) ; ctcount= $("#ctcount_"+i).val()*1+ctcount; if($("#cta_"+i).val()>0){ ckexp=0; company_count=company_count*1+1 if( $("#cta_"+i).val()>$("#cexpmax_"+i).val()){ ckexp=1;} if( $("#cexpmax_"+i).val()==0){ ckexp=0;} // cexpdiff_ if(ckexp==0){ $("#cexpdiff_"+i).val( $("#cexp_"+i).val() ); cexp=$("#cexp_"+i).val()*1+cexp; }else{ $("#cexpdiff_"+i).val(0); } } c = $("#cta_"+i).val()*1 +c; } $("#buy_obj").html("已選商品 "+ctcount+ " 件"); $("#buy_exp").html("合計金額: $"+c ); //基本運費: $0 / 合計: $0 / 總金額 $0 //$("#buy_total").html("合計: $"+c+" 總金額 $"+(c*1+cexp)); //合計: $0.00 總金額 $0 $("#company_count").val(company_count); $("#order_moneyALL").val(c); // $("#order_express").val(cexp); // $("#pay_money").val(c ); //alert(list.length); //if(list==''){ //$("#ctol_"+sid).html('0'); //} } function set_cart_ssel(sid,ccid,selObj){ if($(selObj).is(":checked")) { $('#ccidm_'+sid).prop("checked","checked"); } else{ var elem ="input[name='ccid"+sid+"[]']:checked"; var list = $(elem).map(function () { return this.value; }).get(); if (list == ''){ $('#ccidm_'+sid).prop("checked",false); } } set_sum(sid ); } function checkall() { document.getElementById("mem_name2").value = document.getElementById("mem_name").value; document.getElementById("mem_mobile2").value = document.getElementById("mem_mobile").value; document.getElementById("mem_address2").value = document.getElementById("mem_address").value; document.getElementById("mem_mail2").value = document.getElementById("mem_mail").value; } function showfp() { fp2.style.display = ''; } function showfp2() { fp2.style.display = 'none'; } function showfp3() { fp3.style.display = ''; } function showfp31() { fp3.style.display = 'none'; } function form1check(){ var ck=true; ck= check_tax_number(); return ck; } function check_tax_number() { const gui_number = document.querySelector('.gui_number').value; // 取欄位內容 const cx = [1, 2, 1, 2, 1, 2, 4, 1]; const cnum = gui_number.split(''); let sum = 0; function cc(num) { let total = num; if (total > 9) { let s = total.toString(); const n1 = s.substring(0, 1) * 1; const n2 = s.substring(1, 2) * 1; total = n1 + n2; } return total; } if (gui_number.length !== 8) { alert('統編錯誤,要有 8 個數字'); return false; } cnum.forEach((item, index) => { if (gui_number.charCodeAt() < 48 || gui_number.charCodeAt() > 57) { // alert('統編錯誤,要有 8 個 0-9 數字組合'); return false; } sum += cc(item * cx[index]); }); if (sum % 10 === 0) { //alert('統編正確'); return true; } else if (cnum[6] === '7' && (sum + 1) % 10 === 0) { //alert('統編正確2'); return true; } else { alert('統編錯誤'); return false; } } //--> </script> <?php mysql_free_result($Rt2); ?>
保存
取消
返回文件列表