From a4e219760271555bcf13ab99d70ac4f92b51f212 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Fri, 14 Mar 2025 15:38:08 +0530 Subject: [PATCH] changes in stock module 14-03-2025 --- app/Controllers/StockController.php | 154 +++++++++++------- app/Views/editCapitalAmendPO.php | 16 +- app/Views/stock/trpProductionStockDetails.php | 17 +- 3 files changed, 111 insertions(+), 76 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index e300fe57..a96b6502 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -3119,111 +3119,143 @@ class StockController extends BaseController public function updateTrpProductionDetails($inserts = null, $freshEntry = false) { - + //getting values from post request $postData['updateTrpProductionDetails'] = json_decode($this->request->getPost('updateTrpProductionDetails'),true); + //checking if post data is empty data ? if (empty($postData['updateTrpProductionDetails'])) { + + //if empty data , we still check for inserts data is available or not if (empty($inserts)) { + + //if both fails return "no data found" return $this->response->setJSON(['error' => 'No data found to update']); + } else { + + //if inserts data is available , then assign to post data $postData['updateTrpProductionDetails'] = $inserts; } } $updateTrpProductionDetails = $postData['updateTrpProductionDetails']; - // Extract all dates from input data + // Extract all dates from post data $dates = array_column($updateTrpProductionDetails, 'Date'); + + //format from "d-m-Y" to db "Y-m-d" format $formattedDates = array_map(fn($date) => $this->convertToDateWithFlexibleFormats($date, ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d"), $dates); - // Fetch all existing records in a single query per table + + + // Fetch all existing maintenance , production and waste records for the given formatted dates + $existingMaintenance = $this->TrpProductionMaintenance_model->whereIn('date', $formattedDates)->findAll(); + $existingProduction = $this->TrpProduction_model->whereIn('date', $formattedDates)->findAll(); + $existingWaste = $this->TrpProductionWaste_model->whereIn('date', $formattedDates)->findAll(); - // Map existing records by date for quick lookup - $existingMaintenanceMap = array_column($existingMaintenance, null, 'date'); - $existingProductionMap = array_column($existingProduction, null, 'date'); - $existingWasteMap = array_column($existingWaste, null, 'date'); + + //getting list of existing dates of maintenance , production and waste records + + $existingMaintenanceDateList = array_column($existingMaintenance, null, 'date'); + + $existingProductionDateList = array_column($existingProduction, null, 'date'); + + $existingWasteDateList = array_column($existingWaste, null, 'date'); - $insertMaintenance = []; + $updateMaintenance = []; - $insertProduction = []; - $updateProduction = []; - $insertWaste = []; - $updateWaste = []; + $updateProduction = []; + $updateWaste = []; + + + $insertMaintenance = []; + $insertProduction = []; + $insertWaste = []; + foreach ($updateTrpProductionDetails as $data) { + $date = $this->convertToDateWithFlexibleFormats($data['Date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d"); // Data arrays $dbDataTrpMaintenance = [ - 'date' => $date, - 'openingTime' => $data['openingTime'], - 'closingTime' => $data['closingTime'], - 'totalHours' => $data['totalHours'], - 'coldStart' => $data['coldStart'], - 'breakdownHours' => $data['breakdownHours'], - 'burnerFiringHours' => $data['burnerFiringHours'], - 'sandFeedingHours' => $data['sandFeedingHours'], - 'workingPersonEngineers' => $data['workingPersonEngineers'], - 'workingPersonSupervisiors' => $data['workingPersonSupervisiors'], - 'workingPersonOperators' => $data['workingPersonOperators'], - 'rollerDrivers' => $data['rollerDrivers'], - 'natureOfMaintenance' => $data['natureOfMaintenance'], - 'location' => $data['location'], - 'description' => $data['description'] + 'date' => $date, + 'openingTime' => $data['openingTime'], + 'closingTime' => $data['closingTime'], + 'totalHours' => $data['totalHours'], + 'coldStart' => $data['coldStart'], + 'breakdownHours' => $data['breakdownHours'], + 'burnerFiringHours' => $data['burnerFiringHours'], + 'sandFeedingHours' => $data['sandFeedingHours'], + 'workingPersonEngineers' => $data['workingPersonEngineers'], + 'workingPersonSupervisiors' => $data['workingPersonSupervisiors'], + 'workingPersonOperators' => $data['workingPersonOperators'], + 'rollerDrivers' => $data['rollerDrivers'], + 'natureOfMaintenance' => $data['natureOfMaintenance'], + 'location' => $data['location'], + 'description' => $data['description'] ]; $dbDataTrpProduction = [ - 'date' => $date, - 'gasReceiptBg' => $data['gasReceiptBg'], - 'gasReceiptPg' => $data['gasReceiptPg'], - 'physicalGasConsumption' => $data['physicalGasConsumption'], - 'trpPlusDrierGasConsumption' => $data['trpPlusDrierGasConsumption'], - 'trpPhysicalGasPerTon' => $data['trpPhysicalGasPerTon'], - 'panelGasConsumption' => $data['panelGasConsumption'], - 'panelGasPerTon' => $data['panelGasPerTon'], - 'edRunningHours' => $data['edRunningHours'], - 'edProduction' => $data['edProduction'], - 'edUsage' => $data['edUsage'], - 'trpProduction' => $data['trpProduction'], - 'trpProductionPerHour' => $data['trpProductionPerHour'], - 'waterReceipt' => $data['waterReceipt'], - 'waterConsumption' => $data['waterConsumption'], - 'ebReading' => $data['ebReading'], - 'ebReadingPerUnitTon' => $data['ebReadingPerUnitTon'], + 'date' => $date, + 'gasReceiptBg' => $data['gasReceiptBg'], + 'gasReceiptPg' => $data['gasReceiptPg'], + 'physicalGasConsumption' => $data['physicalGasConsumption'], + 'trpPlusDrierGasConsumption' => $data['trpPlusDrierGasConsumption'], + 'trpPhysicalGasPerTon' => $data['trpPhysicalGasPerTon'], + 'panelGasConsumption' => $data['panelGasConsumption'], + 'panelGasPerTon' => $data['panelGasPerTon'], + 'edRunningHours' => $data['edRunningHours'], + 'edProduction' => $data['edProduction'], + 'edUsage' => $data['edUsage'], + 'trpProduction' => $data['trpProduction'], + 'trpProductionPerHour' => $data['trpProductionPerHour'], + 'waterReceipt' => $data['waterReceipt'], + 'waterConsumption' => $data['waterConsumption'], + 'ebReading' => $data['ebReading'], + 'ebReadingPerUnitTon' => $data['ebReadingPerUnitTon'], ]; $dbDataTrpWaste = [ - 'date' => $date, - 'msSeperation' => $data['msSeperation'], - 'edWaste' => $data['edWaste'], - 'coolerBags' => $data['coolerBags'], - 'edPlus20Waste' => $data['edPlus20Waste'], - 'cycloneWaste' => $data['cycloneWaste'], + 'date' => $date, + 'msSeperation' => $data['msSeperation'], + 'edWaste' => $data['edWaste'], + 'coolerBags' => $data['coolerBags'], + 'edPlus20Waste' => $data['edPlus20Waste'], + 'cycloneWaste' => $data['cycloneWaste'], ]; // Check if data already exists - if (isset($existingMaintenanceMap[$date])) { - $dbDataTrpMaintenance['id'] = $existingMaintenanceMap[$date]['id']; + if (isset($existingMaintenanceDateList[$date])) { + + $dbDataTrpMaintenance['id'] = $existingMaintenanceDateList[$date]['id']; $updateMaintenance[] = $dbDataTrpMaintenance; + } else { + $insertMaintenance[] = $dbDataTrpMaintenance; + } - if (isset($existingProductionMap[$date])) { - $dbDataTrpProduction['id'] = $existingProductionMap[$date]['id']; + if (isset($existingProductionDateList[$date])) { + + $dbDataTrpProduction['id'] = $existingProductionDateList[$date]['id']; $updateProduction[] = $dbDataTrpProduction; + } else { $insertProduction[] = $dbDataTrpProduction; } - if (isset($existingWasteMap[$date])) { - $dbDataTrpWaste['id'] = $existingWasteMap[$date]['id']; + if (isset($existingWasteDateList[$date])) { + + $dbDataTrpWaste['id'] = $existingWasteDateList[$date]['id']; $updateWaste[] = $dbDataTrpWaste; + } else { $insertWaste[] = $dbDataTrpWaste; } @@ -3233,6 +3265,15 @@ class StockController extends BaseController $this->db->transBegin(); try { + + // dd($updateMaintenance); + // dd($updateProduction); + // dd($updateWaste); + + // dd($insertMaintenance); + // dd($insertProduction); + // dd($insertWaste); + // Insert new records in batch if (!empty($insertMaintenance)) { $this->TrpProductionMaintenance_model->insertBatch($insertMaintenance); @@ -3272,6 +3313,7 @@ class StockController extends BaseController public function updateAbstractDetails() { + $updateAbstractDetails = json_decode($this->request->getPost('updateAbstractDetails'), true); if (empty($updateAbstractDetails)) { diff --git a/app/Views/editCapitalAmendPO.php b/app/Views/editCapitalAmendPO.php index 88dd00ae..13e0ee49 100755 --- a/app/Views/editCapitalAmendPO.php +++ b/app/Views/editCapitalAmendPO.php @@ -533,7 +533,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
- + *
- Select Delivery By + Select Delivery By *
- + * 'PlaceOforigin','value' => set_value('PlaceOforigin'),'id'=>'PlaceOforigin', 'class' => 'form-control' ,'required' => 'true', 'onkeypress'=>'return false;'); @@ -755,7 +755,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
- + *
-
--> +
-->
diff --git a/app/Views/stock/trpProductionStockDetails.php b/app/Views/stock/trpProductionStockDetails.php index 3a6d6b0e..3c944a95 100644 --- a/app/Views/stock/trpProductionStockDetails.php +++ b/app/Views/stock/trpProductionStockDetails.php @@ -151,14 +151,6 @@ text-align: center; } - .celda_encabezado_total { - background-color:#ffffff !important; - border: 1px solid #ffffff; - color: #ffffff !important; - font-weight: bold; - padding: 6px 10px; - text-align: center; - } .celda_normal { /*background-color: #fff;*/ @@ -349,6 +341,7 @@ $timeOtions[] = "12:00 AM";
+ @@ -443,7 +436,7 @@ $timeOtions[] = "12:00 AM"; - + @@ -465,7 +458,7 @@ $timeOtions[] = "12:00 AM"; - + @@ -1277,7 +1270,7 @@ $timeOtions[] = "12:00 AM"; -


+ @@ -1303,7 +1296,7 @@ $timeOtions[] = "12:00 AM"; -


+