Merge branch 'Warehouse/fix-and-improve' into 'master'
Added WarehouseOffer and WarehouseOfferTemplate, also fixed menu for Lager Point See merge request fronk/thetool!1156
This commit is contained in:
@@ -2,20 +2,21 @@
|
||||
|
||||
class WarehouseOfferController extends TTCrud {
|
||||
protected string $headerTitle = 'Angebote';
|
||||
protected string $singleText = 'Angebot';
|
||||
protected bool $createText = false;
|
||||
|
||||
protected array $columns = [
|
||||
['key' => 'id', 'text' => 'ID', 'modal' => false],
|
||||
['key' => 'id', 'text' => 'ID', 'modal' => false, 'table' => false],
|
||||
['key' => 'offerNumber', 'text' => 'Angebotsnummer', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerNumber', 'text' => 'Kundennummer', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerName', 'text' => 'Kundenname', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerCity', 'text' => 'Stadt', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerVAT', 'text' => 'UID', 'required' => true, 'modal' => false],
|
||||
['key' => 'editor', 'text' => 'Sachbearbeiter', 'required' => true, 'modal' => false],
|
||||
['key' => 'editor', 'text' => 'Sachbearbeiter', 'required' => true, 'modal' => ['type' => 'select'], 'table' => ['filter' => 'select']],
|
||||
['key' => 'totalAmount', 'text' => 'Gesamtbetrag', 'required' => true, 'modal' => false],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => true, 'modal' => ['type' => 'select']],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => true],
|
||||
['key' => 'create', 'text' => 'Erstellt', 'required' => true, 'modal' => false],
|
||||
['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'modal' => ['type' => 'select']],
|
||||
['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'modal' => ['type' => 'select'], 'table' => ['filter' => 'select']],
|
||||
['key' => 'actions',
|
||||
'text' => 'Aktionen',
|
||||
'required' => false,
|
||||
@@ -24,27 +25,19 @@ class WarehouseOfferController extends TTCrud {
|
||||
];
|
||||
|
||||
protected array $permissionCheck = ['WarehouseAdmin'];
|
||||
protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
|
||||
|
||||
protected array $additionalActions = [
|
||||
['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary'],
|
||||
['key' => 'sendOffer', 'title' => 'Angebot senden', 'class' => 'fas fa-paper-plane text-success']
|
||||
];
|
||||
|
||||
protected array $additionalJS = ['
|
||||
https://cdn.jsdelivr.net/npm/sortablejs@1.14.0/Sortable.min.js
|
||||
https://cdn.jsdelivr.net/npm/vue-draggable-next@2.1.0'];
|
||||
|
||||
protected array $infoMessages = [
|
||||
'create' => 'Angebot wurde erfolgreich erstellt.',
|
||||
'update' => 'Angebot wurde aktualisiert.',
|
||||
'delete' => 'Angebot wurde gelöscht',
|
||||
'noChanges' => 'Keine Änderungen',
|
||||
'sent' => 'Angebot wurde erfolgreich gesendet',
|
||||
];
|
||||
protected function prepareCrudConfig(): void {
|
||||
$editorColumnIndex = array_search('editor', array_column($this->columns, 'key'));
|
||||
$this->columns[$editorColumnIndex]['modal']['items'] = array_map(function ($user) {
|
||||
return ['value' => intval($user->id), 'text' => $user->name];
|
||||
}, UserModel::search(['employee' => true]));
|
||||
}
|
||||
|
||||
protected function beforeCreate(): bool {
|
||||
$currentCount = WarehouseOfferModel::count(['create' => ['from' => strtotime(date('Y-01-01'))]]);
|
||||
$this->postData['offerNumber'] = 'AN' . date('Y') . '-' . str_pad($currentCount + 1, 4, '0', STR_PAD_LEFT);
|
||||
$this->postData['status'] = 'new';
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -57,4 +50,24 @@ class WarehouseOfferController extends TTCrud {
|
||||
protected function getHistoryAction() {
|
||||
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
|
||||
}
|
||||
|
||||
protected function createTemplateAction() {
|
||||
$_POST = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$templateId = WarehouseOfferTemplateModel::create([
|
||||
'templateName' => $_POST['name'],
|
||||
'positions' => $_POST['positions'],
|
||||
'totalDiscount' => $_POST['totalDiscount'],
|
||||
'paymentTerms' => $_POST['paymentTerms'],
|
||||
'deliveryTerms' => $_POST['deliveryTerms'],
|
||||
'closingText' => $_POST['closingText'],
|
||||
'notes' => $_POST['notes'],
|
||||
]);
|
||||
|
||||
self::returnJson(['success' => true, 'id' => $templateId]);
|
||||
}
|
||||
|
||||
protected function getTemplatesAction() {
|
||||
self::returnJson(WarehouseOfferTemplateModel::getAll());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*
|
||||
* @property int $id Unique identifier for the warehouse offer
|
||||
* @property string $offerNumber Unique offer number
|
||||
* @property string $reference Reference number for the offer
|
||||
* @property string $customerNumber Customer number
|
||||
* @property string $customerName Name of the customer
|
||||
* @property string $customerStreet Street address of the customer
|
||||
@@ -30,6 +31,7 @@
|
||||
class WarehouseOfferModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public string $offerNumber;
|
||||
public string $reference;
|
||||
public string $customerNumber;
|
||||
public string $customerName;
|
||||
public string $customerStreet;
|
||||
@@ -50,3 +52,31 @@ class WarehouseOfferModel extends TTCrudBaseModel {
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
|
||||
//SQL TO CREATE TABLE
|
||||
/*
|
||||
CREATE TABLE `warehouse_offer` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`offerNumber` varchar(255) NOT NULL,
|
||||
`customerNumber` varchar(255) NOT NULL,
|
||||
`customerName` varchar(255) NOT NULL,
|
||||
`customerStreet` varchar(255) NOT NULL,
|
||||
`customerCity` varchar(255) NOT NULL,
|
||||
`customerZip` varchar(255) NOT NULL,
|
||||
`customerVAT` varchar(255) NOT NULL,
|
||||
`editor` int(11) NOT NULL,
|
||||
`purpose` varchar(255) NOT NULL,
|
||||
`positions` text NOT NULL,
|
||||
`alternativePositions` text NOT NULL,
|
||||
`totalDiscount` float NOT NULL,
|
||||
`paymentTerms` varchar(255) NOT NULL,
|
||||
`deliveryTerms` varchar(255) NOT NULL,
|
||||
`closingText` varchar(255) NOT NULL,
|
||||
`notes` varchar(255) NOT NULL,
|
||||
`status` varchar(255) NOT NULL,
|
||||
`totalAmount` float NOT NULL,
|
||||
`create` int(11) NOT NULL,
|
||||
`createBy` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @property mixed|null $name
|
||||
*/
|
||||
class WarehouseOfferTemplate extends mfBaseModel
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WarehouseOfferTemplateModel
|
||||
*
|
||||
* Represents a warehouse offer template with key details.
|
||||
*
|
||||
* @property string $templateName Name of the template
|
||||
* @property string $positions Details about positions in the offer
|
||||
* @property float $totalDiscount Total discount applied to the offer
|
||||
* @property string $paymentTerms Payment terms for the offer
|
||||
* @property string $deliveryTerms Delivery terms for the offer
|
||||
* @property string $closingText Closing text for the offer
|
||||
* @property string $notes Additional notes for the offer
|
||||
*/
|
||||
class WarehouseOfferTemplateModel extends TTCrudBaseModel
|
||||
{
|
||||
public string $templateName;
|
||||
public string $positions;
|
||||
public float $totalDiscount;
|
||||
public string $paymentTerms;
|
||||
public string $deliveryTerms;
|
||||
public string $closingText;
|
||||
public string $notes;
|
||||
}
|
||||
Reference in New Issue
Block a user