From c061ce31c7f73c8c09abe3ad034766b6e1465895 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Tue, 15 Oct 2024 17:13:00 +0530 Subject: [PATCH 1/2] changes in ria -vadivel J --- app/Controllers/Purchaseorder.php | 22 ++++- app/Models/Purchaseorder_model.php | 21 +++-- app/Views/EditservicePurchaseorder.php | 16 ++-- app/Views/POlist.php | 4 +- app/Views/editRevenuepurchaseorder.php | 119 +++++++++++++++++++------ app/Views/userListing.php | 2 +- 6 files changed, 137 insertions(+), 47 deletions(-) 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)) { - - - + + + - + @@ -1132,11 +1132,11 @@ if (!empty($getlogpodtl)) { ?> - - - + + + - + 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 @@ - + @@ -152,7 +152,7 @@ - + - + $gd) { - if (!empty($gd->BillNo)) { - $index = $row + 1; - ?> + foreach ($billfile as $row => $gd) { + if (!empty($gd->BillNo)) { + $index = $row + 1; + ?> @@ -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 @@ From 73443de17291dcf52b13f469428d6af343e19021 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Tue, 15 Oct 2024 20:31:31 +0530 Subject: [PATCH 2/2] commit after pull from new_theme 15/10/2024 -vadivel J --- app/Controllers/Inwardgateregister.php | 8 +- app/Controllers/Purchaseorder.php | 22 ++- app/Models/Inwardgateregister_model.php | 33 +++- app/Models/Purchaseorder_model.php | 21 ++- app/Views/EditservicePurchaseorder.php | 16 +- app/Views/POlist.php | 4 +- app/Views/userListing.php | 2 +- app/Views/viewinwardgateregister.php | 211 ++++++++++++++++-------- 8 files changed, 219 insertions(+), 98 deletions(-) diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index d99a697b..83a028c1 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -50,14 +50,14 @@ class Inwardgateregister extends BaseController function viewIGR() { + $this->global['pageTitle'] = 'View Inward Gate Register'; - $data['IGR'] = $this->inwardgateregister_model->ViewigrListing(); + $result = $this->inwardgateregister_model->ViewigrListing(); + $data['IGR'] = $result[0]; + $data['IGRDownload'] = $result[1]; $data['userRole'] = $this->session->get('role'); $data['transporter'] = $this->inwardgateregister_model->transporter(); $this->loadViews("viewinwardgateregister", $this->global, $data, NULL); - // $this->global['pageTitle'] = 'Inward Gate Register Details'; - // $data['IGR'] = $this->inwardgateregister_model->igrListing(); - // $this->loadViews("viewIGRDetails", $this->global, $data, NULL); } function addIGR() 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/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index a0bd5054..860a415a 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -339,7 +339,7 @@ class Inwardgateregister_model extends Model $result = $query->getResult(); return $result; } - function ViewigrListing() + function ViewigrListing_old() { // $builder = $this->db->table('t_igr_master igr') @@ -368,6 +368,37 @@ class Inwardgateregister_model extends Model return $result; } + function ViewigrListing() + { + + $builder = $this->db->table('t_igr_master igr') + ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount') + ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') + ->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left') + ->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo') + ->where('igr.IGRStatus !=', MRIR_CREATED) + ->groupBy('igr.IGRNo') + ->orderBy('igr.CreatedDate', 'desc'); + $query = $builder->get(); + $result = $query->getResult(); + + $builder2 = $this->db->table('t_igr_details igr_details') + ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') + ->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo') + ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID') + ->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left') + ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left') + ->where('igr.IGRStatus !=', MRIR_CREATED) + ->orderBy('igr.CreatedDate', 'desc'); + $query2 = $builder2->get(); + $result2 = $query2->getResult(); + // echo $this->db->getLastQuery()->getQuery();die; + return [$result,$result2]; + } + + function viewigr($IGRNO) { 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)) {
SNoRequisition NoItem CodeSNoRequisition NoItem Code Item NameQuantityQuantity UOM Rate Basic Amount
ReqNo ?>MaterialCode ?>ReqNo ?>MaterialCode ?> MaterialName ?>Quantity ?>Quantity ?> UOM ?> Rate ?>PONO# PO Type Supplier NameTotal Order ValueTotal Order Value PO Status Delivery Option Delivery DateReqType ?> SupplierName ?>TotalOrderValue ?>TotalOrderValue ?> Action
BillNo ?>
- - - + + + - + @@ -1132,11 +1132,11 @@ if (!empty($getlogpodtl)) { ?> - - - + + + - + 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 @@ - + @@ -152,7 +152,7 @@ - + -->
SNoRequisition NoItem CodeSNoRequisition NoItem Code Item NameQuantityQuantity UOM Rate Basic Amount
ReqNo ?>MaterialCode ?>ReqNo ?>MaterialCode ?> MaterialName ?>Quantity ?>Quantity ?> UOM ?> Rate ?>PONO# PO Type Supplier NameTotal Order ValueTotal Order Value PO Status Delivery Option Delivery DateReqType ?> SupplierName ?>TotalOrderValue ?>TotalOrderValue ?> diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index 55a5d38b..abe442a9 100755 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -163,34 +163,41 @@ +
-
- - - +
+
+ + + + - - + + - - -
- + + +
+ +
+
+ +
+
- - + - - - + + + @@ -201,62 +208,115 @@ - CreatedDate); - $datewithtime = $createddate->format('d-m-Y h:i A'); $date = $createddate->format('d-m-Y'); $time = $createddate->format('h:i A'); ?> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + +   + + + + +   + + + +
Create DateCreate time IGR NoPO NoPO No Supplier NameInvoice NoInvoice Date ItemInvoice NoInvoice Date Item Count Rec Qty Net Weight Vechicle No
IGRNO ?> PONO ?>SupplierName ?>DeliveryChellanOrInvoiceNo ?>DeliveryChellanDate); - echo $date->format('d-m-Y'); ?>MaterialName ?>ReceivedQuantity ?>NetWeight ?>VehicleNo ?>DriverName ?>TransporterName ?>IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?> - - - -   - FilePath)) { ?> +
IGRNO ?> PONO ?>SupplierName ?>DeliveryChellanOrInvoiceNo ?>DeliveryChellanDate); + echo $date->format('d-m-Y'); ?>itemCount ?>ReceivedQuantity ?>NetWeight ?>VehicleNo ?>DriverName ?>TransporterName ?>IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?> + + + +   + FilePath)) { ?> - file)) { ?> + file)) { ?> - + - -   - - - - -   - - -
+ + + + + + + + + + + + + + + + + + + + + + + CreatedDate); + $date = $createddate->format('d-m-Y'); + $time = $createddate->format('h:i A'); + ?> + + + + + + + + + + + + + + + + + + + +
@@ -415,6 +475,7 @@
+ @@ -1612,25 +1673,15 @@ } $(document).ready(function() { - $('#view_inward_gate_register').DataTable({ - dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination - buttons: [ - 'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons - ], - pageLength: 10, // Default rows per page + table = $('#view_inward_gate_register').DataTable({ + + pageLength: 10, lengthMenu: [ [10, 20, 30, 50, -1], [10, 20, 30, 50, "All"] - ], // Rows per page options - responsive: true, // Responsive table - - // Default ordering (column index 0, ascending) - // order: [ - // [0, 'desc'] - // ], - + ], + responsive: true, ordering:false, - language: { paginate: { next: '', // Next button icon @@ -1700,4 +1751,18 @@ } }); }); + + + + \ No newline at end of file