ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/easyEdit.php

<?php require_once('header.php');
$total_p=0;
?>
<script>
	$(document).ready(function() {
$(function(){
    
    $("[data-hide]").on("click", function(){
        // -or-, see below
        $(this).closest("." + $(this).attr("data-hide")).hide()
    })
})
		/***********    For fetching Driver ***********/
		$('#update_all').click(function() {
		        var all_awb = $("input[name='awb_ids[]']")
              .map(function(){return $(this).val();}).get();
              
              var nopics = $("input[name='no_pics[]']")
              .map(function(){return $(this).val();}).get();
              var update_day = $("input[name='update_date[]']")
              .map(function(){return $(this).val();}).get();
              
			var arr_len = all_awb.length;
			var user_id = $('#user_id').val();
		var user_location = $('#user_location').val();
			if(arr_len != 0) {
				$.ajax({
					url: 'get_unique_awb.php',
					type: 'post',
					data: {
						awb_id: all_awb,
						nop:nopics,
						update_day:update_day,
						user_id:user_id,
					    user_location:user_location,
						type:'easyEdit'
						},
					dataType: 'json',
					 beforeSend: function() {
                        // setting a timeout
                        $('#update_fa').removeClass('fa fa-paper-plane');
                        $('#update_txt').text('Please Wait');
                        $('#update_fa').addClass('fa fa-spinner fa-spin');
                    },
					success: function(response) {
					    $('#update_fa').removeClass('fa fa-spinner fa-spin');
						if(response[0]['error'] == 1) {
						    $('#success_msg').text('');
						    var tmsg=response[0]['msg'].length;
						    for(var i=0; i<tmsg;i++)
						    {
						       $('#success_msg').append(response[0]['msg'][i]+"<br>") 
						    }
						    $('#status_success').show();
							$('#status_failure').hide();
						    $('#update_txt').text('Done');
						    $('#update_fa').addClass('fa fa fa-check');
							
						} else {
						    $('#status_success').hide();
							$('#status_failure').show();
							$('#update_txt').text('Submit Again');
						    $('#update_fa').addClass('fa fa-paper-plane');
						}
					}
				});
			} else {
				alert('No Pickup Entries is Selected');
			}
		});
	});

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

	function setText(element) {
	   // alert('set text function');
		var value = $(element).text();
		var userid = $(element).val();
		$("#awb").val(value);
		process(2);
		$("#searchResult").empty();
	}

	function process(dynamic) {
	   // alert(dynamic);
	    var gvalue=dynamic;
	   // console.log(gvalue);
	    var type_id = $('#awb').val();
		var awb_id = $('#i').val();
		var destination = $('#destination').val();
		if(type_id != "") {
			$.ajax({
				type: 'POST',
				url: 'check-awb.php',
				data: {
					id: type_id,
					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 {
						        var ct_day=response[0]['created'];
								var up_day=response[0]['today'];
								ct_day = Date.parse(ct_day);
                                up_day = Date.parse(up_day);
						    /*Confirm Dialog Start*/
								$('#awb').val('');
								if(awb_id == "") {
									var sd = response[0]['id'];
								}else {
									var sd = awb_id + ',' + response[0]['id'];
								}
								
								var k = response[0]['id'];
							if(response[0]['read_status']=='1'){
							    $('#s').text(response[0]['status']);
						    if (ct_day === up_day) {
								array.push(k);
								count++;
                                    $('#myTable').prepend('<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"><input type="number" id="autofocus'+count+'" onkeypress="goToSearch(event)" class="form-control" step="any" name="no_pics[]" value="' + response[0]['pics'] + '"></td><td><input type="date" class="form-control" name="update_date[]" value="' + response[0]['created'] + '"></td><td>' + response[0]['dpcode'] + '</td><td>' + response[0]['customer_name'] + '</td><td class="weight"><input type="hidden" class="form-control" step="any" name="awb_ids[]" value="' + response[0]['id'] + '">' + response[0]['c_weight'] + '</td><td>' + response[0]['destination'] + '</td><td>' + response[0]['client_id'] + '</td></tr>');
                                }else
                                {
                                    var isConfirm=confirm('This pickup entry '+response[0]['ref_no']+' is Back dated('+response[0]['created']+'). Do you want to add..? ');
                                    if(isConfirm)
                                    {
    								array.push(k);
    								count++;
                                    $('#myTable').prepend('<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"><input type="number" id="autofocus'+count+'" onkeypress="goToSearch(event)" class="form-control" step="any" name="no_pics[]" value="' + response[0]['pics'] + '"></td><td><input type="date" class="form-control" name="update_date[]" value="' + response[0]['created'] + '"></td><td>' + response[0]['dpcode'] + '</td><td>' + response[0]['customer_name'] + '</td><td class="weight"><input type="hidden" class="form-control" step="any" name="awb_ids[]" value="' + response[0]['id'] + '">' + response[0]['c_weight'] + '</td><td>' + response[0]['destination'] + '</td><td>' + response[0]['client_id'] + '</td></tr>');
                                    }
                                }
								}else
								{
							        $('#f').text('This AWB Number is Already Picked');
								}
								
                                /*$("#autofocus"+count).focus();*/
                                $('#awb').select();
                                $('#awb').focus();
                                
								$("#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_record").text(tot_records);
		
	}
	function goToSearch(event) {
         var code = event.keyCode || event.which;
             if(code == 13) { //Enter keycode
              $('#awb').focus();
             }
                }
	</script>
	<section class="content-header">
		<div class="content-header-left">
			<h1>Bulk Edit No.of Pieces</h1> </div>
		<div class="content-header-right"> <a href="manifest.php" class="btn btn-primary btn-sm">View All</a> </div>
	</section>
	<section class="content">
		<div class="row">
		    <input type="hidden" id="user_id" value="<?=$clientId?>">
		    <input type="hidden" id="user_location" value="<?=$clientLocation?>">
			<div class="col-md-12">
			    <div class="alert alert-success alert-dismissible fade in" id="status_success" style="display:none;">
		     <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <strong>Success!</strong> Pick Entry Updated !  
		     <p id="success_msg"></p>
		     
		     </div>
				<div class="alert alert-danger alert-dismissible fade in" id="status_failure" style="display:none;"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <strong>Failed!</strong> Please Try Again ! </div>
		<div class="row">
		    
			<div class="col-md-4">
				<label>Total Records Scanned: <span id="tot_record">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" onfocus="this.select()" 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-3">
				<button class="btn btn-sm btn-primary" id="a">Search <i class="fa fa-search-plus"></i></button>
			</div>
			<div class="col-md-3">
			    	<button id='update_all' class="btn btn-danger btn-sm"><span id="update_txt">Update All</span> <i id="update_fa" class="fa fa-paper-plane"></i></button>
			</div>
		</div>
				<div class="box box-info">
					<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>Date Added</th>
									<th>DP Code</th>
									<th>Customer</th>
									<th>Weight</th>
									<th>Destination City</th>
									<th>Client Name</th>
								</tr>
							</thead>
							<tbody id="myTable"> </tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
		
	</section>
	<?php require_once('footer.php'); ?>

Zerion Mini Shell 1.0