stock module latest today vadivel J 05-1-2025
This commit is contained in:
parent
c28461f5c2
commit
afc9dd2c6b
@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
//$routes->match(['GET', 'POST'], 'trpProductionDetails', 'StockController::trpProductionDetails');
|
||||
// $routes->match(['GET', 'POST'], 'trpProductionDetails', 'StockController::trpProductionDetails');
|
||||
GET http://localhost/ci4/ria/trpProductionDetails
|
||||
|
||||
@ -1466,6 +1466,151 @@ class StockController extends BaseController
|
||||
echo "An error occurred: " . $error->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public function updateTrpProductionDetails() {
|
||||
// $postData = $this->request->getPost();
|
||||
// $updateTrpProductionDetails = json_decode($postData['updateTrpProductionDetails'], true);
|
||||
|
||||
// $updateProduction = [];
|
||||
// $updateMaintenance = [];
|
||||
// $updateWaste = [];
|
||||
|
||||
// $insertProduction = [];
|
||||
// $insertMaintenance = [];
|
||||
// $insertWaste = [];
|
||||
|
||||
// // Extract dates from the data
|
||||
// $dates = array_column($updateTrpProductionDetails, 'Date');
|
||||
// $formattedDates = array_map(function($date) {
|
||||
// return $this->convertToDateWithFlexibleFormats($date, ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d");
|
||||
// }, $dates);
|
||||
|
||||
// // Fetch existing records in bulk
|
||||
// $existingMaintenanceRecords = $this->TrpProductionMaintenance_model->whereIn('date', $formattedDates)->findAll();
|
||||
// $existingProductionRecords = $this->TrpProduction_model->whereIn('date', $formattedDates)->findAll();
|
||||
// $existingWasteRecords = $this->TrpProductionWaste_model->whereIn('date', $formattedDates)->findAll();
|
||||
|
||||
// // Convert fetched records to associative arrays for quick lookup
|
||||
// $existingMaintenanceMap = [];
|
||||
// foreach ($existingMaintenanceRecords as $record) {
|
||||
// $existingMaintenanceMap[$record['date']] = $record;
|
||||
// }
|
||||
|
||||
// $existingProductionMap = [];
|
||||
// foreach ($existingProductionRecords as $record) {
|
||||
// $existingProductionMap[$record['date']] = $record;
|
||||
// }
|
||||
|
||||
// $existingWasteMap = [];
|
||||
// foreach ($existingWasteRecords as $record) {
|
||||
// $existingWasteMap[$record['date']] = $record;
|
||||
// }
|
||||
|
||||
// foreach ($updateTrpProductionDetails as $data) {
|
||||
// $data['date'] = $this->convertToDateWithFlexibleFormats($data['Date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d");
|
||||
// $date = $data['date'];
|
||||
|
||||
// $dbDataTrpMaintenance = [
|
||||
// 'date' => $data['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' => $data['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' => $data['date'],
|
||||
// 'msSeperation' => $data['msSeperation'],
|
||||
// 'edWaste' => $data['edWaste'],
|
||||
// 'coolerBags' => $data['coolerBags'],
|
||||
// 'edPlus20Waste' => $data['edPlus20Waste'],
|
||||
// 'cycloneWaste' => $data['cycloneWaste']
|
||||
// ];
|
||||
|
||||
// if (empty($existingMaintenanceMap[$date])) {
|
||||
// $insertMaintenance[] = $dbDataTrpMaintenance;
|
||||
// $insertProduction[] = $dbDataTrpProduction;
|
||||
// $insertWaste[] = $dbDataTrpWaste;
|
||||
// } else {
|
||||
// $dbDataTrpMaintenance['id'] = $existingMaintenanceMap[$date]['id'];
|
||||
// $dbDataTrpProduction['id'] = $existingProductionMap[$date]['id'];
|
||||
// $dbDataTrpWaste['id'] = $existingWasteMap[$date]['id'];
|
||||
|
||||
// $updateMaintenance[] = $dbDataTrpMaintenance;
|
||||
// $updateProduction[] = $dbDataTrpProduction;
|
||||
// $updateWaste[] = $dbDataTrpWaste;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Start the transaction
|
||||
// $this->db->transBegin();
|
||||
|
||||
// try {
|
||||
// if (!empty($insertMaintenance)) {
|
||||
// $this->TrpProductionMaintenance_model->insertBatch($insertMaintenance);
|
||||
// }
|
||||
|
||||
// if (!empty($insertProduction)) {
|
||||
// $this->TrpProduction_model->insertBatch($insertProduction);
|
||||
// }
|
||||
|
||||
// if (!empty($insertWaste)) {
|
||||
// $this->TrpProductionWaste_model->insertBatch($insertWaste);
|
||||
// }
|
||||
|
||||
// if (!empty($updateMaintenance)) {
|
||||
// $this->TrpProductionMaintenance_model->updateBatch($updateMaintenance, 'id');
|
||||
// }
|
||||
|
||||
// if (!empty($updateProduction)) {
|
||||
// $this->TrpProduction_model->updateBatch($updateProduction, 'id');
|
||||
// }
|
||||
|
||||
// if (!empty($updateWaste)) {
|
||||
// $this->TrpProductionWaste_model->updateBatch($updateWaste, 'id');
|
||||
// }
|
||||
|
||||
// // Commit the transaction if all operations are successful
|
||||
// $this->db->transCommit();
|
||||
// echo "Data Saved Successfully";
|
||||
|
||||
// } catch (\Exception $error) {
|
||||
// // Rollback the transaction in case of any errors
|
||||
// $this->db->transRollback();
|
||||
// echo "An error occurred: " . $error->getMessage();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user