diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index 0d3ebff8..990f37ef 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -289,6 +289,7 @@ class Rawmaterialdetails extends BaseController $data['assetcode'] = $this->rawmaterialdetails_model->getAssetcode(); $data['avg_price'] = $this->rawmaterialdetails_model->getMaterialAvg($RawMaterialID); $data['materialRateHistory'] = $this->rawmaterialdetails_model->getMaterialRateHistory($RawMaterialID); + $data['materialListPage'] = $_GET['page']; //print_r($data['avg_price']);die(); $this->global['pageTitle'] = 'Edit Material Master'; @@ -317,6 +318,7 @@ class Rawmaterialdetails extends BaseController $stock = $this->request->getPost('openstock'); $reorder = $this->request->getPost('reorder'); $stockdate = $this->request->getPost('Date'); + $materialListPage = $this->request->getPost('materialListPage'); $stockdate = (empty($stockdate)) ? NULL : get_date_time_dynamical_format('d-m-Y','Y-m-d',"$stockdate"); $chked = $this->request->getPost('isactive'); @@ -329,11 +331,15 @@ class Rawmaterialdetails extends BaseController $result = $this->rawmaterialdetails_model->editRawmaterial($RawMaterial, $MaterialCode); - if ($result == true) { + if ($result == true) { $this->session->setFlashdata('success', 'RawMaterial Updated successfully!'); + $this->session->setFlashdata('materialListPage', "$materialListPage"); + } else { echo ""; $this->session->setFlashdata('error', 'RawMaterial Record Not updated!'); + $this->session->setFlashdata('materialListPage', "$materialListPage"); + } return redirect()->route('rawmaterialListing'); diff --git a/app/Views/editRawmaterial.php b/app/Views/editRawmaterial.php index e29874fd..e142d4b3 100755 --- a/app/Views/editRawmaterial.php +++ b/app/Views/editRawmaterial.php @@ -113,7 +113,7 @@ if ($total <= $reorder) {

Edit Material - Details

-
@@ -361,10 +361,12 @@ if ($total <= $reorder) {
diff --git a/app/Views/rawmaterialListing.php b/app/Views/rawmaterialListing.php index 4ea7e148..565072ef 100755 --- a/app/Views/rawmaterialListing.php +++ b/app/Views/rawmaterialListing.php @@ -76,6 +76,9 @@ $type = "success"; echo show_alert($type, $success); } + + $materialListPage = session()->getFlashdata('materialListPage') ?? $_GET['materialListPage'] ?? 1; + ?>
@@ -207,6 +210,7 @@ ; // Default to 1 if not set + + savedPage = savedPage -1 ; + + + if (!isNaN(savedPage)) { + // Check if the DataTable is initialized + if ($.fn.DataTable.isDataTable('#raw_material_list_table')) { + var dataTable = $('#raw_material_list_table').DataTable(); + + // Get the total number of pages in DataTable + var totalPages = dataTable.page.info().pages; + + // Ensure the page number is within range + if (savedPage >= totalPages) { + savedPage = totalPages > 0 ? totalPages - 1 : 0; + } + + // Set DataTable to the saved page + dataTable.page(savedPage).draw(false); + } + } + // Date range filter function // $.fn.dataTable.ext.search.push( // function (settings, data, dataIndex) { @@ -542,10 +570,31 @@ $(document).ready(function () { }); }); + +