<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" href="css/incomestatement.css">
	</head>
	<body>
	<form method="post" action="">
		<table border="0" align="center" dir="rtl">
			<tr>
				<th>تــاریخ:</td>
				<td style="direction:ltr"><input type="text" name="date" value=' <?php  include("pdate.php"); echo  $pdate = pdate("Y-m-d");   ?>'>
				<td><input type="submit" name="submit" value=" جستـجــــوی ">
			</tr>
		</table>
	</form>
	
		<?php
		 if($_POST['submit']){
		 $pdate = $_POST['date'];
		echo '<div id="wrap">	<div id="titel">
			<h4><h4>گزارشات کلی معاملات ر<span style="color:red;font-size: 16px"> </span></h4> </h4>
			 <h4 dir="rtl">'.$pdate.'<span dir="ltr">:تاریخ </span></h4>
			  
			  
			 <h3  > </h3>
		</div>
		<div id="content">';

	
	 
	  include('config.php');
	  
	 echo $date=$pdat;
	 echo "<table border='0' width='900px'>
			<tr>";
	 /*=================Total sale==================*/
			
		    $total=mysql_query("select sum(total) from  `sale`   where date='$pdate'");
		    while($total_row=mysql_fetch_array($total)){
		     echo  "<td>مجمـــوع فــــروشــات   روز  </td><td>";
		    echo  $total_price=number_format($total_row['sum(total)'])." AF</td></tr>";
		   
		  }  
	 /*================================================*/
	  /*=================Find Remain==================*/
	 
		   $remain=mysql_query("select sum(remain) from `remain` where date='$pdate'");
		   while($remain_row=mysql_fetch_array($remain)){
		 
		    echo  "<tr><td><span style='color: green'>مجمــــوع طلبـــات</span></td><td>"; 
		       $remain_price=$remain_row['sum(remain)']." AF</td></tr>";
			echo "<span style='color: green'>".number_format($remain_price)."<span>";
		  }    
	  /*===============================================*/

	   /*=================آوردگی طلبـات==================*/
	 
		   $reciv_payment=mysql_query("select sum(price)from   `payment` where date='$pdate' and  subject='1'");
		   while($recive_row=mysql_fetch_array($reciv_payment)){
				
				   echo "<tr><td style='width: 700px'>مجمــوع آوردگی طلبات </td><td style='width: 200px'>";
				   echo $talabat=number_format($recive_row['sum(price)'])." AF</td></tr>";
				 	 
		    }
	   /*=================پایان ==============*/
	 
	 
	  /*================= Find Pyament ==============*/
		   $pyment=mysql_query("select sum(cash)from   `payment`  where date='$pdate'");
		   while($row=mysql_fetch_array($pyment)){

				  echo "<tr><td><span style='color: #669966'>مجمــوع رسیــده نقــدی</span></td><td>";
				   $price=$row['sum(cash)']." AF</td></tr>";
				 echo "<span style='color: #669966'>".number_format($price)."<span>";
		   }
	  /*================= End of Pyament ==============*/

       /*================= Find bonus ==============*/
		   $pyment=mysql_query("select sum(bonus)from   `payment`  where date='$pdate'");
		   while($row=mysql_fetch_array($pyment)){

				  echo "<tr><td><span style='color:#669966'>مجمـــوع Bonus</span></td><td>";
				   $bonus=$row['sum(bonus)']." AF</td></tr>";
				 echo "<span style='color: #669966'>".number_format($bonus)."<span>";
		   }
	  /*================= End of Pyament ==============*/
	    /*=================پـرداختی حاصل از فــروش==================*/

		   $reciv_sale=mysql_query("select sum(price)from   `payment` where date='$pdate' and  subject='0'");
		    while($sale_row=mysql_fetch_array($reciv_sale)){

				    echo "<tr><td>مبلغ پرداختی حاصل از فروش</td><td>";
				    echo $sale= number_format($sale_row['sum(price)'])." AF</td></tr>";

		    }
	   /*=================پایان ==============*/  
		  

      
	
	
	
	 
	 
	 /*=================benefic Remain==================*/
	 
		    $benefic=mysql_query("select sum(price) from  `daily_benefic` where date='$pdate'");
		   while($benefic_row=mysql_fetch_array($benefic)){
		   echo  "<tr><td><span style='color: green'>دخل گـــذشــته</span></td><td>";
		      $benefic_price=$benefic_row['sum(price)']." AF</td></tr>";
		     echo "<span style='color: green'>".number_format($benefic_price)."<span>";
		  }
	  /*=================End Of  benefic==============*/
	 
	 

	
	 
	        $benefic_price = preg_replace('/[^\d\.-]/', '', $benefic_price);
            $price = preg_replace('/[^\d\.-]/', '', $price);
		   echo"<tr><td><span style='color: #FFF'>مجمــوع رسیـدگـی نقــدی و دخـل </span></td><td>";
		   echo number_format($benefic_price+$price)." AF</td></tr>";
		   
		   /*================= Find Consume ================*/
		   $consume=mysql_query("select sum(price) from `dail_consume` where date='$pdate'");
		    while($con_row=mysql_fetch_array($consume)){
		   
		     echo "<tr><td style='color: red'>مجمـــوع مصــارف</td><td>";
		    $consume_price=$con_row['sum(price)']." AF</td></tr>";
		    echo "<span style='color: red'>".number_format($consume_price)."<span>";
		  }   
	  /*================= =============== ==============*/
	 
		 
		    echo "<tr><td>------------------------------------------------------</td></tr>";
		 // /*  echo "مجمـــوع نقــــدینگـــی";*/
            $price = preg_replace('/[^\d\.-]/', '', $price);
            $benefic_price = preg_replace('/[^\d\.-]/', '', $benefic_price);
            $consume_price = preg_replace('/[^\d\.-]/', '', $consume_price);
		    $result=($benefic_price+$price)-$consume_price;
	   

	     echo"<tr><td style='color:#99CC00'>مــوجـــودی نقـــدی کنـــونــی شمــا </td><td style='color: #99CC00'>".number_format($result)." AF</td></tr></table>";

?>
</div>
<?php } ?>
</div>
</body>
</html>