From 88800e186caec1d137da9cd6911206fada691c6e Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Wed, 29 Jan 2025 09:30:07 +0530 Subject: [PATCH 1/6] stock module latest today vadivel J 29-01-2025 --- app/Views/dieselStockDetails.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Views/dieselStockDetails.php b/app/Views/dieselStockDetails.php index c7f0ba3d..f766835c 100644 --- a/app/Views/dieselStockDetails.php +++ b/app/Views/dieselStockDetails.php @@ -444,9 +444,9 @@ foreach ($period as $day) { $summary['balanceStock'] = 0 ; } - $summary['totalPurchaseDiesel'] += $totalDiesel[$groupedDieselMachineStockDetailsIndex]['purchase_diesel'] == '-' ? 0 : $totalDiesel[$groupedDieselMachineStockDetailsIndex]['purchase_diesel'] ; - $summary['totalFillingDiesel'] += $totalDiesel[$groupedDieselMachineStockDetailsIndex]['total_filling_diesel'] == '-' ? 0 : $totalDiesel[$groupedDieselMachineStockDetailsIndex]['total_filling_diesel'] ; - $summary['balanceStock'] = $totalDiesel[$groupedDieselMachineStockDetailsIndex]['balance_stock'] == '-' ? 0 : $totalDiesel[$groupedDieselMachineStockDetailsIndex]['balance_stock'] ; + $summary['totalPurchaseDiesel'] += is_numeric($totalDiesel[$groupedDieselMachineStockDetailsIndex]['purchase_diesel'] ) ? $totalDiesel[$groupedDieselMachineStockDetailsIndex]['purchase_diesel'] : 0 ; + $summary['totalFillingDiesel'] += is_numeric($totalDiesel[$groupedDieselMachineStockDetailsIndex]['total_filling_diesel']) ? $totalDiesel[$groupedDieselMachineStockDetailsIndex]['total_filling_diesel'] : 0 ; + $summary['balanceStock'] = is_numeric($totalDiesel[$groupedDieselMachineStockDetailsIndex]['balance_stock']) ? $totalDiesel[$groupedDieselMachineStockDetailsIndex]['balance_stock'] : 0 ; ?> From b8a1490d7653824240cd63e0ff6e1bb5085c44b5 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Wed, 29 Jan 2025 10:28:30 +0530 Subject: [PATCH 2/6] stock module latest today vadivel J 29-01-2025 --- app/Controllers/StockController.php | 2 +- app/Views/trpProductionStockDetails.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 79451166..21843367 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -1383,7 +1383,7 @@ class StockController extends BaseController } else { // $month = new DateTime('2024-10-01'); - // $month = $month->format('Y-m'); + // $month = $month->format('Y-m'); $month = date('Y-m'); diff --git a/app/Views/trpProductionStockDetails.php b/app/Views/trpProductionStockDetails.php index 24a6fe5c..a825e64c 100644 --- a/app/Views/trpProductionStockDetails.php +++ b/app/Views/trpProductionStockDetails.php @@ -1051,7 +1051,7 @@ //table to json function - var updateResinStockDetails = tableToJson(); + var updateTrpProductionDetails = tableToJson(); alert('Updation may take a while, And we appreciate your patience..!!'); @@ -1062,7 +1062,7 @@ updateResinStockDetails }, type: "POST", - url: "updateResinStockDetails", + url: "updateTrpProductionDetails", success: function (data) { if (data) { From 2406b0fa71866d0256868c6f910bb4e0e611bc9c Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Wed, 29 Jan 2025 11:23:20 +0530 Subject: [PATCH 3/6] stock module latest today vadivel J 29-01-2025 --- app/Controllers/StockController.php | 366 ++++++++++++++-------------- 1 file changed, 188 insertions(+), 178 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 21843367..76cabd29 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -1409,7 +1409,9 @@ class StockController extends BaseController $inserts = $this->generateDummyData($startDate, $endDate); - $data['trpProductionMaintenanceData'] = $this->updateTrpProductionDetails($inserts); + $freshEntry = true ; + + $data['trpProductionMaintenanceData'] = $this->updateTrpProductionDetails($inserts ,$freshEntry); } @@ -1443,147 +1445,155 @@ class StockController extends BaseController - public function updateTrpProductionDetails($inserts) { - - $postData = $this->request->getPost(); - - if(empty($postData['updateTrpProductionDetails'])){ - if(empty($inserts)){ - return $this->response->setJSON(['error' => 'No data found to update']); - }else{ - $postData['updateTrpProductionDetails'] = $inserts; - } - } - - - $updateTrpProductionDetails = $postData['updateTrpProductionDetails']; - - $updateProduction = []; - $updateMaintanence = []; - $updateWaste = []; - - $insertProduction = []; - $insertMaintanence = []; - $insertWaste = []; - - 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'], - ]; - - $trpMaintenanceResultExists = $this->TrpProductionMaintenance_model - ->where('date', $date) - ->first(); - - $trpProductionResultExists = $this->TrpProduction_model - ->where('date', $date) - ->first(); - - $trpWasteResultExists = $this->TrpProductionWaste_model - ->where('date', $date) - ->first(); - - if (empty($trpMaintenanceResultExists)) { - $insertMaintanence[] = $dbDataTrpMaintenance; - $insertProduction[] = $dbDataTrpProduction; - $insertWaste[] = $dbDataTrpWaste; - } else { - $dbDataTrpMaintenance['id'] = $trpMaintenanceResultExists['id']; - $dbDataTrpProduction['id'] = $trpProductionResultExists['id']; - $dbDataTrpWaste['id'] = $trpWasteResultExists['id']; - - $updateMaintanence[] = $dbDataTrpMaintenance; - $updateProduction[] = $dbDataTrpProduction; - $updateWaste[] = $dbDataTrpWaste; - } - } - - // Start the transaction - $this->db->transBegin(); - - try { - if (!empty($insertMaintanence)) { - $this->TrpProductionMaintenance_model->insertBatch($insertMaintanence); - } - - if (!empty($insertProduction)) { - $this->TrpProduction_model->insertBatch($insertProduction); - } - - if (!empty($insertWaste)) { - $this->TrpProductionWaste_model->insertBatch($insertWaste); - } - - if (!empty($updateMaintanence)) { - $this->TrpProductionMaintenance_model->updateBatch($updateMaintanence, '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(); - } - } + public function updateTrpProductionDetails($inserts, $freshEntry = false) + { + $postData = $this->request->getPost(); + + if (empty($postData['updateTrpProductionDetails'])) { + if (empty($inserts)) { + return $this->response->setJSON(['error' => 'No data found to update']); + } else { + $postData['updateTrpProductionDetails'] = $inserts; + } + } + + $updateTrpProductionDetails = $postData['updateTrpProductionDetails']; + + // Extract all dates from input data + $dates = array_column($updateTrpProductionDetails, 'Date'); + $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 + $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'); + + $insertMaintenance = []; + $updateMaintenance = []; + $insertProduction = []; + $updateProduction = []; + $insertWaste = []; + $updateWaste = []; + + 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'] + ]; + + $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'], + ]; + + $dbDataTrpWaste = [ + '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']; + $updateMaintenance[] = $dbDataTrpMaintenance; + } else { + $insertMaintenance[] = $dbDataTrpMaintenance; + } + + if (isset($existingProductionMap[$date])) { + $dbDataTrpProduction['id'] = $existingProductionMap[$date]['id']; + $updateProduction[] = $dbDataTrpProduction; + } else { + $insertProduction[] = $dbDataTrpProduction; + } + + if (isset($existingWasteMap[$date])) { + $dbDataTrpWaste['id'] = $existingWasteMap[$date]['id']; + $updateWaste[] = $dbDataTrpWaste; + } else { + $insertWaste[] = $dbDataTrpWaste; + } + } + + // Start transaction + $this->db->transBegin(); + + try { + // Insert new records in batch + if (!empty($insertMaintenance)) { + $this->TrpProductionMaintenance_model->insertBatch($insertMaintenance); + } + if (!empty($insertProduction)) { + $this->TrpProduction_model->insertBatch($insertProduction); + } + if (!empty($insertWaste)) { + $this->TrpProductionWaste_model->insertBatch($insertWaste); + } + + // Update existing records in batch + 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 transaction if successful + $this->db->transCommit(); + + if (!$freshEntry) { + echo "Data Saved Successfully"; + } + } catch (\Exception $error) { + // Rollback transaction on error + $this->db->transRollback(); + echo "An error occurred: " . $error->getMessage(); + } + } + + @@ -1592,10 +1602,10 @@ class StockController extends BaseController $datesInMonth = []; $inserts = []; - $period = new DatePeriod( - new DateTime($startDate), - new DateInterval('P1D'), - (new DateTime($endDate))->modify('+1 day') + $period = new DatePeriod( + new DateTime($startDate), + new DateInterval('P1D'), + (new DateTime($endDate))->modify('+1 day') ); foreach ($period as $day) { @@ -1606,41 +1616,41 @@ class StockController extends BaseController $inserts[] = [ 'Date' => $dateInMonth, - 'openingTime' => '00:00', - 'closingTime' => '00:00', - 'totalHours' => '00:00', - 'coldStart' => '00:00', - 'breakdownHours' => '00:00', - 'burnerFiringHours' => '00:00', - 'sandFeedingHours' => '00:00', - 'workingPersonEngineers' => 0, - 'workingPersonSupervisiors' => 0, - 'workingPersonOperators' => 0, - 'rollerDrivers' => 0, + 'openingTime' => " ", + 'closingTime' => " ", + 'totalHours' => " ", + 'coldStart' => " ", + 'breakdownHours' => " ", + 'burnerFiringHours' => " ", + 'sandFeedingHours' => " ", + 'workingPersonEngineers' => " ", + 'workingPersonSupervisiors' => " ", + 'workingPersonOperators' => " ", + 'rollerDrivers' => " ", 'natureOfMaintenance' => '', 'location' => '', 'description' => '', - 'gasReceiptBg' => 0, - 'gasReceiptPg' => 0, - 'physicalGasConsumption' => 0, - 'trpPlusDrierGasConsumption' => 0, - 'trpPhysicalGasPerTon' => 0, - 'panelGasConsumption' => 0, - 'panelGasPerTon' => 0, - 'edRunningHours' => 0, - 'edProduction' => 0, - 'edUsage' => 0, - 'trpProduction' => 0, - 'trpProductionPerHour' => 0, - 'waterReceipt' => 0, - 'waterConsumption' => 0, - 'ebReading' => 0, - 'ebReadingPerUnitTon' => 0, - 'msSeperation' => 0, - 'edWaste' => 0, - 'coolerBags' => 0, - 'edPlus20Waste' => 0, - 'cycloneWaste' => 0 + 'gasReceiptBg' => " ", + 'gasReceiptPg' => " ", + 'physicalGasConsumption' => " ", + 'trpPlusDrierGasConsumption' => " ", + 'trpPhysicalGasPerTon' => " ", + 'panelGasConsumption' => " ", + 'panelGasPerTon' => " ", + 'edRunningHours' => " ", + 'edProduction' => " ", + 'edUsage' => " ", + 'trpProduction' => " ", + 'trpProductionPerHour' => " ", + 'waterReceipt' => " ", + 'waterConsumption' => " ", + 'ebReading' =>" ", + 'ebReadingPerUnitTon' =>" ", + 'msSeperation' => " ", + 'edWaste' => " ", + 'coolerBags' =>" ", + 'edPlus20Waste' => " ", + 'cycloneWaste' => " " ]; } From 20a73ed18b2db14af2a497c6b464dbf3d312bdd0 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Wed, 29 Jan 2025 14:17:40 +0530 Subject: [PATCH 4/6] stock module latest today vadivel J 29-01-2025 --- api_test.http | 2 +- app/Controllers/StockController.php | 2 +- app/Models/TrpProductionModel.php | 8 +++--- app/Views/trpProductionStockDetails.php | 33 +++++++++++++------------ 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/api_test.http b/api_test.http index bf824419..88ea6b3f 100644 --- a/api_test.http +++ b/api_test.http @@ -6,7 +6,7 @@ // $routes->match(['GET', 'POST'], 'trpProductionDetails', 'StockController::trpProductionDetails'); - # GET http://localhost/ci4/ria/trpProductionDetails + GET http://localhost/ci4/ria/trpProductionDetails diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 76cabd29..df0de8f7 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -496,7 +496,7 @@ class StockController extends BaseController } else { $updated = $this->incomingSilicaSandDetails_model ->insert($dbData); - } + } if ($updated) { diff --git a/app/Models/TrpProductionModel.php b/app/Models/TrpProductionModel.php index e0ead6c2..0496178b 100644 --- a/app/Models/TrpProductionModel.php +++ b/app/Models/TrpProductionModel.php @@ -68,6 +68,8 @@ class TrpProductionModel extends Model // Convert the array of material codes to a comma-separated string $materialCodesString = "'" . implode("','", $materialCodes) . "'"; + + // dd($materialCodes); $sql = "SELECT @@ -190,9 +192,9 @@ class TrpProductionModel extends Model tigrd.CreatedDate , - SUM(CASE WHEN ts.SupplierName = 'ASHOK LEYLAND LIMITED FOUNDRY DIVN - SPU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS + SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-SPU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ALs_wcs`, - SUM(CASE WHEN ts.SupplierName = 'ASHOK LEYLAND LIMITED FOUNDRY DIVN - ENU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS + SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-ENU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ALe_wcs`, SUM(CASE WHEN ts.SupplierName = 'MADRAS ENGINEERING INDUSTRIES PRIVATE LIMITED' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ME_wcs`, @@ -202,7 +204,7 @@ class TrpProductionModel extends Model `caparo_wcs`, SUM(CASE WHEN ts.SupplierName = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `Nemak_wcs`, - SUM(CASE WHEN ts.SupplierName = 'DR AXION INDIA PRIVATE LIMITED' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS + SUM(CASE WHEN ts.SupplierName = 'DR Axion India Private Limited' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `DR_wcs` from t_igr_details tigrd diff --git a/app/Views/trpProductionStockDetails.php b/app/Views/trpProductionStockDetails.php index a825e64c..37504006 100644 --- a/app/Views/trpProductionStockDetails.php +++ b/app/Views/trpProductionStockDetails.php @@ -570,7 +570,7 @@ - + @@ -612,18 +612,19 @@ + - + - + @@ -631,21 +632,21 @@ - + - + - + @@ -653,14 +654,14 @@ - + - + @@ -668,7 +669,7 @@ - + @@ -709,42 +710,42 @@ - + - + - + - + - + - + @@ -752,7 +753,7 @@ - + From 355830ab501501a8dcbc818dc68f719cbb73c33e Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 29 Jan 2025 11:12:27 +0000 Subject: [PATCH 5/6] bug fixs : ps --- app/Config/Email.php | 20 ++++--- app/Controllers/Inwardgateregister.php | 42 ++++++++++++++- app/Controllers/Report.php | 15 +++--- app/Helpers/Notification.php | 71 +++++++++++++++++++++++++ app/Models/Dashboard_model.php | 17 +++++- app/Models/Inwardgateregister_model.php | 29 ++++++++++ app/Views/Report_pending_purchase.php | 32 ++++++++--- app/Views/viewinwardgateregister.php | 6 +-- 8 files changed, 207 insertions(+), 25 deletions(-) create mode 100755 app/Helpers/Notification.php diff --git a/app/Config/Email.php b/app/Config/Email.php index 4dce650b..7c3570e6 100755 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -18,7 +18,7 @@ class Email extends BaseConfig /** * The mail sending protocol: mail, sendmail, smtp */ - public string $protocol = 'mail'; + public string $protocol = 'smtp'; /** * The server path to Sendmail. @@ -28,27 +28,31 @@ class Email extends BaseConfig /** * SMTP Server Hostname */ - public string $SMTPHost = ''; - + public string $SMTPHost = 'smtp.gmail.com'; + // public string $SMTPHost = 'smtppro.zoho.com'; + /** * SMTP Username */ - public string $SMTPUser = ''; + public string $SMTPUser = 'venbalap08@gmail.com'; + // public string $SMTPUser = 'mailadmin@resicoindustries.com'; /** * SMTP Password */ - public string $SMTPPass = ''; + public string $SMTPPass = 'oykobiumkymckoir'; + // public string $SMTPPass = 'RI@feb23'; /** * SMTP Port */ - public int $SMTPPort = 25; + public int $SMTPPort = 587; + // public int $SMTPPort = 465; /** * SMTP Timeout (in seconds) */ - public int $SMTPTimeout = 5; + public int $SMTPTimeout = 20; /** * Enable persistent SMTP connections @@ -77,7 +81,7 @@ class Email extends BaseConfig /** * Type of mail, either 'text' or 'html' */ - public string $mailType = 'text'; + public string $mailType = 'html'; /** * Character set (utf-8, iso-8859-1, etc.) diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 1b58896b..d41fa6af 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -8,7 +8,7 @@ use CodeIgniter\Validation\Exceptions\ValidationException; use App\Models\Inwardgateregister_model; use App\Models\IGRRemarks_model; - +use App\Helpers\Notification; use DateTime; use ZipArchive; @@ -26,6 +26,7 @@ class Inwardgateregister extends BaseController protected $inwardgateregister_model; protected $IGRRemarks_model; protected $session; + protected $logger; /** * This is default constructor of the class @@ -38,6 +39,7 @@ class Inwardgateregister extends BaseController $this->session = session(); helper('form'); //$this->load->library('form_validation'); + $this->logger = service('logger'); // Load the logger service $this->isLoggedIn(); } @@ -410,6 +412,7 @@ class Inwardgateregister extends BaseController //$IGRStatus = IGR_CREATED;//old $PreIGRStatus = (int)$this->request->getPost('hideIGRStatus') == 1 ? IGR_CREATED : IGR_DRAFT; $IGRStatus = ((int)$IsThisOpenOrderPO == 1) ? IGR_DRAFT : $PreIGRStatus; + $igr = array(); // For IGR Master $paymentstatus = NO_PAIDIGR; @@ -827,6 +830,7 @@ function viewIGRDetails() log_message('error', 'UpdateIGR igrarr: ' . json_encode($igrarr)); $updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo); + log_message('error', "Master updated successfully: " . $updateigrmaster); if(!empty($tableData )){ if($VehicleNo){ $vecno = $this->inwardgateregister_model->get_igr_history('VehicleNo',$IGRNo); @@ -1073,6 +1077,42 @@ function viewIGRDetails() } } + $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId')); + + + + if ($updateigrmaster > 0 || $updateigrlineitem > 0) { + if ($IGRStatus == IGR_CREATED || $IGRStatus == MRIR_CREATED || $IGRStatus == MRIR_APPROVED ) { + + $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId')); + $notification = new Notification(); + + for ($i = 0; $i < count($result_for_email['emails']); $i++) { + $email_response = $notification->sendEmail([ + 'recipient_email' => $result_for_email['emails'][$i]->email, + 'subject' => 'new Resico Industries - IGR Notification', + 'description' => 'in - IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name')), + 'company' => $result_for_email['company'], + 'from_mail'=> $result_for_email['from_mail'] + ]); + + log_message('error', 'email reponse : ' . json_encode($email_response)); + // Determine the email response + $mail_log = isset($email_response['success']) ? 'Email sent successfully' : 'Failed to send email'; + $receiving_status = isset($email_response['success']) ? 1 : 0; + + // Log the result + if ($receiving_status) { + $this->logger->info("Email ID = " . $result_for_email['emails'][$i]->email . " " . $mail_log); + } else { + $this->logger->error("Email ID = " . $result_for_email['emails'][$i]->email . " " . $mail_log); + } + } + + } + } + + if ($updateigrmaster > 0) { $finalstatement = "Successfully Updated IGR Number: $IGRNo \n"; } else if($updateigrlineitem >0){ diff --git a/app/Controllers/Report.php b/app/Controllers/Report.php index 4ebc9791..366c643c 100755 --- a/app/Controllers/Report.php +++ b/app/Controllers/Report.php @@ -41,8 +41,8 @@ use App\Models\Zohobook_api_model; class Report extends BaseController { protected $dahsboard_Model; - protected $session; - + protected $session; + protected $logger; /** * This is default constructor of the class */ @@ -54,6 +54,7 @@ class Report extends BaseController $this->isLoggedIn(); $this->session = session(); + $this->logger = service('logger'); } public function index() @@ -987,6 +988,8 @@ class Report extends BaseController $frm = $this->request->getPost('from_date'); $t = $this->request->getPost('to_date'); $m = $this->request->getPost('month'); + $purchaseorder_number = $this->request->getPost('purchaseorder_number'); + $ab = $this->request->getPost('financialyear'); $fa = substr((string)$ab, 0, -5); @@ -996,11 +999,11 @@ class Report extends BaseController $headline .= (isset($prod) && !empty($prod)) ? $prod . ' ' : ''; $headline .= (isset($ab) && !empty($ab)) ? '(' . $ab . ') ' : ''; $headline .= (isset($m) && !empty($m)) ? '(' . $m . ') ' : ''; - $headline .= (isset($frm) && isset($t) && !empty($m) && !empty($m)) ? $frm . '-to-' . $t : ''; - - $pending_purchase_details = $this->dahsboard_Model->pending_purchase($cname, $prod, $fa, $aa, $m, $frm, $t); + $headline .= ((isset($frm) && isset($t)) && (!empty($frm) && !empty($t))) ? $frm . '-to-' . $t : ''; + $headline .= (isset($purchaseorder_number) && !empty($purchaseorder_number)) ? '(' . $purchaseorder_number . ') ' : ''; + $pending_purchase_details = $this->dahsboard_Model->pending_purchase($cname, $prod, $fa, $aa, $m, $frm, $t, $purchaseorder_number); } - + $data['pono'] = $this->dahsboard_Model->purchase_order_list(); $data['material'] = $this->dahsboard_Model->material_name(); $data['cust'] = $this->dahsboard_Model->customer_name(); $data['finyear'] = $this->dahsboard_Model->report_finyear(); diff --git a/app/Helpers/Notification.php b/app/Helpers/Notification.php new file mode 100755 index 00000000..337ea132 --- /dev/null +++ b/app/Helpers/Notification.php @@ -0,0 +1,71 @@ +email = service('email'); + $this->logger = service('logger'); + } + + public function sendEmail($records) + { + $this->logger->error('Helper : Email Request Data type = '.gettype($records)); + + $cc = isset($records['carboncopy']) ? $records['carboncopy'] : ''; + $bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : ''; + + try { + $this->email->clear(); + if($records['recipient_email'] == "" && $records['subject'] == ""){ + throw new \Exception("Email and Subject are Must Please Try again.."); + } + $this->email->setTo($records['recipient_email']); + $this->logger->error('Helper : Email recipient = '.$records['recipient_email']); + + $this->email->setFrom($records['from_mail'], isset($records['company'])?$records['company']:"RI Pvt Ltd"); + $this->email->setSubject($records['subject']); + $this->logger->error('Helper : Email subject = '.$records['subject']); + + $this->email->setMessage($records['description']); + + if ($cc !== '') { + $ccRecipients = explode(',', trim($cc)); + $this->logger->error('Helper : Email carbon copy CC recipient = ' . implode(',', $ccRecipients)); + if (!empty($ccRecipients)) { + $this->email->setCC($ccRecipients); + } + } else { + $this->email->setCC('vadivel.j@venbainfotech.com'); + } + + if ($bcc !== '') { + $bccRecipients = explode(',', trim($bcc)); + $this->logger->error('Helper : Email blindcarboncopy BCC recipient = ' . implode(',', $bccRecipients)); + if(!empty($bccRecipients)) { + $this->email->setBCC($bccRecipients); + } + }else{ + $this->email->setCC('gowtham.m@venbainfotech.com'); + } + + if ($this->email->send()) { + $message['success'] = 'Email sent successfully'; + $this->logger->error('Helper : Email Status = sent successfully'); + } else { + throw new \Exception('Email sending failed.'); + } + } catch (\Exception $e) { + $this->logger->error('Helper : Email Error = ' . $e->getMessage()); + $message['error'] = 'Email Exception Occur : ' . $e->getMessage(); + } + return $message; + } +} + +?> diff --git a/app/Models/Dashboard_model.php b/app/Models/Dashboard_model.php index fd3f9a58..b9580445 100755 --- a/app/Models/Dashboard_model.php +++ b/app/Models/Dashboard_model.php @@ -2185,7 +2185,7 @@ category = '" . $cat . "' "; //echo $sql; return $query->getResult(); } - function pending_purchase($cname, $prod, $fa, $aa, $m, $frm, $t) + function pending_purchase($cname, $prod, $fa, $aa, $m, $frm, $t, $purchaseorder_number) { $sql = "select po.PONO as po,date_format(po.PODate,'%d-%m-%Y') as pdate,sup.SupplierName as supplier,mm.MaterialName as material,mm.Category as category,pl.Quantity as quantity,pl.ReceivedQuantity as received, (pl.Quantity - pl.ReceivedQuantity) as pending @@ -2227,6 +2227,10 @@ where po.Status != 'ST030' and po.Status = 'ST026' // $sql.=" and mm.Category = '".$cat."' "; // } + + if($purchaseorder_number != ''){ + $sql .= " and po.PONO = '" . $purchaseorder_number . "' "; + } $sql .= "order by po.PONO"; $query = $this->db->query($sql); //echo $sql; @@ -3020,4 +3024,15 @@ function daybeforetotal($yesterday){ $query = $this->db->query($sql); return $query->getResult(); } + + function purchase_order_list() + { + $sql = "select po.PONO as po,po.POType as type,date(po.PODate) as podate + from t_purchaseorder_master po + where po.Status != 'ST030' and po.Status = 'ST026' + order by podate desc"; + $query = $this->db->query($sql); + return $query->getResult(); + } + } \ No newline at end of file diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index ef94a74d..ed6dd90b 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -1141,6 +1141,35 @@ class Inwardgateregister_model extends Model return $result; } + public function getDetailsforEmail($userId) + { + $query0 = $this->db->query(" + SELECT CompanyName,EmailAddress + FROM t_company_details"); + $company = $query0->getRow(); + + $query1 = $this->db->query(" + SELECT CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName + FROM tbl_users + LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID + WHERE tbl_users.userId = ?", [$userId] + ); + $fullName = $query1->getRow(); + + $query2 = $this->db->query(" + SELECT email FROM tbl_users + WHERE isDeleted = 0 AND roleId = 2" // hardcoded because auditor role only. refer with gwm 29/01/2025 + ); + $emails = $query2->getResult(); + + return [ + 'from_mail' => $company ? $company->EmailAddress : null, + 'full_name' => $fullName ? $fullName->FullName : null, + 'company' => $company ? $company->CompanyName : null, + 'emails' => $emails + ]; + } + } \ No newline at end of file diff --git a/app/Views/Report_pending_purchase.php b/app/Views/Report_pending_purchase.php index 14388065..901e3a75 100755 --- a/app/Views/Report_pending_purchase.php +++ b/app/Views/Report_pending_purchase.php @@ -3,6 +3,7 @@ $("#client_name").select2(); $("#item_name").select2(); + $("#purchaseorder_number").select2(); }); @@ -45,22 +46,28 @@
-
+
-
+ + +
+
+ Result filter by :

+
+
@@ -135,7 +142,7 @@
-
+
@@ -144,7 +151,7 @@
-
+
@@ -153,6 +160,19 @@
+
+ + +

- 'SupplierName', 'value' => set_value('SupplierName'), 'id' => 'Supplier', 'class' => 'form-control', 'required=>"true"', 'readonly' => 'true'); - echo form_input($data); + 'SupplierName', 'value' => set_value('SupplierName'), 'id' => 'Supplier', 'class' => 'form-control', 'required=>"true"', 'readonly' => 'true' ,'rows' => 2); + echo form_textarea($data); ?>
@@ -918,7 +918,7 @@ $("#DriverMobileNumber").val(item.DriverMobileNumber); $("#IGRStatus").val(item.IGRStatus); $("#PONo").val(item.PONO); - $("#Supplier").val(item.SupplierName); + $("#Supplier").val(item.SupplierName + "\n" + item.Address); $("#Add1").val(item.Address); $("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo); console.log(typeof item.MasterFile); From 73a274fe712193a4d72093049a530b158d11c6a0 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 29 Jan 2025 11:22:42 +0000 Subject: [PATCH 6/6] modal width : ps --- app/Controllers/Inwardgateregister.php | 4 ++-- app/Views/viewinwardgateregister.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index d41fa6af..65d02aaf 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -1090,8 +1090,8 @@ function viewIGRDetails() for ($i = 0; $i < count($result_for_email['emails']); $i++) { $email_response = $notification->sendEmail([ 'recipient_email' => $result_for_email['emails'][$i]->email, - 'subject' => 'new Resico Industries - IGR Notification', - 'description' => 'in - IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name')), + 'subject' => 'Resico Industries - IGR Notification', + 'description' => 'IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name')), 'company' => $result_for_email['company'], 'from_mail'=> $result_for_email['from_mail'] ]); diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index affa4cb9..bd6d17b9 100755 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -356,10 +356,9 @@
-