<?php
session_start();
ob_start();
$father = $_SESSION["user_id"];
if(!isset($_SESSION["user_id"])){header("location:../logout.php");}
	include "../actions/dbPDO.php";
	if(isset($_REQUEST["dd"])){ $myday = $_REQUEST["dd"];	}
	$myday = date('Y-m-d ', strtotime($myday.' + 30 days'));
	// $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="../css/day.css"media="print"/>
				 <script src="../js/jquery.js"></script>
				 <script src="../dist/js/umd/popper.min.js"></script>
			 	<script src="../dist/js/bootstrap.js"></script>
	 </head>
    <body onload="javascript: window.print(); setTimeout(window.close, 1000);" >
			<div class="container">
						<h6 style="font-weight:bold;font-size:10pt;" > حصر الإستمارات المنتهية حتي تاريخ <?php echo $mms ;?></h6>
								<div class="row" style="padding:0 ;">
									<div class="col-xs-12"style="float:right;">
	 											<table class="table table-bordered">
	 												<thead>
	 													 <tr>
															 		<th class="text-center" width="6%">م</th>
	 																<th class="text-center" width="12%">الماركة</th>
	 																<th class="text-center" width="12%">الطراز</th>
	 																<th class="text-center" width="14%">لوحة رقم</th>
	 																<th class="text-center" width="7%">موديل</th>
	 																<th class="text-center" width="37%">المالك</th>
	 																<th class="text-center" width="12%">نهاية الرخصة</th>
	 													 </tr>
	 												 </thead>
	 													 <tbody id="tstandby">
	 					<?php
	 							$output = '';
	 						$sql =$db->prepare("SELECT cars.brand , cars.kind , concat(cars.letters,' ' ,cars.numbers) as PL , cars.model , cars.lic_expire , supplycomp.supp_name
							from cars , supplycomp where cars.woner = supplycomp.supp_id AND cars.lic_expire < ? ");
	 															$sql->bindParam(1,$myday);
	 															 $sql->execute();
	 																if($sql->rowCount()>0)
	 															 { $ss = 1 ;
	 																	while($row = $sql->fetch())
	 																		{
	 																				 $output .= '<tr>
																					 					<td>' . $ss . '</td>
	 																									 <td>' . $row['brand'] . '</td>
	 																									 <td>' . $row['kind'] . '</td>
	 																									 <td>' . $row['PL'] . '</td>
	 																									 <td class="text-center" >' . $row['model'] . '</td>
	 																									 <td>' . $row['supp_name'] . '</td>
																										 <td>' . $row['lic_expire'] . '</td>
	 																								</tr>  '; $ss = $ss + 1 ;
	 																		}
	 															 }
	 															 else
	 															 {
	 																		$output .= '<tr>
	 																												<td colspan="7">لا يوجد سجلات ...</td>
	 																									 </tr>';
	 															 }
	 															 echo $output;
	 															 ?>
	 													 </tbody>
	 												 <tfoot></tfoot>
	 											 </table>
										</div>
							</div> <!-- end of table row -->

				</div><!-- main fluied container -->
    </body>
</html>
