updated warehouseoffer

This commit is contained in:
Luca Haid
2025-06-04 12:50:43 +02:00
parent c3237017a2
commit b8ceba5220
7 changed files with 666 additions and 80 deletions
@@ -24,6 +24,7 @@ class WarehouseArticleController extends TTCrud {
];
protected array $autocompleteColumns = ['articleNumber', 'title', 'description'];
protected array $permissionCheck = ['WarehouseUser'];
protected array $additionalActions = [['key' => 'openHistory','title' => 'Historie','class' => 'fas fa-history text-secondary']];
// @formatter:on
@@ -148,8 +148,8 @@ class WarehouseOfferController extends TTCrud {
$article = WarehouseArticleModel::get($position['article']);
if (!$article) continue; // Skip if article not found
$position['articleText'] = $article->title ?? 'N/A';
// Avoid showing description if same as title
$position['articleNumber'] = $article->articleNumber ?? null;
$position['articleText'] = $article->title;
$position['articleDescription'] = ($article->description !== $article->title) ? ($article->description ?? '') : '';
$position['articleUnit'] = $position['unit'] ?? $article->unit ?? 'Stk.'; // Default to 'Stk.'
$position['price'] = (float)($position['unitPrice'] ?? 0); // Ensure price is float
@@ -170,6 +170,9 @@ class WarehouseOfferController extends TTCrud {
trigger_error("Invalid or empty positions JSON for offer ID: " . $id, E_USER_WARNING);
}
$editor = UserModel::getOne($offer->editor);
$editorName = $editor ? $editor->name : 'Unbekannt'; // Fallback if editor not found
// --- Prepare PDF Variables ---
$pdf_vars = [
@@ -179,6 +182,7 @@ class WarehouseOfferController extends TTCrud {
// Add other offer details needed in PDF_MAIN
"offerNumber" => $offer->offerNumber ?? $offer->id, // Use offerNumber if available
"offerDate" => $offer->createDate ?? time(), // Assuming createDate is a timestamp
"offerEditorName" => $editorName, // Editor name for the offer
"validUntilDate" => $offer->validUntilDate ?? null, // Assuming validUntilDate is a timestamp
"includeTax" => $offer->includeTax ?? true, // Default to including tax (e.g., 20% VAT)
"vatRate" => 0.20, // Example VAT rate (20%) - make this configurable if needed
@@ -1,33 +1,5 @@
<?php
/**
* Class WarehouseOfferModel
*
* Represents a warehouse offer with customer details and related metadata.
*
* @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
* @property string $customerCity City of the customer
* @property string $customerZip Postal code of the customer
* @property string $customerVAT VAT number of the customer
* @property int $editor ID of the editor who last modified the offer
* @property string $purpose Purpose of the offer
* @property string $positions Details about positions in the offer
* @property string $alternativePositions Details about alternative 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
* @property string $status Current status of the offer
* @property float $totalAmount Total amount of the offer
* @property int $create Timestamp of the offer creation
* @property int $createBy ID of the user who created the offer
*/
class WarehouseOfferModel extends TTCrudBaseModel {
public int $id;
public string $offerNumber;
@@ -37,7 +9,7 @@ class WarehouseOfferModel extends TTCrudBaseModel {
public string $customerStreet;
public string $customerCity;
public string $customerZip;
public string $customerVAT;
public ?string $customerVAT;
public int $editor;
public string $purpose;
public string $positions;
@@ -51,32 +23,4 @@ class WarehouseOfferModel extends TTCrudBaseModel {
public float $totalAmount;
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;
*/
}