<!DOCTYPE html>
<html>
<head>
	<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<style>
#customers {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

#customers td, #customers th {
    border: 1px solid #ddd;
    padding: 8px;
}

#customers tr:nth-child(even){background-color: #f2f2f2;}

#customers tr:hover {background-color: #ddd;}

#customers th {
    padding-top: 12px;
    padding-bottom: 12px;
    text-align: left;
    background-color: hsl(148, 7%, 62%);
    color: white;
}
</style>

</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>	
		<div class="container" style="margin-top: -50px;">
  <center><h3>Weekly Timesheet</h3></center><br>	<br>	
  <form action="post.php" method="POST" id="timesheet" enctype="multipart/form-data">
    <?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" >
  <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" required = "true" name="date" required="">
        <option value="">Select a date</option>
        <?php
          for($i2=1; $i2<30; $i2++)
         {

    // echo '<br>',
      $ddd = $str.$i2;
    // echo '',
      $date = date('d M D Y', $time = strtotime($ddd) );

      if(strpos($date, 'Sun') )
      {
        echo '<option value ="'.$date.'">'.$date.'</option>';
      }
  }
        ?>
      </select>
    
 </div><br> 

<br>

<div class="barrol" style=" overflow:hidden;overflow-x:scroll;">
<label><b>Rate 1</b></label>

<table style="width: 100%;" class="table" id="customers">
  <tr>
    <th  style="background: white;"></th>
    <th><center>Sunday</center></th>
    <th><center>Monday</center></th>
    <th><center>Tuesday</center></th>
    <th><center>Wednesday</center></th>
    <th><center>Thursday</center></th>
    <th><center>Friday</center></th>
    <th><center>Saturday</center></th>
  </tr>
  <tr>
    <th><center>Duty</center></th>
    <td><input type="text" class="form-control"  name="rate1_duty_sunday"></td>
    <td><input type="text" class="form-control"  name="rate1_duty_monday"></td>
    <td><input type="text" class="form-control"  name="rate1_duty_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate1_duty_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate1_duty_thursday"></td>
    <td><input type="text" class="form-control"  name="rate1_duty_friday"></td>
    <td><input type="text" class="form-control"  name="rate1_duty_saturday"></td>
  </tr>
  <tr>
    <th><center>Less Break</center></th>
    <td><input type="text" class="form-control"  name="rate1_less_sunday"></td>
    <td><input type="text" class="form-control"  name="rate1_less_monday"></td>
    <td><input type="text" class="form-control"  name="rate1_less_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate1_less_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate1_less_thursday"></td>
    <td><input type="text" class="form-control"  name="rate1_less_friday"></td>
    <td><input type="text" class="form-control"  name="rate1_less_saturday"></td>
  </tr>
  <tr>
    <th><center>Total Payable</center></th>
    <td><input type="text" class="form-control"  name="rate1_payable_sunday"></td>
    <td><input type="text" class="form-control"  name="rate1_payable_monday"></td>
    <td><input type="text" class="form-control"  name="rate1_payable_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate1_payable_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate1_payable_thursday"></td>
    <td><input type="text" class="form-control"  name="rate1_payable_friday"></td>
    <td><input type="text" class="form-control"  name="rate1_payable_saturday"></td>
  </tr>
  <tr>
    <th><center>Rate 1</center></th>
    <td><input type="text" class="form-control"  name="rate1_sunday"></td>
    <td><input type="text" class="form-control"  name="rate1_monday"></td>
    <td><input type="text" class="form-control"  name="rate1_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate1_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate1_thursday"></td>
    <td><input type="text" class="form-control"  name="rate1_friday"></td>
    <td><input type="text" class="form-control"  name="rate1_saturday"></td>
    
  </tr>
  <tr>
    <th><center>Nights Out Y/N</center></th>
    <td><input type="text" class="form-control"  name="rate1_night_sunday"></td>
    <td><input type="text" class="form-control"  name="rate1_night_monday"></td>
    <td><input type="text" class="form-control"  name="rate1_night_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate1_night_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate1_night_thursday"></td>
    <td><input type="text" class="form-control"  name="rate1_night_friday"></td>
    <td><input type="text" class="form-control"  name="rate1_night_saturday"></td>
  </tr>
  <tr>
    <th><center>Parking/Tolls</center></th>
    <td><input type="text" class="form-control"  name="rate1_parking_sunday"></td>
    <td><input type="text" class="form-control"  name="rate1_parking_monday"></td>
    <td><input type="text" class="form-control"  name="rate1_parking_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate1_parking_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate1_parking_thursday"></td>
    <td><input type="text" class="form-control"  name="rate1_parking_friday"></td>
    <td><input type="text" class="form-control"  name="rate1_parking_saturday"></td>
  </tr>
  <tr>
    <th><center>DNI</center></th>
    <td><input type="text" class="form-control"  name="rate1_dni_sunday"></td>
    <td><input type="text" class="form-control"  name="rate1_dni_monday"></td>
    <td><input type="text" class="form-control"  name="rate1_dni_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate1_dni_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate1_dni_thursday"></td>
    <td><input type="text" class="form-control"  name="rate1_dni_friday"></td>
    <td><input type="text" class="form-control"  name="rate1_dni_saturday"></td>
  </tr>
