<?php 
include('include/auth.php');
//$fid=$_GET['id'];
$car=$_GET['car'];
$sp=$_GET['sp'];
$datechanged=$_GET['d'];
$vehchanged=$_GET['v'];
$pagerole="user";
include('include/head.php');
if (isset($_GET['id'])  && $_GET['id']!='0') {
    $fid=$_GET['id'];
    $sql = $db2->query("SELECT * FROM jostj_vikrentcar_orders WHERE jostj_vikrentcar_orders.id='$fid' ") or die(mysql_error());
$row = mysqli_fetch_array( $sql );
}
else {
    $fid2=$_GET['webid'];
    $sql = $db2->query("SELECT * FROM jostj_vikrentcar_orders WHERE jostj_vikrentcar_orders.webid='$fid2' ") or die(mysql_error());
$row = mysqli_fetch_array( $sql );
$fid=$row['id'];
}
$idcar=$row["idcar"];
$idplace=$row["idplace"];
$idreturnplace =$row["idreturnplace"];
$hour     = abs((int)$row['consegna'] - (int)$row['ritiro']) / 3600;
$disfunct = "disabled";

// --- Base times (ints)
$base_pick_ts = (int)$row['ritiro'];
$base_drop_ts = (int)$row['consegna'];

// If it's a contract, load contract row and prefer cont_return for drop.
$rowcont = null;
$licnum = null;
$chnum  = null;

if ($row['status'] === 'contract') {
    $sqlcont = $db2->query("SELECT * FROM contracts WHERE contracts.Res_ref='$fid' ") or die($db2->error);
    $rowcont = mysqli_fetch_array($sqlcont);

    if ($rowcont) {
        $licnum = $rowcont['vehfleet_id'];
        $chnum  = $rowcont['contract_id'];

        if ((int)$rowcont['cont_return'] > 0) {
            $base_drop_ts = (int)$rowcont['cont_return'];
        }
    }
}

// --- Apply +2h for source 1006 (contract or not), but no "*" in contract print
$pickdet = '';
$dropdet = '';

if ((int)$row['source'] === 1006) {
    $adj_pick_ts = strtotime('+2 hours', $base_pick_ts);
    $adj_drop_ts = strtotime('+2 hours', $base_drop_ts);

    if ($adj_pick_ts !== false) $base_pick_ts = $adj_pick_ts;
    if ($adj_drop_ts !== false) $base_drop_ts = $adj_drop_ts;

    $pickdet = 'Time Auto Adjusted. Original time was: ' . date('H:i', (int)$row['ritiro']);

    $orig_drop_ts = ($rowcont && (int)$rowcont['cont_return'] > 0)
        ? (int)$rowcont['cont_return']
        : (int)$row['consegna'];
    $dropdet = 'Time Auto Adjusted. Original time was: ' . date('H:i', $orig_drop_ts);
}

// --- Final formatted strings (no *)
$picktime = date('d-m-Y H:i', $base_pick_ts);
$droptime = date('d-m-Y H:i', $base_drop_ts);
if (is_null($row['totpaid']) || $row['totpaid']==0.00) {
$resttopay=$row['order_total'];
}
else{
   if(is_null($row['cust_cost']) || $row['cust_cost']==0.00){
       $resttopay=$row['order_total']-$row['totpaid'];
   } 
   else{
       $resttopay=$row['cust_cost'];
   }
}
$subtotal= ($row['order_total']+$row['extracosts'])/1.24;
$vat= $row['order_total']-$subtotal;
$sql2 = $db2->query("SELECT * FROM jostj_vikrentcar_cars WHERE jostj_vikrentcar_cars.id=$idcar ") or die(mysql_error());
$row2 = mysqli_fetch_array( $sql2 ); 
$sqlcar2 = $db->query("SELECT * FROM jos8r_vikrentcar_cars WHERE jos8r_vikrentcar_cars.id='$idcar'  ") or die(mysql_error());
$rowcar2 = mysqli_fetch_array( $sqlcar2 );
$idcat2=explode(';', $rowcar2['idcat']);
$vehtype2=$idcat2[0];
$carcat2=$idcat2[1];
$sqlveh2 = $db->query("SELECT * FROM jos8r_vikrentcar_categories WHERE jos8r_vikrentcar_categories.id='$vehtype2'  ") or die(mysql_error());
$rowveh2 = mysqli_fetch_array( $sqlveh2 );
$sqlcar3 = $db->query("SELECT * FROM jos8r_vikrentcar_categories WHERE jos8r_vikrentcar_categories.id='$carcat2'  ") or die(mysql_error());
$rowcar3 = mysqli_fetch_array( $sqlcar3 );
$group2=$rowveh2['name']." / ".$rowcar3['name'];

