<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/singleentryedit.js"></script>
<script src="restriction/single_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;
}
    @media (max-width: 800px) {
        #fullbody
    {
        display:flex;
        flex-wrap: wrap;
    }
        #navbar,#content {
    flex: 100%;
  }
}
</style>
<script>
$(document).ready( function () {
    $('#protable').DataTable();
} );
</script>

</head>
<body>
    
    <div id="fullbody"> 
<div id="navbar" class="bg-info"><?php include "navbar.php"?></div>
<div id="content">
<br>
<h3>Edit Single Entry</h3>
<br>
 <!-- entry for edit  -->
 <form action="updatesingle.php" method="post">
 <?php 
 $ticket = $_GET['ticket'];
$cus=mysqli_query($connect,"select *,(select customerdetails.name from customerdetails where customerdetails.code = single_transaction.customer && status!='deleted')as cusname,(select productdetail.productname from productdetail where productdetail.productcode = single_transaction.product )as proname from single_transaction where status !='deleted' and ticket='$ticket'");
while($cusshow = mysqli_fetch_array($cus))
{
?>
            <div class="row">
              <div class="col-sm-2"><label>Ticket-no</label></div>:
              <div class="col-sm-3"><input class="form-control" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?> value="<?php echo $cusshow['ticket'] ?>" name="ticketedit" required>
              </div>
              <div class="col-sm-2"><label>Customer</label></div>:
              <div class="col-sm-3"><select class="form-control selectpro " name="customeredit" id="customeredit">
              <option value="<?php echo $cusshow['customer'] ?>"><?php echo $cusshow['cusname'] ?></option>
              <?php 
              $customer = $cusshow['customer'];
$cuss=mysqli_query($connect,"select * from customerdetails where single_entry = '1' && status !='deleted'and code !='$customer'");
while($cusshoww = mysqli_fetch_array($cuss))
{
?>
<option value="<?php echo $cusshoww['code'] ?>"><?php  echo $cusshoww['name'] ?></option>
        <?php }?>     
              </select></div>
            </div><br>
            <!--  -->
    
               <div class="row">
     <div class="col-sm-2"><label> vehicle No</label></div>:
     <div class="col-sm-3"><select class="form-control selectpro" name="vehicleedit" id="vehiclenoedit" >
              <option><?php echo $cusshow['vehicleno'] ?></option>
              <?php 
              $vehicle = $cusshow['vehicleno'];
$veh=mysqli_query($connect,"select * from vehiclemaster 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 class="col-sm-2"><label> Trip No</label></div>: -->
     <div class="col-sm-2"><label>Trip</label></div>:
     <div class="col-sm-3"><input type="text" value="<?php echo $cusshow['trip'] ?>" class="form-control" name="tripedit" required></div>
    </div><br>
    <!--  -->
    <div class="row">
    
     <div class="col-sm-2"><label>Material In/Out</label></div>:
              <div class="col-sm-3"><select class="form-control selectpro" name="matinedit">
              
               <?php if($cusshow['matentrytype']=="Material In") {
                    echo "<option>Material In</option>
                    <option>Material Out</option>
                    ";

               }if($cusshow['matentrytype']=="Material Out") {
                echo "<option>Material Out</option>
                <option>Material In</option>
                ";

           } ?>
              
              </select></div>
              <div class="col-sm-2"><label>Material</label></div>:
              <div class="col-sm-3"><select class="form-control selectpro" name="productedit" id="productedit">
              <option value="<?php echo $cusshow['product'] ?>"><?php echo $cusshow['proname'] ?></option>
              <?php 
              $product =$cusshow['product'];
$cusp=mysqli_query($connect,"select * from productdetail where status !='deleted' and productcode !='$product'");
while($cusshowp = mysqli_fetch_array($cusp))
{
?>
<option value="<?php echo $cusshowp['productcode'] ?>"><?php  echo $cusshowp['productname'] ?></option>
        <?php }?>          
              </select>
            <input type="hidden" id="unitconversionedit">
            </div>
    </div>
    
    <!--  -->
    
    <!-- <div class="row"> -->
              
              <!-- <div class="col-sm-2"><label>Sales type</label></div>:
     <div class="col-sm-3"><select class="form-control" name="salestypeedit">
         <option><?php echo $cusshow['salestype'] ?></option>
         <option>Site</option>
         <option>Cash</option>
         <option>Credit</option>
         <option>Contract</option>
     </select></div> -->

              <input type="hidden" class="form-control" value ="<?php echo $cusshow['entrydate'] ?>"  name="entrydateedit">
              <input type="hidden" class="form-control" value ="<?php echo $cusshow['entrytime'] ?>"  name="entrytimeedit">
<!-- </div> -->
              <!-- <br> -->
            <!--  -->
            <div class="row">
     <!-- <div class="col-sm-3"><label>Entry Date & Time</label></div>: -->
     
    </div><br>
    <!--  -->
    <div class="row">
     <div class="col-sm-2"><label>Empty Weight</label></div>:
     <div class="col-sm-3"><input type="text" value="<?php echo $cusshow['emptyweight'] ?>"  class="form-control emptyweightedit" name="emptyweightedit" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?> required>  <input type="button" class="btn btn-warning emptybutedit" value="GetWeight" style="height:40px;margin-top:5px"></div>
     
     <div class="col-sm-2"><label>Load Weight</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control getloadweightedit" value=" <?php echo $cusshow['loadweight'] ?>" name="loadweightedit" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?> required>   </div>
     <div class="col-sm-1"><input type="button" class="btn btn-warning loadbutedit" value="GetWeight"  style="height:40px;"></div>
    </div><br>
    <!--  -->
    
    <div class="row">
     <div class="col-sm-2"><label>Nett Weight</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" value=" <?php echo $cusshow['netweight'] ?>" name="netweightedit" id="netweightedit" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?> required></div>
     <div class="col-sm-2"><label>Quantity</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" value=" <?php echo $cusshow['quantity'] ?>" name="quantityedit" id="netqtyedit" required><input type="hidden" class="form-control" value=" <?php echo $cusshow['quantityori'] ?>" name="quantityeditori" id="netqtyoriedit"></div>
    </div><br>
    <!--  -->
    <div class="row">
     <!-- <div class="col-sm-2"><label>Adjustment</label></div>:
     <div class="col-sm-3"><input type="hidden" class="form-control" value=" <?php echo $cusshow['adjustment'] ?>" name="adjustmentedit"></div> -->
     <div class="col-sm-2"><label>Delivery Place</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" value="<?php echo $cusshow['delivery'] ?>" name="deliveryedit" required></div>
     <div class="col-sm-2"><label>Remarks</label></div>:
     <div class="col-sm-3"><input type="text"value=" <?php echo $cusshow['remark'] ?>" class="form-control" name="remarkedit"><input type="hidden"value=" <?php echo $cusshow['financialyear'] ?>" class="form-control" name="financialyearedit"></div>
    </div><br>
    <input type="button" class="btn btn-success"data-toggle="modal" data-target="#editpro" value="Update">
    <!--  -->
    
    
    
    
    <!--  -->
    <!-- entry for edit  -->           

        </div>
        
        <!-- Modal footer -->
        
          
 
        <!-- modal for add -->
<div class="modal fade" id="editpro">
    <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> Single-Entry Transaction Have Been Updated Successfully</span>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="submit" type="button" class="btn btn-warning" >Ok</button>
        </div>
        
      </div>
    </div>
  </div>
  
<!-- modal for add -->
     
</form>
<!-- modal for edit -->
      <?php }?>
</div>
<script>
    $('.selectpro').select2({ width: '100%',height:'420px;' });
    
</script>
</body>
</html>