<!DOCTYPE html>
<html>
<head>
	<title>	</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->

</head>
<body>
    
    <header style=" text-align:center;">
        <br>        <br>
        <a href = "CLOSE" style="margin-top: -150px;"><img src="https://image.flaticon.com/icons/svg/93/93634.svg" class="img-responsive" style="height:50px"></a>
    </header>
    
<br><br>
	<form  method="post" action="post.php" enctype="multipart/form-data">	
		<div class="container" style="margin-left: -10px; ">
		  <center>	<h4>Travel and Subsistence Details</h4></center><br><br><br>	
       
				<div class="container">
					<?php
      include('connect.php');
      $driver_id = $_GET['driver_id'];
      $sql = mysqli_query($con,"SELECT * FROM assigned_drivers WHERE driver_id = '$driver_id'");
      
     ?>
   
<input type="hidden" name="driver_id" value="<?= $_GET['driver_id'] ?>">
<select class="form-control" name="agency_id" required="">
  <option value="">Select an Agency</option>
  <?php 
   
   while ($data = mysqli_fetch_array($sql,MYSQLI_BOTH)) 
   { 
     $agency_id = $data['agency_id'];
     $sql2 = mysqli_query($con,"SELECT * FROM agencies WHERE id = '$agency_id'");
     $data2 = mysqli_fetch_array($sql2,MYSQLI_BOTH);
    ?>
     
     <option value="<?= $data2['id'] ?>"><?= $data2['company_re_name'] ?></option>


   <?php } 

  ?>


</select>
<br>

<?php

  $str = date('Y-m-');


