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; +?> +
@@ -168,7 +172,9 @@ isActive == 1 ? 'Active' : 'InActive'; ?> - @@ -225,6 +231,30 @@ } }); + // Ensure the saved page is a valid number + let savedPage =; // Default to 1 if not set + + savedPage = savedPage -1 ; + + // Check if the saved page is a number and not NaN + if (!isNaN(savedPage)) { + // Check if the DataTable is initialized + if ($.fn.DataTable.isDataTable('#config_list_table')) { + var dataTable = $('#config_list_table').DataTable(); + + // Get the total number of pages in DataTable + var totalPages = dataTable.page.info().pages; + + // Ensure the page number is within range + if (savedPage >= totalPages) { + savedPage = totalPages > 0 ? totalPages - 1 : 0; + } + + // Set DataTable to the saved page + dataTable.page(savedPage).draw(false); + } + } + // Date range filter function $.fn.dataTable.ext.search.push( function (settings, data, dataIndex) { @@ -287,6 +317,30 @@ } }); }); + + + + + \ No newline at end of file diff --git a/app/Views/editconfig.php b/app/Views/editconfig.php index 6757a319..aaeefbd9 100755 --- a/app/Views/editconfig.php +++ b/app/Views/editconfig.php @@ -35,7 +35,7 @@ if (!empty($master)) { @@ -68,7 +68,7 @@ if (!empty($master)) {
'form-horizontal', 'id' => 'editConfig'); - echo form_open(base_url() . 'configurationctrl/updateconfig', $attributes); ?> + echo form_open(base_url() . "configurationctrl/updateconfig?page=$page", $attributes); ?>
@@ -241,7 +241,9 @@ if (!empty($master)) { @@ -608,9 +610,17 @@ if (!empty($master)) { data-materialCode="${item.MaterialCode}" data-materialType="${item.MaterialType}" data-uom="${item.UOM}" - style="cursor: pointer; color: #02a8b5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" onmouseover="this.style.color='#016269';"> + style="cursor: pointer; color: #02a8b5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" onmouseover="this.style.color='#016269'; width:10%; + text-align:center;"> ${item.MaterialCode} + ${item.MaterialName} + ${item.MaterialType} + ${item.IsActive == 1 ?"Active":"InActive"} ${item.MaterialName} ${item.MaterialType} diff --git a/app/Views/gasCylinderReturned.php b/app/Views/gasCylinderReturned.php index d5c542c6..a4bca007 100644 --- a/app/Views/gasCylinderReturned.php +++ b/app/Views/gasCylinderReturned.php @@ -152,7 +152,7 @@
@@ -543,12 +543,12 @@ ${item.IGRNO} ${item.fullCylinderDate} ${item.cylinderNo} - ${item.grossWeight} + ${item.grossWeight} ${item.emptyCylinderDate} - ${item.tareWeight} - ${item.netWeight} - ${item.actualWeight} - ${item.shortage} + ${item.tareWeight} + ${item.netWeight} + ${item.actualWeight} + ${item.shortage} ${item.invoiceNo} ${item.DeliveryChellanDate} ${item.DriverName} @@ -570,10 +570,10 @@ - Weight - ${totalNetWeight} - ${totalActualWeight} - ${totalShortage} + Weight + ${totalNetWeight} + ${totalActualWeight} + ${totalShortage} diff --git a/app/Views/includes/new_header.php b/app/Views/includes/new_header.php index fe6b57ba..e67192ba 100755 --- a/app/Views/includes/new_header.php +++ b/app/Views/includes/new_header.php @@ -759,7 +759,7 @@
diff --git a/app/Views/rawmaterialListing.php b/app/Views/rawmaterialListing.php index 34fd5091..883e87cb 100755 --- a/app/Views/rawmaterialListing.php +++ b/app/Views/rawmaterialListing.php @@ -232,7 +232,7 @@ -

( 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) {
+
+
@@ -368,7 +381,7 @@ foreach ($period as $day) { + id="dieselMachineStockDetailsExport"> 0, 'running_hours' => 0, 'mileage' => 0, + 'machineId' => $machineId, ]; } @@ -782,21 +796,39 @@ foreach ($period as $day) { - - - - + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + Total + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1123,10 +1208,9 @@ foreach ($period as $day) { var updateDieselMachineDetails = tableToJson(); - alert('Updation may take a while, And we appreciate your patience..!!'); + showMessage('Updation may take a while, And we appreciate your patience..!!'); - $('#loader').show(); - $.ajax({ + $.ajax({ data: { updateDieselMachineDetails }, @@ -1135,16 +1219,13 @@ foreach ($period as $day) { success: function(data) { if (data) { - $('#loader').hide(); - console.log(data); - alert(data); - window.location.reload(); + showMessage(data); } }, error: function(xhr, status, error) { - alert("An error occurred while processing the request. Please try again."); + showMessage("An error occurred while processing the request. Please try again."); console.error("Error Code:", xhr.status); console.error("Error Message:", error); console.error("Response Text:", xhr.responseText); @@ -1223,6 +1304,15 @@ foreach ($period as $day) { function openingReadingChange(tdElement) { try { + + let basicCheck =checkIsNumber(tdElement.innerText.trim()); + + if(basicCheck == 0){ + + alert("Kindly Enter Numbers only..!!"); + return ; + } + let dataId = tdElement.getAttribute('data-id'); let [date, machine_id] = tdElement.getAttribute('data-id').split(' '); let openingReading = validateInput(tdElement.innerText); @@ -1235,7 +1325,16 @@ foreach ($period as $day) { document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = parseFloat(mileage).toFixed(2); - updateStockValue(date, machine_id, closingReading) + updateStockValue(date, machine_id, closingReading); + + + let table = document.getElementById('dieselStockDetailsTableId'); + let column1 = 'runningHours'; + let column2 = 'mileage'; + + calculateTotal(table,dataId,column1) + + calculateTotal(table,dataId,column2) } catch (error) { @@ -1248,6 +1347,15 @@ foreach ($period as $day) { function closingReadingChange(tdElement) { try { + + let basicCheck =checkIsNumber(tdElement.innerText.trim()); + + if(basicCheck == 0){ + + alert("Kindly Enter Numbers only..!!"); + return ; + } + let dataId = tdElement.getAttribute('data-id'); let [date, machine_id] = tdElement.getAttribute('data-id').split(' '); let closingReading = validateInput(tdElement.innerText); @@ -1259,8 +1367,16 @@ foreach ($period as $day) { document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = parseFloat(runningHours).toFixed(2); document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = parseFloat(mileage).toFixed(2); - updateStockValue(date, machine_id, closingReading) + updateStockValue(date, machine_id, closingReading); + let table = document.getElementById('dieselStockDetailsTableId'); + + let column1 = 'runningHours'; + let column2 = 'mileage'; + + calculateTotal(table,dataId,column1) + + calculateTotal(table,dataId,column2) } catch (error) { @@ -1273,6 +1389,15 @@ foreach ($period as $day) { function consumptionChange(tdElement) { try { + + let basicCheck =checkIsNumber(tdElement.innerText.trim()); + + if(basicCheck == 0){ + + alert("Kindly Enter Numbers only..!!"); + return ; + } + let dataId = tdElement.getAttribute('data-id'); let [date, machine_id] = tdElement.getAttribute('data-id').split(' '); let closingReading = validateInput(document.querySelector(`td.closingReading[data-id="${dataId}"]`).innerText); @@ -1284,7 +1409,16 @@ foreach ($period as $day) { document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = parseFloat(runningHours).toFixed(2); document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = parseFloat(mileage).toFixed(2); - updateStockValue(date, machine_id, closingReading) + updateStockValue(date, machine_id, closingReading); + + let table = document.getElementById('dieselStockDetailsTableId'); + + let column1 = 'consumption'; + let column2 = 'mileage'; + + calculateTotal(table,dataId,column1) + + calculateTotal(table,dataId,column2) } catch (error) { @@ -1298,6 +1432,15 @@ foreach ($period as $day) { try { + let basicCheck =checkIsNumber(tdElement.innerText.trim()); + + if(basicCheck == 0){ + + alert("Kindly Enter Numbers only..!!"); + return ; + } + + let dataId = tdElement.getAttribute('data-id'); let [date, machine_id] = tdElement.getAttribute('data-id').split(" "); @@ -1327,6 +1470,17 @@ foreach ($period as $day) { updateTotalStockValue(date, balanceTD); + let table = document.getElementById('dieselStockDetailsTableId'); + let column1 = 'fillingDiesel'; + let column2 = 'fillingTD'; + let column3 = 'purchaseTD'; + + calculateTotal(table,dataId,column1); + + calculateTotal(table,date,column2); + + calculateTotal(table,date,column3); + } catch (error) { @@ -1344,6 +1498,14 @@ foreach ($period as $day) { try { + let basicCheck =checkIsNumber(tdElement.innerText.trim()); + + if(basicCheck == 0){ + + alert("Kindly Enter Numbers only..!!"); + return ; + } + let dataId = tdElement.getAttribute('data-id'); let openingTD = validateInput(tdElement.innerText); @@ -1355,7 +1517,17 @@ foreach ($period as $day) { document.querySelector(`td.balanceTD[data-id="${dataId}"]`).innerText = parseFloat(balanceTD).toFixed(2); - updateTotalStockValue(dataId, balanceTD) + updateTotalStockValue(dataId, balanceTD); + + let table = document.getElementById('dieselStockDetailsTableId'); + + let column1 = 'fillingTD'; + + let column2 = 'purchaseTD'; + + calculateTotal(table,dataId,column1); + + calculateTotal(table,dataId,column2); } catch (error) { @@ -1369,6 +1541,16 @@ foreach ($period as $day) { function purchaseTDStockChange(tdElement) { try { + + + let basicCheck =checkIsNumber(tdElement.innerText.trim()); + + if(basicCheck == 0){ + + alert("Kindly Enter Numbers only..!!"); + return ; + } + let dataId = tdElement.getAttribute('data-id'); let purchaseTD = validateInput(tdElement.innerText); let openingTD = validateInput(document.querySelector(`td.openingTD[data-id="${dataId}"]`).innerText); @@ -1381,6 +1563,18 @@ foreach ($period as $day) { updateTotalStockValue(dataId, balanceTD); + + let table = document.getElementById('dieselStockDetailsTableId'); + + let column1 = 'fillingTD'; + + let column2 = 'purchaseTD'; + + calculateTotal(table,dataId,column1); + + calculateTotal(table,dataId,column2); + + } catch (error) { @@ -1405,12 +1599,23 @@ foreach ($period as $day) { // Validate against the regex const isValid = /^-?\d*\.?\d*$/.test(input); if (!isValid) { - alert('Invalid input! Please enter a valid number.'); + return 0; } return input; } + + function checkIsNumber(input) { + + const isValid = /^-?\d*\.?\d*$/.test(input); + + if (!isValid) { + return 0; + } + } + + + + + + + + + \ No newline at end of file diff --git a/app/Views/stock/drierMachineDetails.php b/app/Views/stock/drierMachineDetails.php index 6b626dbe..0edcb20d 100644 --- a/app/Views/stock/drierMachineDetails.php +++ b/app/Views/stock/drierMachineDetails.php @@ -535,7 +535,9 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
* - +
@@ -592,9 +594,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
- + * - +
@@ -699,7 +703,9 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
* - +
@@ -756,9 +762,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
- + * - +
@@ -807,7 +815,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); Gas Per Ton Qty Per Hrs (Metric Ton) Moisture Loss Qty (Metric Ton) - Dust Qty (Metric Ton) + Dust Qty (Kgs) Customer Name id @@ -895,12 +903,12 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); - + - + @@ -1122,9 +1130,9 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); hours = parseInt(hours, 10); // Adjust hours based on AM/PM - if (modifier === "pm" && hours < 12) { + if (modifier === "PM" && hours < 12) { hours += 12; - } else if (modifier === "am" && hours === 12) { + } else if (modifier === "AM" && hours === 12) { hours = 0; } @@ -1188,6 +1196,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); let totalGasConsumption = $('#additionalEntryTotalGasConsumptionId').val(); let sandDriedQty = $('#additionalEntrySandDriedQtyId').val(); + + let basicCheck = checkIsNumber(totalGasConsumption); + let basicCheck2 = checkIsNumber(sandDriedQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (basicCheck2 == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (totalGasConsumption != '' && sandDriedQty != '') { let gasPerTon = (parseFloat(totalGasConsumption) / parseFloat(sandDriedQty)).toFixed(2); @@ -1203,6 +1222,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); let inputSandQty = $('#additionalEntryInputSandQtyId').val(); let sandDriedQty = $('#additionalEntrySandDriedQtyId').val(); + let basicCheck = checkIsNumber(inputSandQty); + let basicCheck2 = checkIsNumber(sandDriedQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (basicCheck2 == 0) { + alert("Kindly Enter Numbers only..!!"); + + } + if (inputSandQty != '' && sandDriedQty != '') { let moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty); @@ -1219,6 +1249,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); let drierRunninhHrs = $('#additionalEntryRunningHrsId').val(); let sandDriedQty = $('#additionalEntrySandDriedQtyId').val(); + let basicCheck = checkIsNumber(drierRunninhHrs); + let basicCheck2 = checkIsNumber(sandDriedQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (basicCheck2 == 0) { + alert("Kindly Enter Numbers only..!!"); + + } + if (drierRunninhHrs != '' && sandDriedQty != '') { let qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs); @@ -1233,13 +1274,38 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); } + function additionalEntryInputSandMoisture(value) { + + let sandMoisture = $('#additionalEntryInputSandMoistureId').val(); + + let basicCheck = checkIsNumber(sandMoisture); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + +} + + function additionalEntryDustQty(value) { + + let dustQty = $('#additionalEntryDustQtyId').val(); + + let basicCheck = checkIsNumber(dustQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + + } + + // this for edit entry in ten ton f=drier function editEntryCalculateMachineRunningHrs() { - let dreierMachineOnTime = $('#editEntryDrierOnTimeId').val(); + let dreierMachineOnTime = $('#editEntryDrierOnTimeId').val(); let dreierMachineOffTime = $('#editEntryDrierOffTimeId').val(); if (dreierMachineOnTime == dreierMachineOffTime) { @@ -1291,6 +1357,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); let totalGasConsumption = $('#editEntryTotalGasConsumptionId').val(); let sandDriedQty = $('#editEntrySandDriedQtyId').val(); + + let basicCheck = checkIsNumber(totalGasConsumption); + let basicCheck2 = checkIsNumber(sandDriedQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (basicCheck2 == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (totalGasConsumption != '' && sandDriedQty != '') { let gasPerTon = (parseFloat(totalGasConsumption) / parseFloat(sandDriedQty)).toFixed(2); @@ -1306,6 +1383,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); let inputSandQty = $('#editEntryInputSandQtyId').val(); let sandDriedQty = $('#editEntrySandDriedQtyId').val(); + let basicCheck = checkIsNumber(inputSandQty); + let basicCheck2 = checkIsNumber(sandDriedQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + + if (basicCheck2 == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (inputSandQty != '' && sandDriedQty != '') { let moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty); @@ -1322,6 +1410,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); let drierRunninhHrs = $('#editEntryRunningHrsId').val(); let sandDriedQty = $('#editEntrySandDriedQtyId').val(); + let basicCheck = checkIsNumber(drierRunninhHrs); + let basicCheck2 = checkIsNumber(sandDriedQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + + if (basicCheck2 == 0) { + alert("Kindly Enter Numbers only..!!"); + } + if (drierRunninhHrs != '' && sandDriedQty != '') { let qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs); @@ -1332,6 +1431,41 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); } } + + function editEntryInputSandMoisture(value) { + + let sandMoisture = $('#editEntryInputSandMoistureId').val(); + + let basicCheck = checkIsNumber(sandMoisture); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + + } + + function editEntryDustQty(value) { + + let dustQty = $('#editEntryDustQtyId').val(); + + let basicCheck = checkIsNumber(dustQty); + + if (basicCheck == 0) { + alert("Kindly Enter Numbers only..!!"); + } + + } + + function checkIsNumber(input) { + + const isValid = /^-?\d*\.?\d*$/.test(input); + + if (!isValid) { + return 0; + } + } + + @@ -1395,17 +1529,14 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); let rows = []; // Extract table data row-by-row - $(table).find('tr').each(function(rowIndex) { + $(table).find('tr').each(function() { let rowData = []; - $(this).find('th, td').each(function(colIndex) { + $(this).find('th, td').each(function() { // Skip hidden columns if ($(this).css('display') === 'none') return; let cellText = $(this).text().trim(); - - - rowData.push(cellText); }); @@ -1417,25 +1548,37 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); // Create a worksheet from array (no DOM needed!) let ws = XLSX.utils.aoa_to_sheet(rows); + + // Calculate max column count from the collected rows + let colCount = 0; + rows.forEach(row => { + if (row.length > colCount) colCount = row.length; + }); + + // Set custom column widths (10 for each column) + const wscols = []; + for (let i = 0; i < colCount; i++) { + wscols.push({ wch: 10 }); + } + ws['!cols'] = wscols; + + // Create workbook and export let wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); XLSX.writeFile(wb, filename || 'export.xlsx'); } - let tableId = 'drierTable'; document.getElementById('drierMachineDetailsExport').addEventListener('click', function() { - exportTableToExcel(tableId, 'drierMachineDetails_.xlsx'); + }); - }) - - - }) + }); + diff --git a/app/Views/stock/dustAndRoughStockDetails.php b/app/Views/stock/dustAndRoughStockDetails.php index 97456c67..348f287b 100644 --- a/app/Views/stock/dustAndRoughStockDetails.php +++ b/app/Views/stock/dustAndRoughStockDetails.php @@ -332,73 +332,86 @@
- - - - -
- - -
-
- -
- - " - class="form-control " - data-provide="datepicker" - data-date-format="M-yyyy" - data-date-min-view-mode="1" readonly - style="max-width: 175px;"> - -
- - - -
- - - - - - - - - - - - - - - - - - - - -
- -
-
- +
- + +
+
+
+ + + +
+ + " + class="form-control " + data-provide="datepicker" + data-date-format="M-yyyy" + data-date-min-view-mode="1" readonly + style="max-width: 175px;"> + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+
+ +