Feature/warehouse

This commit is contained in:
Luca Haid
2024-07-16 06:55:46 +00:00
parent 8b4589523e
commit e75f13f8d8
64 changed files with 3207 additions and 265 deletions

View File

@@ -0,0 +1,9 @@
<?php
/**
* @property mixed|null $name
*/
class WarehouseArticlePriceType extends mfBaseModel
{
}

View File

@@ -0,0 +1,67 @@
<?php
class WarehouseArticlePriceTypeController extends TTCrud {
protected string $headerTitle = 'Artikel Verkaufspreise';
protected string $createText = 'Artikel Verkaufspreis erstellen';
// @formatter:off
protected array $columns = [
['key' => 'title', 'text' => 'Titel', 'required' => true],
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center', 'priority' => 10]],
];
// @formatter:on
protected array $infoMessages = ['create' => 'Artikel Verkaufspreis wurde erstellt',
'update' => 'Artikel Verkaufspreis wurde aktualisiert',
'delete' => 'Artikel Verkaufspreis wurde gelöscht',
'noChanges' => 'Keine Änderungen'];
protected function checkExistingDistributorEntry($postData): bool {
// if postData id exists check if there is already an entry with the same articleId and locationId if postdata id and WarehouseLocationThresholdOverrideModel id are different return false
if (isset($postData['id'])) {
$count = WarehouseArticlePriceTypeModel::count(['title' => $postData['title'], 'id' => $postData['id']]);
if ($count > 0) {
return true;
}
} else {
$count = WarehouseArticlePriceTypeModel::count(['title' => $postData['title']]);
if ($count > 0) {
self::returnJson(['success' => false,
'message' => 'Es existiert bereits ein Preis Typ mit diesem Titel.']);
return false;
}
}
return true;
}
protected function beforeCreate($postData): bool {
return $this->checkExistingDistributorEntry($postData);
}
protected function beforeUpdate($postData): bool {
$existing = $this->checkExistingDistributorEntry($postData);
if (!$existing) {
return false;
}
(new WarehouseHistoryController)->create($postData, $this->mod);
return true;
}
protected function getHistoryAction() {
$history = WarehouseHistoryModel::getByRowId($this->request->id, $this->mod);
$history = array_map(function ($item) {
$item = (array) $item;
$item['columnHeader'] = $this->columns[array_search($item['key'], array_column($this->columns, 'key'))]['text'];
return $item;
}, $history);
self::returnJson($history);
}
}

View File

@@ -0,0 +1,6 @@
<?php
class WarehouseArticlePriceTypeModel extends TTCrudBaseModel {
public int $id;
public string $title;
}