ok

Mini Shell

Direktori : /proc/thread-self/root/home2/selectio/public_html/lilyexpresslive/software/admin/
Upload File :
Current File : //proc/thread-self/root/home2/selectio/public_html/lilyexpresslive/software/admin/manifest-add.php

<?php require_once('header.php');
$total_p=0;
?>
<script>
    $(document).ready(function(){
            /***********    For fetching Driver ***********/             
    $('#transport_name').on('change',function(){
          var transport_name=$(this).val();
           if(transport_name!=''){
             // alert(transport_name);
                $.ajax({
                type:'POST',
                url:'get_driver_selection.php',
                data:{name:transport_name},
                success:function(html){
                     //alert(html);
                    $('#driver_id').html(html);
    
                }
            }); 
           }
       });
        $('#add_manifest').click(function(){
           var transport_name=   $('#transport_name').val();
            var entry_date=   $('#entry_date').val();
            var send_through=   $('#send_through').val();
             var destination=  $('#destination').val();     
              var origin=  $('#origin').val();
              var driver_id=  $('#driver_id').val();
       
            var checkValues = $('input[name=checkboxlist]:checked').map(function()
            {
                return $(this).val();
            }).get();
            alert(driver_id);
            var arr_len=array.length;
             if(arr_len!=0){
          $.ajax({
        url: 'assign_manifest.php',
        type: 'post',
        data: {awb_id:array,t_name:transport_name,e_date:entry_date,send:send_through,dest:destination,orig:origin,driver_id:driver_id},
        dataType: 'json',
        success: function(response)
        {
         // alert(response);
            if(response[0]['resp']==1)
            {
            var mani_id =response[0]['manifest_id'];
                $('#success_msg').show();
                
                $("#success_url").attr("href", "manifest-pickup-entry.php?type='manifest'&id="+mani_id);
            }
            else{
               alert('Failed To Add !!');
               location.reload();
            }
        }

    });
        }
            else{
                alert('No AWB Number is Selected');
            }
        });
    });
</script>

<script>
$(document).ready(function(){
 
  // Initialize select2
  $("#destination").select2();
});
</script>


<script>
const array=[];
var count=0;
    $(document).ready(function(){
          /***********    For fetching customer address and phone number ***********/
          
         $('#awb').keyup(function(){
             process(1);

       });
    });
    function setText(element){

    var value = $(element).text();
    var userid = $(element).val();
    $("#awb").val(value);
     process(2);
    $("#searchResult").empty();
}
    function process(dynamic)
    {
        var gvalue=dynamic;
           var cust_id=$('#awb').val();
           var awb_id=$('#i').val();
           var destination=  $('#destination').val();     
           if(cust_id!=""){
                $.ajax({
                  type:'POST',
                  url:'check-awb.php',
                  data:{id:cust_id,destination:destination,gvalue:gvalue},
                   dataType: 'json',
                  success:function(response){
                       $('#f').text('');
                       $('#s').text('');
                     if(response[0]['id']==0)
                     {
                         $('#s').text(response[0]['status']);
                         $('#f').text('');
                         $("#searchResult").empty();
                     }
                     if(response[0]['status']==2)
                     {
                         var len = response.length;
                        $("#searchResult").empty();
                    for( var i = 0; i<len; i++){
                        var id = response[i]['id'];
                        var awb_number = response[i]['ref_no'];

                        $("#searchResult").append("<li value='"+awb_number+"'>"+awb_number+"</li>");

                    }
                    $("#searchResult li").bind("click",function(){
                        setText(this);
                    });

                     }
                     if(response[0]['status']=="Success")
                     {
                        
                         if(array.includes(response[0]['id'])){
                             $('#f').text('AWB Number Already Added');
                              $('#s').text('');
                              $("#searchResult").empty();
                         }
                     else{
                          /*Confirm Dialog Start*/
                          if(destination==response[0]['destination'])
                          {
                            $('#awb').val('');
                            
                         if(awb_id=="")
                         {
                         var sd=response[0]['id'];
                         }
                         else
                         {
                              var sd=awb_id+','+response[0]['id'];
                         }
                         $('#s').text(response[0]['status']);
                         var k=response[0]['id'];
                         array.push(k);
                         count++;
                         $('#myTable').append('<tr id='+count+'><td><button class="btn btn-sm btn-danger" onclick="remove('+k+','+count+')">X</button></td><td>' + response[0]['ref_no'] + '</td><td class="pics">' + response[0]['pics'] + '</td><td>' + response[0]['dpcode'] + '</td><td>' + response[0]['customer_name'] + '</td><td class="weight">' + response[0]['c_weight'] + '</td><td>' + response[0]['destination'] + '</td><td>' + response[0]['client_id'] + '</td><td>' + response[0]['created'] + '</td></tr>');
                        $("#searchResult").empty();
                          }
                          else
                          {
                             var des= response[0]['destination'];
                            var r = confirm("Destination City ("+des+") is Different...If You Want To Add?");
                            if (r == true) 
                            {
                                    $('#awb').val('');
                                        
                                     if(awb_id=="")
                                     {
                                     var sd=response[0]['id'];
                                     }
                                     else
                                     {
                                          var sd=awb_id+','+response[0]['id'];
                                     }
                                     $('#s').text(response[0]['status']);
                                     var k=response[0]['id'];
                                     array.push(k);
                                     count++;
                                     $('#myTable').append('<tr id='+count+'><td><button class="btn btn-sm btn-danger" onclick="remove('+k+','+count+')">X</button></td><td>' + response[0]['ref_no'] + '</td><td class="pics">' + response[0]['pics'] + '</td><td>' + response[0]['address'] + '</td><td>' + response[0]['phone'] + '</td><td class="weight">' + response[0]['c_weight'] + '</td><td>' + response[0]['destination'] + '</td><td>' + response[0]['client_id'] + '</td><td>' + response[0]['created'] + '</td></tr>');
                                    $("#searchResult").empty();
                            } else 
                            {
                                $("#awb").val('');
                               $("#searchResult").empty();
                            }
                          }
                          total_summary();
                           /*Confirm Dialog End*/
                          }
                     }
                     
                  }
               });
           }
    }
 </script>
 <script>
