diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index a864263f..3dc91d30 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -130,19 +130,33 @@ class StockController extends BaseController { if ($this->request->getMethod() === 'POST') { + $month = $this->request->getPost('month'); $date = DateTime::createFromFormat('M-Y', $month); $formattedDate = $date->format('Y-m'); - $month = $formattedDate; + $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + } else { - $filteredMonth = $this->request->getGet('month'); - $month = $filteredMonth ?? date('Y-m'); + $session = session(); + + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } + } + $data['month'] = $month ; + $this->global['pageTitle'] = 'Coating Machine Details '; @@ -171,7 +185,7 @@ class StockController extends BaseController $data['month'] = $formattedDate; - return $this->loadViews("CoatingMachineDetail", $this->global, $data, NULL); + return $this->loadViews("stock/CoatingMachineDetail", $this->global, $data, NULL); } public function addNewCoatingMachineDetails() @@ -181,8 +195,6 @@ class StockController extends BaseController $message3 = ''; $postData = $this->request->getPost(); - $month = $this->request->getGet('month'); - $month = DateTime::createFromFormat('M-Y', $month)->format('Y-m'); $date = $postData['date']; $shift = $postData['shift']; @@ -265,7 +277,7 @@ class StockController extends BaseController // Set flashdata for success message - return redirect()->to("/coatingMachineDetails?month=$month") + return redirect()->to("/coatingMachineDetails") ->with('success', $message1 . " " . $message2 . " " . $message3); } catch (\Exception $error) { $this->db->transRollback(); @@ -284,8 +296,7 @@ class StockController extends BaseController $message3 = ''; $putData = $this->request->getPost(); - $month = $this->request->getGet('month'); - $month = DateTime::createFromFormat('M-Y', $month)->format('Y-m'); + $id = $putData['editCoatingMachineDetailId']; @@ -361,7 +372,7 @@ class StockController extends BaseController // Set flashdata for success message - return redirect()->to("/coatingMachineDetails?month=$month") + return redirect()->to("/coatingMachineDetails") ->with('success', $message1 . " " . $message2 . " " . $message3); } else { throw new \Exception('Failed to update Coating machine details.'); @@ -443,10 +454,23 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + + } else { $remark = $this->request->getVar('remark'); - $month = date('Y-m'); + $session = session(); + + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } + } $data['month'] = $month; @@ -489,7 +513,7 @@ class StockController extends BaseController $data['remark'] = $remark; - return $this->loadViews("incomingSilicaSandDetails", $this->global, $data, NULL); + return $this->loadViews("stock/incomingSilicaSandDetails", $this->global, $data, NULL); } public function updateIncomingSilicaSandDetails() @@ -624,6 +648,47 @@ class StockController extends BaseController // Bag Stock details starts + + + //custom filterMaterialCode given by user + + //two types of custom filter + + //1) fliter for no data present in db - active and is active is not a concern ..!!(for current month) + // + adding new material in packing material category is not a concern ..!! + // - deleting existing material in packing material category is not a concern ..!! + + //fetch all active material in bag stock then , + // i) if no custom filter option given , all active material code going to be present in filterMaterialCode . + // ii)if custom filter option given , what are all the materials active is going to be filtered among given filterMaterialCode.. + + + //----------------1st part finished----// + + + //2) filter for data present in db -- active and is active is a concern ..!! + // + adding new material category in packing material is a concern ..!! + // - deleting existing material category in packing material is a concern ..!! + + //for second case if already material present in db but deleted in material master means + // i) we need to show the deleted one too for that month . + // ii)check If they add another material in packing material for current month, + // we need to put dummy entry(empty string) and show that as well. + + //wild scenario if user wants to add an new material and its entry in previous month + //i) Hard code database entry after consultation can be entertained..!! + + //-------------- 2nd part finished -----// + + + // Action + + + + + + + public function loadView_bagStockDetails() { @@ -634,15 +699,23 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); - $month = $formattedDate; + $month = $formattedDate; - //filterMaterialCode + $session = session (); + + $session->set('stock_month',$month); - $filterMaterialCode = $this->request->getPost('filterMaterialCode'); } else { - $month = date('Y-m'); - $filterMaterialCode = ['601529']; + + $session = session(); + + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } + } $data = []; @@ -672,7 +745,13 @@ class StockController extends BaseController $startDate = "$month-01"; $endDate = date("Y-m-t", strtotime($startDate)); - $data['bagStockDetails'] = $this->bagStockDetails_model->getBagStockForGivenMonth($startDate , $endDate ,$filterMaterialCode); + $data['bagStockDetails'] = $this->bagStockDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->groupBy(['materialCode', 'date']) + ->orderBy('date', 'asc') + ->orderBy('materialCode', 'asc') + ->findAll(); // Initialize an empty array to hold the grouped data $data['groupedBagStockDetails'] = []; @@ -717,15 +796,20 @@ class StockController extends BaseController // if not get all the material codes from the raw material details table if (!empty($data['groupedBagStockDetails'])) { + $result = $groupedByDate[$date]; - $bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($filterMaterialCode); + $distinctMaterialCodes = []; + + foreach ($result as $index => $eachResult) { + $distinctMaterialCodes[] = $result[$index]['materialCode']; + } + + $bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($distinctMaterialCodes); + } else { - $bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode($filterMaterialCode); + $bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode(); } - - - // getting customer for creating table headers // checking already existing stock if yes then get customer from the existing stock @@ -752,7 +836,7 @@ class StockController extends BaseController $data['month'] = $formattedDate; - return $this->loadViews("bagStockDetails", $this->global, $data, NULL); + return $this->loadViews("stock/bagStockDetails", $this->global, $data, NULL); } public function updateBagStockDetails() @@ -826,8 +910,19 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + } else { - $month = date('Y-m'); + $session = session(); + + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } } $data = []; @@ -850,7 +945,7 @@ class StockController extends BaseController $data['month'] = $formattedDate; - return $this->loadViews("dustAndRoughStockDetails", $this->global, $data, NULL); + return $this->loadViews("stock/dustAndRoughStockDetails", $this->global, $data, NULL); } public function updateDustAndRoughStockDetails() @@ -922,8 +1017,19 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + } else { - $month = date('Y-m'); + $session = session(); + + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } } $data = []; @@ -1043,7 +1149,7 @@ class StockController extends BaseController $data['month'] = $formattedDate; - return $this->loadViews("resinStockDetails", $this->global, $data, NULL); + return $this->loadViews("stock/resinStockDetails", $this->global, $data, NULL); } public function updateResinStockDetails() @@ -1122,8 +1228,19 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + } else { - $month = date('Y-m'); + $session = session(); + + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } } $data = []; @@ -1189,7 +1306,7 @@ class StockController extends BaseController $data['month'] = DateTime::createFromFormat('Y-m', $month)->format('M-Y'); - return $this->loadViews("gasStockDetails", $this->global, $data, NULL); + return $this->loadViews("stock/gasStockDetails", $this->global, $data, NULL); } public function updateGasStockDetails() @@ -1393,7 +1510,13 @@ class StockController extends BaseController $month = $formattedDate; } else { - $month = date('Y-m'); + $session = session(); + + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } } $data = []; @@ -1416,7 +1539,7 @@ class StockController extends BaseController $data['month'] = $formattedDate; - return $this->loadViews("trpSandUseStockDetails", $this->global, $data, NULL); + return $this->loadViews("stock/trpSandUseStockDetails", $this->global, $data, NULL); } @@ -1490,12 +1613,21 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + + } else { - // $month = new DateTime('2024-10-01'); - // $month = $month->format('Y-m'); + $session = session(); - $month = date('Y-m'); + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } } @@ -1545,7 +1677,7 @@ class StockController extends BaseController // return $this->response->setJSON($data); - return $this->loadViews("trpProductionStockDetails", $this->global, $data, NULL); + return $this->loadViews("stock/trpProductionStockDetails", $this->global, $data, NULL); @@ -1856,7 +1988,7 @@ class StockController extends BaseController $data['datefordropdown'] = $currentMonth; $this->global['pageTitle'] = 'Drier Details'; - $this->loadViews("drierMachineDetails", $this->global, $data, NULL); + $this->loadViews("stock/drierMachineDetails", $this->global, $data, NULL); } @@ -2008,11 +2140,21 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + + } else { - // $month = '2024-12'; + $session = session(); - $month = date('Y-m'); + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } } $data = []; @@ -2146,7 +2288,7 @@ class StockController extends BaseController // return $this->response->setJSON(['status' =>'success' ,'message' => $data['electricMachines']]); - return $this->loadViews("powerConsumptionDetails", $this->global, $data, NULL); + return $this->loadViews("stock/powerConsumptionDetails", $this->global, $data, NULL); } @@ -2283,11 +2425,20 @@ class StockController extends BaseController $formattedDate = $date->format('Y-m'); $month = $formattedDate; + + $session = session (); + + $session->set('stock_month',$month); + } else { - // $month = '2025-02'; + $session = session(); - $month = date('Y-m'); + $month = $session->get('stock_month'); + + if (empty($month)) { + $month = date('Y-m'); // Default to the current month + } } $data = []; @@ -2427,7 +2578,7 @@ class StockController extends BaseController // return $this->response->setJSON(['status' =>'success' ,'message' => $data['dieselMachines']]); - return $this->loadViews("dieselStockDetails", $this->global, $data, NULL); + return $this->loadViews("stock/dieselStockDetails", $this->global, $data, NULL); diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index b118ac55..105489f7 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -164,35 +164,27 @@ class Rawmaterialdetails_model extends Model return array_column($materialResults, 'MaterialCode'); } - function getAllBagMaterialCode($filterMaterialCode) + function getAllBagMaterialCode() { + //when no data present for current month we are showing only active materials with filter option $builder = $this->db->table('t_materialmaster') ->select('MaterialCode, MaterialName') ->where('Category', 'Packing Material') - ->where('IsActive', 1); - - - if (!empty($filterMaterialCode)) { - $builder->whereIn('MaterialCode', $filterMaterialCode); - } - - $builder->orderBy('MaterialCode', 'asc'); + ->where('IsActive', 1) + ->orderBy('MaterialCode', 'asc'); $query = $builder->get(); return $query->getResultArray(); } - function getSelectedBagMaterialCode($filterMaterialCode) + function getSelectedBagMaterialCode($distinctMaterialCodes) { + //when data present with whether material is active or not we have to show them with filter option $builder = $this->db->table('t_materialmaster') ->select('MaterialCode, MaterialName') - ->where('Category', 'Packing Material'); - - if (!empty($filterMaterialCode)) { - $builder->whereIn('MaterialCode', $filterMaterialCode); - } - - $builder->orderBy('MaterialCode', 'asc'); + ->where('Category', 'Packing Material') + ->whereIn('MaterialCode', $distinctMaterialCodes) + ->orderBy('MaterialCode', 'asc'); $query = $builder->get(); return $query->getResultArray(); } diff --git a/app/Views/driverListing.php b/app/Views/driverListing.php index 2fc60246..f6cb32c8 100755 --- a/app/Views/driverListing.php +++ b/app/Views/driverListing.php @@ -63,8 +63,8 @@ - - + + diff --git a/app/Views/CoatingMachineDetail.php b/app/Views/stock/CoatingMachineDetail.php similarity index 99% rename from app/Views/CoatingMachineDetail.php rename to app/Views/stock/CoatingMachineDetail.php index 6e356d93..f9e667b6 100644 --- a/app/Views/CoatingMachineDetail.php +++ b/app/Views/stock/CoatingMachineDetail.php @@ -16,6 +16,17 @@ } + input[type="date"]::-webkit-calendar-picker-indicator { + transform: scale(2.0); + cursor: pointer; + } + + input[type="date"] { + cursor: pointer; + } + + + .fht-table, .fht-table thead, @@ -32,7 +43,7 @@ } .fht-table td:hover { - background-color: #00a65a; + background-color: #50bbd9; color: #ffffff; } @@ -215,7 +226,7 @@ .table-responsive { overflow-y: auto; - max-height: 450px; + max-height: 500px; } .fht-table thead th { @@ -1493,6 +1504,10 @@ let machineOnTime12 = machineOnTimeHr; let machineOffTime12 = machineOffTimeHr; + if(machineOnTime12 == machineOffTime12){ + return `24.00`; + } + let machineOnTime24 = convertTo24Hr(machineOnTime12); let machineOffTime24 = convertTo24Hr(machineOffTime12); diff --git a/app/Views/bagStockDetails.php b/app/Views/stock/bagStockDetails.php similarity index 97% rename from app/Views/bagStockDetails.php rename to app/Views/stock/bagStockDetails.php index 697be538..37ded70e 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/stock/bagStockDetails.php @@ -18,7 +18,7 @@ } .fht-table td:hover { - background-color: #00a65a; + background-color: #50bbd9; color: #ffffff; } @@ -140,7 +140,7 @@ .celda_encabezado_general { - background-color: #00a65a; + background-color: #50bbd9; border: 1px solid #ccc; color: #ffffff; font-weight: bold; @@ -171,7 +171,7 @@ position: sticky; top: 0; z-index: 20; /* Ensure the entire header stays above table rows */ - background-color: #00a65a; /* Header background color */ + background-color: #50bbd9; /* Header background color */ } .dropdown-menu { @@ -185,7 +185,7 @@ position: sticky; top: 0; z-index: 11; /* Higher than table rows but lower than first column */ - background-color: #00a65a; /* Green background */ + background-color: #50bbd9; /* Green background */ color: #ffffff; border: 1px solid #ddd; padding: 10px; @@ -196,7 +196,7 @@ .fht-table td:nth-child(1) { position: sticky; left: 0; - background-color: #00a65a; + background-color: #50bbd9; z-index: 15; /* Ensures it stays above other cells */ border-right: 2px solid #ddd; color: #ffffff; @@ -206,7 +206,7 @@ .table-responsive { overflow-x: auto; overflow-y: auto; - max-height: 450px; /* Adjust as needed */ + max-height: 500px; /* Adjust as needed */ position: relative; } @@ -507,7 +507,9 @@ - + $dateInMonth){ ?>