<?php
/*
Template Name: Contract Page
*/
 get_header();
require("customfunction.php");  
require("chklogin.php");  
require("islogin.php"); 
$auth=$_REQUEST["auth"];
$guid=$_REQUEST["guid"];
$rfid=$_REQUEST["rfid"];

$apiUrl=$apiBaseUrl."/api/customers/contract.php?apikey=".$apiKey."&time=".$time;
$postdata=$postdata.'&auth='.$auth.'';
$postdata=$postdata.'&guid='.$guid.'';
$postdata=$postdata.'&rfid='.$rfid.'';
//echo $apiUrl;
$resp=GetApiData($apiUrl,$postdata);
$responseAPI=json_decode($resp);
//print_r($responseAPI);
?>
 <form name="frm_Reg" id="frm_Reg" method="post" action="/proccessform.php?actions=update_card_authorizion" onSubmit="return checkformR();" enctype="multipart/form-data">
	<input type="hidden" name="guid" id="guid" value="<?=$guid?>" />
	<input type="hidden" name="rfid" id="rfid" value="<?=$rfid?>" />
	<input type="hidden" name="auth" id="auth" value="<?=$auth?>" />
	<input type="hidden" name="reservation_id" id="reservation_id" value="<?=$responseAPI->reservation_id?>" />
<div class="HeaderExoticlimo">
  <div class="container">
    <div class="row">
      <div class="col-sm-6">
        <div class="exotic-left">
          <h1>Sacramento <br>
            Limousine Service</h1>
        </div>
      </div>
      <div class="col-sm-6">
        <div class="exotic-right">
          <ul>
            <li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/phone-icon.png" alt="phone-icon" class="img-responsive"/> 916-325-5555</a></li>
            <li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/email-icon.png" alt="email-icon" class="img-responsive"/> info@sacramentolimousineservice.net</a></li>
            <li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/website-icon.png" alt="website-icon" class="img-responsive"/> www.sacramentolimousineservice.net</a></li>
          </ul>
          <span class="reservatin">Reservation #<?=$responseAPI->reservation_id?></span> <img src="<?php echo get_template_directory_uri(); ?>/assets/images/reservatin-left.png" alt="reservatin-left" class="img-responsive reservatin-left"/> <img src="<?php echo get_template_directory_uri(); ?>/assets/images/reservatin-right.png" alt="reservatin-right" class="img-responsive reservatin-right"/> </div>
      </div>
    </div>
  </div>
</div>

<!--Billing-Address-->

<div class="billing_customer">
  <div class="container">
    <div class="row">
      <div class="col-sm-6">
        <div class="billing_info">
          <h2>Billing Info:</h2>
          <ul>
            <li> <strong>Name:</strong>
              <p><input name="Name_On_Card" id="Name_On_Card" value="<?=$responseAPI->customers_name?>" type="hidden" class="table-input" disabled="disabled" /> <?=$responseAPI->customers_name?></p>
            </li>
            <li> <strong>Phone:</strong>
              <p><input name="Billing_Phone" id="Billing_Phone" value="<?=$responseAPI->Billing_Phone?>" type="hidden"  class="table-input" readonly="true"/><?=$responseAPI->Billing_Phone?></p>
            </li>
            <li><strong>Address:</strong>
              <p class="margin-left"><input name="Billing_Address" id="Billing_Address" value="<?=$responseAPI->Billing_Address?>" type="hidden" class="table-input" readonly="true"/>****** ******** ******* <br>
                <input name="Billing_City" id="Billing_City" value="<?=$responseAPI->Billing_City?>" type="hidden" class="table-input" readonly="true"/><?=$responseAPI->Billing_City?>, <input name="Billing_State" id="Billing_State" value="<?=$responseAPI->Billing_State?>" type="hidden" class="table-input" readonly="true"/><?=$responseAPI->Billing_State?>, <input type="hidden"  id="postal_code" name="postal_code" size="5" value="<?=$responseAPI->postal_code?>" class="table-input" readonly="true"/><?=$responseAPI->postal_code?></p>
            </li>
          </ul>
        </div>
      </div>
      <div class="col-sm-6">
        <div class="billing_info">
          <h2>Customer Info:</h2>
          <ul>
            <li> <strong>Name:</strong>
              <p><?=$responseAPI->customers_name?></p>
            </li>
            <li> <strong>Phone:</strong>
              <p><?=$responseAPI->phone_number?></p>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</div>

<!--pickDate_time-->

