Merge branch 'fix-eshop-shipping-note' into 'master'
added articlenumber for article and shipping note See merge request fronk/thetool!799
This commit is contained in:
@@ -7,6 +7,7 @@ class WarehouseArticleController extends TTCrud {
|
||||
// @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],
|
||||
['key' => 'category', 'text' => 'Kategorie', 'required' => true],
|
||||
['key' => 'unit', 'text' => 'Einheit', 'required' => true,'table' => false], // Boolean value
|
||||
@@ -253,6 +254,48 @@ class WarehouseArticleController extends TTCrud {
|
||||
}
|
||||
}
|
||||
|
||||
protected function provArticleNumberImportAction() {
|
||||
// if method is post and file is set read the csv and var dump json and die
|
||||
// if method is get return basic html with a form to upload a file and a submit button
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['file'])) {
|
||||
$file = fopen($_FILES['file']['tmp_name'], 'r');
|
||||
$data = [];
|
||||
// parse csv as object with first row as keys as header and use key => value
|
||||
$firstRow = true;
|
||||
while (($row = fgetcsv($file)) !== false) {
|
||||
if ($firstRow) {
|
||||
$header = $row;
|
||||
$firstRow = false;
|
||||
continue;
|
||||
}
|
||||
$data[] = array_combine($header, $row);
|
||||
}
|
||||
|
||||
// loop through all the data and if PRODUKT 1.ZEILE is set and articleNumber is not set push the last 4 numbers of "EAN 13 Code" to articleNumber of the found article
|
||||
|
||||
foreach ($data as $item) {
|
||||
if (isset($item['PRODUKT 1.ZEILE'])) {
|
||||
$articles = WarehouseArticleModel::getAll(['title' => $item['PRODUKT 1.ZEILE']]);
|
||||
if (!empty($articles)) {
|
||||
$article = (array) WarehouseArticleModel::get($articles[0]->id);
|
||||
|
||||
$article['articleNumber'] = substr($item['EAN 13 Code'], -4);
|
||||
WarehouseArticleModel::update($article);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose($file);
|
||||
die(json_encode(['success' => true]));
|
||||
}
|
||||
|
||||
$html = '<html><head></head><body><form method="post" enctype="multipart/form-data"><input type="file" name="file"><input type="submit"></form></body></html>';
|
||||
echo $html;
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
protected function prepareOrderAction() {
|
||||
// inside post json it will look like
|
||||
// [
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class WarehouseArticleModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public string $title;
|
||||
public string $articleNumber;
|
||||
public string $description;
|
||||
public string $category;
|
||||
public ?float $cheapestPurchasePrice;
|
||||
|
||||
@@ -218,7 +218,7 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
foreach (json_decode($shippingNote->positions, true) as $position) {
|
||||
if (isset($position['article'])) {
|
||||
$article = WarehouseArticleModel::get($position['article']);
|
||||
$position['articleTitle'] = $article->title;
|
||||
$position['articleTitle'] = $article->articleNumber . " | " .$article->title;
|
||||
$position['articleDescription'] = $article->description === $article->title ? "" : $article->description;
|
||||
$position['articleUnit'] = $article->unit;
|
||||
$positions[] = $position;
|
||||
|
||||
31
db/migrations/20241210120000_warehouse_modify_6.php
Normal file
31
db/migrations/20241210120000_warehouse_modify_6.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php /** @noinspection ALL */
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class WarehouseModify6 extends AbstractMigration {
|
||||
public function up(): void {
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
// add articleNumber varchar 255 to the table WarehouseArticle
|
||||
$WarehouseArticle = $this->table("WarehouseArticle", ["signed" => true]);
|
||||
$WarehouseArticle->addColumn("articleNumber", "string", ["null" => false, "limit" => 255]);
|
||||
$WarehouseArticle->save();
|
||||
}
|
||||
|
||||
if ($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$WarehouseArticle = $this->table("WarehouseArticle", ["signed" => true]);
|
||||
$WarehouseArticle->removeColumn("articleNumber");
|
||||
$WarehouseArticle->save();
|
||||
}
|
||||
|
||||
if ($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
.warehouse-shipping-note-modal-positions-entry-container {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr 1fr 1fr;
|
||||
grid-template-columns: 2fr 1fr 0.5fr 1fr 1fr;
|
||||
grid-gap: 10px;
|
||||
}
|
||||
|
||||
.warehouse-shipping-note-modal-positions-entry-container.hidePrice {
|
||||
grid-template-columns: 2fr 1fr 1fr;
|
||||
grid-template-columns: 2fr 1fr 0.5fr 1fr;
|
||||
}
|
||||
|
||||
.warehouse-shipping-note-modal-positions-entry-actions, .warehouse-shipping-note-modal-hours-entry-actions {
|
||||
|
||||
@@ -264,6 +264,7 @@ Vue.component('warehouse-shipping-note-modal-positions-entry', {
|
||||
articlePacketId: '',
|
||||
amount: '',
|
||||
price: '',
|
||||
isEnergieMaterial: false,
|
||||
}
|
||||
},
|
||||
//language=Vue
|
||||
@@ -272,6 +273,7 @@ Vue.component('warehouse-shipping-note-modal-positions-entry', {
|
||||
<tt-autocomplete v-model="articleId" :api-url="articleApiUrl" label="Artikel" sm ref="article"/>
|
||||
<!-- <tt-autocomplete v-model="articlePacketId" :api-url="articlePacketApiUrl" label="Artikel Packet" sm/>-->
|
||||
<tt-input v-model="amount" label="Menge" sm/>
|
||||
<tt-checkbox v-model="isEnergieMaterial" label="Energie Material" sm/>
|
||||
<tt-input v-show="isAdmin" v-model="price" label="Preis" type="number" sm/>
|
||||
<div class="warehouse-shipping-note-modal-positions-entry-actions">
|
||||
<button @click="createOrUpdate" class="btn btn-sm btn-primary">Speichern</button>
|
||||
@@ -284,6 +286,7 @@ Vue.component('warehouse-shipping-note-modal-positions-entry', {
|
||||
if (!this.amount) return this.window.notify('error', 'Bitte füllen sie die Menge aus');
|
||||
const data = {
|
||||
amount: this.amount,
|
||||
isEnergieMaterial: this.isEnergieMaterial,
|
||||
price: parseFloat(this.price) ?? ''
|
||||
}
|
||||
if (isNaN(data.price)) data.price = '';
|
||||
@@ -335,6 +338,7 @@ Vue.component('warehouse-shipping-note-modal-positions-view', {
|
||||
<tr>
|
||||
<th>Artikel</th>
|
||||
<th>Menge</th>
|
||||
<th>Energie Material</th>
|
||||
<th v-if="isAdmin">Preis</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
@@ -348,6 +352,7 @@ Vue.component('warehouse-shipping-note-modal-positions-view', {
|
||||
position.articleText }}
|
||||
</td>
|
||||
<td>{{ position.amount }}</td>
|
||||
<td>{{ position?.isEnergieMaterial ? 'Ja' : 'Nein' }}</td>
|
||||
<td v-if="isAdmin">{{ (position.price?.toFixed(2)) }} €</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-danger" @click="$emit('delete', position)">Löschen</button>
|
||||
|
||||
@@ -25,6 +25,7 @@ Vue.component('tt-checkbox', {
|
||||
<div class="form-group" :class="{'row': row}">
|
||||
<slot name="prepend"></slot>
|
||||
<label
|
||||
style="width: 100%;text-align: center;"
|
||||
:class="{'col-form-label': row, 'col-sm-4': row, 'col-form-label-sm': sm && row}"
|
||||
v-if="label"
|
||||
:for="label">{{ label }}</label>
|
||||
|
||||
Reference in New Issue
Block a user