mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 12:07:15 +01:00
Small fixes and selectable separator when creating variants
This commit is contained in:
parent
95cb03f43b
commit
aad77a350d
@ -16,6 +16,7 @@ class ArticleService
|
||||
function CopyArticle(int $id, bool $purchasePrices, bool $sellingPrices, bool $files, bool $properties,
|
||||
bool $instructions, bool $partLists, bool $customFields, string $newArticleNumber = '')
|
||||
{
|
||||
$newArticleNumber = $this->app->DB->real_escape_string($newArticleNumber);
|
||||
$this->app->DB->MysqlCopyRow('artikel','id',$id);
|
||||
|
||||
$idnew = $this->app->DB->GetInsertID();
|
||||
@ -26,7 +27,7 @@ class ArticleService
|
||||
$this->app->DB->Update("UPDATE artikel SET steuersatz = '$steuersatz' WHERE id = '$idnew' LIMIT 1");
|
||||
}
|
||||
|
||||
$this->app->DB->Update("UPDATE artikel SET nummer='$newArticleNumber' WHERE id='$idnew' LIMIT 1");
|
||||
$this->app->DB->Update("UPDATE artikel SET nummer='$newArticleNumber', matrixprodukt = 0 WHERE id='$idnew' LIMIT 1");
|
||||
if($this->app->DB->Select("SELECT variante_kopie FROM artikel WHERE id = '$id' LIMIT 1"))
|
||||
$this->app->DB->Update("UPDATE artikel SET variante = 1, variante_von = '$id' WHERE id = '$idnew' LIMIT 1");
|
||||
|
||||
|
@ -130,13 +130,26 @@ final class MatrixProductService
|
||||
foreach ($optionArr as $option) {
|
||||
$groupId = $this->gateway->GetArticleGroupIdByName($articleId, $option['groupname']);
|
||||
if (!$groupId) {
|
||||
$obj = new Group($option['groupname'], nameExternal: $option['groupnameext'], projectId: $option['groupprojekt'], required: $option['grouprequired'], articleId: $articleId);
|
||||
$obj = new Group(
|
||||
name: $option['groupname'],
|
||||
nameExternal: $option['groupnameext'],
|
||||
projectId: $option['groupprojekt'],
|
||||
required: $option['grouprequired'],
|
||||
articleId: $articleId);
|
||||
$group = $this->gateway->InsertArticleGroup($obj);
|
||||
$groupId = $group->id;
|
||||
}
|
||||
$optionId = $this->gateway->GetArticleOptionIdByName($articleId, $groupId, $option['name']);
|
||||
if (!$optionId) {
|
||||
$obj = new Option($option['name'], $groupId, nameExternal: $option['name_ext'], sort: $option['sort'], globalOptionId: $option['id'], articleId: $articleId);
|
||||
$obj = new Option(
|
||||
name: $option['name'],
|
||||
groupId: $groupId,
|
||||
nameExternal: $option['name_ext'],
|
||||
sort: $option['sort'],
|
||||
articleNumber: $option['articlenumber'],
|
||||
articleNumberSuffix: $option['articlenumber_suffix'],
|
||||
globalOptionId: $option['id'],
|
||||
articleId: $articleId);
|
||||
$this->gateway->InsertArticleOption($obj);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import Button from "primevue/button";
|
||||
import Dialog from "primevue/dialog";
|
||||
import MultiSelect from "primevue/multiselect";
|
||||
import Fluid from "primevue/fluid";
|
||||
import InputText from "primevue/inputtext";
|
||||
import {onMounted, ref} from "vue";
|
||||
import axios from "axios";
|
||||
import {AlertErrorHandler} from "@res/js/ajaxErrorHandler";
|
||||
@ -41,6 +42,8 @@ async function save() {
|
||||
<Dialog visible modal header="Variante" style="width: 500px" @update:visible="emit('close')">
|
||||
<Fluid>
|
||||
<div class="grid gap-1" style="grid-template-columns: 25% 75%;" autofocus>
|
||||
<label>Trennzeichen:</label>
|
||||
<InputText v-model="model.separator" maxlength="2" />
|
||||
<template v-for="group in model.groups">
|
||||
<label>{{ group.name }}</label>
|
||||
<MultiSelect v-model="group.selected" :options="group.options" option-label="name" option-value="value"/>
|
||||
|
2
www/dist/.vite/manifest.json
vendored
2
www/dist/.vite/manifest.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"classes/Modules/MatrixProduct/www/js/entry.js": {
|
||||
"file": "modules/MatrixProduct-BFgn1wkj.js",
|
||||
"file": "modules/MatrixProduct-PtaGHDSi.js",
|
||||
"name": "modules/MatrixProduct",
|
||||
"src": "classes/Modules/MatrixProduct/www/js/entry.js",
|
||||
"isEntry": true,
|
||||
|
File diff suppressed because one or more lines are too long
@ -363,9 +363,10 @@ class Matrixprodukt
|
||||
$result[$option->groupId]['options'][] = ['value' => $option->id, 'name' => $option->name];
|
||||
$result[$option->groupId]['selected'][] = $option->id;
|
||||
}
|
||||
return new JsonResponse(['groups' => $result ?? []]);
|
||||
return new JsonResponse(['groups' => $result ?? [], 'separator' => '_']);
|
||||
} else {
|
||||
$json = $this->request->getJson();
|
||||
$separator = substr($json->separator ?? '_', 0, 2);
|
||||
$list = [[]];
|
||||
foreach ($json->groups as $group) {
|
||||
if (empty($group->selected))
|
||||
@ -373,18 +374,18 @@ class Matrixprodukt
|
||||
$newList = [];
|
||||
foreach ($list as $old) {
|
||||
foreach ($group->selected as $option) {
|
||||
$newList[] = array_merge($old, [$option]);
|
||||
$newList[] = array_merge($old, [(int)$option]);
|
||||
}
|
||||
}
|
||||
$list = $newList;
|
||||
}
|
||||
$oldnumber = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = $json->articleId");
|
||||
$oldnumber = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = (int)$json->articleId");
|
||||
$created = [];
|
||||
foreach ($list as $optionSet) {
|
||||
$variantId = $this->service->GetVariantIdByOptionSet($optionSet);
|
||||
if ($variantId)
|
||||
continue;
|
||||
$number = $oldnumber.'_'.$this->service->GetSuffixStringForOptionSet($optionSet);
|
||||
$number = $oldnumber.$separator.$this->service->GetSuffixStringForOptionSet($optionSet);
|
||||
$newId = $this->articleService->CopyArticle($json->articleId, true, true, true, true, true, true, true, $number);
|
||||
$this->service->SaveVariant($json->articleId, $newId, $optionSet);
|
||||
$created[] = $number;
|
||||
|
Loading…
Reference in New Issue
Block a user