working
This commit is contained in:
parent
10ef24ffe0
commit
28f1b5e36a
977
src/new/composer.lock
generated
977
src/new/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -385,4 +385,12 @@ return [
|
|||||||
'@hotwired/turbo' => [
|
'@hotwired/turbo' => [
|
||||||
'version' => '7.3.0',
|
'version' => '7.3.0',
|
||||||
],
|
],
|
||||||
|
'tom-select/dist/css/tom-select.default.css' => [
|
||||||
|
'version' => '2.4.3',
|
||||||
|
'type' => 'css',
|
||||||
|
],
|
||||||
|
'tom-select/dist/css/tom-select.bootstrap4.css' => [
|
||||||
|
'version' => '2.4.3',
|
||||||
|
'type' => 'css',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -9,6 +9,10 @@ onMounted(() => {
|
|||||||
const globalStore = useGlobalStore()
|
const globalStore = useGlobalStore()
|
||||||
const params = new URLSearchParams(window.location.search)
|
const params = new URLSearchParams(window.location.search)
|
||||||
const uuid = params.get('uuid')
|
const uuid = params.get('uuid')
|
||||||
|
const shopUuid = params.get('shop')
|
||||||
|
const mode = params.get('mode')
|
||||||
|
globalStore.setProductUuid(shopUuid)
|
||||||
|
globalStore.setMode(mode)
|
||||||
if (uuid) {
|
if (uuid) {
|
||||||
globalStore.setProductUuid(uuid)
|
globalStore.setProductUuid(uuid)
|
||||||
globalStore.loadConfigFromProductApi(uuid).then(data => {
|
globalStore.loadConfigFromProductApi(uuid).then(data => {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ function addBorder(dep: Dependency) {
|
|||||||
<SelectValue placeholder="Select Relation" />
|
<SelectValue placeholder="Select Relation" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem v-for="item in itemStore.getItems" :value="item.id">{{item.id}}</SelectItem>
|
<SelectItem v-for="id in itemStore.getIdRecursiv" :value="id">{{id}}</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<Label for="formula">Formula</Label>
|
<Label for="formula">Formula</Label>
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useGlobalStore } from '../../../stores/Global'
|
import { useGlobalStore } from '../../../stores/Global'
|
||||||
import { Image, Rows3, TableCellsMerge, SquareParking, SquareDot, SquareMenu, SquarePen, SquareChevronDown, SquareDashed } from 'lucide-vue-next';
|
import { Image, Rows3, TableCellsMerge, SquareParking, SquareDot, SquareMenu, SquarePen, SquareChevronDown, SquareDashed, type LucideProps } from 'lucide-vue-next';
|
||||||
import { Switch } from '../../../components/ui/switch'
|
import { Switch } from '../../../components/ui/switch'
|
||||||
import { Label } from '../../../components/ui/label'
|
import { Label } from '../../../components/ui/label'
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch, h } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
const { locale } = useI18n()
|
const { locale, t } = useI18n()
|
||||||
const globalStore = useGlobalStore()
|
const globalStore = useGlobalStore()
|
||||||
|
|
||||||
let previewMode = ref(false)
|
let previewMode = ref(false)
|
||||||
@ -28,10 +28,41 @@ watch(previewMode, (newPreviewMode) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const libraryItems = ref([
|
||||||
|
{
|
||||||
|
category: 'cms_elements',
|
||||||
|
elements: [
|
||||||
|
{ id: '6', name: 'headline', icon: SquareDot },
|
||||||
|
{ id: '4', name: 'text', icon: SquareParking },
|
||||||
|
{ id: '9', name: 'media', icon: Image },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
category: 'form_elements',
|
||||||
|
elements: [
|
||||||
|
{ id: '5', name: 'textarea', icon: SquareMenu },
|
||||||
|
{ id: '2', name: 'input', icon: SquarePen },
|
||||||
|
{ id: '3', name: 'select', icon: SquareChevronDown },
|
||||||
|
{ id: '1', name: 'hidden', icon: SquareDashed },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
category: 'structure_elements',
|
||||||
|
elements: [
|
||||||
|
{ id: '12', name: 'fieldset', icon: Rows3 },
|
||||||
|
{ id: '7', name: 'row', icon: TableCellsMerge },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
const renderIcon = (icon: any) => {
|
||||||
|
return h(icon as any, { class: 'w-5 h-5' } as LucideProps);
|
||||||
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col p-3 gap-3 overflow-auto">
|
<div class="flex flex-col p-3 gap-3 overflow-y-auto">
|
||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<select v-model="locale">
|
<select v-model="locale">
|
||||||
@ -44,41 +75,18 @@ watch(previewMode, (newPreviewMode) => {
|
|||||||
<Label for="preview-mode">{{ $t('preview_mode') }}</Label>
|
<Label for="preview-mode">{{ $t('preview_mode') }}</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="headline" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '6')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<SquareDot />
|
<div v-for="group in libraryItems" :key="group.category">
|
||||||
<span>{{ $t('headline') }}</span>
|
<h3 class="font-bold my-2">{{ $t(group.category) }}</h3>
|
||||||
|
<div v-for="element in group.elements" :key="element.id"
|
||||||
|
class="border-1 p-2 w-full flex flex-row gap-2 cursor-grab"
|
||||||
|
draggable="true"
|
||||||
|
@dragstart="startDrag($event, element.id)"
|
||||||
|
@dragenter.prevent
|
||||||
|
@dragover.prevent>
|
||||||
|
<component :is="renderIcon(element.icon)" />
|
||||||
|
<span>{{ $t(element.name) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="text" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '4')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<SquareParking />
|
|
||||||
<span>{{ $t('text') }}</span>
|
|
||||||
</div>
|
|
||||||
<div id="fieldset" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '12')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<Rows3 />
|
|
||||||
<span>{{ $t('fieldset') }}</span>
|
|
||||||
</div>
|
|
||||||
<div id="media" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '9')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<Image />
|
|
||||||
<span>{{ $t('media') }}</span>
|
|
||||||
</div>
|
|
||||||
<div id="textarea" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '5')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<SquareMenu />
|
|
||||||
<span>{{ $t('textarea') }}</span>
|
|
||||||
</div>
|
|
||||||
<div id="input" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '2')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<SquarePen />
|
|
||||||
<span>{{ $t('input') }}</span>
|
|
||||||
</div>
|
|
||||||
<div id="select" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '3')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<SquareChevronDown />
|
|
||||||
<span>{{ $t('select') }}</span>
|
|
||||||
</div>
|
|
||||||
<div id="hidden" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '1')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<SquareDashed />
|
|
||||||
<span>{{ $t('hidden') }}</span>
|
|
||||||
</div>
|
|
||||||
<div id="row" class="border-1 p-2 w-full flex flex-row gap-2" draggable="true" @dragstart="startDrag($event, '7')" @dragenter.prevent @dragover.prevent>
|
|
||||||
<TableCellsMerge />
|
|
||||||
<span>{{ $t('row') }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -47,5 +47,8 @@
|
|||||||
"parameter_view": "Parameter Ansicht",
|
"parameter_view": "Parameter Ansicht",
|
||||||
"paperdb_view": "PapierDB Ansicht",
|
"paperdb_view": "PapierDB Ansicht",
|
||||||
"syncing": "Synchronisiere...",
|
"syncing": "Synchronisiere...",
|
||||||
"sync": "Synchronisieren"
|
"sync": "Synchronisieren",
|
||||||
|
"cms_elements": "CMS-Elemente",
|
||||||
|
"form_elements": "Formular-Elemente",
|
||||||
|
"structure_elements": "Struktur-Elemente"
|
||||||
}
|
}
|
||||||
@ -47,5 +47,8 @@
|
|||||||
"parameter_view": "Parameter View",
|
"parameter_view": "Parameter View",
|
||||||
"paperdb_view": "PaperDB View",
|
"paperdb_view": "PaperDB View",
|
||||||
"syncing": "Syncing...",
|
"syncing": "Syncing...",
|
||||||
"sync": "Sync"
|
"sync": "Sync",
|
||||||
|
"cms_elements": "CMS Elements",
|
||||||
|
"form_elements": "Form Elements",
|
||||||
|
"structure_elements": "Structure Elements"
|
||||||
}
|
}
|
||||||
@ -35,7 +35,9 @@ export default class BaseElement {
|
|||||||
}, [])
|
}, [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getIdRecursiv(list: []) {
|
||||||
|
|
||||||
|
}
|
||||||
fromJSON(obj: any) {
|
fromJSON(obj: any) {
|
||||||
this.id = obj.id
|
this.id = obj.id
|
||||||
this.type = obj.type
|
this.type = obj.type
|
||||||
|
|||||||
@ -32,7 +32,13 @@ export default class Column extends BaseElement {
|
|||||||
this.items.push(item)
|
this.items.push(item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
getIdRecursiv(list: []) {
|
||||||
|
this.items.forEach((item) => {
|
||||||
|
list.push(item.id);
|
||||||
|
item.getIdRecursiv(list)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
cutItem(existingUuid: string) {
|
cutItem(existingUuid: string) {
|
||||||
let item: BaseElement | null = null;
|
let item: BaseElement | null = null;
|
||||||
this.items.forEach((element: BaseElement, indexArray: number) => {
|
this.items.forEach((element: BaseElement, indexArray: number) => {
|
||||||
|
|||||||
@ -34,7 +34,13 @@ export default class FieldsetElement extends BaseElement {
|
|||||||
this.items.push(item)
|
this.items.push(item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
getIdRecursiv(list: []) {
|
||||||
|
this.items.forEach((item) => {
|
||||||
|
list.push(item.id);
|
||||||
|
item.getIdRecursiv(list)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
cutItem(existingUuid: string) {
|
cutItem(existingUuid: string) {
|
||||||
let item: BaseElement | null = null;
|
let item: BaseElement | null = null;
|
||||||
this.items.forEach((element: BaseElement, indexArray: number) => {
|
this.items.forEach((element: BaseElement, indexArray: number) => {
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
enum Mode {
|
||||||
|
Product = 1,
|
||||||
|
CMS = 2,
|
||||||
|
News = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Mode
|
||||||
@ -16,6 +16,11 @@ export default class Row extends BaseElement {
|
|||||||
addColumnAtTheBeginning(column: Column) {
|
addColumnAtTheBeginning(column: Column) {
|
||||||
this.columns.unshift(column)
|
this.columns.unshift(column)
|
||||||
}
|
}
|
||||||
|
getIdRecursiv(list: []) {
|
||||||
|
this.columns.forEach((column) => {
|
||||||
|
column.getIdRecursiv(list)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
deleteColumnAt(targetUuid: string): boolean {
|
deleteColumnAt(targetUuid: string): boolean {
|
||||||
return this.columns.some((element: BaseElement, indexArray: number) => {
|
return this.columns.some((element: BaseElement, indexArray: number) => {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import BaseElement from '../model/BaseElement'
|
import BaseElement from '../model/BaseElement'
|
||||||
|
import Mode from '../model/Mode'
|
||||||
import { saveProductToApi, saveFomulasAndParameterToApi, loadJsonFromApi, loadPriceFromApi, savePaperContainerToApi, saveDesignToApi, saveXmlToApi } from '../lib/api'
|
import { saveProductToApi, saveFomulasAndParameterToApi, loadJsonFromApi, loadPriceFromApi, savePaperContainerToApi, saveDesignToApi, saveXmlToApi } from '../lib/api'
|
||||||
import { useItemStore } from './Items'
|
import { useItemStore } from './Items'
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ export const useGlobalStore = defineStore('global', {
|
|||||||
paperContainer: "",
|
paperContainer: "",
|
||||||
parameter: "",
|
parameter: "",
|
||||||
shopUuid: "",
|
shopUuid: "",
|
||||||
|
mode: Mode.Product,
|
||||||
saving: false,
|
saving: false,
|
||||||
syncing: false,
|
syncing: false,
|
||||||
currentTab: 'designer' as string | number,
|
currentTab: 'designer' as string | number,
|
||||||
@ -50,6 +52,9 @@ export const useGlobalStore = defineStore('global', {
|
|||||||
setParameter(value: string) {
|
setParameter(value: string) {
|
||||||
this.parameter = value
|
this.parameter = value
|
||||||
},
|
},
|
||||||
|
setMode(value: Number) {
|
||||||
|
this.mode = value
|
||||||
|
},
|
||||||
setJson(value: string) {
|
setJson(value: string) {
|
||||||
this.json = value
|
this.json = value
|
||||||
},
|
},
|
||||||
@ -77,6 +82,9 @@ export const useGlobalStore = defineStore('global', {
|
|||||||
setDragMode(mode: string) {
|
setDragMode(mode: string) {
|
||||||
this.dragMode = mode
|
this.dragMode = mode
|
||||||
},
|
},
|
||||||
|
setShopUuid(value: string) {
|
||||||
|
this.shopUuid = value
|
||||||
|
},
|
||||||
async loadConfigFromProductApi(uuid: string) {
|
async loadConfigFromProductApi(uuid: string) {
|
||||||
const data: any = await loadJsonFromApi(uuid)
|
const data: any = await loadJsonFromApi(uuid)
|
||||||
this.json = data.json
|
this.json = data.json
|
||||||
|
|||||||
@ -11,6 +11,14 @@ export const useItemStore = defineStore('items', {
|
|||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getCount: (state) => state.items.length,
|
getCount: (state) => state.items.length,
|
||||||
|
getIdRecursiv(state) {
|
||||||
|
let list = []
|
||||||
|
state.items.forEach((item) => {
|
||||||
|
list.push(item.id);
|
||||||
|
item.getIdRecursiv(list)
|
||||||
|
})
|
||||||
|
return list
|
||||||
|
},
|
||||||
getItems: (state) => state.items,
|
getItems: (state) => state.items,
|
||||||
getUuid: (state) => state.uuid,
|
getUuid: (state) => state.uuid,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export default defineConfig({
|
|||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
configure: (proxy) => {
|
configure: (proxy) => {
|
||||||
proxy.on('proxyReq', (proxyReq) => {
|
proxy.on('proxyReq', (proxyReq) => {
|
||||||
proxyReq.setHeader('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTM5NjM0MjksImV4cCI6MTc1Mzk2NzAyOSwicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU0hPUF9PUEVSQVRPUiIsIlJPTEVfVVNFUiIsIlJPTEVfVVNFUiIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9FZGl0IiwiUk9MRV9QU0NfQ29sbGVjdF9Db250YWN0X0FkZCIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9EZWxldGUiLCJST0xFX1BTQ19Db2xsZWN0X0NvbnRhY3RfTG9jayIsIlJPTEVfUFNDX1IyX1NlbmRjbG91ZF9TaG93Il0sInVpZCI6MX0.OdEjvrvnZQs5Rty_t5gPIr7N4FV4Sq8KWvWDD76qHiIcLdj89IGtShFfFBUk4jtF6Y4heS7uDOAsTuY1KhhiusCPp9zXhCne3HoygK5EQPQ72u9LkMghpuGjStBVAPECaxoxufSfoKYAmBl7D3bcowZ8rfx2fKRwWl0vDWO7Vj9uu2cf3HrRzNl4zrbJMk0xtrQjPs5zF5j1AFSnd2OpYU7j3od5GPZqmQPZofd-vhbO85eMyDpaucJ7UMsef8G1Gq0TO6CBh1Hg7hqCXVX_nDKhhNz4Hi26DqK6GjX8a4AkJFeyfCxictYsAvIQsEmhL8oP52WcXdRV3Tqr2RwaSw');
|
proxyReq.setHeader('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTQzMjQwMzAsImV4cCI6MTc1NDMyNzYzMCwicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU0hPUF9PUEVSQVRPUiIsIlJPTEVfVVNFUiIsIlJPTEVfVVNFUiIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9FZGl0IiwiUk9MRV9QU0NfQ29sbGVjdF9Db250YWN0X0FkZCIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9EZWxldGUiLCJST0xFX1BTQ19Db2xsZWN0X0NvbnRhY3RfTG9jayIsIlJPTEVfUFNDX1IyX1NlbmRjbG91ZF9TaG93Il0sInVpZCI6MX0.JQV0pGK1C_9sL4-0zLlXBzwMV8tUwCLis9KDUC_5DVOZf8Ujb0Yqgmie9B9DISAGvjtWUSvuUzcbcsV4m2gkNN-6dar-Y6XCC54KbkVCAOhssMp3KsZ1pbCiZ_VdUt78WbAFMkvhToHjjdpD4KqhetQjqFlGF1jYXfJmFzRDHh0YnUfYZDsqgun423JeUXbRYB0sJ3FLQzCuyUDWFvdsQVwCGsgs0ffkro42qMbLXZtdRPaAPZTlEYbE5H-wck1iKvAeEgNuqGJEnk-oEy6UQ1mGUHz7NT5N7NmXhkca2byInCMXhDPn2tmQvte5AKUAte0GELt3FjF5rhk1Iu2rZw');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
287
src/new/var/plugins/System/PSC/XmlCalc/Api/Product/Preview.php
Normal file
287
src/new/var/plugins/System/PSC/XmlCalc/Api/Product/Preview.php
Normal file
@ -0,0 +1,287 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Plugin\System\PSC\XmlCalc\Api\Product;
|
||||||
|
|
||||||
|
use Doctrine\ODM\MongoDB\DocumentManager;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
|
use OpenApi\Annotations as OA;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\Display\Group as DisplayGroup;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\PreCalc\Group;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\PreCalc\Value;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\PreCalc\Variant;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Element;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Option;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Max as PluginMax;
|
||||||
|
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Min;
|
||||||
|
use PSC\Library\Calc\Engine;
|
||||||
|
use PSC\Library\Calc\Error\Validation\Input\Max;
|
||||||
|
use PSC\Library\Calc\Error\Validation\Input\Min as PSCMin;
|
||||||
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
|
use PSC\Library\Calc\Option\Type\ColorDBSelect;
|
||||||
|
use PSC\Library\Calc\Option\Type\DeliverySelect;
|
||||||
|
use PSC\Library\Calc\Option\Type\Select\Opt;
|
||||||
|
use PSC\Library\Calc\PaperContainer;
|
||||||
|
use PSC\Shop\ContactBundle\Model\Contact;
|
||||||
|
use PSC\Shop\ContactBundle\Transformer\Model\Contact as ContactTransformer;
|
||||||
|
use PSC\Shop\EntityBundle\Entity\Product;
|
||||||
|
use PSC\System\SettingsBundle\Service\Help;
|
||||||
|
use PSC\System\SettingsBundle\Service\PaperDB;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
|
class Preview extends AbstractController
|
||||||
|
{
|
||||||
|
private \PSC\System\SettingsBundle\Service\Shop $shopService;
|
||||||
|
/**
|
||||||
|
* @var DocumentManager
|
||||||
|
*/
|
||||||
|
private DocumentManager $documentManager;
|
||||||
|
/**
|
||||||
|
* @var PaperDB
|
||||||
|
*/
|
||||||
|
private PaperDB $paperDB;
|
||||||
|
/**
|
||||||
|
* @var EntityManagerInterface
|
||||||
|
*/
|
||||||
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
|
private TokenStorageInterface $tokenStorage;
|
||||||
|
private ContactTransformer $contactTransformer;
|
||||||
|
|
||||||
|
private Help $helpService;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
\PSC\System\SettingsBundle\Service\Shop $shopService,
|
||||||
|
DocumentManager $documentManager,
|
||||||
|
EntityManagerInterface $entityManager,
|
||||||
|
PaperDB $paperDB,
|
||||||
|
ContactTransformer $contactTransformer,
|
||||||
|
TokenStorageInterface $tokenStorage,
|
||||||
|
Help $helpService,
|
||||||
|
) {
|
||||||
|
$this->shopService = $shopService;
|
||||||
|
$this->documentManager = $documentManager;
|
||||||
|
$this->entityManager = $entityManager;
|
||||||
|
$this->tokenStorage = $tokenStorage;
|
||||||
|
$this->paperDB = $paperDB;
|
||||||
|
$this->contactTransformer = $contactTransformer;
|
||||||
|
$this->helpService = $helpService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get price
|
||||||
|
*
|
||||||
|
* @OA\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="orders",
|
||||||
|
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Dto\Output\PriceOutput::class))
|
||||||
|
* )
|
||||||
|
* @OA\RequestBody(
|
||||||
|
*
|
||||||
|
* @Model(type=\Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput::class))
|
||||||
|
* )
|
||||||
|
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Price")
|
||||||
|
*/
|
||||||
|
#[Route(path: '/product/preview', methods: ['POST'])]
|
||||||
|
#[ParamConverter(
|
||||||
|
'data',
|
||||||
|
class: '\Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput',
|
||||||
|
converter: 'psc_rest.request_body',
|
||||||
|
)]
|
||||||
|
public function preview(PriceInput $data)
|
||||||
|
{
|
||||||
|
$output = new \Plugin\System\PSC\XmlCalc\Dto\Output\PriceOutput();
|
||||||
|
$output->product = $data->product;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Product $product
|
||||||
|
*/
|
||||||
|
$product = $this->entityManager
|
||||||
|
->getRepository('PSC\Shop\EntityBundle\Entity\Product')
|
||||||
|
->findOneBy(['uuid' => $data->product]);
|
||||||
|
|
||||||
|
$paperContainer = new PaperContainer();
|
||||||
|
$paperContainer->parse(simplexml_load_string($product->getShop()->getInstall()->getPaperContainer()));
|
||||||
|
$engine = new Engine();
|
||||||
|
$engine->setPaperRepository($this->paperDB);
|
||||||
|
$engine->setPaperContainer($paperContainer);
|
||||||
|
if ($product->getShop()->getInstall()->getCalcTemplates() && !$data->test) {
|
||||||
|
$engine->setTemplates('<root>' . $product->getShop()->getInstall()->getCalcTemplates() . '</root>');
|
||||||
|
}
|
||||||
|
if ($product->getShop()->getInstall()->getCalcTemplatesTest() && $data->test) {
|
||||||
|
$engine->setTemplates('<root>' . $product->getShop()->getInstall()->getCalcTemplatesTest() . '</root>');
|
||||||
|
}
|
||||||
|
$engine->loadString($product->getCalcXml());
|
||||||
|
if (!$data->test) {
|
||||||
|
$engine->setFormulas($product->getShop()->getFormel());
|
||||||
|
$engine->setParameters($product->getShop()->getParameter());
|
||||||
|
}
|
||||||
|
if ($data->test) {
|
||||||
|
$engine->setFormulas($product->getShop()->getTestFormel());
|
||||||
|
$engine->setParameters($product->getShop()->getTestParameter());
|
||||||
|
}
|
||||||
|
$engine->setVariables($data->values);
|
||||||
|
$engine->setTax($product->getMwert());
|
||||||
|
if ($this->tokenStorage->getToken()) {
|
||||||
|
$contact = new Contact();
|
||||||
|
$this->contactTransformer->fromDb($contact, $this->tokenStorage->getToken()->getUser());
|
||||||
|
$engine->setVariable('contact.accountType', $contact->getAccountType()->value);
|
||||||
|
$engine->setVariable('contact.account', $contact->getAccount()->getUid());
|
||||||
|
}
|
||||||
|
if ($data->xmlProduct != '') {
|
||||||
|
$engine->setActiveArticle($data->xmlProduct);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($engine->getArticle()->getDisplayGroups() as $group) {
|
||||||
|
$groupObj = new DisplayGroup();
|
||||||
|
$groupObj->id = $group->getId();
|
||||||
|
$groupObj->name = $group->getName();
|
||||||
|
$output->displayGroups[] = $groupObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->netto = $engine->getPrice() * 100;
|
||||||
|
$output->steuer = $engine->getTaxPrice() * 100;
|
||||||
|
$output->brutto = $engine->getCompletePrice() * 100;
|
||||||
|
$output->xmlProduct = $engine->getArticle()->getName();
|
||||||
|
$output->weight = $engine->getWeight();
|
||||||
|
$output->weightSingle = $engine->getWeightSingle();
|
||||||
|
|
||||||
|
foreach ($engine->getArticles() as $article) {
|
||||||
|
$output->xmlProductTypes[] = $article->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Base $option
|
||||||
|
*/
|
||||||
|
foreach ($engine->getArticle()->getOptions() as $option) {
|
||||||
|
$tmp = new Element();
|
||||||
|
$tmp->name = $option->getName();
|
||||||
|
$tmp->required = $option->isRequire();
|
||||||
|
if (is_array($option->getRawValue())) {
|
||||||
|
$tmp->rawValues = $option->getRawValue();
|
||||||
|
} else {
|
||||||
|
$tmp->rawValue = $option->getRawValue();
|
||||||
|
}
|
||||||
|
if ($option->getDefault()) {
|
||||||
|
$tmp->defaultValue = $option->getDefault();
|
||||||
|
}
|
||||||
|
$tmp->value = $option->getValue();
|
||||||
|
|
||||||
|
if ($help = $this->helpService->getHelp((string) $product->getUid(), $option->getId())) {
|
||||||
|
$tmp->help = $help->helpText;
|
||||||
|
$tmp->helpTitle = $help->helpTitle;
|
||||||
|
} else {
|
||||||
|
$tmp->help = $option->getHelp();
|
||||||
|
$tmp->helpLink = $option->getHelpLink();
|
||||||
|
}
|
||||||
|
$tmp->id = $option->getId();
|
||||||
|
$tmp->valid = $option->isValid();
|
||||||
|
$tmp->htmlType = $option->type;
|
||||||
|
$tmp->displayGroup = $option->getDisplayGroup();
|
||||||
|
|
||||||
|
if ($option->type == 'select' || $option->type == 'checkbox' || $option->type == 'radio') {
|
||||||
|
/**
|
||||||
|
* @var Opt $option
|
||||||
|
*/
|
||||||
|
if ($option instanceof ColorDBSelect) {
|
||||||
|
$tmp->colorSystem = $option->getColorSystem();
|
||||||
|
if (!isset($output->colorDb[$option->getColorSystem()])) {
|
||||||
|
$output->colorDb[$option->getColorSystem()] = [];
|
||||||
|
foreach ($option->getOptions() as $opt) {
|
||||||
|
$element = array_find((array) $option->getSelectedOptions(), function (Opt $o1) use ($opt) {
|
||||||
|
return $o1->getId() === $opt->getId();
|
||||||
|
});
|
||||||
|
$tmpOpt = new Option();
|
||||||
|
$tmpOpt->id = $opt->getId();
|
||||||
|
$tmpOpt->name = $opt->getLabel();
|
||||||
|
$tmpOpt->prefix = $opt->getPrefix();
|
||||||
|
$tmpOpt->suffix = $opt->getSuffix();
|
||||||
|
$tmpOpt->valid = $opt->isValid();
|
||||||
|
$tmpOpt->selected = $element ? true : false;
|
||||||
|
$output->colorDb[$option->getColorSystem()][] = $tmpOpt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($option->getOptions() as $opt) {
|
||||||
|
$element = array_find((array) $option->getSelectedOptions(), function (Opt $o1) use ($opt) {
|
||||||
|
return $o1->getId() === $opt->getId();
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($option instanceof DeliverySelect) {
|
||||||
|
$tmpOpt = new Option();
|
||||||
|
$tmpOpt->id = $opt->getId();
|
||||||
|
$tmpOpt->name = $opt->getLabel();
|
||||||
|
$tmpOpt->valid = $opt->isValid();
|
||||||
|
$tmpOpt->selected = $element ? true : false;
|
||||||
|
$tmpOpt->info = $opt->getInfo();
|
||||||
|
$tmpOpt->deliveryDate = $opt->getDeliveryDateAsString();
|
||||||
|
} else {
|
||||||
|
$tmpOpt = new Option();
|
||||||
|
$tmpOpt->id = $opt->getId();
|
||||||
|
$tmpOpt->name = $opt->getLabel();
|
||||||
|
$tmpOpt->valid = $opt->isValid();
|
||||||
|
$tmpOpt->selected = $element ? true : false;
|
||||||
|
}
|
||||||
|
$tmp->options[] = $tmpOpt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($option->type == 'input') {
|
||||||
|
$tmp->minValue = $option->getMinValue();
|
||||||
|
$tmp->maxValue = $option->getMaxValue();
|
||||||
|
$tmp->placeHolder = $option->getPlaceHolder();
|
||||||
|
$tmp->pattern = $option->getPattern();
|
||||||
|
foreach ($option->getValidationErrors() as $error) {
|
||||||
|
if ($error instanceof PSCMin) {
|
||||||
|
$tmp->validationErrors[] = new Min($tmp->value, $option->getMinValue());
|
||||||
|
}
|
||||||
|
if ($error instanceof Max) {
|
||||||
|
$tmp->validationErrors[] = new PluginMax($tmp->value, $option->getMaxValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->elements[] = $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($engine->getArticle()->getPreCalc()->getGroups() as $group) {
|
||||||
|
$groupObj = new Group();
|
||||||
|
$groupObj->name = $group->getName();
|
||||||
|
foreach ($group->getVariants() as $variant) {
|
||||||
|
$variantObj = new Variant();
|
||||||
|
$variantObj->name = $variant->getName();
|
||||||
|
$variantObj->text = $variant->getText();
|
||||||
|
$variantObj->data = $variant->getData();
|
||||||
|
foreach ($variant->getValues() as $value) {
|
||||||
|
$valueObj = new Value();
|
||||||
|
$valueObj->key = $value->getKey();
|
||||||
|
$valueObj->value = $value->getValue();
|
||||||
|
$variantObj->values[] = $valueObj;
|
||||||
|
}
|
||||||
|
$groupObj->variants[] = $variant;
|
||||||
|
}
|
||||||
|
$output->preCalc[] = $groupObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->displayValues = $engine->getDisplayVariables();
|
||||||
|
$output->exportValues = $engine->getAjaxVariables();
|
||||||
|
|
||||||
|
if ($this->isGranted('ROLE_SHOP')) {
|
||||||
|
$output->debug['formels'] = $engine->getDebugCalcFormel();
|
||||||
|
$output->debug['flatPrice'] = $engine->getDebugFlatPrice();
|
||||||
|
$output->debug['price'] = $engine->getDebugPrice();
|
||||||
|
$output->debug['calcValues'] = $engine->getDebugCalcVariables();
|
||||||
|
$output->debug['graphJson'] = $engine->getCalcGraph()->generateJsonGraph();
|
||||||
|
}
|
||||||
|
return $this->json($output);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4182,7 +4182,11 @@ class UserController extends TP_Controller_Action
|
|||||||
$_authAdapter->setIdentity($vars[0]);
|
$_authAdapter->setIdentity($vars[0]);
|
||||||
$result = Zend_Auth::getInstance()->authenticate($_authAdapter);
|
$result = Zend_Auth::getInstance()->authenticate($_authAdapter);
|
||||||
|
|
||||||
Zend_Registry::set('browser_form_post_url', urldecode($vars[2]));
|
$_SESSION['browser_form_post_url'] = urldecode($vars[2]);
|
||||||
|
$_SESSION['from_identity'] = urldecode($vars[3]);
|
||||||
|
$_SESSION['to_identity'] = urldecode($vars[4]);
|
||||||
|
$_SESSION['sender_domain'] = urldecode($vars[5]);
|
||||||
|
$_SESSION['sender_identity'] = urldecode($vars[6]);
|
||||||
|
|
||||||
if ($result->isValid()) {
|
if ($result->isValid()) {
|
||||||
return $this->redirectSpeak('/');
|
return $this->redirectSpeak('/');
|
||||||
@ -4228,8 +4232,18 @@ class UserController extends TP_Controller_Action
|
|||||||
$basepath .
|
$basepath .
|
||||||
'/user/xmllogin?contact=' .
|
'/user/xmllogin?contact=' .
|
||||||
$contact->id .
|
$contact->id .
|
||||||
'*nsWXSoLmx8TNEjdE8fbn*' .
|
'*' .
|
||||||
|
'nsWXSoLmx8TNEjdE8fbn' .
|
||||||
|
'*' .
|
||||||
urlencode((string) $xml->Request->PunchOutSetupRequest->BrowserFormPost->URL) .
|
urlencode((string) $xml->Request->PunchOutSetupRequest->BrowserFormPost->URL) .
|
||||||
|
'*' .
|
||||||
|
urlencode((string) $xml->Header->From->Credential->Identity) .
|
||||||
|
'*' .
|
||||||
|
urlencode((string) $xml->Header->To->Credential->Identity) .
|
||||||
|
'*' .
|
||||||
|
urlencode((string) $xml->Header->Sender->Credential['domain']) .
|
||||||
|
'*' .
|
||||||
|
urlencode((string) $xml->Header->Sender->Credential->Identity) .
|
||||||
'</URL>' .
|
'</URL>' .
|
||||||
'</StartPage>' .
|
'</StartPage>' .
|
||||||
'</PunchOutSetupResponse>' .
|
'</PunchOutSetupResponse>' .
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user