function remove(k,count)
{
   var len= array.length;
   len=len-1;
   for(var i=len;i>=0;i--)
   {
       if(array[i]==k)
       {
          var i_val=i;
          array.splice(i_val, 1);
          $('table#my_data tr#'+count).remove();
          break;
       }
   }
   total_summary();
}


function total_summary()
{
    var no_pics = 0;
    var no_weights = 0;
    var tot_records = $('#my_data tr').length-1;
// iterate through each td based on class and add the values
if(tot_records>=1){
$(".pics").each(function() {

    var value = $(this).text();
    // add only if the value is number
    if(!isNaN(value) && value.length != 0) {
        no_pics += parseFloat(value);
    }
  
});
$(".weight").each(function() {

    var value1 = $(this).text();
    // add only if the value is number
    if(!isNaN(value1) && value1.length != 0) {
        no_weights += parseFloat(value1);
        no_weight=no_weights.toFixed(2);
    }
   
});
}
else{
    no_pics=0;
    no_weight=0;
    tot_records=0;
    
    
}
 $("#tot_pics").text(no_pics); 
$("#tot_weight").text(no_weight); 
   $("#tot_record").text(tot_records);
}
    </script>
    


<section class="content-header">

	 <div class="row">
		<div class="col-md-6" style="text-align: center;">
			<h4><i class="fa fa-info-circle"></i> Create Manifest</h4>
		</div>
		<div class="col-md-4" style="text-align: left;">
		    <a href="manifest.php" class="btn btn-info btn-sm">View All Manifest</a>
		</div>
	</div>

</section>

