diff --git a/application/WarehouseArticle/WarehouseArticleController.php b/application/WarehouseArticle/WarehouseArticleController.php index 912b9a700..8f0d6cc69 100644 --- a/application/WarehouseArticle/WarehouseArticleController.php +++ b/application/WarehouseArticle/WarehouseArticleController.php @@ -4,12 +4,13 @@ class WarehouseArticleController extends TTCrud { protected string $headerTitle = 'Artikel'; protected $createText = 'Artikel erstellen'; protected string $singleText = 'Artikel'; + protected bool $reopenOnCreate = true; // @formatter:off protected array $columns = [ ['key' => 'title', 'text' => 'Titel', 'required' => true, 'table' => ['priority' => 9]], ['key' => 'articleNumber', 'text' => 'Nr.', 'required' => true], - ['key' => 'description', 'text' => 'Beschreibung', 'required' => true, 'table' => ['sortable' => false]], + ['key' => 'description', 'text' => 'Beschreibung', 'required' => true,'modal' => ['type' => 'textarea'], 'table' => ['sortable' => false]], ['key' => 'category_id', 'text' => 'Kategorie', 'required' => true, 'modal' => ['type' => 'select', 'items' => []], 'table' => ['filter' => 'select']], ['key' => 'unit', 'text' => 'Einheit', 'required' => true,'table' => false], ['key' => 'revenueAccount', 'text' => 'Erlöskonto', 'required' => true,'modal' => ['type' => 'select', 'items' => [['value' => 0, 'text' => 'Dienstleistungen'], ['value' => 1, 'text' => 'Handelswaren']]], 'table' => false], @@ -46,7 +47,15 @@ class WarehouseArticleController extends TTCrud { $this->additionalJSVariables['WAREHOUSE_ADMIN'] = false; } + protected function beforeCreate() { + if (!in_array($this->user->id, [2, 5, 6, 145])) + self::sendError("Sie haben keine Berechtigung, Artikel zu erstellen."); + return true; + } + protected function beforeUpdate($postData): bool { + if (!in_array($this->user->id, [2, 5, 6, 145])) + self::sendError("Sie haben keine Berechtigung, Artikel zu bearbeiten."); (new WarehouseHistoryController)->create($postData, $this->mod); return true; } diff --git a/application/WarehouseArticle/WarehouseArticleModel.php b/application/WarehouseArticle/WarehouseArticleModel.php index 217243029..b8765a07c 100644 --- a/application/WarehouseArticle/WarehouseArticleModel.php +++ b/application/WarehouseArticle/WarehouseArticleModel.php @@ -17,6 +17,6 @@ class WarehouseArticleModel extends TTCrudBaseModel { public string $unit; public ?int $isSerialDocumentation; public int $revenueAccount; - - + public int $create; + public int $createBy; } \ No newline at end of file diff --git a/application/WarehouseArticleDistributor/WarehouseArticleDistributorModel.php b/application/WarehouseArticleDistributor/WarehouseArticleDistributorModel.php index d22dd64ca..5bcac36df 100644 --- a/application/WarehouseArticleDistributor/WarehouseArticleDistributorModel.php +++ b/application/WarehouseArticleDistributor/WarehouseArticleDistributorModel.php @@ -7,4 +7,6 @@ class WarehouseArticleDistributorModel extends TTCrudBaseModel { public float $purchasePrice; public string $externalArticleNumber; public ?string $note; + public int $create; + public int $createBy; } \ No newline at end of file diff --git a/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php b/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php index 72dc48586..9e83aa3a7 100644 --- a/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php +++ b/application/WarehouseArticlePacket/WarehouseArticlePacketModel.php @@ -13,4 +13,6 @@ class WarehouseArticlePacketModel extends TTCrudBaseModel { public ?int $isEShopHide; // New field to hide from Energie Steiermark shop public ?int $isSbidiShop; // New field for Sbidi shop visibility public ?int $isSbidiShopHide; // New field to hide from Sbidi shop + public int $create; + public int $createBy; } diff --git a/application/WarehouseArticlePrice/WarehouseArticlePriceModel.php b/application/WarehouseArticlePrice/WarehouseArticlePriceModel.php index 86f83ef3e..814d5efe6 100644 --- a/application/WarehouseArticlePrice/WarehouseArticlePriceModel.php +++ b/application/WarehouseArticlePrice/WarehouseArticlePriceModel.php @@ -6,4 +6,6 @@ class WarehouseArticlePriceModel extends TTCrudBaseModel { public int $articlePriceTypeId; public ?float $priceMultiplier; public ?float $priceOverride; + public int $create; + public int $createBy; } \ No newline at end of file diff --git a/application/WarehouseCategory/WarehouseCategory.php b/application/WarehouseCategory/WarehouseCategory.php index 77703bb1b..aa6447a6f 100644 --- a/application/WarehouseCategory/WarehouseCategory.php +++ b/application/WarehouseCategory/WarehouseCategory.php @@ -1,23 +1,11 @@ 'name', 'text' => 'Name', 'required' => true,], ['key' => 'description', 'text' => 'Beschreibung', 'required' => true], + ['key' => 'articleNumberPrefix', 'text' => 'Artikelnummerprefix', 'required' => true], ['key' => 'create', 'text' => 'Erstellt am', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']], ['key' => 'create_by', 'text' => 'Erstellt von', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']], - ['key' => 'edit', 'text' => 'Bearbeitet am', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']], - ['key' => 'edit_by', 'text' => 'Bearbeitet von', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']], ['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center', 'priority' => 10]], ]; // @formatter:on diff --git a/application/WarehouseDistributor/WarehouseDistributorModel.php b/application/WarehouseDistributor/WarehouseDistributorModel.php index a35d1769e..216e457b3 100644 --- a/application/WarehouseDistributor/WarehouseDistributorModel.php +++ b/application/WarehouseDistributor/WarehouseDistributorModel.php @@ -10,4 +10,6 @@ class WarehouseDistributorModel extends TTCrudBaseModel { public string $email; public string $phone; public string $contactPerson; + public int $create; + public int $createBy; } \ No newline at end of file diff --git a/application/WarehouseEShopOrderItem/WarehouseEShopOrderItemModel.php b/application/WarehouseEShopOrderItem/WarehouseEShopOrderItemModel.php index f1bf47acc..2ac47e247 100644 --- a/application/WarehouseEShopOrderItem/WarehouseEShopOrderItemModel.php +++ b/application/WarehouseEShopOrderItem/WarehouseEShopOrderItemModel.php @@ -13,4 +13,6 @@ class WarehouseEShopOrderItemModel extends TTCrudBaseModel { public ?int $articleId; public int $quantity; public ?int $articlePacketId; + public int $create; + public int $createBy; } \ No newline at end of file diff --git a/application/WarehouseLocationThresholdOverride/WarehouseLocationThresholdOverrideModel.php b/application/WarehouseLocationThresholdOverride/WarehouseLocationThresholdOverrideModel.php index 4c6ffc765..3d8db5afc 100644 --- a/application/WarehouseLocationThresholdOverride/WarehouseLocationThresholdOverrideModel.php +++ b/application/WarehouseLocationThresholdOverride/WarehouseLocationThresholdOverrideModel.php @@ -6,4 +6,6 @@ class WarehouseLocationThresholdOverrideModel extends TTCrudBaseModel { public int $articleId; public int $warningAmount; public int $criticalAmount; + public int $create; + public int $createBy; } \ No newline at end of file diff --git a/application/WarehouseOfferTemplate/WarehouseOfferTemplateModel.php b/application/WarehouseOfferTemplate/WarehouseOfferTemplateModel.php index ad63b36da..8bd797e35 100644 --- a/application/WarehouseOfferTemplate/WarehouseOfferTemplateModel.php +++ b/application/WarehouseOfferTemplate/WarehouseOfferTemplateModel.php @@ -24,4 +24,6 @@ class WarehouseOfferTemplateModel extends TTCrudBaseModel public string $deliveryTerms; public string $closingText; public string $notes; + public int $create; + public int $createBy; } \ No newline at end of file diff --git a/db/migrations/20250804150000_warehouse_add_all_create_cols.php b/db/migrations/20250804150000_warehouse_add_all_create_cols.php new file mode 100644 index 000000000..ccfb52656 --- /dev/null +++ b/db/migrations/20250804150000_warehouse_add_all_create_cols.php @@ -0,0 +1,71 @@ +getEnvironment() == "thetool") { + $this->execute("ALTER TABLE `WarehouseArticle` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseArticleDistributor` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseArticlePacket` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseArticlePrice` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseDistributor` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseEShopOrderItem` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseLocationThresholdOverride` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseOfferTemplate` ADD COLUMN `create` int(11) DEFAULT 1754312555, ADD COLUMN `createBy` int(11) DEFAULT 1;"); + $this->execute("ALTER TABLE `WarehouseCategory` ADD `articleNumberPrefix` int NULL AFTER `description`;"); + } + } + + public function down(): void + { + if ($this->getEnvironment() == "thetool") { + $table = $this->table('WarehouseArticle'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseArticleDistributor'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseArticlePacket'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseArticlePrice'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseDistributor'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseEShopOrderItem'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseLocationThresholdOverride'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseOfferTemplate'); + $table->removeColumn('create') + ->removeColumn('createBy') + ->save(); + + $table = $this->table('WarehouseCategory'); + $table->removeColumn('articleNumberPrefix') + ->save(); + } + } +} diff --git a/lib/TTCrud/TTCrud.php b/lib/TTCrud/TTCrud.php index 4dcf2072a..35e84ba11 100644 --- a/lib/TTCrud/TTCrud.php +++ b/lib/TTCrud/TTCrud.php @@ -82,6 +82,7 @@ class TTCrud extends mfBaseController { "CREATE_URL" => $this::getUrl("{$this->mod}/create"), "TABLE_URL" => $this::getUrl("{$this->mod}/get"), "UPDATE_URL" => $this::getUrl("{$this->mod}/update"), + "GET_BY_ID_URL" => $this::getUrl("{$this->mod}/getById"), "DELETE_URL" => $this::getUrl("{$this->mod}/delete"), "USER_ID" => $this->user->id ]; @@ -136,10 +137,11 @@ class TTCrud extends mfBaseController { } return ['key' => $this->mod, - 'tableHeader' => $this->headerTitle, - 'createText' => $this->createText, - 'columns' => $columns, - 'additionalActions' => $this->additionalActions]; + 'tableHeader' => $this->headerTitle, + 'reopenOnCreate' => $this->reopenOnCreate ?? false, + 'createText' => $this->createText, + 'columns' => $columns, + 'additionalActions' => $this->additionalActions]; } protected function getAction() { diff --git a/public/plugins/vue/tt-components/tt-select.js b/public/plugins/vue/tt-components/tt-select.js index 68d21c4b4..cd19e9eda 100644 --- a/public/plugins/vue/tt-components/tt-select.js +++ b/public/plugins/vue/tt-components/tt-select.js @@ -167,7 +167,7 @@ Vue.component('tt-select', { {{ label }} -
+