<?php
require_once __DIR__ . '/../../magic/auth.php';

$auth = bdr_require_privilege(1, '../../logout.php');
$user = $auth['user_id'];
$father = $auth['user_id'];
$branch = $auth['branch'];
$conn = $auth['conn'];
$db = $auth['conn'];

// $contt = $_REQUEST['contt'];
$contt = 100548;
$sql = $db->prepare('select * from newcontprint where contract_id = ? ');
				$sql->bindParam(1,$contt);
				$sql->execute();
			  if($sql->rowCount()>0){$result = $sql->fetch(PDO::FETCH_ASSOC);
					$father = $result['father'];
					$branch = $result['branch'];}
	 ?>
<!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="../../css/bootstrap.css"/>
         <!-- <link rel="stylesheet" type="text/css" media="print" href="../css/print2.css"> -->
				 <link rel="stylesheet" href="../css/print2.css"/>
				 <script src="../../js/jquery.js"></script>
			 	<!-- <script src="../js/jquery.autocomplete.js"></script> -->
			 	<script src="../../js/bootstrap.js"></script>
			 	<script src="../../hj2/jquery.plugin.js"></script>
			 	<script src="../../hj2/jquery.calendars.js"></script>
			 	<script src="../../hj2/jquery.calendars.plus.js"></script>
			 	<script src="../../hj2/jquery.calendars.picker.js"></script>
			 	<script src="../../hj2/jquery.calendars.ummalqura.js"></script>
    </head>
		<!-- onLoad="javscript:window.close( window.print() )" -->
    <body>
			<div class="container-fluid">
			<div class="row" style="padding:0 ;">
							<br style="line-height:70px;"/>
			</div>
			<div class="row " style="padding:0 ;">
						<input type="hidden" id="idxp_s"  value ="<?php echo $result['id_Expire']; ?>" />
						<input type="hidden" id="licxp_s"  value ="<?php echo $result['lic_expire']; ?>" />
						<input type="hidden" class="form-control" id="freekilo" name="freekilo" />
							<div class="col-xs-5"style="float:right;padding:2px;">
								<input type="text" class="form-control text-center" value="<?php echo $result['cust_name'];?>"/>
							</div>
							<div class="col-xs-2"style="padding:2; float:left;">
									<input type="text" class="form-control text-left" value="<?php echo $result['used_area']; ?>"/>
							</div>
							<div class="col-xs-3"style="padding:0; float:left;">
									<input type="text" class="form-control text-center" value="<?php echo $result['rent_days']; ?>"/>
							</div>
					</div>
				<div class="row " style="padding:0 ;">
							<div class="col-xs-2"style="float:right;">
								<input type="text" style="font-size:9pt;" class="form-control text-left" value="رقم الهوية"/>
							</div>
							<div class="col-xs-3" style="float:right;"></div>
							<div class="col-xs-4"style="padding:0; float:right;padding-left:20px;">
									<input type="text" class="form-control text-left"value="<?php echo $result['kind']; ?>"/>
								</div>
							<div class="col-xs-2"style="padding:2; float:left;padding-left:15px;">
										<input type="text" class="form-control text-left" value="<?php echo $result['day_cost']; ?>"/>
							</div>
					</div>
					<div class="row " style="padding:0 ;">
								<div class="col-xs-2"style="float:right;padding:0px;">
									<input type="text" class="form-control text-left" value="<?php echo $result['idSA']; ?>"/>
								</div>
								<div class="col-xs-2"style="float:right;padding-left:3px;">
									<input type="text" id="idxp" style="padding:0px;font-size:9pt;" class="form-control text-left"/>
								</div>
								<div class="col-xs-1"style="padding:0; float:right;">
										<input type="text"style="padding:0px;font-size:9pt;"  class="form-control text-right" value="<?php echo $result['id_From']; ?>"/>
									</div>
									<div class="col-xs-1"style="padding:0; float:right;">
												<input type="text" class="form-control text-right" style="padding:0px;font-size:9pt;" value="<?php echo $result['nation']; ?>"/>
								</div>
									<div class="col-xs-2"style="padding:2; float:left;padding-left:15px;">
											<input type="text" class="form-control text-left" value="<?php echo $result['free_kilo']; ?>"/>
									</div>
									<div class="col-xs-3"style="padding:2; float:left;">
											<input type="text" class="form-control text-right" value="<?php echo $result['plate']; ?>"/>
									</div>
						</div>
						<!-- // -->
						<div class="row " style="padding:0 ;">
									<div class="col-xs-5"style="float:right;padding:2px;">
									</div>
									<div class="col-xs-4"style="padding:0; float:right;padding-left:20px;">
											<input type="text" class="form-control text-left" value="<?php echo $result['color']; ?>"/>
										</div>
									<div class="col-xs-2"style="padding:2; float:left;padding-left:15px;">
												<input type="text" class="form-control text-left" value="<?php echo $result['hour_cost']; ?>"/>
									</div>
							</div>
							<div class="row " style="padding:0 ;">
										<div class="col-xs-2"style="float:right;padding:0px;padding-right:15px;">
											<input type="text" class="form-control text-left" value="<?php echo $result['license']; ?>"/>
										</div>
										<div class="col-xs-2"style="float:right;padding:0px;">
											<input type="text" id="licxp" class="form-control text-left"/>
										</div>
										<div class="col-xs-1"style="padding:2; float:right;">
												<input type="text"style="padding:0px;font-size:9pt;"class="form-control text-left" value="<?php echo $result['lic_from']; ?>"/>
											</div>
											<div class="col-xs-2"style="padding:0; float:right;">
														<input type="text" class="form-control text-right" style="padding:0px;font-size:9pt;" value="خصوصي"/>
										</div>
											<div class="col-xs-2"style="padding:2; float:left;padding-left:15px;">
													<input type="text" class="form-control text-left" value="<?php echo $result['kilo_cost']; ?>"/>
											</div>
											<div class="col-xs-2"style="padding:2; float:left;padding-left:30px;">
													<input type="text" class="form-control text-right" value="<?php echo $result['model']; ?>"/>
											</div>
								</div>
								<div class="row " style="padding:0 ;">
											<div class="col-xs-4"style="float:right;padding:2px;">
											</div>
											<div class="col-xs-5"style="padding:0; float:left;">
													<input type="text" class="form-control text-right" value="<?php echo $result['date_out']; ?>"/>
												</div>
											<div class="col-xs-2"style="padding:2; float:left;">
											</div>
									</div>
									<div class="row " style="padding:0 ;">
												<div class="col-xs-4"style="float:right;padding:2px;">
												</div>
												<div class="col-xs-5"style="padding:0; float:left;">
														<input type="text" class="form-control text-right" value="<?php echo $result['time_out']; ?>"/>
												</div>
												<div class="col-xs-2"style="padding:2; float:left;">
												</div>
										</div>
						<?php
										$phone9 			= "";
										$cust_name9		= "";
										$lic_from9		= "";
										$lic_expire9	= "";
										$license9			= "";
										$address9			= "";
										$cust_id2 = $result['cust_id2'];
										if($cust_id2 > 0){
											$dd2 = $db->prepare('select cust_name , phone ,license , lic_from ,lic_expire , address from customers where cust_id = ? ');
											$dd2->bindParam(1,$cust_id2);
											$dd2->execute();
											if($dd2->rowCount()>0){$ddy = $dd2->fetch(PDO::FETCH_ASSOC);
												$phone9 			=  $ddy['phone'];
												$cust_name9		= $ddy['cust_name'];
												$lic_from9		= $ddy['lic_from'];
												$lic_expire9	= $ddy['lic_expire'];
												$license9			= $ddy['license'];
												$address9			= $ddy['address'];
										}
									}
										 ?>
						<div class="row " style="padding:0 ;">
									<div class="col-xs-4"style="float:right;padding:2px;">
										<input type="hidden" id="licxp_s2"  value ="<?php echo $lic_expire9; ?>" />
										<input type="text" class="form-control text-center" value="<?php echo $cust_name9	;?>"/>
									</div>
									<div class="col-xs-5"style="padding:0; float:left;">
										<input type="text" class="form-control text-right" value="<?php echo $result['km_out']; ?>"/>
									</div>
									<div class="col-xs-2"style="padding:2; float:left;">
									</div>
						</div>
						<div class="row " style="padding:0 ;">
									<br />
							</div>
							<div class="row " style="padding:0 ;">
										<div class="col-xs-2"style="float:right;padding:0px;">
											<input type="text" class="form-control text-left" value="<?php echo $license9 ?>"/>
										</div>
									<div class="col-xs-2"style="float:right;padding:0px;">
											<input type="text" id="licxp2" class="form-control text-left"/>
										</div>
										<div class="col-xs-1"style="padding:2; float:right;">
												<input type="text"style="padding:0px;font-size:9pt;"  class="form-control text-left" value="<?php echo $lic_from9; ?>"/>
											</div>
											<div class="col-xs-2"style="padding:0; float:right;">
														<input type="text" class="form-control text-right" style="padding:0px;font-size:9pt;" value="خصوصي"/>
										</div>
											<div class="col-xs-2"style="padding:2; float:left;">
											</div>
											<div class="col-xs-2"style="padding:2; float:left;">
											</div>
								</div>
						<div class="row " style="padding:0 ;">
									<div class="col-xs-5"style="float:right;padding:2px;">
										<input type="text" class="form-control text-center"  style="font-size:9pt;" value="<?php echo $result['working_woner']; ?>"/>
									</div>
									<div class="col-xs-4"style="padding:0; float:right;">
									</div>
									<div class="col-xs-2"style="padding:2; float:left;">
									</div>
						</div>
						<div class="row " style="padding:0 ;">
									<div class="col-xs-3"style="float:right;padding:2px;padding-right:20px;">
										<input type="text" class="form-control text-center" value="<?php echo $result['phone'];?>"/>
									</div>
									<div class="col-xs-2"style="padding:0; float:right;">
										<input type="text" class="form-control text-left" value="<?php echo $result['phone2']; ?>"/>
									</div>
									<div class="col-xs-6"style="padding:2; float:left;">
									</div>
						</div>
						<div class="row " style="padding:0 ;">
									<div class="col-xs-5"style="float:right;padding:2px;padding-right:15px;">
										<input type="text" class="form-control text-center" style="font-size:9pt;" value="<?php echo $result['address']; ?>"/>
									</div>
									<div class="col-xs-4"style="padding:0; float:right;">
									</div>
									<div class="col-xs-2"style="padding:2; float:left;">
									</div>
						</div>
						<div class="row" style="padding:0 ;">
										<br style="line-height:40px;"/>
						</div>
					<?php
					$ff = $db->prepare('SELECT realName , (SELECT b_name from branches WHERE branchID = ?) as branch FROM users WHERE user_Id = ?');
					$ff->bindParam(1,$branch);
					$ff->bindParam(2,$father);
					$ff->execute();
					if($ff->rowCount()>0){$kk = $ff->fetch(PDO::FETCH_ASSOC);
						$bbr 		= $kk['branch'];	$user = $kk['realName'];}
					 ?>
					<div class="row" style="padding:0px;">
								<div class="col-xs-2"style="padding:0; float:right;padding-right:25px;">
									<input type="text" class="form-control text-center" value=" فرع <?php echo $bbr ; ?>"/>
								</div>
								<div class="col-xs-2"style="padding:0; float:right;">
									<input type="text" class="form-control text-right" value="<?php echo $user ; ?>"/>
								</div>
					</div>
						<div class="row" style="padding:0;">
										<br style="line-height:340px;"/>
						</div>
						<?php
						include "../../op/number_text.php";
						$sql = $db->prepare('select * from sanad_in where in_id = 1119 ');
						// $sql->bindParam(1,$sanad);
						$sql->execute();
					  if($sql->rowCount()>0){$sanad = $sql->fetch(PDO::FETCH_ASSOC);}
						// return $result;
						$payy =  $sanad['payMethod'];
						switch ( $payy) {
										case "1":
										$pay =  "كاش";
											break;
										case "2":
										$pay =  "تحويل بنكي";
													break;
										case "3":
										$pay =  "نقاط بيع";
													break;
										case "4":
										$pay = "فواتير";
							break;
						}
						?>
								<div class="row" style="padding:0 ;">
										<div class="col-xs-2"style="float:right;padding-right:30px;">
											<input type="text" class="form-control text-left" value="<?php echo $sanad['in_id']; ?>"/>
										</div>
										<div class="col-xs-3"style="float:right;">
											<input type="text" class="form-control text-right" value="<?php echo $sanad['sanad_date']; ?>"/>
										</div>
										<div class="col-xs-4"style="padding:0;float:right;">
												<input type="text" style="font-weight:bold;" class="form-control text-right" value=" سند قبض"/>
											</div>
											<div class="col-xs-3"style="float:left;">
														<input type="text" class="form-control text-left" value="<?php echo $sanad['contract_id']; ?>"/>
										</div>
								</div>
								<div class="row" style="padding:0;margin-top:5px;">
										<div class="col-xs-3"style="float:right;">
											<input type="text" class="form-control text-left" style="font-weight:bold;" value="<?php echo $sanad['money_in']; ?>"/>
										</div>
										<div class="col-xs-2"style="padding:0; float:left;">
												<input type="text" class="form-control text-left" value="<?php echo $sanad['date_out']; ?>"/>
											</div>
								</div>
								<div class="row"style="padding:0 ;line-height:16px;padding-right:30px;margin-top:16px;" >
										<div class="col-xs-6"style="float:right;">
											<input type="text" class="form-control text-left" value="<?php echo $sanad['cust_name']; ?>"/>
										</div>
										<div class="col-xs-5"style="padding:0; float:left;">
												<input type="text" class="form-control text-right" value="<?php echo $sanad['comm']; ?>"/>
											</div>
								</div>
								<div class="row"style="padding:0 ;line-height:16px;" >
										<div class="col-xs-8"style="padding:2; float:right;padding-right:70px;">
												<input type="text" class="form-control text-right"  style="margin-right:10px;font-size:9pt;line-height:15px;" value=" <?php echo samTXT($sanad['money_in']) ?> لا غير "/>
											</div>
										<div class="col-xs-3"style="float:right;">
													<input type="text" class="form-control text-left" style="font-weight:bold;line-height:15px;" value="<?php echo $pay ; ?>"/>
										</div>
								</div>
								<div class="row" style="padding:0 ;">
										<div class="col-xs-12">
											<input type="text" style="font-size:8pt;line-height:15px;"class="form-control text-center" value="دفعة إيجار سيارة <?php
											 echo $sanad['kind']. " لوحة رقم " . $sanad['letters']. " ".$sanad['numbers']. " موديل ".$sanad['model'] ;
											 ?>"/>
										</div>
								</div>
							<div class="row" style="padding:0 ;">
										<div class="col-xs-3"style="float:right;">
											<input type="text" class="form-control text-left" style="font-size:9pt;line-height:15px;"value="<?php echo $sanad['realName']; ?>"/>
										</div>
										<div class="col-xs-6"style="padding:0; float:right;">
												<input type="text" style="font-size:7pt;line-height:12px;" class="form-control text-center" value="<?php echo $sanad['b_name']; ?>"/>
											</div>
								</div>
