diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 8d423624..1597b50f 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -1344,21 +1344,6 @@ class StockController extends BaseController 'machine_category' => "diesel", 'machine_id' => $customisedMachineCode ]; - - - //checking filtered material code present in table , if not create dummy one for whole month - $findMachineCode = $this->factoryVehicleDieselDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('machine_id',$customisedMachineCode) - ->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($customisedMachineCode,$startDate,$endDate); - } } @@ -1396,6 +1381,24 @@ class StockController extends BaseController $machineCodeList = array_column($existingCustomMachineCodes, 'id'); + 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); + } + + } + $dieselMachines = $existingCustomMachineCodes; $data['activeDieselMachines'] = $this->factoryMachine_model->getAllActiveDieselMachines(); @@ -1761,23 +1764,6 @@ class StockController extends BaseController 'machine_category' => "electric", 'machine_id' => $customisedMachineCode ]; - - - //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',$customisedMachineCode) - ->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($customisedMachineCode,$startDate,$endDate); - } } @@ -1811,9 +1797,28 @@ 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){ + + //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(); @@ -2284,19 +2289,6 @@ class StockController extends BaseController 'stock_category' => "resin", 'materialCode' => $customisedMaterialCode ]; - - //checking filtered material code present in table , if not create dummy one for whole month - $findMaterialCode = $this->resinStockDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('materialCode',$customisedMaterialCode) - ->findAll(); - - //check any material code is not present in stock table but applied in filter - if(empty($findMaterialCode)){ - //create dummy entry for that - $this->createDummyEntryForResin($customisedMaterialCode,$startDate,$endDate); - } } @@ -2329,6 +2321,25 @@ class StockController extends BaseController $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); + 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); + } + + } + $resinMaterials = $existingCustomMaterialCodes ; $data['activeResinMaterials'] = $this->rawmaterialdetails_model->getAllResinMaterialCode(); @@ -2663,19 +2674,6 @@ class StockController extends BaseController 'stock_category' => "packing_material", 'materialCode' => $customisedMaterialCode ]; - - //checking filtered material code present in table , if not create dummy one for whole month - $findMaterialCode = $this->bagStockDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('materialCode',$customisedMaterialCode) - ->findAll(); - - //check any material code is not present in stock table but applied in filter - if(empty($findMaterialCode)){ - //create dummy entry for that - $this->createDummyEntryForBag($customisedMaterialCode,$startDate,$endDate); - } } @@ -2709,6 +2707,25 @@ class StockController extends BaseController $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); + 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); + } + + } + $bagMaterials = $existingCustomMaterialCodes ; $data['activeBagMaterials'] = $this->rawmaterialdetails_model->getAllBagMaterialCode(); diff --git a/app/Views/stock/drierMachineDetails.php b/app/Views/stock/drierMachineDetails.php index 79ac5c1f..5e441fec 100644 --- a/app/Views/stock/drierMachineDetails.php +++ b/app/Views/stock/drierMachineDetails.php @@ -471,12 +471,13 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');