changed shipping note
This commit is contained in:
@@ -101,7 +101,7 @@ TODO: enable option for showing prices
|
||||
<th style="text-align: center">Position</th>
|
||||
<th style="text-align: right;padding-right: 4pt">Menge</th>
|
||||
<th style="text-align: left;padding-right: 4pt">Einheit</th>
|
||||
<th style="text-align: center">Artikel</th>
|
||||
<th style="text-align: left">Artikel</th>
|
||||
<?php if($showPrices): ?>
|
||||
<th style="text-align: right;padding-right: 4pt">Preis</th>
|
||||
<?php endif; ?>
|
||||
@@ -112,7 +112,7 @@ TODO: enable option for showing prices
|
||||
<td style="text-align: center;"><?= $i + 1 ?></td>
|
||||
<td style="text-align: right;padding-right: 8pt"><?=$p["amount"]?> </td>
|
||||
<td style="text-align: left;padding-right: 8pt"><?=$p["articleUnit"]?> </td>
|
||||
<td style="text-align: center;"><b><?=$p["articleTitle"]?></b></td>
|
||||
<td style="text-align: left;"><b><?=$p["articleTitle"]?></b></td>
|
||||
<?php if($showPrices): ?>
|
||||
<td style="text-align: right;padding-right: 8pt"><?=number_format(
|
||||
$p["price"] * $p["amount"], 2, ",", ".")?> €</td>
|
||||
@@ -123,7 +123,7 @@ TODO: enable option for showing prices
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
||||
<td style="text-align: center;"><?= $p["articleDescription"] ?></td>
|
||||
<td style="text-align: left;"><?= $p["articleDescription"] ?></td>
|
||||
<?php if($showPrices): ?>
|
||||
<td></td>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -13,7 +13,7 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
['key' => 'deliveryAddressPLZ', 'text' => 'L.-Adr. PLZ', 'required' => true],
|
||||
['key' => 'deliveryAddressEMail', 'text' => 'L.-Adr. EMail', 'required' => false, 'table' => false],
|
||||
['key' => 'note', 'text' => 'Art der Arbeit', 'required' => true, 'table' => false],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => true, 'table' => ['filter' => 'select'], 'modal' => ['type' => 'select', 'items' => [['value' => 'new', 'text' => 'Neu'], ['value' => 'inProgress', 'text' => 'In Bearbeitung'], ['value' => 'accepted', 'text' => 'Akzeptiert'], ['value' => 'invoiced', 'text' => 'In Rechnung gestellt'],]]],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => true, 'table' => ['filter' => 'select'], 'modal' => ['type' => 'select', 'items' => [['value' => 'new', 'text' => 'Neu'], ['value' => 'in_progress', 'text' => 'In Bearbeitung'], ['value' => 'accepted', 'text' => 'Akzeptiert'], ['value' => 'invoiced', 'text' => 'In Rechnung gestellt'],]]],
|
||||
['key' => 'positions', 'text' => 'Positionen', 'required' => true, 'table' => false, 'modal' => false],
|
||||
['key' => 'create', 'text' => 'Erstellt', 'required' => false, 'modal' => false, 'table' => ['filter' => 'date']],
|
||||
['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'type' => 'autocomplete', 'table' => ['class' => 'text-nowrap', 'filter' => 'select'], 'modal' => ['items' => [], 'type' => 'select',]],
|
||||
@@ -247,18 +247,20 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
$articleTitle = "Arbeitsstunden (100% Zuschlag)";
|
||||
}
|
||||
|
||||
$positions[] = [
|
||||
'articleTitle' => $articleTitle,
|
||||
'articleDescription' => "Datum: ". date("d.m.Y", strtotime($hoursEntry['date'])) . " | Mitarbeiter: " . UserModel::getOne($hoursEntry['userId'])->name,
|
||||
'articleUnit' => 'Std.',
|
||||
'amount' => $hoursEntry['hourCount'],
|
||||
'price' => $hoursEntry['hourlyPrice'] * $hoursEntry['hourCount'] ?? 0,
|
||||
];
|
||||
if (intval($hoursEntry['hourCount']) > 0) {
|
||||
$positions[] = [
|
||||
'articleTitle' => $articleTitle,
|
||||
'articleDescription' => "Datum: ". date("d.m.Y", strtotime($hoursEntry['date'])) . " | Mitarbeiter: " . UserModel::getOne($hoursEntry['userId'])->name,
|
||||
'articleUnit' => 'Std.',
|
||||
'amount' => $hoursEntry['hourCount'],
|
||||
'price' => $hoursEntry['hourlyPrice'] * $hoursEntry['hourCount'] ?? 0,
|
||||
];
|
||||
}
|
||||
|
||||
if ($hoursEntry['carId']) {
|
||||
$positions[] = [
|
||||
'articleTitle' => "Fahrkostenpauschale",
|
||||
'articleDescription' => "Fahrzeug: " . TimerecordingCarModel::getOne($hoursEntry['carId'])->number_plate,
|
||||
'articleTitle' => "Fahrkostenpauschale (hin und retour)",
|
||||
'articleDescription' => "Datum: ". date("d.m.Y", strtotime($hoursEntry['date'])) . " | Fahrzeug: " . TimerecordingCarModel::getOne($hoursEntry['carId'])->number_plate,
|
||||
'articleUnit' => 'Km',
|
||||
'amount' => $hoursEntry['kilometerCount'],
|
||||
'price' => 1 * $hoursEntry['kilometerCount'] ?? 0,
|
||||
@@ -268,6 +270,21 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
}
|
||||
|
||||
|
||||
usort($positions, function ($a, $b) {
|
||||
$aHasMitarbeiter = str_contains($a['articleDescription'], 'Mitarbeiter');
|
||||
$bHasMitarbeiter = str_contains($b['articleDescription'], 'Mitarbeiter');
|
||||
$aHasFahrzeug = str_contains($a['articleDescription'], 'Fahrzeug');
|
||||
$bHasFahrzeug = str_contains($b['articleDescription'], 'Fahrzeug');
|
||||
|
||||
if ($aHasMitarbeiter && !$bHasMitarbeiter) return -1;
|
||||
if (!$aHasMitarbeiter && $bHasMitarbeiter) return 1;
|
||||
if ($aHasFahrzeug && !$bHasFahrzeug) return -1;
|
||||
if (!$aHasFahrzeug && $bHasFahrzeug) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
||||
|
||||
$textElements = [];
|
||||
// parse shippingNote.textElements ({"1":true,"2":true}) to array, fetch each text element and put content into array
|
||||
$shippingNoteTextElements = json_decode($shippingNote->textElements, true);
|
||||
@@ -356,6 +373,28 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
self::returnJson(array_values($out));
|
||||
}
|
||||
|
||||
protected function changeStatusAction() {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
$json = json_decode(file_get_contents('php://input'), true);
|
||||
$id = $json['id'];
|
||||
$status = $json['status'];
|
||||
if (strlen($id) < 1) {
|
||||
http_response_code(500);
|
||||
self::returnJson(['success' => false, 'message' => 'Lieferschein wurde nicht gefunden']);
|
||||
}
|
||||
|
||||
$shippingNote = (array) WarehouseShippingNoteModel::get($id);
|
||||
if ($shippingNote['status'] === 'accepted' || $shippingNote['status'] === 'invoiced') {
|
||||
http_response_code(500);
|
||||
self::returnJson(['success' => false, 'message' => 'Status kann nicht geändert werden']);
|
||||
}
|
||||
|
||||
$shippingNote['status'] = $status;
|
||||
WarehouseShippingNoteModel::update($shippingNote);
|
||||
self::returnJson(['success' => true, 'message' => 'Status wurde geändert']);
|
||||
}
|
||||
|
||||
//TODO: either move this to TimerecordingCarController or make it better
|
||||
protected function timerecordingCarAutoCompleteAction() {
|
||||
$timerecordingCars = array_map(function ($timerecordingCar) {
|
||||
|
||||
33
db/migrations/20241209130000_warehouse_modify_5.php
Normal file
33
db/migrations/20241209130000_warehouse_modify_5.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php /** @noinspection ALL */
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class WarehouseModify2 extends AbstractMigration {
|
||||
public function up(): void {
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$WarehouseHistory = $this->table("WarehouseHistory", ["signed" => true]);
|
||||
$WarehouseHistory->changeColumn("old_value", "text", ["null" => true]);
|
||||
$WarehouseHistory->changeColumn("new_value", "text", ["null" => true]);
|
||||
$WarehouseHistory->save();
|
||||
|
||||
}
|
||||
|
||||
if ($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$WarehouseHistory = $this->table("WarehouseHistory", ["signed" => true]);
|
||||
$WarehouseHistory->changeColumn("old_value", "string", ["null" => true, "limit" => 255]);
|
||||
$WarehouseHistory->changeColumn("new_value", "string", ["null" => true, "limit" => 255]);
|
||||
$WarehouseHistory->save();
|
||||
}
|
||||
|
||||
if ($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,10 @@
|
||||
grid-template-columns: 2fr 1fr 1fr 1fr 2fr 1fr 1fr;
|
||||
}
|
||||
|
||||
.warehouse-shipping-note-modal-hours-entry-container.hideHourlyPrice.hideKilometer {
|
||||
grid-template-columns: 2fr 1fr 1fr 1fr 2fr 1fr;
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.modal-lg, .modal-xl {
|
||||
/*max width either 90% or 1120px*/
|
||||
|
||||
@@ -52,14 +52,14 @@ Vue.component('warehouse-shipping-note-modal-hours-entry', {
|
||||
},
|
||||
//language=Vue
|
||||
template: `
|
||||
<div class="warehouse-shipping-note-modal-hours-entry-container" v-bind:class="{ 'hideHourlyPrice': !showHourlyPrice }">
|
||||
<div class="warehouse-shipping-note-modal-hours-entry-container" v-bind:class="{ 'hideHourlyPrice': !showHourlyPrice, 'hideKilometer': window.TT_CONFIG['WAREHOUSE_ADMIN'] != true }">
|
||||
<tt-autocomplete v-model="userId" :api-url="userApiUrl" label="Mitarbeiter" sm/>
|
||||
<tt-input v-model="date" label="Datum" type="date" sm/>
|
||||
<tt-input v-model="hourCount" label="Stunden" sm/>
|
||||
<tt-select v-model="priceType" label="Stundenart" sm :options="[{text: 'Normal', value: 'normal'}, {text: '+50%', value: '50'}, {text: '+100%', value: '100'}]"/>
|
||||
<tt-autocomplete v-model="carId" :api-url="carApiUrl" label="Fahrzeug" sm/>
|
||||
<tt-input v-model="hourlyPrice" label="Stundenlohn" type="number" sm v-if="showHourlyPrice"/>
|
||||
<tt-input :disabled="carId === ''" v-model="kilometerCount" label="Kilometer" sm/>
|
||||
<tt-input v-show="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true" :disabled="carId === ''" v-model="kilometerCount" label="Kilometer" sm/>
|
||||
<div class="warehouse-shipping-note-modal-hours-entry-actions">
|
||||
<button @click="createOrUpdate" class="btn btn-sm btn-primary">Speichern</button>
|
||||
</div>
|
||||
@@ -168,7 +168,7 @@ Vue.component('warehouse-shipping-note-modal-hours-view', {
|
||||
<td>{{ userNames[entry.userId] }}</td>
|
||||
<td>{{ window.moment(entry.date).format('DD.MM.YYYY') }}</td>
|
||||
<td>{{ entry.hourCount }}</td>
|
||||
<td>{{ entry.kilometerCount }}</td>
|
||||
<td v-show="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true">{{ entry.kilometerCount }}</td>
|
||||
<td v-if="showHourlyPrice">{{ entry.hourlyPrice }}</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-danger" @click="$emit('delete', entry)">Löschen</button>
|
||||
@@ -500,13 +500,13 @@ Vue.component('warehouse-shipping-note-modal', {
|
||||
</div>
|
||||
<!-- TODO: fix these buttons-->
|
||||
<template v-slot:footer-prepend v-if="id !== 'create'">
|
||||
<button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && status === 'new'" class="btn btn-warning" @click="alert('In Bearbeitung')">In
|
||||
<button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && status === 'new'" class="btn btn-warning" @click="changeStatus('in_progress')">In
|
||||
Bearbeitung
|
||||
</button>
|
||||
<button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && (status === 'new' || status === 'in_progress')" class="btn btn-success"
|
||||
@click="alert('Accepted')">Akzeptieren
|
||||
@click="changeStatus('accepted')">Akzeptieren
|
||||
</button>
|
||||
<button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && status === 'accepted'" class="btn btn-info" @click="alert('Invoiced')">
|
||||
<button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && status === 'accepted'" class="btn btn-info" @click="changeStatus('invoiced')">
|
||||
Verrechnet
|
||||
</button>
|
||||
<button class="btn btn-info" @click="$emit('open-signing-modal', id)">Unterschreiben</button>
|
||||
@@ -547,6 +547,16 @@ Vue.component('warehouse-shipping-note-modal', {
|
||||
this.window.notify('error', response.data.message || 'Ein Fehler ist aufgetreten');
|
||||
}
|
||||
},
|
||||
async changeStatus(newStatus) {
|
||||
const response = await axios.post(window.TT_CONFIG.BASE_PATH + '/WarehouseShippingNote/changeStatus', {id: this.id, status: newStatus});
|
||||
if (response.data.success) {
|
||||
this.window.notify('success', response.data.message || 'Erfolgreich aktualisiert');
|
||||
this.status = newStatus;
|
||||
this.$emit('close');
|
||||
} else {
|
||||
this.window.notify('error', response.data.message || 'Ein Fehler ist aufgetreten');
|
||||
}
|
||||
},
|
||||
async submit() {
|
||||
const data = {
|
||||
billingAddressId: this.billAddrId,
|
||||
|
||||
Reference in New Issue
Block a user