$sql3 = $db2->query("SELECT * FROM jostj_vikrentcar_places LEFT JOIN jostj_vikrentcar_stations ON jostj_vikrentcar_places.station=jostj_vikrentcar_stations.station_id WHERE jostj_vikrentcar_places.id=$idplace ");
$row3 = mysqli_fetch_array( $sql3 ); 
       
$sql4 = $db2->query("SELECT * FROM jostj_vikrentcar_places LEFT JOIN jostj_vikrentcar_stations ON jostj_vikrentcar_places.station=jostj_vikrentcar_stations.station_id WHERE jostj_vikrentcar_places.id=$idreturnplace ") or die(mysql_error());
$row4 = mysqli_fetch_array( $sql4 );

$sql55 = $db2->query("SELECT * FROM fleet LEFT JOIN jostj_vikrentcar_cars ON jostj_vikrentcar_cars.id=fleet.veh_id  WHERE fleet.fleet_id=$licnum ") or die(mysql_error());
$row55 = mysqli_fetch_array( $sql55 ); 

$sourcename=$row['source'];
$sql56 = $db2->query("SELECT * FROM jostj_vikrentcar_sources  WHERE jostj_vikrentcar_sources.id=$sourcename ") or die(mysql_error());
$row56 = mysqli_fetch_array( $sql56 ); 

$custdata=$row['custdata'];
$cust2=explode(":",$custdata); 

if($row['cd_dob']==NULL){
    $custdob=substr($cust2[2], 0, strpos($cust2[2], "Address")); // imerominia genissis
}
else{$custdob=$row['cd_dob'];}
if($row['cd_address']==NULL){
    $custaddress=substr($cust2[3], 0, strpos($cust2[3], "Zip Code")); //address
    }
    else{$custaddress=$row['cd_address'];
    }
    if($row['cd_dlnumber']==NULL){
        $custdrlic=substr($cust2[6], 0, strpos($cust2[6], "Passport Number")); //license number
        }
        else{$custdrlic=$row['cd_dlnumber'];
        }

        if($row['cd_passnum']==NULL){
            $custpass=substr($cust2[7], 0, strpos($cust2[7], "Flight Number"));// passport
            }
            else{$custpass=$row['cd_passnum'];
            }
            if($row['cd_flight']==NULL){
                $custflight=substr($cust2[8], 0, strpos($cust2[8], "Hotel Name"));// flight
                }
                else{$custflight=$row['cd_flight'];
                }
                if($row['cd_hotel']==NULL){
                    $custhotel=substr($cust2[9], 0, strpos($cust2[9], "Room")); // hotel
                    }
                    else{$custhotel=$row['cd_hotel'];
                    }
                
                    if($row['cd_hotelroom']==NULL){
                        $custroom=$cust2[10]; //hotel room
                        }
                        else{$custroom=$row['cd_hotelroom'];
                        }


?>
<html>
	<head>
		<title>WV Admin - Reservation Print</title>
		<!-- Web Fonts  -->
		<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet" type="text/css">

		<!-- Vendor CSS -->
		<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css" />

		<!-- Invoice Print Style -->
		<link rel="stylesheet" href="css/invoice-print.css" />
        <style>
<?php if($row['status']=="confirmed"){?>
.statuscl{color:green;}
<?php } elseif ($row['status']=="cancelled") {?>
    .statuscl{color:red;}
<?php } elseif ($row['status']=="standby") {?>
    .statuscl{color:orange;} <?php }
    ?>
    .noshow{display:none;}
