diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php index a06ca417..b655a10d 100755 --- a/app/Controllers/Purchaseorder.php +++ b/app/Controllers/Purchaseorder.php @@ -4256,8 +4256,14 @@ class Purchaseorder extends BaseController $filelist = array('PONO' => $pono, 'IGRNO' => $igr, 'FilePath' => $Picture); $uploadfiles = $this->purchaseorder_model->insertfile($filelist); if ($uploadfiles > 0) { - echo "file updated successfully!"; - return true; + $response = [ + 'message' => 'File updated successfully!', + 'data' => $uploadfiles + ]; + + // Return the response as JSON + return $this->response->setJSON($response); + } } else{ echo " Internal Server Error..!!"; @@ -4395,8 +4401,16 @@ class Purchaseorder extends BaseController } - if($uploadfile > 0){ - echo "updated successfully!"; + if( $uploadfile['afftectedRows'] > 0){ + + $response = [ + 'message' => 'File updated successfully!', + 'data' =>$uploadfile['updatedRow'] + ]; + + // Return the response as JSON + return $this->response->setJSON($response); + } else{ echo "Update Failed (maybe same file provided for update kindly check)..!!"; diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index b2d0c71e..9edea48b 100755 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -2325,12 +2325,23 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, function updatefile($bill, $Picture) { + $uploadfile; $this->db->table('t_purchaseorder_billupload') ->set('FilePath', $Picture) ->where('BillNo', $bill) ->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) { - //print_r($myfile);die; $builder = $this->db->table('t_purchaseorder_billupload'); $builder->insert($filelist); - $myfile = $this->db->affectedRows(); - return $myfile; + $insertedID = $this->db->insertID(); + $insertedRow = $builder->where('BillNo', $insertedID)->get()->getRowArray(); + return $insertedRow; } /*------------------------------------------------------------------------------*/ diff --git a/app/Views/EditservicePurchaseorder.php b/app/Views/EditservicePurchaseorder.php index 27b751dd..f4a4900a 100755 --- a/app/Views/EditservicePurchaseorder.php +++ b/app/Views/EditservicePurchaseorder.php @@ -1096,11 +1096,11 @@ if (!empty($getlogpodtl)) {
| SNo | -Requisition No | -Item Code | +SNo | +Requisition No | +Item Code | Item Name | -Quantity | +Quantity | UOM | Rate | Basic Amount | @@ -1132,11 +1132,11 @@ if (!empty($getlogpodtl)) { ?>||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| - | ReqNo ?> | -MaterialCode ?> | ++ | ReqNo ?> | +MaterialCode ?> | MaterialName ?> | -Quantity ?> | +Quantity ?> | UOM ?> | Rate ?> | diff --git a/app/Views/POlist.php b/app/Views/POlist.php index c1bb7d8f..a3696fa1 100755 --- a/app/Views/POlist.php +++ b/app/Views/POlist.php @@ -128,7 +128,7 @@PONO# | PO Type | Supplier Name | -Total Order Value | +Total Order Value | PO Status | Delivery Option | Delivery Date | @@ -152,7 +152,7 @@ReqType ?> | SupplierName ?> | -TotalOrderValue ?> | +TotalOrderValue ?> | Action |
| BillNo ?> | @@ -5090,8 +5090,17 @@ if (!empty($getlogpodtl)) { }, error: function(jqXHR, textStatus, errorThrown) { - console.error("AJAX Error: " + textStatus + ": " + errorThrown); - alert("Error: " + textStatus); + // Handle errors here + $('#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(); $.ajax({ - data: formData, // The form data to send (contains the file) - type: "POST", // HTTP method - url: "purchaseorder/uploadfile", // URL to send the request to - cache: false, // Disable caching of the response - contentType: false, // Tell jQuery not to set content type (it's handled by FormData) - processData: false, // Don't process the data into a query string (needed for FormData) + data: formData, + type: "POST", + url: "purchaseorder/uploadfile", + cache: false, + contentType: false, + processData: false, - 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 + success: function(response) { + if (response) { + $('#loader').hide(); + updateRowToTable(response.data,response.data.BillNo); + console.log(response.data); + $('#billModel').modal('hide'); + } }, - error: function(xhr, status, error) { // Handle errors gracefully - $('#loader').hide(); // Hide the loader even on error + error: function(xhr, status, error) { + $('#loader').hide(); let errorMessage = ''; // Custom error messages based on status codes @@ -5417,11 +5427,13 @@ if (!empty($getlogpodtl)) { cache: false, contentType: false, processData: false, - success: function(data) { - if (data) { + success: function(response) { + if (response) { $('#loader').hide(); - alert(data); - window.location.reload(); + alert(response.message); + console.log(response.data.BillNo); + console.log(response.data.FilePath); + addRowToTable(response.data); $('#billModel').modal('hide'); } }, @@ -5551,4 +5563,57 @@ if (!empty($getlogpodtl)) { $('#Quantity').attr('required', true); } }); - \ No newline at end of file + + + diff --git a/app/Views/userListing.php b/app/Views/userListing.php index dd890b5c..743323d7 100755 --- a/app/Views/userListing.php +++ b/app/Views/userListing.php @@ -50,7 +50,7 @@