<?php
 session_start();
    
   include("../pdate.php");
   include("db.php");
   
   $transactCurrency=$_POST['currency'];
   $startDate="1397-01-01";
   $endDate=pdate("Y-m-d");
   //===================currency Name====================
   $currencyName_sql="select * from currencies where id='$transactCurrency'";
   $currencyName_query= $db ->query($currencyName_sql);
   $currencyName_row=$currencyName_query ->fetch_array();
   $currencyName=$currencyName_row['name'];
   
   
   //===================currency Name====================
    
 
?>
<!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" /> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/print.css" /> 
<!-- ===================ÇíÌÇÏ íÇã ÈÑÇí æíÑÇíÔ ÝÇíá====================================-->
   
  
<!--======================= ÇíÇä  ============================================================-->
 <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/DroidNaskh-Regular.ttf'); /* IE */
      src: local('DroidNaskh-Regular'), url('../font/DroidNaskh-Regular.ttf') format('truetype'); /* non-IE */
      font-weight:normal;
}
.font{
    color: #000;
    font-family: 'hekmat';  

}
@font-face {
	  font-family: 'text';
	  src: url('../font/Far_TitrBd.ttf'); /* IE */
      src: local('Far_TitrBd'), url('../font/Far_TitrBd.ttf') format('truetype'); /* non-IE */
      font-weight:normal;
}
.text{
    color: #000;
    font-family: 'text';  
	font-size: 20px;

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

}
@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"><h3><?php  include("../info/companyName.php"); ?></h3> نقل و انتقالات پولی&nbsp( <?php echo $currencyName.')';
			    
				echo "<br><span style='color:green'></span>".$pdate1."</td>";
				 
			  
			  
			  ?>
			
			<th style="width:186px;text-align:left;height: 40px" > </th>
			 
		</tr>
		</table> 

 <div id='content' style="border: 0px solid red;width: 800px;margin: auto">
  
   
   
	  
			 <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;" dir="rtl" ><a href="openingBalance.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
			       <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font"> حساب افتتاحیه</a></td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class="adad">
					     <?php
						 			  //dollar recive
							$openingBalance_sql="SELECT sum(amount) FROM `assetopeningbalance` where  currencyUnit='$transactCurrency' "; 
							$openingBalance_query= $db ->query($openingBalance_sql);
							$openingBalance_row=$openingBalance_query ->fetch_array();
						    $openingBalance=$openingBalance_row['sum(amount)'];
						    echo $openingBalance_showing=number_format($openingBalance);
						      
						 ?>
					  
					  
					  
					  </td>
			       </tr>
				   </table>
				   </a>
			 </div> 
			 <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px" dir="rtl" >
			 <a href="operation_customerTransaction.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
			       <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font">رسیـــد مشتــریان</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class="adad">
					     <?php
						 			  //dollar recive
							$dollar_recive_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='1'  and transactCurrency='$transactCurrency' and (date between '$startDate' and '$endDate')"; 
							$dollar_recive_query= $db ->query($dollar_recive_sql);
							$dollar_recive_row=$dollar_recive_query ->fetch_array();
							$dollar_recive=$dollar_recive_row['sum(amount)'];
							echo $showing_dollar_recive=number_format($dollar_recive);
						
						 ?>
					  
					  
					  
					  </td>
			       </tr>
				   </table></a>
			 </div> 
			 
			 
			 <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px" dir="rtl">
			 <a href="operation_karidPoli.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
			       <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font">خریداریهای پولی</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class='adad'>
					     <?php
						 	//خریداری های دلار	
							$dollarBuy_sql="select sum(counterAmount) from transaction where counterCurrency='$transactCurrency' and  (date between '$startDate' and '$endDate') and remove='0' and treatment='1' and extra='0'";
							$dollarBuy_query=$db ->query($dollarBuy_sql);
							$dollarBuy_row=$dollarBuy_query ->fetch_array();
							$dollarBuy=$dollarBuy_row['sum(counterAmount)'];
							echo $showing_dollarBuy=number_format($dollarBuy);
											
						 ?>
					  </td>
			       </tr>
				   </table></a>
			 </div>
			 
			 <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px" dir="rtl">
			       <a href="operation_increase_from_other.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
				   <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font">امدن از فروش سایر پولها</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class='adad'>
					     <?php
						 	  //اضافه شدن از فروش سایر پولها به افغانی
							$ezafe_dollar_azfrosh_sql="select sum(baseAmount) from transaction where baseCurrency='$transactCurrency' and (date between '$startDate' and '$endDate') and remove='0' and treatment='2' and extra='0'  ";
							$ezafe_dollar_azfrosh_query=$db ->query($ezafe_dollar_azfrosh_sql);
							$ezafe_dollar_azfrosh_row=$ezafe_dollar_azfrosh_query ->fetch_array();
							$ezafe_dollar_azfrosh=$ezafe_dollar_azfrosh_row['sum(baseAmount)'];		
							echo $showing_ezafe_dollar_azfrosh=number_format($ezafe_dollar_azfrosh);		
														
						 ?>
					  </td>
			       </tr>
				   </table></a>
			 </div>
			 
			  <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px;border-bottom:0" dir="rtl">
			       <a href="operation_otherIncome.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
				   <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font">اضافه شدن از درامدهای متفرقه</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class='adad'>
					     <?php
						 	$totalIncome_dollar_sql="select sum(amount) from others where currencyId='$transactCurrency' and  typeOthers='2' and (date between '$startDate' and '$endDate') and remover='0'    ";
							$totalIncome_dollar_query=$db ->query($totalIncome_dollar_sql);
							$totalIncome_dollar_row=$totalIncome_dollar_query ->fetch_array();
							$totalIncome_dollar=$totalIncome_dollar_row['sum(amount)'];	 					
							echo $showing_totalIncome_dollar=number_format($totalIncome_dollar);	 					
						 ?>
					  </td>
			       </tr>
				   </table></a>
			  </div>
			  
			  
			  <div style="border: 2px solid #000;width: 800px;margin: auto;height: 50px;" dir="rtl">
			       <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="text">مجموع آمدهای <?php echo $currencyName   ?></td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class="text">
					     <?php
						 	  echo number_format($reciveMoney=$totalIncome_dollar+$ezafe_dollar_azfrosh+$dollarBuy+$dollar_recive+$openingBalance);			
						 ?>
					  </td>
			       </tr>
				   </table>
			  </div>
			  
			  
			  
			  
			  
		<!---==================================================================================================================-->	 
		<!---==================================================================================================================-->	 
		<!---==================================================================================================================-->	 
			  <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px" dir="rtl">
			       <a href="operation_customerBordegi.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
				   <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font">بردگی مشتریان</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class='adad'>
					     <?php
							//dollar payment
							$dollar_payment_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='2'  and transactCurrency='$transactCurrency' and (date between '$startDate' and '$endDate')"; 
							$dollar_payment_query= $db ->query($dollar_payment_sql);
							$dollar_payment_row=$dollar_payment_query ->fetch_array();
							$dollar_payment=$dollar_payment_row['sum(amount)'];
						    echo $showingdollar_payment=number_format($dollar_payment);
						 ?>
					  </td>
			       </tr>
				   </table></a>
			  </div>
			 
			   <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px" dir="rtl">
			       <a href="operation_tabdilattPoli.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
				   <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font">تبدیل پولی</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class='adad'>
					     <?php
							  
							//خریداری از دلار وکم شدن از دلار
								$dollar_Sales_sql="select sum(baseAmount) from transaction where baseCurrency='$transactCurrency' and (date between '$startDate' and '$endDate') and remove='0'  and extra='0' and treatment='1' ";
								$dollar_Sales_query=$db ->query($dollar_Sales_sql);
								$dollar_Sales_row=$dollar_Sales_query ->fetch_array();
								$dollar_Sales=$dollar_Sales_row['sum(baseAmount)'];
								echo $showing_dollar_Sales=number_format($dollar_Sales);
						 ?>
					  </td>
			       </tr>
				   </table>
			  </div>
			 
			  
			 <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px" dir="rtl">
			      <a href="operation_foroshPoli.php?currency=<?php echo $transactCurrency; ?>" target="_blank">
			       <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="font">فروش پول</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class='adad'>
					     <?php
							  
							//فروش دلار				
							$frosh_dollar_sql="select sum(counterAmount) from transaction where counterCurrency='$transactCurrency' and (date between '$startDate' and '$endDate') and remove='0' and treatment='2' and extra='0'  ";
							$frosh_dollar_query=$db ->query($frosh_dollar_sql);
							$frosh_dollar_row=$frosh_dollar_query ->fetch_array();
							$frosh_dollar=$frosh_dollar_row['sum(counterAmount)'];
							echo $showing_frosh_dollar=number_format($frosh_dollar);
						 ?>
					  </td>
			       </tr>
				   </table></a>
			  </div>
			 
			  
			 <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px;border-bottom:0px" dir="rtl">
				<a href="operation_otherExpenses.php?currency=<?php echo $transactCurrency; ?>" target="_blank">			      
				  <table border="0" width="800px" height="50px">
				   <tr> 
				      <td style="width: 200px" class="font">مصارف</td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class='adad'>
					     <?php
							  
							 //پرداخت مصارف از دالر
							$totalExpenses_dollar_sql="select sum(amount) from others where currencyId='$transactCurrency' and  typeOthers='1' and (date between '$startDate' and '$endDate') and remover='0'    ";
							$totalExpenses_dollar_query=$db ->query($totalExpenses_dollar_sql);
							$totalExpenses_dollar_row=$totalExpenses_dollar_query ->fetch_array();
							$totalExpenses_dollar=$totalExpenses_dollar_row['sum(amount)'];	 
							echo $showing_totalExpenses_dollar=number_format($totalExpenses_dollar);	 
						 ?>
					  </td>
			       </tr>
				   </table></a>
			  </div>
			 
			   <div style="border: 2px solid #000;width: 800px;margin: auto;height: 50px;" dir="rtl">
			       <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="text">مجموع رفت های <?php  echo $currencyName;  ?></td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class="text">
					     <?php
							   echo $outingMoney=$totalExpenses_dollar+$frosh_dollar+$dollar_Sales+$dollar_payment;
	
							  
						 ?>
					  </td>
			       </tr>
				   </table>
			  </div>
			 
			  
			 
	           <div style="border: 1px solid #000;width: 800px;margin: auto;height: 50px;border-top: 0px" dir="rtl">
			       <table border="0" width="800px" height="50px">
				   <tr>
				      <td style="width: 200px" class="text">موجودی فعلی <?php  echo $currencyName;  ?></td>
				      <td style="width: 200px"></td>
				      <td style="width: 200px;text-align: center" class="text">
					     <?php
							  
							 echo $reciveMoney-$outingMoney;
						 ?>
					  </td>
			       </tr>
				   </table>
			  </div>
			 
			  
			 
	          
					 
 
  
</div>
</div>  
 </body>
 </form>
 </html>  
  
 
     