@media print {

html,
body {
width: 40%;
height: 60%;
position: absolute;
margin: 0mm;
padding: 0mm;
}

.show {
width: 100%;
}
}
.table th, .table td {
    padding: 0rem; 
    vertical-align: top;
    border-top: 1px solid #dee2e6;
}
.table {
width: 100%;
margin-bottom: .1rem;
color: #212523;
}
.table thead th {
vertical-align: top;
font-size: 10px;
}
.invoice {
    padding: 0 15px;
}
.invoice header {
    margin-bottom: 1px;
    border-bottom: 0px solid #fff; 
}
.invoice address {
color: #7F8597;
line-height: 1rem;
}
.address {
    margin-bottom: .2rem;
    font-style: normal;
}
.contnumber{position:absolute;
top:10;
right:40;}
</style>
	</head>
<body><div class="container">


		<div class="invoice">
			<header class="clearfix">
            <div class="contnumber"><h4 class="h4 m-0 text-dark font-weight-bold">#<?php echo $rowcont['contract_num'];?> </h4></div>
				<div class="row">
                <div class="invoice">
			<header class="clearfix">
                        <div class="col-md-12">						
                            <img class="normal-logo  img-fluid" src="https://motorclub.gr/public/assets/img/motorclub-logo-dark.png" alt="MotorClub.gr" style="padding-bottom: 1rem;">
							</div>
                       
                <div class="row" style="white-space: nowrap;">
     <div class="col-sm-6">
      
						<address class="ib mr-5">
							<strong>ΣΙΓΜΑ Α.Ε. / Ξενοδ. - Τουρ. - Ναυτ. Επιχ/σειs
							<br>
							A.Φ.Μ. 094235568 - Δ.Ο.Υ. ΗΡΑΚΛΕΙΟΥ</strong>
							<br>
							Κεντρικό: Πλατεία 18 Άγγλων Αρ. 1, 71202 Ηράκλειο Κρήτης
							<br>
							Τηλ.: (+30) 2810 222408, (+30) 2810 286012, (+30) 2810 286031
							<br>
							Fax: (+30) 2810 222862, e-mail: info@motorclub.gr
							<br>
							www.motorclub.gr 
						</address>
					</div><div class="col-sm-6">
						<address class="ib mr-5">
							<strong>SIGMA S.A.
							<br>
							Tourism Trade &amp; Nautical Enterprices</strong>
							<br>
							Main office: 1, 18 Agglon Sq. 71202 Heraklion Crete
							<br>
							Tel.: (+30) 2810 222408, (+30) 2810 286012, (+30) 2810 286031
							<br>
							Fax: (+30) 2810 222862, e-mail: info@motorclub.gr
							<br>
							www.motorclub.gr 
						</address>
					</div>
