<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/firsttrans.js"></script>

<script src="restriction/firsttrans_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;
}
#menu1 input
{
    height:30px;
}
.row input
{
    height:30px;
}
#menu1 select
{
    height:35px;
    /* padding-bottom:8px; */
}
#ticketFetch
{
width:250px;
float:right;
margin-bottom:20px;
}
    @media (max-width: 800px) {
        #fullbody
    {
        display:flex;
        flex-wrap: wrap;
                 
    }
        #navbar,#content {
    flex: 100%;
  }
}
</style>
<script>
$(document).ready( function () {
    $('#protable').DataTable();
} );
</script>
<script>
$(document).ready(function(){
  $("#ticketselect").on('change',function(){
    var ticket = $(this).val();
    //alert('hai');
    $.ajax({
    type:'POST',
    url:'ajaxpath/overallfetch-first.php',
    data:{ticket:ticket},
    success:function(a){
    //  alert(a);
     // $("#showquantity-with-color").css("display","block");
      //$("#vehicleno").val(a);
      var renderdata = a.split("||");
      $("#vehicleno").val(renderdata[0]);
      $("#customeradd").val(renderdata[1]);
      $("#customername").val(renderdata[2]);
      $("#vehiclenameadd").val(renderdata[3]);
      $("#productname").val(renderdata[4]);
      $("#productadd").val(renderdata[5]);
      $("#weightadd").val(renderdata[6]);
      $("#estqtyadd").val(renderdata[7]);
      $("#tripsheetadd").val(renderdata[8]);
      //alert(a);
      $("#remarkadd").css("border","1px solid red");
      $("#getweightadd").css("border","1px solid red");
      $("#remarkadd").css("box-shadow","2px 1px 3px 1px rgba(241, 70, 70, 0.979)");
      $("#getweightadd").css("box-shadow","2px 1px 3px 1px rgba(241, 70, 70, 0.979)");

   }
                });
  });
});

</script>
</head>
<body>
    
    <div id="fullbody"> 
<div id="navbar" class="bg-info"><?php include "navbar.php"?></div>
<div id="content">
<br>
<h3>First Transaction</h3>
<br>

<!-- table -->
<div>
<?php 
        $userall=$_SESSION['log'];
        $usper = mysqli_query($connect,"select * from userpermission where username = '$userall'  && filename='firsttransaction'");
