  <?php require_once('../Connections/BE2.php'); ?>
<?php
include "../config.data.php"; 
$sqltext='';
/*
if (isset($_POST['s1'])){
	 if($_POST['s1']<>''){ $sqltext=sprintf(" AND order_check = '%s' ",$_POST['s1']); }
     if($_POST['s2']<>''){ $sqltext.=sprintf(" AND mem_name = '%s' ",$_POST['s2']); }
	 if($_POST['s3']<>''){ $sqltext.=sprintf(" AND order_num = '%s' ",$_POST['s3']); }
	 
	}
*/
 
$currentPage = "mysale2.html";//$_SERVER["PHP_SELF"];  
$maxRows_Rt2 = 20;
$pageNum_Rt2 = 0;
if (isset($_GET['pageNum_Rt2'])) {
  $pageNum_Rt2 = $_GET['pageNum_Rt2'];
}
$startRow_Rt2 = $pageNum_Rt2 * $maxRows_Rt2;
 
 
  
$colname_Rt2 = "-1";
if (isset( $_SESSION['login_memid']  )) {
  $colname_Rt2 =  $_SESSION['login_memid']  ;
}

$colname_Rt2=-1;
mysql_select_db($database_BE2, $BE2);
$query_Rt2 = sprintf("SELECT a.* FROM order_datam as a,order_datas as b,product_data as c WHERE a.dcode=b.dcode AND b.mem_auto=c.mem_auto AND c.company_num='%s' %s ORDER BY a.dcode DESC",$_SESSION['login_memid'],$sqltext); ;//,$colname_Rt2
 
//$query_Rt2 = sprintf("SELECT * FROM product_order_data WHERE company_num='%s' %s ORDER BY mem_auto DESC",$_SESSION['login_memid'],$sqltext);//,$colname_Rt2

$query_limit_Rt2 = sprintf("%s LIMIT %d, %d", $query_Rt2, $startRow_Rt2, $maxRows_Rt2);
$Rt2 = mysql_query($query_limit_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);


if (isset($_GET['totalRows_Rt2'])) {
  $totalRows_Rt2 = $_GET['totalRows_Rt2'];
} else {
  $all_Rt2 = mysql_query($query_Rt2);
  $totalRows_Rt2 = mysql_num_rows($all_Rt2);
}
$totalPages_Rt2 = ceil($totalRows_Rt2/$maxRows_Rt2)-1;


$queryString_Rt2 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Rt2") == false && 
	//   stristr($param, "act") == false && 
        stristr($param, "totalRows_Rt2") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Rt2 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Rt2 = sprintf("&totalRows_Rt2=%d%s", $totalRows_Rt2, $queryString_Rt2);
?> 
					    
 <div class="main "> 
 
 <div class="row">
 <div class="col-lg-12">				    
<a style="cursor: pointer" ><b><font color="blue">產品資訊</font></b></a></p>
<a href="#" class="btn btn-3d btn-blue btn-md">產品資訊</a>
<a href="#" class="btn btn-3d btn-red btn-md" target="_blank">物流流程查詢</a>
<? // echo $query_Rt21 ; ?>
 <div class="table-responsive">
<form action="mysale.html" method="POST" name="form2">
	<table class="table table-bordered table-hover">
		<tbody>
		<tr>
			<td>訂單狀態
			<select class="form-control select" name="s1" id="s1">
				<option value="">請選擇</option>
                <? for($i=0;$i<count($select_s1_ar);$i++){ ?> 
				<option value="<?=$select_s1_ar[$i]?>"><?=$select_s1_ar[$i]?></option>
                <? }?>
			</select>
			</td>
			<td>訂購人姓名<input name="s2" type="text" id="s2" class="form-control"></td>
			<td>訂單編號<input name="s3" type="text" id="s3" class="form-control"></td>
		  <td><br><input type="submit" name="Submit" value="搜尋" class="btn btn-3d btn-black btn-md"></td>
		</tr>
		</tbody>
	</table>
</form>
</div>

<table class="table table-bordered table-striped table-condensed table-hover" style="min-width:1500px;">
	<thead>
		<tr>
			<th>訂單日期</th>
			<th>訂單編號</th>
			<th>通知廠商日期</th>
			<th>廠商名稱.統編</th>
			<th>廠商收貨地址</th>
			<th>收貨聯絡人</th>
			<th>商品名稱</th>
			<th>通知物流時間</th>
			<th>物流查詢</th>
			<th>物流單號</th>
			<th>會員編號</th>
			<th>會員姓名</th>
            <th>地址</th>
            <th>電話</th>
            <th>物流出貨時間</th>
            <th>管理</th>
		</tr>
	</thead>
	<tbody>
    <?php 
	if($totalRows_Rt2>0){
	do {   ?>
  <tr>
    <td><?= $row_Rt2['ddate'];?></td>
    <td><?= $row_Rt2['dcode'];?></td>
    <td><?= $row_Rt2['duser'] ;?></td>
    <td>&nbsp;</td>
    <td><?= $row_Rt2['dmoney'];?></td>
    <td>&nbsp;</td>
    <td><?= $row_Rt2['dexpess'];?></td>
    <td><?= $row_Rt2['dall'] ;?></td>
    
    <? $ar1=array("","信用卡線上刷卡","超商取貨付款","臨櫃匯款","ATM轉帳"); ?>
    
    <td><?= $ar1[$row_Rt2['dpay']];?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><a href="#" target="_self">訂單明細</a>
      <a href="#" target="_self">編輯訂</a>
      <a href="#" target="_self">刪除</a>
    </td>
  </tr>
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2));
	}
	 ?>
    <tbody>
</table>


 </div>
 <ul class="pagination">
                    <?   
                     if( $totalPages_Rt2 >1){	 
						    //分頁程式
if($totalPages_Rt2<5){
		 $start=0;
		 $end=$totalPages_Rt2;
		}else{  
	    $start=$pageNum_Rt2-5;
		$end=$pageNum_Rt2+5;
        if ($start<0){
		 $start=0;
		 $end=10; } 
		 else { $end=$start+10 ;}
		 if ($end>$totalPages_Rt2){ 
		   $start = $end-$totalPages_Rt2-5;
		   $end=$totalPages_Rt2;
		   }
		 if ($end-$start>10){ 
		   $start = $end-10;
		   }  
		 } ?> 
                     <?php if ($pageNum_Rt2 > 0) { // Show if not first page ?>
                     <li><a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, max(0, $pageNum_Rt2 - 1), $queryString_Rt2); ?>">上一頁</a></li><?php } // Show if not first page ?>
                    	<?	   
		for($i=$start;$i<=$end;$i++){
		if($i==$pageNum_Rt2){ echo '<li class="active"><a href="#">'.($i+1).'</a></li>';} else {?>
            <li><a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, min($totalPages_Rt2, $i), $queryString_Rt2); ?>"><? echo $i+1 ;?></a></li>
                 
                        <?	}   }  ?>

                      <?php if ($pageNum_Rt2 < $totalPages_Rt2) { // Show if not last page ?>
                          <li><a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, min($totalPages_Rt2, $pageNum_Rt2 + 1), $queryString_Rt2); ?>">下一頁</a></li>
                        <?php }  
						             } ?>
								
						  </ul>
   </div> 
		</div>
<?php
mysql_free_result($Rt2);
  
?>        
        
 