changes in stock module 12-03-2025
This commit is contained in:
parent
dd835f830f
commit
caa0314ef7
@ -1244,9 +1244,17 @@ class StockController extends BaseController
|
|||||||
->where('machine_category','diesel')
|
->where('machine_category','diesel')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
$filterUpdateNeeded = true ;
|
||||||
|
|
||||||
|
if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){
|
||||||
|
$customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ;
|
||||||
|
$filterUpdateNeeded = false ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//check user applies for filter currently
|
//check user applies for filter currently
|
||||||
if(!empty($customisedMachineCodes)){
|
if(!empty($customisedMachineCodes) && $filterUpdateNeeded){
|
||||||
|
|
||||||
//user applied filter,
|
//user applied filter,
|
||||||
|
|
||||||
@ -1407,11 +1415,62 @@ class StockController extends BaseController
|
|||||||
$groupedByDate[$date][] = $detail;
|
$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
|
// Reset the structure to have indexed arrays without the date keys
|
||||||
$data['groupedDieselMachineStockDetails'] = array_values($groupedByDate);
|
$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);
|
$dieselMachinesCount = count($dieselMachines);
|
||||||
|
|
||||||
@ -1602,9 +1661,17 @@ class StockController extends BaseController
|
|||||||
->where('machine_category','electric')
|
->where('machine_category','electric')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
$filterUpdateNeeded = true ;
|
||||||
|
|
||||||
|
if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){
|
||||||
|
$customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ;
|
||||||
|
$filterUpdateNeeded = false ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//check user applies for filter currently
|
//check user applies for filter currently
|
||||||
if(!empty($customisedMachineCodes)){
|
if(!empty($customisedMachineCodes) && $filterUpdateNeeded){
|
||||||
|
|
||||||
//user applied filter,
|
//user applied filter,
|
||||||
|
|
||||||
@ -1769,10 +1836,63 @@ class StockController extends BaseController
|
|||||||
$groupedByDate[$date][] = $detail;
|
$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
|
// Reset the structure to have indexed arrays without the date keys
|
||||||
$data['groupedPowerConsumptionStockDetails'] = array_values($groupedByDate);
|
$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);
|
$electricMachinesCount = count($electricMachines);
|
||||||
|
|
||||||
$data['electricMachinesCount'] = $electricMachinesCount;
|
$data['electricMachinesCount'] = $electricMachinesCount;
|
||||||
@ -2076,7 +2196,7 @@ class StockController extends BaseController
|
|||||||
//check user applies for filter currently
|
//check user applies for filter currently
|
||||||
if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){
|
if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){
|
||||||
|
|
||||||
//user applied filter,
|
//user applied new filter,
|
||||||
|
|
||||||
//check already filter existing , if exists remove that ,
|
//check already filter existing , if exists remove that ,
|
||||||
if(!empty($existingCustomMaterialCodes)){
|
if(!empty($existingCustomMaterialCodes)){
|
||||||
@ -2137,7 +2257,7 @@ class StockController extends BaseController
|
|||||||
//no filter applied at all just present all active material codes
|
//no filter applied at all just present all active material codes
|
||||||
$existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode();
|
$existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode();
|
||||||
}else{
|
}else{
|
||||||
//if filter present,get that material codes
|
//if filter present , Reuse the filter and get that material codes
|
||||||
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
|
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
|
||||||
->getSelectedResinMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode'));
|
->getSelectedResinMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode'));
|
||||||
}
|
}
|
||||||
@ -2441,9 +2561,17 @@ class StockController extends BaseController
|
|||||||
->where('stock_category','packing_material')
|
->where('stock_category','packing_material')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
$filterUpdateNeeded = true ;
|
||||||
|
|
||||||
|
if( empty($customisedMaterialCodes) && !empty($existingCustomMaterialCodes)){
|
||||||
|
$customisedMaterialCodes = array_column($existingCustomMaterialCodes, 'materialCode') ;
|
||||||
|
$filterUpdateNeeded = false ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//check user applies for filter currently
|
//check user applies for filter currently
|
||||||
if(!empty($customisedMaterialCodes)){
|
if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){
|
||||||
|
|
||||||
//user applied filter,
|
//user applied filter,
|
||||||
|
|
||||||
@ -2582,6 +2710,34 @@ class StockController extends BaseController
|
|||||||
$groupedByDate[$date][] = $detail;
|
$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
|
// Reset the structure to have indexed arrays without the date keys
|
||||||
$data['groupedBagStockDetails'] = array_values($groupedByDate);
|
$data['groupedBagStockDetails'] = array_values($groupedByDate);
|
||||||
|
|
||||||
@ -2600,6 +2756,31 @@ class StockController extends BaseController
|
|||||||
->first()['customer'] ?? '';
|
->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);
|
$bagMaterialcount = count($bagMaterials);
|
||||||
|
|
||||||
$data['bagMaterialcount'] = $bagMaterialcount;
|
$data['bagMaterialcount'] = $bagMaterialcount;
|
||||||
@ -2853,7 +3034,7 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
$trpAbstract = $this->trpAbstract_model->where('date', $startDate)->findAll();
|
$trpAbstract = $this->trpAbstract_model->where('date', $startDate)->findAll();
|
||||||
|
|
||||||
// dd( $trpAbstract );
|
|
||||||
|
|
||||||
$groupedTrpAbstract = [] ;
|
$groupedTrpAbstract = [] ;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user