while($per=mysqli_fetch_array($usper))
{
          ?>
          <span id="print" style="display:none"><?php echo $per['dataprint'] ?></span>
<span id="edit" style="display:none"><?php echo $per['dataedit'] ?></span>
  <!-- tab for rate -->
  <ul class="nav nav-pills" role="tablist">
  <li class="nav-item">
  <?php if($per['dataadd'] =='1'){ ?>    <a class="nav-link active " data-toggle="pill" href="#menu1">Entry</a>
    </li><?php }?>
    <li class="nav-item">
      <a <?php if($per['dataadd'] !='1'){ echo 'class="nav-link active"'; }else {echo 'class="nav-link"';}?>   data-toggle="pill" href="#home">List</a>
    </li>
  </ul>

  <!-- Tab panes -->
  <div class="tab-content" style="border:1px solid lightgrey">
    <!--  -->
        <!-- entrydiv -->
        <div id="menu1" <?php if($per['dataadd'] !='1'){ echo 'class="container tab-pane fade "'; }else {echo 'class="container tab-pane active"';}?>><br>
    <!-- enter the entry list -->
    <form action="insertfirsttransaction.php" id="form1" method="post">
    <div class="row">
              <div class="col-sm-2"><label>Vehicle/Ticket-no</label></div>:
              <div class="col-sm-3">
                <select class="form-control selectpro" id="ticketselect" name="ticketadd">

              <option>--Select ticket--</option>
              <?php 
$tktedit=mysqli_query($connect,"select ticket,vehicleno from ticket where status !='deleted'&& firsttrans!='1' order by concat(date,time) desc");
while($fstktshowedi = mysqli_fetch_array($tktedit))
{
  $frsttkt = $fstktshowedi['ticket'];
  $vehtkt = $fstktshowedi['vehicleno'];
?>
<option value="<?php echo $frsttkt;  ?>"><?php echo $frsttkt;  ?>/<?php echo $vehtkt;  ?></option>
<?php }?>
              </select></div>
              <div class="col-sm-2"><label> vehicle No</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" autocomplete="off" id ="vehicleno"name="vehicleadd" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?>></div>
            </div><br>
            <!--  -->
    <!-- div for ajax -->
            <div class="totaldiv">
    
    <div class="row">
              <div class="col-sm-2"><label>Customer</label></div>:
              <div class="col-sm-3"><input class="form-control selectpro" id="customername" name="customerad"><input type="hidden" class="form-control selectpro" id="customeradd" name="customeradd">
              
              
              </div>
              <div class="col-sm-2"><label>Material</label></div>:
              <div class="col-sm-3"><input type="hidden" class="form-control " id="productadd" name="productadd">
              <input class="form-control"  id="productname" name="productad">
</div>
              <!--  -->
              <!-- <div class="col-sm-2"><label>vehicle-Name</label></div>: -->
     <!-- <div class="col-sm-3"> -->
       <input type="hidden" class="form-control" autocomplete="off" id="vehiclenameadd" name="vehiclenameadd"></div>
            <!-- </div><br> -->
            <!--  -->
            
    <!--  -->
    <!-- <div class="row"> -->
              <!-- <div class="col-sm-2"><label>Material</label></div>:
              <div class="col-sm-3"><select class="form-control selectpro" id="productadd" name="productadd">
              <option>--Select Product--</option>
              
              </select></div> -->
              
            <!-- </div><br> -->
            <!--  -->
            

    <!-- <div class="row">
     <div class="col-sm-2"><label>Est Quantity</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" autocomplete="off" id="estqtyadd" name="estquantityadd"></div>
     <div class="col-sm-2"><label>Trip Sheet No</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" autocomplete="off" id="tripsheetadd" name="tripnoadd"></div>
    </div><br> -->
    <input type="hidden" class="form-control" autocomplete="off" id="estqtyadd" name="estquantityadd">
    <input type="hidden" class="form-control" autocomplete="off" id="tripsheetadd" name="tripnoadd">
    <!--  -->
<!-- </div> --><br>
<div class="row">
<div class="col-sm-2"><label>(Load/Empty)</label></div>:
              <div class="col-sm-3">
                 <input class="form-control" id="weightadd"  name="salestypeadd">
              
               
                          
            </div>
     <div class="col-sm-2"><label>Weight</label></div>:
     <div class="col-sm-3"><input type="text"  class="form-control" autocomplete="off"  id="getweightadd" name="weightadd" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?> ></div>
     <div class="col-sm-1"><input type="button" class="btn btn-warning" id="getweightbutton" value="Get Weight" style="height:40px;"></div>
    </div><br>
   <!-- div for ajax -->
   <div class="row">
	<?php 
	$datetime = mysqli_query($connect,"select CURRENT_DATE()as dat,CURRENT_TIME()as tme ");
while($datime = mysqli_fetch_array($datetime))
{
	?>
	<div class="col-sm-2"><label>Date</label></div>
	<div class="col-sm-3"><input type="text" class="form-control" name="datefrst" placeholder="Date" value="<?php echo $datime['dat'] ?>" <?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="form-control" name="timefrst" placeholder="Date" value="<?php echo $datime['tme'] ?>" <?php $user=$_SESSION['log']; if($user != 'admin'){ echo "readonly";} ?>></div>
	<?php }?>
	</div><br>
    <div class="row">
     <div class="col-sm-2"><label>Remarks</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" autocomplete="off" id="remarkadd" name="remarkadd"></div>
     <!-- <div class="col-sm-2"><label>Date & Time</label></div>:
     <div class="col-sm-3"><input type="text" class="form-control" autocomplete="off" value="<?php echo date('Y-m-d') ?>" name="dateadd"></div> -->
     <div class="col-sm-1"> <input type="button" class="btn btn-success" data-toggle="modal" data-target="#addpro" style="float:left;margin-left:10px;height:40px;" value="Submit" id="firstbutadd"></div>
     <input type="hidden" class="form-control" autocomplete="off" value="<?php echo date('Y-m-d') ?>" name="dateadd">
    </div><br>
    <!--  -->
    
    
    <!--  -->
    <!-- enter the entry list -->
           
<br><br>
            <!-- entry div over  -->
        </div>
</div>
  <!-- modal for add confirm -->
  <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> First Transaction Have Been Generated Successfully</span>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="submit" type="button" id="addsubmit" class="btn btn-warning" ><span class="spinner-border spinner-border-sm subspin2"></span>Ok</button>
        </div>
</form>
      </div>
    </div>
  </div>
  
<!-- modal for add confirm -->
    <!--  -->
    <div id="home" <?php if($per['dataadd'] !='1'){ echo 'class="container tab-pane active "'; }else {echo 'class="container tab-pane fade"';}?>><br>
    <!-- entry list div -->
    <input type="text" id="ticketFetch" class="form-control" placeholder="Search">
    <table class="table table-bordered table-hover " style="border:1px solid lightgrey" id="protabl">
    <thead >
<tr>
  <th>sno</th>
    <th>Ticket</th>
    <th>Vehicle No</th>
    <th>Customer</th>
    <th>Weight</th>
    <?php if($per['dataprint'] =='1'){ ?>  <th>Print</th><?php }?>
    <?php if($per['dataedit'] =='1'){ ?><th>Edit</th><?php }?>
    
</tr>

    </thead>
    <tbody id="tableTbody">
    <?php 
$proshow=mysqli_query($connect,"select first_transaction.ticket,first_transaction.vehicleno,first_transaction.weight,first_transaction.id,(select customerdetails.name from customerdetails where customerdetails.code = first_transaction.customer )as cusname from first_transaction where first_transaction.status !='deleted'  order by id desc limit 200");
while($proshowshow = mysqli_fetch_array($proshow))
{
	
?>
        <tr>
        <td><?php echo $proshowshow['id'] ?></td>
        <td><?php echo $proshowshow['ticket'] ?></td>
    <td><?php echo $proshowshow['vehicleno'] ?></td>
    <td><?php echo $proshowshow['cusname'] ?></td>
    <td><?php echo $proshowshow['weight'] ?></td>
    <?php if($per['dataprint'] =='1'){ ?><td><a href="billslipfirst.php?print=<?php echo $proshowshow['ticket'] ?> " target="_blank"><i class="fas fa-print"></i></a></td><?php }?>
    <?php if($per['dataedit'] =='1'){ ?>    <td><a href="firsttransedit.php?edit=<?php echo $proshowshow['ticket'] ?>"><i class="fas fa-edit edit"></i></a></td><?php }?>
            <!-- <td><a data-toggle="modal" data-target="#dele<?php echo $proshowshow['ticket'] ?>"><i  class="fas fa-trash-alt dele"></a></i></td> -->
        </tr>
        
     <?php }}?>   
    </tbody>
