{template_user 'head.html'}

<?php
    $source = explode("-",trim($orders['aid']));

    $totl=0;
    $discountid = explode("-",trim($orders['oid']));    //获取下单的用户
    $discount=usergroup::getusergrop(user::getuserid($discountid[2])); //获取用户组的折扣
    $isint =usergroup::getisint(user::getuserid($discountid[2]));      //获取是否取整
?>
<div class="index-bg">
	<div class="container">
		<div class="section2">

		<div class="index-title">
				<h4>{lang('order')}</h4>
            <?php if(!config::getadmin('memberbuy') && $discountid[2]==0) { ?>
            <span style="color:#FF4A00;">{lang('anonymous_order_reminder')}</span>
            <?php } ?>
			</div>


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

  {if $orders['oid']}
            <div  class="thistotal  pull-left">
                <strong>{lang('order_number')}：{$orders['oid']}</strong>
            </div>
            <span class="pull-right">{lang('order_time')}：{cut(date('Y-m-d H:i:s',$orders['adddate']))}</span>
			<div class="blank5"></div>

                <?php
				for($index=0;$index<count($source);$index++){
					$newsource = explode("#",trim($source[$index]));
                     $setdatatype="";
                     $fh="";
                     if(isset($newsource[1]) && $newsource[1] !=''){
                     $leixin = explode(";",trim($newsource[1]));
                        for($num=0;$num<count($leixin);$num++){
                              $leixin2 = explode(":",trim($leixin[$num]));
                              $newcname='cname_'.lang::getistemplate();
                              if($orders['type']==2){
                                $setdatatype=$setdatatype.setting::$service_var[$leixin2['0']][$newcname]."：";
                              }else{
                                $setdatatype=$setdatatype.setting::$var['archive'][$leixin2['0']][$newcname]."：";
                              }
                              $leixin2 = explode(",",trim($leixin2['1']));
                              $setdatatype=$setdatatype.$leixin2['0']."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                              if($fh==""){
                                 $fh=$fh.$leixin2['1'].','.$leixin2['2'];
                              }else{
                                 $fh=$fh.':'.$leixin2['1'].','.$leixin2['2'];
                              }
                        }
                     }
					$ordersdata = explode(",",trim($newsource[0]));
					if ($orders['type'] == 2) {
                        $archive = servicearchive::getInstance();
                    } else {
                        $archive = archive::getInstance();
                    }
					$ordersArray=$archive->getarchive($ordersdata[0]);
                    if ($orders['type'] == 2) {
                        $ordersArray['customize_attr2'] = $ordersArray['customize_attr2'] == "" ? 0 : $ordersArray['customize_attr2'];
                        $newcname = 'attr2_' . lang::getistemplate();
                        $attr2 = json_decode($ordersArray['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;
                        //若是没有设置多语言 默认使用原来价格  否则使用多语言价格
                        $ordersArray['customize_attr2'] = is_numeric($ordersArray['customize_attr2']) ? $ordersArray['customize_attr2'] : $attr2[$newcname];
                        $ordersArray['attr2'] =$ordersArray['customize_attr2'];
                    }else{
                        $newcname='attr2_'.lang::getistemplate();
                        $attr2=json_decode($ordersArray['attr2'],true);
                        $ordersArray['attr2']=is_array($attr2)?$attr2[$newcname]:$ordersArray['attr2'];
                    }
                    $ordersArray['attr2']=(floatval($ordersArray['attr2'])*$discount/10);   //单价打折
                    if($isint){                                  //判断取整
                    $ordersArray['attr2']=round($ordersArray['attr2']);
            }
                $price=0;
                if($fh!=""){
                $pricesource = explode(":",trim($fh));
                $price=floatval($ordersArray['attr2']);
                for($priceindex=0;$priceindex<count($pricesource);$priceindex++){
                $pricesource2= explode(",",trim($pricesource[$priceindex]));
                if($pricesource2['0']=="jia"){
                $price=$price+floatval($pricesource2['1']);
                }else if($pricesource2['0']=="jian"){
                $price=$price-floatval($pricesource2['1']);
                }else if($pricesource2['0']=="chen"){
                $price=$price*floatval($pricesource2['1']);
                }else if($pricesource2['0']=="chu"){
                $price=$price/floatval($pricesource2['1']);
                }
                }
                }else{
                $price=$ordersArray['attr2'];
                }
                ?>
                <div   class="row orders-list">
                    <div class="col-xs-4 col-sm-3 col-md-2 col-lg-2 orders-pic">
                        <?php  if($orders['type']==2){ ?>
                        <a target="_blank" href="<?php echo $base_url;?>/index.php?case=proxy&act=show&aid={$ordersArray['aid']}"><img src="{$ordersArray['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={$ordersArray['aid']}"><img src="{$ordersArray['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-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($orders['type']==2){ ?>
                                <a target="_blank" href="<?php echo $base_url;?>/index.php?case=proxy&act=show&aid={$ordersArray['aid']}" class="o_title">{$ordersArray['title']}</a>
                                <?php  }else{?>
                                <a target="_blank" href="<?php echo $base_url;?>/index.php?case=archive&act=show&aid={$ordersArray['aid']}" class="o_title">{$ordersArray['title']}</a>
                                <?php  }?>
                                <span><?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  align="center" class="price">
                                          <?php  echo $price;?>
                                     </span>&nbsp;<?php echo lang('unit');?>
                            </div>
                            <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
                                <span>{lang('numbers')}：{$ordersdata[1]}</span>
                            </div>
                            <div class="pull-right col-xs-1 col-sm-1 col-md-1 col-lg-1 orders-padding-x" style="width: 100px">
                                    <span>{lang('amount_of_money')}：<label style="color: #FF4A00;font-size: 20px;max-width: 100%;margin-bottom: 5px;font-weight: 700;">
                                        <?php   echo $ordersdata[1]*$price;$totl=$ordersdata[1]*$price+$totl ?></label>
                                    </span>
                            </div>
                        </div>
                    </div>
                </div>
                <?php } ?>
                <?php  if($orders['somecoupon']!=''){?>
				<div class="table-responsive">
                <table class="table table-striped table-hover ">
                    <thead>
                    <tr class="th">
                        <th class="coupon-list-coupontitle">{lang('preferential_offer')}</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('quantity_of_use')}</th>
                    </tr>

                    </thead>
                    <tbody>

                    <?php
                    $coupondata=array();
                    $couponsource = explode(",", trim($orders['somecoupon']));
                    for ($couponindex = 0; $couponindex < count($couponsource); $couponindex++) {
                     $coupondata[count($coupondata)]=coupon::getcouponid( $couponsource[$couponindex]);; //优惠劵信息获取
                    }
                    foreach($coupondata as $d) {
                    ?>
                    <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']; $totl=$totl-$d['moeny'];?></th>
                        <th class="coupon-list-quantity"><!--quantity-->1</th>
                    </tr>
                    <?php  }  ?>
                    </tbody>
                </table>
				</div>
                <?php  }  ?>
 <div class="clearfix blank5"></div>
