<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title><?php echo lang('onlinepayment');?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">

    <meta name="author" content="CmsEasy Team" />
    <link rel="icon" href="<?php echo get('site_ico');?>" type="image/x-icon" />
    <link rel="shortcut icon" href="<?php echo get('site_ico');?>" type="image/x-icon" />
    <link href="<?php echo $base_url;?>/common/css/bootstrap/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="data:text/css;charset=utf-8," data-href="<?php echo $skin_user_path;?>/css/bootstrap-theme.min.css" rel="stylesheet" id="bs-theme-stylesheet">
    <link rel="stylesheet" href="<?php echo $skin_user_path;?>/css/orders.css" />
    <script src="<?php echo $base_url;?>/common/js/jquery/jquery.min.js"></script>
</head>
<body>

<div class="container">





    <?php
      $isint =usergroup::getisint(user::getuserid());
    if(config::get('user_orders')=='1' && !$user['userid']) {
    ?>
    <div class='tip_box' style='width:150px;margin:0px auto;margin-top:50px;padding:20px;border:5px solid #ccc;border-radius: 5px 5px 5px 5px;text-align:center;'>
        <?php echo lang('not_logged');?>，<a href="<?php echo url('user/register');?>" style=" text-decoration: underline; color: blue;"><?php echo lang('please');?><?php echo lang('register');?>！</a>
    </div>
    <?php } else { ?>

    <div class="blank30"></div>
    <a href="{url('user/index')}" class="btn btn-default btn-lg pull-right"><?php echo lang('backhome');?></a>



    <!-- 中部开始 -->

    <script type="text/javascript">
        //使用的优惠劵   格式 ‘key’-》‘卷ID：金额：是否叠加’
        var yhjsy=new Array();


        function check(submit){

            if($("#pname").val()==""){
                alert("<?php echo lang('enter');?><?php echo lang('ordercontactname');?>!");
                $("#pname").focus();
                return false;
            }

            var myreg=/^1\d{10}$/;
            if (!myreg.test($("#telphone").val())) {
                alert("<?php echo lang('enter');?><?php echo lang('ordertel');?>!");
                $("#telphone").focus();
                return false;
            }

        <?php if(config::get('mobilechk_enable') && config::get('mobilechk_buy')) { ?>
                if($('#mobilenum').val() == ''){
                    alert('<?php echo lang('please_enter_the_phone_verification_code');?>');
                    $('#mobilenum').focus();
                    return false;
                }
            <?php } ?>


            if($('#address').val()==""){
                alert("<?php echo lang('enter');?><?php echo lang('orderaddress');?>!");
                $('#address').focus();
                return false;
            }
            {if session::get('username')==''}
            if($('#postcode').val()==""){
                alert("<?php echo lang('enter');?><?php echo lang('email');?>!");
                $('#postcode').focus();
                return false;
            }
            {/if}
            //总价 $("#total").html()
            var total=$("#total").html();
            var yuer=<?php echo user::getmenoy();?>;
            if(parseFloat(total)>parseFloat(yuer)){
                $('#user_menoy').attr("disabled","disabled");
            }else{
                $('#user_menoy').removeAttr("disabled");
            }
            $('#step2').hide();$('#step3').show();
            return true;
        }


        //计算总价
        function setTotal(){
            var s=0;

            $(".orders-list").each(function(){
                s+=parseInt($(this).find('input[class*=thisnum]').val())*parseFloat($(this).find('span[class*=price]').text());
            });

            $("#tab").each(function(){
                s+=parseInt($(this).find('input[class*=thisnum]').val())*parseFloat($(this).find('span[class*=price]').text());
            });
            var isuseyhj=false;
            for(var key in yhjsy){
                var arr = yhjsy[key].split(":");
                if(key != 'coupon' && arr[2]=='0'){
                    isuseyhj=true;
                }
                s=s-parseFloat(arr[1]);
            }
            if(isuseyhj){
                $("[name='couponyhj']").val('{lang('not_available')}');
                $("[name='couponyhj']").attr("disabled","disabled");
                if(yhjsy['coupon'] != '' && yhjsy['coupon'] != undefined) {
                    var arrs = yhjsy['coupon'].split(":");
                    s=s+parseFloat(arr[1]);   //还原原来的价格  去掉通用优惠劵
                    yhjsy['coupon'] = ''+ ':0:0';
                    $("#coupon" + arrs[0]).attr("onclick", "setcoupon(this,'" + arrs[0] + "',1)");
                }
            }else{
                $("[name='couponyhj']").val('{lang('immediate_use')}');
                $("[name='couponyhj']").removeAttr("disabled");
                if(yhjsy['coupon'] != '' && yhjsy['coupon'] != undefined) {
                    var arrs = yhjsy['coupon'].split(":");
                    if (arrs[0] != '' && arrs[0] != undefined ) {
                        $("#coupon" + arrs[0]).val('{lang('cancel_use')}');
                    }
                }
            }
            $("#total").html(s.toFixed(2));
        }
        //加载计算总价
        $(function(){
            setTotal();
        });
        //计算当前商品的总购买数量
        function getoldinventorynum(aid){
            var inventoryname='inventory'+aid;
            var oldinventorynum=$("input[name="+inventoryname+"]");
            var newinventorynum=0;
            for(var i=0;i<oldinventorynum.length;i++){
                newinventorynum =newinventorynum+ parseInt($(oldinventorynum[i]).val());
            }
            return newinventorynum;
        }
        //数量加1
        function addnum(obj,changenum,totalname,pricenum,aid,inventory){
            if(getoldinventorynum(aid)>=inventory){
                alert('{lang('quantity_should_not_be_greater_than_inventory')}');
                return false;
            }
            var t=$(obj).parent().find('input[class*=thisnum]');
            var hiddendata=$(obj).parent().parent().parent().parent().prev().val();
            var savenameArry= new Array(); //定义一数组
            savenameArry=hiddendata.split("#"); //字符分割
            var savenameArry2= new Array(); //定义一数组
            savenameArry2=savenameArry[0].split(","); //字符分割
            hiddendata=savenameArry2[0]+','+(parseFloat(savenameArry2[1])+parseFloat(1))+'#'+savenameArry[1];
            $(obj).parent().parent().parent().parent().prev().val(hiddendata);
            t.val(parseInt(t.val())+1);
            //小计
            setxiaoji(changenum,totalname,pricenum,'add');
            //计算总价
            setTotal();
        }
        //数量减1
        function minnum(obj,changenum,totalname,pricenum){
            var hiddendata=$(obj).parent().parent().parent().parent().prev().val();
            var savenameArry= new Array(); //定义一数组
            savenameArry=hiddendata.split("#"); //字符分割
            var savenameArry2= new Array(); //定义一数组
            savenameArry2=savenameArry[0].split(","); //字符分割
            if(parseFloat(savenameArry2[1])==0){
                hiddendata=savenameArry2[0]+','+'0'+'#'+savenameArry[1];
            }else {
                hiddendata = savenameArry2[0] + ',' + (parseFloat(savenameArry2[1]) - parseFloat(1)) + '#' + savenameArry[1];
            }
            $(obj).parent().parent().parent().parent().prev().val(hiddendata);
            var t=$(obj).parent().find('input[class*=thisnum]');
            t.val(parseInt(t.val())-1)
            if(parseInt(t.val())<0){
                t.val(0);
            }else{
                //小计
                setxiaoji(changenum,totalname,pricenum,'min');
            }
            //计算总价
            setTotal();
        }
        //获得数量修改前
        var oldnum=0;
        function getnum(obj){
            oldnum=$(obj).val();
        }
        //修改数量
        function setnum(obj,hiddname,totalname,pricenum,aid,inventory) {
            if(getoldinventorynum(aid)>inventory){
                alert('{lang('quantity_should_not_be_greater_than_inventory')}');
                $(obj).val(oldnum);
                return false;
            }
            var hiddendata=$("#hidden"+hiddname+"").val();
            var savenameArry= new Array(); //定义一数组
            savenameArry=hiddendata.split("#"); //字符分割
            var savenameArry2= new Array(); //定义一数组
            savenameArry2=savenameArry[0].split(","); //字符分割
            hiddendata = savenameArry2[0] + ',' + $(obj).val() + '#' + savenameArry[1];
            $("#hidden"+hiddname+"").val(hiddendata);

            //小计
            var changenum=0;
            if(parseFloat($(obj).val())>parseFloat(oldnum)){
                changenum=parseFloat($(obj).val())-parseFloat(oldnum);
                setxiaoji(changenum,totalname,pricenum,'add');
            }else{
                changenum=parseFloat(oldnum)-parseFloat($(obj).val());
                setxiaoji(changenum,totalname,pricenum,'min');
            }

        };
        //小计
        function setxiaoji(changenum,totalname,pricenum,minadd){
            var newtotalname=totalname+"total";
            var xiaoji=parseFloat($("#"+newtotalname).html());
            if(minadd=='min'){
                xiaoji=xiaoji-(parseFloat(changenum)*parseFloat(pricenum));
            }else{
                xiaoji=xiaoji+(parseFloat(changenum)*parseFloat(pricenum));
            }
            if(xiaoji==0){
                $("#listdivparent"+totalname).remove();
            }else{
                $("#"+newtotalname).html(xiaoji.toFixed(2));
            }
        }
        //删除
        function reomeclick(valname,totalname,price){
            var oldnum=$("#thisnum"+valname).val();
            if (oldnum!=0){
                setxiaoji(oldnum,totalname,price,'min');
            }
            //删除节点
            $("#list"+valname).remove();
            $("#hidden"+valname).remove();
            $("#proxyhidden"+valname).remove();
            //重算总价
            setTotal();
        }
        //删除cookie
        function dropclick(aid,key){
            var url="{url('archive/emptyorders/delete/1')}"+'&key='+key+'&aid='+aid;
            $.get(url, function(data){
                var returndata=data;
            });
        }
        //保存下拉的优惠劵和数量
        var usableusernum ={};
        //优惠劵选择
        function setselect(obj,totalname){
            //获取选择的优惠劵
            var couponid=$(obj).val();
            //获取 优惠劵当前使用的数量
            var couponidnum=0;
            for(var key in yhjsy){
                var arr = yhjsy[key].split(":");
                if (arr[0] == couponid && arr[0] != undefined ) {
                    couponidnum=couponidnum+1;  //已经使用数量+当前数量+1
                 /*   if (!parseFloat(arr[2])){   //不可叠加
                        alert('{lang('non_superposition')}');
                        $(obj).val('');
                        return;
                    }*/
                }
            }
            //获取下拉全部优惠劵和数量   不足则清空
            if( couponidnum >= parseFloat(usableusernum[couponid]) ){
                alert('{lang('the_number_of_discounts_currently_selected_is_insufficient')}');
                $(obj).val('');
                return;
            }
            //获取小计
            var xiaoji=parseFloat($("#"+totalname+"total").html());
            if(yhjsy[totalname] != '' && yhjsy[totalname] != undefined){
                var arr = yhjsy[totalname].split(":");
                if(arr[1] > 0){
                    xiaoji=xiaoji+parseFloat(arr[1]);
                }
            }
            $("#"+totalname+"total").html(xiaoji.toFixed(2));   //使用之前先还原小计
            //未选择优惠劵则清空   还原总价
            if(couponid==''){
                yhjsy[totalname]=''+':0:1';
                setTotal();
            }
            //开始获取优惠劵信息  进行计算
            var hrefname="<?php echo modify("/act/getcouponid"); ?>";
            $.get(hrefname,{'couponid':couponid},function(data,status){
                if(data != ''){
                    data=JSON.parse(data);
                    if(parseFloat(xiaoji)<parseFloat(data['satisfy'])){
                        alert('{lang('not_satisfied_with_the_use_conditions')}');
                        $(obj).val('');
                    }else{
                        if($.inArray(totalname, yhjsy))
                        yhjsy[totalname]=couponid+':'+data['moeny']+':'+data['overlay'];
                        xiaoji=xiaoji-parseFloat(data['moeny']);
                        $("#"+totalname+"total").html(xiaoji.toFixed(2));
                        setTotal();
                    }
                }
            });
        }

        //通用优惠劵选择
        function setcoupon(obj,couponid,isuse){
            if(isuse=='0'){
                yhjsy['coupon']=''+':0:0';
                $(obj).val('{lang('immediate_use')}');
                $(obj).attr("onclick","setcoupon(this,'"+couponid+"',1)");
                setTotal();
            }else{
                //存在已选通卷 则替换掉

                if(yhjsy['coupon']!='' && yhjsy['coupon']!=undefined ){
                    var arr = yhjsy['coupon'].split(":");
                    if( arr[0] != couponid){
                        $("#coupon"+arr[0]).val('{lang('immediate_use')}');
                        $("#coupon"+arr[0]).attr("onclick","setcoupon(this,'"+arr[0]+"',1)");
                    }
                }
                //获取总价
                var allprice=$("#total").html();
                //开始获取优惠劵信息  进行计算
                var hrefname="<?php echo modify("/act/getcouponid"); ?>";
                $.get(hrefname,{'couponid':couponid},function(data,status){
                    if(data != ''){
                        data=JSON.parse(data);
                        if(parseFloat(allprice)<parseFloat(data['satisfy'])){
                            alert('{lang('not_satisfied_with_the_use_conditions')}');
                        }else{
                            yhjsy['coupon']=couponid+':'+data['moeny']+':0';
                            $(obj).attr("onclick","setcoupon(this,'"+couponid+"',0)");
                            setTotal();
                        }
                    }
                });
            }
        }

        //保存使用的优惠劵到数据库
        function setsomecoupon() {
            var somecoupon='';
            for(var key in yhjsy){
                var arr = yhjsy[key].split(":");
                if (arr[0] != '' && arr[0] != undefined ) {
                    somecoupon+=arr[0]+',';
                }
            }
            if(somecoupon !=''){
                somecoupon = (somecoupon .substring(somecoupon .length - 1) == ',') ? somecoupon .substring(0, somecoupon .length - 1) : somecoupon ;
                $("#somecoupon").val(somecoupon);
            }
        }
    </script>

    <form action="<?php echo uri();?>" id="orders" name="orders" method="post" onsubmit="return check(true)">
        <input type="hidden" name="isproxy" value="{$isproxy}">
        {if (isset($settlement) && $settlement=='1')}
            <div id="step1" style="display:none;">
        {else}
            <div id="step1" style="">
        {/if}

            <div class="t_1">
                <div>
                    <h3><a href="<?php echo $cat['url'];?>" title="<?php echo $cat['catname'];?>"><?php echo lang('onlinepayment');?></a></h3>
                    <p>Online Payment</p>
                </div>
            </div>
            <?php
              //获取用户优惠劵
              $couponidnum=getcouponidnum() ;
              $data=array();
              $coupon = new coupon();
               if($couponidnum != ''){
                    $source = explode(",",trim($couponidnum));
                        for($index=0;$index<count($source);$index++){
                            $sourcearry=explode(":",trim($source[$index]));
                            $where = " couponid=".$sourcearry['0']." and langid='".lang::getlangid(lang::getistemplate())."'";
                            $cols = '*,'.$sourcearry['1'].' as usableusernum';
                            $usercoupondata =$coupon->getrows($where, 1, 'adddatatime desc',$cols);
                            if(isset($usercoupondata['0']) && $usercoupondata['0']['statu']=='1' && strtotime($usercoupondata['0']['overduedate']) > strtotime(date("y-m-d")) &&
                             $usercoupondata[0]['usableusernum'] > 0) {
                                        $data[count($data)] = $usercoupondata['0'];
                           }
                    }
               }

            ?>

            <?php if($orderaidlist) { ?>
            <?php  asort($orderaidlist);$titlename='';$divname=''?>
            <?php if(is_array($orderaidlist))
            foreach($orderaidlist as $val) { ?>
            <?php
              $setdatatype="";
                 $fh="";
                 if( $val['datatype'] !=''){
                 $source = explode(";",trim($val['datatype']));
                    for($index=0;$index<count($source);$index++){
                          $source2 = explode(":",trim($source[$index]));
                          $sourcevalkey=explode(",",trim($source2['0']));
                          $newcname='cname_'.lang::getistemplate();
                          if(front::get('isproxy')){
                            $setdatatype=$setdatatype.setting::$service_var[$sourcevalkey['0']][$newcname]."：";
                          }else{
                            $setdatatype=$setdatatype.setting::$var['archive'][$sourcevalkey['0']][$newcname]."：";
                          }
                          $source2 = explode(",",trim($source2['1']));
                          $setdatatype=$setdatatype.$source2['0']."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                          if($index==""){
                             $fh=$fh.$source2['1'].','.$source2['2'];
                          }else{
                             $fh=$fh.':'.$source2['1'].','.$source2['2'];
                          }
                    }
                 }

                  if($isproxy){
                        $val['customize_attr2']=$val['customize_attr2']==""?0:$val['customize_attr2'];
                        $newcname='attr2_'.lang::getistemplate();
                        $attr2=json_decode($val['customize_attr2'],true);
                        $attr2=is_array($attr2)?$attr2:array();
                        //取出中文价格
                        $attr2_cn_price=(is_array($attr2) && isset($attr2['attr2_cn']))?$attr2['attr2_cn']:0;
                        //当前价格不存在则使用中文价格
                        $attr2[$newcname]=(is_array($attr2) && isset($attr2[$newcname]))?$attr2[$newcname]:$attr2_cn_price;
                        //若是没有设置多语言 默认使用原来价格  否则使用多语言价格
                        $val['customize_attr2']=is_numeric($val['customize_attr2'])?$val['customize_attr2']:$attr2[$newcname];
                        $val['attr2']=$val['customize_attr2'];
                  }else{
                        $newcname='attr2_'.lang::getistemplate();
                        $attr2=json_decode($articles[$val['attr2']],true);
                        $val['attr2']=is_array($attr2)?$attr2[$newcname]:$val['attr2'];
                  }
                  $price=0;
                  if($fh!=""){
                        $source = explode(":",trim($fh));
                        $price=floatval($val['attr2']);
                        for($index=0;$index<count($source);$index++){
                           $source2= explode(",",trim($source[$index]));
                           if($source2['0']=="jia"){
                              $price=$price+floatval($source2['1']);
                           }else if($source2['0']=="jian"){
                              $price=$price-floatval($source2['1']);
                           }else if($source2['0']=="chen"){
                              $price=$price*floatval($source2['1']);
                           }else if($source2['0']=="chu"){
                              $price=$price/floatval($source2['1']);
                           }
                        }
                  }else{
                    $price=$val['attr2'];
                  }
                  if($isint){
                     $price=round($price);
                  }
             ?>
            <?php if($titlename==$val['title']){ ?>
            <script>
                var htmljd="<hr class='featurette-divider'>";
                htmljd+="<input type=\"hidden\" id=\"hidden<?php echo $val['name'];?>\" name=\"aid[]\" value=\"<?php echo $val['name'];?>,<?php echo $val['amount'];?>#<?php echo $val['datatype'];?>\" />";
                <?php if(front::get('isproxy')){ ?>
                    htmljd+="<input type=\"hidden\" id=\"proxyhidden<?php echo $val['name'];?>\" name=\"service_aid[]\" value=\"<?php echo $val['service_aid'];?>,<?php echo $val['amount'];?>#<?php echo $val['datatype'];?>\" />";
                <?php } ?>
                htmljd+="<div id=\"list<?php echo $val['name'];?>\"  class=\"row orders-list\">";
                htmljd+="<div class=\"col-xs-4 col-sm-3 col-md-2 col-lg-2 orders-pic\">";
                <?php if(front::get('isproxy')){ ?>
                     htmljd+="<a target=\"_blank\" href=\"<?php echo $base_url;?>/index.php?case=proxy&act=show&aid=<?php echo $val['aid'];?>\"><img src=\"<?php echo $val['thumb'];?>\" class=\"img-responsive\" onerror='this.src=\"<?php echo config::get('onerror_pic');?>\"' /></a>";
                <?php }else{ ?>
                    htmljd+="<a target=\"_blank\" href=\"<?php echo $base_url;?>/index.php?case=archive&act=show&aid=<?php echo $val['aid'];?>\"><img src=\"<?php echo $val['thumb'];?>\" class=\"img-responsive\" onerror='this.src=\"<?php echo config::get('onerror_pic');?>\"' /></a>";
                <?php } ?>
                htmljd+="</div>";
                htmljd+=" <div class=\"col-xs-8 col-sm-9 col-md-10 col-lg-10\">";
                htmljd+="<div class=\"pull-right col-xs-1 col-sm-1 col-md-1 col-lg-1 orders-padding-x\">"
                htmljd+="<a href=\"#\" onclick=\"reomeclick('<?php echo $val['name'];?>','<?php echo $divname;?>','<?php echo $price;?>');dropclick('<?php echo $val['aid'];?>','<?php echo $val['name'];?>');\" title=\"{lang('delete')}\" class=\"orders-del\"><i class=\"glyphicon glyphicon-remove\"></i></a>";
                htmljd+="</div>";
                htmljd+="<div class=\"pull-left col-xs-11 col-sm-11 col-md-11 col-lg-11 orders-padding-x\">";
                htmljd+=" <div class=\"col-xs-11 col-sm-5 col-md-5 col-lg-5\" id=\"<?php echo $val['name'];?>\">";
                <?php if(front::get('isproxy')){ ?>
                    htmljd+=" <a target=\"_blank\" href=\"<?php echo $base_url;?>/index.php?case=proxy&act=show&aid=<?php echo $val['aid'];?>\" class=\"o_title\"><?php echo $val['title'];?></a>";
                <?php }else{ ?>
                    htmljd+=" <a target=\"_blank\" href=\"<?php echo $base_url;?>/index.php?case=archive&act=show&aid=<?php echo $val['aid'];?>\" class=\"o_title\"><?php echo $val['title'];?></a>";
                <?php } ?>
                htmljd+="<span><?php echo $setdatatype;?></span>";
                htmljd+="</div>";
                htmljd+="<div class=\"col-xs-12 col-sm-3 col-md-3 col-lg-3\">";
                htmljd+="<?php echo lang('price');?>&nbsp;:&nbsp;<?php echo lang('the_symbol_of_money');?>&nbsp;<span id=\"thisprice<?php echo $val['aid'];?>\" align=\"center\" class=\"price\"><?php echo $price;?></span>&nbsp;<?php echo lang('unit');?>   <span> {lang('stock')}：{$val['inventory']}</span> ";
                htmljd+="</div>";
                htmljd+="<div class=\"col-xs-12 col-sm-3 col-md-3 col-lg-3\">";
                htmljd+="<input class=\"min\" name=\"\" type=\"button\" value=\"-\"  onclick=\"minnum(this,'1','<?php echo $divname;?>',<?php echo $price;?>)\"/>" ;
                htmljd+="<input class=\"thisnum\" type=\"text\" id=\"thisnum<?php echo $val['name'];?>\" name=\"inventory{$val['aid']}\"  onfocus=\"getnum(this)\"  value=\"<?php echo $val['amount'];?>\" size=\"5\"  onblur=\"setnum(this,'<?php echo $val['name'];?>','<?php echo $divname;?>',<?php echo $price;?>,'{$val['aid']}','{$val['inventory']}'); setTotal();\"  />" ;
                htmljd+="<input class=\"add\" name=\"\" type=\"button\" value=\"+\"  onclick=\"addnum(this,'1','<?php echo $divname;?>',<?php echo $price;?>,'{$val['aid']}','{$val['inventory']}')\" />" ;
                htmljd+="</div>";
                htmljd+="</div>";
                htmljd+="</div>";
                htmljd+="</div>";
                var divname="listdiv<?php echo $divname;?>";
                $("#"+divname+"").append(htmljd);//插入节点
                //计算小计
                var xiaoji=parseFloat("<?php echo $price;?>")*parseFloat("<?php echo $val['amount'];?>");
                $("#<?php echo $divname;?>total").html(parseFloat( $("#<?php echo $divname;?>total").html())+parseFloat(xiaoji));
            </script>
            <?php }else{ ?>
            <div id="listdivparent<?php echo $val['name'];?>"  style="margin: 10px 5px 10px 5px;">
                <div   class="thistotal">
                    <strgong><?php echo $val['title'];?></strgong>
                    {if config::get('coupon_show')}
                    <select id="select<?php echo $val['name'];?>" onchange="setselect(this,'<?php echo $val['name'];?>')" style="float:right; border:1px solid #eee; font-weight:normal; border-radius: 3px;font-size:12px; padding: 6px 12px;">
                        <option value=''>{lang('no_discount')}</option>
                    </select>
                    {/if}
                </div>
                <br/>
                <div id="listdiv<?php echo $val['name'];?>" style="padding: 10px 5px 10px 5px;margin-top: 5px">
                    <input type="hidden" id="hidden<?php echo $val['name'];?>" name="aid[]" value="<?php echo $val['name'];?>,<?php echo $val['amount'];?>#<?php echo $val['datatype'];?>" />
                    <?php if(front::get('isproxy')){ ?>
                    <input type="hidden" id="proxyhidden<?php echo $val['name'];?>" name="service_aid[]" value="<?php echo $val['service_aid'];?>,<?php echo $val['amount'];?>#<?php echo $val['datatype'];?>" />
                    <?php } ?>
                    <div id="list<?php echo $val['name'];?>"  class="row orders-list">
                        <div class="col-xs-4 col-sm-3 col-md-2 col-lg-2 orders-pic">
                            <?php if(front::get('isproxy')){ ?>
                            <a target="_blank" href="<?php echo $base_url;?>/index.php?case=proxy&act=show&aid=<?php echo $val['aid'];?>"><img src="<?php echo $val['thumb'];?>" class="img-responsive" onerror='this.src="<?php echo config::get('onerror_pic');?>"' /></a>
                            <?php }else{ ?>
                            <a target="_blank" href="<?php echo $base_url;?>/index.php?case=archive&act=show&aid=<?php echo $val['aid'];?>"><img src="<?php echo $val['thumb'];?>" class="img-responsive" onerror='this.src="<?php echo config::get('onerror_pic');?>"' /></a>
                            <?php } ?>
                        </div>

                        <div class="col-xs-8 col-sm-9 col-md-10 col-lg-10">
                            <div class="pull-right col-xs-1 col-sm-1 col-md-1 col-lg-1 orders-padding-x">

                                <a href="#" onclick="reomeclick('<?php echo $val['name'];?>','<?php echo $val['name'];?>','<?php echo $price;?>');dropclick('<?php echo $val['aid'];?>','<?php echo $val['name'];?>');" title="{lang('delete')}" class="orders-del"><i class="glyphicon glyphicon-remove"></i></a>
                            </div>
                            <div class="pull-left col-xs-11 col-sm-11 col-md-11 col-lg-11 orders-padding-x">
                                <div class="col-xs-11 col-sm-5 col-md-5 col-lg-5" id="<?php echo $val['name'];?>">
                                    <?php if(front::get('isproxy')){ ?>
                                    <a target="_blank" href="<?php echo $base_url;?>/index.php?case=proxy&act=show&aid=<?php echo $val['aid'];?>" class="o_title"><?php echo $val['title'];?></a>
                                    <?php }else{ ?>
                                    <a target="_blank" href="<?php echo $base_url;?>/index.php?case=archive&act=show&aid=<?php echo $val['aid'];?>" class="o_title"><?php echo $val['title'];?></a>
                                    <?php } ?>
                                    <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <?php
                                            echo $setdatatype;
                                             ?>
                                        </span>
                                </div>

                                <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
                                    <?php echo lang('price');?>&nbsp;:&nbsp;<?php echo lang('the_symbol_of_money');?>&nbsp;
                                    <span id="thisprice<?php echo $val['aid'];?>" align="center" class="price">
                                      <?php  echo $price;?>
                                 </span>&nbsp;<?php echo lang('unit');?>
                                    <span> {lang('stock')}：{$val['inventory']}</span>
                                </div>
                                <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
                                    <input class="min" name="" type="button" value="-" onclick="minnum(this,'1','<?php echo $val['name'];?>','<?php echo $price;?>')" />
                                    <input class="thisnum" type="text" id="thisnum<?php echo $val['name'];?>" name="inventory{$val['aid']}" value="<?php echo $val['amount'];?>" size="5"  onfocus="getnum(this)"  onblur="setnum(this,'<?php echo $val['name'];?>','<?php echo $val['name'];?>','<?php echo $price;?>','{$val['aid']}','{$val['inventory']}');setTotal();")"  />
                                    <input class="add" name="" type="button" value="+" onclick="addnum(this,'1','<?php echo $val['name'];?>','<?php echo $price;?>','{$val['aid']}','{$val['inventory']}')"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="thistotal  pull-right">
                    {lang('subtotal')}：<span><?php echo lang('the_symbol_of_money');?><label id="<?php echo $val['name'];?>total"><?php echo $price* $val['amount'];?></label></span>
                </div>
                <div class="clearfix"></div>
                <hr class="featurette-divider">
            </div>

            <?php $titlename=$val['title'];$divname=$val['name'];}?>
            <script>
                $(function () {
                <?php

                    if(is_array($data)){
                        foreach($data as $d)
                        {
                 ?>
                            var htmlselect="";

                <?php
                            if(trim($d['couponrange']) =='0:0'){
                                continue;
                            }
                            $source = explode(":", trim($d['couponrange']));
                            $categorysonid= category::getInstance()->templateson($source[0]);
                            $categorysonidstatuc=false;
                            if (is_array($categorysonid)){
                                foreach($categorysonid as $valcatid ){
                                    if( $val['catid'] == $valcatid ){
                                        $categorysonidstatuc=true;
                                    }
                                }
                            }

                            if (($source[0] == $val['catid'] || $categorysonidstatuc) && ($source[1] == $val['aid'] || $source[1]==0)) {
                                $catname =$d['coupontitle'];
                                $couponid=$d['couponid'];
                                $satisfy=$d['satisfy'];
                                $usableusernum=$d['usableusernum'];
                                if($d['overlay']=='1'){
                                    $overlay=lang('superposition');
                                }else{
                                    $overlay=lang('non_superposition');
                                }
                 ?>
                                usableusernum[{$couponid}]={$usableusernum};

                                var xiaoji=parseFloat($("#"+{$val['name']}+"total").html());
                                /* if(parseFloat('{$satisfy}')> xiaoji){
                                     htmlselect+="<option value='{$couponid}'>{$catname}{$overlay}(不满足条件)</option>";
                                 }else{*/
                                htmlselect+="<option value='{$couponid}'>{$catname}{$overlay}</option>";

                                /* }*/
                                $("#select{$val['name']}").append(htmlselect);
                <?php        }
                        }
                    }
                ?>


                });
            </script>
            <?php } ?>
            <?php
            if(is_array($data)){
                foreach($data as $key=>$d) {
                    if(trim($d['couponrange']) !='0:0'){
                         unset($data[$key]);
                    }
                }
            }
            if(is_array($data) && count($data)>0 && config::get('coupon_show')){
            ?>
            <div class="table-responsive">
                <table class="table table-hover ">
                    <thead>
                    <tr class="th">
                        <th class="coupon-list-coupontitle"><?php echo lang('title');?></th>
                        <th class="coupon-list-couponrange"><!--couponrange-->{lang('scope_of_use')}</th>
                        <th class="coupon-list-overlay"><!--overlay-->{lang('superposition')}</th>
                        <th class="coupon-list-satisfy"><!--satisfy-->{lang('how_much_is_available')}</th>
                        <th class="coupon-list-moeny"><!--moeny-->{lang('amount_of_offset')}</th>
                        <th class="coupon-list-quantity"><!--quantity-->{lang('residual_quantity')}</th>
                        <th class=""><?php echo lang('dosomething');?></th>
                    </tr>

                    </thead>
                    <tbody>
                    <?php
                    foreach($data as $key=>$d) {
                        if(trim($d['couponrange']) !='0:0'){
                          continue;
                        }
                    ?>
                    <tr class="s_out">
                        <td class="coupon-list-coupontitle"><?php echo $d['coupontitle'];?></td>
                        <th class="coupon-list-couponrange"><!--couponrange-->
                            <?php
                             $source = explode(":",trim($d['couponrange']));
                             if($source['0']=='0'){
                                 echo '全部栏目';
                             }else{
                                 $catname=category::getcategoryname($source['0']);
                                 echo $catname['0']['catname'];
                             }
                             if($source['1']=='0'){
                                   echo '|全部产品';
                             }else{
                                   $catname=archive::getarchivename($source['1']);
                                   echo '|'.$catname;
                             }
                           ?>
                        </th>
                        <th class="coupon-list-overlay"><!--overlay--><?php echo $d['overlay']==1?'是':'否' ?></th>
                        <th class="coupon-list-satisfy"><!--satisfy--><?php echo $d['satisfy'];?></th>
                        <th class="coupon-list-moeny"><!--moeny--><?php echo $d['moeny'];?></th>
                        <th class="coupon-list-quantity"><!--quantity--><?php echo $d['usableusernum'];?>
                        </th>
                        <td class="">
                            <input type="button" name="couponyhj" class="coupon-btn"  id="coupon<?php echo $d['couponid'];?>" onclick="setcoupon(this,'<?php echo $d['couponid'];?>',1)" value="{lang('immediate_use')}"/>
                        </td>
                    </tr>
                    <?php };?>
                    </tbody>
                </table>
            </div>
            <?php };?>

            <div class="blank30"></div>
            <div class="thistotal  pull-right">
                <?php echo lang('ordertotal');?>：<span><?php echo lang('the_symbol_of_money');?><label id="total"></label></span>
            </div>

            <div class="blank30"></div>

            <input type="text" id="somecoupon" name="somecoupon"  style="display: none">
            <a href="{url('archive/emptyorders')}" class="buy">{lang('empty')}</a> <a href="{$base_url}/index.php?case=archive&act=listscreening&cateGory=&type=&special=" class="buy">{lang('continue_shopping')}</a>

                    <a href="#" class="shoppingcart" onClick="$('#step2').show();$('#step1').hide();setsomecoupon();">
                        <?php echo lang('fill_in_the_contact_form_to_complete_the_shopping');?>
                        </a>
              


            <?php } else { ?>
            <h1 style="text-align: center;">{lang('no_merchandise_for_the_time_being')}</h1>
            <?php } ?>

        </div>

            {if (isset($settlement) && $settlement=='1')}
                <div id="step2" style="">
            {else}
             <div id="step2" style="display:none;">
            {/if}
            <div class="t_1" id="lianxi">
                <div>
                    <h3><a href="<?php echo $cat['url'];?>" title="<?php echo $cat['catname'];?>"><?php echo lang('contactmode');?></a></h3>
                    <p>Contact information</p>
                </div>
            </div>


            <div class="orders-conact">
                <div class="form-group">
                    <label for="<?php echo lang('ordercontactname');?>"><?php echo lang('ordercontactname');?></label>
                    <input type="text" class="form-control" name="pname" placeholder="<?php echo lang('ordercontactname');?>" />
                </div>


                <div class="form-group">
                    <label for="<?php echo lang('ordertel');?>"><?php echo lang('ordertel');?></label>
                    <input type="text" class="form-control" id="telphone" name="telphone" placeholder="<?php echo lang('ordertel');?>" />
                </div>


                <?php if(config::get('mobilechk_enable') && config::get('mobilechk_buy')) { ?>
                <div class="row">
                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                        <input type='text' id="mobilenum"  tabindex="4" placeholder="{lang('mobile_phone_check_code')}" class="form-control"  name="mobilenum" />
                    </div>
                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 text-left">
                        <input id="btm_sendMobileCode" onclick="sendMobileCode('<?php echo url('tool/smscode');?>',$('#telphone'));" type="button" class="btn pull-left btn-primary pull-right orders-btn" value="{lang('send_mobile_check_code')}" />
                    </div>
                </div>
                <div class="blank10"></div>
                <?php } ?>


                <div class="form-group">
                    <label for="<?php echo lang('orderaddress');?>"><?php echo lang('orderaddress');?></label>
                    <input type="text" class="form-control" id="address" name="address" placeholder="<?php echo lang('orderaddress');?>" />
                </div>
                {if session::get('username')==''}
                <div class="form-group">
                    <label for="<?php echo lang('email');?>"><?php echo lang('email');?></label>
                    <input type="text" class="form-control" id="postcode" name="postcode" placeholder="<?php echo lang('email');?>" />
                </div>
                {/if}
                <?php if($logisticslist) { ?>
                <h4><?php echo lang('pickingmethods');?></h4>



                <?php if(is_array($logisticslist))
foreach($logisticslist as $i => $logistics) { ?>
                <div class="radio">
                    <label>
                        <input type="radio" name="logisticsid" value="<?php echo $logistics['id'];?>" checked>
                        <?php echo $logistics['title'];?><p> <?php echo lang('fees');?>：<?php echo $logistics['price'];?></p>
                    </label>
                </div>

                <small><?php echo $logistics['content'];?></small>

                <?php } ?>
                <div class="blank10"></div>
                <?php } ?>

                <div class="blank10"></div>
                <textarea placeholder="<?php echo lang('ordercontent');?>" name="content" class="form-control" rows="3"></textarea>

                <div class="blank30"></div>
                <a href="#" class="shoppingcart" onClick="return check();"><?php echo lang('onlinepayment');?></a>
                <a href="#" class="buy" onClick="$('#step1').show();$('#step2').hide();"><?php echo lang('previous_step');?></a>
            </div>
        </div>



        <div id="step3" style="display:none">
            <div class="t_1">
                <div>
                    <h3><a href="<?php echo $cat['url'];?>" title="<?php echo $cat['catname'];?>"><?php echo lang('now_turn_to_pay_page');?></a></h3>
                    <p>Now Turn To Pay Page</p>
                </div>
            </div>
            <div class="container">
                <div class="row">
                    <div style="width:100%;padding:0px 10px; display: table;">
                        <?php if($paylist) { ?>
                        <?php if(is_array($paylist))
                            foreach($paylist as $i => $pay) { ?>
                                <?php if($pay['enabled']==1) { ?>
                                <div class="col-md-4 col-xs-12">
                                <div class="row radio">
                                    <label>
                                        <input type="radio" name="payname" value="<?php echo $pay['pay_code'];?>" checked>
                                        <img src="<?php echo $pay['pay_image'];?>" height="26">
                                        <?php echo $pay['pay_name'];?><p> <?php echo lang('rates');?>：<?php echo $pay['pay_fee'];?>%</p>
                                    </label>
                                </div>
                                </div>
                                <?php } ?>
                            <?php } ?>
                        <?php } else { ?>
                        <?php echo lang('nopayment');?>
                        <?php } ?>
                        <div class="col-md-4 col-xs-12">
                            <div class="row radio">
                                <label>
                                    <input type="radio" id="user_menoy" name="payname" value="yuer">
                                    <?php echo lang('余额支付');?><p> <?php echo lang('剩余余额');?>：<?php echo user::getmenoy();?></p>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="blank30"></div>
                    <button class="shoppingcart"  type="submit" name="submit"   value="<?php echo lang('buy');?>"><?php echo lang('buy');?></button>
                    <input class="buy" type="button" value="<?php echo lang('previous_step');?>" onClick="$('#step2').show();$('#step3').hide();">

                </div>
            </div>
        </div>
