Merge branch 'warehouse-improve' into 'master'

added new warehouseorder features

See merge request fronk/thetool!1090
This commit is contained in:
Luca Haid
2025-03-10 09:40:31 +00:00
5 changed files with 84 additions and 19 deletions

View File

@@ -16,7 +16,7 @@ class WarehouseOrderController extends TTCrud {
['key' => 'delAddrName', 'text' => 'Name', 'required' => true, 'modal' => false, 'table' => false],
['key' => 'delAddrPLZ', 'text' => 'PLZ', 'required' => true, 'modal' => false, 'table' => false],
['key' => 'editor', 'text' => 'Bearbeiter', 'required' => true, 'modal' => ['type' => 'select'], 'table' => ['filter' => 'select']],
['key' => 'note', 'text' => 'Notiz', 'required' => false, 'modal' => false, 'table' => false],
['key' => 'note', 'text' => 'Interne Notiz', 'required' => false, 'modal' => false, 'table' => false],
['key' => 'sum', 'text' => 'Summe', 'required' => false, 'modal' => false, 'table' => ['class' => 'text-right']],
['key' => 'status', 'text' => 'Status', 'required' => false, 'modal' => ['type' => 'select', 'items' => [
['value' => 'new', 'text' => 'Neu'],
@@ -174,6 +174,37 @@ class WarehouseOrderController extends TTCrud {
$order['positions'] = json_decode($order['positions'], true);
$distributorName = WarehouseDistributorModel::get($order['distributorId'])->name;
$texts = [
'EN' => [
'taxFree' => 'Please provide tax-free delivery according to § 6a UStG (Austrian Sales tax law).<br>Our VAT ID number: ATU68711968. Delivery to Austria.',
'orderConfirmation' => 'Please send the order confirmation to einkauf@xinon.at',
'sendShippingNote' => 'Please send the delivery note with our shipping note and neutral packaging.',
],
'DE' => [
'taxFree' => 'Bitte um steuerfreie Lieferung gemäß § 6a UStG.<br> Unsere UID-Nr.: ATU68711968. Lieferung nach Österreich.',
'orderConfirmation' => 'Wir bitten um Zusendung der Auftragsbestätigung für die Bestellung an einkauf@xinon.at.',
'sendShippingNote' => 'Bitte senden Sie den Lieferschein mit unserem Versandschein und neutraler Verpackung.',
]];
$countryText = (new Country(WarehouseDistributorModel::get($order['distributorId'])->countryId))->name;
$isGermanSpeaking = in_array($countryText, ['Österreich', 'Deutschland', 'Schweiz']);
$appendToBody = '';
if ($isGermanSpeaking && $countryText !== "Österreich") {
$appendToBody .= $texts['DE']['taxFree'] . '<br><br>';
} else {
$appendToBody .= $texts['EN']['taxFree'] . '<br><br>';
}
$appendToBody .= $texts[$isGermanSpeaking ? 'DE' : 'EN']['orderConfirmation'];
if ($order['sendShippingNote'] > 0) {
$appendToBody .= '<br><br>' . $texts[$isGermanSpeaking ? 'DE' : 'EN']['sendShippingNote'];
}
$appendToBody .= $isGermanSpeaking ? '<br><br>Die Bestellung liegt als PDF-Anhang bei.' : '<br><br>The order is attached as a PDF file.';
// Instantiate PHPMailer
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
@@ -208,7 +239,8 @@ class WarehouseOrderController extends TTCrud {
Datum: " . date('d.m.Y H:i', $order['create']) . "<br>
Lieferant: <strong>$distributorName</strong>
</p>
<p>Die Bestellung liegt als PDF-Anhang bei.</p>
$appendToBody
</body>
</html>";

View File

@@ -8,7 +8,7 @@ class WarehouseOrderRequestController extends TTCrud {
//@formatter:off
protected array $columns = [
['key' => 'id', 'text' => 'Bestellnummer', 'table' => ['filter' => false], 'modal' => false],
['key' => 'addressId', 'text' => 'Kunde', 'required' => false, 'type' => 'autocomplete', 'table' => ['class' => 'text-nowrap', 'filter' => 'autocomplete'], 'modal' => ['apiUrl' => 'Address/api?do=findAddress', 'items' => '/Address/Api?do=findAddress', 'type' => 'autocomplete']],
['key' => 'addressId', 'text' => 'Kunde', 'required' => false, 'type' => 'autocomplete', 'table' => ['class' => 'text-nowrap', 'filter' => 'autocomplete'], 'modal' => ['apiUrl' => 'Address/api?do=findAddress&fibu_primary_account=1', 'items' => '/Address/Api?do=findAddress&fibu_primary_account=1', 'type' => 'autocomplete']],
['key' => 'purpose', 'text' => 'Verwendungszweck', 'required' => true],
['key' => 'positions', 'text' => 'Positionen', 'required' => true, 'modal' => ['type' => 'positions-manager', 'config' => [
'header' => 'Positionen',
@@ -26,7 +26,6 @@ class WarehouseOrderRequestController extends TTCrud {
'validateFormOptions' => [
['key' => 'articleId', 'message' => 'Bitte füllen Sie den Artikel aus'],
['key' => 'amount', 'message' => 'Bitte füllen Sie die Menge aus'],
['key' => 'purpose', 'message' => 'Bitte füllen Sie den Zweck aus'],
],
]], 'table' => false],
['key' => 'linkedOrderIds', 'text' => 'Verlinkte Bestellung', 'modal' => false],
@@ -37,8 +36,8 @@ class WarehouseOrderRequestController extends TTCrud {
['value' => 1, 'text' => 'Bestellwunsch storniert', 'icon' => 'fa-regular fa-circle-xmark text-danger']]], 'table' => ['filter' => 'iconSelect']
],
['key' => 'done', 'text' => 'Erledigt', 'modal' => ['visible' => false, 'type' => 'icon-select', 'items' => [
['value' => 0, 'text' => 'Bestellwunsch nicht erledigt', 'icon' => 'fa-regular fa-circle-check text-success'],
['value' => 1, 'text' => 'Bestellwunsch erledigt', 'icon' => 'fa-regular fa-circle-xmark text-danger']]], 'table' => ['filter' => 'iconSelect']
['value' => 0, 'text' => 'Bestellwunsch nicht erledigt', 'icon' => 'fa-regular fa-circle-xmark text-danger'],
['value' => 1, 'text' => 'Bestellwunsch erledigt', 'icon' => 'fa-regular fa-circle-check text-success']]], 'table' => ['filter' => 'iconSelect']
],
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
];
@@ -72,10 +71,16 @@ class WarehouseOrderRequestController extends TTCrud {
if (!$id || $cancel === false) self::returnJson(['error' => 'Ungültige Anfrage']);
if (!(WarehouseOrderRequestModel::get($id))) self::returnJson(['error' => 'Bestellwunsch nicht gefunden']);
WarehouseOrderRequestModel::update(['id' => $id, 'canceled' => $cancel]);
$currentData = (array) WarehouseOrderRequestModel::get($id);
WarehouseOrderRequestModel::update(array_merge($currentData, ['id' => $id, 'cancelled' => $cancel]));
self::returnJson(['success' => true]);
}
public function customAutoCompleteAddressId($id): array {
$address = new Address($id);
return ['title' => $address->getCompanyOrName(), 'value' => $address->id];
}
protected function doneAction() {
$id = filter_var($this->request->id, FILTER_VALIDATE_INT);
$done = filter_var($this->request->done, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 1]]);
@@ -83,7 +88,8 @@ class WarehouseOrderRequestController extends TTCrud {
if (!$id || $done === false) self::returnJson(['error' => 'Ungültige Anfrage']);
if (!(WarehouseOrderRequestModel::get($id))) self::returnJson(['error' => 'Bestellwunsch nicht gefunden']);
WarehouseOrderRequestModel::update(['id' => $id, 'done' => $done]);
$currentData = (array) WarehouseOrderRequestModel::get($id);
WarehouseOrderRequestModel::update(array_merge($currentData, ['id' => $id, 'done' => $done]));
self::returnJson(['success' => true]);
}
@@ -95,6 +101,35 @@ class WarehouseOrderRequestController extends TTCrud {
return;
}
// send email to einkauf@xinon.at
// Instantiate PHPMailer
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
try {
// Server settings
$mail->isSMTP();
$mail->Host = TT_WAREHOUSE_ORDER_SMTP_HOST;
$mail->SMTPAuth = true;
$mail->Username = TT_WAREHOUSE_ORDER_SMTP_USER;
$mail->Password = TT_WAREHOUSE_ORDER_SMTP_PASS;
$mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
// Recipients
$mail->setFrom('einkauf@xinon.at', 'XINON Einkauf');
$mail->addAddress('einkauf@xinon.at', 'XINON Einkauf');
// Content
$mail->isHTML(true);
$mail->Subject = "Neue Nachricht zu Besteallwunsch #" . $postData['orderRequestId'];
$mail->Body = $postData['note'];
$mail->send();
} catch (Exception $e) {
self::returnJson(['error' => 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo]);
exit;
}
WarehouseLogModel::create([
"table" => "WarehouseOrderRequest",
"rowId" => intval($postData['orderRequestId']),

View File

@@ -78,11 +78,11 @@
}
.file-item i {
margin-right: 10px;
color: #6c757d;
color: #000000;
}
.file-name {
margin-left: 10px;
flex-grow: 1;
font-size: 14px;
}

View File

@@ -46,6 +46,8 @@ Vue.component('change-status-modal', {
return [
{value: 'noChanges', text: 'Keine Änderungen'},
{value: 'sent', text: 'Versendet'},
{value: 'fullyDelivered', text: 'Geliefert'},
{value: 'cancelled', text: 'Storniert'},
{value: 'cancelled', text: 'Storniert'},
];
case 'sent':
@@ -305,7 +307,7 @@ Vue.component('warehouse-order-modal', {
</template>
<hr>
<tt-textarea label="Notiz" v-model="order.note" sm row/>
<tt-textarea label="Interne Notiz" v-model="order.note" sm row/>
</div>
</tt-modal>
`,
@@ -313,7 +315,7 @@ Vue.component('warehouse-order-modal', {
data() {
return {
window: window,
showSendShippingNote: false,
showSendShippingNote: null,
positionsConfig: {
customOrdering: 'distributorId',
fields: {
@@ -356,7 +358,7 @@ Vue.component('warehouse-order-modal', {
delAddrEMail: 'einkauf@xinon.at',
note: '',
editor: window.TT_CONFIG['USER_ID'],
sendShippingNote: false,
sendShippingNote: null,
positions: [],
}
}
@@ -381,7 +383,7 @@ Vue.component('warehouse-order-modal', {
buyPrice: distributor.purchasePrice,
distributorId: distributor.id,
distributorArticleNumber: distributor.externalArticleNumber,
verwendung: `${p.purpose} [Bestellwunsch: #${orderRequest.id}]`,
verwendung: `${p.hasOwnProperty('purpose') ? p.purpose : ''} [Bestellwunsch: #${orderRequest.id}]`,
linkedOrderRequestId: orderRequest.id
};
}));

View File

@@ -208,10 +208,6 @@ Vue.component('warehouse-order-request', {
<template #linkedorderids="{row}">
<linked-order-status :linkedOrders="row.linkedOrderIds" v-if="row.linkedOrderIds"/>
</template>
<template #note="{row}">
<span v-if="row.note?.length > 45" :title="row.note">{{ row.note.substring(0, 45) }}...</span>
<span v-else>{{ row.note }}</span>
</template>
<template #expandedRow="{row}">
<warehouse-order-request-detail :positions="JSON.parse(row['positions'])"/>
<order-request-log :orderRequestId="row.id"/>
@@ -221,7 +217,7 @@ Vue.component('warehouse-order-request', {
</template>
</tt-table-crud>
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
<add-log-modal v-if="addLogModalId" :orderRequestId="addLogModalId" @close="addLogModal = false; addLogModalId = null"/>
<add-log-modal v-if="addLogModalId" :orderRequestId="addLogModalId" @close="addLogModal = false; addLogModalId = null; $refs.crud.$refs.table.refreshTable()"/>
</tt-card>
`,
data: () => ({