Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme
This commit is contained in:
commit
812147f228
@ -2522,14 +2522,14 @@ if (!empty($getlogpodtl)) {
|
|||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="spl">
|
<tbody id="splPoBillTbId">
|
||||||
<?php
|
<?php
|
||||||
if (!empty($billfile)) {
|
if (!empty($billfile)) {
|
||||||
|
|
||||||
foreach ($billfile as $row => $gd) {
|
foreach ($billfile as $row => $gd) {
|
||||||
if (!empty($gd->BillNo)) {
|
if (!empty($gd->BillNo)) {
|
||||||
$index = $row + 1;
|
$index = $row + 1;
|
||||||
?>
|
?>
|
||||||
<tr id="lastvalue">
|
<tr id="lastvalue">
|
||||||
<td><?php echo $gd->BillNo ?></td>
|
<td><?php echo $gd->BillNo ?></td>
|
||||||
|
|
||||||
@ -5090,8 +5090,17 @@ if (!empty($getlogpodtl)) {
|
|||||||
|
|
||||||
},
|
},
|
||||||
error: function(jqXHR, textStatus, errorThrown) {
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
console.error("AJAX Error: " + textStatus + ": " + errorThrown);
|
// Handle errors here
|
||||||
alert("Error: " + textStatus);
|
$('#loader').hide();
|
||||||
|
console.error("AJAX Error: ", textStatus, errorThrown);
|
||||||
|
alert("An error occurred: " + textStatus + " - " + errorThrown);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
complete: function() {
|
||||||
|
// Actions that should always happen regardless of success or error
|
||||||
|
console.log("AJAX request completed.");
|
||||||
|
$('#loader').hide(); // Hide the loader in any case
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -5304,24 +5313,25 @@ if (!empty($getlogpodtl)) {
|
|||||||
|
|
||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: formData, // The form data to send (contains the file)
|
data: formData,
|
||||||
type: "POST", // HTTP method
|
type: "POST",
|
||||||
url: "<?php echo base_url();?>purchaseorder/uploadfile", // URL to send the request to
|
url: "<?php echo base_url();?>purchaseorder/uploadfile",
|
||||||
cache: false, // Disable caching of the response
|
cache: false,
|
||||||
contentType: false, // Tell jQuery not to set content type (it's handled by FormData)
|
contentType: false,
|
||||||
processData: false, // Don't process the data into a query string (needed for FormData)
|
processData: false,
|
||||||
|
|
||||||
|
success: function(response) {
|
||||||
|
if (response) {
|
||||||
|
$('#loader').hide();
|
||||||
|
updateRowToTable(response.data,response.data.BillNo);
|
||||||
|
console.log(response.data);
|
||||||
|
$('#billModel').modal('hide');
|
||||||
|
|
||||||
success: function(data) {
|
|
||||||
if (data) {
|
|
||||||
$('#loader').hide(); // Hide loader on success
|
|
||||||
alert(data); // Show response data (you may want to customize this)
|
|
||||||
$('#billModel').modal('hide'); // Hide the modal if file uploaded successfully
|
|
||||||
window.location.reload(); // Reload the page to reflect changes
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
error: function(xhr, status, error) { // Handle errors gracefully
|
error: function(xhr, status, error) {
|
||||||
$('#loader').hide(); // Hide the loader even on error
|
$('#loader').hide();
|
||||||
let errorMessage = '';
|
let errorMessage = '';
|
||||||
|
|
||||||
// Custom error messages based on status codes
|
// Custom error messages based on status codes
|
||||||
@ -5417,11 +5427,13 @@ if (!empty($getlogpodtl)) {
|
|||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function(data) {
|
success: function(response) {
|
||||||
if (data) {
|
if (response) {
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
alert(data);
|
alert(response.message);
|
||||||
window.location.reload();
|
console.log(response.data.BillNo);
|
||||||
|
console.log(response.data.FilePath);
|
||||||
|
addRowToTable(response.data);
|
||||||
$('#billModel').modal('hide');
|
$('#billModel').modal('hide');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -5552,3 +5564,56 @@ if (!empty($getlogpodtl)) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// This function adds a new row to the table
|
||||||
|
function addRowToTable(data) {
|
||||||
|
|
||||||
|
var currentRowCount = $('#splPoBillTbId tr').length;
|
||||||
|
|
||||||
|
var newIndex = currentRowCount + 1;
|
||||||
|
|
||||||
|
var newRow = `
|
||||||
|
<tr id="lastvalue">
|
||||||
|
<td>${data.BillNo}</td>
|
||||||
|
<td>${data.FilePath ? data.FilePath : "No File"}</td>
|
||||||
|
<input type="hidden" id="billnos${newIndex}" value="${data.BillNo}">
|
||||||
|
<input type="hidden" id="file${newIndex}" name="file" value="${data.FilePath}">
|
||||||
|
<td style="cursor:pointer">
|
||||||
|
<span onclick="openbillmodel(${newIndex});">
|
||||||
|
<i class="ri-pencil-fill"></i>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<a target="_blank" href="<?= base_url('public/uploads/BillFiles/') ?>${data.FilePath}">
|
||||||
|
<i class="fa fa-download"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
|
||||||
|
$('#splPoBillTbId').append(newRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateRowToTable(updatedData, billNo) {
|
||||||
|
// Find the row using the provided BillNo
|
||||||
|
$('#splPoBillTbId tr').each(function(index) {
|
||||||
|
// Check if the BillNo of the current row matches the provided billNo
|
||||||
|
var currentBillNo = $(this).find('td:first').text(); // Assuming BillNo is in the first cell
|
||||||
|
if (currentBillNo === billNo) {
|
||||||
|
// Update the relevant cells of the row with the new values from updatedData
|
||||||
|
$(this).find('td:nth-child(1)').text(updatedData.BillNo); // Update BillNo
|
||||||
|
$(this).find('td:nth-child(2)').text(updatedData.FilePath || 'No File'); // Update FilePath
|
||||||
|
|
||||||
|
// Also update the hidden inputs if necessary
|
||||||
|
$(this).find('input[id^="billnos"]').val(updatedData.BillNo); // Update BillNo hidden input
|
||||||
|
$(this).find('input[id^="file"]').val(updatedData.FilePath); // Update FilePath hidden input
|
||||||
|
|
||||||
|
// Exit the loop once the correct row is found and updated
|
||||||
|
return false; // Stops the iteration as we've found the row to update
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user