improved warehouse module
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@ class WarehouseArticleModel extends TTCrudBaseModel {
|
||||
public string $unit;
|
||||
public ?int $isSerialDocumentation;
|
||||
public int $revenueAccount;
|
||||
|
||||
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -7,4 +7,6 @@ class WarehouseArticleDistributorModel extends TTCrudBaseModel {
|
||||
public float $purchasePrice;
|
||||
public string $externalArticleNumber;
|
||||
public ?string $note;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -6,4 +6,6 @@ class WarehouseArticlePriceModel extends TTCrudBaseModel {
|
||||
public int $articlePriceTypeId;
|
||||
public ?float $priceMultiplier;
|
||||
public ?float $priceOverride;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -1,23 +1,11 @@
|
||||
<?php
|
||||
|
||||
class WarehouseCategory extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public string $name;
|
||||
public string $description;
|
||||
public ?int $articleNumberPrefix;
|
||||
public int $create;
|
||||
public int $create_by;
|
||||
public ?int $edit;
|
||||
public ?int $edit_by;
|
||||
}
|
||||
|
||||
// SQL:
|
||||
// CREATE TABLE `WarehouseCategory` (
|
||||
// `id` INT NOT NULL AUTO_INCREMENT,
|
||||
// `name` VARCHAR(255) NOT NULL,
|
||||
// `description` TEXT NOT NULL,
|
||||
// `create` INT NOT NULL,
|
||||
// `create_by` INT NOT NULL,
|
||||
// `edit` INT DEFAULT NULL,
|
||||
// `edit_by` INT DEFAULT NULL,
|
||||
// PRIMARY KEY (`id`)
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
}
|
||||
@@ -9,10 +9,9 @@ class WarehouseCategoryController extends TTCrud {
|
||||
protected array $columns = [
|
||||
['key' => '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
|
||||
|
||||
@@ -10,4 +10,6 @@ class WarehouseDistributorModel extends TTCrudBaseModel {
|
||||
public string $email;
|
||||
public string $phone;
|
||||
public string $contactPerson;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -13,4 +13,6 @@ class WarehouseEShopOrderItemModel extends TTCrudBaseModel {
|
||||
public ?int $articleId;
|
||||
public int $quantity;
|
||||
public ?int $articlePacketId;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -6,4 +6,6 @@ class WarehouseLocationThresholdOverrideModel extends TTCrudBaseModel {
|
||||
public int $articleId;
|
||||
public int $warningAmount;
|
||||
public int $criticalAmount;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -24,4 +24,6 @@ class WarehouseOfferTemplateModel extends TTCrudBaseModel
|
||||
public string $deliveryTerms;
|
||||
public string $closingText;
|
||||
public string $notes;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php /** @noinspection ALL */
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class WarehouseAddAllCreateCols extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
@@ -167,7 +167,7 @@ Vue.component('tt-select', {
|
||||
{{ label }}
|
||||
</label>
|
||||
|
||||
<div :class="row ? 'col-sm-8' : ''">
|
||||
<div :class="row ? 'col-sm-8 p-0' : ''">
|
||||
<div class="dropdown" :class="{ show: open }">
|
||||
<button type="button"
|
||||
class="btn btn-outline-secondary form-control"
|
||||
|
||||
@@ -107,9 +107,17 @@ Vue.component('tt-table-crud', {
|
||||
const response = await axios.post(this.crudModalData.id ? window['TT_CONFIG']['UPDATE_URL'] : window['TT_CONFIG']['CREATE_URL'],
|
||||
this.crudModalData);
|
||||
if (response.data.success) {
|
||||
this.$refs.table.refreshTable();
|
||||
this.resetCrudModalData();
|
||||
this.window.notify('success', response.data.message || 'Erfolgreich gespeichert');
|
||||
if (this.crudConfig.reopenOnCreate && !this.crudModalData.id) {
|
||||
this.resetCrudModalData();
|
||||
const getByIdUrl = window['TT_CONFIG']['GET_BY_ID_URL'] || `${window['TT_CONFIG']['BASE_PATH']}/${this.crudConfig.key}/getById`;
|
||||
const getByIdResponse = await axios.get(getByIdUrl, {params: {id: response.data.id}});
|
||||
this.crudModalData = getByIdResponse.data;
|
||||
this.crudModal = true;
|
||||
} else {
|
||||
this.resetCrudModalData();
|
||||
this.$refs.table.refreshTable();
|
||||
}
|
||||
} else {
|
||||
this.window.notify('error',
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message || 'Ein Fehler ist aufgetreten');
|
||||
|
||||
Reference in New Issue
Block a user