</div></div>
<div class="col-sm-12" style="margin-bottom: .2rem;line-height: 15px;text-align: center;">
                        <span>ΕΝΟΙΚΙΑΣΕΙΣ ΑΥΤΟΚΙΝΗΤΩΝ<br>
						<strong>RENTAL AGREEMENT / Μισθωτήριο Συμβόλαιο</strong><br>
						ΑΠΟΔΕΙΞΗ ΠΑΡΟΧΗΣ ΥΠΗΡΕΣΙΩΝ ΑΡΘΡΟ 13 &amp; 2Κ.Β.Σ </span>
					</div>

			</header>
            
            <div class="col-md-12">
			<div class="row">
                
                    <div class="col-md-6">
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Renter's Name - Όνομα Μισθωτού</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo $row['nominative'];  ?></td>
                    </tr>
                    </tbody>
                </table>
			
			
			
           
               
                    
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Home Address - Διεύθυνση</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$custaddress.' '.$custcity.' '.$custzip.' '.$custcountry);?>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
			
			
			
            

                    
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Hotel - Ξενοδοχείο</th>
                                    <th>Room - Δωμάτιο</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$custhotel); ?>&nbsp;</td>
                        <td><?php echo str_replace('\r\n',' ',$custroom); ?>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
		
			
            
        
        
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Telephone - Τηλέφωνο</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$row['phone'] ); ?></td>
                    </tr>
                    </tbody>
                </table>
			
			
			
			

        
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>e-mail</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$row['custmail']);  ?></td>
                    </tr>
                    </tbody>
                </table>
			
			

        
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Passport No - Αριθμός Διαβατηρίου</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$custpass); ?>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
			
			

                
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Licence No - Αριθμός Διπλώματος</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$custdrlic); ?>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
	
            

                  
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Co Driver - Συνοδηγός</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$rowcont['cont_codriver']);  ?>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
		
            

             
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Passport No - Αριθμός Διαβατηρίου</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$rowcont['cont_copport']);  ?>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
		
            
                   
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Licence No - Αριθμός Διπλώματος</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$rowcont['cont_colicense']);  ?>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Τιμολόγιο Προμηθευτή ή Εταιρίας - Invoice</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo str_replace('\r\n',' ',$rowcont['cont_notes']);  ?>&nbsp;</td>
                    </tr>
                    </tbody>
                    <thead>
                    </table>
                    <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>ΕΠΩΝΥΜΙΑ:</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    </tbody>
                    <thead>
                    </thead></table>
                    <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>ΔΡΑΣΤΗΡΙΟΤΗΤΑ - ACTIVITY:</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    </tbody>
                    </table>
                <table class="table table-bordered">  
                <thead>
                        <tr>
                                    <th>ΔΙΕΥΘΥΝΣΗ - ADDRESS:</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    </tbody></table>
                <table class="table table-bordered"> 
                <thead>  
                        <tr>
                                    <th>Α.Φ.Μ. - VAT No</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
           
                <table class="table table-bordered"> 
                <thead>  
                        <tr>
                                    <th>Δ.Ο.Υ - REVENUE OFFICE</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered"> 
                <thead>  
                        <tr>
                                    <th>NOTICE / ΣΗΜΕΙΩΣΗ : EXCESS / ΑΠΑΛΛΑΓΗ - SELBSTBETEILIGUNG</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td> <?php if ($row['employee']==10) {
                                        $apsoure= $row['source'];
                                                    $sqlac = $db2->query("SELECT * FROM api_fleet WHERE api_fleet.api_fleet_partner='$apsoure' AND api_fleet.api_fleet_idcar='$idcar' ") or die(mysql_error());
                                                    $rowac = mysqli_fetch_array( $sqlac );
                                                    echo $rowac['api_fleet_acriss']." / ";  
                                                 } 
                                        if ($row['source']==16){ 
                                            $webid=$row['webid'];
                                            $sqtar = $db->query("SELECT * FROM jos8r_vikrentcar_orders LEFT JOIN jos8r_vikrentcar_dispcost ON jos8r_vikrentcar_dispcost.id=jos8r_vikrentcar_orders.idtar  WHERE jos8r_vikrentcar_orders.id='$webid'  ") or die(mysql_error());
                                            $rowtar = mysqli_fetch_array( $sqtar );
                                            $priceid=$rowtar['idprice'];
                                            $sqtar2 = $db->query("SELECT * FROM jos8r_vikrentcar_prices  WHERE jos8r_vikrentcar_prices.id='$priceid'  ") or die(mysql_error());
                                            $rowtar2 = mysqli_fetch_array( $sqtar2 );
                                            echo $rowtar2['name']." / ".$rowtar['attrdata'];
                                            
                                            } else{ 
                                                echo $row['idtar'];
                                                      }     ?></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>COLLISION DAMAGE WAIVER:<br>RENTER ACCEPTS OR DECLINES PURCHASE</th> 
                                    <th>THEFT INSURANCE:<br>RENTER ACCEPTS OR DECLINES PURCHASE<br>(Cost: 5 euro extra per day)</th>  
                                </tr>
                            </thead>
                    <tbody>
                    <tr><td style="text-align: right;"></td>
                        <td style="text-align: right;"><p>YES-ACCEPT-YA<br><span><input type="checkbox" name="brand"></span></p><p>NO-DECLINES-NEIN<br><span><input type="checkbox" name="brand"></span></p></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>VOLLCASKOVERSICHERUNG- MIKTH ΑΣΦΑΛΕΙΑ</th> 
                                    <th>RENTER ACCEPTS OR DECLINES PERSONAL ACCIDENT INSURANCE<br>INSASSEN VERSICHERUNG ΑΣΦΑΛΕΙΑ ΕΠΙΒΑΤΩΝ</th>  
                                </tr>
                            </thead>
                    <tbody>
                    <tr><td style="text-align: right;"><p>YES-ACCEPT-YA<br><span><input type="checkbox" name="brand"></span></p><p>NO-DECLINES-NEIN<br><span><input type="checkbox" name="brand"></span></p></td>
                        <td style="text-align: right;"><p>YES-ACCEPT-YA<br><span><input type="checkbox" name="brand"></span></p><p>NO-DECLINES-NEIN<br><span><input type="checkbox" name="brand"></span></p></td>
                    </tr>
                    </tbody>
                </table>
					</div>

			<div class="col-md-6">
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Model - Τύπος</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo $row55['name'];?></td>
                    </tr>
                    </tbody>
                </table>
			
			
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Licence No - Αριθμός Κυκλοφορίας</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo $row55['lic_num'];?></td>
                    </tr>
                    </tbody>
                </table>
			
			
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Agreed out Location</th>
                                    <th>Date & Time OUT - Ημερομηνία & 'Ωρα Αναχώρησης</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo $row3['name'];  ?></td>
                        <td><?php echo $picktime;  ?></td>
                    </tr>
                    </tbody>
                </table>
			

                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Agreed return Location</th>
                                    <th>Date in & Time in - Ημερομηνία Επιστροφής</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo $row4['name'];  ?></td>
                        <td><?php echo $droptime;  ?></td>
                    </tr>
                    </tbody>
                </table>
                <?php if($rowcont['cont_extended']==1){
                    
                    $sqlcext = "SELECT * FROM contract_extensions  WHERE contract_extensions.cont_ext_res=$fid";
                                                $result = mysqli_query($db2,$sqlcext);
                                                while($rowcext = mysqli_fetch_array($result)) {
$pla1=$rowcext['ext_old_return'];
$pla2=$rowcext['ext_new_rplace'];

                                                    $sql3ext = $db2->query("SELECT * FROM jostj_vikrentcar_places WHERE jostj_vikrentcar_places.id=$pla1 ");
                                                    $row3ext = mysqli_fetch_array( $sql3ext ); 
                                                           
                                                    $sql4ext = $db2->query("SELECT * FROM jostj_vikrentcar_places WHERE jostj_vikrentcar_places.id=$pla2 ") or die(mysql_error());
                                                    $row4ext = mysqli_fetch_array( $sql4ext );
                                                
                                                    
                                                    ?>
                <!--loop-->
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Extension date out</th>
                                    <th>Extension date in</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php echo date('d-m-Y H:i', $rowcext['ext_old_date']);?></td> <!--if cont_extended =0 keno allios na deikso pliroforia -->
                        <td><?php echo date('d-m-Y H:i', $rowcext['ext_new_date']);?></td> <!--if cont_extended =0 keno allios na deikso pliroforia -->
                    </tr>
                    </tbody>
                </table>
		
			<!--loop-->
            <?php } }?>
            <?php if($rowcont['cont_veh_change']==1){
                    
                    $sqlvhex = "SELECT * FROM veh_change  LEFT JOIN fleet ON fleet.fleet_id=veh_change.veh_id LEFT JOIN jostj_vikrentcar_cars ON jostj_vikrentcar_cars.id=fleet.veh_id WHERE veh_change.contract_id=$chnum";

                                                $result = mysqli_query($db2,$sqlvhex);
                                                while($rowvhex = mysqli_fetch_array($result)) {
 
                                                    ?>
            <!--loop-->
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Vehicle Replacement / Αλλαγή Οχήματος</th>
                                    <th>Date & Time of Replacement / Ημερ. & Ώρα αλλαγής</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td> <?php echo $rowvhex['name'];?> <?php echo $rowvhex['lic_num'];?>&nbsp;</td><!--pinakida-->
                        <td><?php echo date('d-m-Y H:i', $rowvhex['change_from']);?>&nbsp;</td><!-- hm/nia    change_from-->
                    </tr>
                    </tbody>
                </table>
		<!--loop-->
        <?php } }?>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>ΕΚΡΑΤΗΘΗ ΑΠΟ - RESERVED BY</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td>
                        <?php echo $row56['name'];?>
                        </td>
                    </tr>
                    </tbody> 
                </table>
			
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>KMS  / ΧΙΛΙΟΜΕΤΡΑ</th>
                                    <!--<th>KMS ΙΝ / ΧΙΛΙΟΜΕΤΡΑ ΕΠΙΣΤΡΟΦΗΣ</th>
                                    <th>TOTAL KMS / ΣΥΝΟΛΟ ΧΙΛΙΟΜΕΤΡΩΝ</th>
                                    <th>FREE</th>-->
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                       
                        <td>FREE</td>
                    </tr>
                    </tbody>
                </table>
			
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Pretax (Total)/ Σύνολο προ φόρου</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                    <?php $subcont=$rowcont['Contract_value']/1.24; ?>
                        <td><?php if($sp==1){ echo number_format($subcont, 2, '.', '')." €" ;} else{echo "</br>";}  ?> </td>
                    </tr>
                    </tbody>
                </table>
			
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Taxes - VAT / Φόροι Φ.Π.Α. 24%</th>
                                </tr>
                            </thead>
                    <tbody>
                        <?php $vatcont=$rowcont['Contract_value']-$subcont; ?>
                    <tr>
                        <td><?php if($sp==1){ echo "(".number_format($vatcont, 2, '.', '')." €)"  ;} else{echo "</br>";} ?> </td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>TOTAL / ΣΥΝΟΛΟ</th>
                                    <th>BALANCE / ΥΠΟΛΟΙΠΟ</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                    <td><?php  if($sp==1){echo number_format($rowcont['Contract_value'], 2, '.', '')." €" ;} else{echo "</br>";} ?></td>
                   <?php $contrestpay=$rowcont['Contract_value']-($rowcont['ctotal_paid']+$rowcont['deposit']);?>
                        <td><?php if($sp==1){ echo number_format($contrestpay, 2, '.', '')." €" ;} else{echo "</br>";} ?></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>DEPOSIT - ΠΡΟΚΑΤΑΒΟΛΗ</th>
                                    <th>PAID / ΕΞΩΦΛΗΘΗ</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                        <td><?php if($sp==1){echo $rowcont['deposit']." €" ;} else{echo "</br>";} ?></td>
                        <td><?php if($sp==1){echo $rowcont['ctotal_paid']." €" ;} else{echo "</br>";} ?></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>REMARKS</th>  
                                </tr>
                            </thead>
                    <tbody>
                    <tr>
                    <td style="padding-bottom: 5rem;"></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <td><strong><span style="font-size: 10px;">EXTRAS :</strong></span>         <?php
                                    if (is_null($row['optionals'])) {echo "None Selected";}
                                    else {
                            $st2=explode(';', $row['optionals']);
                        
                        
                            foreach ($st2 as $index=>$value){
                                if ($value == NULL) {
                                    break;
                                }
                        $optionalname=trim(explode(':', $value)[0]);
                        $optionalquant=trim(explode(':', $value)[1]);
                        $sqlopt = $db2->query("SELECT * FROM jostj_vikrentcar_optionals  WHERE jostj_vikrentcar_optionals.id='$optionalname'  ") or die(mysql_error());
                                            $rowopt = mysqli_fetch_array( $sqlopt );
                       if ($row['source']==16){
                        $sqlopt2 = $db->query("SELECT * FROM jos8r_vikrentcar_optionals  WHERE jos8r_vikrentcar_optionals.id='$optionalname'  ") or die(mysql_error());
                        $rowopt2 = mysqli_fetch_array( $sqlopt2 );
                        $optionalvalue=$rowopt2['cost']*$optionalquant;
                       }
                       else{
                           $optionalvalue=$rowopt['cost']*$optionalquant;
                       }                    
                       ?>
                       <span class="<?php if($optionalquant==0){echo "noshow";}?> text-dark" ><?php echo $rowopt['name'];?> X<?php echo $optionalquant;?>, </span> </p>
                   <?php }
                        }
                            ?></td>
                    </tr>
                    <tr>
                    <td><strong><span style="font-size: 10px;">FUEL GAS :</strong></span><?php echo $rowcont['cont_fuel_out'];  ?></td>
</tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                <th>ΥΠΟΓΡΑΦΗ ΣΥΝΟΔΗΓΟΥ / <br>Co-Driver SUGNATURE</th>
                                    <th>ΕΓΓΥΗΤΗΣ: Αριθμός πιστωτικής κάρτας<br>Credit card number</th> 
                                    <th>ΥΠΟΓΡΑΦΗ - SIGNATURE</th>
                                    <th>CVV</th>
                                    <th>VALIDTHRU</th>
                                </tr>
                            </thead>
                    <tbody>
                    <tr><td style="padding-bottom: 4rem;text-align: right;"></td>
                    <td style="padding-bottom: 4rem;text-align: right;"></td>
                    <td style="padding-bottom: 4rem;text-align: right;"></td>
                    <td style="padding-bottom: 4rem;text-align: right;"></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>ΠΑΡΕΔΩΘΗ (ΥΠΑΛΛΗΛΟΣ)<br>CHECK OUT (EMPLOYEE)</th> 
                                    <th>ΠΑΡΕΛΗΦΘΗ (ΥΠΑΛΛΗΛΟΣ)<br>CHECK IN (EMPLOYEE)</th>  
                                </tr>
                            </thead>
                    <tbody>
                    <tr><td style="padding-bottom: 3rem;text-align: right;"><span>ΕΞΩΦΛΗΘΗ <br>PAID </span> <input type="checkbox" name="brand"> </td>
                        <td style="padding-bottom: 3rem;"></td>
                    </tr>
                    </tbody>
                </table>
                <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>ΥΠΟΓΡΑΦΗ ΠΕΛΑΤΗ / CUSTOMERS SIGNATURE</th> 
                                    <th>ΥΠΟΓΡΑΦΗ ΣΥΝΟΔΗΓΟΥ / <br>Co-Driver SUGNATURE</th>  
                                </tr>
                            </thead>
                    <tbody>
                    <tr><td style="padding-bottom: 5rem;text-align: right;"></td>
                        <td style="padding-bottom: 5rem;text-align: right;"></td>
                    </tr>
                    </tbody>
                </table>

			</div>
			
			
			</div>
			</div>
			</div>
		
                <div class="col-sm-12 justify-content-center">
                <span style="
    margin-left: 2rem;
    margin-right: 2rem;
    font-size: 10px;
    text-align: justify;
