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

View File

@@ -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));
}
}

View File

@@ -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;

View File

@@ -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',

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class WarehouseArticleAddIsEndOfLife extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$this->table("WarehouseArticle")
->addColumn("isEndOfLife", "integer", ["null" => false, "default" => 0, "after" => "criticalAmount"])
->update();
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$this->table("WarehouseArticle")
->removeColumn("isEndOfLife")
->update();
}
}
}

View File

@@ -271,10 +271,10 @@ class TTCrud extends mfBaseController {
}
protected function updateAction() {
if (property_exists($this->model, 'create') && isset($this->postData['create'])) {
if (property_exists($this->model, 'create')) {
$this->postData['create'] = $this->model::get($this->postData['id'])->create;
}
if (property_exists($this->model, 'createBy') && isset($this->postData['createBy'])) {
if (property_exists($this->model, 'createBy')) {
$this->postData['createBy'] = $this->model::get($this->postData['id'])->createBy;
}

View File

@@ -1,38 +1,43 @@
/* style.css */
.end-of-life {
background-color: #f8d7da !important;
}
.warehouse-article-prices > div,
.warehouse-article-distributor > div {
display: grid;
grid-template-columns: repeat(3, minmax(150px, 1fr)) 120px; /* Defines 4 columns */
gap: 12px; /* Use gap for spacing */
margin-bottom: 8px; /* Add small gap between rows */
grid-template-columns: repeat(3, minmax(150px, 1fr)) 120px;
gap: 12px;
margin-bottom: 8px;
}
.warehouse-article-prices .form-group,
.warehouse-article-distributor .form-group {
margin-bottom: 0; /* Keep inputs tight in grid cells */
margin-bottom: 0;
}
@media (max-width: 992px) {
.warehouse-article-prices > div,
.warehouse-article-distributor > div {
display: block; /* Stack items vertically */
border: 1px solid #eee; /* Lighter border */
display: block;
border: 1px solid #eee;
padding: 10px;
margin-bottom: 10px;
}
.warehouse-article-prices > div > *,
.warehouse-article-distributor > div > * {
display: block; /* Ensure children are block */
margin-bottom: 10px !important; /* Add space between stacked items */
display: block;
margin-bottom: 10px !important;
}
.warehouse-article-prices > div > div:last-child, /* Target button container */
.warehouse-article-prices > div > div:last-child,
.warehouse-article-distributor > div > div:last-child {
text-align: right; /* Keep buttons aligned right */
margin-bottom: 0 !important; /* Remove extra margin below buttons */
text-align: right;
margin-bottom: 0 !important;
}
.warehouse-article-prices > div > div:last-child > *, /* Target buttons inside */
.warehouse-article-prices > div > div:last-child > *,
.warehouse-article-distributor > div > div:last-child > * {
margin-left: 5px; /* Add small space between buttons */
margin-left: 5px;
}
}

View File

@@ -1,3 +1,7 @@
window.TT_CONFIG.CRUD_CONFIG.customRowClass = (row) => {
if (row.isEndOfLife) return 'end-of-life';
}
async function handleApiResponse(responsePromise) {
const res = await responsePromise;
if (!res.data.success) {