</div>
</div>
</form>

<script>
    $(function () {
        $("[name=submit]").onclick(function () {
            $("[name=submit]").attr("disable","disable");
        });
    })
</script>

<div class="blank30"></div>

<div class="copy">
    <?php echo get('site_right');?> <a title="<?php echo get('sitename');?>" href="<?php echo $base_url;?>/"><?php echo get('sitename');?></a>
    <div class="f"  style="display:none">
        <?php echo getCopyRight();?>
    </div>
</div>
</div>
<?php } ?>
</div>
</div>

<!-- Bootstrap Js -->
<script src="<?php echo $base_url;?>/common/css/bootstrap/bootstrap-3.3.7/js/bootstrap.min.js"></script>

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="<?php echo $base_url;?>/common/plugins/ie/ie10-viewport-bug-workaround.js"></script>
<script src="<?php echo $base_url;?>/common/css/bootstrap/bootstrap-3.3.7/js/bootstrap-submenu.js"></script>

<!--[if lt IE 9]><!-->
<script src="<?php echo $base_url;?>/common/plugins/ie/html5shiv.min.js"></script>
<script src="<?php echo $base_url;?>/common/plugins/ie/respond.min.js"></script>
<![endif]-->

<div class="servers-wap">
    <?php if(config::get('wap_foot_nav')=='1') { ?>
    <?php echo template('system/foot_nav_a.html'); ?>
    <?php } elseif (config::get('wap_foot_nav')=='2') { ?>
    <?php echo template('system/foot_nav_b.html'); ?>
    <?php } elseif (config::get('wap_foot_nav')=='3') { ?>
    <?php echo template('system/foot_nav_c.html'); ?>
    <?php } else { ?>
    <?php } ?>
</div>

</body>
</html>