<section class="content">
    
    <div class="row">
	    <div class="col-md-3">
	        <label for="to">Select Origin</label>
		  <select class="form-control select2" name="origin" id="origin" required>
							        <option value='0'>Select Origin</option>

							        <?php
									$statement = $pdo->prepare("SELECT location FROM tbl_user GROUP BY location");
									$statement->execute();
									$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
									foreach ($result as $row) {
										?>
										<option value="<?php echo $row['location']; ?>"  <?php if($row['location']=='Bangalore') { echo 'selected'; } ?>><?php echo $row['location']; ?></option>
										<?php
									}
									?>
							    </select>
		 </div>
		 <div class="col-md-3">
		      <label for="to">Select Destination</label>
		  <select class="form-control select2" name="destination" id="destination" required>
							       <option value='0'>Select Destination</option>
							         <?php
									$statement = $pdo->prepare("SELECT destination_city FROM `tbl_customer` GROUP BY destination_city");
									$statement->execute();
									$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
									foreach ($result as $row) {
										?>
										<option value="<?php echo $row['destination_city']; ?>" <?php if(isset($_POST['destination'])){ if($_POST['destination']==$row['destination_city']){ echo'selected';}} ?>><?php echo $row['destination_city']; ?></option>
										<?php
									}
									?>
							    </select>
		 </div>
	    <div class="col-md-3">
	                            <label for="to">Shipping Mode</label>
		                        <select class="form-control select2" name="send_through" id="send_through" required>
							       <!--<option>Select Sending Through</option>-->
							        <option value="air">Air</option>
							        <option value="road">Road</option>
							    </select>
		 </div>
		 	<div class="col-md-3">
	    	    <label for="to">Entry Date</label>
		         <input type="date" autocomplete="off" class="form-control" name="entry_date" value="<?php echo date("Y-m-d") ?>"  id="entry_date" required>
		    </div>
		 <!--<input type="hidden" name="destin" id="destin" value="<?php echo $dest ?>">-->
	</div><br>
	
		<div class="row">
	    
		 <div class="col-md-3">
		     <label for="to">Select Transport</label>
         <select class="form-control select2" name="transport_name" id="transport_name" required>
							       <option value='0'>Select Transport</option>
							         <?php
									$statement = $pdo->prepare("SELECT transport_name FROM `tbl_transport` GROUP BY transport_name");
									$statement->execute();
									$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
									foreach ($result as $row) {
										?>
										<option value="<?php echo $row['transport_name']; ?>"><?php echo $row['transport_name']; ?></option>
										<?php
									}
									?>
							    </select>
		 </div>
		  <div class="col-md-3">
		      <label for="to">Select Driver</label>
                             <select class="form-control select2" name="driver_id" id="driver_id" required>
							       <option value='0'>Select Driver</option>
							    </select>
		    </div>
		    <div class="col-md-3">
	    	    <label for="to">Vechicle Number</label>
		         <input type="text" autocomplete="off" class="form-control" name="vechicle_no" id="vechicle_no" placeholder="Enter Vechicle No" >
		    </div>
	    </div>
    
    <div class="callout callout-success" id="success_msg" style="display:none;">
				<p>Manifest Added  SuccessFully !!</p>
					<a href="manifest-pickup-entry.php?type='manifest'&id=" id="success_url" ><button class="btn btn-md btn-primary">View Manifest</button></a>
			   </div>
	<div class="row">
		<div class="col-md-12">
			<div>
				<div class="box-body table-responsive">
					<table id="my_data" class="table table-bordered table-striped">
						<thead>
							<tr>
								<th>Action</th>
								<th>AWB Number</th>
								<th>No.Of Pics</th>
								<th>DP Code</th>
								<th>Customer </th>
								<th>Weight</th>
								<th>Destination City</th>
								<th>Client Name</th>
								<th>Date</th>
							</tr>
						</thead>
						<tbody id="myTable">
						 
														
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	
	<div class="row">
	     <div class="col-md-4">
		  <label>Total Records Scanned: <span id="tot_record">0</span> </label>
		 </div>
	    	<div class="col-md-4">
		 <label>Total Weights: <span id="tot_weight">0</span> </label>
		 </div>
		 <div class="col-md-4">
         <label>Total Pieces: <span id="tot_pics">0</span> </label>
		 </div>
	    </div>
	    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-4">
                                   <input placeholder="Enter AWB Number" type="text" class="form-control" name="awb" id="awb" ><br>
                                   <ul id="searchResult"></ul>
                                    <center><span style="color:green;" id="s"></span><span style="color:red;" id="f"></span></center>
                                    <input type="hidden" class="form-control" name="i" id="i" >
                                    
	    </div>
	    <div class="col-md-4">
	        <button  class="btn btn-sm btn-primary"id="a">Add</button>
	    </div>
	</div>
	<br>
		<div class="content-footer-right" style="margin-left:45%">
		<button id='add_manifest' class="btn btn-primary btn-sm">Add Manifest</button>
	</div>
</section>

<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Delete Confirmation</h4>
            </div>
            <div class="modal-body">
                <p>Are you sure want to delete this item?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <a class="btn btn-danger btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>


<?php require_once('footer.php'); ?>

Zerion Mini Shell 1.0