diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index cbb9f924..cb7d78d9 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -346,7 +346,8 @@ class StockController extends BaseController 'clayOrLossOfIgnition' => $postData['clayOrLossOfIgnition'], 'reportComments' => $postData['reportComments'], 'gradeRange' => $postData['gradeRange'], - 'reportTime' => $postData['reportTime'] + 'reportTime' => $postData['reportTime'], + 'remark' => $postData['remark'] ]; @@ -1244,9 +1245,17 @@ class StockController extends BaseController ->where('machine_category','diesel') ->findAll(); + $filterUpdateNeeded = true ; + if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){ + $customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ; + $filterUpdateNeeded = false ; + + } + + //check user applies for filter currently - if(!empty($customisedMachineCodes)){ + if(!empty($customisedMachineCodes) && $filterUpdateNeeded){ //user applied filter, @@ -1407,11 +1416,62 @@ class StockController extends BaseController $groupedByDate[$date][] = $detail; } + // Sort each date's machines based on the custom order to set table body td + if (!empty($customisedMachineCodes)) { + + foreach ($groupedByDate as $date => &$machines) { + + usort($machines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['machine_id'], $customisedMachineCodes); + $indexB = array_search($b['machine_id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + } + unset($machines); + } + // Reset the structure to have indexed arrays without the date keys $data['groupedDieselMachineStockDetails'] = array_values($groupedByDate); + // Sort each date's machines based on the custom order to set table header th + + if (!empty($customisedMachineCodes)) { + + + + usort($dieselMachines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['id'], $customisedMachineCodes); + $indexB = array_search($b['id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + + } $dieselMachinesCount = count($dieselMachines); @@ -1602,9 +1662,17 @@ class StockController extends BaseController ->where('machine_category','electric') ->findAll(); + $filterUpdateNeeded = true ; + if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){ + $customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ; + $filterUpdateNeeded = false ; + + } + + //check user applies for filter currently - if(!empty($customisedMachineCodes)){ + if(!empty($customisedMachineCodes) && $filterUpdateNeeded){ //user applied filter, @@ -1769,10 +1837,63 @@ class StockController extends BaseController $groupedByDate[$date][] = $detail; } + + // Sort each date's machines based on the custom order to set table body td + if (!empty($customisedMachineCodes)) { + + foreach ($groupedByDate as $date => &$machines) { + + usort($machines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['machine_id'], $customisedMachineCodes); + $indexB = array_search($b['machine_id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + } + unset($machines); + } + // Reset the structure to have indexed arrays without the date keys $data['groupedPowerConsumptionStockDetails'] = array_values($groupedByDate); + // Sort each date's machines based on the custom order to set table header th + + if (!empty($customisedMachineCodes)) { + + + + usort($electricMachines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['id'], $customisedMachineCodes); + $indexB = array_search($b['id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + + } + $electricMachinesCount = count($electricMachines); $data['electricMachinesCount'] = $electricMachinesCount; @@ -2076,7 +2197,7 @@ class StockController extends BaseController //check user applies for filter currently if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){ - //user applied filter, + //user applied new filter, //check already filter existing , if exists remove that , if(!empty($existingCustomMaterialCodes)){ @@ -2137,7 +2258,7 @@ class StockController extends BaseController //no filter applied at all just present all active material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode(); }else{ - //if filter present,get that material codes + //if filter present , Reuse the filter and get that material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model ->getSelectedResinMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode')); } @@ -2441,9 +2562,17 @@ class StockController extends BaseController ->where('stock_category','packing_material') ->findAll(); + $filterUpdateNeeded = true ; + + if( empty($customisedMaterialCodes) && !empty($existingCustomMaterialCodes)){ + $customisedMaterialCodes = array_column($existingCustomMaterialCodes, 'materialCode') ; + $filterUpdateNeeded = false ; + } + + //check user applies for filter currently - if(!empty($customisedMaterialCodes)){ + if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){ //user applied filter, @@ -2582,6 +2711,34 @@ class StockController extends BaseController $groupedByDate[$date][] = $detail; } + // Sort each date's materials based on the custom order to set table body td + if (!empty($customisedMaterialCodes)) { + + foreach ($groupedByDate as $date => &$materials) { + + usort($materials, function ($a, $b) use ($customisedMaterialCodes) { + + $indexA = array_search($a['materialCode'], $customisedMaterialCodes); + $indexB = array_search($b['materialCode'], $customisedMaterialCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + } + unset($materials); + } + + + // Reset the structure to have indexed arrays without the date keys $data['groupedBagStockDetails'] = array_values($groupedByDate); @@ -2600,6 +2757,31 @@ class StockController extends BaseController ->first()['customer'] ?? ''; } + + // Sort each date's materials based on the custom order to set table header th + if (!empty($customisedMaterialCodes)) { + + usort($bagMaterials, function ($a, $b) use ($customisedMaterialCodes) { + + $indexA = array_search($a['MaterialCode'], $customisedMaterialCodes); + $indexB = array_search($b['MaterialCode'], $customisedMaterialCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + + } + + $bagMaterialcount = count($bagMaterials); $data['bagMaterialcount'] = $bagMaterialcount; @@ -2853,7 +3035,7 @@ class StockController extends BaseController $trpAbstract = $this->trpAbstract_model->where('date', $startDate)->findAll(); - // dd( $trpAbstract ); + $groupedTrpAbstract = [] ; diff --git a/app/Views/stock/drierMachineDetails.php b/app/Views/stock/drierMachineDetails.php index 4244ad46..713e5e30 100644 --- a/app/Views/stock/drierMachineDetails.php +++ b/app/Views/stock/drierMachineDetails.php @@ -1186,7 +1186,7 @@ $('#drierTable tbody').on('click', '.edit-btn', function() { console.log('working here', 'totalHours', totalHours); if (totalHours != NaN && totalHours != Infinity) { - $('#additionalEntryRunningHrsId').val(totalHours); + $('#editEntryRunningHrsId').val(totalHours); editEntryGasPerTon(); editEntryMoistureLossQty(); editEntryQtyPerHrs(); diff --git a/app/Views/stock/dustAndRoughStockDetails.php b/app/Views/stock/dustAndRoughStockDetails.php index 405c77ff..7c490cae 100644 --- a/app/Views/stock/dustAndRoughStockDetails.php +++ b/app/Views/stock/dustAndRoughStockDetails.php @@ -598,6 +598,7 @@ return 0; } + //one of the type in empty space character list is 10 if (typeof input === 'string' && input.split('').map(char => char.charCodeAt(0))[0] == 10) { return 0; } diff --git a/app/Views/stock/incomingSilicaSandDetails.php b/app/Views/stock/incomingSilicaSandDetails.php index ecedf7c4..44b40b71 100644 --- a/app/Views/stock/incomingSilicaSandDetails.php +++ b/app/Views/stock/incomingSilicaSandDetails.php @@ -366,7 +366,7 @@