</table>
</div>
<br><br><br><br><br>







<label><b>Rate 2</b></label>
<div class="barrol" style=" overflow:hidden;overflow-x:scroll;">
<table style="width: 100%;" class="table" id="customers">
  <tr>
    <th style="background: white;"></th>
    <th><center>Sunday</center></th>
    <th><center>Monday</center></th>
    <th><center>Tuesday</center></th>
    <th><center>Wednesday</center></th>
    <th><center>Thursday</center></th>
    <th><center>Friday</center></th>
    <th><center>Saturday</center></th>
  </tr>
  <tr>
    <th><center>Duty</center></th>
    <td><input type="text" class="form-control"  name="rate2_duty_sunday"></td>
    <td><input type="text" class="form-control"  name="rate2_duty_monday"></td>
    <td><input type="text" class="form-control"  name="rate2_duty_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate2_duty_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate2_duty_thursday"></td>
    <td><input type="text" class="form-control"  name="rate2_duty_friday"></td>
    <td><input type="text" class="form-control"  name="rate2_duty_saturday"></td>
  </tr>
  <tr>
    <th><center>Less Break</center></th>
    <td><input type="text" class="form-control"  name="rate2_less_sunday"></td>
    <td><input type="text" class="form-control"  name="rate2_less_monday"></td>
    <td><input type="text" class="form-control"  name="rate2_less_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate2_less_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate2_less_thursday"></td>
    <td><input type="text" class="form-control"  name="rate2_less_friday"></td>
    <td><input type="text" class="form-control"  name="rate2_less_saturday"></td>
  </tr>
  <tr>
    <th><center>Total Payable</center></th>
    <td><input type="text" class="form-control"  name="rate2_payable_sunday"></td>
    <td><input type="text" class="form-control"  name="rate2_payable_monday"></td>
    <td><input type="text" class="form-control"  name="rate2_payable_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate2_payable_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate2_payable_thursday"></td>
    <td><input type="text" class="form-control"  name="rate2_payable_friday"></td>
    <td><input type="text" class="form-control"  name="rate2_payable_saturday"></td>
  </tr>
  <tr>
    <th><center>Rate 2</center></th>
    <td><input type="text" class="form-control"  name="rate2_sunday"></td>
    <td><input type="text" class="form-control"  name="rate2_monday"></td>
    <td><input type="text" class="form-control"  name="rate2_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate2_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate2_thursday"></td>
    <td><input type="text" class="form-control"  name="rate2_friday"></td>
    <td><input type="text" class="form-control"  name="rate2_saturday"></td>
  </tr>
  <tr>
    <th><center>Nights Out Y/N</center></th>
    <td><input type="text" class="form-control"  name="rate2_night_sunday"></td>
    <td><input type="text" class="form-control"  name="rate2_night_monday"></td>
    <td><input type="text" class="form-control"  name="rate2_night_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate2_night_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate2_night_thursday"></td>
    <td><input type="text" class="form-control"  name="rate2_night_friday"></td>
    <td><input type="text" class="form-control"  name="rate2_night_saturday"></td>
  </tr>
  <tr>
    <th><center>Parking/Tolls</center></th>
    <td><input type="text" class="form-control"  name="rate2_parking_sunday"></td>
    <td><input type="text" class="form-control"  name="rate2_parking_monday"></td>
    <td><input type="text" class="form-control"  name="rate2_parking_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate2_parking_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate2_parking_thursday"></td>
    <td><input type="text" class="form-control"  name="rate2_parking_friday"></td>
    <td><input type="text" class="form-control"  name="rate2_parking_saturday"></td>
  </tr>
  <tr>
    <th><center>DNI</center></th>
    <td><input type="text" class="form-control"  name="rate2_dni_sunday"></td>
    <td><input type="text" class="form-control"  name="rate2_dni_monday"></td>
    <td><input type="text" class="form-control"  name="rate2_dni_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate2_dni_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate2_dni_thursday"></td>
    <td><input type="text" class="form-control"  name="rate2_dni_friday"></td>
    <td><input type="text" class="form-control"  name="rate2_dni_saturday"></td>
  </tr>
</table>
</div>
<br><br><br><br><br>


