<?php
session_start();
ob_start();
$father = $_SESSION["user_id"];
if(!isset($_SESSION["user_id"])){header("location:../logout.php");}
	include "../actions/dbPDO.php";
						?>
<!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-fluid">
				<div class="form-row">
					<div class="col-9">
						<p style="font-weight:bold;font-size:10pt;" > أقساط سيارات التأجير</p>
					</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="align-middle text-center" width="9%">م</th>
	 							<th class="align-middle text-center" width="20%">الطراز</th>
	 							<th class="align-middle text-center" width="12%">موديل</th>
								<th class="align-middle text-center" width="12%">الحروف</th>
								<th class="align-middle text-center" width="12%">القسط</th>
	 							<th class="align-middle text-center" width="35%">ملاحظات</th>
	 						</tr>
	 					</thead>
	 					<?php
	 						$output = '';
	 						$sql = $db->prepare("SELECT DISTINCT `kest`, letters, `kind` , `model` FROM `cars`
												 WHERE `model` > 2019 AND`car_job_id` = 1 AND branch > 0
												  ORDER BY kind, model , letters");
	 						$sql->execute();
	 					if($sql->rowCount()>0)
	 							    { $ss = 1 ; $sum_kest = 0 ;
	 			while($row = $sql->fetch())
	 									{
										$kest = $row['kest'] ;
	 				$output .= '<tr>
									<td>' . $ss . '</td>
	 								<td>' . $row['kind'] . '</td>
	 								<td>' . $row['model'] . '</td>
									<td>' . $row['letters'] . '</td>
									<td>' . $kest . '</td>
	 								<td></td>
	 							</tr>  ';
					 $ss = $ss + 1 ;
	 						}			
	 					}
	 					else
	 					{
	 				$output .= '<tr><td colspan="6">لا يوجد سجلات ...</td></tr>';
	 					}
				echo $output;
	 					?>
	 			</tbody>
	 		<tfoot></tfoot>
	 	</table>
		</div>
	</div> <!-- end of table row -->
	</div><!-- main fluied container -->
    </body>
</html>
