<?php
session_start();
ob_start();
$father = $_SESSION["user_id"];
if(!isset($_SESSION["user_id"])){header("location:../logout.php");}
	include "../actions/dbPDO.php";
	include "../op/box.php";
	if(isset($_REQUEST["dd"])){ $myday = $_REQUEST["dd"];}
	$first_day = date('Y-m-01', strtotime($myday));
	$last_day 	= date('Y-m-t', strtotime($myday));
	// $mms  = DateTime::createFromFormat( 'm-Y', $myday );
	$mmm = new DateTime($myday);
	$mms =  $mmm->format("m Y");
						?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
      	<title>جدول ماليات الشهر</title>
         <link rel="stylesheet" href="../dist/css/bootstrap.css"/>
      	 <link rel="stylesheet" href="../dist/css/day.css"media="print"/>
	 </head>
    <body onload="javascript: window.print(); setTimeout(window.close, 1000);" >
			<div class="container-fluid">
				<div class="form-row">
					<div class="col-9">
						<h6 style="font-weight:bold;font-size:10pt;" > جدول ماليات شهر <?php echo $mms ;?></h6>
					</div>
					<div class="col-3" style="float:left;">
							<p style="font-size:8pt;float:left;" ><?php echo date("Y-m-d"); ?></p>
			   </div>
			 </div>
				<div class="form-row">
							<div class="col">
	 								<table class="table table-bordered">
	 										<thead>
	 													 <tr>
	 																<th class="text-center" width="14%">التاريخ</th>
	 																<th class="text-center" width="10%">تحويل الراجحي</th>
																	<th class="text-center" width="10%">تحويل الأهلي</th>
	 																<th class="text-center" width="10%">نقاط بيع</th>
																	<th class="text-center" width="12%">ايداع كاش</th>
	 																<th class="text-center" width="12%">إجمالي</th>
	 																<th class="text-center" width="12%">فواتير</th>
																	<th class="text-center" width="20%">ملاحظات</th>
	 													 </tr>
	 												 </thead>
	 													 <tbody id="tstandby">
	 					<?php
	 							$output = ''; $gt =0; $out = 0; $tot_n2 = 0; $tot_n3 = 0; $cash = 0; $tot_n5 =0 ;
								while($first_day <= $last_day){
									 $month =  modey_schedule($first_day) ;
	 									       $output .= '<tr>
	 																				<td>' . $first_day . '</td>
	 																				<td>' . $month['n2'] . '</td>
																					<td>' . $month['n5'] . '</td>
	 																				<td>' . $month['n3'] . '</td>
																					<td>' . $month['box_cash'] . '</td>
	 																				<td>' . $month['tot'] . '</td>
																					<td>' . $month['box_out'] . '</td>
																					<td></td>
	 																		</tr>  '; $gt = $gt + $month['tot'] ; $out = $out + $month['box_out'] ;
				 $tot_n2 = $tot_n2 + $month['n2'] ; $tot_n3 = $tot_n3 + $month['n3']; $cash = $cash + $month['box_cash'];
				 $tot_n5 = $tot_n5 + $month['n5'];
																			$first_day = date('Y-m-d', strtotime($first_day. ' + 1 days'));
	 																		}
																		$sam =	$out + $gt ;
														$output .= '<tr><td colspan="7"></td></tr>
														<tr>
																					<td>إجمالي</td>
																					<td>'.$tot_n2.'</td>
																					<td>'.$tot_n5.'</td>
																					<td>'.$tot_n3.'</td>
																					<td>'.$cash.'</td>
	 																				<td>'.$gt.'</td>
																					<td>'.$out.'</td>
																					<td>'.$sam.'</td>
	 																			</tr>';
	 															 echo $output;
	 															 ?>
	 													 </tbody>
	 												 <tfoot></tfoot>
	 											 </table>
										</div>
							</div> <!-- end of table row -->
				</div><!-- main fluied container -->
				<script src="../js/jquery.js"></script>
				<script src="../dist/js/umd/popper.min.js"></script>
			 <script src="../dist/js/bootstrap.js"></script>
    </body>
</html>
