changes in igr vadivel J

This commit is contained in:
vadivel J 2024-10-26 17:06:17 +05:30
parent 7b6d45f25c
commit e70d7d4ba4
2 changed files with 125 additions and 54 deletions

View File

@ -309,12 +309,12 @@ class Inwardgateregister extends BaseController
$deleteAdditionalFile = false; $deleteAdditionalFile = false;
$fileid = $this->request->getPost('id'); $fileid = $this->request->getPost('id');
$deleteAdditionalFile = $this->inwardgateregister_model->deleteAdditionalFile($fileid); $deleteAdditionalFile = $this->inwardgateregister_model->deleteAdditionalFile($fileid);
return $deleteAdditionalFile; return $this->response->setJSON([
// if ($deleteAdditionalFile) { 'status' => 'success',
// echo "file deleted successfully!"; 'message' => 'Operation successful',
// } else { 'data' => $deleteAdditionalFile
// echo "file details not exist to delete"; ]);
// }
} }
@ -706,7 +706,7 @@ function viewIGRDetails()
} }
function UpdateIGR() function GR()
{ {
$IGRNo = $this->request->getPost('igr'); $IGRNo = $this->request->getPost('igr');
$PONo = $this->request->getPost('po'); $PONo = $this->request->getPost('po');

View File

@ -236,8 +236,12 @@
?> ?>
<tr id="<?php echo $index ?>" > <tr id="<?php echo $index ?>" >
<td align="right"><?php echo $date; ?></td> <td align="right"><?php echo $date; ?></td>
<td><a data-toggle="modal" data-target="#Igrshow" data-id="<?php echo $index;?>" data-inx="<?php echo $index;?>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>"> <?php echo $record->IGRNO ?></a></td> <td style="cursor:pointer; color:#0bb2b5" ><a data-toggle="modal" data-target="#Igrshow" data-id="<?php echo $index;?>" data-inx="<?php echo $index;?>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>">
<td><a data-toggle="modal" data-target="#CostCentershow" data-id="<?php echo $index;?>" data-igno="<?php echo $record->IGRNO;?>" data-pono="<?php echo $record->PONO ?>" target="_blank"> <?php echo $record->PONO ?></a></td> <?php echo $record->IGRNO ?></a>
</td>
<td style="cursor:pointer; color:#0bb2b5" ><a data-toggle="modal" data-target="#CostCentershow" data-id="<?php echo $index;?>" data-igno="<?php echo $record->IGRNO;?>" data-pono="<?php echo $record->PONO ?>" target="_blank">
<?php echo $record->PONO ?></a>
</td>
<td><?php echo $record->SupplierName ?></td> <td><?php echo $record->SupplierName ?></td>
<td><?php echo $record->DeliveryChellanOrInvoiceNo ?></td> <td><?php echo $record->DeliveryChellanOrInvoiceNo ?></td>
<td align="right"><?php <td align="right"><?php
@ -437,16 +441,20 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row text-right"> <br><br>
<div class="row text-left">
<br> <br>
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<input type="file" name="MasterFile" id="MasterFile" onchange="filenames(this.name); "> <label> Master IGR file</label>
<br>
<input type="file" name="MasterFile" id="MasterFile" onchange="filenames(this.name); ">
<label id="MasterFileLabel" style="display:none;"> <label id="MasterFileLabel" style="display:none;">
<a><span></span><small></small></a> <a><span></span><small></small></a>
</label> </label>
</div> </div>
</div> </div>
<div class="files"> <div class="files ">
<div class="form-row float-right"> <div class="form-row float-right">
<div class="form-group"> <div class="form-group">
<button type="button" class="btn btn-primary waves-effect btn-sm a1" <button type="button" class="btn btn-primary waves-effect btn-sm a1"
@ -613,6 +621,9 @@
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$("#Igrshow").on("shown.bs.modal", function(e) { $("#Igrshow").on("shown.bs.modal", function(e) {
$('#loader').show();
console.log("hello"); console.log("hello");
var inx = $(e.relatedTarget).data('id'); var inx = $(e.relatedTarget).data('id');
@ -860,17 +871,43 @@
$("#tbleIGRAppend").empty(); $("#tbleIGRAppend").empty();
$("#tbleIGRAppend").append(trIGRHTML); $("#tbleIGRAppend").append(trIGRHTML);
if (parsedData['files'].length !== 0) {
if (parsedData['files'].length != 0) {
$.each(parsedData['files'], function(i, item) { $.each(parsedData['files'], function(i, item) {
appendExistingFilesFileds(item)
if(parseInt(item.Isactive)){
console.log(item);
appendExistingFilesFileds(item)
}
}); });
} }
},
error: function(xhr, status, error) { // Error callback
console.error('AJAX Error:', status, error);
alert("An error occurred: " + error);
// Additional error handling (e.g., showing a custom message)
},
complete: function() { // Complete callback
$('#loader').hide();
console.log('AJAX request completed.');
// Any cleanup or final actions after success/error
} }
}); });
}); });
}); });
</script> </script>
<script>
$(document).ready(function(){
$('#Igrshow').on("hide.bs.modal", function(e){
$('#existingContainer').empty();
});
});
</script>
<script> <script>
$('#update').click(function() { $('#update').click(function() {
// $('#content').loader('show'); // $('#content').loader('show');
@ -887,7 +924,7 @@
type: "POST", type: "POST",
url: "<?php echo base_url() ?>UpdateIGR", url: "<?php echo base_url() ?>UpdateIGR",
success: function(data) { success: function(data) {
// $('#content').loader('hide');
alert(data); alert(data);
} }
}); });
@ -949,14 +986,14 @@
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
// $('#content').loader('hide');
alert(data); alert(data);
location.reload(); location.reload();
} }
}); });
}); });
$('#generateIGR').click(function() { $('#generateIGR').click(function() {
// $('#content').loader('show');
var igrno = $("#IGRNO1").val(); var igrno = $("#IGRNO1").val();
var pono = $("#PONO1").val(); var pono = $("#PONO1").val();
var status = 1; var status = 1;
@ -1002,6 +1039,7 @@
} else { } else {
console.log("ajax call"); console.log("ajax call");
} }
$('#loader').show();
$.ajax({ $.ajax({
data: formData, data: formData,
type: "POST", type: "POST",
@ -1009,9 +1047,19 @@
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
// $('#content').loader('hide');
alert(data); alert(data);
location.reload(); location.reload();
},
error: function(xhr, status, error) { // Error callback
console.error('AJAX Error:', status, error);
alert("An error occurred: " + error);
// Additional error handling (e.g., showing a custom message)
},
complete: function() { // Complete callback
$('#loader').hide();
console.log('AJAX request completed.');
// Any cleanup or final actions after success/error
} }
}); });
}); });
@ -1546,9 +1594,9 @@
var billNo = data != null && data != '' ? data.BillNo : ''; var billNo = data != null && data != '' ? data.BillNo : '';
var downloadUrl = `${base_url}public/uploads/Igrfiles/${filePath}`; var downloadUrl = `${base_url}public/uploads/Igrfiles/${filePath}`;
var newRowHtml = `<div class="form-row mt-2 "> var newRowHtml = `<div class="form-row pad mt-2 ">
<div class="col-md-4"> <div class="col-md-4">
<span>File Name</span> <span><b>File Name</b></span>
<input type="text" maxlength="255" class="form-control" <input type="text" maxlength="255" class="form-control"
value="${fileName}" readonly> value="${fileName}" readonly>
</div> </div>
@ -1571,16 +1619,16 @@
function appendFilesFileds(data) { function appendFilesFileds(data) {
var newRowHtml = ` var newRowHtml = `
<div class="form-row pad"> <div class="form-row pad mt-2">
<div class="form-group col-md-4"> <div class=" col-md-4">
<label class="col-form-label">File name</label> <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 : ''}"> <input type="text" id="file_name" name="file_name[]" maxlength="255" class="form-control" value="${data != null && data != '' ? data.file_name : ''}">
</div> </div>
<div class="form-group col-md-4"> <div class=" col-md-4">
<label class="col-form-label" for="emp_file">File</label> <label class="col-form-label" for="emp_file">File</label>
<input type="file" id="emp_file" name="emp_file[]" class="form-control"> <input type="file" id="emp_file" name="emp_file[]" class="form-control">
</div> </div>
<div class="form-group col-md-4 p-4"> <div class=" col-md-4" style="margin-top: 40px;">
<button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)">Remove</button> <button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)">Remove</button>
<button type="button" class="btn btn-primary btn-sm a1" onclick="appendFilesFileds()">Add</button> <button type="button" class="btn btn-primary btn-sm a1" onclick="appendFilesFileds()">Add</button>
</div> </div>
@ -1591,46 +1639,69 @@
$('#filesContainer .pad:last .a1').show(); $('#filesContainer .pad:last .a1').show();
} }
// function removeContact(button) {
// $(button).closest('.pad').remove();
// $('#filesContainer .a1').hide();
// $('#filesContainer .pad:last .a1').show();
// var len = $('#filesContainer .pad:last .a1')
// var length = len.length;
// if (length == 0) {
// $('#day').show()
// } else {
// $('#day').hide()
// }
// }
function removeContact(button) { function removeContact(button) {
if (button.id != '') {
$.ajax({
if ( button.value != '') {
let deleteConfirmation=confirm("Do you wish to Delete the Selected File?");
if(deleteConfirmation){
$('#loader').show();
$.ajax({
data: { data: {
id: button.id id: button.value
}, },
type: "POST", type: "POST",
url: "<?php echo base_url(); ?>deleteAdditionalIGRFile", url: "<?php echo base_url(); ?>deleteAdditionalIGRFile",
success: function(data) { success: function(data) {
if (data) { if (data.status === 'success' && data.data === true)
alert("File removed"); {
return false;
$(button).closest('.pad').remove();
$('#filesContainer .a1').hide();
$('#filesContainer .pad:last .a1').show();
var filesContainer = $('#filesContainer .pad:last .a1');
filesContainer.length === 0 ? $('#additionalfilebtn').show() : $('#additionalfilebtn').hide();
return true;
} else {
console.log('Failed to delete: Check server response.');
}
},
error: function(xhr, status, error) {
console.error('AJAX Error:', status, error);
alert("An error occurred: " + error);
},
complete: function() {
$('#loader').hide();
console.log('AJAX request completed.');
} }
}
}); });
} }
$(button).closest('.pad').remove(); }else{
$('#filesContainer .a1').hide();
$('#filesContainer .pad:last .a1').show(); $(button).closest('.pad').remove();
var len = $('#filesContainer .pad:last .a1') $('#filesContainer .a1').hide();
var length = len.length; $('#filesContainer .pad:last .a1').show();
if (length == 0) { var len = $('#filesContainer .pad:last .a1')
$('#additionalfilebtn').show() var length = len.length;
} else { if (length == 0) {
$('#additionalfilebtn').hide() $('#additionalfilebtn').show()
} else {
$('#additionalfilebtn').hide()
}
} }
} }
$(document).ready(function() { $(document).ready(function() {