<label><b>Rate 3</b></label>
<div class="barrol" style=" overflow:hidden;overflow-x:scroll;">
<table style="width: 100%;" class="table" id="customers">
  <tr>
    <th style="background: white;"></th>
    <th><center>Sunday</center></th>
    <th><center>Monday</center></th>
    <th><center>Tuesday</center></th>
    <th><center>Wednesday</center></th>
    <th><center>Thursday</center></th>
    <th><center>Friday</center></th>
    <th><center>Saturday</center></th>
  </tr>
  <tr>
    <th><center>Duty</center></th>
    <td><input type="text" class="form-control"  name="rate3_duty_sunday"></td>
    <td><input type="text" class="form-control"  name="rate3_duty_monday"></td>
    <td><input type="text" class="form-control"  name="rate3_duty_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate3_duty_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate3_duty_thursday"></td>
    <td><input type="text" class="form-control"  name="rate3_duty_friday"></td>
    <td><input type="text" class="form-control"  name="rate3_duty_saturday"></td>
  </tr>
  <tr>
    <th><center>Less Break</center></th>
    <td><input type="text" class="form-control"  name="rate3_less_sunday"></td>
    <td><input type="text" class="form-control"  name="rate3_less_monday"></td>
    <td><input type="text" class="form-control"  name="rate3_less_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate3_less_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate3_less_thursday"></td>
    <td><input type="text" class="form-control"  name="rate3_less_friday"></td>
    <td><input type="text" class="form-control"  name="rate3_less_saturday"></td>
  </tr>
  <tr>
    <th><center>Total Payable</center></th>
    <td><input type="text" class="form-control"  name="rate3_payable_sunday"></td>
    <td><input type="text" class="form-control"  name="rate3_payable_monday"></td>
    <td><input type="text" class="form-control"  name="rate3_payable_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate3_payable_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate3_payable_thursday"></td>
    <td><input type="text" class="form-control"  name="rate3_payable_friday"></td>
    <td><input type="text" class="form-control"  name="rate3_payable_saturday"></td>
  </tr>
  <tr>
    <th><center>Rate 3</center></th>
    <td><input type="text" class="form-control"  name="rate3_sunday"></td>
    <td><input type="text" class="form-control"  name="rate3_monday"></td>
    <td><input type="text" class="form-control"  name="rate3_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate3_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate3_thursday"></td>
    <td><input type="text" class="form-control"  name="rate3_friday"></td>
    <td><input type="text" class="form-control"  name="rate3_saturday"></td>
  </tr>
  <tr>
    <th><center>Nights Out Y/N</center></th>
    <td><input type="text" class="form-control"  name="rate3_night_sunday"></td>
    <td><input type="text" class="form-control"  name="rate3_night_monday"></td>
    <td><input type="text" class="form-control"  name="rate3_night_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate3_night_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate3_night_thursday"></td>
    <td><input type="text" class="form-control"  name="rate3_night_friday"></td>
    <td><input type="text" class="form-control"  name="rate3_night_saturday"></td>
  </tr>
  <tr>
    <th><center>Parking/Tolls</center></th>
    <td><input type="text" class="form-control"  name="rate3_parking_sunday"></td>
    <td><input type="text" class="form-control"  name="rate3_parking_monday"></td>
    <td><input type="text" class="form-control"  name="rate3_parking_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate3_parking_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate3_parking_thursday"></td>
    <td><input type="text" class="form-control"  name="rate3_parking_friday"></td>
    <td><input type="text" class="form-control"  name="rate3_parking_saturday"></td>
  </tr>
  <tr>
    <th><center>DNI</center></th>
    <td><input type="text" class="form-control"  name="rate3_dni_sunday"></td>
    <td><input type="text" class="form-control"  name="rate3_dni_monday"></td>
    <td><input type="text" class="form-control"  name="rate3_dni_tuesday"></td>
    <td><input type="text" class="form-control"  name="rate3_dni_wednesday"></td>
    <td><input type="text" class="form-control"  name="rate3_dni_thursday"></td>
    <td><input type="text" class="form-control"  name="rate3_dni_friday"></td>
    <td><input type="text" class="form-control"  name="rate3_dni_saturday"></td>
  </tr>
</table>
</div>
<br><br><br>


    <div class="form-group">
      <label>Additional Information:</label>
      <textarea class="form-control" required = "true" name="additional_info"></textarea>
    </div><br> 

    <div class="form-group">
      <label>Invoice Or Remittance To Upload:</label>
      <input type="file" class="form-control" required = "true" name="invoice">
    </div><br> 
  <br><br>
    
    <button type="submit" id="savetimesheet" name="savetimesheet" class="btn btn-primary" onclick="save()">Submit</button>
  </form>

</div>

<br>  <br>  <br>  
</body>
</html>

<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 timesheet has been sent to selected agency.",
  icon: "success",
  button: "Close",
});
 </script>

<?php } 


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

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

<?php } ?>
  <script>
      $(function () {
        $('form').bind('save', function () {
          $.ajax({
            type: 'post',
            url: 'post.php',
            data: $('form').serialize(),
            success: function () {
              alert('form was submitted');
            }
          });
          return false;
        });
      });
    </script>


<script type="text/javascript">
  $(document).ready(function(){
    var form = $('#timesheet');
    $('#savetimesheet').click(function(){

      $.ajax({
        url: form.attr("action"),
        type: 'POST',
        data: $("#timesheet input").serialize(),

         success: function(data){
          console.log(data);
         }
      });

    });
  });
</script>




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