Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme

This commit is contained in:
Smart 2024-10-16 16:58:45 +05:30
commit f01e195f01
6 changed files with 137 additions and 47 deletions

View File

@ -4256,8 +4256,14 @@ class Purchaseorder extends BaseController
$filelist = array('PONO' => $pono, 'IGRNO' => $igr, 'FilePath' => $Picture); $filelist = array('PONO' => $pono, 'IGRNO' => $igr, 'FilePath' => $Picture);
$uploadfiles = $this->purchaseorder_model->insertfile($filelist); $uploadfiles = $this->purchaseorder_model->insertfile($filelist);
if ($uploadfiles > 0) { if ($uploadfiles > 0) {
echo "file updated successfully!"; $response = [
return true; 'message' => 'File updated successfully!',
'data' => $uploadfiles
];
// Return the response as JSON
return $this->response->setJSON($response);
} }
} else{ } else{
echo " Internal Server Error..!!"; echo " Internal Server Error..!!";
@ -4395,8 +4401,16 @@ class Purchaseorder extends BaseController
} }
if($uploadfile > 0){ if( $uploadfile['afftectedRows'] > 0){
echo "updated successfully!";
$response = [
'message' => 'File updated successfully!',
'data' =>$uploadfile['updatedRow']
];
// Return the response as JSON
return $this->response->setJSON($response);
} }
else{ else{
echo "Update Failed (maybe same file provided for update kindly check)..!!"; echo "Update Failed (maybe same file provided for update kindly check)..!!";

View File

@ -2325,12 +2325,23 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
function updatefile($bill, $Picture) function updatefile($bill, $Picture)
{ {
$uploadfile;
$this->db->table('t_purchaseorder_billupload') $this->db->table('t_purchaseorder_billupload')
->set('FilePath', $Picture) ->set('FilePath', $Picture)
->where('BillNo', $bill) ->where('BillNo', $bill)
->update(); ->update();
$afftectedRows = $this->db->affectedRows();
return $afftectedRows; $uploadfile['afftectedRows'] = $this->db->affectedRows();
if( $uploadfile['afftectedRows'] > 0){
$uploadfile['updatedRow'] = $this->db->table('t_purchaseorder_billupload')
->where('BillNo', $bill)
->get()
->getRowArray();
}
return $uploadfile;
} }
@ -2425,11 +2436,11 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
function insertfile($filelist) function insertfile($filelist)
{ {
//print_r($myfile);die;
$builder = $this->db->table('t_purchaseorder_billupload'); $builder = $this->db->table('t_purchaseorder_billupload');
$builder->insert($filelist); $builder->insert($filelist);
$myfile = $this->db->affectedRows(); $insertedID = $this->db->insertID();
return $myfile; $insertedRow = $builder->where('BillNo', $insertedID)->get()->getRowArray();
return $insertedRow;
} }
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/

View File

@ -1096,11 +1096,11 @@ if (!empty($getlogpodtl)) {
<table id="ServiceTable" class="table table-striped table-hover mb-0" style="font-size:12px;"> <table id="ServiceTable" class="table table-striped table-hover mb-0" style="font-size:12px;">
<thead> <thead>
<tr> <tr>
<th>SNo</th> <th style="text-align:center !important;">SNo</th>
<th>Requisition No</th> <th style="text-align:center !important;">Requisition No</th>
<th>Item Code</th> <th style="text-align:center !important;">Item Code</th>
<th>Item Name</th> <th>Item Name</th>
<th style="text-align: right;">Quantity</th> <th style="text-align: center;">Quantity</th>
<th>UOM</th> <th>UOM</th>
<th style="text-align: right;">Rate <?php echo "($INRSYM)" ?></th> <th style="text-align: right;">Rate <?php echo "($INRSYM)" ?></th>
<th style="text-align: right;">Basic Amount <?php echo "($INRSYM)" ?></th> <th style="text-align: right;">Basic Amount <?php echo "($INRSYM)" ?></th>
@ -1132,11 +1132,11 @@ if (!empty($getlogpodtl)) {
?> ?>
<tr id="<?php echo $index; ?>"> <tr id="<?php echo $index; ?>">
<td align="left"><?php echo $index; ?></td> <td align="center"><?php echo $index; ?></td>
<td><?php echo $record->ReqNo ?></td> <td align="center"><?php echo $record->ReqNo ?></td>
<td><?php echo $record->MaterialCode ?></td> <td align="center"><?php echo $record->MaterialCode ?></td>
<td><?php echo $record->MaterialName ?></td> <td><?php echo $record->MaterialName ?></td>
<td align="right"><?php echo $record->Quantity ?></td> <td align="center"><?php echo $record->Quantity ?></td>
<td><?php echo $record->UOM ?></td> <td><?php echo $record->UOM ?></td>
<td align="right"><?php echo $record->Rate ?></td> <td align="right"><?php echo $record->Rate ?></td>

View File

@ -128,7 +128,7 @@
<th>PONO#</th> <th>PONO#</th>
<th>PO Type</th> <th>PO Type</th>
<th>Supplier Name</th> <th>Supplier Name</th>
<th>Total Order Value</th> <th style="text-align: right !important;">Total Order Value</th>
<th>PO Status</th> <th>PO Status</th>
<th>Delivery Option</th> <th>Delivery Option</th>
<th>Delivery Date</th> <th>Delivery Date</th>
@ -152,7 +152,7 @@
<td><?php echo $record->ReqType ?></td> <td><?php echo $record->ReqType ?></td>
<td><?php echo $record->SupplierName ?></td> <td><?php echo $record->SupplierName ?></td>
<td><?php echo $record->TotalOrderValue ?></td> <td align="right"><?php echo $record->TotalOrderValue ?></td>
<!-- <td><?php echo $record->StatusName ?></td> --> <!-- <td><?php echo $record->StatusName ?></td> -->
<td><?php <td><?php

View File

@ -2522,7 +2522,7 @@ 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)) {
@ -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>
&nbsp;&nbsp;
<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>