ria/app/Views/inwardgateregister.php
2024-08-21 03:51:35 +00:00

952 lines
31 KiB
PHP
Executable File

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.3.4/jquery.inputmask.bundle.min.js"></script>
<script src="<?php echo base_url() ?>public/assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
<script src="<?php echo base_url() ?>public/assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
<style>
#MaterialRcvdDate {
text-align: left;
}
#InvoiceDate {
text-align: left;
}
</style>
<style>
.autocomplete-suggestion {
cursor: pointer;
background-color: skyblue;
/* background-color: darkgrey; */
outline: 1px solid slategrey;
}
</style>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script>
<script>
$(document).ready(function() {
$("#PONO").select2();
$("#TransporterId").select2();
$('#DriverName').autocomplete({
onSearchStart: function(query) {
//alert(query);
$('#DriverName').autocomplete("option", "minLength", 0);
},
serviceUrl: "<?php echo base_url(); ?>drivernameautocomplete",
onSelect: function(suggestion) {
var data = suggestion.DriverName;
}
});
$('#DriverMobileNumber').autocomplete({
serviceUrl: "<?php echo base_url(); ?>drivermobileautocomplete",
params: {
driverName: function() {
return $('#DriverName').val(); // Pass the value of the DriverName input field
}
},
onSearchStart: function(query) {
$('#DriverMobileNumber').autocomplete("option", "minLength", 0);
},
onSelect: function(suggestion) {
var data = suggestion.DriverMobileNumber;
}
});
$("#InvoiceDate").datepicker({
maxDate: 'now',
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
yearRange: '-100:+0'
});
$("#MaterialRcvdDate").datepicker({
maxDate: 'now',
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
yearRange: '-100:+0'
}).datepicker("setDate", new Date());
});
//jquery for vechicle masking
// $(document).ready(function(){
// Inputmask("A{2,3} 9{1,2} A{1,2} 9{4}").mask($("#VehicleNo"));
// });
</script>
<style>
.modal {
text-align: center;
padding: 0 !important;
}
.modal:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -4px;
}
.modal-dialog {
display: inline-block;
text-align: left;
vertical-align: middle;
}
.select2 {
width: 100% ! important;
}
.num {
text-align: right;
}
.dataTables_wrapper {
padding-bottom: 0px;
}
</style>
<div class="content-wrapper" style="min-height:537px;">
<section class="content-header">
<h5>
<div class="pull-right hidden-xs">
<b>
<div id="wizard_clock"></div>
</b>
</div>
</h5>
<h1>
<center> Inward Gate Register </center>
</h1>
</section>
<section class="content" style="margin: 15px;"><br />
<div style="border:2px solid #333;">
<form action="<?php echo base_url() ?>SaveIGR" method="post" enctype="multipart/form-data">
<div class="row"><br /><br />
<div id="content"> </div>
<div class="col-md-12">
<div class="col-md-6">
<div style="display: flex; justify-content: space-between; align-items: center;">
<label>Select Purchase Order No <span style="color:red; font-size: 15px;">*</span></label>
<a id="printLink" data-toggle="tooltip" href="" target="new" style="text-align: right;">
<i class="fa fa-print" data-toggle="tooltip" title="Click here to Print the Purchase Order details"></i>
</a>
</div>
<?php
$options = array("-1" => 'Purchase Order No');
if (!empty($PO_NO)) {
//print_r($PO_NO);
foreach ($PO_NO as $SI) :
$options[$SI->PONO] = $SI->PONO . '-' . $SI->SupplierName;
$PONO = $SI->PONO;
endforeach;
}
echo form_dropdown('PONO', $options, set_value('PONO'), 'id="PONO"', 'class="form-control select2"', 'required="true"');
?>
<span class="help-block"></span>
</div>
<input type="hidden" name="hiddenIsOpenOrder" id="hiddenIsOpenOrder" />
<div class="col-md-6">
<label>Supplier Name </label>
<div class="form-group">
<?php
$data = array('name' => 'SupplierName', 'value' => set_value('SupplierName'), 'id' => 'Sup', 'class' => 'form-control', 'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-12" style="margin: 10px 0;">
<div class="col-md-4">
<label>Invoice Number <span style="color:red; font-size: 15px;">*</span><!-- Delivery Challan/Inv No --></label>
<?php
$data = array('name' => 'InvoiceNo', 'value' => set_value('InvoiceNo'), 'id' => 'InvoiceNo', 'class' => 'form-control', 'required=>"true"', 'autocomplete'=>'off'); // ,'onkeypress'=>'return isNumberKey(event);' );
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Invoice Date <span style="color:red; font-size: 15px;">*</span><!-- Delivery Challan/Inv Date --></label>
<?php
$data = array('name' => 'InvoiceDate', 'value' => set_value('InvoiceDate'), 'id' => 'InvoiceDate', 'class' => 'form-control num', 'required' => 'true', 'autocomplete'=>'off');
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Material Received Date <span style="color:red; font-size: 15px;">*</span></label>
<?php
$data = array('name' => 'MaterialRcvdDate', 'value' => set_value('MaterialRcvdDate'), 'id' => 'MaterialRcvdDate', 'class' => 'form-control num', 'required' => 'true', 'autocomplete'=>'off');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-12" style="margin: 10px 0;">
<div class="col-md-3">
<label>Vechicle Number</label>
<?php
$data = array('name' => 'VehicleNo', 'value' => set_value('VehicleNo'), 'id' => 'VehicleNo', 'class' => 'form-control', 'maxlength' => '20', 'autocomplete'=>'off');
echo form_input($data);
?>
<!-- <span pattern="" required="true"></span> -->
</div>
<div class="col-md-3">
<label>Transporter Name</label>
<?php
$option = array(0 => 'Transporter Name');
if (!empty($transporter)) {
foreach ($transporter as $opt) :
$option[$opt->id] = $opt->name;
endforeach;
}
echo form_dropdown('TransporterId', $option, set_value('TransporterId'), 'id="TransporterId"', 'class="form-control select2"');
?>
</div>
<div class="col-md-3">
<label>Driver Name</label>
<?php
$data = array('name' => 'DriverName', 'value' => set_value('DriverName'), 'id' => 'DriverName', 'class' => 'form-control', 'maxlength' => '50', 'autocomplete'=>'off');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<label>Driver Mobile Number</label>
<?php
$data = array('name' => 'DriverMobileNumber', 'value' => set_value('DriverMobileNumber'), 'id' => 'DriverMobileNumber', 'class' => 'form-control', 'maxlength' => '50', 'autocomplete'=>'off');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-12" style="margin-top: 10px;">
<input type="hidden" name="hideIGRStatus" id="hideIGRStatus" value="0" />
</div>
<div class="row">
<div class="col-md-12">
<table id="Inwardgateregistertable" class="table table-bordered table-hover editabletable IGR_Line" style="background-color:#fff;font-size:12px;">
<thead style="background-color:#ddf">
<tr>
<th>#</th>
<th>Item Code</th>
<th>Material</th>
<th>UOM</th>
<th>Ordered Quantity</th>
<th>Received Quantity</th>
<th>Balance Quantity</th>
<th>Invoice Quantity</th>
<th>Remarks</th>
<th> </th>
</tr>
</thead>
<tbody id="IGRappend"></tbody>
</table>
<input type="hidden" name="txtRowCount" id="txtRowCount" />
<div class="col-md-4 col-md-offset-8">
<input type="file" name="MasterFile" id="images1" onchange="Copyfilenames(this.name); "><br>
</div>
<div class="files">
<div class="col-md-4 col-md-offset-8" style="padding-bottom: 15px;">
<button type="button" class="btn btn-primary btn-sm a1"
onclick="appendFilesFileds()" id="day">
Add Additional File
</button>
</div>
<?php if(!empty($emp_data)){ foreach ($emp_data as $key => $value) { ?>
<div class="col-md-12 pad ">
<div class="col-md-4">
<span>File Name</span>
<input type="text" maxlength="255" class="form-control"
value="<?php echo $value['file_name']; ?>" readonly>
</div>
<div class="col-md-1" style="margin-top: 25px;">
<a href="<?php echo base_url() . 'public/uploads/images/emp_files/' . $value['emp_file']; ?>"
download>
<i class="fa fa-download" aria-hidden="true"
style="font-size: 25px;"></i>
</a>
</div>
<div class="col-md-5" style="margin-top: 23px;">
<button type="button" class="btn btn-danger btn-sm"
id="<?= $value['id']; ?>"
onclick="removeContact(this)">Delete</button>
</div>
</div>
<?php }} ?>
<div id="filesContainer"></div>
</div><br>
<div class="col-md-4 col-md-offset-8">
<button class="btn btn-success" id='IGRLink' type="submit" name='IGRLink' onclick="filecheck(1);">Generate IGR</button>
<button class="btn btn-success" id='IGRDraftLink' type="submit" name='IGRDraftLink' onclick="filecheck(0);">Save as Draft IGR</button>
</div>
</div>
</div>
</form>
<!-- form closed-->
<div class="modal fade" id="generateIGR" role="dialog">
<div class="modal-dialog modal_style">
<!-- Modal content-->
<form>
<div class="modal-content">
<div class="modal-header" style="background-color: #3c8dbc;color:#fff;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center>
<h4>Inward Gate Register Number</h4>
</center>
</div>
<div class="col-md-12"> <br />
<center><label style="font-size:40px;" id="finaligr">Default</label> </center>
</div>
<div class="modal-footer">
<center>
<button type="reset" value="Reset" onClick="window.location.reload()"> OK</button>
</center>
</div><!-- footer div closed -->
</div><!-- modal content div closed-->
</form><!-- form closed-->
</div><!-- modal content closed-->
</div><!-- modal fade closed-->
<!-- generateIGR modal ended-->
<div class="modal fade" id="WeightCalculator" role="dialog">
<div class="modal-dialog modal_style">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center>
<h4>Weight Calculator<span id="WeightTitle"></span></h4>
</center>
<div class="pull-right hidden-xs">
<b>
<div id="clock"></div>
</b>
</div>
</div>
<div class="col-md-12"> <br />
<!-- <center><label style="font-size:40px;">Default</label> </center> -->
<!-- <div class="container"> -->
<div class="form-group row">
<label for="GrossWeight" class="col-md-2 col-form-label">Gross Weight</label>
<div class="col-md-5">
<?php
$data = array('name' => 'GrossWeight', 'value' => set_value('GrossWeight'), 'id' => 'GrossWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);', 'placeholder' => 'Gross Weight Value (A)', 'autocomplete'=>"off");
echo form_input($data);
?>
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'GrossWeightDate', 'value' => set_value('GrossWeightDate'), 'id' => 'GrossWeightDate', 'class' => 'form-control', 'readonly' => true, 'placeholder' => 'Gross Weight Date/Timing');
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="TareWeight" class="col-md-2 col-form-label">Tare Weight</label>
<div class="col-md-5">
<?php
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'validateTareWeight(this);', 'autocomplete' => 'off', 'placeholder' => 'Tare Weight Value (B)', 'autocomplete'=>"off");
echo form_input($data);
?>
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'TareWeightDate', 'value' => set_value('TareWeightDate'), 'id' => 'TareWeightDate', 'class' => 'form-control', 'readonly' => true, 'placeholder' => 'Tare Weight Date/Timing',);
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="NetWeight" class="col-md-2 col-form-label">Net Weight</label>
<div class="col-md-5">
<input type="hidden" id="CurrentInx" name="CurrentInx" readonly>
<?php
$data = array('name' => 'NetWeight', 'value' => set_value('NetWeight'), 'id' => 'NetWeight', 'class' => 'form-control', 'maxlength' => '50', 'readonly' => true, 'placeholder' => 'Net Weight Value (A-B)');
echo form_input($data);
?>
</div>
<div class="col-md-5">
<input type="file" name="WeightFile" id="WeightFile" onchange="Copyfilenames(this.name); "><br>
</div>
</div>
<!-- </div> -->
</div>
<div class="modal-footer">
<div class="col-md-12 text-right">
<div class="col-md-4 col-md-offset-8">
<a class="btn btn-cancel" data-dismiss="modal" value="Close">Close</a>
<a class="btn btn-primary" onclick="modalSave()">&nbsp;&nbsp;<span class="bold">Save</span></a>
</div>
</div>
</div><!-- footer div closed -->
</div><!-- modal content div closed-->
</div><!-- modal content closed-->
</div><!-- modal fade closed-->
</div>
<!-- WeightCalculator modal ended-->
</div>
</section>
</div>
<script>
function validate() {
var rowcount = $("#txtRowCount").val();
var isOpenOrder = parseInt($("#hiddenIsOpenOrder").val(), 2);
var formatted_IsOpenOrder = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? 0 : 1;
var Noval = 0;
var isExceed = 0;
for (k = 1; k <= rowcount; k++) {
var InvoiceQty = parseFloat($('#QuantityAsPerInvoice' + k).val() == '' ? '0.00' : $('#QuantityAsPerInvoice' + k).val());
var RecQty = parseFloat($('#txtReceivedQuantity' + k).val() == '' ? '0.00' : $('#txtReceivedQuantity' + k).val());
var OrderedQty = parseFloat($('#Quantity_1' + k).text());
if (InvoiceQty != '0.00') {
if (OrderedQty < (InvoiceQty + RecQty)) {
isExceed = 1;
return false;
}
Noval = 1;
}
}
if ($('#PONO').val() == '-1') {
alert("Please select PurchaseOrder");
$('#PONO').focus();
return false;
} else if ($('#InvoiceNo').val() == '') {
alert('Please Enter Invoice Number');
$('#InvoiceNo').focus();
return false;
} else if ($('#InvoiceDate').val() == '') {
alert('Please Enter Invoice Date');
$('#InvoiceDate').focus();
return false;
} else if ($('#MaterialRcvdDate').val() == '') {
alert('Please Enter Material Received Date');
$('#MaterialRcvdDate').focus();
return false;
} else if (Noval == 0) {
alert('Invoice Quantity is Empty.Please Enter the value');
return false;
} else if (isExceed == 1 && formatted_IsOpenOrder == 0) {
alert("Invoice Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ")
return false;
} else {
return true;
}
}
</script>
<script>
$(function() {
$('#Inwardgateregistertable').DataTable({
"paging": false,
"lengthChange": false,
"searching": false,
"ordering": false,
"info": false,
"autoWidth": false
});
});
</script>
<script>
// $(function() {
function removeHidden() {
var rowcount = $("#txtRowCount").val();
for (k = 1; k <= rowcount; k++) {
$("#MaterialCode" + k).remove();
$("#txtQuantityAsPerInvoice" + k).remove();
$("#OrderedQuantity" + k).remove();
$("#txtReceivedQuantity" + k).remove();
$("#txtRemarks" + k).remove();
$("#txtPendingQty" + k).remove();
$("#txtGrossWeight" + k).remove();
$("#txtGrossWeightDate" + k).remove();
$("#txtTareWeight" + k).remove();
$("#txtTareWeightDate" + k).remove();
$("#txtNetWeight" + k).remove();
$("#txtWeightFile" + k).remove();
}
}
$('#PONO').change(function() {
removeHidden();
$("#IGRappend").empty();
$('#txtRowCount').val('');
var id = $('#PONO').val();
var status = '';
var isOpenOrder = 0;
if (id != '-1') {
$('#content').loader('show');
var y = <?php echo json_encode($PO_NO, JSON_PRETTY_PRINT) ?>;
$.each(y, function(idx, obj) {
if (id == obj.PONO) {
var baseUrl = '<?php echo base_url(); ?>purchaseorder/CreatePOPrint';
var newUrl = baseUrl + '?PONO=' + obj.PONO + '&ReqType=' + obj.POType;
$('#printLink').attr('href', newUrl);
$("#po").val(obj.PONO);
$("#Sup").val(obj.SupplierName);
$("#hiddenIsOpenOrder").val(obj.IsOpenOrder);
isOpenOrder = parseInt(obj.IsOpenOrder ? obj.IsOpenOrder : "0", 2);
var formatted_IsOpenOrder = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "" : "Open";
$('.help-block').text(formatted_IsOpenOrder);
var button_text_for_IGRDraftLink = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "Save as Draft IGR" : "Save as Open IGR";
$('#IGRDraftLink').text(button_text_for_IGRDraftLink);
//$("#Add").val(obj.Address);
$("#del").val(obj.DeliveryDate);
//$("#ser").val(obj.ServiceDescription);
status = obj.status;
ostatus = obj.OGR_Status;
formatted_PODate = obj.formatted_PODate;
formatted_IsOpenOrder = obj.formatted_IsOpenOrder;
}
});
$.ajax({
data: { id: id },
type: "POST",
url: "<?php echo base_url() ?>GetIGRLineItemDetails",
success: function(data) {
$('#content').loader('hide');
//alert(data);
var trHTML = '';
var j = 0;
var showTable = false;
$.each(JSON.parse(data), function(i, item) {
showTable = true;
if (showTable) {
i = i + 1;
j = j + 1;
trHTML += '<tr>' +
'<td align="right">' + j + '</td>' +
'<td name="MaterialName" id="MaterialCode" >' + item.MaterialCode + '</td>' +
'<td>' + item.MaterialName + '</td>' +
'<td name="UOM">' + item.UOM + '</td>' +
'<td name="Quantity1' + i + '" id="Quantity_1' + i + '">' + item.Quantity + '</td>' +
'<td name="ReceivedQuantity' + i + '" id="ReceivedQuantity' + i + '">' + item.ReceivedQuantity + '</td>' +
'<td name="PendingQuantity' + i + '" id="PendingQuantity' + i + '">' + ((isOpenOrder === 0 || isNaN(isOpenOrder)) ? item.PendingQty : 0 ) + '</td>' +
'<td data-name="sel" ><input type="text" onchange="validateReceivedQuantity(' + i + ')"id="QuantityAsPerInvoice' + i + '" name="QuantityAsPerInvoice' + i + '" value="" onkeypress="return isNumberKey(event);" autocomplete="off"></td>' +
'<td><input type="text" id="Remark' + i + '" name="Remark' + i + '" class="form" onchange="SetRemarks(' + i + ')" autocomplete="off"> </td>' +
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="' + i + '" data-material="' + item.MaterialName + '"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'</tr>';
$('#txtRowCount').val(i);
$('<input>').attr({
type: 'hidden',
id: 'MaterialCode' + i,
value: item.MaterialCode,
name: 'MaterialCode' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtQuantityAsPerInvoice' + i,
name: 'txtQuantityAsPerInvoice' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'OrderedQuantity' + i,
value: item.Quantity,
name: 'OrderedQuantity' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtReceivedQuantity' + i,
name: 'txtReceivedQuantity' + i,
value: item.ReceivedQuantity
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtRemarks' + i,
name: 'txtRemarks' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtPendingQty' + i,
name: 'txtPendingQty' + i,
value: ((isOpenOrder === 0 || isNaN(isOpenOrder)) ? item.PendingQty : 0 )
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtGrossWeight' + i,
value: item.GrossWeight,
name: 'txtGrossWeight' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtGrossWeightDate' + i,
value: item.GrossWeightDate,
name: 'txtGrossWeightDate' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtTareWeight' + i,
value: item.TareWeight,
name: 'txtTareWeight' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtTareWeightDate' + i,
value: item.TareWeightDate,
name: 'txtTareWeightDate' + i
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtNetWeight' + i,
value: item.NetWeight,
name: 'txtNetWeight' + i
}).appendTo('form');
$('<input>').attr({
type: 'file',
id: 'txtWeightFile' + i,
value: item.WeightFile,
name: 'txtWeightFile' + i,
style: 'display:none;' // This makes the input hidden
}).appendTo('form'); // Make sure the form has the id 'IGR'
if (item.PendingQty == 0.00) {
$('#QuantityAsPerInvoice' + i).attr('readonly', 'true');
}
$("#IGRLink").show();
} else {
if (JSON.parse(data).length == 1 && item.PendingQty == 0) {
$("#IGRLink").hide();
//alert('The Order is new completed!!');
}
}
});
$("#IGRappend").empty();
$('#IGRappend').append(trHTML);
}
});
if ((status == '<?php echo IGR_CREATED ?>' || status == '<?php echo MRIR_CREATED ?>' || status == '<?php echo MRIR_APPROVED ?>')) {
alert('The Order is completed!!');
$("#IGRLink").hide();
} else {
$("#IGRLink").show();
}
} else {
alert('Please Select the Purchase Order Number to Create IGR');
}
});
function SetRemarks(RowId) {
var remks = $("#Remark" + RowId).val();
if (remks != '') {
$("#txtRemarks" + RowId).val(remks);
}
}
function validateReceivedQuantity(Rowid) {
//alert(Rowid);
var InvoiceQty = parseFloat($('#QuantityAsPerInvoice' + Rowid).val() == '' ? '0.00' : $('#QuantityAsPerInvoice' + Rowid).val());
var PendingQty = parseFloat($('#PendingQuantity' + Rowid).text() == '' ? '0.00' : $('#PendingQuantity' + Rowid).text());
var RecQty = parseFloat($('#txtReceivedQuantity' + Rowid).val() == '' ? '0.00' : $('#txtReceivedQuantity' + Rowid).val());
var OrderedQty = parseFloat($("#Quantity_1" + Rowid).text());
var r = $("#Remark" + Rowid).val();
var isOpenOrder = parseInt($("#hiddenIsOpenOrder").val(), 2);
var formatted_IsOpenOrder = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? 0 : 1;
if(formatted_IsOpenOrder == 0){
if ((InvoiceQty + RecQty) > OrderedQty) {
alert("Invoice Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ")
$("#QuantityAsPerInvoice" + Rowid).focus();
$("#QuantityAsPerInvoice" + Rowid).val('');
return false;
} else if (((InvoiceQty + RecQty) - OrderedQty) > 0.00) {
alert("Order is completed.")
$("#QuantityAsPerInvoice" + Rowid).focus();
$('#QuantityAsPerInvoice' + Rowid).val('');
return false;
} else {
// alert(RecQty);
$('#PendingQuantity' + Rowid).text((OrderedQty - (InvoiceQty + RecQty)).toFixed(2));
$('#txtPendingQty' + Rowid).val(OrderedQty - (InvoiceQty + RecQty));
$("#ReceivedQuantity" + Rowid).val(InvoiceQty + RecQty);
$("#txtQuantityAsPerInvoice" + Rowid).val(InvoiceQty);
// InvoiceQty
return true;
}}else{
console.log(InvoiceQty + RecQty);
$('#PendingQuantity' + Rowid).text(0.00);
$('#txtPendingQty' + Rowid).val(0.00);
$("#ReceivedQuantity" + Rowid).val(InvoiceQty + RecQty);
$("#txtQuantityAsPerInvoice" + Rowid).val((InvoiceQty + RecQty));
// InvoiceQty
return true;
}
}
</script>
<script>
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
function Save(status) {
if (validate()) {
$("#IGR").attr("method", "post");
$("#IGR").attr("enctype", "multipart/form-data");
$("#IGR").attr("action", "SaveIGR");
$('#IGR').submit();
} //validate if closed
} //save function closed
</script>
<script>
function filecheck(status) {
$('#hideIGRStatus').val(status);
Save(status);
}
function Copyfilenames(id) {
var size = $('input[name=' + id + ']')[0].files[0].size;
if (size > 2100000) {
alert('Sorry Your File is Large To 2MB');
} else {
var name = $('input[name=' + id + ']')[0].files[0].name;
}
}
</script>
<script>
function validateTareWeight(element) {
var grossWeight = parseFloat(document.getElementById('GrossWeight').value);
var tareWeight = parseFloat(document.getElementById('TareWeight').value);
if (tareWeight > grossWeight) {
alert("Tare Weight must be less than or equal to Gross Weight.");
document.getElementById('TareWeight').value = '';
document.getElementById('TareWeightDate').value = '';
return false;
}
WeightDiffer(element)
return true;
}
function updateTime() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const todaydate = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
const dateString = todaydate + '-' + month + '-' + year;
const timeString = hours + ":" + minutes + ":" + seconds;
document.getElementById('clock').textContent = dateString + " " + timeString;
document.getElementById('wizard_clock').textContent = dateString + " " + timeString;
}
setInterval(updateTime, 1000);
updateTime();
function WeightDiffer(element) {
var v1 = $("#GrossWeight").val();
var v2 = $("#TareWeight").val();
var v3 = v1 - v2;
$("#NetWeight").val(v3);
if (element.id === 'GrossWeight') {
$("#GrossWeightDate").val($("#clock").text());
}
if (element.id === 'TareWeight') {
$("#TareWeightDate").val($("#clock").text());
}
}
</script>
<script>
$("#WeightCalculator").on("shown.bs.modal", function(e) {
var inx = $(e.relatedTarget).data('index');
var material = $(e.relatedTarget).data('material');
$('#WeightTitle').text(" ( " + material + " )");
// Clear the modal inputs
$("#GrossWeight").val('');
$("#GrossWeightDate").val('');
$("#TareWeight").val('');
$("#TareWeightDate").val('');
$("#NetWeight").val('');
// Retrieve values from hidden inputs
var v1 = $("#txtGrossWeight" + inx).val();
var v2 = $("#txtGrossWeightDate" + inx).val();
var v3 = $("#txtTareWeight" + inx).val();
var v4 = $("#txtTareWeightDate" + inx).val();
var v5 = $("#txtNetWeight" + inx).val();
var fileInput = $("#txtWeightFile" + inx)[0];
console.log("Selected values for index:", typeof inx, inx);
// Set modal inputs with the retrieved values
$("#GrossWeight").val(v1);
$("#GrossWeightDate").val(v2);
$("#TareWeight").val(v3);
$("#TareWeightDate").val(v4);
$("#NetWeight").val(v5);
$("#CurrentInx").val(inx);
if (fileInput && fileInput.files.length > 0) {
var targetInput = $("#WeightFile")[0];
var file = fileInput.files[0];
// Create a new DataTransfer object
var dataTransfer = new DataTransfer();
dataTransfer.items.add(file);
// Set the file to the target input
targetInput.files = dataTransfer.files;
} else {
console.log("No file selected or file input not found.");
}
});
function modalSave() {
var v1 = $("#GrossWeight").val();
var v2 = $("#GrossWeightDate").val();
var v3 = $("#TareWeight").val();
var v4 = $("#TareWeightDate").val();
var v5 = $("#NetWeight").val();
var inx = $("#CurrentInx").val();
var fileInput = $("#WeightFile")[0]; // Get the file input element
if (inx !== undefined && inx !== '') {
console.log("Saving values for index:", inx);
// Set the values back to the hidden inputs
$("#txtGrossWeight" + inx).val(v1);
$("#txtGrossWeightDate" + inx).val(v2);
$("#txtTareWeight" + inx).val(v3);
$("#txtTareWeightDate" + inx).val(v4);
$("#txtNetWeight" + inx).val(v5);
if (fileInput && fileInput.files.length > 0) {
var targetInput = $("#txtWeightFile" + inx)[0];
var file = fileInput.files[0];
// Create a new DataTransfer object
var dataTransfer = new DataTransfer();
dataTransfer.items.add(file);
// Set the file to the target input
targetInput.files = dataTransfer.files;
} else {
console.log("No file selected or file input not found.");
}
// Clear modal inputs
$("#GrossWeight").val('');
$("#GrossWeightDate").val('');
$("#TareWeight").val('');
$("#TareWeightDate").val('');
$("#NetWeight").val('');
$("#WeightFile").val('');
// Close the modal
$("#WeightCalculator").modal('hide');
} else {
console.log("Saving values for index: " + inx + " undefined");
}
}
</script>
<script>
function appendFilesFileds(data) {
var newRowHtml = `
<div class="col-md-12 pad">
<div class="col-md-4">
<span for="file_name">File name</span>
<input type="text" id="file_name" name="file_name[]" maxlength="255" class="form-control" value="${data != null && data != '' ? data.file_name : ''}">
</div>
<div class="col-md-4">
<span for="emp_file">File</span>
<input type="file" name="emp_file[]" class="form-control">
</div>
<div class="col-md-4" style="margin-top: 23px;">
<button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)">Remove</button>
<button type="button" class="btn btn-primary btn-sm a1" onclick="appendFilesFileds()">Add</button>
</div>
</div>`;
$('#filesContainer').append(newRowHtml);
$('.a1').hide();
$('#filesContainer .pad:last .a1').show();
}
function removeContact(button) {
$(button).closest('.pad').remove();
$('#filesContainer .a1').hide();
$('#filesContainer .pad:last .a1').show();
var len = $('#filesContainer .pad:last .a1')
var length = len.length;
if (length == 0) {
$('#day').show()
} else {
$('#day').hide()
}
}
</script>