<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="datatable/data.css">
<script src="datatable/data.js" type="text/javascript"></script>
<script src="datatable/table.js" type="text/javascript"></script>
<script src="datatable/datatable.js"></script>
<link rel="stylesheet" href="datatable/data-boot.css">
<link href="javascript/select2.css" rel="stylesheet" >
<script src="javascript/selectt2.js"></script>
<script src="ajax/ticketedit.js"></script>
<script src="restriction/ticket_restriction.js"></script>
<style>
    
    #navbar
    {
        flex:15%;
        height:100%; 
        flex-direction:row;
        overflow:auto;
        
    }
    #content
    {
        flex:90%;
        overflow:auto;
        padding-left:10px;
        padding-right:10px;
    }
    #fullbody
    {
        display:flex;
        
         height:100%;         
    }
    label
    {
      font-size:20px;
    }
    .edit
    {
        font-size:18px;
        color:green;
        cursor:pointer;
    }
    .dele
    {
        font-size:18px;
        color:red;
        cursor:pointer;
    }
    .edit:hover
    {
        font-size:20px;
        
    }
    .dele:hover
    {
        font-size:20px;
        color:red;
        cursor:pointer;
        
    }
    td
    {
      text-align:center;
    }
    th
    {
      text-align:center;
    }
    li a 
    {
      color:black;
    }
    .page-item.active .page-link {
    
    background-color:yellow;
    border-color: #007bff;
}
select,input[type="text"],input[type="date"]
{
  width:100%;
}
    @media (max-width: 800px) {
        #fullbody
    {
        display:flex;
        flex-wrap: wrap;
    }
        #navbar,#content {
    flex: 100%;
  }
}
</style>
<script>
$(document).ready( function () {
    $('#protable').DataTable();
} );
</script>
<script>
  submitRestrict=()=>{
    document.getElementById("finalSubmit").disabled=true;
  }
</script>
</head>
<body>
    <div ><?php include "navbar.php"?></div>
    <div id="fullbody"> 

