CHANGE_INWARD_RIASE

This commit is contained in:
aadhavan valli 2024-08-29 08:51:04 +05:30
parent 7c1b938ebc
commit 598148a969
13 changed files with 854 additions and 532 deletions

View File

@ -270,6 +270,7 @@ $routes->post('editExpense', 'Expense::editExpense');
$routes->post('getExpenseDetails', 'Expense::getExpenseDetails');
$routes->get('uploads/(:any)', 'Expense::downloads/$1');
$routes->post('deleteFile', 'Expense::deleteFile');
$routes->get('downloadFile/(:any)', 'Expense::downloads/$1');
// Application OGR Page

View File

@ -39,18 +39,21 @@ class Expense extends BaseController
$file->move(WRITEPATH . 'uploads', $fileName);
}
$status = $this->request->getPost('status');
$paymentMethod = $status === 'Paid' ? $this->request->getPost('payment_method') : 0;
$data = [
'transporter_file' => $fileName,
'supplier_id' => $this->request->getPost('supplierid'),
'remarks' => $this->request->getPost('remarks'),
'cost' => $this->request->getPost('cost'),
'gst' => $this->request->getPost('gst'),
'total' => $this->request->getPost('total'),
'status' => $this->request->getPost('status'),
'payment_method' => $this->request->getPost('payment_method')
'total' => (int)$this->request->getPost('gst') + (int)$this->request->getPost('cost'),
'status' => $status,
'payment_method' => $paymentMethod
];
$insert_id = $this->expense_model->insertExpense($data);
$insert_id = $this->expense_model->insertExpense($data);
if ($insert_id) {
return json_encode('true');
} else {
@ -83,18 +86,23 @@ class Expense extends BaseController
$fileName = $this->request->getPost('existing_file'); // Use existing file if no new file is uploaded
}
$status = $this->request->getPost('status');
$paymentMethod = $status === 'Paid' ? $this->request->getPost('payment_method') : 0;
$data = [
'supplier_id' => $this->request->getPost('supplierid'),
'remarks' => $this->request->getPost('remarks'),
'cost' => $this->request->getPost('cost'),
'gst' => $this->request->getPost('gst'),
'total' => $this->request->getPost('total'),
'status' => $this->request->getPost('status'),
'payment_method' => $this->request->getPost('payment_method')
'total' => (int)$this->request->getPost('gst') + (int)$this->request->getPost('cost'),
'status' => $status,
'payment_method' => $paymentMethod
];
if(!empty($fileName)){
$data['transporter_file'] = $fileName;
}
$data['payment_method'] = $this->request->getPost('payment_method');
if ($id) {
$result = $this->expense_model->updateExpense($id, $data);

View File

@ -465,7 +465,7 @@ legend {
</b>
</div>
<div class="col-md-5" style="margin-top: 20px;margin-bottom: 10px;text-align:right;">
<a href="<?php echo base_url() ?>employeeListing" class="btn btn-cancel" value="Back">Back</a>
<a href="<?php echo base_url() ?>employeeListing" class="btn btn-dark waves-effect waves-light" value="Back">Back</a>
</div>
<div class="col-md-1"></div>
</div>

View File

@ -46,7 +46,7 @@
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting"><span class="bold">Back</span></a>
<a class="btn btn-dark waves-effect waves-light" href="<?php echo base_url(); ?>supplierlisting"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->

View File

@ -10,7 +10,7 @@
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>assetListing"><span class="bold">Back</span></a>
<a class="btn btn-dark waves-effect waves-light" href="<?php echo base_url(); ?>assetListing"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->

View File

@ -16,7 +16,7 @@
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>configlisting"><span class="bold">Back</span></a>
<a class="btn btn-dark waves-effect waves-light" href="<?php echo base_url(); ?>configlisting"><span class="bold">Back</span></a>
</div>
</div>
<?php

View File

@ -20,7 +20,7 @@
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>departmentListing"><span class="bold">Back</span></a>
<a class="btn btn-dark waves-effect waves-light" href="<?php echo base_url(); ?>departmentListing"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->

View File

@ -34,6 +34,19 @@ if (!empty($ReqPOType)) {
$strReqPOType = $ReqPOType;
}
?>
<style>
.btn-soft-primary {
color: white;
background-color: rgb(42, 206, 150);
border-color: rgb(42, 206, 150);
}
.btn-soft-primary:hover {
background-color: rgb(32, 176, 130); /* Slightly darker shade for hover */
border-color: rgb(32, 176, 130);
}
</style>
<script type="text/javascript">
window.onload = function() {
var serviceScheduleType = '<?php echo $serviceSchedule; ?>';
@ -216,13 +229,13 @@ if (!empty($ReqPOType)) {
<div class="form-row float-right">
<?php if ($Status == REQ_DRAFT) { ?>
<input type="reset" value="Reset" class="btn btn-secondary waves-effect" onclick="window.location.reload();">&nbsp;&nbsp;
<button type="button" class="btn btn-primary waves-effect Save" onclick="Save(0)" id="Save">Save As Draft</button>&nbsp;&nbsp;
<button type="button" class="btn btn-primary waves-effect submit" onclick="Save(1)" id="submit">Submit</button>&nbsp;&nbsp;
<button type="button" class="btn btn-soft-primary waves-effect waves-light submit" onclick="Save(2)" id="submit">Approve</button>&nbsp;&nbsp;
<button type="button" class="btn btn-primary waves-effect Save" " id="Save">Save As Draft</button>&nbsp;&nbsp;
<button type="button" class="btn btn-primary waves-effect submit" id="submit1">Submit</button>&nbsp;&nbsp;
<button type="button" class="btn btn-soft-primary waves-effect waves-light submit" id="submit2">Approve</button>&nbsp;&nbsp;
<?php } else if ($Status == REQ_PENDING_APPROVAL) { ?>
<input type="reset" value="Reset" class="btn btn-secondary waves-effect" onclick="window.location.reload();">&nbsp;&nbsp;
<button type="button" class="btn btn-primary waves-effect submit" onclick="Save(1)" id="submit">Submit</button>&nbsp;&nbsp;
<button type="button" class="btn btn-soft-primary waves-effect waves-light submit" onclick="Save(2)" id="submit">Approve</button>&nbsp;&nbsp;
<button type="button" class="btn btn-primary waves-effect submit" id="submit1">Submit</button>&nbsp;&nbsp;
<button type="button" class="btn btn-soft-primary waves-effect waves-light submit" id="submit2">Approve</button>&nbsp;&nbsp;
<?php } ?>
</div>
<?php echo form_close(); ?>
@ -518,72 +531,82 @@ if (!empty($ReqPOType)) {
userid = '';
}
}
$(document).ready(function() {
$('#submit2').on('click', function() {
Save(2);
});
$('#submit1').on('click', function() {
Save(1);
});
$('#Save').on('click', function() {
Save(0);
});
function Save(status) {
if (status == '0') {
stat = '<?php echo REQ_DRAFT; ?>';
}
if (status == '1') {
stat = '<?php echo REQ_PENDING_APPROVAL; ?>';
}
if (status == '2') {
stat = '<?php echo REQ_APPROVED; ?>'
}
//alert($('#MaterialCode4').val());
function Save(status) {
if (status == '0') {
stat = '<?php echo REQ_DRAFT; ?>';
}
if (status == '1') {
stat = '<?php echo REQ_PENDING_APPROVAL; ?>';
}
if (status == '2') {
stat = '<?php echo REQ_APPROVED; ?>'
}
//alert($('#MaterialCode4').val());
if (validate()) {
if (document.getElementById('Items').rows.length < 2) {
alert('Please Select Line item to update the Requisition');
$('#Deliverydt').focus();
return false;
} else {
//alert(document.getElementById('Items').rows.length);
// $('#content').loader('show');
$('#txtStatus').val(stat);
var serviceSchedule = '';
var servicePeriod = '';
var noOfService = '';
if ($('#RequestType').val() == 'SERVICE') {
if ($('#ScheduleType').val() == 'Recurring') {
serviceSchedule = $('#ScheduleType').val();
servicePeriod = $('#ServiceOptions').val();
noOfService = $('#ServiceNo').val();
} else {
serviceSchedule = $('#ScheduleType').val();
servicePeriod = '';
noOfService = 0;
}
if (validate()) {
if (document.getElementById('Items').rows.length < 2) {
alert('Please Select Line item to update the Requisition');
$('#Deliverydt').focus();
return false;
} else {
//alert(document.getElementById('Items').rows.length);
// $('#content').loader('show');
$('#txtStatus').val(stat);
var serviceSchedule = '';
var servicePeriod = '';
var noOfService = '';
}
$.ajax({
data: $('.requistion').serialize() + "&serviceSchedule=" + serviceSchedule + "&servicePeriod=" + servicePeriod + "&noOfService=" + noOfService,
type: "POST",
url: "<?php echo base_url() ?>EditRequisition",
success: function(data) {
if (data) {
// $('#content').loader('hide');
alert(data);
$('#txtRowCount').val('');
$('#txtDeletedRow').val('');
window.location = "Requisition";
if ($('#RequestType').val() == 'SERVICE') {
if ($('#ScheduleType').val() == 'Recurring') {
serviceSchedule = $('#ScheduleType').val();
servicePeriod = $('#ServiceOptions').val();
noOfService = $('#ServiceNo').val();
} else {
alert("Error");
serviceSchedule = $('#ScheduleType').val();
servicePeriod = '';
noOfService = 0;
}
} else {
var serviceSchedule = '';
var servicePeriod = '';
var noOfService = '';
}
$.ajax({
data: $('.requistion').serialize() + "&serviceSchedule=" + serviceSchedule + "&servicePeriod=" + servicePeriod + "&noOfService=" + noOfService,
type: "POST",
url: "<?php echo base_url() ?>EditRequisition",
success: function(data) {
if (data) {
// $('#content').loader('hide');
alert(data);
$('#txtRowCount').val('');
$('#txtDeletedRow').val('');
});
window.location = "Requisition";
} else {
alert("Error");
}
}
});
}
}
}
}
});
function validate() {
if ($("option:selected", $("#RequestType")).val() == '-1') {

View File

@ -1,3 +1,9 @@
<!-- Include jQuery first -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Include jQuery Validation plugin -->
<script src="https://cdn.jsdelivr.net/jquery.validation/1.19.3/jquery.validate.min.js"></script>
<style>
.form-group {
padding-bottom: 0%;
@ -79,34 +85,55 @@
<thead style="background-color: #ddd;">
<tr>
<th align="right">Created Date</th>
<th align="right">Expense Id</th>
<!-- <th align="right">Expense Id</th> -->
<th align="right">Supplier Name</th>
<th align="right">Cost</th>
<th align="right">GST</th>
<th align="right">Cost</th>
<th align="right">Total</th>
<th align="right">Status</th>
<th align="right">Payment Method</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($expense_list)) {
foreach ($expense_list as $record) {
?>
$fileExists = 0;
$fileUrl = '';
if ($record['transporter_file']) {
$fileExists = 1;
$fileUrl = base_url('uploads/') . $record['transporter_file'];
}
// Create download link and delete button
?>
<tr>
<?php if (date('d-m-Y', strtotime($record['created_on'])) == "30-11--0001") {
$cdate = '00-00-0000';
} else {
$cdate = date('d-m-Y', strtotime($record['created_on']));
} ?>
}
?>
<td><?php echo $cdate; ?></td>
<td class="edit-button" data-id="<?php echo $record['id']; ?>"><a href="#" data-toggle="modal" data-target="#expenseModal"><?php echo $record['id']; ?></a></td>
<!-- <td><?php echo $record['id']; ?></td> -->
<td><?php echo $record['SupplierName']; ?></td>
<td><?php echo $record['cost']; ?></td>
<td><?php echo $record['gst']; ?></td>
<td><?php echo $record['cost']; ?></td>
<td><?php echo $record['total']; ?></td>
<td><?php echo $record['status']; ?></td>
<td><?php echo $record['payment_method']; ?></td>
<td>
<?php if($fileExists == 1){ ?>
<button title="Download FIle" class="download_button" onclick="downloadFile('<?php echo $record['id']; ?>', '<?php echo $record['transporter_file']; ?>')" style="border: none;background-color: white;color: #02a8b5;">
<i class="fas fa-file-download"></i>
</button>
<button title="Delete File" id="deleteFile" class="delete_button" data-value="<?php echo $record['id'] ?>" data-id="<?php echo $record['id'] ?>" data-file="<?php echo $record['transporter_file'] ?>"><i class="fas fa-trash"></i></button>
<?php } ?>
<button title="Edit" class="edit-button" data-toggle="modal" data-target="#expenseModal" data-id="<?php echo $record['id']; ?>" style="border: none;background-color: white;color: #02a8b5;" >
<i class="fas fa-pencil-alt"></i>
</button>
</td>
</tr>
<?php
}
@ -149,15 +176,15 @@
</div>
<div class="col-md-5">
<label for="supplierid" class="col-form-label">Supplier :</label>
<select name="supplierid" id="supplierid" class="form-control">
<option value="">Select Supplier</option>
<select name="supplierid" id="supplierid" class="form-control" required>
</select>
</div>
</div>
<div class="form-group row">
<div class="col-md-5">
<label for="remarks" class="col-form-label">Remarks:</label>
<input type="text" name="remarks" id="remarks" class="form-control">
<label for="gst" class="col-form-label">Tax:</label>
<input type="number" name="gst" id="gst" class="form-control" >
</div>
<div class="col-md-1">
</div>
@ -165,26 +192,16 @@
<label for="cost" class="col-form-label">Cost:</label>
<input type="number" name="cost" id="cost" class="form-control">
</div>
</div>
<div class="form-group row">
<div class="col-md-5">
<label for="gst" class="col-form-label">GST:</label>
<input type="number" name="gst" id="gst" class="form-control">
</div>
<div class="col-md-1">
</div>
<div class="col-md-5">
<label for="total" class="col-form-label">Total:</label>
<input type="number" name="total" id="total" class="form-control">
</div>
</div>
<div class="form-group row">
<div class="col-md-5">
<label for="status" class="col-form-label">Status:</label>
<select name="status" id="status_id" class="form-control" required>
<option >Select Status</option>
<option value="1">Pending</option>
<option value="2">Complete</option>
<option>Select Status</option>
<option value="Payment Pending">Payment Pending</option>
<option value="Paid">Paid</option>
</select>
</div>
<div class="col-md-1">
@ -192,12 +209,20 @@
<div class="col-md-5">
<label for="payment_method" class="col-form-label">Payment Method:</label>
<select name="payment_method" id="payment_method" class="form-control" required>
<option >Select Payment Method</option>
<option value="1">Cash</option>
<option value="2">Online</option>
<option>Select Payment Method</option>
<option value="Cash">Cash</option>
<option value="Online">Online</option>
</select>
</div>
</div>
<div class="form-group row">
<div class="col-md-12">
<label for="remarks" class="col-form-label">Remarks:</label>
<!-- <input type="text" name="remarks" id="remarks" class="form-control"> -->
<textarea name="remarks" id="remarks" class="form-control"></textarea>
</div>
</div>
</form>
</div>
@ -210,7 +235,33 @@
</div><!-- /.modal -->
<script>
function downloadFile(fileId, fileName) {
window.location.href = 'downloadFile/' + fileName;
}
$(document).ready(function() {
// Function to toggle payment method based on status
function togglePaymentMethod() {
var status = $('#status_id').val();
console.log(status);
if (status === 'Paid') {
$('#payment_method').prop('disabled', false); // Enable payment method
} else {
$('#payment_method').prop('disabled', true).val(''); // Disable payment method and clear value
}
}
// Trigger the toggle function on page load
togglePaymentMethod();
// Trigger the toggle function whenever the status changes
$('#status_id').on('change', function() {
togglePaymentMethod();
});
});
$(document).ready(function() {
$('#supplierid').select2();
var formActionUrl = '';
// Event handler for file input change
@ -218,67 +269,70 @@
var fileName = $(this).val().split('\\').pop(); // Get the file name
$('#file-name-display').text(fileName); // Display the file name
});
$(document).on('click', '.edit-button', function() {
$('.modal-title').html('Edit Expense');
var expenseId = $(this).data('id');
var supplier_list = [<?php echo $supplier_list; ?>];
$('#supplierid').empty(); // Clear the supplier dropdown
$('#supplierid').append('<option >Select Supplier</option>');
supplier_list[0].forEach(function(supplier) {
$('#supplierid').append('<option value="' + supplier.SupplierID + '">' + supplier.SupplierName + '</option>');
});
formActionUrl = '<?php echo base_url().'editExpense' ?>'; // Set action URL for adding
$.ajax({
url: '<?php echo base_url().'getExpenseDetails'; ?>',
type: 'POST',
data: { id: expenseId },
success: function(response) {
var expense = JSON.parse(response);
$('#id').val(expense.id);
$('#transporterfile').val(''); // Clear the file input
$('#currentFileName').text(''); // Clear the file name display
$('#supplierid').val(expense.supplier_id);
$('#remarks').val(expense.remarks);
$('#cost').val(expense.cost);
$('#gst').val(expense.gst);
$('#total').val(expense.total);
if(expense.status == 1){
$('#status_id').val("Pending");
}else if(expense.status == 2){
$('#status_id').val("Completed");
}
if(expense.payment_method == 1){
$('#payment_method').val("Cash");
}else if(expense.payment_method == 2){
$('#payment_method').val("Online");
}
// Clear any existing file link and delete button
$('#transporterfile').next('.download_button').remove();
$('#transporterfile').next('.delete_button').remove();
if (expense.transporter_file) {
$('#transporterfile_name').val(expense.transporter_file); // Set the hidden input value
$('#currentFileName').text(expense.transporter_file); // Display the existing file name
// Construct the full URL to the file
var fileUrl = '<?php echo base_url('uploads/'); ?>' + expense.transporter_file;
// Create download link and delete button
var fileLink = '<a class="download_button" href="' + fileUrl + '" target="_blank" download="' + expense.transporter_file + '">Download Current File</a>';
var deleteButton = '<button id="deleteFile" class="delete_button" data-value="' + expense.id +'" data-id="' + expense.id + '" data-file="' + expense.transporter_file + '"><i class="fas fa-trash"></i></button>';
// Add the file link and delete button
$('#transporterfile').after(fileLink + ' ' + deleteButton);
function togglePaymentMethodEdit() {
var status = $('#status_id').val();
console.log(status);
if (status === 'Paid') {
$('#payment_method').prop('disabled', false); // Enable payment method
} else {
$('#transporterfile_name').val(''); // Clear hidden input if no file
$('#payment_method').prop('disabled', true).val(''); // Disable payment method and clear value
}
}
});
$(document).on('click', '.edit-button', function() {
});
$('.modal-title').html('Edit Expense');
var expenseId = $(this).data('id');
var supplier_list = [<?php echo $supplier_list; ?>];
$('#supplierid').empty(); // Clear the supplier dropdown
$('#supplierid').append('<option>Select Supplier</option>');
supplier_list[0].forEach(function(supplier) {
$('#supplierid').append('<option value="' + supplier.SupplierID + '">' + supplier.SupplierName + '</option>');
});
formActionUrl = '<?php echo base_url().'editExpense' ?>'; // Set action URL for adding
$.ajax({
url: '<?php echo base_url().'getExpenseDetails'; ?>',
type: 'POST',
data: { id: expenseId },
success: function(response) {
var expense = JSON.parse(response);
$('#id').val(expense.id);
$('#transporterfile').val(''); // Clear the file input
$('#currentFileName').text(''); // Clear the file name display
$('#supplierid').val(expense.supplier_id).trigger('change');
$('#remarks').val(expense.remarks);
$('#cost').val(expense.cost);
$('#gst').val(expense.gst);
$('#total').val(expense.total);
$('#status_id').val(expense.status);
$('#payment_method').val(expense.payment_method);
// Clear any existing file link and delete button
$('#transporterfile').next('.download_button').remove();
$('#transporterfile').next('.delete_button').remove();
if (expense.transporter_file) {
$('#transporterfile_name').val(expense.transporter_file); // Set the hidden input value
$('#currentFileName').text(expense.transporter_file); // Display the existing file name
// Construct the full URL to the file
var fileUrl = '<?php echo base_url('uploads/'); ?>' + expense.transporter_file;
// Create download link and delete button
var fileLink = '<a class="download_button" href="' + fileUrl + '" target="_blank" download="' + expense.transporter_file + '"><i class=" fas fa-file-download"></i></a>';
var deleteButton = '<button id="deleteFile" class="delete_button" data-value="' + expense.id +'" data-id="' + expense.id + '" data-file="' + expense.transporter_file + '"><i class="fas fa-trash"></i></button>';
// Add the file link and delete button
$('#transporterfile').after(fileLink + ' ' + deleteButton);
} else {
$('#transporterfile_name').val(''); // Clear hidden input if no file
}
togglePaymentMethodEdit();
}
});
});
$(document).on('click', '#addExpense', function () {
@ -287,7 +341,7 @@
$('.modal-title').html('Add Expense');
$('#transporterfile').val(''); // Clear the file input
$('#currentFileName').text(''); // Clear the file name display
$('#supplierid').val('');
$('#supplierid').val('').trigger('change');
$('#remarks').val('');
$('#cost').val('');
$('#gst').val('');
@ -296,22 +350,26 @@
$('#payment_method').val('');
var supplier_list = [<?php echo $supplier_list; ?>];
$('#supplierid').empty(); // Clear the supplier dropdown
$('#supplierid').append('<option >Select Supplier</option>');
$('#supplierid').append('<option>Select Supplier</option>');
supplier_list[0].forEach(function(supplier) {
$('#supplierid').append('<option value="' + supplier.SupplierID + '">' + supplier.SupplierName + '</option>');
});
formActionUrl = '<?php echo base_url().'addExpense' ?>'; // Set action URL for adding
togglePaymentMethodEdit();
});
// Handle form submission
$('#tempClick').on('click', function(e) {
e.preventDefault();
e.preventDefault();
// Native HTML5 form validation
if ($('#expenseForm')[0].checkValidity()) {
var formData = new FormData($('#expenseForm')[0]); // Use FormData to handle file upload
console.log(formActionUrl);
$.ajax({
url: formActionUrl, // Use the correct URL based on the button clicked
url: formActionUrl,
type: 'POST',
data: formData,
processData: false,
@ -332,7 +390,12 @@
alert('An error occurred: ' + error);
}
});
});
} else {
// If form is invalid, show native validation messages
$('#expenseForm')[0].reportValidity();
}
});
// DataTable initialization and date range filter logic (unchanged)
var table = $('#expense_list_table').DataTable({

View File

@ -59,6 +59,18 @@
<link href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
<style>
/* Select2 Input Hight Set */
.select2-selection.select2-selection--single{
height: calc(1.5em + .9rem + 2px);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height: 37px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
top: 7px;
}
/* Select2 Height End */
th{
background-color: #ddd !important;
}
@ -66,17 +78,17 @@
border: 1px solid grey;
border-radius: 4px !important;
}
legend {
border-bottom: 2px solid #FFF !important;
margin-left: -2%;
}
.form-group {
padding-bottom: 4%;
}
.badge {
color: red;
background-color: #fff;
}
legend {
border-bottom: 2px solid #FFF !important;
margin-left: -2%;
}
.form-group {
/* padding-bottom: 4%; */
}
.badge {
color: red;
background-color: #fff;
}
.btn-cancel {
background-color: grey; /* Red color */
color: white;

View File

@ -2,9 +2,11 @@
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script>
<style>
#MaterialRcvdDate, #InvoiceDate {
#MaterialRcvdDate,
#InvoiceDate {
text-align: left;
}
.autocomplete-suggestion {
cursor: pointer;
background-color: skyblue;
@ -113,7 +115,7 @@
'PONO',
$options,
set_value('PONO'),
'class="form-control searchabledropdown" id="PONO" data-toggle="select2" required="true"'
'class="form-control searchabledropdown" id="PONO" data-toggle="select2" required="true" onchange="yourFunctionName()"'
);
?>
<span class="help-block"></span>
@ -137,12 +139,13 @@
<div class="form-group col-md-4">
<label class="col-form-label">Invoice Date<span class="text-danger">*</span></label>
<div class="input-group">
<input type="text" 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">
<div class="input-group-append">
<input type="date" 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">
<!-- <input type="text" 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"> -->
<!-- <div class="input-group-append">
<span class="input-group-text">
<i class="ri-calendar-event-fill"></i>
</span>
</div>
</div> -->
</div><!-- input-group -->
<!-- <input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : '' ?>" max="<?= date('d/m/Y'); ?>" required> -->
@ -158,12 +161,13 @@
<div class="form-group col-md-4">
<label class="col-form-label">Material Received Date<span class="text-danger">*</span></label>
<div class="input-group">
<input type="text" 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">
<input type="date" 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">
<!-- <input type="text" 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">
<div class="input-group-append">
<span class="input-group-text">
<i class="ri-calendar-event-fill"></i>
</span>
</div>
</div> -->
</div>
<?php
// $data = array('name' => 'MaterialRcvdDate', 'value' => set_value('MaterialRcvdDate'), 'id' => 'MaterialRcvdDate', 'class' => 'form-control num', 'required' => 'true', 'autocomplete' => 'off');
@ -172,7 +176,7 @@
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<div class="form-group col-md-4">
<label class="col-form-label">Vechicle Number</label>
<?php
@ -180,7 +184,7 @@
echo form_input($data);
?>
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-4">
<label class="col-form-label">Transporter Name</label>
<?php
$option = array(0 => 'Transporter Name');
@ -193,14 +197,14 @@
?>
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-4">
<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');
echo form_input($data);
?>
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-4">
<label class="col-form-label">Driver Mobile Number</label>
<?php
$data = array('name' => 'DriverMobileNumber', 'value' => set_value('DriverMobileNumber'), 'id' => 'DriverMobileNumber', 'class' => 'form-control', 'maxlength' => '50', 'autocomplete' => 'off');
@ -270,7 +274,7 @@
</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">
<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>
@ -722,75 +726,41 @@
}
</script>
<script>
$("#weight-calc-modal").on("shown.bs.modal", function(e) {
var inx = $(e.relatedTarget).data('index');
var material = $(e.relatedTarget).data('material');
$(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 + " )");
$('#WeightTitle').text(" ( " + material + " )");
// Clear the modal inputs
$("#GrossWeight").val('');
$("#GrossWeightDate").val('');
$("#TareWeight").val('');
$("#TareWeightDate").val('');
$("#NetWeight").val('');
// 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];
// 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);
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 = $("#txtWeightFile" + inx)[0];
var targetInput = $("#WeightFile")[0];
var file = fileInput.files[0];
// Create a new DataTransfer object
@ -803,22 +773,61 @@
} 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('');
// 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");
// Close the modal
$("#weight-calc-modal").modal('hide');
} else {
console.log("Saving values for index: " + inx + " undefined");
}
}
}
</script>
<script>
function appendFilesFileds(data) {
@ -867,4 +876,191 @@
"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);
$("#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 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>

View File

@ -13,6 +13,19 @@ if (!empty($Emp)) {
}
}
?>
<style>
.btn-soft-primary {
color: white;
background-color: rgb(42, 206, 150);
border-color: rgb(42, 206, 150);
}
.btn-soft-primary:hover {
background-color: rgb(32, 176, 130); /* Slightly darker shade for hover */
border-color: rgb(32, 176, 130);
}
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->

View File

@ -1,6 +1,6 @@
<style>
.modal {
padding-right: 25% ! important;
/* padding-right: 25% ! important; */
}
.num {
@ -8,7 +8,7 @@
}
.modal-content {
width: 800px ! important;
/* width: 800px ! important; */
}
th {
@ -250,7 +250,7 @@
<!-- box closed here -->
<!-- Igr modal fade -->
<div id="Igrshow" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
@ -443,8 +443,8 @@
<!-- WeightCalculator modal fade -->
<div id="WeightCalculator" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-dialog modal-lg">
<div class="modal-content" style="border: 1px solid #ddd; margin-top: 73px; box-shadow: 0 0 40px rgb(0 0 0 / 43%);">
<div class="modal-header">
<h4 class="modal-title">Weight Calculator <span id="WeightTitle"></span></h4>
<button type="button" class="close" data-dismiss="modal"
@ -570,189 +570,157 @@
<script>
$("#Igrshow").on("shown.bs.modal", function(e) {
var inx = $(e.relatedTarget).data('id');
var igr = $(e.relatedTarget).data('userid');
var igrstatus = $(e.relatedTarget).data('igrstatus');
$(document).ready(function() {
$("#Igrshow").on("shown.bs.modal", function(e) {
console.log("hello");
var inx = $(e.relatedTarget).data('id');
var igr = $(e.relatedTarget).data('userid');
var igrstatus = $(e.relatedTarget).data('igrstatus');
// alert(igrstatus);
var buttonContainer = $(".buttonContainer");
var modal = $(this); // Reference to the modal itself
var invoiceDateInput = modal.find('#Invoice_Date');
var invoiceNoInput = modal.find('#Invoice_No');
var MaterialRcvdDateInput = modal.find('#MaterialRcvdDate');
var VehicleNoInput = modal.find('#Vehicle_No');
var TransporterIdInput = modal.find('#Transporter_Id');
var DriverInput = modal.find('#Driver_Name');
var DriverMobileNumberInput = modal.find('#DriverMobileNumber');
var MasterFileInput = modal.find('#MasterFile');
modal.find('#MasterFileLabel').hide();
// alert(igrstatus);
var buttonContainer = $(".buttonContainer");
var modal = $(this); // Reference to the modal itself
var invoiceDateInput = modal.find('#Invoice_Date');
var invoiceNoInput = modal.find('#Invoice_No');
var MaterialRcvdDateInput = modal.find('#MaterialRcvdDate');
var VehicleNoInput = modal.find('#Vehicle_No');
var TransporterIdInput = modal.find('#Transporter_Id');
var DriverInput = modal.find('#Driver_Name');
var DriverMobileNumberInput = modal.find('#DriverMobileNumber');
var MasterFileInput = modal.find('#MasterFile');
modal.find('#MasterFileLabel').hide();
var userRole = "<?php echo (int)$userRole; ?>";
if (userRole != 1) {
if (igrstatus == "ST074") {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
$(".a_tag_for_mrir").css("display", "block");
VehicleNoInput.prop('readonly', false);
DriverInput.prop('readonly', false);
DriverMobileNumberInput.prop('readonly', false);
MaterialRcvdDateInput.prop('readonly', false);
invoiceDateInput.prop('readonly', false);
invoiceNoInput.prop('readonly', false);
} else {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "none");
$(".a_tag_for_mrir").css("display", "none");
VehicleNoInput.prop('readonly', true);
DriverInput.prop('readonly', true);
DriverMobileNumberInput.prop('readonly', true);
MaterialRcvdDateInput.prop('readonly', true);
invoiceDateInput.prop('readonly', true);
invoiceNoInput.prop('readonly', true);
}
} else {
$(".a_tag_for_mrir").css("display", "none");
if (igrstatus == "ST074") {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
} else {
buttonContainer.find("#draftIGR").css("display", "none");
}
}
$("#tbleIGRAppend").empty();
$('#content').loader('show');
$.ajax({
data: {
id: igr
},
type: "POST",
url: "<?php echo base_url() ?>ViewIGRDetails",
success: function(data) {
// success:function(data) {
$('#content').loader('hide');
var parsedData = JSON.parse(data);
console.log(parsedData);
if (parsedData['details'].length === 0) {
console.log("No data available");
// Reset all relevant fields and table
$('#IgrshowTitle').text('');
$("#IGRNO1").val('');
$("#PONO1").val('');
$("#txtIGRLineItem").val('');
$('#printLink').attr('href', '#');
$('.help-block').text('');
$("#Vehicle_No").val('');
$("#Transporter_Id").val('');
$("#Driver_Name").val('');
$("#DriverMobileNumber").val('');
$("#IGRStatus").val('');
$("#PONo").val('');
$("#Supplier").val('');
$("#Add1").val('');
$("#Invoice_No").val('');
$("#Invoice_Date").val('');
$("#MaterialRcvdDate").val('');
$("#ser").val('');
$("#tbleIGRAppend").empty(); // Clear the table
// Hide the MasterFileLabel if no data
modal.find('#MasterFileLabel').hide();
return; // Exit the function early
var userRole = "<?php echo (int)$userRole; ?>";
if (userRole != 1) {
if (igrstatus == "ST074") {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
$(".a_tag_for_mrir").css("display", "block");
VehicleNoInput.prop('readonly', false);
DriverInput.prop('readonly', false);
DriverMobileNumberInput.prop('readonly', false);
MaterialRcvdDateInput.prop('readonly', false);
invoiceDateInput.prop('readonly', false);
invoiceNoInput.prop('readonly', false);
} else {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "none");
$(".a_tag_for_mrir").css("display", "none");
VehicleNoInput.prop('readonly', true);
DriverInput.prop('readonly', true);
DriverMobileNumberInput.prop('readonly', true);
MaterialRcvdDateInput.prop('readonly', true);
invoiceDateInput.prop('readonly', true);
invoiceNoInput.prop('readonly', true);
}
} else {
$(".a_tag_for_mrir").css("display", "none");
if (igrstatus == "ST074") {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
} else {
buttonContainer.find("#draftIGR").css("display", "none");
}
}
var trIGRHTML = '';
$("#tbleIGRAppend").empty();
// $('#content').loader('show');
$.each(parsedData['details'], function(i, item) {
if (igr == item.IGRNO) {
console.log(item);
$('#IgrshowTitle').text(" ( " + item.IGRNO + " ) ");
$("#IGRNO1").val(item.IGRNO);
$("#PONO1").val(item.PONO);
$("#txtIGRLineItem").val(item.IGRItemNo);
var baseUrl = '<?php echo base_url(); ?>purchaseorder/CreatePOPrint';
var newUrl = baseUrl + '?PONO=' + item.PONO + '&ReqType=' + item.POType;
$('#printLink').attr('href', newUrl);
var isOpenOrder = parseInt(item.IsOpenOrder ? item.IsOpenOrder : "0", 2);
console.log(item.IsOpenOrder);
console.log(isOpenOrder);
var formatted_IsOpenOrder = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "" : "Open";
$('.help-block').text(formatted_IsOpenOrder);
var button_text_for_IGRDraft = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "Save as Draft IGR" : "Save as Open IGR";
$('#draftIGR').text(button_text_for_IGRDraft);
$("#hiddenIsOpenOrder").val(isOpenOrder);
$("#Vehicle_No").val(item.VehicleNo);
$("#Transporter_Id").val(item.TransporterId);
$("#Driver_Name").val(item.DriverName);
$("#DriverMobileNumber").val(item.DriverMobileNumber);
$("#IGRStatus").val(item.IGRStatus);
$("#PONo").val(item.PONO);
$("#Supplier").val(item.SupplierName);
$("#Add1").val(item.Address);
$("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo);
console.log(typeof item.MasterFile);
$.ajax({
data: {
id: igr
},
type: "POST",
url: "<?php echo base_url() ?>ViewIGRDetails",
success: function(data) {
// success:function(data) {
// $('#content').loader('hide');
var parsedData = JSON.parse(data);
console.log(parsedData);
if (parsedData['details'].length === 0) {
console.log("No data available");
// Reset all relevant fields and table
$('#IgrshowTitle').text('');
$("#IGRNO1").val('');
$("#PONO1").val('');
$("#txtIGRLineItem").val('');
$('#printLink').attr('href', '#');
$('.help-block').text('');
$("#Vehicle_No").val('');
$("#Transporter_Id").val('');
$("#Driver_Name").val('');
$("#DriverMobileNumber").val('');
$("#IGRStatus").val('');
$("#PONo").val('');
$("#Supplier").val('');
$("#Add1").val('');
$("#Invoice_No").val('');
$("#Invoice_Date").val('');
$("#MaterialRcvdDate").val('');
$("#ser").val('');
$("#tbleIGRAppend").empty(); // Clear the table
// Hide the MasterFileLabel if no data
modal.find('#MasterFileLabel').hide();
if (typeof item.MasterFile == 'string') {
if (item.MasterFile !== null && item.MasterFile !== undefined && item.MasterFile.trim() !== "") {
modal.find('#MasterFileLabel a').attr('href', '<?php echo base_url() ?>' + 'public/uploads/Igrfiles/' + item.MasterFile);
modal.find('#MasterFileLabel a').attr('title', 'previously uploaded IGR Master File');
modal.find('#MasterFileLabel a').attr('target', '_blank');
modal.find('#MasterFileLabel a span').text('previously uploaded - ');
modal.find('#MasterFileLabel a small').text(item.MasterFile);
modal.find('#MasterFileLabel').show();
}
} else {
return; // Exit the function early
}
var trIGRHTML = '';
$.each(parsedData['details'], function(i, item) {
if (igr == item.IGRNO) {
console.log(item);
$('#IgrshowTitle').text(" ( " + item.IGRNO + " ) ");
$("#IGRNO1").val(item.IGRNO);
$("#PONO1").val(item.PONO);
$("#txtIGRLineItem").val(item.IGRItemNo);
var baseUrl = '<?php echo base_url(); ?>purchaseorder/CreatePOPrint';
var newUrl = baseUrl + '?PONO=' + item.PONO + '&ReqType=' + item.POType;
$('#printLink').attr('href', newUrl);
var isOpenOrder = parseInt(item.IsOpenOrder ? item.IsOpenOrder : "0", 2);
console.log(item.IsOpenOrder);
console.log(isOpenOrder);
var formatted_IsOpenOrder = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "" : "Open";
$('.help-block').text(formatted_IsOpenOrder);
var button_text_for_IGRDraft = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "Save as Draft IGR" : "Save as Open IGR";
$('#draftIGR').text(button_text_for_IGRDraft);
$("#hiddenIsOpenOrder").val(isOpenOrder);
$("#Vehicle_No").val(item.VehicleNo);
$("#Transporter_Id").val(item.TransporterId);
$("#Driver_Name").val(item.DriverName);
$("#DriverMobileNumber").val(item.DriverMobileNumber);
$("#IGRStatus").val(item.IGRStatus);
$("#PONo").val(item.PONO);
$("#Supplier").val(item.SupplierName);
$("#Add1").val(item.Address);
$("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo);
console.log(typeof item.MasterFile);
modal.find('#MasterFileLabel').hide();
}
// Format dates
var dcd = new Date(item.DeliveryChellanDate);
var dcd2 = (String(dcd.getDate()).padStart(2, '0') + '-' + (String(dcd.getMonth() + 1).padStart(2, '0')) + '-' + dcd.getFullYear());
$("#Invoice_Date").val(dcd2);
console.log(item.MaterialRcvdDate)
var Mat_rcv_date = (item.MaterialRcvdDate == 'null') ? ' ' : formatDateTime(item.MaterialRcvdDate, 1);
$("#MaterialRcvdDate").val(Mat_rcv_date);
console.log(item.MaterialRcvdDate)
var gross_rcv_date = (item.GrossWeightDate == 'null') ? ' ' : formatDateTime(item.GrossWeightDate, 2);
$("#ser").val(item.ServiceDescription);
i = i + 1;
// userrole is system admin also know as admin (if)
if (userRole == 1) {
$("#pendingQuantityHeader").css("display", "table-cell");
trIGRHTML += '<tr>' +
'<td style="width: 50px;" align="right">' + i + '</td>' +
'<td style="width: 100px;" name="MaterialName" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td style="width: 200px; word-wrap: break-word; word-break: break-all; white-space: normal;">' + item.MaterialName + '</td>' +
'<td style="width: 50px;" name="UOM">' + item.UOM + '</td>' +
'<td style="width: 100px;" align="right" id="Quantity' + i + '" name="Quantity">' + parseInt(item.Quantity) + '</td>' +
'<td style="width: 100px;" align="right" data-name="sel" ><input type="text" onchange="validateReceivedQuantity(' + i + ',' + isOpenOrder + ')"id="QuantityAsPerInvoice' + i + '" name="QuantityAsPerInvoice' + i + '" value="' + parseInt(item.QuantityAsPerInvoice) + '" onkeypress="return isNumberKey(event);" style="width: 75px;"></td>' +
'<td style="width: 100px;" name="PendingQuantity' + i + '" id="PendingQuantity' + i + '">' + ((isOpenOrder) ? 0 : parseInt(item.Quantity - item.QuantityAsPerInvoice)) + '</td>' +
'<td style="width: 150px;"><input type="text" id="Remark' + i + '" name="Remark' + i + '" class="form" onchange="SetRemarks(' + i + ')" style="width: 75px;"> </td>' +
'<td style="width: 50px;"><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="' + i + '" data-material="' + item.MaterialName + '" data-igrstatus = "' + igrstatus + '"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
'<input type="hidden" id="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
'<input type="hidden" id="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
'<input type="hidden" id="txtGrossWeight' + i + '" name="txtGrossWeight' + i + '" value="' + item.GrossWeight + '">' +
'<input type="hidden" id="txtGrossWeightDate' + i + '" name="txtGrossWeightDate' + i + '" value="' + item.GrossWeightDate + '">' +
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' +
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '" style="display:none;">' +
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">' +
'</tr>';
if ((item.Quantity - item.QuantityAsPerInvoice) == 0.00) {
$('#QuantityAsPerInvoice' + i).attr('readonly', 'true');
if (typeof item.MasterFile == 'string') {
if (item.MasterFile !== null && item.MasterFile !== undefined && item.MasterFile.trim() !== "") {
modal.find('#MasterFileLabel a').attr('href', '<?php echo base_url() ?>' + 'public/uploads/Igrfiles/' + item.MasterFile);
modal.find('#MasterFileLabel a').attr('title', 'previously uploaded IGR Master File');
modal.find('#MasterFileLabel a').attr('target', '_blank');
modal.find('#MasterFileLabel a span').text('previously uploaded - ');
modal.find('#MasterFileLabel a small').text(item.MasterFile);
modal.find('#MasterFileLabel').show();
}
} else {
modal.find('#MasterFileLabel').hide();
}
}
// userrole is security based on status we show and here (else if)
else if (userRole !== 1) {
if (igrstatus === "ST074") {
// Format dates
var dcd = new Date(item.DeliveryChellanDate);
var dcd2 = (String(dcd.getDate()).padStart(2, '0') + '-' + (String(dcd.getMonth() + 1).padStart(2, '0')) + '-' + dcd.getFullYear());
$("#Invoice_Date").val(dcd2);
console.log(item.MaterialRcvdDate)
var Mat_rcv_date = (item.MaterialRcvdDate == 'null') ? ' ' : formatDateTime(item.MaterialRcvdDate, 1);
$("#MaterialRcvdDate").val(Mat_rcv_date);
console.log(item.MaterialRcvdDate)
var gross_rcv_date = (item.GrossWeightDate == 'null') ? ' ' : formatDateTime(item.GrossWeightDate, 2);
$("#ser").val(item.ServiceDescription);
i = i + 1;
// userrole is system admin also know as admin (if)
if (userRole == 1) {
$("#pendingQuantityHeader").css("display", "table-cell");
trIGRHTML += '<tr>' +
@ -784,52 +752,88 @@
$('#QuantityAsPerInvoice' + i).attr('readonly', 'true');
}
} else {
$("#pendingQuantityHeader").css("display", "none");
trIGRHTML += '<tr>' +
'<td style="width: 50px;" align="right">' + i + '</td>' +
'<td style="width: 100px;" name="MaterialName" id="MaterialCode" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td style="width: 200px; word-wrap: break-word; word-break: break-all; white-space: normal;">' + item.MaterialName + '</td>' +
'<td style="width: 50px;" name="UOM">' + item.UOM + '</td>' +
'<td style="width: 100px;" align="right" name="Quantity">' + item.Quantity + '</td>' +
'<td style="width: 100px;" align="right" data-name="sel" >' + item.QuantityAsPerInvoice + '</td>' +
'<td style="width: 150px;">' + item.Remarks + '</td>' +
'<td style="width: 50px;"><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="' + i + '" data-material="' + item.MaterialName + '" data-igrstatus = "' + igrstatus + '"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
'<input type="hidden" id="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
'<input type="hidden" id="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
'<input type="hidden" id="txtGrossWeight' + i + '" name="txtGrossWeight' + i + '" value="' + item.GrossWeight + '">' +
'<input type="hidden" id="txtGrossWeightDate' + i + '" name="txtGrossWeightDate' + i + '" value="' + item.GrossWeightDate + '">' +
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' +
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '">' +
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">' +
'</tr>';
}
// userrole is security based on status we show and here (else if)
else if (userRole !== 1) {
if (igrstatus === "ST074") {
$("#pendingQuantityHeader").css("display", "table-cell");
trIGRHTML += '<tr>' +
'<td style="width: 50px;" align="right">' + i + '</td>' +
'<td style="width: 100px;" name="MaterialName" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td style="width: 200px; word-wrap: break-word; word-break: break-all; white-space: normal;">' + item.MaterialName + '</td>' +
'<td style="width: 50px;" name="UOM">' + item.UOM + '</td>' +
'<td style="width: 100px;" align="right" id="Quantity' + i + '" name="Quantity">' + parseInt(item.Quantity) + '</td>' +
'<td style="width: 100px;" align="right" data-name="sel" ><input type="text" onchange="validateReceivedQuantity(' + i + ',' + isOpenOrder + ')"id="QuantityAsPerInvoice' + i + '" name="QuantityAsPerInvoice' + i + '" value="' + parseInt(item.QuantityAsPerInvoice) + '" onkeypress="return isNumberKey(event);" style="width: 75px;"></td>' +
'<td style="width: 100px;" name="PendingQuantity' + i + '" id="PendingQuantity' + i + '">' + ((isOpenOrder) ? 0 : parseInt(item.Quantity - item.QuantityAsPerInvoice)) + '</td>' +
'<td style="width: 150px;"><input type="text" id="Remark' + i + '" name="Remark' + i + '" class="form" onchange="SetRemarks(' + i + ')" style="width: 75px;"> </td>' +
'<td style="width: 50px;"><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="' + i + '" data-material="' + item.MaterialName + '" data-igrstatus = "' + igrstatus + '"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
'<input type="hidden" id="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
'<input type="hidden" id="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
'<input type="hidden" id="txtGrossWeight' + i + '" name="txtGrossWeight' + i + '" value="' + item.GrossWeight + '">' +
'<input type="hidden" id="txtGrossWeightDate' + i + '" name="txtGrossWeightDate' + i + '" value="' + item.GrossWeightDate + '">' +
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' +
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '" style="display:none;">' +
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">' +
'</tr>';
if ((item.Quantity - item.QuantityAsPerInvoice) == 0.00) {
$('#QuantityAsPerInvoice' + i).attr('readonly', 'true');
}
} else {
$("#pendingQuantityHeader").css("display", "none");
trIGRHTML += '<tr>' +
'<td style="width: 50px;" align="right">' + i + '</td>' +
'<td style="width: 100px;" name="MaterialName" id="MaterialCode" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td style="width: 200px; word-wrap: break-word; word-break: break-all; white-space: normal;">' + item.MaterialName + '</td>' +
'<td style="width: 50px;" name="UOM">' + item.UOM + '</td>' +
'<td style="width: 100px;" align="right" name="Quantity">' + item.Quantity + '</td>' +
'<td style="width: 100px;" align="right" data-name="sel" >' + item.QuantityAsPerInvoice + '</td>' +
'<td style="width: 150px;">' + item.Remarks + '</td>' +
'<td style="width: 50px;"><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="' + i + '" data-material="' + item.MaterialName + '" data-igrstatus = "' + igrstatus + '"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
'<input type="hidden" id="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
'<input type="hidden" id="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
'<input type="hidden" id="txtGrossWeight' + i + '" name="txtGrossWeight' + i + '" value="' + item.GrossWeight + '">' +
'<input type="hidden" id="txtGrossWeightDate' + i + '" name="txtGrossWeightDate' + i + '" value="' + item.GrossWeightDate + '">' +
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' +
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '">' +
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">' +
'</tr>';
}
}
}
}
});
$("#tbleIGRAppend").empty();
$("#tbleIGRAppend").append(trIGRHTML);
if (parsedData['files'].length !== 0) {
$.each(parsedData['files'], function(i, item) {
appendExistingFilesFileds(item)
});
$("#tbleIGRAppend").empty();
$("#tbleIGRAppend").append(trIGRHTML);
if (parsedData['files'].length !== 0) {
$.each(parsedData['files'], function(i, item) {
appendExistingFilesFileds(item)
});
}
}
}
});
});
});
</script>
</script>
<script>
$('#update').click(function() {
$('#content').loader('show');
// $('#content').loader('show');
var igrno = $("#IGRNO1").val();
var materialrcv_date = $("#MaterialRcvdDate").val();
var inv_date = $("#Invoice_Date").val();
@ -843,13 +847,13 @@
type: "POST",
url: "<?php echo base_url() ?>UpdateIGR",
success: function(data) {
$('#content').loader('hide');
// $('#content').loader('hide');
alert(data);
}
});
});
$('#draftIGR').click(function() {
$('#content').loader('show');
// $('#content').loader('show');
var igrno = $("#IGRNO1").val();
var pono = $("#PONO1").val();
var status = 0;
@ -905,14 +909,14 @@
processData: false,
contentType: false,
success: function(data) {
$('#content').loader('hide');
// $('#content').loader('hide');
alert(data);
location.reload();
}
});
});
$('#generateIGR').click(function() {
$('#content').loader('show');
// $('#content').loader('show');
var igrno = $("#IGRNO1").val();
var pono = $("#PONO1").val();
var status = 1;
@ -965,7 +969,7 @@
processData: false,
contentType: false,
success: function(data) {
$('#content').loader('hide');
// $('#content').loader('hide');
alert(data);
location.reload();
}
@ -1122,71 +1126,72 @@
$("#TareWeightDate").val($("#clock").text());
}
}
$("#WeightCalculator").on("shown.bs.modal", function(e) {
var inx = $(e.relatedTarget).data('index');
console.log(inx);
var material = $(e.relatedTarget).data('material');
var modal = $(this);
$(document).ready(function() {
$("#WeightCalculator").on("shown.bs.modal", function(e) {
var inx = $(e.relatedTarget).data('index');
console.log(inx);
var material = $(e.relatedTarget).data('material');
var modal = $(this);
$('#WeightTitle').text(" ( " + material + " )");
$('#WeightTitle').text(" ( " + material + " )");
// Clear the modal inputs
$("#GrossWeight").val('');
$("#GrossWeightDate").val('');
$("#TareWeight").val('');
$("#TareWeightDate").val('');
$("#NetWeight").val('');
$("#WeightFile").val('');
// Clear the modal inputs
$("#GrossWeight").val('');
$("#GrossWeightDate").val('');
$("#TareWeight").val('');
$("#TareWeightDate").val('');
$("#NetWeight").val('');
$("#WeightFile").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];
var fileName = $("#txtWeightFileName" + inx).val();
modal.find('#WeightFileLabel').hide();
console.log(typeof fileName);
if (fileName !== 'null' && fileName !== undefined && fileName.trim() !== "") {
modal.find('#WeightFileLabel a').attr('title', 'previously uploaded IGR Weight File');
modal.find('#WeightFileLabel a').attr('href', '<?php echo base_url() ?>' + 'public/uploads/Igrfiles/' + fileName);
modal.find('#WeightFileLabel a').attr('target', '_blank');
modal.find('#WeightFileLabel a span').text('previously uploaded - ');
modal.find('#WeightFileLabel a small').text(fileName);
modal.find('#WeightFileLabel').show();
}
console.log(fileInput);
console.log("Selected values for index:", typeof inx, inx);
// 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];
var fileName = $("#txtWeightFileName" + inx).val();
modal.find('#WeightFileLabel').hide();
console.log(typeof fileName);
if (fileName !== 'null' && fileName !== undefined && fileName.trim() !== "") {
modal.find('#WeightFileLabel a').attr('title', 'previously uploaded IGR Weight File');
modal.find('#WeightFileLabel a').attr('href', '<?php echo base_url() ?>' + 'public/uploads/Igrfiles/' + fileName);
modal.find('#WeightFileLabel a').attr('target', '_blank');
modal.find('#WeightFileLabel a span').text('previously uploaded - ');
modal.find('#WeightFileLabel a small').text(fileName);
modal.find('#WeightFileLabel').show();
}
console.log(fileInput);
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);
// 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);
fileName
if (fileInput && fileInput.files.length > 0) {
var targetInput = $("#WeightFile")[0];
var file = fileInput.files[0];
fileName
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);
// Create a new DataTransfer object
var dataTransfer = new DataTransfer();
dataTransfer.items.add(file);
// Set the file to the target input
targetInput.files = dataTransfer.files;
// Set the file to the target input
targetInput.files = dataTransfer.files;
} else {
console.log("No file selected or file input not found.");
}
} else {
console.log("No file selected or file input not found.");
}
});
});
function modalSave() {
var v1 = $("#GrossWeight").val();
var v2 = $("#GrossWeightDate").val();
@ -1427,7 +1432,7 @@
formData.append('count', counter);
formData.append('igr', igr);
$('.content').loader('show');
// $('.content').loader('show');
$.ajax({
data: formData,
type: "POST",
@ -1441,7 +1446,7 @@
billNo = chars[1] != undefined ? chars[1] : "";
alert('File uploaded successfully.');
addToTable(counter, billNo, file.name);
$('.content').loader('hide');
// $('.content').loader('hide');
$('#billModel').modal('hide');
}
}
@ -1600,6 +1605,7 @@ function appendExistingFilesFileds(data){
[10, 20, 30, 50, "All"]
], // Rows per page options
responsive: true, // Responsive table
order: [
[0, 'desc']
], // Default ordering (column index 0, ascending)