<?php
session_start();
include("pdate.php");
 $other_date=pdate("Y-m-d");
 
  

?>
 <!DOCTYPE html>
<html>
	<head>
	<link href="css/fontstyle.css" rel="stylesheet" type="text/css"/>	 
	<title>تــراز نـــامــه</title>
	</head>
	<body>
	 <!--<form method="post" action="">
		<table border="0" align="center"  dir="rtl">
			<tr>
				<th>تــاریخ:</td>
				<td style="direction:ltr"><input type="text" class='font' name="date" value=' <?php   echo  $pdate = pdate("Y/n/j");   ?>'>
				<td><input type="submit" name="submit" class='font' value=" جستـجــــوی ">
			</tr>
		</table>
	</form>-->
	
		<?php
		
		include("payable_Receivable_Account.php");
		//$sum_accountReceivable=$_SESSION['sum_accountReceivable'];
		 
		//$sum_accountPayable=-$_SESSION['sum_accountPayable'];
		
		//if($_POST['submit']){ 
		 include("db.php");
	     $asset_Sql="select sum(dollarTotal) from dailyasset where date='$other_date'";
		 $asset_query=$db ->query($asset_Sql);
		 $asset_Row=$asset_query->fetch_array();
		 
		 $asset_amoun=$asset_Row['sum(dollarTotal)'];
		 
          
		 //=======================================================
		 
		  //total of customer Debit
		         $customer_debit_sql="SELECT SUM(dollarAmount) FROM customerbalance WHERE   dollarAmount<0 ";
		         $customer_debit_query= $db ->query($customer_debit_sql);
				 $customer_debit_row=$customer_debit_query ->fetch_array();
		         $customer_debit=-$customer_debit_row['SUM(dollarAmount)'];
		    //total of customer credit
			     $customer_credit_sql="SELECT SUM(dollarAmount) FROM customerbalance WHERE  dollarAmount>0 ";
		         $customer_credit_query= $db ->query($customer_credit_sql);
				 $customer_credit_row=$customer_credit_query ->fetch_array();
		         $customer_credit=$customer_credit_row['SUM(dollarAmount)'];
		     
		    $cash=$asset_amoun+(-$allDollarRecivable);
		     
			$equity=$cash-$allDollarPayable;
         //=======================================================
		 echo "<table border='1' class='fotntitle' width='700px' dir='rtl' cellpadding='0' cellspacing='0'>
		      <tr>
			      <td style='text-align: center' colspan='2' >
				   <h3 class='fotntitle'> تـــــــرازنـــــامـــه</h3>
				   <h3 class='fotntitle'>مــــورخ</h3>
				   <h3>". $date."</h3>
				  
				  </td>
			  </tr>
			 
			  <tr>
					 
			  </tr>
			  <tr>
			      <td ><span class='fotntitle'>نقــدنگیهـــا</span>
				  <ul>
				     <li  class='fotntitle'><a href='cashDetails.php?date=$date & transaction=recive' ' target='_'>مـوجـودی نقــدی</a></li>
				     <li  class='fotntitle'><a href='accountReciveable.php?date=$date & transaction=send' ' target='_'>طلبــات</a></li>
				     
				  </ul>
				  </td>
				  <td>
                   <ul>				  
				     <li class='fotntitle'><a href='cashDetails.php?date=$date & transaction=recive' target='_'>".number_format($asset_amoun,2)."</a></li>
				     <li class='fotntitle'><a href='accountReciveable.php?date=$date'  & transaction=send'target='_'>".number_format(-$allDollarRecivable,2)."</a></li>
				  </ul>
				  </td>
			  </tr>
			   
			  	  
			  <tr>
			      <td ><span class='fotntitle'>دیــون</span>
				  <ul>
				     <li class='fotntitle'><a href='accountPayable.php?date=$date & treatment=1' ' target='_'>طلبات مشتـــریــان</a></li>
				     
				    
				  </ul>
				  </td>
				  <td>
                   <ul>				  
				     <li class='fotntitle'><a href='accountPayable.php?date=$date & treatment=1' ' target='_'>".number_format($allDollarPayable,2)."</a></li>
				     
				      
				  </ul>
				  </td>
			  </tr>
			   <tr>
			      <td> 
				   <ul>
				      <li class='fotntitle'>
					      ســرمایــه شخصــی(نقدینـگی - دیــون) 
					  </li>
					</ul>
					  </td>
			      <td> 
				     <ul>
				      <li style='color: #003366;font-weight: bold'>
					      ".number_format($equity,2)."  
						 
					  </li>
					</ul>
				  
				  </td>
			  </tr ></table>";
			   
		//}	  
		 
?>
</div>
 
</div>
</body>
</html>