diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b08ca39c..b613750c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -43,9 +43,9 @@ $routes->get('user/deleteUser', 'User::deleteUser'); $routes->get('user/reActivateUser', 'User::reActivateUser'); // Supplier Routes -$routes->get('supplierlisting', 'Supplier::index'); // list supplier +$routes->match(["GET","POST"],'supplierlisting', 'Supplier::index'); // list supplier $routes->add('addsupplier', 'Supplier::addsupplier');//load add supplier page -$routes->get('viewsupplier', 'Supplier::viewsupplier');// load edit supplier page +$routes->get('viewsupplier', 'Supplier::viewsupplier'); $routes->post('editsupplier', 'Supplier::updatesupplierdetails'); //save supplier details $routes->post('addNewsupplier', 'Supplier::savesupplierdetails'); // update supplier details $routes->post('supplierExist', 'Supplier::checksupplier'); @@ -68,7 +68,7 @@ $routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial'); $routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial'); // Cost Center Routes -$routes->get('costListing', 'CostCenter::index'); +$routes->match(['GET','POST'],'costListing', 'CostCenter::index'); $routes->post('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit.... $routes->get('reActivateCostCenter', 'CostCenter::reActivateCostCenter'); $routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter'); @@ -97,7 +97,7 @@ $routes->post('getDriver', 'Driver::getDriver'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'driverPrintPdf', 'Driver::driverPrintPdf'); // Asset Detail Routes -$routes->get('assetListing', 'Assetdetails::assetListing'); +$routes->match(['GET','POST'],'assetListing', 'Assetdetails::assetListing'); $routes->get('addasset', 'Assetdetails::addasset'); $routes->post('assetdetails/getpodetails', 'Assetdetails::getpodetails'); $routes->post('assetdetails/getline', 'Assetdetails::getline'); @@ -151,7 +151,7 @@ $routes->get('configurationctrl/deleteConfig', 'Configurationctrl::deleteConfig' $routes->get('configurationctrl/reActivateConfig', 'Configurationctrl::reActivateConfig'); // Department Master Routes -$routes->get('departmentListing', 'Department::index'); +$routes->match(["GET","POST"],'departmentListing', 'Department::index'); $routes->get('adddepartment', 'Department::adddepartment'); $routes->post('savedepartment', 'Department::savedepartment'); $routes->get('editOlddepartment', 'Department::viewdepartment'); @@ -295,10 +295,10 @@ $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'storerequisitionlisting', 'Sto $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'EditStoreRequisition', 'Storerequisitioncontroller::EditStoreRequistion'); // Application IGR Routes -$routes->get('AddIGR', 'Inwardgateregister::addIGR'); // ADD IGR page - working -$routes->get('ViewIGR', 'Inwardgateregister::viewIGR'); // View IGR PAGE - Working +$routes->get( 'AddIGR', 'Inwardgateregister::addIGR'); // ADD IGR page - working +$routes->get( 'ViewIGR', 'Inwardgateregister::viewIGR'); // View IGR PAGE - Working $routes->post('ViewIGR', 'Inwardgateregister::viewIGR');//for filter purpose -$routes->get('accountsDashboard', 'Inwardgateregister::accountsDashboard'); // View IGR PAGE - Working +$routes->get( 'accountsDashboard', 'Inwardgateregister::accountsDashboard'); // View IGR PAGE - Working $routes->post('ViewIGRDetails', 'Inwardgateregister::viewIGRDetails'); $routes->post('GetIGRLineItemDetails', 'Inwardgateregister::getIGRLineItemDetails'); $routes->post('SaveIGR', 'Inwardgateregister::SaveIGR');// Save IGR PAGE - Working @@ -309,10 +309,13 @@ $routes->post('getCostCenterData', 'Inwardgateregister::getCostCenterData'); $routes->post('ViewIGRfile', 'Inwardgateregister::ViewIGRfile'); $routes->post('getAdditionalIGRFile', 'Inwardgateregister::getAdditionalIGRFile'); $routes->post('deleteAdditionalIGRFile', 'Inwardgateregister::deleteAdditionalIGRFile'); -$routes->get('download-files/(:segment)', 'Inwardgateregister::downloadFilesAsZip/$1'); +$routes->get( 'download-files/(:segment)', 'Inwardgateregister::downloadFilesAsZip/$1'); $routes->post('inwardgateregister/edituploadfile', 'Inwardgateregister::edituploadfile'); $routes->post('getIGRRemarks', 'Inwardgateregister::getIGRRemarks'); $routes->post('saveIGRRemarks', 'Inwardgateregister::saveIGRRemarks'); +$routes->post('updateGasShortage','Inwardgateregister::updateGasShortage'); +$routes->post('gasShortageList','Inwardgateregister::gasShortageList'); +$routes->post('getGasShortageDetail',"Inwardgateregister::getGasShortageDetail"); // Non IGR / Expense @@ -439,7 +442,7 @@ $routes->post('download_sales_invoice', 'Sales::download_sales_invoice'); $routes->post('updateInvRecQty', 'Sales::updateInvRecQty'); // transporter Routes -$routes->get('transporterListing', 'Supplier::transporterListing'); +$routes->match(['GET', 'POST'],'transporterListing', 'Supplier::transporterListing'); $routes->post('fetchTransporterDetails', 'Supplier::fetchTransporterDetails');// for Ajax both add and edit.... $routes->get('deleteTransporter', 'Supplier::deleteTransporter'); $routes->get('reActivateTransporter', 'Supplier::reActivateTransporter'); @@ -449,6 +452,7 @@ $routes->post('checkTransporter', 'Supplier::checkTransporter'); $routes->post('createFactoryMachineMasterDetails', 'FactoryMachineController::createFactoryMachineMasterDetails'); $routes->get('readFactoryMachineMasterDetails', 'FactoryMachineController::readFactoryMachineMasterDetails'); +$routes->post('readFactoryMachineMasterDetails', 'FactoryMachineController::readFactoryMachineMasterDetails'); $routes->get('readFactoryMachineMasterDetailsById', 'FactoryMachineController::readFactoryMachineMasterDetailsById'); $routes->post('updateFactoryMachineMasterDetails', 'FactoryMachineController::updateFactoryMachineMasterDetails'); $routes->get('deleteFactoryMachineMasterDetails', 'FactoryMachineController::deleteFactoryMachineMasterDetails'); diff --git a/app/Controllers/Assetdetails.php b/app/Controllers/Assetdetails.php index d1b2977a..abe28116 100755 --- a/app/Controllers/Assetdetails.php +++ b/app/Controllers/Assetdetails.php @@ -50,9 +50,22 @@ class Assetdetails extends BaseController */ function assetListing() { + $isActiveFilter = 1 ; // default showing active data + $showArchive = 0 ; // + + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown then we are making active filter 0 + if($showArchive){ + $isActiveFilter = 0; + } + } + + $data['showArchive'] = $showArchive; - $data['userRecords'] = $this->assetdetails_model->assetListing(); + $data['userRecords'] = $this->assetdetails_model->assetListing($isActiveFilter); $this->global['pageTitle'] = 'Asset List'; //print_r($data);die(); diff --git a/app/Controllers/CostCenter.php b/app/Controllers/CostCenter.php index d23a4a2d..b91be7f4 100755 --- a/app/Controllers/CostCenter.php +++ b/app/Controllers/CostCenter.php @@ -45,7 +45,21 @@ class CostCenter extends BaseController */ public function index() { - $data['userRecords'] = $this->costcenter_model->CostListing(); + + $isActiveFilter = 1 ; // default showing active data + $showArchive = 0 ; // + + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown we are making active filter + if($showArchive){ + $isActiveFilter = 0; + } + } + + $data['showArchive'] = $showArchive; + $data['userRecords'] = $this->costcenter_model->CostListing($isActiveFilter); $this->global['pageTitle'] = 'Cost List'; $this->loadViews("costListing", $this->global, $data, NULL); diff --git a/app/Controllers/Department.php b/app/Controllers/Department.php index 79d4d956..fa607f43 100755 --- a/app/Controllers/Department.php +++ b/app/Controllers/Department.php @@ -48,20 +48,25 @@ class Department extends BaseController public function index() { - // if($this->isAdmin() == TRUE) - // { - // $this->loadThis(); - // } - // else - // { + + $isActiveFilter = 1 ; // default showing active data + $showArchive = 0 ; // + + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown then we are making active filter 0 + if($showArchive){ + $isActiveFilter = 0; + } + } + + $data['showArchive'] = $showArchive; + + $this->department_model = new department_model(); - //$searchText = $this->request->getPost('searchText'); - //$data['searchText'] = $searchText; - //$count = $this->department_model->departmentListing($searchText); - //$returns = $this->paginationCompress ( "departmentListing/", $count, 20 ); - - $data['userRecords'] = $this->department_model->departmentListing(); //$searchText, $returns["page"], $returns["segment"]); + $data['userRecords'] = $this->department_model->departmentListing($isActiveFilter); //$searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Department Listing'; diff --git a/app/Controllers/Expense.php b/app/Controllers/Expense.php index 4483e649..4d4a61d6 100755 --- a/app/Controllers/Expense.php +++ b/app/Controllers/Expense.php @@ -25,6 +25,8 @@ class Expense extends BaseController public function index() { + + $isActiveFilter = 1 ; if ($this->request->getMethod() === 'GET') { @@ -38,7 +40,7 @@ class Expense extends BaseController } $data['expense_list'] = $this->expense_model->getAllExpense($fromDate,$toDate); - $data['supplier_list'] = json_encode($this->supplier_model->supplierlisting()); + $data['supplier_list'] = json_encode($this->supplier_model->supplierlisting($isActiveFilter)); $this->global['pageTitle'] = 'Non IGR / Expense List'; $data['fromDate'] = date('d-m-Y', strtotime($fromDate)); $data['toDate'] = date('d-m-Y', strtotime($toDate)); diff --git a/app/Controllers/FactoryMachineController.php b/app/Controllers/FactoryMachineController.php index 002f78dd..aac84358 100644 --- a/app/Controllers/FactoryMachineController.php +++ b/app/Controllers/FactoryMachineController.php @@ -80,9 +80,25 @@ class FactoryMachineController extends BaseController public function readFactoryMachineMasterDetails(){ + + $isActiveFilter = 1 ; // default showing active data + $showArchive = 0 ; // + + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown then we are making active filter 0 + if($showArchive){ + $isActiveFilter = 0; + } + } + + $data['showArchive'] = $showArchive; + $this->global['pageTitle'] = 'Factory Machine Master Details'; $data['masterData'] = $this->factoryMachineMaster_model + ->where('is_active',$isActiveFilter) ->orderBy('created_at','DESC') ->findAll(); diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 438272e9..a66fabb8 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -8,6 +8,7 @@ use CodeIgniter\Validation\Exceptions\ValidationException; use App\Models\Inwardgateregister_model; use App\Models\IGRRemarks_model; +use App\Models\GasShortageModel; use App\Helpers\Notification; use DateTime; @@ -25,6 +26,7 @@ class Inwardgateregister extends BaseController { protected $inwardgateregister_model; protected $IGRRemarks_model; + protected $gasShortage_model; protected $session; protected $logger; @@ -37,6 +39,7 @@ class Inwardgateregister extends BaseController parent::__construct(); $this->inwardgateregister_model = new Inwardgateregister_model(); $this->IGRRemarks_model = new IGRRemarks_model(); + $this->gasShortage_model = new GasShortageModel(); $this->session = session(); helper('form'); //$this->load->library('form_validation'); @@ -1472,4 +1475,62 @@ function updateIGRWeight(){ } } + + + public function gasShortageList(){ + + $postData = $this->request->getPost(); + + $allShortages = $this->gasShortage_model->where('invoiceNo',$postData['invoiceNo'])->findAll(); + + return $this->response->setJSON(['status' => 'success', 'data' => $allShortages]); + + + } + + + public function getGasShortageDetail(){ + + $postData = $this->request->getPost(); + + $shortage = $this->gasShortage_model->where('id',$postData['id'])->find(); + + return $this->response->setJSON(['status' => 'success', 'data' => $shortage]); + + } + + + + public function updateGasShortage() + { + $postData = $this->request->getPost(); + + // Validate required data + if (!$postData) { + return $this->response->setJSON(['status' => 'error', 'message' => 'Invalid request. No data received.']); + } + + // Validate required fields for adding + if ( !isset($postData['invoiceNo']) ) { + return $this->response->setJSON(['status' => 'error', 'message' => 'Missing required fields: invoice No.']); + } + + // Handle update (edit) + if (isset($postData["id"])) { + return $this->gasShortage_model->update($postData["id"], $postData) + ? $this->response->setJSON(['status' => 'success', 'message' => 'Gas shortage details updated successfully.']) + : $this->response->setJSON(['status' => 'error', 'message' => 'Failed to update gas shortage details.']); + } + + // Insert new shortage (add) + return ($insertId = $this->gasShortage_model->insert($postData)) + ? $this->response->setJSON(['status' => 'success', 'message' => 'Gas shortage details added successfully.', 'data' => ['id' => $insertId]]) + : $this->response->setJSON(['status' => 'error', 'message' => 'Failed to save gas shortage details.']); + + } + + + + + } \ No newline at end of file diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index 738e2c69..0c48421e 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -66,9 +66,22 @@ class Rawmaterialdetails extends BaseController function rawmaterialListing() { - $this->rawmaterialdetails_model = new rawmaterialdetails_model();; + $isActiveFilter = 1 ; // default showing active data + $showArchive = 0 ; // - $data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing(); + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown we are making active filter + if($showArchive){ + $isActiveFilter = 0; + } + } + + $this->rawmaterialdetails_model = new rawmaterialdetails_model(); + + $data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing($isActiveFilter); + $data['showArchive'] = $showArchive ; $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); $this->global['pageTitle'] = 'RawMaterial Listing'; diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index c3b26a66..de76134c 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -17,14 +17,16 @@ use App\Models\BagStockDetailsModel; use App\Models\DustAndRoughModel; use App\Models\ResinStockModel; use App\Models\GasStockModel; -use App\Models\TrpAbstract; -use App\Models\TrpAbstractParticulars; use App\Models\TrpSandUseStockModel; use App\Models\TrpProductionModel; use App\Models\TrpProductionMaintenanceModel; use App\Models\TrpProductionWasteModel; use App\Models\Employeedetails_model; use App\Models\PowerConsumptionSummaryModel; +use App\Models\MonthWiseMaterialInStockModel; +use App\Models\MonthWiseMachinesInStockModel; +use App\Models\TrpAbstractModel; + @@ -68,9 +70,11 @@ class StockController extends BaseController protected $employeedetails_model; - protected $trpAbstractParticularsModel ; + protected $monthWiseMaterialInStockModel ; - protected $trpAbstractModel ; + protected $monthWiseMachineInStockModel ; + + protected $trpAbstract_model ; /** @@ -120,10 +124,12 @@ class StockController extends BaseController $this->employeedetails_model = new Employeedetails_model(); $this->powerConsumptionSummary_model = new PowerConsumptionSummaryModel(); + + $this->monthWiseMaterialInStockModel = new MonthWiseMaterialInStockModel(); - $this->trpAbstractParticularsModel = new TrpAbstractParticulars(); + $this->monthWiseMachineInStockModel = new MonthWiseMachinesInStockModel(); - $this->trpAbstractModel = new TrpAbstract(); + $this->trpAbstract_model = new TrpAbstractModel(); $this->session = session(); @@ -791,6 +797,98 @@ class StockController extends BaseController $this->global['pageTitle'] = 'Bag Stock Details'; + $startDate = "$month-01"; + $endDate = date("Y-m-t", strtotime($startDate)); + + + + $customisedMaterialCodes = $this->request->getPost('customisedMaterialCodes') ?? []; + + $existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel + ->select('materialCode') + ->where('date',"$month-01") + ->where('stock_category','packing_material') + ->findAll(); + + + //check user applies for filter currently + if(!empty($customisedMaterialCodes)){ + + //user applied filter, + + //check already filter existing , if exists remove that , + if(!empty($existingCustomMaterialCodes)){ + + //hard delete done..!! + $existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel + ->where('date',"$month-01") + ->where('stock_category','packing_material') + ->delete(); + + } + + + //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' => "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); + } + + } + + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMaterialInStockModel->insertBatch($inserts); + + //get the currently applied filter + $existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel + ->select('materialCode') + ->where('date',"$month-01") + ->where('stock_category','packing_material') + ->get()->getResultArray(); + + } + + } + + + //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 + ->getAllBagMaterialCode(); + }else{ + //if filter present,get that material codes + $existingCustomMaterialCodes = $this->rawmaterialdetails_model + ->getSelectedBagMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode')); + } + + + $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); + + $bagMaterials = $existingCustomMaterialCodes ; + + $data['activeBagMaterials'] = $this->rawmaterialdetails_model->getAllBagMaterialCode(); + + // Get the previous month's last date bag stock details for next month updation $previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m'); @@ -809,11 +907,10 @@ class StockController extends BaseController // checking in database if the data is available for the month - $startDate = "$month-01"; - $endDate = date("Y-m-t", strtotime($startDate)); $data['bagStockDetails'] = $this->bagStockDetails_model ->where('date >=', $startDate) ->where('date <=', $endDate) + ->whereIn('materialCode',$materialCodeList) ->groupBy(['materialCode', 'date']) ->orderBy('date', 'asc') ->orderBy('materialCode', 'asc') @@ -856,25 +953,28 @@ class StockController extends BaseController + //temp_code_s_2025_02 - // getting bag material for creating table headers - // checking already existing stock if yes then get the material code from the existing bag - // if not get all the material codes from the raw material details table + // // getting bag material for creating table headers + // // checking already existing stock if yes then get the material code from the existing bag + // // if not get all the material codes from the raw material details table - if (!empty($data['groupedBagStockDetails'])) { - $result = $groupedByDate[$date]; + // if (!empty($data['groupedBagStockDetails'])) { + // $result = $groupedByDate[$date]; - $distinctMaterialCodes = []; + // $distinctMaterialCodes = []; - foreach ($result as $index => $eachResult) { - $distinctMaterialCodes[] = $result[$index]['materialCode']; - } + // foreach ($result as $index => $eachResult) { + // $distinctMaterialCodes[] = $result[$index]['materialCode']; + // } - $bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($distinctMaterialCodes); + // $bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($distinctMaterialCodes); - } else { - $bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode(); - } + // } else { + // $bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode(); + // } + + //temp_code_e_2025_02 // getting customer for creating table headers @@ -1104,6 +1204,97 @@ class StockController extends BaseController $this->global['pageTitle'] = 'Resin Stock Details'; + $startDate = "$month-01"; + $endDate = date("Y-m-t", strtotime($startDate)); + + + + $customisedMaterialCodes = $this->request->getPost('customisedMaterialCodes') ?? []; + + $existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel + ->select('materialCode') + ->where('date',"$month-01") + ->where('stock_category','resin') + ->findAll(); + + + //check user applies for filter currently + if(!empty($customisedMaterialCodes)){ + + //user applied filter, + + //check already filter existing , if exists remove that , + if(!empty($existingCustomMaterialCodes)){ + + //hard delete done..!! + $existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel + ->where('date',"$month-01") + ->where('stock_category','resin') + ->delete(); + + } + + + //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 + ]; + + //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); + } + + } + + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMaterialInStockModel->insertBatch($inserts); + + //get the currently applied filter + $existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel + ->select('materialCode') + ->where('date',"$month-01") + ->where('stock_category','resin') + ->get()->getResultArray(); + + } + + } + + + //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(); + }else{ + //if filter present,get that material codes + $existingCustomMaterialCodes = $this->rawmaterialdetails_model + ->getSelectedResinMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode')); + } + + + $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); + + $resinMaterials = $existingCustomMaterialCodes ; + + $data['activeResinMaterials'] = $this->rawmaterialdetails_model->getAllResinMaterialCode(); + + // Get the previous month's last date resin stock details for next month updation @@ -1123,11 +1314,12 @@ class StockController extends BaseController // checking in database if the data is available for the month - $startDate = "$month-01"; - $endDate = date("Y-m-t", strtotime($startDate)); + + $data['resinStockDetails'] = $this->resinStockDetails_model ->where('date >=', $startDate) ->where('date <=', $endDate) + ->whereIn('materialCode',$materialCodeList) ->groupBy(['materialCode', 'date']) ->orderBy('date', 'asc') ->orderBy('materialCode', 'asc') @@ -1166,28 +1358,31 @@ class StockController extends BaseController $data['groupedResinStockDetails'] = array_values($groupedByDate); + //temp_code_s_2025_02 // getting resin material for creating table headers // checking already existing stock if yes then get the material code from the existing stock - // if not get all the material codes from the raw material details table + // if not get all the material codes currently isActive from the raw material details table - if (!empty($data['groupedResinStockDetails'])) { + // if (!empty($data['groupedResinStockDetails'])) { - $result = $groupedByDate[$date]; + // $result = $groupedByDate[$date]; - $distinctMaterialCodes = []; + // $distinctMaterialCodes = []; - foreach ($result as $index => $eachResult) { - $distinctMaterialCodes[] = $result[$index]['materialCode']; - } + // foreach ($result as $index => $eachResult) { + // $distinctMaterialCodes[] = $result[$index]['materialCode']; + // } - $resinMaterials = $this->rawmaterialdetails_model->getSelectedResinMaterialCode($distinctMaterialCodes); + // $resinMaterials = $this->rawmaterialdetails_model->getSelectedResinMaterialCode($distinctMaterialCodes); - } else { + // } else { - $resinMaterials = $this->rawmaterialdetails_model->getAllResinMaterialCode(); + // $resinMaterials = $this->rawmaterialdetails_model->getAllResinMaterialCode(); - } + // } + + //temp_code_e_2025_02 // getting customer for creating table headers @@ -1218,6 +1413,119 @@ class StockController extends BaseController return $this->loadViews("stock/resinStockDetails", $this->global, $data, NULL); } + public function createDummyEntryForResin($customisedMaterialCode, $startDate, $endDate) + { + if (!empty($customisedMaterialCode)) { + $inserts = []; + + // Convert start and end date to timestamps + $startTimestamp = strtotime($startDate); + $endTimestamp = strtotime($endDate); + + while ($startTimestamp <= $endTimestamp) { + $inserts[] = [ + 'date' => date('Y-m-d', $startTimestamp), // Convert timestamp to date format + 'materialCode' => $customisedMaterialCode, + 'customer' => ' ', + 'opening' => ' ', + 'receipt' => ' ', + 'used' => ' ', + 'balanceStock' => ' ', + ]; + + $startTimestamp = strtotime('+1 day', $startTimestamp); // Move to the next day + } + + if (!empty($inserts)) { + $this->resinStockDetails_model->insertBatch($inserts); + } + } + } + + public function createDummyEntryForBag($customisedMaterialCode, $startDate, $endDate) + { + if (!empty($customisedMaterialCode)) { + $inserts = []; + + // Convert start and end date to timestamps + $startTimestamp = strtotime($startDate); + $endTimestamp = strtotime($endDate); + + while ($startTimestamp <= $endTimestamp) { + $inserts[] = [ + 'date' => date('Y-m-d', $startTimestamp), // Convert timestamp to date format + 'materialCode' => $customisedMaterialCode, + 'customer' => ' ', + 'opening' => ' ', + 'receipt' => ' ', + 'used' => ' ', + 'balanceStock' => ' ', + ]; + + $startTimestamp = strtotime('+1 day', $startTimestamp); // Move to the next day + } + + if (!empty($inserts)) { + $this->bagStockDetails_model->insertBatch($inserts); + } + } + } + + public function createDummyEntryForDieselMachine($customisedMachineCode, $startDate, $endDate) + { + if (!empty($customisedMachineCode)) { + $inserts = []; + + // Convert start and end date to timestamps + $startTimestamp = strtotime($startDate); + $endTimestamp = strtotime($endDate); + + while ($startTimestamp <= $endTimestamp) { + $inserts[] = [ + 'date' => date('Y-m-d', $startTimestamp), // Convert timestamp to date format + 'machine_id' => $customisedMachineCode, + 'opening_units' => ' ', + 'closing_units' => ' ', + 'total_units' => ' ', + ]; + + $startTimestamp = strtotime('+1 day', $startTimestamp); // Move to the next day + } + + if (!empty($inserts)) { + $this->factoryVehicleDieselDetails_model->insertBatch($inserts); + } + } + } + + public function createDummyEntryForElectricMachine($customisedMachineCode, $startDate, $endDate) + { + if (!empty($customisedMachineCode)) { + $inserts = []; + + // Convert start and end date to timestamps + $startTimestamp = strtotime($startDate); + $endTimestamp = strtotime($endDate); + + while ($startTimestamp <= $endTimestamp) { + $inserts[] = [ + 'date' => date('Y-m-d', $startTimestamp), // Convert timestamp to date format + 'machine_id' => $customisedMachineCode, + 'opening_units' => ' ', + 'closing_units' => ' ', + 'total_units' => ' ', + ]; + + $startTimestamp = strtotime('+1 day', $startTimestamp); // Move to the next day + } + + if (!empty($inserts)) { + $this->powerConsumptionDetails_model->insertBatch($inserts); + } + } + } + + public function updateResinStockDetails() { @@ -1737,6 +2045,7 @@ class StockController extends BaseController $data['wcsSupplierList'] = $result[2] ; + $data['trpAbstract'] = $this->trpAbstract_model->currentMonthTrpAbstract($startDate,$endDate); $date = DateTime::createFromFormat('Y-m', $month); @@ -1931,24 +2240,6 @@ class StockController extends BaseController foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { - if($datesInMonthIndex == 0){ - - $trpAbstractParticulars =$this->trpAbstractParticularsModel->findAll(); - - foreach($trpAbstractParticulars as $index => $trpAbstractParticular){ - - $trpAbstract[] = [ - 'date' => $dateInMonth , - 'abs_opening_stock' => 0 , - 'abs_physical_stock'=> 0 , - 'abs_remarks' => " " , - 'abs_particular_id' => $trpAbstractParticular['id'], - ]; - } - - - } - $inserts[] = [ 'Date' => $dateInMonth, @@ -2091,10 +2382,11 @@ class StockController extends BaseController $monthData = $this->getMonthDatesFromInput($currentMonth); + $isActiveFilter = 1 ; $data['startDate'] = $monthData[0]['database']; $data['endDate'] = $monthData[count($monthData) - 1]['database']; $data['timeDropdown'] = $this->generateTimeOptions(); - $data['supplierData'] = $this->supplier_model->supplierlisting(); + $data['supplierData'] = $this->supplier_model->supplierlisting($isActiveFilter); $data['drierDetails'] = $this->drierMachineDetails_model ->where('date >=', $data['startDate']) @@ -2130,14 +2422,12 @@ class StockController extends BaseController $data = $row; - if (($existingRow)) { - // dd("inside update"); + if (($existingRow)) { $existingRow = $this->drierMachineDetails_model->where('id', $row['id'] ?? '')->first(); $this->handleGasStockUpdate($existingRow, $row); $updates[] = $data; } else { - // dd("inside insert"); $this->updateGasStockConsumption($data['date'], $data['total_gas_consumption']); $inserts[] = $data; } @@ -2261,6 +2551,121 @@ class StockController extends BaseController $this->global['pageTitle'] = 'Power Consumption Stock Details'; + + + //filter part starts + + //start date dynamic from front-end + $startDate = "$month-01"; + //end date of given month + $endDate = date("Y-m-t", strtotime($startDate)); + + + //filter applied currently + $customisedMachineCodes = $this->request->getPost('customisedMachineCodes') ?? []; + + + //already applied filter + $existingCustomMachineCodes = $this->monthWiseMachineInStockModel + ->select('machine_id') + ->where('date',"$month-01") + ->where('machine_category','electric') + ->findAll(); + + + //check user applies for filter currently + if(!empty($customisedMachineCodes)){ + + //user applied filter, + + //check already filter existing , if exists remove that , + if(!empty($existingCustomMachineCodes)){ + + //hard delete done..!! + $existingCustomMachineCodes = $this->monthWiseMachineInStockModel + ->where('date',"$month-01") + ->where('machine_category','electric') + ->delete(); + + } + + + //if no filter already exists or removed current one , just add current filter for that month ....!! + $inserts = []; + + foreach($customisedMachineCodes as $index => $customisedMachineCode){ + + $inserts [] = [ + 'date' => "$month-01", + '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); + } + + } + + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMachineInStockModel->insertBatch($inserts); + + //get the currently applied filter + $existingCustomMachineCodes = $this->monthWiseMachineInStockModel + ->select('machine_id') + ->where('date',"$month-01") + ->where('machine_category','electric') + ->get() + ->getResultArray(); + + } + + } + + + //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 + ->getAllActiveElectricMachines(); + }else{ + //if filter present,get that material codes + $existingCustomMachineCodes = $this->factoryMachine_model + ->getSelectedElectricMachines(array_column($existingCustomMachineCodes, 'machine_id')); + } + + + + //this existingCustomMachineCodes gets its machine after visiting factory machine master table + $machineCodeList = array_column($existingCustomMachineCodes, 'id'); + + $electricMachines = $existingCustomMachineCodes; + + $data['activeElectricMachines'] = $this->factoryMachine_model->getAllActiveElectricMachines(); + + + + + + + + + + // Get the previous month's last date power consumption stock details for next month updation $previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m'); @@ -2288,12 +2693,12 @@ class StockController extends BaseController // checking in database if the data is available for the month - $startDate = "$month-01"; - $endDate = date("Y-m-t", strtotime($startDate)); + $data['powerConsumptionStockDetails'] = $this->powerConsumptionDetails_model ->where('date >=', $startDate) ->where('date <=', $endDate) + ->whereIn('machine_id',$machineCodeList) ->groupBy(['machine_id', 'date']) ->orderBy('date', 'asc') ->orderBy('machine_id', 'asc') @@ -2338,37 +2743,32 @@ class StockController extends BaseController $data['groupedPowerConsumptionStockDetails'] = array_values($groupedByDate); + //temp_code_s_2025_02 + // getting electric machines for creating table headers // checking already existing stock if yes then get the electric machines id from the existing stock // if not get all the electric machines from the factory Machine master table - if (!empty($data['groupedPowerConsumptionStockDetails'])) { + // if (!empty($data['groupedPowerConsumptionStockDetails'])) { - $result = $groupedByDate[$date]; + // $result = $groupedByDate[$date]; - $distinctMachineId = []; + // $distinctMachineId = []; - foreach ($result as $index => $eachResult) { - $distinctMachineId[] = $result[$index]['machine_id']; - } + // foreach ($result as $index => $eachResult) { + // $distinctMachineId[] = $result[$index]['machine_id']; + // } - $electricMachines = $this->factoryMachine_model - ->whereIn('id', $distinctMachineId) - ->orderBy('id', 'asc') - ->get() - ->getResultArray(); + // $electricMachines = $this->factoryMachine_model->getSelectedElectricMachines($distinctMachineId); - } else { + // } else { - $electricMachines = $this->factoryMachine_model - ->where('is_active', 1) - ->where('energy_type', 'Electric') - ->orderBy('id', 'asc') - ->get() - ->getResultArray(); + // $electricMachines = $this->factoryMachine_model->getAllActiveElectricMachines(); - } + // } + + //temp_code_e_2025_02 @@ -2545,6 +2945,119 @@ class StockController extends BaseController $this->global['pageTitle'] = 'Diesel Machine Stock Details'; + //filter part starts + + //start date dynamic from front-end + $startDate = "$month-01"; + //end date of given month + $endDate = date("Y-m-t", strtotime($startDate)); + + + //filter applied currently + $customisedMachineCodes = $this->request->getPost('customisedMachineCodes') ?? []; + + + //already applied filter + $existingCustomMachineCodes = $this->monthWiseMachineInStockModel + ->select('machine_id') + ->where('date',"$month-01") + ->where('machine_category','diesel') + ->findAll(); + + + //check user applies for filter currently + if(!empty($customisedMachineCodes)){ + + //user applied filter, + + //check already filter existing , if exists remove that , + if(!empty($existingCustomMachineCodes)){ + + //hard delete done..!! + $existingCustomMachineCodes = $this->monthWiseMachineInStockModel + ->where('date',"$month-01") + ->where('machine_category','diesel') + ->delete(); + + } + + + //if no filter already exists or removed current one , just add current filter for that month ....!! + $inserts = []; + + foreach($customisedMachineCodes as $index => $customisedMachineCode){ + + $inserts [] = [ + 'date' => "$month-01", + '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); + } + + } + + if(!empty($inserts)){ + //insert all the latest applied filter + $this->monthWiseMachineInStockModel->insertBatch($inserts); + + //get the currently applied filter + $existingCustomMachineCodes = $this->monthWiseMachineInStockModel + ->select('machine_id') + ->where('date',"$month-01") + ->where('machine_category','diesel') + ->get() + ->getResultArray(); + + } + + } + + + //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(); + }else{ + //if filter present,get that material codes + $existingCustomMachineCodes = $this->factoryMachine_model + ->getSelectedDieselMachines(array_column($existingCustomMachineCodes, 'machine_id')); + } + + + + //this existingCustomMachineCodes gets its machine 'id' after visiting factory machine master table in above step, + + $machineCodeList = array_column($existingCustomMachineCodes, 'id'); + + $dieselMachines = $existingCustomMachineCodes; + + $data['activeDieselMachines'] = $this->factoryMachine_model->getAllActiveDieselMachines(); + + + + + + + + + + + // Get the previous month's last date diesel stock details for next month updation $previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m'); @@ -2579,6 +3092,7 @@ class StockController extends BaseController $data['dieselMachineStockDetails'] = $this->factoryVehicleDieselDetails_model ->where('date >=', $startDate) ->where('date <=', $endDate) + ->whereIn('machine_id',$machineCodeList) ->groupBy(['machine_id', 'date']) ->orderBy('date', 'asc') ->orderBy('machine_id', 'asc') @@ -2625,38 +3139,41 @@ class StockController extends BaseController + //temp_code_s_2025_02 + // getting diesel machines for creating table headers // checking already existing stock if yes then get the diesel machines id from the existing stock // if not get all the diesel machines from the factory Machine master table - if (!empty($data['groupedDieselMachineStockDetails'])) { + // if (!empty($data['groupedDieselMachineStockDetails'])) { - $result = $groupedByDate[$date]; + // $result = $groupedByDate[$date]; - $distinctMachineId = []; + // $distinctMachineId = []; - foreach ($result as $index => $eachResult) { - $distinctMachineId[] = $result[$index]['machine_id']; - } + // foreach ($result as $index => $eachResult) { + // $distinctMachineId[] = $result[$index]['machine_id']; + // } - $dieselMachines = $this->factoryMachine_model - ->whereIn('id', $distinctMachineId) - ->orderBy('id', 'asc') - ->get() - ->getResultArray(); + // $dieselMachines = $this->factoryMachine_model + // ->whereIn('id', $distinctMachineId) + // ->orderBy('id', 'asc') + // ->get() + // ->getResultArray(); - } else { + // } else { - $dieselMachines = $this->factoryMachine_model - ->where('is_active', 1) - ->where('energy_type', 'Diesel') - ->orderBy('id', 'asc') - ->get() - ->getResultArray(); + // $dieselMachines = $this->factoryMachine_model + // ->where('is_active', 1) + // ->where('energy_type', 'Diesel') + // ->orderBy('id', 'asc') + // ->get() + // ->getResultArray(); - } + // } + //temp_code_e_2025_02 diff --git a/app/Controllers/Supplier.php b/app/Controllers/Supplier.php index 3cc7562b..2aacb665 100755 --- a/app/Controllers/Supplier.php +++ b/app/Controllers/Supplier.php @@ -47,7 +47,22 @@ class Supplier extends BaseController */ public function index() { - $data['userRecords'] = $this->supplier_model->supplierlisting(); + + $isActiveFilter = 1 ; // default showing active transporters data + $showArchive = 0 ; // + + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown we are making active filter + if($showArchive){ + $isActiveFilter = 0; + } + } + + + $data['userRecords'] = $this->supplier_model->supplierlisting($isActiveFilter); + $data['showArchive'] = $showArchive ; $this->global['pageTitle'] = 'Supplier Listing'; $this->loadViews("supplierListing", $this->global, $data, NULL); } @@ -473,7 +488,20 @@ class Supplier extends BaseController */ public function transporterListing() { - $data['userRecords'] = $this->supplier_model->transporterListing(); + $isActiveFilter = 1 ; // default showing active transporters data + $showArchive = 0 ; // + + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown we are making active filter + if($showArchive){ + $isActiveFilter = 0; + } + } + + $data['userRecords'] = $this->supplier_model->transporterListing($isActiveFilter); + $data['showArchive'] = $showArchive ; $this->global['pageTitle'] = 'Transporter List'; $this->loadViews("transporterListing", $this->global, $data, NULL); } diff --git a/app/Controllers/User.php b/app/Controllers/User.php index 5cea8b2e..04999c49 100755 --- a/app/Controllers/User.php +++ b/app/Controllers/User.php @@ -891,14 +891,26 @@ class User extends BaseController */ function userListing() { - // if($this->isAdmin() == TRUE) - // { - // $this->loadThis(); - // } - // else - // { + + $isDeleted = 0 ; // default showing active data + $showArchive = 0 ; // + + if ($this->request->getMethod() === 'POST') { + + $showArchive = $this->request->getPost('showArchive'); + //reversing condition that when user wants deleted data to be shown then we are making active filter 0 + if($showArchive){ + $isDeleted = 1; + } + } + + $data['showArchive'] = $showArchive; + + // dd($data); + + + $data['userRecords'] = $this->user_model->userListing($isDeleted); - $data['userRecords'] = $this->user_model->userListing(); $this->global['pageTitle'] = 'User Listing'; // dd($data); diff --git a/app/Models/Assetdetails_model.php b/app/Models/Assetdetails_model.php index db2b81cf..e1340547 100755 --- a/app/Models/Assetdetails_model.php +++ b/app/Models/Assetdetails_model.php @@ -14,12 +14,13 @@ class Assetdetails_model extends Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function assetListing() + function assetListing($isActiveFilter) { $builder = $this->db->table('t_asset_details asd') ->select('asd.*,dep.DepartmentName,sup.SupplierName') ->join('t_departmentdetails dep', ' dep.DEPCode = asd.DEPCode', 'left') ->join('t_supplierdetailsn sup', 'sup.SupplierID = asd.SupplierCode', 'left') + ->where('asd.IsActive',$isActiveFilter) ->orderBy('asd.CreatedDt', 'desc'); $query = $builder->get(); diff --git a/app/Models/Costcenter_model.php b/app/Models/Costcenter_model.php index 01c6d783..bb7105ea 100755 --- a/app/Models/Costcenter_model.php +++ b/app/Models/Costcenter_model.php @@ -13,12 +13,13 @@ class Costcenter_model extends Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function CostListing() + function CostListing($isActiveFilter) { $builder = $this->db->table('t_costcenter_master as Cost') ->select('Cost.id as id, Cost.CostCenterCode as code,Cost.CostCenterName as CostCenterName , Cost.ApprovedBy as ApprovedBy,Emp.FirstName as FirstName,Emp.Designation as Designation ,Cost.CreatedDate,Cost.IsActive,Cost.DeletedBy,Cost.DeletedBy') ->join('t_employee_details as Emp', 'Emp.EmpID=Cost.ApprovedBy') + ->where('Cost.IsActive',$isActiveFilter) ->orderBy('Cost.CreatedDate', 'desc'); $query =$builder->get(); diff --git a/app/Models/Department_model.php b/app/Models/Department_model.php index 7e943aa2..9ab32dfe 100755 --- a/app/Models/Department_model.php +++ b/app/Models/Department_model.php @@ -49,11 +49,13 @@ class Department_model extends Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function departmentListing() + function departmentListing($isActiveFilter) { $builder = $this->db->table('t_departmentdetails as BaseT') ->select('BaseT.CreatedDt,BaseT.DepartmentName, BaseT.DEPCode, BaseT.HeadDept, BaseT.IsActive , - BaseT.HeadDept') + BaseT.HeadDept,HeadDept.DepartmentName as headDepartmentName') + ->join('t_departmentdetails as HeadDept', 'BaseT.HeadDept = HeadDept.DEPCode' ,'left') + ->where('BaseT.IsActive',$isActiveFilter) ->orderBy("BaseT.DEPCode", "desc"); $query = $builder->get(); $result = $query->getResult(); diff --git a/app/Models/FactoryMachineModel.php b/app/Models/FactoryMachineModel.php index 12fd7af4..83d6eaed 100644 --- a/app/Models/FactoryMachineModel.php +++ b/app/Models/FactoryMachineModel.php @@ -62,6 +62,57 @@ class FactoryMachineModel extends Model } + public function getAllActiveElectricMachines(){ + + $result = $this->db->table('t_factoryMachineMaster') + ->where('is_active', 1) + ->where('energy_type', 'electric') + ->orderBy('id', 'asc') + ->get() + ->getResultArray(); + + return $result ; + + } + + public function getSelectedElectricMachines($distinctMachineId){ + + $result = $this->db->table('t_factoryMachineMaster') + ->whereIn('id', $distinctMachineId) + ->orderBy('id', 'asc') + ->get() + ->getResultArray(); + + return $result; + + } + + public function getAllActiveDieselMachines(){ + + $result = $this->db->table('t_factoryMachineMaster') + ->where('is_active', 1) + ->where('energy_type', 'diesel') + ->orderBy('id', 'asc') + ->get() + ->getResultArray(); + + return $result ; + + } + + public function getSelectedDieselMachines($distinctMachineId){ + + $result = $this->db->table('t_factoryMachineMaster') + ->whereIn('id', $distinctMachineId) + ->orderBy('id', 'asc') + ->get() + ->getResultArray(); + + return $result; + + } + + } diff --git a/app/Models/GasShortageModel.php b/app/Models/GasShortageModel.php new file mode 100644 index 00000000..4b8f5be9 --- /dev/null +++ b/app/Models/GasShortageModel.php @@ -0,0 +1,49 @@ +db->table('t_igr_master igr') ->distinct() - ->select("igr.IGRNO,igr.*,igrd.*,MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity,POL.Rate,POM.POType,POM.IsOpenOrder, - POM.CapitalRange,POM.CapitalRange,st.CGST as service_cgst,st.SGST as service_sgst,st.IGST as service_igst,it.IGST as import_igst,rt.CGST as revenue_cgst,rt.SGST as revenue_sgst,rt.IGST as revenue_igst") + ->select(" + igr.IGRNO,igr.*,igrd.*, + MM.MaterialName,MM.UOM, + sup.Address,sup.SupplierName, + POL.Rate, + POM.ServiceDescription,POL.Quantity,POM.POType,POM.IsOpenOrder, + POM.CapitalRange,POM.CapitalRange, + st.CGST as service_cgst,st.SGST as service_sgst,st.IGST as service_igst, + it.IGST as import_igst, + rt.CGST as revenue_cgst,rt.SGST as revenue_sgst,rt.IGST as revenue_igst, + cd.ConfigValue As MaterialCategory") + ->join('t_igr_details igrd', 'igrd.IGRNO = igr.IGRNO') ->join('t_purchaseorder_master POM', 'igr.PONO = POM.PONO') ->join('t_purchaseorder_lineitem POL', 'igr.PONO = POL.PONO and POL.MaterialCode=igrd.MaterialCode ') @@ -562,6 +572,7 @@ class Inwardgateregister_model extends Model ->join('t_service_tax st', 'st.LineItemNo = POL.LineItemNo' , 'left') ->join('t_revenue_tax rt', 'rt.LineItemNo = POL.LineItemNo' , 'left') ->join('t_import_tax it', 'it.LineItemNo = POL.LineItemNo' , 'left') + ->join('t_configdetails cd','cd.key = MM.Category','left') ->where('igr.IGRNO', $IGRNO); $query = $builder->get(); @@ -1189,7 +1200,7 @@ class Inwardgateregister_model extends Model igrMast.MaterialRcvdDate as materialRecievedDate, igrMast.VehicleNo, supplierDetails.SupplierName, - materialMaster.Category as sandType , + cd.ConfigValue as sandType , t_igr_details.QuantityAsPerInvoice as Qty, issd.*') ->whereIn('t_igr_details.MaterialCode', $materialCodes) @@ -1205,6 +1216,7 @@ class Inwardgateregister_model extends Model ->join('t_igr_master igrMast', 'igrMast.IGRNO = t_igr_details.IGRNO') ->join('t_incomingSilicaSandDetails issd','issd.igrNo_fk = t_igr_details.IGRNO AND issd.materialCode = t_igr_details.MaterialCode','left') ->join('t_materialmaster materialMaster', 'materialMaster.MaterialCode = t_igr_details.MaterialCode') + ->join('t_configdetails cd','cd.key = materialMaster.Category','left') ->join('t_purchaseorder_master poMaster', 'poMaster.PONO = igrMast.PONO', 'left') ->join('t_supplierdetailsn supplierDetails', 'supplierDetails.SupplierID = poMaster.SupplierID', 'left') ->orderBy('t_igr_details.CreatedDate', 'asc '); @@ -1336,5 +1348,6 @@ $builder = $this->db->table('t_igr_history') return $result; } + } \ No newline at end of file diff --git a/app/Models/TrpAbstractParticulars.php b/app/Models/MonthWiseMachinesInStockModel.php similarity index 86% rename from app/Models/TrpAbstractParticulars.php rename to app/Models/MonthWiseMachinesInStockModel.php index 4cef5bd9..ff901a90 100644 --- a/app/Models/TrpAbstractParticulars.php +++ b/app/Models/MonthWiseMachinesInStockModel.php @@ -4,15 +4,15 @@ namespace App\Models; use CodeIgniter\Model; -class TrpAbstractParticulars extends Model +class MonthWiseMachinesInStockModel extends Model { - protected $table = 't_trp_abstract_particulars'; + protected $table = 't_monthwisemachinesinstock'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = ['particular']; + protected $allowedFields = ['date','machine_id','machine_category']; protected bool $allowEmptyInserts = false; protected bool $updateOnlyChanged = true; diff --git a/app/Models/TrpAbstract.php b/app/Models/MonthWiseMaterialInStockModel.php similarity index 85% rename from app/Models/TrpAbstract.php rename to app/Models/MonthWiseMaterialInStockModel.php index 3df62676..e4626b70 100644 --- a/app/Models/TrpAbstract.php +++ b/app/Models/MonthWiseMaterialInStockModel.php @@ -4,15 +4,15 @@ namespace App\Models; use CodeIgniter\Model; -class TrpAbstract extends Model +class MonthWiseMaterialInStockModel extends Model { - protected $table = 't_trp_abstract'; + protected $table = 't_monthwisematerialinstock'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = ['abs_opening_stock','abs_physical_stock','abs_remarks','abs_particular_id']; + protected $allowedFields = ['date','materialCode','stock_category']; protected bool $allowEmptyInserts = false; protected bool $updateOnlyChanged = true; diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index cbd3a5fa..5c589be8 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -14,7 +14,7 @@ class Rawmaterialdetails_model extends Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function rawmaterialListing() + function rawmaterialListing($isActiveFilter) { $builder = $this->db->table('t_materialmaster') @@ -22,6 +22,7 @@ class Rawmaterialdetails_model extends Model ->join('tbl_users as user', 'user.UserId = t_materialmaster.createdby', 'left') ->join('t_employee_details as emp', 'emp.EmpID = user.EmpID', 'left') ->join('t_configdetails as cd', 'cd.Key = t_materialmaster.Category', 'left') + ->where('t_materialmaster.IsActive',$isActiveFilter) ->orderBy('CreatedDate','desc'); $query = $builder->get(); $result = $query->getResult(); diff --git a/app/Models/Supplier_model.php b/app/Models/Supplier_model.php index 16cba09a..69613bb2 100755 --- a/app/Models/Supplier_model.php +++ b/app/Models/Supplier_model.php @@ -14,7 +14,7 @@ class Supplier_model extends Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function supplierlisting() + function supplierlisting($isActiveFilter) { $builder = $this->db->table('t_supplierdetailsn as BaseT') @@ -22,6 +22,7 @@ class Supplier_model extends Model ->join('t_paymentterms as pmt', 'pmt.PaymentID = BaseT.PaymentID', 'left') ->join('tbl_users as user', 'user.UserId = BaseT.createdby', 'left') ->join('t_employee_details as emp', 'emp.EmpID = user.EmpID', 'left') + ->where('BaseT.IsActive',$isActiveFilter) ->orderBy('BaseT.CreatedOn', 'desc'); $query = $builder->get(); @@ -224,17 +225,19 @@ class Supplier_model extends Model } /*SUPPLIER */ /** for transporter listing */ - function transporterListing() + function transporterListing($isActiveFilter) { + $builder = $this->db->table('t_transporter as t') ->select('t.id,t.name,t_employee_details.FirstName as FirstName,t.created_on,t.isactive') ->join('tbl_users', 'tbl_users.userId = t.created_by') ->join('t_employee_details', 't_employee_details.EmpID=tbl_users.EmpID') - ->orderBy('t.created_on', 'desc'); + ->where('t.isactive',$isActiveFilter); + $builder->orderBy('t.created_on', 'desc'); $query =$builder->get(); $result = $query->getResult(); - // echo $this->db->getLastQuery()->getQuery();die; + // echo $this->db->getLastQuery()->getQuery();die; return $result; } diff --git a/app/Models/TrpAbstractModel.php b/app/Models/TrpAbstractModel.php new file mode 100644 index 00000000..487749ac --- /dev/null +++ b/app/Models/TrpAbstractModel.php @@ -0,0 +1,73 @@ +db->table('t_trp_abstract') + ->where('date',$startDate) + ->where('date',$endDate) + ->get() + ->getResultArray(); + + return $currentMonthTrpAbstract; + + } + + + + + + + + + + + + +} + diff --git a/app/Models/TrpProductionModel.php b/app/Models/TrpProductionModel.php index 0b498b98..e6691ebd 100644 --- a/app/Models/TrpProductionModel.php +++ b/app/Models/TrpProductionModel.php @@ -66,6 +66,8 @@ class TrpProductionModel extends Model $materialCodes = array_column($subquery, 'materialCode'); // Extracts 'materialCode' values + + // dd($this->db->getLastQuery()); // Convert the array of material codes to a comma-separated string diff --git a/app/Models/User_model.php b/app/Models/User_model.php index 2abe7eb9..ebafde7c 100755 --- a/app/Models/User_model.php +++ b/app/Models/User_model.php @@ -15,14 +15,16 @@ class User_model extends Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function userListing() + function userListing($isDeleted) { $builder = $this->db->table('t_employee_details EMP') - ->select('user.isDeleted,user.createdDtm,EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,user.email as EmailId,EMP.ContactNumber, + ->select('user.isDeleted,user.createdDtm,EMP.EmpID,EMP.FirstName, + EMP.LastName,EMP.Designation,user.email as EmailId,EMP.ContactNumber, DEPT.DEPCode,DEPT.DepartmentName,role.role,user.userId') - ->join('t_departmentdetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode') - ->join('tbl_users user', 'user.EmpID = EMP.EmpID') - ->join('tbl_roles role', 'user.roleId = role.roleId') + ->join('t_departmentdetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode','left') + ->join('tbl_users user', 'user.EmpID = EMP.EmpID','left') + ->join('tbl_roles role', 'user.roleId = role.roleId','left') + ->where('user.isDeleted',$isDeleted) ->orderBy('user.createdDtm', 'desc'); $query = $builder->get(); diff --git a/app/Views/addasset.php b/app/Views/addasset.php index 4458c5e9..b9e18ed3 100755 --- a/app/Views/addasset.php +++ b/app/Views/addasset.php @@ -102,7 +102,7 @@