<div id="content">
<br>
<h3>Edit Ticket</h3> 
<br>
<!-- entry for edit  -->
<?php 
$ticket = $_GET['ticket'];
$tktedit=mysqli_query($connect,"select *,(select customerdetails.name from customerdetails where customerdetails.code = ticket.customer && status!='deleted')as cusname,(select productdetail.productname from productdetail where productdetail.productcode = ticket.product )as proname from ticket where status !='deleted' && ticket='$ticket'");
while($tktshowedi = mysqli_fetch_array($tktedit))
{
?>
<form action="updateticket.php" onSubmit="submitRestrict()" method="post">
<div class="row">
     <div class="col-sm-2"><label>New Ticket No</label></div>:
        <div class="col-sm-3"><input type="text" class="required" autocomplete="off" readonly value="<?php echo $tktshowedi['ticket'] ?>" name="ticket" id="ticketno"></div>
     <div class="col-sm-2"><label>Vehicle No</label></div>:
     <div class="col-sm-3"><select class="required selectpro" id="vehicleNo"  name="vehicleno" required>
              <option value="<?php echo $tktshowedi['vehicleno'] ?>"><?php echo $tktshowedi['vehicleno'] ?></option>
              <?php 
              $vehicle = $tktshowedi['vehicleno'];
$veh=mysqli_query($connect,"select distinct vehicleno from cftdetails where status !='deleted'&& vehicleno!='$vehicle'");
while($vehshow = mysqli_fetch_array($veh))
{
?>
<option value="<?php echo $vehshow['vehicleno'] ?>"><?php  echo $vehshow['vehicleno'] ?></option>
        <?php }?>          
  
              </select></div>
    </div><br>
    <!--  -->
    <div class="row">
    <div class="col-sm-2"><label>Chakka Type</label></div>:
     <div class="col-sm-3"><select class="required " id="chakkaType"  name="chakka" >
              <option value="<?php echo $tktshowedi['chakka'] ?>"><?php echo $tktshowedi['chakka'] ?></option>    
              </select></div>
              <?php 
        $userall=$_SESSION['log'];
        $usper = mysqli_query($connect,"select * from userpermission where username = '$userall'  && filename='readonly'");
while($per=mysqli_fetch_array($usper))
{
          ?>
              <div class="col-sm-2"><label>Vehicle Capacity</label></div>:
              <div class="col-sm-3"><input type="text" class="required" autocomplete="off" name="vehiclecapacity" id="cftValue" <?php echo $per['datashow']==1?"":"readonly" ?> required value="<?php echo $tktshowedi['cft'] ?>"><input type="hidden" class="required" autocomplete="off" name="oricapacity" id="cftValueOri" required value="<?php echo $tktshowedi['ori_cft'] ?>"></div>
                                </div><br>
                                <?php } ?>
            <!--  -->
    <div class="row">
    <div class="col-sm-2"><label> Load Type</label></div>:
              <div class="col-sm-3"><select class="required" style="width:100%" id="loadType" name="weight">
              <?php if($tktshowedi['loadtype']=="Empty"){ 
             echo' <option value="Empty">Empty</option>
              <option value="Load">Load</option> <option>Cancel</option>
              ';}
              if($tktshowedi['loadtype']=="Load"){ 
                echo' <option value="Load">Load</option>
                 <option value="Empty">Empty</option>
                  <option>Cancel</option>';
                 
            }if($tktshowedi['loadtype']=="Cancel"){ 
              echo'  <option>Cancel</option><option value="Load">Load</option>
               <option value="Empty">Empty</option>';
               
          }?>
              </select></div>
    <div class="col-sm-2"><label>Customer</label></div>:
              <div class="col-sm-3"><select class="required selectpro" id="customerAdd" name="customer" required>
              <option value="<?php echo $tktshowedi['customer'] ?>"><?php echo $tktshowedi['cusname'] ?></option>
              <?php 
$cus=mysqli_query($connect,"select * from customerdetails where status !='deleted'");
while($cusshow = mysqli_fetch_array($cus))
{
?>
<option value="<?php echo $cusshow['code'] ?>"><?php  echo $cusshow['name'] ?></option>
        <?php }?>          
  
              </select></div>
              
                
            </div><br>
            <!--  -->
   
    <div class="row">
          <div class="col-sm-2"><label>Product</label></div>: 
              <div class="col-sm-3"><select class="required selectpro" id="productAdd" name="product" readonly>
                <option value="<?php echo $tktshowedi['product'] ?>"><?php echo $tktshowedi['proname'] ?></option>
              <?php 
$cus=mysqli_query($connect,"select * from productdetail where status !='deleted'");
while($cusshow = mysqli_fetch_array($cus))
{
?>
<option value="<?php echo $cusshow['productcode'] ?>"><?php  echo $cusshow['productname'] ?></option>
        <?php }?>          


              </select></div>
              <?php 
        $userall=$_SESSION['log'];
        $usper = mysqli_query($connect,"select * from userpermission where username = '$userall'  && filename='readonly'");
while($per=mysqli_fetch_array($usper))
{
          ?>
              <div class="col-sm-2"><label>Weight</label></div>:
     <div class="col-sm-3"><input type="text"  class="required" autocomplete="off"  id="getweight" name="emptyweight" <?php echo $per['datashow']==1?"":"readonly" ?> value="<?php echo $tktshowedi['emptyweight'] ?>"></div>
     <div class="col-sm-1"><input type="button" class="btn btn-warning" id="getweightbutton" value="Get Weight" style="height:40px;"></div>
    </div><br>
<?php } ?>
    <!--  -->
    <div class="row">
            <div class="col-sm-2"><label id="limitName">Credit Limit</label></div>:
	<div class="col-sm-3"><input type="text" class="required" name="limitvalue" placeholder="Credit Limit"  id="limitValue"readonly ><input type="hidden" class="" name="" placeholder="Credit Limit"  id="advanceLimitValue"readonly></div>
            
              <div class="col-sm-2"><label>Trip No</label></div>:
     <div class="col-sm-3"><input type="text" class="required" autocomplete="off"  name="tripno" value="<?php echo $tktshowedi['tripno'] ?>"><input type="hidden" class="" autocomplete="off"  name="process" value="<?php echo $tktshowedi['process'] ?>"></div>
            </div><br>
            <!--  -->
            <div class="row">
            <div class="col-sm-2"><label>Block Date</label></div>:
	<div class="col-sm-3"><input type="text" class="required" name="blockdate" placeholder="Block Date"  id="blockDate"readonly value="<?php echo $tktshowedi['blockdate'] ?>"></div>
            
              <div class="col-sm-2"><label>Delivery</label></div>:
     <div class="col-sm-3">
	 <!--<input type="text" class="required" autocomplete="off" id="deliveryAdd" name="delivery" value="<?php echo $tktshowedi['delivery'] ?>">-->
	 <select  class="form-control selectpro" autocomplete="off"name="delivery" id="deliveryAdd" required  >
     <option value='<?php echo $tktshowedi['delivery'] ?>'><?php echo $tktshowedi['delivery'] ?></option>
     <?php
	 $del=mysqli_query($connect,"select * from delivery_site where status<>'deleted'");
	 while($siterow=mysqli_fetch_array($del))
	 {
	 
	 ?>
     <option value=<?php echo $siterow['sitename'];?>><?php echo $siterow['sitename'];?></option>
     <?php
	 }
	 ?>
     </select>
	 
	 </div>
            </div><br>
            
            <!--  -->
            <div class="row" style="display:none;">
	
	<div class="col-sm-2"><label>Date</label></div>:
	<div class="col-sm-3"><input type="text" id="dateTkt" class="required" name="datetkt" placeholder="Date" value="<?php echo $tktshowedi['date'] ?>" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?>></div>
  <div class="col-sm-2"><label>Time</label></div>
  <div class="col-sm-3"><input type="text" class="required" name="timetkt" placeholder="Date" value="<?php echo $tktshowedi['time'] ?>" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?>></div>

	
	</div><br>
    
    <!--  -->
    <div class="row">
     
     <div class="col-sm-2"><label>Remarks</label></div>:
     <div class="col-sm-8"><input type="text" class="required" autocomplete="off" name="remark" value="<?php echo $tktshowedi['remarks'] ?>"><input type="hidden" class="required" autocomplete="off" name="financialyear" value="<?php echo $tktshowedi['financialyear'] ?>"></div>
    </div><br>
	
    <!--  -->
	
    <?php 
$cus=mysqli_query($connect,"select * from ticket where status !='deleted' and process !='completed'");
while($cusshow = mysqli_fetch_array($cus))
{
$vehicle = $cusshow['vehicleno'];
?>
<input type="hidden" value="<?php echo $vehicle ?>" class="vehicleallcomp">
<?php
}
?>

    <!--  -->
    <!-- <div class="row">
     <div class="col-sm-2"><label>Date & Time</label></div>:
     <div class="col-sm-3">--><!--</div>
     
    </div><br> -->
    <!--  -->
    <!-- enter the entry list -->
            <input type="button" class="btn btn-success"  style="float:left;margin-left:10px;height:40px;" value="Submit" id="validationButton">
            <input type="hidden" class="btn btn-success" data-toggle="modal" data-target="#addpro" style="float:left;margin-left:10px;height:40px;" value="Submit" id="submitButton">
<br><br>
        
        <!-- Modal footer -->
      
         
       
        
<div class="modal fade" id="addpro">
    <div class="modal-dialog modal-sm">
      <div class="modal-content" style="background-color:rgba(77, 219, 106,0.9)">
      
        <!-- Modal Header -->
        
        
        <!-- Modal body -->
        <div class="modal-body">
          <span style="color:white"><i class="fas fa-check" style="font-size:24px"></i> Ticket Have Been Updated Successfully</span>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="submit" type="button" id="finalSubmit" class="btn btn-warning editsubmit" ><span class="spinner-border spinner-border-sm subspin2" data-dismiss="modal"></span>Ok</button>
        </div>
        
      </div>
    </div>
  </div>
  
<!-- modal for add -->
                  </form>
  <?php 
}
?>
<!-- modal for edit -->
</div>
  <!-- alert5 for digit -->
  <button type="button" class="btn btn-primary vehiclealertno" data-toggle="modal" data-target="#myModal" style="display:none">
      </button>

  <!-- The Modal -->
  <div class="modal fade" id="myModal">
    <div class="modal-dialog modal-lg">
     <div class="alert alert-warning alert-dismissible fade show">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <strong>Vehicle Number Should contain 8 or 10 digit</strong>
  </div>
  </div>
        </div>
<!-- alert -->
<!-- alert5 for vehicle in -->
<button type="button" class="btn btn-primary vehiclealertin" data-toggle="modal" data-target="#vehiclein" style="display:none">
      </button>

  <!-- The Modal -->
  <div class="modal fade" id="vehiclein">
    <div class="modal-dialog modal-lg">
     <div class="alert alert-danger alert-dismissible fade show">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <strong>Vehicle Have Been Already Entered ! Please Check Vehicle No</strong>
  </div>
  </div>
        </div>
        <?php 
$cus=mysqli_query($connect,"select * from ticket where status !='deleted' and process !='completed'");
while($cusshow = mysqli_fetch_array($cus))
{
$vehicle = $cusshow['vehicleno'];
?>
<input type="hidden" value="<?php echo $vehicle ?>" class="vehicleallcomp">
<?php
}
?>
<!-- alert -->
<!-- modal to blockdate -->
<button type="button" class="btn btn-primary" id="alertAdvance" data-toggle="modal" data-target="#advanceLimit" style="display:none">
      </button>

  <!-- The Modal -->
  <div class="modal fade" id="advanceLimit">
    <div class="modal-dialog modal-lg">
     <div class="alert alert-danger alert-dismissible fade show">
    <button type="button" class="close"  data-dismiss="alert">&times;</button>
    <strong>Advance Limit Exceeds</strong>
  </div>
  </div>
  </div>
        
<!-- alert -->
<!-- alert5 for vehicle in -->
<button type="button" class="btn btn-primary" id="vehicleInsideAlert" data-toggle="modal" data-target="#vehiclein" style="display:none">
      </button>

  <!-- The Modal -->
  <div class="modal fade" id="vehiclein">
    <div class="modal-dialog modal-lg">
     <div class="alert alert-danger alert-dismissible fade show">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <strong>Vehicle Have Been Already Entered ! Please Check Vehicle No</strong>
  </div>
  </div>
        </div>
<!-- alert -->
<!-- modal for blockdate -->
<input type="button" class="btn btn-success close"data-toggle="modal"  data-backdrop="static" style="display:none" id="blockButton" data-target="#block" >
<div class="modal" id="block">
    <div class="modal-dialog modal-sm">
      <div class="modal-content bg-warning ">
      
        <!-- Modal Header -->
       
        
        <!-- Modal body -->
        <div class="modal-body ">
         <h4>Reached Block Date</h4>
</div>
        
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary reloadPage"  data-dismiss="modal">Ok</button>
        </div>
        
      </div>
    </div>
  </div>
        
<!-- modal for delete -->
<!-- modal for credit -->

<input type="button" class="btn btn-success close"data-toggle="modal"  data-backdrop="static" style="display:none" id="creditButton" data-target="#creditLimitChk" >
<div class="modal" id="creditLimitChk">
    <div class="modal-dialog modal-sm">
      <div class="modal-content " style="background-color:rgba(237, 140, 123)">
      
        <!-- Modal Header -->
       
        
        <!-- Modal body -->
        <div class="modal-body ">
         <h4>Credit Limit Exceeds</h4>
</div>
        
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary reloadPage"  data-dismiss="modal">Ok</button>
        </div>
        
      </div>
    </div>
  </div>
        <!-- modal to credit -->

<script>
    $('.selectpro').select2({ width: '100%',height:'420px;' });
    
</script>
<script>
  $(document).ready(function(){
    //$("#showcredit").hide();
    $(".subspin").hide();
    $(".subspin2").hide();
$(".addsubmit").click(function(){
$(".subspin").show();
});
$(".editsubmit").click(function(){
$(".subspin2").show();
//$(".subspin2").hide();
});
  });
</script>
</body>
<script src="restriction/ticket.js" type="text/javascript"></script>
<script src="js/editticket.js" type="text/javascript"></script>

</html>