<?php
 session_start();
   include("db.php");
   include("../pdate.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>	 
			
			
			
			
			<?php 
			       
			  
			  
			  
				  echo '</th>
				<th style="width:206px"><h2>';
				 include("../info/companyName.php");
				echo '</h2>لیست عکس های حواله&nbsp;(<span dir="rtl">'.pdate("Y-m-d").')<br></span>';
			    
				 
				 
			  
			  
			  ?>
			
			<th style="width:186px;text-align:left;height: 40px" > </th>
			 
		</tr>
		</table> 

 <div id='content'>
 
  <?php
    
	 
    include("db.php");
	$tableName="havale";		
	$targetpage = "havale_Customer_Report.php"; 	
	$limit = 24; 
	 
	$sql="SELECT COUNT(*) as num FROM `$tableName`   ";
	 
	$query= $db ->query($sql);
	$total_pages= $query ->fetch_array();
	
	 
	$total_pages = $total_pages[num];
	
	$stages = 3;
	$page = mysql_escape_string($_GET['page']);
	if($page >=1){
	 $countId=($page*24)-24;
	 }
	if($page){
		$start = ($page - 1) * $limit; 
	}else{
		$start = 0;	
		}	
	//================================================inter page cods HERE===============================================
    // Get page data
		
	  //echo "<div id='content'>";
	
	  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>
				<th scope="col">تلفن</th>
				<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');
				            

						  
						 
					     
						 
						 $mony_sql="SELECT   *  FROM `$tableName`   ";
						 $mony_query= $db ->query($mony_sql);
				  
						  $ii=$countId;
                          while($nrow=$mony_query ->fetch_array()){
						    $ii++;
							 
							$id= $nrow['id'];
							$customerName= $nrow['customerName'];
							$fname	= $nrow['fname'];
							$id_cart	= $nrow['id_cart'];
							$telephone	= $nrow['telephone'];
							$address=  $nrow['address'];
							$description=  $nrow['description'];
							$image	=  $nrow['image'];
					 		//=============================================================
							 
							 
							 
						    //**************************************************************************************************   
							 
							 
			echo "<tbody>
			<tr>
			<td>".$ii."</td>
			<td>".$customerName."</td>
			<td>".$fname."</td>
			<td>".$id_cart."</td> 
			<td>".$telephone."</td> 
			<td>".$address."</td> 
			<td>".$description."</td> 
			 
			<td><a target='_' href='../customerPicthre/".$image.".jpg'><img src='../img/user.png' width='25px' height='25px'></a></td>
			
			<td><a target='_' href='havale_chooise.phpn?id=".$id."'><img src='../img/edit.png' width='25px' height='25px'></a></td> 
			 
			 
			 </tr>";	

                
               			 
				 	  } 
		 echo '<tr style="color: red">';
		    
	 echo'</table>';
              	
	 echo "<br></div>";
	 echo "<div class='dontPrint'>";
//====================================================================================================================
	// Initial page num setup
	if ($page == 0){$page = 1;}
	$prev = $page - 1;	
	$next = $page + 1;							
	$lastpage = ceil($total_pages/$limit);		
	$LastPagem1 = $lastpage - 1;					
	
	
	$paginate = '';
	if($lastpage > 1)
	{	
	

	
	
		$paginate .= "<div class='paginate'>";
		// Previous
		if ($page > 1){
			$paginate.= "<a href='$targetpage?page=$prev & currency=$counterCurrency  & customerTotal= $customerTotal'  >قبلی</a>";
		}else{
			$paginate.= "<span class='disabled'>قبلی</span>";	}
			

		
		// Pages	
		if ($lastpage < 7 + ($stages * 2))	// Not enough pages to breaking it up
		{	
			for ($counter = 1; $counter <= $lastpage; $counter++)
			{
				if ($counter == $page){
					$paginate.= "<span class='current'>$counter</span>";
				}else{
					$paginate.= "<a href='$targetpage?page=$counter & currency=$counterCurrency  & customerTotal= $customerTotal'>$counter</a>";}					
			}
		}
		elseif($lastpage > 5 + ($stages * 2))	// Enough pages to hide a few?
		{
			// Beginning only hide later pages
			if($page < 1 + ($stages * 2))		
			{
				for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter & currency=$counterCurrency  & customerTotal= $customerTotal'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1 & currency=$counterCurrency  & customerTotal= $customerTotal'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage & currency=$counterCurrency  & customerTotal= $customerTotal''>$lastpage</a>";		
			}
			// Middle hide some front and some back
			elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
			{
				$paginate.= "<a href='$targetpage?page=1 & currency=$counterCurrency  & customerTotal= $customerTotal'>1</a>";
				$paginate.= "<a href='$targetpage?page=2 & currency=$counterCurrency  & customerTotal= $customerTotal'>2</a>";
				$paginate.= "...";
				for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter & currency=$counterCurrency  & customerTotal= $customerTotal'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1 & currency=$counterCurrency  & customerTotal= $customerTotal'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage & currency=$counterCurrency  & customerTotal= $customerTotal'>$lastpage</a>";		
			}
			// End only hide early pages
			else
			{
				$paginate.= "<a href='$targetpage?page=1 & currency=$counterCurrency  & customerTotal= $customerTotal'>1</a>";
				$paginate.= "<a href='$targetpage?page=2 & currency=$counterCurrency  & customerTotal= $customerTotal'>2</a>";
				$paginate.= "...";
				for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter & currency=$counterCurrency  & customerTotal= $customerTotal'>$counter</a>";}					
				}
			}
		}
					
				// Next
		if ($page < $counter - 1){ 
			$paginate.= "<a href='$targetpage?page=$next & currency=$counterCurrency  & customerTotal= $customerTotal'>بعدی</a>";
		}else{
			$paginate.= "<span class='disabled'>بعدی</span>";
			}
			
		$paginate.= "</div>";		
	
	
}
 
 // pagination
 echo $paginate; 
   echo "<br>";
    $pageNumber=$_GET['page'];
   if($pageNumber==""){
       $pageNumber="1";
      
      }
     else{

           $pageNumber;
    }	 
 

?>
</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>  
 
     