?>
 <div class="form-group">
      <select class="form-control" name="month" required="">
        <option value="">Select a Month</option>
        <?php
        for ($m=1; $m<=12; $m++) {
     $month = date('F', mktime(0,0,0,$m, 1, date('Y')));
     echo  '<option value = "'.$month.' '.date('Y').'">'.$month.' '.date('Y').'</option>';
     }
        ?>
      </select>
    
 </div><br> 
				  <div class="row clearfix">
				    <div class="col-md-12">
				    	<h4>Daily Linen Allowances (Per Day) &#163;3</h4>
				      <table class="table table-bordered table-hover" id="tab_logic">
				        <thead>
				          <tr>
				            <th class="text-center"> # </th>
				            <th class="text-center"> Date </th>
				            <th class="text-center"> Price </th>
				            <th class="text-center"> Remove </th>
				          </tr>
				        </thead>
				        <tbody>
				          <tr id='addr0'>
				            <td>1</td>
				            <td><input type="date"  style="width: 135px;" name="linen[]" class="form-control"/></td>
				            <td><input type="number" name='price_linen[]' placeholder='€3' value="3" readonly class="form-control"/></td>
				            <td><center>
				             <button type="button" class="deletebtn btn btn-default" title="Delete">X</button>
				            	</center>
				            </td>
				          </tr>
				          <tr id='addr1'></tr>
				        </tbody>
				      </table>
				    </div>
				  </div>
				  <div class="row clearfix">
				    <div class="col-md-12">
				      <input type="button" id="add_row" class="btn btn-default pull-left" value="Add Row">
				    </div>
				  </div>
				</div><br><br><br>	


                
				<div class="container">
				  <div class="row clearfix">
				    <div class="col-md-12">
				    	<h4>Smaller Allowances (Per Day) &#163;3</h4>
				      <table class="table table-bordered table-hover" id="tab_logic1">
				        <thead>
				          <tr>
				            <th class="text-center"> # </th>
				            <th class="text-center"> Date </th>
				            <th class="text-center"> Price </th>
				            <th class="text-center"> Remove </th>
				          </tr>
				        </thead>
				        <tbody>
				          <tr id='addrone0'>
				            <td>1</td>
				            <td><input type="date" style="width: 135px;" name="smaller[]"   class="form-control"/></td>
				            <td><input type="number" name='price_smaller[]' placeholder='€3' value="3" readonly class="form-control"/></td>
				            <td><center>
				             <button type="button" class="deletebtn1 btn btn-default" title="Delete">X</button>
				            	</center>
				            </td>
				          </tr>
				          <tr id='addrone1'></tr>
				        </tbody>
				      </table>
				    </div>
				  </div>
				  <div class="row clearfix">
				    <div class="col-md-12">
				      <input type="button" id="add_row1" class="btn btn-default pull-left" value="Add Row">
				    </div>
				  </div>
				</div><br><br><br>	


				<div class="container">
				  <div class="row clearfix">
				    <div class="col-md-12">
				    	<h4>Main Travel & Subsistence Allowances > 5 Hours (Per Day) &#163;10</h4>
				      <table class="table table-bordered table-hover" id="tab_logic2">
				        <thead>
				          <tr>
				            <th class="text-center"> # </th>
				            <th class="text-center"> Date </th>
				            <th class="text-center"> Price </th>
				            <th class="text-center"> Remove </th>
				          </tr>
				        </thead>
				        <tbody>
				          <tr id='addrtwo0'>
				            <td>1</td>
				            <td><input type="date" style="width: 135px;" name="travel[]"   class="form-control"/></td>
				            <td><input type="number" name='price_travel[]' placeholder='€10' value="10" readonly class="form-control"/></td>
				            <td><center>
				             <button type="button" class="deletebtn2 btn btn-default" title="Delete">X</button>
				            	</center>
				            </td>
				          </tr>
				          <tr id='addrtwo1'></tr>
				        </tbody>
				      </table>
				    </div>
				  </div>
				  <div class="row clearfix">
				    <div class="col-md-12">
				      <input type="button" id="add_row2" class="btn btn-default pull-left" value="Add Row">
				    </div>
				  </div>
				</div><br><br><br>


				<div class="container">
				  <div class="row clearfix">
				    <div class="col-md-12">
				    	<h4>Overnight Allowances ( Sleeper Cab ) &#163;29.20</h4>
				      <table class="table table-bordered table-hover" id="tab_logic3">
				        <thead>
				          <tr>
				            <th class="text-center"> # </th>
				            <th class="text-center"> Date </th>
				            <th class="text-center"> Price </th>
				            <th class="text-center"> Remove </th>
				          </tr>
				        </thead>
				        <tbody>
				          <tr id='addrthree0'>
				            <td>1</td>
				            <td><input type="date" style="width: 135px;" name="sleeper[]"   class="form-control"/></td>
				            <td><input type="number" name='price_sleeper[]' placeholder='€29.20' value="29.20" readonly class="form-control"/></td>
				            <td><center>
				             <button type="button" class="deletebtn3 btn btn-default" title="Delete">X</button>
				            	</center>
				            </td>
				          </tr>
				          <tr id='addrthree1'></tr>
				        </tbody>
				      </table>
				    </div>
				  </div>
				  <div class="row clearfix">
				    <div class="col-md-12">
				      <input type="button" id="add_row3" class="btn btn-default pull-left" value="Add Row">
				    </div>
				  </div>
				</div><br><br><br>	


								<div class="container">
				  <div class="row clearfix">
				    <div class="col-md-12">
				    	<h4>Vehical and Mileage Expenses</h4>
				      <table class="table table-bordered table-hover" id="tab_logic4">
				        <thead>
				          <tr>
				            <th class="text-center"> # </th>
				            <th class="text-center"> Date </th>
				            <th class="text-center"> Price </th>
				            <th class="text-center"> Remove </th>
				          </tr>
				        </thead>
				        <tbody>
				          <tr id='addrfour0'>
				            <td>1</td>
				            <td><input type="date" style="width: 135px;" name="expense[]"   class="form-control"/></td>
				            <td><input type="number" name='price_expense[]' placeholder="" class="form-control"/></td>
				            <td><center>
				             <button type="button" class="deletebtn4 btn btn-default" title="Delete">X</button>
				            	</center>
				            </td>
				          </tr>
				          <tr id='addrfour1'></tr>
				        </tbody>
				      </table>
				    </div>
				  </div>
				  <div class="row clearfix">
				    <div class="col-md-12">
				      <input type="button" id="add_row4" class="btn btn-default pull-left" value="Add Row">
				    </div>
				  </div>
				  <br>
				      <div class="form-group">
      <label>Total number of business miles in the month:</label>
      <input type="number" class="form-control" name="miles_expense">
    </div><br> 
					</div>

								<div class="container">
				  <div class="row clearfix">
				    <div class="col-md-12">
				    	<h4>Miscellaneous Expenditure</h4>
				      <table class="table table-bordered table-hover" id="tab_logic5">
				        <thead>
				          <tr>
				            <th class="text-center"> # </th>
				            <th class="text-center"> Expenses Type </th>
				            <th class="text-center"> Date </th>
				            <th class="text-center"> Price </th>
				            <th class="text-center"> Delete </th>
				          </tr>
				        </thead>
				        <tbody>
				          <tr id='addrfive0'>
				            <td>1</td>

				            <td>
				            	<select class="form-control" name="expense_type[]">
				            		<option value="">Select Expense</option>
				            		<option value="Postage & Stationary">Postage & Stationary</option>
				            		<option value="Mobile Phone">Mobile Phone</option>
				            		<option value="Landline Phone">Landline Phone</option>
				            		<option value="Broadband & Sky/Netflix">Broadband & Sky/Netflix</option>
				            		<option value="Workwear & Tools">Workwear & Tools</option>
				            		<option value="Advertising & Marketing">Advertising & Marketing</option>
				            		<option value="Public Liablilty Insurance">Public Liablilty Insurance</option>
				            		<option value="CPC Training Costs">CPC Training Costs</option>
				            		<option value="Medicals & Glasses">Medicals & Glasses</option>
				            		<option value="Booking & Subscriptions">Booking & Subscriptions</option>
				            	</select>
				            </td>
				            <td><input type="date" style="width: 60px;" name='date_expense_type[]'  placeholder='Enter Product Name' class="form-control"/></td>
				            <td><input type="number" name='price_expense_type[]' placeholder='0.00' class="form-control" /></td>
				            <td><center>
				             <button type="button" class="deletebtn5 btn btn-default" title="Delete">X</button>
				            	</center>
				            </td>
				          </tr>
				          <tr id='addrfive1'></tr>
				        </tbody>
				      </table>
				    </div>
				  </div>
				  <div class="row clearfix">
				    <div class="col-md-12">
				      <input type="button" id="add_row5" class="btn btn-default pull-left" value="Add Row">
				    </div>
				  </div>
				 <!--  <div class="row clearfix" style="margin-top:20px">
				    <div class="pull-right col-md-4">
				      <table class="table table-bordered table-hover" id="tab_logic_total">
				        <tbody>
				          <tr>
				            <th class="text-center">Sub Total</th>
				            <td class="text-center"><input type="number" name='sub_total' placeholder='0.00' class="form-control" id="sub_total" readonly/></td>
				          </tr>
				        </tbody>
				      </table>
				    </div>
				  </div> -->
				</div><br><br><br>

						<div class="container">
  <h4>Use of Home as Office</h4><br>    
    <div class="form-group">
      <label>Mortgage/Rent</label><br>
      <div class="row">
      		<div class="col-md-6"> 
      				<input type="date" class="form-control" id=""  name="rent_date">		
      				<h6>	date</h6>		
      		 </div>
      		 <div class="col-md-6"> 
      				<input type="number" class="form-control" id="" placeholder="Amount" name="rent_amount">
      				<h6>Amount</h6>				
      		 </div>
      	</div>
    </div><br>  

    <div class="form-group">
      <label>Council Tax</label><br>
      <div class="row">
          <div class="col-md-6"> 
              <input type="date" class="form-control" id=""  name="council_date">   
              <h6>  date</h6>   
           </div>
           <div class="col-md-6"> 
              <input type="number" class="form-control" id="" placeholder="Amount" name="council_amount">
              <h6>Amount</h6>       
           </div>
        </div>
    </div><br>

    <div class="form-group">
      <label>Rates Water/Gas/Electric</label><br>
      <div class="row">
          <div class="col-md-6"> 
              <input type="date" class="form-control" id=""  name="bill_date">   
              <h6>  date</h6>   
           </div>
           <div class="col-md-6"> 
              <input type="number" class="form-control" id="" placeholder="Amount" name="bill_amount">
              <h6>Amount</h6>       
           </div>
        </div>
    </div><br>

    <div class="form-group">
      <label>Garage Rental</label><br>
      <div class="row">
          <div class="col-md-6"> 
              <input type="date" class="form-control" id=""  name="garage_date">   
              <h6>  date</h6>   
           </div>
           <div class="col-md-6"> 
              <input type="number" class="form-control" id="" placeholder="Amount" name="garage_amount">
              <h6>Amount</h6>       
           </div>
        </div>
    </div><br>  

  

    <div class="form-group">
      <label>Percentage of office to house:</label>
      <input type="number" class="form-control" name="percentage_house">
      <h6>%age (25% is average)</h6>
    </div><br> 


    <div class="form-group">
      <label>Upload receipts (greater than &#163;100):</label>
      <input type="file" class="form-control" name="invoice">
    </div><br> 

    <div class="form-group">
      <label>Other Miscellaneous Expenses:</label>
      <textarea class="form-control" name="miscellaneous" placeholder="Ex: 07/01/2019 €5.00 for parking"></textarea>
    </div><br> 

    <div class="form-group">
      <label>Comments box:</label>
      <textarea class="form-control" name="comment" placeholder="Ex: 07/01/2019 €5.00 for parking"></textarea>
    </div><br> 

<!--     <div class="form-group">
        <label><h3><b>For office use only</b></h3> </label>
    </div><br> 

    <div class="form-group">
      <label>Expenses Logged and Processed by Admin:</label>
      <textarea class="form-control" name="admin_expense" placeholder="For Ofiice use only, leave it blank"></textarea>
    </div><br>  -->

</div>


			<button type="submit" class="btn btn-primary" name="savetravel">Submit</button>
		</div>
	</form>
</body>
</html>


<script type="">

	$(document).on('click', 'button.deletebtn', function () {
     $(this).closest('tr').remove();
     return false;
 });

	$(document).ready(function(){
    var i=1;
    $("#add_row").click(function(){b=i-1;
      	$('#addr'+i).html($('#addr'+b).html()).find('td:first-child').html(i+1);
      	$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
      	i++; 
  	});
    $("#delete_row").click(function(){
    	if(i>1){
		$("#addr"+(i-1)).html('');
		i--;
		}
		calc();
	});
	
	$('#tab_logic tbody').on('keyup change',function(){
		calc();
	});


});

</script>


<script type="">

	$(document).on('click', 'button.deletebtn1', function () {
     $(this).closest('tr').remove();
     return false;
 });

	$(document).ready(function(){
    var i=1;
    $("#add_row1").click(function(){b=i-1;
      	$('#addrone'+i).html($('#addrone'+b).html()).find('td:first-child').html(i+1);
      	$('#tab_logic1').append('<tr id="addrone'+(i+1)+'"></tr>');
      	i++; 
  	});
    $("#delete_row1").click(function(){
    	if(i>1){
		$("#addrone"+(i-1)).html('');
		i--;
		}
		calc();
	});
	
	$('#tab_logic1 tbody').on('keyup change',function(){
		calc();
	});


});

</script>

<script type="">

	$(document).on('click', 'button.deletebtn2', function () {
     $(this).closest('tr').remove();
     return false;
 });

	$(document).ready(function(){
    var i=1;
    $("#add_row2").click(function(){b=i-1;
      	$('#addrtwo'+i).html($('#addrtwo'+b).html()).find('td:first-child').html(i+1);
      	$('#tab_logic2').append('<tr id="addrtwo'+(i+1)+'"></tr>');
      	i++; 
  	});
    $("#delete_row2").click(function(){
    	if(i>1){
		$("#addrtwo"+(i-1)).html('');
		i--;
		}
		calc();
	});
	
	$('#tab_logic2 tbody').on('keyup change',function(){
		calc();
	});


});

</script>


<script type="">

	$(document).on('click', 'button.deletebtn3', function () {
     $(this).closest('tr').remove();
     return false;
 });

	$(document).ready(function(){
    var i=1;
    $("#add_row3").click(function(){b=i-1;
      	$('#addrthree'+i).html($('#addrthree'+b).html()).find('td:first-child').html(i+1);
      	$('#tab_logic3').append('<tr id="addrthree'+(i+1)+'"></tr>');
      	i++; 
  	});
    $("#delete_row3").click(function(){
    	if(i>1){
		$("#addrthree"+(i-1)).html('');
		i--;
		}
		calc();
	});
	
	$('#tab_logic3 tbody').on('keyup change',function(){
		calc();
	});


});

</script>


<script type="">

	$(document).on('click', 'button.deletebtn4', function () {
     $(this).closest('tr').remove();
     return false;
 });

	$(document).ready(function(){
    var i=1;
    $("#add_row4").click(function(){b=i-1;
      	$('#addrfour'+i).html($('#addrfour'+b).html()).find('td:first-child').html(i+1);
      	$('#tab_logic4').append('<tr id="addrfour'+(i+1)+'"></tr>');
      	i++; 
  	});
    $("#delete_row4").click(function(){
    	if(i>1){
		$("#addrfour"+(i-1)).html('');
		i--;
		}
		calc();
	});
	
	$('#tab_logic4 tbody').on('keyup change',function(){
		calc();
	});


});

</script>

<script type="">

	$(document).on('click', 'button.deletebtn5', function () {
     $(this).closest('tr').remove();
     return false;
 });

	$(document).ready(function(){
    var i=1;
    $("#add_row5").click(function(){b=i-1;
      	$('#addrfive'+i).html($('#addrfive'+b).html()).find('td:first-child').html(i+1);
      	$('#tab_logic5').append('<tr id="addrfive'+(i+1)+'"></tr>');
      	i++; 
  	});
    $("#delete_row5").click(function(){
    	if(i>1){
		$("#addrfive"+(i-1)).html('');
		i--;
		}
		calc();
	});
	
	$('#tab_logic5 tbody').on('keyup change',function(){
		calc();
	});


});

</script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<?php

if(isset($_GET['msg']))
{?>

 <script type="text/javascript">
   swal({
  title: "Data Saved!",
  text: "Your Document has been sent to selected agency.",
  icon: "success",
  button: "Close",
});
 </script>

<?php } 


if(isset($_GET['error']))
{?>

 <script type="text/javascript">
   swal({
  title: "Error!",
  text: "Document Already submitted for this agency and week",
  icon: "error",
  button: "Close",
});
 </script>

<?php } ?>