added new end of life

This commit is contained in:
2025-08-07 16:33:49 +02:00
parent 7ccba02756
commit 4a58cc44da
7 changed files with 88 additions and 17 deletions
@@ -19,6 +19,9 @@ class WarehouseArticleController extends TTCrud {
['key' => 'warningAmount', 'text' => 'Warnmenge', 'required' => true,'modal' => ['type' => 'number'], 'table' => false],
['key' => 'criticalAmount', 'text' => 'Kritische Menge', 'required' => true,'modal' => ['type' => 'number'], 'table' => false],
['key' => 'isSerialDocumentation', 'text' => 'Seriennummern', 'required' => false,'modal' => ['type' => 'checkbox'], 'table' => false],
['key' => 'isEndOfLife', 'text' => 'End of Life', 'required' => false,'modal' => ['type' => 'checkbox', 'items' => [
['value' => 0, 'text' => 'Nicht End of Life', 'icon' => 'fa-regular fa-circle-check text-success'],
['value' => 1, 'text' => 'End of Life', 'icon' => 'fa-regular fa-circle-xmark text-danger']]], 'table' => ['filter' => 'iconSelect']],
['key' => 'isEShop', 'text' => 'Ist E-Shop', 'required' => false,'modal' => ['type' => 'checkbox'], 'table' => false],
['key' => 'isEShopHide', 'text' => 'E-Shop Versteckt', 'required' => false,'modal' => ['type' => 'checkbox'], 'table' => false],
['key' => 'isSbidiShop', 'text' => 'Ist SBIDI-Shop', 'required' => false,'modal' => ['type' => 'checkbox'], 'table' => false],
@@ -127,4 +130,37 @@ class WarehouseArticleController extends TTCrud {
protected function getHistoryAction() {
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
}
protected function autocompleteAction() {
$textKey = property_exists($this->model, 'name') ? 'name' : 'title';
if (strlen($this->request->searchedID) > 0) {
$filter = ['id' => $this->request->searchedID];
$data = $this->model::getAll($filter, 10);
} else {
if (isset($this->autocompleteColumns) && is_array($this->autocompleteColumns)) {
$filterKey = join('|', $this->autocompleteColumns);
} else {
$filterKey = $textKey;
}
$data = [];
if (count($data) < 11) {
if (isset($_GET['hideEndOfLife'])) {
$data = $this->model::getAll([$textKey => $this->request->q . '%', 'isEndOfLife' => 0], 10);
$lazyData = $this->model::getAll([$filterKey => $this->request->q, 'isEndOfLife' => 0], 10);
} else {
$data = $this->model::getAll([$textKey => $this->request->q . '%'], 10);
$lazyData = $this->model::getAll([$filterKey => $this->request->q], 10);
}
$data = array_merge($data, $lazyData);
$data = array_unique($data, SORT_REGULAR);
$data = array_slice($data, 0, 10);
}
}
self::returnJson(array_map(function ($item) use ($textKey) {
return ['value' => $item->id, 'text' => $item->$textKey];
}, $data));
}
}
@@ -14,6 +14,7 @@ class WarehouseArticleModel extends TTCrudBaseModel {
public ?int $isEShopHide;
public ?int $isSbidiShop;
public ?int $isSbidiShopHide;
public ?int $isEndOfLife;
public string $unit;
public ?int $isSerialDocumentation;
public int $revenueAccount;
@@ -18,7 +18,7 @@ class WarehouseOrderRequestController extends TTCrud {
'header' => 'Positionen',
'fields' => [
'articleId' => [
'apiUrl' => '/WarehouseArticle/autoComplete',
'apiUrl' => '/WarehouseArticle/autoComplete?hideEndOfLife=1',
'type' => 'input-article',
'emitDisplayValue' => true,
'customFieldReference' => 'WarehouseArticle',