<?php
 session_start();
   include("db.php");
   include("../jdf.php");
    $counterCurrency=$_POST['counterCurrency'];
  
    if($counterCurrency!="all"){
     $customerTotal_sql="select sum(amount) from customerbalance where currencyId='$counterCurrency' and amount>0 ";
     $customerTotal_query= $db ->query($customerTotal_sql);
     $customerTotal_row=$customerTotal_query ->fetch_array();
	 $customerTotal=number_format($customerTotal_row['sum(amount)'],2);
	 
	 
  }  
   $get_customerTotal=$_GET['customerTotal'];
   
   if(isset($get_customerTotal)){
	   $customerTotal= $get_customerTotal;  
   }
   
   
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<title>لیست طلبات</title>
<head>
    <link href="../css/pagenation.css" rel="stylesheet" type="text/css" /> 
   <link rel="icon" href="../images/favicon.ico" type="image/png"/>  
   <link rel="stylesheet" href="table_style/table_style7.css">
   <link href="../css/pagenation.css" rel="stylesheet" type="text/css" /> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/print.css" /> 
<!-- ===================ÇíÌÇÏ íÇã ÈÑÇí æíÑÇíÔ ÝÇíá====================================-->
<script type="text/javascript" src="../change/edite/revenue_edite.js"></script> 
<script type="text/javascript" src="../change/delete/revenue_delete.js"></script>
 
<!--======================= ÇíÇä  ============================================================-->
 <style>
 a:link {
    text-decoration: none;
	color: #000;
}

 a:hover {
    color: red;
	text-decoration: underline;
}
a:active {
     
    color: #000;
}

@font-face {
	  font-family: 'hekmat';
	  src: url('../font/BHoma.ttf'); /* IE */
      src: local('BHoma-Bold'), url('../font/BHoma.ttf') format('truetype'); /* non-IE */
      font-weight:normal;
}
.font{
    color: #000;
    font-family: 'hekmat';  

}
a{
    color: #000;
    font-family: 'hekmat';  

}
@media print {

   .dontPrint {
       display:none;
    }

    }
	
	@media all{
.page-break{display:none;}
}
@media print{
.page-break{display:block;page-break-after:always;}
.dote img {visibility: visible;}
}
 
@page 
{
   size: auto;   /* auto is the initial value */
    margin: 3mm;  /* this affects the margin in the printer settings */
 }
  @media print {
    html, body {
        height: 99%;    
    }
}
 </style>

</head>
	<body onkeydown = "onKeyDown()" onKeyPress="return disableEnterKey(event)">
 <?php  //include("r_c_d_s_p/back_print_save_refresh.php"); ?>
<div id="wrap">
<table border="0" align="center"   width="930px" dir="rtl" class="font">
		<tr>
			<th style="width:166px;text-align:right">
			   
			</th>	 
			
			
			
			 
			  
				 </th>
				<th style="width:206px"><h2> <?php include("../info/companyName.php"); ?></h2>لیست طلبات&nbsp;(<span dir="rtl"> <?php echo jdate("Y-m-d")?>)<br><?php echo $customerTotal ?></span>
			    
				 
				 
			  
			  
			
			<th style="width:186px;text-align:left;height: 40px" > </th>
			 
		</tr>
		</table> 

 <div id='content'>
 
  <?php
     $counterCurrency=$_POST['counterCurrency'];
     if(isset($counterCurrency)){
          $counterCurrency=$_POST['counterCurrency'];
       }	 
	 //$_SESSION['counterCurrency']=$counterCurrency;
     if(!isset($counterCurrency)){
          $counterCurrency=$_GET['currency']; 
       }	 
	 
   
	  echo'
			<table id="box-table-a"   dir="rtl"  align="center" >
	        <thead> 
				<th scope="col">شماره</th>
				<th scope="col">مشتری</th>
				<th scope="col">نوعیت پول</th>
				<th scope="col">مقدار طلب</th>
				 
			</thead>
				 ';
    // Get page data
	 echo "<div id='content'>";
	  
			                include('db.php');
				            

						  
						 
					    if($counterCurrency=="all"){
						   $mony_sql="SELECT   *  FROM `customerbalance` where amount>0  ";
						 }
						 if($counterCurrency!="all"){
						   $mony_sql="SELECT   *  FROM `customerbalance` where  currencyId='$counterCurrency' and amount>0  ";
						 }
						 $mony_query= $db ->query($mony_sql);
				  
						  $ii=$countId;
                          while($nrow=$mony_query ->fetch_array()){
						    $ii++;
							 
							$customerId= $nrow['customerId'];
							$currencyId	= $nrow['currencyId'];
							$all+=$amount= $nrow['amount'];
					 		//=============================================================
							 
							 
							//******************************customer Name*******************************
							 $customerName_sql="select name from  `customers` where id='$customerId'";
							 $customerName_query=$db ->query($customerName_sql);
							 $customerName_row=$customerName_query ->fetch_array();
							 $customerName=$customerName_row['name'];	
							//=============================================================
							 //******************************Base Courrency*******************************
							 $basecurrency_sql="select name from  `currencies` where id='$currencyId'";
							 $basecurrency_query=$db ->query($basecurrency_sql);
							 $basecurrency_row=$basecurrency_query ->fetch_array();
							 $currency=$basecurrency_row['name'];	
							//=============================================================
							 
							    
						    //**************************************************************************************************   
							 
							 
			echo "<tbody>
			<tr>
			<td>".$ii."</td>
			<td>".$customerName."</td>
			<td>".$currency."</td>
			<td>".number_format($amount)."</td> 
			 
			 
			 </tr>";	

                
               			 
				 	  } 
		 echo '<tr style="color: red">';
		   if($counterCurrency!="all"){
            echo' <td colspan="6"  style="text-align: left;"><hr style="border:1px solid #000;"><sapn style="color: #000;font-weight: bold;font-size: 16px">مجموع: &nbsp;&nbsp;&nbsp;'.number_format($all).'&nbsp;'.$currency.'  </span></td>';
			 
		 }
	 echo'</table>';
              	
	 
 

?>
</tbody></table>
	</div>
</div> 
 
 <div id="footer" class="font" style="width: 400px;height: 25px; margin: auto;background: #7E7D7D;text-align: center;border-radius:20px" ><?php echo "صفحه:".$pageNumber; ?></div>
 </body>
  
 </html>  
 
     