diff --git a/app/Controllers/Configurationctrl.php b/app/Controllers/Configurationctrl.php index 0bcbc51c..1b94d7ee 100755 --- a/app/Controllers/Configurationctrl.php +++ b/app/Controllers/Configurationctrl.php @@ -87,6 +87,7 @@ class Configurationctrl extends BaseController $isActiveFilter = 1 ; // default flag for active data $showArchive = 0 ; // default flag for inactive data + $page = 1; // default page number if ($this->request->getMethod() === 'POST') { @@ -100,6 +101,7 @@ class Configurationctrl extends BaseController if ($this->request->getMethod() === 'GET') { $ConfigID = $this->request->getVar('ConfigID'); + $page = $this->request->getVar('page'); } $data['showArchive'] = $showArchive; @@ -109,6 +111,8 @@ class Configurationctrl extends BaseController $data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID,$isActiveFilter); $data['ConfigID'] = $ConfigID; + + $data['page'] = $page; $this->global['pageTitle'] = 'Edit Config'; $this->loadViews("editconfig", $this->global, $data, NULL); @@ -122,6 +126,7 @@ class Configurationctrl extends BaseController $ConfigName = $this->request->getPost('ConfigName'); $Comments = $this->request->getPost('Remarks'); $Rowcount = $this->request->getPost('txtRowCount'); + $page = $this->request->getGet('page')??1; $config = array('Config_ID' => $ConfigId, 'ConfigName' => $ConfigName, 'Comments' => $Comments); $result = $this->configmodel->updateconfig($config, $ConfigId); @@ -143,7 +148,7 @@ class Configurationctrl extends BaseController $this->session->setFlashdata('success', 'Configuration Updated successfully!'); - return redirect()->route('configlisting'); + return redirect()->to('/configlisting?page=' . $page); } diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 5edbd472..e6a0a7b9 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -447,6 +447,7 @@ class StockController extends BaseController $this->global['pageTitle'] = 'Drier Details'; $this->loadViews("stock/drierMachineDetails", $this->global, $data, NULL); + } @@ -601,6 +602,8 @@ class StockController extends BaseController // Convert month format from "Y-m" to "M-Y" for display $date = DateTime::createFromFormat('Y-m-d', $month.'-01'); + + $formattedDate = $date->format('M-Y'); @@ -1311,7 +1314,7 @@ class StockController extends BaseController $filterUpdateNeeded = true ; if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){ - $customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ; + $customisedMachineCodes = array_column($existingCustomMachineCodes, 'machine_id') ; $filterUpdateNeeded = false ; } @@ -1367,12 +1370,30 @@ class StockController extends BaseController //possible if no filter applied at all...!!! if(empty($existingCustomMachineCodes)){ //no filter applied at all just present all active material codes - $existingCustomMachineCodes = $this->factoryMachine_model - ->getAllActiveDieselMachines(); + $existingCustomMachineCodes = $this ->factoryMachine_model + ->getAllActiveDieselMachines() ; + + //add this active products in monthwisemachine stock table + $inserts = []; + foreach($existingCustomMachineCodes as $index => $customisedMachineCode){ + + $inserts [] = [ + 'date' => "$month-01", + 'machine_category' => "diesel", + 'machine_id' => $customisedMachineCode['id'] + ]; + + } + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMachineInStockModel->insertBatch($inserts); + + } + }else{ //if filter present,get that material codes $existingCustomMachineCodes = $this->factoryMachine_model - ->getSelectedDieselMachines(array_column($existingCustomMachineCodes, 'machine_id')); + ->getSelectedDieselMachines(array_column($existingCustomMachineCodes, 'machine_id')); } @@ -1381,24 +1402,32 @@ class StockController extends BaseController $machineCodeList = array_column($existingCustomMachineCodes, 'id'); - foreach($machineCodeList as $index => $machineCode){ + $currentDate = new DateTime(); + + if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){ + + foreach($machineCodeList as $index => $machineCode){ - //checking filtered present in table , if not create dummy one for whole month - $findMachineCode = $this->factoryVehicleDieselDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('machine_id',$machineCode) - ->findAll(); - - - //check any material code is not present in stock table but applied in filter - if(empty($findMachineCode)){ - //create dummy entry for this - $this->createDummyEntryForDieselMachine($machineCode,$startDate,$endDate); + //checking filtered present in table , if not create dummy one for whole month + $findMachineCode = $this->factoryVehicleDieselDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('machine_id',$machineCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForDieselMachine($machineCode,$startDate,$endDate); + } + } } + + $dieselMachines = $existingCustomMachineCodes; $data['activeDieselMachines'] = $this->factoryMachine_model->getAllActiveDieselMachines(); @@ -1731,7 +1760,8 @@ class StockController extends BaseController $filterUpdateNeeded = true ; if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){ - $customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ; + + $customisedMachineCodes = array_column($existingCustomMachineCodes, 'machine_id') ; $filterUpdateNeeded = false ; } @@ -1785,14 +1815,37 @@ class StockController extends BaseController //possible if no filter applied at all...!!! - if(empty($existingCustomMachineCodes)){ + if(empty($existingCustomMachineCodes) ){ //no filter applied at all just present all active material codes $existingCustomMachineCodes = $this->factoryMachine_model ->getAllActiveElectricMachines(); + + + //if no filter exists , just add current filter for that month ....!! + $inserts = []; + + foreach($existingCustomMachineCodes as $index => $customisedMachineCode){ + + $inserts [] = [ + 'date' => "$month-01", + 'machine_category' => "electric", + 'machine_id' => $customisedMachineCode['id'] + ]; + + } + + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMachineInStockModel->insertBatch($inserts); + + } + + + }else{ //if filter present,get that material codes $existingCustomMachineCodes = $this->factoryMachine_model - ->getSelectedElectricMachines(array_column($existingCustomMachineCodes, 'machine_id')); + ->getSelectedElectricMachines(array_column($existingCustomMachineCodes, 'machine_id')); } @@ -1801,24 +1854,32 @@ class StockController extends BaseController //this existingCustomMachineCodes gets its machine after visiting factory machine master table $machineCodeList = array_column($existingCustomMachineCodes, 'id'); - foreach($machineCodeList as $index => $machineCode){ + $currentDate = new DateTime(); - //checking filtered material code present in table , if not create dummy one for whole month - $findMachineCode = $this->powerConsumptionDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('machine_id',$machineCode) - ->findAll(); - - //check any material code is not present in stock table but applied in filter - if(empty($findMachineCode)){ - //create dummy entry for this - $this->createDummyEntryForElectricMachine($machineCode,$startDate,$endDate); + if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){ + + foreach($machineCodeList as $index => $machineCode){ + + //checking filtered material code present in table , if not create dummy one for whole month + $findMachineCode = $this->powerConsumptionDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('machine_id',$machineCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForElectricMachine($machineCode,$startDate,$endDate); + } + } - } + + $electricMachines = $existingCustomMachineCodes; $data['activeElectricMachines'] = $this->factoryMachine_model->getAllActiveElectricMachines(); @@ -2310,8 +2371,31 @@ class StockController extends BaseController //possible if no filter applied at all...!!! if(empty($existingCustomMaterialCodes)){ + //no filter applied at all just present all active material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode(); + + + //if no filter already exists or removed current one , just add current filter for that month ....!! + $inserts = []; + + foreach($existingCustomMaterialCodes as $index => $customisedMaterialCode){ + + $inserts [] = [ + 'date' => "$month-01", + 'stock_category' => "resin", + 'materialCode' => $customisedMaterialCode['MaterialCode'] + ]; + + } + + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMaterialInStockModel->insertBatch($inserts) ; + + } + + }else{ //if filter present , Reuse the filter and get that material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model @@ -2321,24 +2405,31 @@ class StockController extends BaseController $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); - foreach($materialCodeList as $index => $materialCode){ + $currentDate = new DateTime(); + + if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){ + + foreach($materialCodeList as $index => $materialCode){ - //checking filtered material code present in table , if not create dummy one for whole month - $findMachineCode = $this->resinStockDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('materialCode',$materialCode) - ->findAll(); - - - //check any material code is not present in stock table but applied in filter - if(empty($findMachineCode)){ - //create dummy entry for this - $this->createDummyEntryForResin($materialCode,$startDate,$endDate); + //checking filtered material code present in table , if not create dummy one for whole month if it is current month + $findMachineCode = $this->resinStockDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('materialCode',$materialCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForResin($materialCode,$startDate,$endDate); + } + } - - } + } + + $resinMaterials = $existingCustomMaterialCodes ; @@ -2590,6 +2681,7 @@ class StockController extends BaseController { if ($this->request->getMethod() === 'POST') { + $month = $this->request->getPost('month'); $date = DateTime::createFromFormat('d-M-Y', '01-'.$month); @@ -2698,33 +2790,62 @@ class StockController extends BaseController //no filter applied at all just present all active material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model ->getAllBagMaterialCode(); + + //if no filter already exists or removed current one , just add current filter for that month ....!! + $inserts = []; + + foreach($customisedMaterialCodes as $index => $customisedMaterialCode){ + + $inserts [] = [ + 'date' => "$month-01", + 'stock_category' => "resin", + 'materialCode' => $customisedMaterialCode['MaterialCode'] + ]; + + } + + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMaterialInStockModel->insertBatch($inserts) ; + } + + }else{ //if filter present,get that material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model ->getSelectedBagMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode')); - } + + + } $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); - foreach($materialCodeList as $index => $materialCode){ + $currentDate = new DateTime(); + + if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){ + + foreach($materialCodeList as $index => $materialCode){ - //checking filtered material code present in table , if not create dummy one for whole month - $findMachineCode = $this->bagStockDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('materialCode',$materialCode) - ->findAll(); - - - //check any material code is not present in stock table but applied in filter - if(empty($findMachineCode)){ - //create dummy entry for this - $this->createDummyEntryForBag($materialCode,$startDate,$endDate); + //checking filtered material code present in table , if not create dummy one for whole month for current month only + $findMachineCode = $this->bagStockDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('materialCode',$materialCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForBag($materialCode,$startDate,$endDate); + } + } - - } + } + + $bagMaterials = $existingCustomMaterialCodes ; @@ -3054,8 +3175,6 @@ class StockController extends BaseController echo "Data Saved Successfully"; } - - public function trpProductionDetails(){ //filtering month in post request @@ -3171,10 +3290,6 @@ class StockController extends BaseController return $this->loadViews("stock/trpProductionStockDetails", $this->global, $data, NULL); } - - - - public function updateTrpProductionDetails($inserts = null, $freshEntry = false) @@ -3267,6 +3382,7 @@ class StockController extends BaseController 'gasReceiptBg' => $data['gasReceiptBg'], 'gasReceiptPg' => $data['gasReceiptPg'], 'physicalGasConsumption' => $data['physicalGasConsumption'], + 'drierGasConsumption' => $data['drierGasConsumption'], 'trpPlusDrierGasConsumption' => $data['trpPlusDrierGasConsumption'], 'trpPhysicalGasPerTon' => $data['trpPhysicalGasPerTon'], 'panelGasConsumption' => $data['panelGasConsumption'], @@ -3362,9 +3478,6 @@ class StockController extends BaseController echo "An error occurred: " . $error->getMessage(); } } - - - public function updateAbstractDetails() { @@ -3404,20 +3517,6 @@ class StockController extends BaseController } - - - - - - - - - - - - - - // -------------------------------------------- in class helpers ---------------------------------------------- @@ -3457,7 +3556,7 @@ class StockController extends BaseController while ($start <= $end) { $timeValue = date('H:i', $start); // 24-hour format for value - $timeLabel = date('h:i a', $start); // 12-hour format with AM/PM for display + $timeLabel = date('h:i A', $start); // 12-hour format with AM/PM for display $times[$timeValue] = $timeLabel; // Store time in associative array $start = strtotime('+15 minutes', $start); // Increment by 15 minutes } @@ -3627,6 +3726,7 @@ class StockController extends BaseController 'gasReceiptBg' => " ", 'gasReceiptPg' => " ", 'physicalGasConsumption' => " ", + 'drierGasConsumption' => " ", 'trpPlusDrierGasConsumption' => " ", 'trpPhysicalGasPerTon' => " ", 'panelGasConsumption' => " ", @@ -3655,7 +3755,6 @@ class StockController extends BaseController - diff --git a/app/Models/TrpProductionModel.php b/app/Models/TrpProductionModel.php index 8b8366ae..b7fb0551 100644 --- a/app/Models/TrpProductionModel.php +++ b/app/Models/TrpProductionModel.php @@ -13,7 +13,8 @@ class TrpProductionModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = ['id','date', 'gasReceiptBg', 'gasReceiptPg', 'physicalGasConsumption', 'trpPlusDrierGasConsumption', + protected $allowedFields = ['id','date', 'gasReceiptBg', 'gasReceiptPg', 'physicalGasConsumption', + 'drierGasConsumption','trpPlusDrierGasConsumption', 'trpPhysicalGasPerTon', 'panelGasConsumption','panelGasPerTon','edRunningHours','edProduction','edUsage', 'trpProduction', 'trpProductionPerHour', 'waterReceipt', 'waterConsumption' ,'ebReading', 'ebReadingPerUnitTon']; @@ -88,8 +89,8 @@ class TrpProductionModel extends Model tpd.physicalGasConsumption, - IFNULL(tdmd.totalGasConsumption, 0) AS drierGasConsumption, IFNULL(tcmd.totalGasConsumption, 0) AS coatingGasConsumption, + tpd.drierGasConsumption As drierGasConsumption, tpd.trpPlusDrierGasConsumption, tpd.trpPhysicalGasPerTon, tpd.panelGasConsumption, @@ -143,13 +144,15 @@ class TrpProductionModel extends Model $builder->join("({$subquery1}) tcmd", 'tcmd.date = tpmd.date', 'left'); - // Subquery: Drier Machine Gas Consumption - $subquery2 = $this->db->table('t_driermachinedetails') - ->select('date, SUM(total_gas_consumption) AS totalGasConsumption') - ->groupBy('date') - ->getCompiledSelect(false); // Convert Query Builder to raw SQL; + //client requirement change from auto entry to manual entry from drier gas consumption - $builder->join("({$subquery2}) tdmd", 'tdmd.date = tpmd.date', 'left'); + // Subquery: Drier Machine Gas Consumption + // $subquery2 = $this->db->table('t_driermachinedetails') + // ->select('date, SUM(total_gas_consumption) AS totalGasConsumption') + // ->groupBy('date') + // ->getCompiledSelect(false); // Convert Query Builder to raw SQL; + + // $builder->join("({$subquery2}) tdmd", 'tdmd.date = tpmd.date', 'left'); diff --git a/app/Views/configlisting.php b/app/Views/configlisting.php index 2412296f..0796b75a 100755 --- a/app/Views/configlisting.php +++ b/app/Views/configlisting.php @@ -57,6 +57,10 @@ +getFlashdata('page') ?? $_GET['page'] ?? 1; +?> +
( Note :The entries count includes archived data... )
+ diff --git a/app/Views/stock/CoatingMachineDetail.php b/app/Views/stock/CoatingMachineDetail.php index e7e2bb68..e81d289c 100644 --- a/app/Views/stock/CoatingMachineDetail.php +++ b/app/Views/stock/CoatingMachineDetail.php @@ -1296,7 +1296,7 @@ @@ -1459,7 +1458,6 @@ let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOffTimeHr); if (!machineRunningInHrs) { - $('#machineOffTimeHrId').val(''); return } @@ -1467,12 +1465,31 @@ $('#totalCoatingSandId').trigger('change'); $('#totalGasConsumptionId').trigger('change'); - - }) + $('#totalCoatingId , #shiftId , #gradeId').change(function(){ + + let basicCheck =checkIsNumber($(this).val().trim()); + + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + return; + } + + + }) + $('#totalCoatingSandId').change(function() { + let basicCheck =checkIsNumber($(this).val().trim()); + + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + return; + } + let totalCoatingSandValue = $(this).val(); let machineRunningInHrsValue = $('#machineRunningInHrsId').val(); @@ -1486,6 +1503,15 @@ $('#totalGasConsumptionId').change(function() { + + let basicCheck =checkIsNumber($(this).val().trim()); + + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + return; + } + let totalGasConsumptionValue = $(this).val(); let machineRunningInHrsValue = $('#machineRunningInHrsId').val(); if (totalGasConsumptionValue && machineRunningInHrsValue) { @@ -1496,14 +1522,6 @@ }) - }) - - - - - @@ -1712,48 +1770,59 @@ + @@ -1141,60 +1239,70 @@ foreach ($period as $day) { + + + + + + + + + \ No newline at end of file diff --git a/app/Views/stock/dieselStockDetails.php b/app/Views/stock/dieselStockDetails.php index f0d294ae..c48483f5 100644 --- a/app/Views/stock/dieselStockDetails.php +++ b/app/Views/stock/dieselStockDetails.php @@ -319,6 +319,19 @@ foreach ($period as $day) {