Update WarehouseArticleController.php
This commit is contained in:
@@ -76,7 +76,25 @@ class WarehouseArticleController extends TTCrud {
|
|||||||
$prices[] = ['title' => $pt->title, 'price' => round($p, 2)]; // Add title and rounded price
|
$prices[] = ['title' => $pt->title, 'price' => round($p, 2)]; // Add title and rounded price
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($prices, fn($x,$y)=>(match($x['title']){'Verkauf'=>1,'Partner'=>2,'Energie Steiermark'=>3,default=>4})<=>(match($y['title']){'Verkauf'=>1,'Partner'=>2,'Energie Steiermark'=>3,default=>4}));
|
usort($prices, function($x, $y) {
|
||||||
|
$priorityX = 4;
|
||||||
|
$titleX = isset($x['title']) ? $x['title'] : null;
|
||||||
|
switch ($titleX) {
|
||||||
|
case 'Verkauf': $priorityX = 1; break;
|
||||||
|
case 'Partner': $priorityX = 2; break;
|
||||||
|
case 'Energie Steiermark': $priorityX = 3; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$priorityY = 4;
|
||||||
|
$titleY = isset($y['title']) ? $y['title'] : null;
|
||||||
|
switch ($titleY) {
|
||||||
|
case 'Verkauf': $priorityY = 1; break;
|
||||||
|
case 'Partner': $priorityY = 2; break;
|
||||||
|
case 'Energie Steiermark': $priorityY = 3; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $priorityX <=> $priorityY;
|
||||||
|
});
|
||||||
|
|
||||||
$a->cheapestSellPrice = json_encode($prices);
|
$a->cheapestSellPrice = json_encode($prices);
|
||||||
WarehouseArticleModel::update(get_object_vars($a));
|
WarehouseArticleModel::update(get_object_vars($a));
|
||||||
@@ -93,4 +111,4 @@ class WarehouseArticleController extends TTCrud {
|
|||||||
protected function getHistoryAction() {
|
protected function getHistoryAction() {
|
||||||
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
|
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user