1048 lines
36 KiB
PHP
Executable File
1048 lines
36 KiB
PHP
Executable File
<link href="<?= base_url() . "public/new_assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" ?>" rel="stylesheet" type="text/css" />
|
||
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script>
|
||
|
||
<style>
|
||
#MaterialRcvdDate,
|
||
#InvoiceDate {
|
||
text-align: left;
|
||
}
|
||
|
||
.autocomplete-suggestion {
|
||
cursor: pointer;
|
||
background-color: skyblue;
|
||
/* background-color: darkgrey; */
|
||
outline: 1px solid slategrey;
|
||
}
|
||
</style>
|
||
<div class="content-page">
|
||
<div class="content">
|
||
<!-- Start Content-->
|
||
<div class="container-fluid">
|
||
<!-- start page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="page-title-box page-title-box-alt">
|
||
<div class="page-title-right">
|
||
<ol class="breadcrumb mt-2 mb-2.5">
|
||
<li class="breadcrumb-item"><a href="javascript: void(0);">Inward</a></li>
|
||
<li class="breadcrumb-item active">
|
||
<h4 class="page-title">Inward Gate Register</h4>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
|
||
<div class="pull-right hidden-xs">
|
||
<b>
|
||
<div id="wizard_clock"></div>
|
||
</b>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end page title -->
|
||
<!-- Form row -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<form id="IGRForm" action="<?php echo base_url() ?>SaveIGR" method="post" enctype="multipart/form-data">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<div class="d-flex justify-content-between align-items-center">
|
||
<label class="col-form-label">Select Purchase Order No <span class="text-danger">*</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'),
|
||
'class="form-control searchabledropdown" id="PONO" data-toggle="select2" required="true" onchange="yourFunctionName()"'
|
||
);
|
||
?>
|
||
<span class="help-block"></span>
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label class="col-form-label">Supplier Name</label>
|
||
<?php
|
||
$data = array('name' => 'SupplierName', 'value' => set_value('SupplierName'), 'id' => 'Sup', 'class' => 'form-control', 'readonly' => 'true','rows' => 3);
|
||
echo form_textarea($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group col-md-3">
|
||
<label class="col-form-label">Invoice Number<span class="text-danger">*</span></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="form-group col-md-3">
|
||
<label class="col-form-label">Invoice Date<span class="text-danger">*</span></label>
|
||
<input class="form-control" data-provide="datepicker" data-date-format="dd-mm-yyyy" data-date-autoclose="true" id="InvoiceDate" name="InvoiceDate" data-date-end-date="<?= date('d-m-Y'); ?>" required autocomplete="off" data-date-orientation="bottom">
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<div class="form-group col-md-3">
|
||
<label class="col-form-label">Material Received Date<span class="text-danger">*</span></label>
|
||
<input class="form-control" data-provide="datepicker" data-date-format="dd-mm-yyyy" data-date-autoclose="true" id="MaterialRcvdDate" name="MaterialRcvdDate" data-date-end-date="<?= date('d-m-Y'); ?>" required autocomplete="off" data-date-orientation="bottom">
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
|
||
<label class="col-form-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);
|
||
?>
|
||
</div>
|
||
</div>
|
||
<div class="form-row">
|
||
|
||
<div class="form-group col-md-3">
|
||
<label class="col-form-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'), 'class="form-control searchabledropdown" id="TransporterId" data-toggle="select2"');
|
||
|
||
?>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label class="col-form-label">Driver Name</label>
|
||
<?php
|
||
$data = array('name' => 'DriverName', 'value' => set_value('DriverName'), 'id' => 'DriverName', 'class' => 'form-control', 'maxlength' => '50', 'autocomplete' => 'off','list' => 'driverlist','onchange' => "fetchMobileNumber(this.value)");
|
||
echo form_input($data);
|
||
echo '<datalist id="driverlist">';
|
||
foreach ($driverlist as $driver) {
|
||
echo '<option value="' . $driver['DriverName'] . ( ( $driver['DriverMobileNumber'] ) ? ' - ' . $driver['DriverMobileNumber'] : '' ) . '" >';
|
||
}
|
||
echo '</datalist>';
|
||
?>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label class="col-form-label">Driver Mobile Number</label>
|
||
<?php
|
||
$data = array('name' => 'DriverMobileNumber', 'value' => set_value('DriverMobileNumber'), 'id' => 'DriverMobileNumber', 'class' => 'form-control', 'autocomplete' => 'off', 'maxlength'=>'10');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label class="col-form-label">Remark</label>
|
||
<?php
|
||
$data = array('name' => 'MasterRemarks', 'value' => set_value('MasterRemarks'), 'id' => 'MasterRemarks', 'class' => 'form-control', 'autocomplete' => 'off','rows' => 3);
|
||
echo form_textarea($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="table-responsive">
|
||
<table id="Inwardgateregistertable" class="table table-striped table-hover mb-0 editabletable IGR_Line" style="font-size:12px;">
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
<th>Item Code</th>
|
||
<th>Item Description</th>
|
||
<th>Rate</th>
|
||
<th>UOM</th>
|
||
<th>Ordered Quantity</th>
|
||
<th>Received Quantity</th>
|
||
<th>Balance Quantity</th>
|
||
<th>Invoice Quantity<span class="text-danger">*</span></th>
|
||
<th>Remarks</th>
|
||
<th> </th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="IGRappend"></tbody>
|
||
</table>
|
||
</div> <!-- end table-responsive-->
|
||
</div>
|
||
<div class="form-row text-left">
|
||
<div class="form-group col-md-12">
|
||
<br>
|
||
<div class="form-group col-md-12">
|
||
<label> Master IGR file</label>
|
||
<br>
|
||
<input type="file" name="MasterFile" id="MasterFile" onchange="filenames(this.name); ">
|
||
<label id="MasterFileLabel" style="display:none;">
|
||
<a><span></span><small></small></a>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="files">
|
||
<div class="form-row float-right">
|
||
<div class="form-group">
|
||
<button type="button" class="btn btn-primary waves-effect btn-sm a1"
|
||
onclick="appendFilesFileds()" id="additionalfilebtn">
|
||
Add Additional File
|
||
</button>
|
||
</div>
|
||
</div>
|
||
<span id="filesContainer"></span>
|
||
</div><br>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12"><br>
|
||
<input type="hidden" name="hiddenIsOpenOrder" id="hiddenIsOpenOrder" />
|
||
<input type="hidden" name="txtRowCount" id="txtRowCount" />
|
||
<input type="hidden" name="hideIGRStatus" id="hideIGRStatus" value="0" />
|
||
</div>
|
||
</div>
|
||
<div class="form-row float-right">
|
||
<div class="form-group">
|
||
<button class="btn btn-primary waves-effect" id="IGRLink" type="button">Generate IGR</button>
|
||
<button class="btn btn-primary waves-effect" id="IGRDraftLink" type="button">Save as Draft IGR</button>
|
||
</div>
|
||
</div>
|
||
</form> <!-- end form -->
|
||
</div> <!-- end card body-->
|
||
</div> <!-- end card -->
|
||
</div><!-- end col-->
|
||
</div>
|
||
</div> <!-- container -->
|
||
</div> <!-- content -->
|
||
</div>
|
||
<div id="weight-calc-modal" class="modal fade" tabindex="-1" role="dialog"
|
||
aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||
<div class="modal-dialog modal-lg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title">Weight Calculator<span id="WeightTitle"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal"
|
||
aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body p-4">
|
||
<div id="clock"></div>
|
||
<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="filenames(this.name); "><br>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-secondary waves-effect"
|
||
data-dismiss="modal" value="Cancel">Cancel</button>
|
||
<button type="button"
|
||
class="btn btn-info waves-effect waves-light" onclick="modalSave()">Save</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal weight-calc-modal -->
|
||
<script>
|
||
$(document).ready(function() {
|
||
$("#DriverMobileNumber").on('input', function(e) {
|
||
this.value = this.value.replace(/\D/g, '');
|
||
});
|
||
|
||
$(".searchabledropdown").select2();
|
||
|
||
$('#IGRLink').on('click', function() {
|
||
filecheck(1);
|
||
});
|
||
|
||
$('#IGRDraftLink').on('click', function() {
|
||
filecheck(0);
|
||
});
|
||
|
||
function filecheck(status) {
|
||
$('#hideIGRStatus').val(status);
|
||
Save();
|
||
}
|
||
|
||
function Save() {
|
||
if (validate()) {
|
||
$('#IGRForm').submit();
|
||
}
|
||
}
|
||
});
|
||
</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 filenames(id) {
|
||
var size = $('input[name=' + id + ']')[0].files[0].size;
|
||
if (size > 2100000) {
|
||
alert('Sorry Your File is Large To 2MB');
|
||
}
|
||
}
|
||
|
||
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() {
|
||
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();
|
||
|
||
|
||
}
|
||
}
|
||
|
||
$('#PONO1').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 + "\n" + obj.Address);
|
||
$("#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>' + Number(item.Rate).toFixed(2) + '</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="#weight-calc-modal" 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 validateTareWeight(element) {
|
||
var grossWeight = parseFloat($('#GrossWeight').val());
|
||
var tareWeight = parseFloat($('#TareWeight').val());
|
||
|
||
if (tareWeight > grossWeight) {
|
||
alert("Tare Weight must be less than or equal to Gross Weight.");
|
||
$('#GrossWeight').val('');
|
||
$('#TareWeightDate').val('');
|
||
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;
|
||
$('#clock').text(dateString + " " + timeString);
|
||
$('#wizard_clock').text(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>
|
||
$(document).ready(function() {
|
||
$("#weight-calc-modal").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
|
||
|
||
console.log("inx");
|
||
console.log(inx);
|
||
|
||
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
|
||
$("#weight-calc-modal").modal('hide');
|
||
} else {
|
||
console.log("Saving values for index: " + inx + " undefined");
|
||
}
|
||
}
|
||
</script>
|
||
<script>
|
||
function appendFilesFileds(data) {
|
||
var newRowHtml = `
|
||
<div class="form-row pad mt-2">
|
||
<div class=" col-md-4">
|
||
<label class="col-form-label">File name</label>
|
||
<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">
|
||
<label class="col-form-label">File</label>
|
||
<input type="file" name="emp_file[]" class="form-control">
|
||
</div>
|
||
<div class=" col-md-4" style="margin-top: 40px;">
|
||
<button type="button" class="btn btn-danger waves-effect btn-sm" onclick="removeContact(this)">Remove</button>
|
||
<button type="button" class="btn btn-primary waves-effect 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) {
|
||
$('#additionalfilebtn').show()
|
||
} else {
|
||
$('#additionalfilebtn').hide()
|
||
}
|
||
}
|
||
</script>
|
||
<script>
|
||
$(function() {
|
||
$('#Inwardgateregistertable').DataTable({
|
||
"paging": false,
|
||
"lengthChange": false,
|
||
"searching": false,
|
||
"ordering": false,
|
||
"info": false,
|
||
"autoWidth": false
|
||
});
|
||
});
|
||
|
||
function yourFunctionName() {
|
||
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 + "\n" + obj.Address);
|
||
$("#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) {
|
||
console.log(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>' + Number(item.Rate).toFixed(2) + '</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="#weight-calc-modal" 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');
|
||
}
|
||
}
|
||
|
||
</script>
|
||
<script>
|
||
// Chat Gpt Code not working
|
||
// function fetchMobileNumber(driverName) {
|
||
// let options = document.querySelectorAll("#driverlist option");
|
||
// console.log('*',options);
|
||
// // Loop through options to find the selected driver
|
||
// options.forEach(option => {
|
||
// if (option.value === driverName) {
|
||
// let mobileNumber = option.getAttribute("data-mobile"); // Get the mobile number
|
||
// document.getElementById("DriverMobileNumber").value = mobileNumber; // Set the mobile field
|
||
// }
|
||
// });
|
||
// }
|
||
function fetchMobileNumber(selectedValue) {
|
||
let parts = selectedValue.split(" - ");
|
||
// console.log(parts);
|
||
// console.log(parts[0]);
|
||
if (parts.length === 2) {
|
||
document.getElementById("DriverName").value = parts[0];
|
||
document.getElementById("DriverMobileNumber").value = parts[1];
|
||
}else{
|
||
document.getElementById("DriverName").value = parts[0];
|
||
}
|
||
}
|
||
</script>
|