<div class="pickDate_time">
  <div class="container">
    <ul>
      <li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/pick-date.png" alt="pick-date" class="img-responsive"/> <b>Pick Date:</b> <?=date('l, F d Y', strtotime($responseAPI->pickup_date))?></a></li>
      <li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/pick-time.png" alt="pick-time" class="img-responsive"/> <b>Pick Time:</b> <?=date('h:i A', strtotime($responseAPI->pickup_time))?> <span class="pick_time"><b>Drop Time:</b> <?=date('h:i A', strtotime($responseAPI->dropoff_time))?></span></a></li>
      <li><img src="<?php echo get_template_directory_uri(); ?>/assets/images/map.png" alt="map" class="img-responsive"/><b>Pick Address:</b> <?=$responseAPI->pa_address?><br><?=$responseAPI->pa_city?>, <?=$responseAPI->pa_state?>, <?=$responseAPI->pa_zip?></li>
      <? 			
		$result_sR=$responseAPI->reservationStopA;
		if(count($result_sR) > 0 ){
			$indx=0;
			foreach ($result_sR as $row_sR ){
				$indx=$indx + 1;
			?>
			<li><img src="<?php echo get_template_directory_uri(); ?>/assets/images/map.png" alt="map" class="img-responsive"/><b>Stops<?=$indx?>: </b> <?=$row_sR->type_name?>: </strong> <?=$row_sR->locations?>, <?=$row_sR->address?>, <?=$row_sR->city?>, <?=$row_sR->state?>, <?=$row_sR->zip_code?></li>
		 <? } 
		}?>
      <li><img src="<?php echo get_template_directory_uri(); ?>/assets/images/map.png" alt="map" class="img-responsive"/><b>Drop Off Address: </b> <?=$responseAPI->da_address?><br><?=$responseAPI->da_city?>, <?=$responseAPI->da_state?>, <?=$responseAPI->da_zip?></li>
    </ul>
    <ul class="cloud-tour-passenger">
      <li><img src="<?php echo get_template_directory_uri(); ?>/assets/images/icon-steering.png" alt="steering" class="img-responsive"/> <?=$responseAPI->Type_of_Vehicle?></li>
     <li><img src="<?php echo get_template_directory_uri(); ?>/assets/images/passengerIcon.png" alt="passenger" class="img-responsive"/> <?=$responseAPI->no_of_passengers?> Passengers</li>
      <li><img src="<?php echo get_template_directory_uri(); ?>/assets/images/tour.png" alt="tour" class="img-responsive"/> <?=$responseAPI->ServiceName?></li>
    </ul>
  </div>
</div>

<!--Table section-->

<div class="table_section_Wr">
  <div class="container">
    <div class="tableSecWrpRate">
      <table class="table tableBaseRate">
        <thead class="thead-blue">
          <tr>
            <th>Total Rate <img src="<?php echo get_template_directory_uri(); ?>/assets/images/table-left-img.png" alt="" class="table-left-img"/></th>
            <th>Deposits</th>
            <th>Balance Included <img src="<?php echo get_template_directory_uri(); ?>/assets/images/table-right-img.png" alt="" class="table-right-img"/></th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><span class="pricetxt">$<?=number_format($responseAPI->Vendor_Total_Rate,2)?></span><br>
              <? if($responseAPI->rate_e4 > 0){?>	
			  <span class="savedtxt">(Discount $<?=number_format($responseAPI->rate_e4,2)?>)</span>
			  <? }?></td>
            <td><? 
			$totalR=0;
			$result_TR=$responseAPI->reservationTrA;
			if(count($result_TR) > 0 ){
				foreach ($result_TR as $row_TR ){
					if($row_TR->Transaction_Type!="auth_only"){
						$totalR=$totalR+$row_TR->Amount;
					}?>							
					<span class="pricetxt">$<?=$row_TR->Amount?></span> (<?=date('m/d/Y', strtotime($row_TR->c_date))?>) <? if($row_TR->Transaction_ID!=""){?> RefID: (<?=$row_TR->Transaction_ID?>)<? }?><br>
				<?
				} 
			}?></td>
            <td><span class="pricetxt">$<?=number_format(($responseAPI->quote_total-$totalR),2)?></span></td>
          </tr>
        </tbody>
      </table>
    </div>
	<? if($auth=="ni"){}else{?>
    <div class="upload_section">
      <div class="row">
        <div class="col-sm-12">
          <div class="col-sm-6 p_d_0">
            <div class="content_box">
              <h3>Upload Picture of ID</h3>
              <img src="<?php echo get_template_directory_uri(); ?>/assets/images/upload-left.png" alt="" class=" img-responsive upload-left"/>
              <div class="choose_file">
                <? if($responseAPI->idp_copy != ""){?>			
				 <img src="<?=$apiBaseUrl?>/uploads/reservation/<?=$responseAPI->idp_copy?>" alt="Image" title="Image" border="0"  width="300px" height="150px" />
				 <? }else{?>	
					<a href="javascript:deleteFile(1);" id="linkdelete1" style="display:none;">Delete</a>		 	
	                <div class="imageUploadbx">
               			 <img src="<?php echo get_template_directory_uri(); ?>/assets/images/icon-photo-id.png" alt="" id="img1" style="width:138px; height:90px;"/>
					</div>
					<div class="choosefileBtn">Click To Upload Image <input type="file" name="idp_copy" id="idp_copy" onChange="readURL1(this);"/></div>
				<? }?>
				
                 </div>
            </div>
          </div>
          <div class="col-sm-6 p_d_0">
            <div class="content_box content_box-1">
              <h3>Upload Picture of card</h3>
              <img src="<?php echo get_template_directory_uri(); ?>/assets/images/upload-left.png" alt="" class=" img-responsive upload-left"/>
              <div class="choose_file">
                <? if($responseAPI->card_copy != ""){?> 
					<img src="<?=$apiBaseUrl?>/uploads/reservation/<?=$responseAPI->card_copy?>" alt="Image" title="Image" border="0"  width="300px" height="150px" />
				<? }else{?>	
					<a href="javascript:deleteFile(2);" id="linkdelete2" style="display:none;">Delete</a>
					<div class="imageUploadbx">
					<img src="<?php echo get_template_directory_uri(); ?>/assets/images/icon-card-back.png" alt="" id="img2" style="width:138px; height:90px;"/>
					</div>
					 <div class="choosefileBtn">Click To Upload Photo <input type="file" name="card_copy" id="card_copy" onChange="readURL2(this);"/></div>
					</div>
				<? }?>  
				
                 </div>
            </div>
          </div>
        </div>
      </div>
	<? }?>
    </div>
  </div>