<hr class="featurette-divider">
			<div class="clearfix blank5"></div>
            <div   class="thistotal  pull-right">
                <span style="color: #000;font-weight: bold;">{lang('total_order_price')}：<label style="color: #FF4A00;font-size: 20px;max-width: 100%;margin-bottom: 5px;font-weight: 700;">￥{$totl}</label></span>
                <span style="color: #000;font-weight: bold; padding-left: 10px;">{lang('orderstatus')}：<span class='btn-soft-success'>{$orders['status']}</span></span>
                <?php if($orders['status2']==0){ ?>
                    <span style="font-weight: bold; padding-left: 10px;">
                     <a  class="orders-list-dosomething" href='<?php echo url("archive/payorders/oid/".$orders['oid'],false);?>' target="_blank">{lang('immediate_payment')}</a>
                    </span>
                <?php };?>
            </div>


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

	<div class="index-title">
				<h4>{lang('ordersinfo')}</h4>
			</div>

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





  <div class="clearfix form-group">
    <label for="exampleInputEmail1">{lang('ordertel')}</label>
    <input class="form-control input-readonly" type="text" placeholder="{$orders['telphone']}" readonly>
  </div>

  <div class="clearfix form-group">
    <label for="exampleInputEmail1">{lang('orderaddress')}</label>
    <input class="form-control input-readonly" type="text" placeholder="{$orders['address']}" readonly>
  </div>


  <div class="clearfix form-group">
    <label for="exampleInputEmail1">{lang('postcode')}</label>
    <input class="form-control input-readonly" type="text" placeholder="{$orders['postcode']}" readonly>
  </div>

  <div class="clearfix form-group">
    <label for="exampleInputEmail1">{lang('ordercontent')}</label>
    <input class="form-control input-readonly" type="text" placeholder="{$orders['content']}" readonly>
  </div>

     <div class="clearfix form-group">
    <label for="exampleInputEmail1">{lang('tatus')}</label>
    <input class="form-control input-readonly" type="text" placeholder="{$orders['status']}" readonly>
  </div>

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

    <label for="exampleInputEmail1" class="pay-btn">{$gotopaygateway}</label>
    <input class="form-control input-readonly" type="hidden" placeholder="{getArchiveTitle($orders['aid'])}" readonly>


   <input type="submit" value="{lang('shutwin')}" onClick="window.close()" class="btn btn-default" style="margin-left:15px;">

    {else}
    {lang('ordersnot')}
	<meta http-equiv="refresh" content="1;URL={get('site_url')}">
    {/if}


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

</div>
</div>
</div>
</div>
<div class="blank30"></div>
<style type="text/css">
	.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
    background-color: #fff;
    opacity: 1;
}
.btn-default {background:#eee;}
.orders-oid strong {color:#FF4A00;}
</style>
{template_user 'foot.html'}