</table>
    <!-- entry div table -->
    </div>


              
        <!--overall entry div over  -->
        
        
    </div>
   <!--  -->
  </div>
</div>

  <!-- tab for rate -->
</div>
<!-- tab for entry area-->
      
<!-- modal for delete -->
<!-- The Modal -->
<div class="modal fade" id="prd-1">
    <div class="modal-dialog modal-sm">
      <div class="modal-content" style="background-color:rgba(247, 2, 80,0.9)">
      
        <!-- Modal Header -->
        
        
        <!-- Modal body -->
        <div class="modal-body" >
         Are You Sure Want To Delete !.
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
        <a href="#?dele=1"><button type="button" class="btn btn-success" data-dismiss="modal">Yes</button></a>
          <button type="button" class="btn btn-warning" data-dismiss="modal">No</button>
        </div>
        
      </div>
    </div>
  </div>
<!-- ,odal for delete -->
<!-- table -->

<!-- alert5 -->
<button type="button" class="btn btn-primary alerterror" data-toggle="modal" data-target="#weighterror" style="display:none">
      </button>

  <!-- The Modal -->
  <div class="modal fade" id="weighterror">
    <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>Please Chk The Weight Machine</strong>
  </div>
  </div>
        </div>
<!-- alert -->

<!-- main-content-div -->
</div>
<!-- main-content-div -->
</div>
<script>
    $('.selectpro').select2({ width: '100%',height:'420px;' });
    
</script>
<script>
  $(document).ready(function(){
    $(".subspin").hide();
    $(".subspin2").hide();
$("#addsubmit").click(function(){
$(".subspin2").show();
});
$("#editsubmit").click(function(){
$(".subspin").show();
//$(".subspin2").hide();
});
  });
</script>

</body>