</div>

<!--Credit card-->

<div class="credit-card-sign-section">
  <div class="container">
    <div class="credit-card-sign">
      <h4>Credit Card Signtaure <img src="<?php echo get_template_directory_uri(); ?>/assets/images/creditcard-left.png" alt="" class="creditcard-left"/> <img src="<?php echo get_template_directory_uri(); ?>/assets/images/credit-card-right.png" alt="" class="credit-card-right"/> </h4>

      
       <div class="sign-box-outer">
           <? if($responseAPI->signature_copy != ""){?> 
		  		<img src="<?=$apiBaseUrl?>/uploads/reservation/<?=$responseAPI->signature_copy?>" alt="Image" title="Image" border="0"  width="200px" height="100px" />
		<? }else{?></div>
				<iframe src="<?=$apiBaseUrl?>/sign.php?reservation_id=<?=$responseAPI->reservation_id?>&page_from=cust" width="90%" height="290px;" seamless="seamless" scrolling="no" frameborder="0"></iframe>
		<? }?>
          <div class="signDate">Date: <input name="a_date" id="a_date" value="" type="hidden" class="table-input" readonly="true" /> <? if($responseAPI->a_date=="0000-00-00"){echo date('M d, Y');}else{echo $responseAPI->a_date;}?></div>
        </div>
    </div>
  </div>
</div>

<div class="terms-condition">
  <div class="container">
    <div class="authorizereservation"><input type="submit" name="dsss" value="Authorize Your Reservation" class="auth"/></div>
    <p>By authorization you agree to <a href="/contracttermandconditions?rfid=<?=$rfid?>" target="_blank"  title="Terms and Conditions" rel="gb_page_center[880, 450]"><font color="black" size="2"><b>terms and conditions.</b></font></a></p>
  </div>
</div> 
</form>
<!--/.contentPart--> 

 <script>
function deleteFile(sval){
	if(sval==1){
		$('#idp_copy').val(null); 
		$('#img1').attr('src', '<?php echo get_template_directory_uri(); ?>/assets/images/icon-photo-id.png');
		$('#linkdelete1').hide();
	}	
	else if(sval==2){
		$('#card_copy').val(null); 
		$('#img2').attr('src', '<?php echo get_template_directory_uri(); ?>/assets/images/icon-card-back.png');
		$('#linkdelete2').hide();
	}	
} 

function readURL2(input){
	var ext = input.files[0]['name'].substring(input.files[0]['name'].lastIndexOf('.') + 1).toLowerCase();
	if (input.files && input.files[0] && (ext == "gif" || ext == "png" || ext == "jpeg" || ext == "jpg")) 
	{
		var reader = new FileReader();
		reader.onload = function (e) {
			$('#img2').attr('src', e.target.result);
		}
		reader.readAsDataURL(input.files[0]);		
	}else{
		 $('#img2').attr('src', '<?php echo get_template_directory_uri(); ?>/assets/images/icon-card-back.png');
	}
	$('#linkdelete2').show();
}

function readURL1(input){
	var ext = input.files[0]['name'].substring(input.files[0]['name'].lastIndexOf('.') + 1).toLowerCase();
	if (input.files && input.files[0] && (ext == "gif" || ext == "png" || ext == "jpeg" || ext == "jpg")) 
	{
		var reader = new FileReader();
		reader.onload = function (e) {
			$('#img1').attr('src', e.target.result);
		}
		reader.readAsDataURL(input.files[0]);
	}else{
		 $('#img1').attr('src', '<?php echo get_template_directory_uri(); ?>/assets/images/icon-photo-id.png');
	}
	$('#linkdelete1').show();
}
</script>
 <?php get_footer();?>