</div>
					<script>
					// $(document).ready(function(){

					function convertDates(name,ss,dest) {
					var date = $('#' + ss).val().split('-');
					var year = parseInt(date[0], 10);
					if(name == 'ummalqura'){
					  if (year > 1800){ return false ;}
					} else if (name == 'gregorian') {
					  if (year < 1800){ return false ;}
					}
					var month = parseInt(date[1], 10);

					var day = parseInt(date[2], 10);
					try {var jd = $.calendars.instance(name).newDate(year,month,day).toJD();}
					catch (e) {alert(e);		return;	}
					name == 'ummalqura'?showDate('gregorian', jd,dest):showDate('ummalqura', jd,dest);
					      }
					function showDate(name, jd,dest) {
					try {
					  $('#' + dest).val('');
					  var date = $.calendars.instance(name).fromJD(jd);
					  $('#' + dest).val(date.formatYear()+'/'+date.month()+'/'+date.day());
					}
					catch (e) { alert(e); return null; }
					}

					var tt = $('#idxp_s').val();
						if(tt.length != 0 ){convertDates('gregorian','idxp_s','idxp');}
						var dd = $('#licxp_s').val();
							if(dd.length != 0 ){convertDates('gregorian','licxp_s','licxp');}

							var ss = $("#licxp_s2").val() ;
								if(ss.length != 0 ){convertDates('gregorian','licxp_s2','licxp2');}
					</script>
    </body>
</html>
