From fb66a2468ffa8f209929c286138f1bd48d91c32f Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Tue, 10 Dec 2024 15:04:48 +0530 Subject: [PATCH] master detail module changes-2 vadivel J 10-12-2024 --- app/Controllers/Configurationctrl.php | 7 +- app/Controllers/StockController.php | 67 +++++++++++------- app/Models/Rawmaterialdetails_model.php | 14 ++++ app/Views/addconfig.php | 59 ++++++---------- app/Views/editconfig.php | 94 +++++++++++++------------ app/Views/gasStockDetails.php | 9 +-- app/Views/powerConsumptionDetails.php | 14 +++- 7 files changed, 147 insertions(+), 117 deletions(-) diff --git a/app/Controllers/Configurationctrl.php b/app/Controllers/Configurationctrl.php index f4d5bbd8..2a583b2b 100755 --- a/app/Controllers/Configurationctrl.php +++ b/app/Controllers/Configurationctrl.php @@ -119,12 +119,9 @@ class Configurationctrl extends BaseController $child_result = $this->configmodel->addconfigdetails($child_arr); } } - - if ($result || $child_result) { + $this->session->setFlashdata('success', 'Configuration Updated successfully!'); - } else { - $this->session->setFlashdata('error', 'Configuration Record Not Updated!'); - } + return redirect()->route('configlisting'); } diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index e0f437cd..80b4416b 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -177,7 +177,7 @@ class StockController extends BaseController throw new \Exception('Failed to update gas stock consumption.'); } $message2 = 'And updated gas stock consumption.'; - $message3 =" Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; + $message3 = " Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; } else { throw new \Exception('Failed to insert Coating machine details.'); } @@ -189,11 +189,11 @@ class StockController extends BaseController } $this->db->transCommit(); - + // Set flashdata for success message return redirect()->to("/coatingMachineDetails?month=$month") - ->with('success', $message1 . " " . $message2 ." ".$message3); + ->with('success', $message1 . " " . $message2 . " " . $message3); } catch (\Exception $error) { $this->db->transRollback(); @@ -238,7 +238,7 @@ class StockController extends BaseController } $message2 = 'And updated gas stock consumption.'; - $message3 ="Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; + $message3 = "Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; } // Commit the transaction if all queries succeed @@ -254,7 +254,7 @@ class StockController extends BaseController // Set flashdata for success message return redirect()->to("/coatingMachineDetails?month=$month") - ->with('success', $message1 . " " . $message2 ." " . $message3); + ->with('success', $message1 . " " . $message2 . " " . $message3); } else { throw new \Exception('Failed to update Coating machine details.'); @@ -470,30 +470,27 @@ class StockController extends BaseController $data['groupedBagStockDetails'] = array_values($groupedByDate); - /** - * need to change the below condition to allow active bag materials for new entries - * not for older entries - **/ - if(!empty($data['groupedBagStockDetails'])){ + + if (!empty($data['groupedBagStockDetails'])) { $result = $this->bagStockDetails_model - ->select('materialCode') // Specify the column you want to select - ->distinct() // Use distinct without arguments - ->orderBy('materialCode', 'asc') - ->findAll(); - $distinctMaterialCodes=[]; - foreach($result as $index => $eachResult){ - $distinctMaterialCodes[] = $result[$index]['materialCode']; - } + ->select('materialCode') // Specify the column you want to select + ->distinct() // Use distinct + ->orderBy('materialCode', 'asc') + ->findAll(); + $distinctMaterialCodes = []; + foreach ($result as $index => $eachResult) { + $distinctMaterialCodes[] = $result[$index]['materialCode']; + } $bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($distinctMaterialCodes); - - }else{ + + } else { $bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode(); } - + foreach ($bagMaterials as $key => $bagMaterial) { @@ -755,7 +752,25 @@ class StockController extends BaseController - $resinMaterials = $this->rawmaterialdetails_model->getAllResinMaterialCode(); + if (!empty($data['groupedBagStockDetails'])) { + + $result = $this->resinStockDetails_model + ->select('materialCode') // Specify the column you want to select + ->distinct() // Use distinct + ->orderBy('materialCode', 'asc') + ->findAll(); + $distinctMaterialCodes = []; + foreach ($result as $index => $eachResult) { + $distinctMaterialCodes[] = $result[$index]['materialCode']; + } + $resinMaterials = $this->rawmaterialdetails_model->getSelectedResinMaterialCode($distinctMaterialCodes); + + } else { + $resinMaterials = $this->rawmaterialdetails_model->getAllResinMaterialCode(); + + + } + foreach ($resinMaterials as $key => $resinMaterial) { $materialCode = $resinMaterial['MaterialCode']; @@ -1270,19 +1285,19 @@ class StockController extends BaseController if (!empty($inserts)) { $this->drierMachineDetails_model->insertBatch($inserts); - $message1 ="Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; + $message1 = "Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; } if (!empty($updates)) { $this->drierMachineDetails_model->updateBatch($updates, 'id'); - $message1 ="Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; + $message1 = "Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!"; } if ($this->db->transStatus() === false) { throw new \Exception('Transaction failed due to database error.'); } - + } $this->db->transCommit(); @@ -1481,7 +1496,7 @@ class StockController extends BaseController $data['powerConsumptionDetails'] = $this->getElectricConsumptionPivot($data['machineDetails'], $data['startDate'], $data['endDate']); if (!count($data['powerConsumptionDetails'])) { //insert empty data - $tempInsert = []; + $tempInsert = []; foreach ($monthData as $key => $value) { array_push($tempInsert, ['date' => $value['database'], 'machine_id' => $data['machineDetails'][0]['id']]); } diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index df8e28a6..344b5d1e 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -195,6 +195,20 @@ class Rawmaterialdetails_model extends Model } + function getSelectedResinMaterialCode($distinctMaterialCodes) + { + $builder = $this->db->table('t_materialmaster') + ->select('MaterialCode, MaterialName') + ->whereIn('MaterialCode', $distinctMaterialCodes) // Matches MaterialCode with the array + ->orderBy('MaterialCode', 'asc'); + + $query = $builder->get(); + $materialResults = $query->getResultArray(); + + return $materialResults; + + } + function getMaterialstock($MaterialCode, $currentdate) diff --git a/app/Views/addconfig.php b/app/Views/addconfig.php index 09b52484..6d41b5c2 100755 --- a/app/Views/addconfig.php +++ b/app/Views/addconfig.php @@ -91,7 +91,7 @@
- + Cancel
@@ -168,13 +168,16 @@ @@ -257,8 +260,9 @@ ${ConfigValue} - -     + + + `; @@ -310,7 +314,7 @@ - $("#AddConfiguration").modal('hide'); + $("#Edit").modal('hide'); } else { alert('Please enter all the values'); @@ -420,36 +424,17 @@ \ No newline at end of file diff --git a/app/Views/editconfig.php b/app/Views/editconfig.php index 83f6519f..0d93f07a 100755 --- a/app/Views/editconfig.php +++ b/app/Views/editconfig.php @@ -125,7 +125,7 @@ if (!empty($master)) { S.NO - Config Value + Configuration Value Action @@ -165,15 +165,16 @@ if (!empty($master)) {     + title="Click here to Edit Config Value"> -    -    + +       +     + title="Click here to Delete the Config Value"> @@ -247,7 +248,7 @@ if (!empty($master)) {