"><strong>Notes: </strong>1)Διάβασα τους όρους της ενοικίασης που αναφέρονται και στις δυο (2) πλευρές του συμβολαίου και συμφωνώ. 2)Επιβαρύνομαι με όλες τις παραβάσεις της Τροχαίας. 3)Με την υπογραφή μου στο παρόν συμφωνητικό μίσθωμα αποδέχομαι συνάμα και την χρέωση που θα γίνει στο δελτίο χρέωσης της πιστωτικής μου κάρτας για την εξόφληση οποιασδήποτε οφειλής μου προκύψει από το συμφωνητικό αυτό. Τέλος δηλώνω ότι για το σκοπό αυτό, εξουσιοδοτώ και δίδω εντολή στην εκμισθώτρια εταιρεία να προβεί στην παραπάνω χρέωση της πιστωτικής μου κάρτας τα στοιχεία της οποίας έχω δηλώσει στην αρχή του παρόντος. 4)Η μικτή ασφάλιση δεν ισχύει με τη λήξη του συμβολαίου. 5)Σε περίπτωση ατυχήματος πρέπει να ειδοποιηθεί η αστυνομία και η Motorclub. <strong>6)Χρήματα δεν επιστρέφονται.</strong> 7)Βεβαιώνουμε, ότι τα προσωπικά δεδομένα του πελάτη επεξεργάζονται μόνον εφόσον είναι απαραίτητα για την εκτέλεση της παρούσας σύμβασης ενοικίασης και για την συμμόρφωση των νόμιμων υποχρεώσεων της εταιρίας ΣΙΓΜΑ Α.Ε. 8)Συμφωνώ να λαμβάνω διαφημιστικές πληροφορίες της motor club μέσω του email μου <br>
1)I have read and agree to the terms and conditions on both sides of the rental agreement. 2)I am liable for all parking and traffic violations. 3)With my signature in the current rental agreement, I accept the charge which be made in a bank voucher using the number of my credit card in order to pay off any dept concerning this rental agreement. Finally I declare that for this purpose I permit and give the order to the car rental company to charge my credit card using its details as I have declared them in this rental agreement. 4)Insurance not in effect upon expiration of date and time. 5)In case of accident, police and Motorclub should be informed. 6)Money will be returned in any case of any cancelation. 7)We certify that the personal data of the customer are processed only if they are necessary for the execution of this rental agreement and for the compliance of the legal obligations of SIGMA SA. 8)I agree to receive motor club info through my email.</span>
				</div>       
            
                    </div>
		</div>

		<!--<script>
			window.print();
		</script>-->
	</body>
</html>
<?php  include('include/footer.php');?>