diff options
| author | Daniel Schmitzer <noreply@maennchen1.de> | 2023-05-05 11:06:39 +0000 |
|---|---|---|
| committer | Daniel Schmitzer <noreply@maennchen1.de> | 2023-05-05 11:06:39 +0000 |
| commit | 8352f0594f5c6da5a1a7ca58b2ea490807768336 (patch) | |
| tree | 3f53da0566e19a400da222d42479eb2fcfbea70c /views | |
| parent | 8ee6278ddee7a0bbc8f0652b0626d4f170d78a3e (diff) | |
- Feature: Produktkombinationen für Varianten
- Feature: Productcodemanagement
- Feature: Positionsnummer für Produktgruppen
- Feature: Markierung wenn Produktgruppe aktiven Rabatt hat in Produktgruppenübersicht
git-svn-id: https://[internal]/wordpress/plugins/wpsg4@8280 0d5edaf7-2b12-4e95-93f4-047927463d4b
Diffstat (limited to 'views')
| -rw-r--r-- | views/mods/mod_productgroups/add.phtml | 1 | ||||
| -rw-r--r-- | views/mods/mod_productgroups/index.phtml | 4 | ||||
| -rw-r--r-- | views/mods/mod_productgroups/list.phtml | 36 | ||||
| -rw-r--r-- | views/mods/mod_productgroups/show_2.phtml | 6 | ||||
| -rw-r--r-- | views/mods/mod_productvariants/admin_edit.phtml | 8 | ||||
| -rw-r--r-- | views/mods/mod_productvariants/produkt_addedit_content.phtml | 582 | ||||
| -rw-r--r-- | views/mods/mod_rechnungen/invoice_pdf.phtml | 6 | ||||
| -rw-r--r-- | views/order/product_table.phtml | 9 | ||||
| -rw-r--r-- | views/produkt/addedit_productcodes.phtml | 145 | ||||
| -rw-r--r-- | views/produkttemplates/standard.phtml | 9 |
10 files changed, 472 insertions, 334 deletions
diff --git a/views/mods/mod_productgroups/add.phtml b/views/mods/mod_productgroups/add.phtml index 22983b0..2d304f6 100644 --- a/views/mods/mod_productgroups/add.phtml +++ b/views/mods/mod_productgroups/add.phtml @@ -69,6 +69,7 @@ <?php echo wpsg_drawForm_Select('template_file', __('Template', 'wpsg'), $this->view['templates'], $this->view['data']['template_file']); ?>
<?php echo wpsg_drawForm_Select('infopage', __('Info Seite', 'wpsg'), $this->view['pages'], $this->view['data']['infopage']); ?>
+ <?php echo wpsg_drawForm_Input('pos', __('Positionsnummer (Sortierung, aufsteigend)', 'wpsg'), $this->view['data']['pos']); ?>
<div class="form-group form-group-sm ">
<label class="col-sm-6 control-label"><?php echo __('Produktgruppenbild', 'wpsg'); ?></label>
diff --git a/views/mods/mod_productgroups/index.phtml b/views/mods/mod_productgroups/index.phtml index 18b19d1..b5cdc02 100644 --- a/views/mods/mod_productgroups/index.phtml +++ b/views/mods/mod_productgroups/index.phtml @@ -83,6 +83,7 @@ <th class="wpsg_pic_col"></th>
<th class="wpsg_order col_name" data-order="nr"><?php echo __("Name", 'wpsg'); ?></th>
<th class="wpsg_order col_template" data-order="template"><?php echo __("Template", 'wpsg'); ?></th>
+ <th class="wpsg_order col_pos" data-order="template"><?php echo __("Position", 'wpsg'); ?></th>
<th class="wpsg_order col_products" data-order="products"><?php echo __("Produkte", 'wpsg'); ?></th>
</tr>
</thead>
@@ -123,6 +124,9 @@ <td class="col_template">
<?php echo (($pg->template_file == "0")?'Individuelle Produkttemplates':$pg->template_file); ?>
</td>
+ <td class="col_pos">
+ <?php echo $pg->pos; ?>
+ </td>
<td class="col_products">
<?php echo $pg->countProducts(); ?>
</td>
diff --git a/views/mods/mod_productgroups/list.phtml b/views/mods/mod_productgroups/list.phtml index 440af68..fbdaeff 100644 --- a/views/mods/mod_productgroups/list.phtml +++ b/views/mods/mod_productgroups/list.phtml @@ -11,9 +11,17 @@ ?>
-<?php $c = 0; foreach ((array)$this->view['data'] as $k => $g) { ?>
+<?php $c = 0; foreach ((array)$this->view['data'] as $k => $g) {
+
+ $oProductgroup = wpsg_productgroup::getInstance(intval($k));
+
+ ?>
<?php //wpsg_debug($g) ?>
-<div class="wpsg_pgruppen_list_row">
+<div class="wpsg_pgruppen_list_row <?php
+
+ echo (($oProductgroup->hasActiveDiscount())?'active_discount':'');
+
+ ?>">
<div class="wpsg_pgruppen_list_titel">
<a href="<?php echo WPSG_URL_WP ?>?page_id=<?php echo get_the_ID(); ?>&show=<?php echo $k ?>">
<h2><?php echo $g['pgruppe_name'] ?></h2>
@@ -35,17 +43,19 @@ <?php } else { ?>
- <?php $image = array_rand($g['produkte'][$i]['bilder']); ?>
- <?php if ($image >= 0 && is_int($image)) { ?>
- <div class="wpsg_pgruppen_list_image">
-
- <a href="<?php echo $g['produkte'][$i]['url'] ?>">
- <?php echo wp_get_attachment_image($g['produkte'][$i]['bilder'][0], 'thumbnail', false, array()); ?>
- </a>
-
- </div>
- <?php } ?>
-
+ <?php if (sizeof($g['produkte'][$i]['bilder']??[]) > 0) { ?>
+ <?php $image = array_rand($g['produkte'][$i]['bilder']); ?>
+ <?php if ($image >= 0 && is_int($image)) { ?>
+ <div class="wpsg_pgruppen_list_image">
+
+ <a href="<?php echo $g['produkte'][$i]['url'] ?>">
+ <?php echo wp_get_attachment_image($g['produkte'][$i]['bilder'][0], 'thumbnail', false, array()); ?>
+ </a>
+
+ </div>
+ <?php } ?>
+ <?php } ?>
+
<?php } ?>
<?php } ?>
diff --git a/views/mods/mod_productgroups/show_2.phtml b/views/mods/mod_productgroups/show_2.phtml index 2f8eaef..5d5db54 100644 --- a/views/mods/mod_productgroups/show_2.phtml +++ b/views/mods/mod_productgroups/show_2.phtml @@ -50,7 +50,11 @@ if (intval($oProductgroup->__get('infopage')) > 0) echo \get_permalink(intval($oProductgroup->__get('infopage'))); else echo $page_url.'show='.$oProductgroup->getId(); - ?>" class="productgroup"> + ?>" class="productgroup <?php + + echo (($oProductgroup->hasActiveDiscount())?'active_discount':''); + + ?>"> <div class="title"><?php echo $oProductgroup->getLabel(); ?></div> diff --git a/views/mods/mod_productvariants/admin_edit.phtml b/views/mods/mod_productvariants/admin_edit.phtml index ebfc9a6..57f7ddb 100644 --- a/views/mods/mod_productvariants/admin_edit.phtml +++ b/views/mods/mod_productvariants/admin_edit.phtml @@ -37,7 +37,7 @@ <?php $colspan += 3; ?>
<?php if (wpsg_isSizedInt($this->view['product_id'])) { $colspan += 2; ?>
- <th class="col_artnr"><?php echo __('Artikelnummer', 'wpsg'); ?></th>
+ <!--<th class="col_artnr"><?php echo __('Artikelnummer', 'wpsg'); ?></th>-->
<th class="col_price"><?php echo __('Preis', 'wpsg'); ?></th>
<?php if ($this->hasMod('wpsg_mod_stock')) { ?>
@@ -170,7 +170,7 @@ <td class="col_shortname"><span class="wpsg_editable" id="productvariation_shortname_<?php echo $vari['id']; ?>"><?php echo wpsg_hspc($vari['shortname']); ?></span></td>
<?php if (wpsg_isSizedInt($this->view['product_id'])) { ?>
- <td class="col_artnr"><span class="wpsg_editable" id="productvariation_anr_<?php echo $vari['id']; ?>"><?php echo wpsg_hspc($vari['anr']); ?></span></td>
+ <!--<td class="col_artnr"><span class="wpsg_editable" id="productvariation_anr_<?php echo $vari['id']; ?>"><?php echo wpsg_hspc($vari['anr']); ?></span></td>-->
<td class="col_price"><span class="wpsg_editable" id="productvariation_price_<?php echo $vari['id']; ?>"><?php echo wpsg_hspc(wpsg_ff($vari['price'], $this->get_option('wpsg_currency'))); ?></span></td>
<?php if ($this->hasMod('wpsg_mod_stock')) { ?>
@@ -316,7 +316,7 @@ </div>
<?php } ?>
- <?php if (wpsg_isSizedInt($this->view['product_id'])) { ?>
+ <?php /* if (wpsg_isSizedInt($this->view['product_id'])) { ?>
<div style="margin-top:0.25rem;">
<span>EAN:
<span title="<?php echo __('EAN der Produktvariation', 'wpsg'); ?>" class="wpsg_editable" id="productvariation_ean_<?php echo $vari['id']; ?>"><?php echo $vari['ean']??''; ?></span>
@@ -333,7 +333,7 @@ </script>
</div>
- <?php } ?>
+ <?php } */ ?>
<script>
diff --git a/views/mods/mod_productvariants/produkt_addedit_content.phtml b/views/mods/mod_productvariants/produkt_addedit_content.phtml index 50de7b4..657cd21 100644 --- a/views/mods/mod_productvariants/produkt_addedit_content.phtml +++ b/views/mods/mod_productvariants/produkt_addedit_content.phtml @@ -51,8 +51,13 @@ <div class="panel-heading clearfix">
<h3 class="panel-title">
{{combination.label}}
- <span v-if="combination.id > 0" class="glyphicon glyphicon-pencil" @click.prevent="edit(combination)"></span>
- <span v-else class="glyphicon glyphicon-plus" @click.prevent="add(combination)"></span>
+ <div class="right">
+ <a :href="combination.url" target="_blank" class="url" title="<?php echo __('Produktvariante im Frontend ansehen', 'wpsg'); ?>">
+ <span class="glyphicon glyphicon-new-window"></span>
+ </a>
+ <span v-if="combination.id > 0" class="glyphicon glyphicon-pencil" @click.prevent="edit(combination)"></span>
+ <span v-else class="glyphicon glyphicon-plus" @click.prevent="add(combination)"></span>
+ </div>
</h3>
</div>
<div class="panel-body" v-if="combination.loaded">
@@ -62,113 +67,76 @@ </div>
<div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">Artikelnummer</label>
+ <label class="col-sm-6 control-label" for="name">Produktname</label>
<div class="col-sm-6">
<div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.anr" />
+ <input type="text"
+ @keydown.enter.prevent
+ class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.name" />
</div>
</div>
<div class="clearfix wpsg_clear"></div>
</div>
- <!-- EAN -->
<div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">EAN (European Article Number)</label>
+ <label class="col-sm-6 control-label" for="detailname">Produktname (Detail)</label>
<div class="col-sm-6">
<div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.ean" maxlength="13" />
+ <input type="text"
+ @keydown.enter.prevent
+ class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.detailname" />
</div>
</div>
<div class="clearfix wpsg_clear"></div>
</div>
- <!-- GTIN -->
<div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">GTIN (Global Trade Item Number)</label>
+ <label class="col-sm-6 control-label" for="anr">Artikelnummer</label>
<div class="col-sm-6">
<div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.gtin" />
+ <input type="text"
+ @keydown.enter.prevent
+ class="form-control input-sm" autocomplete="off" placeholder="" v-model="combination.anr" />
</div>
</div>
<div class="clearfix wpsg_clear"></div>
</div>
-
- <!-- MPN -->
- <div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">MPN (Manufacturer Part Number)</label>
- <div class="col-sm-6">
- <div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.mpn" />
+
+ <!-- Productcodes -->
+ <template v-if="codeKeyNotSet(combination).length > 0">
+ <div class="form-group form-group-sm has-feedback">
+ <label class="col-sm-6 control-label" for="metaean">Code hinzufügen</label>
+ <div class="col-sm-6">
+ <div class="wpsg_field_wrap">
+ <select class="form-control input-sm" v-model="combination.add_code_key">
+ <option v-for="(code_key, i) of codeKeyNotSet(combination)" :value="code_key">{{combination.arProductCodes[code_key].label}}</option>
+ </select>
+ <a @click.stop.prevent="codeKeyAdd(combination)" href="#" class="glyphicon glyphicon glyphicon-plus form-control-feedback" aria-hidden="true" style="pointer-events: auto;"></a>
+ </div>
</div>
+ <div class="clearfix wpsg_clear"></div>
</div>
- <div class="clearfix wpsg_clear"></div>
- </div>
-
- <!-- PZN -->
- <div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">PZN (Pharmazentralnummer)</label>
- <div class="col-sm-6">
- <div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.pzn" />
+ <hr />
+ </template>
+
+ <div class="code_wrap">
+ <template v-for="(code, i) of combination.arProductCodes">
+ <div class="form-group form-group-sm has-feedback" v-if="code.set === true">
+ <label class="col-sm-6 control-label" for="metaean">{{code.label}}</label>
+ <div class="col-sm-6">
+ <div class="wpsg_field_wrap">
+ <input type="text" class="form-control input-sm" v-model="code.code"
+ @keydown.enter.prevent
+ />
+ <a @click.stop.prevent="codeKeyRemove(combination, code.code_key)" href="#" class="glyphicon glyphicon glyphicon-trash form-control-feedback" aria-hidden="true" style="pointer-events: auto;"></a>
+ </div>
+ </div>
+ <div class="clearfix wpsg_clear"></div>
</div>
- </div>
- <div class="clearfix wpsg_clear"></div>
+ </template>
</div>
- <!-- SKU -->
- <div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">SKU (Stock Keeping Unit)</label>
- <div class="col-sm-6">
- <div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.sku" />
- </div>
- </div>
- <div class="clearfix wpsg_clear"></div>
- </div>
-
- <!-- UPC -->
- <div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">UPC (Universal Product Code)</label>
- <div class="col-sm-6">
- <div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.upc" />
- </div>
- </div>
- <div class="clearfix wpsg_clear"></div>
- </div>
-
- <!-- ISBN -->
- <div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">ISBN (International Standard Book Number)</label>
- <div class="col-sm-6">
- <div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.isbn" />
- </div>
- </div>
- <div class="clearfix wpsg_clear"></div>
- </div>
-
- <!-- ISSN -->
- <div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">ISSN (International Standard Serial Number)</label>
- <div class="col-sm-6">
- <div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.issn" />
- </div>
- </div>
- <div class="clearfix wpsg_clear"></div>
- </div>
-
- <!-- ISIN -->
- <div class="form-group form-group-sm ">
- <label class="col-sm-6 control-label" for="detailname">ISIN (International Securities Identification Number)</label>
- <div class="col-sm-6">
- <div class="wpsg_field_wrap">
- <input type="text" class="form-control input-sm " autocomplete="off" placeholder="" v-model="combination.isin" />
- </div>
- </div>
- <div class="clearfix wpsg_clear"></div>
- </div>
+ <!--<pre>{{combination}}</pre>-->
<div class="mt-8 flex w-full justify-end">
<input type="submit" @click.prevent="save(combination)" class="button button-primary" value="speichern" />
@@ -180,226 +148,277 @@ </div>
</div>
+ <?php $GLOBALS['wpsg_vue_3.2.47_loaded'] = ($GLOBALS['wpsg_vue_3.2.47_loaded']??0) + 1; if ($GLOBALS['wpsg_vue_3.2.47_loaded'] <= 1) { ?>
<script src="<?php echo WPSG_URL_CONTENT.'plugins/'.WPSG_FOLDERNAME.'/views/js/vue-3.2.47.global.min.js'; ?>"></script>
+ <?php } ?>
+
<script>
- const ref = Vue.ref;
- const computed = Vue.computed;
- const onMounted = Vue.onMounted;
-
- const app = Vue.createApp({
- setup() {
-
- const product_id = ref(<?php echo $oProduct->getId(); ?>);
- const loading = ref(true);
- const arFilter = ref(undefined);
- const arPossibleKeys = ref(undefined);
- const arVariant = ref(undefined);
- const arVariantLabel = ref(undefined);
- const arVariationen = ref(undefined);
- const arVariationLabel = ref(undefined);
-
- const arPossibleKeysFiltered = computed(() => {
-
- let r = [];
-
- if (!arPossibleKeys.value) return r;
-
- for (let var_key of arPossibleKeys.value) {
-
- const arKey = var_key.var_key.split('|');
- const typedKey = {};
-
- for (let i of arKey) {
-
- const [var_id, vari_id] = i.split(':');
-
- typedKey[var_id] = parseInt(vari_id);
-
- }
-
- let set = true;
-
- for (let f in arFilter.value) {
-
- if (arFilter.value[f] !== 0 && typedKey[f] !== arFilter.value[f]) {
-
- set = false; break;
-
+ (() => {
+
+ const ref = Vue.ref;
+ const computed = Vue.computed;
+ const onMounted = Vue.onMounted;
+
+ const app = Vue.createApp({
+ setup() {
+
+ const product_id = ref(<?php echo $oProduct->getId(); ?>);
+ const loading = ref(true);
+ const arFilter = ref(undefined);
+ const arPossibleKeys = ref(undefined);
+ const arVariant = ref(undefined);
+ const arVariantLabel = ref(undefined);
+ const arVariationen = ref(undefined);
+ const arVariationLabel = ref(undefined);
+
+ const arPossibleKeysFiltered = computed(() => {
+
+ let r = [];
+
+ if (!arPossibleKeys.value) return r;
+
+ for (let var_key of arPossibleKeys.value) {
+
+ const arKey = var_key.var_key.split('|');
+ const typedKey = {};
+
+ for (let i of arKey) {
+
+ const [var_id, vari_id] = i.split(':');
+
+ typedKey[var_id] = parseInt(vari_id);
+
}
-
+
+ let set = true;
+
+ for (let f in arFilter.value) {
+
+ if (arFilter.value[f] !== 0 && typedKey[f] !== arFilter.value[f]) {
+
+ set = false;
+ break;
+
+ }
+
+ }
+
+ if (set) r.push(var_key);
+
}
-
- if (set) r.push(var_key);
-
- }
-
- return r;
-
- });
-
- const getVariantLabel = (var_id) => {
-
- if (arVariantLabel.value[var_id.toString()] !== undefined) return arVariantLabel.value[var_id.toString()];
- else '';
-
- };
- const getVariationLabel = (var_id) => {
-
- if (arVariationLabel.value[var_id.toString()] !== undefined) return arVariationLabel.value[var_id.toString()];
- else '';
-
- };
- const xhr = (action_do, data, cb_success) => {
-
- const request = new XMLHttpRequest();
-
- data.action_do = action_do;
-
- request.open('POST', '<?php echo WPSG_URL_WP; ?>wp-admin/?page=wpsg-Admin&action=module&modul=wpsg_mod_productvariants&subaction=combination&noheader=1', true);
- request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
- request.onload = () => {
-
- if (request.status >= 200 && request.status < 400) {
-
- const response = JSON.parse(request.responseText);
-
- cb_success(response);
-
- } else {
-
+
+ return r;
+
+ });
+
+ const getVariantLabel = (var_id) => {
+
+ if (arVariantLabel.value[var_id.toString()] !== undefined) return arVariantLabel.value[var_id.toString()];
+ else '';
+
+ };
+ const getVariationLabel = (var_id) => {
+
+ if (arVariationLabel.value[var_id.toString()] !== undefined) return arVariationLabel.value[var_id.toString()];
+ else '';
+
+ };
+ const xhr = (action_do, data, cb_success) => {
+
+ const request = new XMLHttpRequest();
+
+ data.action_do = action_do;
+
+ request.open('POST', '<?php echo WPSG_URL_WP; ?>wp-admin/?page=wpsg-Admin&action=module&modul=wpsg_mod_productvariants&subaction=combination&noheader=1', true);
+ request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
+ request.onload = () => {
+
+ if (request.status >= 200 && request.status < 400) {
+
+ const response = JSON.parse(request.responseText);
+
+ cb_success(response);
+
+ } else {
+
+ console.error('Error: ' + request.statusText);
+
+ }
+
+ };
+
+ request.onerror = function () {
+
console.error('Error: ' + request.statusText);
-
- }
-
+
+ };
+
+ request.send(JSON.stringify(data));
+
};
-
- request.onerror = function() {
-
- console.error('Error: ' + request.statusText);
-
+ const save = (combination) => {
+
+ xhr('save', {
+ var_key: combination.var_key,
+ product_id: combination.product_id,
+ combination: combination
+ }, (response) => {
+
+ for (let i = 0; i < arPossibleKeys.value.length; i++) {
+
+ const var_key = arPossibleKeys.value[i];
+
+ if (var_key.var_key === response.combination.var_key) {
+
+ arPossibleKeys.value[i] = response.combination;
+
+ }
+
+ }
+
+ });
+
+ combination.loading = true;
+
+ }
+ const updateCombinationData = () => {
+
+ xhr('getCombination', {
+ product_id: product_id.value
+ }, (response) => {
+
+ arFilter.value = response.arFilter;
+ arPossibleKeys.value = response.arPossibleKeys;
+ arVariant.value = response.arVariant;
+ arVariantLabel.value = response.arVariantLabel;
+ arVariationen.value = response.arVariationen;
+ arVariationLabel.value = response.arVariationLabel;
+
+ loading.value = false;
+
+ });
+
};
-
- request.send(JSON.stringify(data));
-
- };
- const save = (combination) => {
-
- xhr('save', {
- var_key: combination.var_key,
- product_id: combination.product_id,
- combination: combination
- }, (response) => {
-
- for (let i = 0; i < arPossibleKeys.value.length; i ++) {
-
- const var_key = arPossibleKeys.value[i];
-
- if (var_key.var_key === response.combination.var_key) {
-
- arPossibleKeys.value[i] = response.combination;
-
+ const add = (combination) => {
+
+ combination.loaded = true;
+ combination.loading = true;
+
+ xhr('add', {
+ var_key: combination.var_key,
+ product_id: product_id.value
+ }, (response) => {
+
+ for (let i = 0; i < arPossibleKeys.value.length; i++) {
+
+ const var_key = arPossibleKeys.value[i];
+
+ if (var_key.var_key === response.combination.var_key) {
+
+ arPossibleKeys.value[i] = response.combination;
+
+ }
+
}
-
- }
-
- });
-
- combination.loading = true;
-
- }
- const updateCombinationData = () => {
- xhr('getCombination', {
- product_id: product_id.value
- }, (response) => {
+ });
+
+ };
+ const edit = (combination) => {
+
+ combination.loaded = true;
+ combination.loading = true;
+
+ xhr('edit', {
+ var_key: combination.var_key,
+ product_id: product_id.value
+ }, (response) => {
+
+ for (let i = 0; i < arPossibleKeys.value.length; i++) {
+
+ const var_key = arPossibleKeys.value[i];
+
+ if (var_key.var_key === response.combination.var_key) {
+
+ arPossibleKeys.value[i] = response.combination;
+
+ }
+
+ }
+
+ });
+
+ };
+ const codeKeyNotSet = (combination) => {
- arFilter.value = response.arFilter;
- arPossibleKeys.value = response.arPossibleKeys;
- arVariant.value = response.arVariant;
- arVariantLabel.value = response.arVariantLabel;
- arVariationen.value = response.arVariationen;
- arVariationLabel.value = response.arVariationLabel;
+ let r = [];
- loading.value = false;
+ for (let code_key in combination.arProductCodes) {
- });
-
- };
- const add = (combination) => {
-
- combination.loaded = true;
- combination.loading = true;
-
- xhr('add', {
- var_key: combination.var_key,
- product_id: product_id.value
- }, (response) => {
+ if (combination.arProductCodes[code_key].set !== true) r.push(code_key);
- for (let i = 0; i < arPossibleKeys.value.length; i ++) {
-
- const var_key = arPossibleKeys.value[i];
-
- if (var_key.var_key === response.combination.var_key) {
-
- arPossibleKeys.value[i] = response.combination;
-
- }
-
}
- });
-
- };
- const edit = (combination) => {
-
- combination.loaded = true;
- combination.loading = true;
-
- xhr('edit', {
- var_key: combination.var_key,
- product_id: product_id.value
- }, (response) => {
-
- for (let i = 0; i < arPossibleKeys.value.length; i ++) {
-
- const var_key = arPossibleKeys.value[i];
-
- if (var_key.var_key === response.combination.var_key) {
-
- arPossibleKeys.value[i] = response.combination;
-
- }
+ return r;
+
+ };
+ const codeKeyAdd = (combination) => {
+
+ const add_code_key = combination.add_code_key;
+
+ if (add_code_key !== undefined && codeKeyNotSet(combination).includes(add_code_key)) {
+
+ combination.arProductCodes[add_code_key].set = true;
+ combination.add_code_key = undefined;
+
}
+ };
+ const codeKeyRemove = (combination, code_key_remove) => {
+
+ combination.arProductCodes[code_key_remove].set = false;
+
+ }
+
+ onMounted(() => {
+
+ // updateCombinationData();
+
});
-
+
+ return {
+ arFilter,
+ arPossibleKeys,
+ arVariant,
+ arVariantLabel,
+ arVariationen,
+ arVariationLabel,
+ product_id,
+ loading,
+ getVariantLabel,
+ getVariationLabel,
+ codeKeyNotSet, codeKeyAdd, codeKeyRemove,
+ arPossibleKeysFiltered,
+ add,
+ edit,
+ save,
+ updateCombinationData
+ };
+
}
-
- onMounted(() => {
-
- // updateCombinationData();
-
- });
-
- return {
- arFilter, arPossibleKeys, arVariant, arVariantLabel, arVariationen, arVariationLabel, product_id, loading,
- getVariantLabel, getVariationLabel,
- arPossibleKeysFiltered,
- add, edit, save, updateCombinationData
- };
-
- }
- }).mount('#wpsg_mod_productvars_combination');
-
- window.wpsg_mod_productvariants = app;
-
- jQuery(document).ready(function() {
-
- wpsg_mod_productvariants_show(<?php echo $this->view['data']['id']; ?>);
-
- } );
+ }).mount('#wpsg_mod_productvars_combination');
+
+ window.wpsg_mod_productvariants = app;
+
+ jQuery(document).ready(function () {
+
+ wpsg_mod_productvariants_show(<?php echo $this->view['data']['id']; ?>);
+
+ });
+
+ })();
</script>
@@ -409,6 +428,7 @@ #wpsg_mod_productvars_combination .top_filter { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); row-gap:1rem; column-gap:1rem; margin-bottom:2rem; }
#wpsg_mod_productvars_combination .top_filter select { width:100%; }
#wpsg_mod_productvars_combination .panel-title { display:flex; justify-content:space-between; align-items:center; }
+ #wpsg_mod_productvars_combination .panel-title a.url { color:inherit; margin-right:1rem; display:inline-block; }
#wpsg_mod_productvars_combination .panel-title .glyphicon { cursor:pointer; }
#wpsg_mod_productvars_combination .panel { margin-bottom:10px; }
#wpsg_mod_productvars_combination .loading_layer { z-index:10; position:absolute; left:0; top:0; width:100%; height:100%; background-color:rgba(255, 255, 255, 0.5); display:flex; justify-content:center; align-items:center; }
diff --git a/views/mods/mod_rechnungen/invoice_pdf.phtml b/views/mods/mod_rechnungen/invoice_pdf.phtml index 6434ade..4f49dad 100644 --- a/views/mods/mod_rechnungen/invoice_pdf.phtml +++ b/views/mods/mod_rechnungen/invoice_pdf.phtml @@ -216,7 +216,9 @@ $bKopf = false; $pnr = 1; $offset = 0; $count = 0;
foreach ($this->view['basket']['arCalculation']['product'] as $p)
{
+
$product = wpsg_product::getInstance($p['product_id']);
+ if (($p['product_key']??'') !== '') $product->setProductKey($p['product_key']);
if (!$bKopf)
{
@@ -256,8 +258,8 @@ if ($this->get_option('wpsg_mod_rechnungen_anr') == '1') $pdf->Cell(10, 8, $product->getNr(), 0, 0, 'C');
else $pdf->Cell(10, 8, $pnr.".", 0, 0, 'C');
- if ($this->get_option('wpsg_rechnungen_pdetailname') == '1') $produkt_text = $this->getProductName($this->getProduktID($p['product_id']), true);
- else $produkt_text = $this->getProductName($this->getProduktID($p['product_id']), false);
+ if ($this->get_option('wpsg_rechnungen_pdetailname') == '1') $produkt_text = $product->getProductName(true);
+ else $produkt_text = $product->getProductName(false);
$produktBeschreibung = trim(strip_tags($product->getShortDescription()));
diff --git a/views/order/product_table.phtml b/views/order/product_table.phtml index 39ef05d..3fc4499 100644 --- a/views/order/product_table.phtml +++ b/views/order/product_table.phtml @@ -49,7 +49,12 @@ <tbody>
<tr><td colspan="<?php echo $this->view['colspan'] + 1; ?>" style="line-height:2px; height:2px; background-color:#999999; padding:0px;"></td></tr>
- <?php $i = 0; foreach ($arCalculation['product'] as $p) { $i ++; $product_price = $p[$display.'_single']; ?>
+ <?php $i = 0; foreach ($arCalculation['product'] as $p) { $i ++; $product_price = $p[$display.'_single'];
+
+ $oProduct = wpsg_product::getInstance(intval($p['product_id']));
+ if (($p['product_key']??'') !== '') $oProduct->setProductKey($p['product_key']);
+
+ ?>
<tr class="wpsg_<?php echo (($i % 2 == 0)?'odd':'even'); ?>">
<td colspan="<?php echo $this->view['colspan'] + 1; ?>">
@@ -62,7 +67,7 @@ echo wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Produkt&action=edit&edit_id='.$p['product_id'], 'wpsg-product-edit-'.wpsg_getInt($p['product_id']));
?>" title="<?php echo __('Zum Produkt', 'wpsg'); ?>">
- <?php echo wpsg_hspc($this->getProductName($p['product_id'])); ?>
+ <?php echo wpsg_hspc($oProduct->getProductName(false)); ?>
</a>
<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Produkt bearbeiten', 'wpsg'); ?>" onclick="return WPSG_BE_Product.editProduct(<?php echo $p['order_product_id']; ?>);"><span class="glyphicon glyphicon-pencil"></span></a>
<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Produkt löschen', 'wpsg'); ?>" onclick="return WPSG_BE_Product.removeProduct(<?php echo $p['order_product_id']; ?>);"><span class="glyphicon glyphicon-trash"></span></a>
diff --git a/views/produkt/addedit_productcodes.phtml b/views/produkt/addedit_productcodes.phtml index 602a9b5..065eb86 100644 --- a/views/produkt/addedit_productcodes.phtml +++ b/views/produkt/addedit_productcodes.phtml @@ -10,7 +10,7 @@ */ namespace wpsg; - + ?> <div class="general-panel-block"> @@ -22,37 +22,127 @@ /** @var \wpsg_product $oProduct */ $oProduct = \wpsg_product::getInstance(intval($this->view['data']['id'])); + $arData = []; + + foreach (\wpsg_product::getProductCodeConfig() as $code_key => $code_data) { + + $product_code = $oProduct->getMeta($code_key, false, ''); + + $arData[$code_key] = [ + 'label' => $code_data['label'], + 'code_key' => $code_key, + 'code' => trim($product_code), + 'set' => trim($product_code) !== '' + ]; + + } + ?> - - <?php echo wpsg_drawForm_Select('meta[code_mode]', __('Modus', 'wpsg'), [ - '0' => __('Erster definierter Code', 'wpsg'), - 'ean' => __('EAN als Standard', 'wpsg'), - 'gtin' => __('GTIN als Standard', 'wpsg'), - 'mpn' => __('MPN als Standard', 'wpsg'), - 'pzn' => __('PZN als Standard', 'wpsg'), - 'sku' => __('SKU als Standard', 'wpsg'), - 'upc' => __('UPC als Standard', 'wpsg'), - 'isbn' => __('ISBN als Standard', 'wpsg'), - 'issn' => __('ISSN als Standard', 'wpsg'), - 'isin' => __('ISIN als Standard', 'wpsg') - ], $oProduct->getMeta('code_mode', false, '0'), ['help' => 'code_mode']); ?> - <?php echo wpsg_drawForm_Input('meta[ean]', __('EAN', 'wpsg'), $oProduct->getMeta('ean'), ['help' => 'ean']); ?> - <?php echo wpsg_drawForm_Input('meta[gtin]', __('GTIN', 'wpsg'), $oProduct->getMeta('gtin'), ['help' => 'gtin']); ?> - <?php echo wpsg_drawForm_Input('meta[mpn]', __('MPN', 'wpsg'), $oProduct->getMeta('mpn'), ['help' => 'mpn']); ?> - <?php echo wpsg_drawForm_Input('meta[pzn]', __('PZN', 'wpsg'), $oProduct->getMeta('pzn'), ['help' => 'pzn']); ?> - <?php echo wpsg_drawForm_Input('meta[sku]', __('SKU', 'wpsg'), $oProduct->getMeta('sku'), ['help' => 'sku']); ?> - <?php echo wpsg_drawForm_Input('meta[upc]', __('UPC', 'wpsg'), $oProduct->getMeta('upc'), ['help' => 'upc']); ?> - <?php echo wpsg_drawForm_Input('meta[isbn]', __('ISBN', 'wpsg'), $oProduct->getMeta('isbn'), ['help' => 'isbn']); ?> - <?php echo wpsg_drawForm_Input('meta[issn]', __('ISSN', 'wpsg'), $oProduct->getMeta('issn'), ['help' => 'issn']); ?> - <?php echo wpsg_drawForm_Input('meta[isin]', __('ISIN', 'wpsg'), $oProduct->getMeta('isin'), ['help' => 'isin']); ?> - - <?php if (\wpsg_ShopController::getShop()->hasMod('wpsg_mod_productvariants')) { ?> - <br /> + <div id="wpsg_mod_productcodes_app"> - <p class="wpsg_hinweis">Ist das Produkt ein Variantenprodukt, können die Codes unter Produktvarianten für einzelne Variationen überschrieben werden.</p> + <template v-if="codeKeyNotSet.length > 0"> + <div class="form-group form-group-sm has-feedback"> + <label class="col-sm-6 control-label" for="metaean">Code hinzufügen</label> + <div class="col-sm-6"> + <div class="wpsg_field_wrap"> + <select class="form-control input-sm" v-model="add_code_key"> + <option v-for="(code_key, i) of codeKeyNotSet" :value="code_key">{{data[code_key].label}}</option> + </select> + <a @click.stop.prevent="add()" href="#" class="glyphicon glyphicon glyphicon-plus form-control-feedback" aria-hidden="true" style="pointer-events: auto;"></a> + </div> + </div> + <div class="clearfix wpsg_clear"></div> + </div> + <hr /> + </template> + <div class="code_wrap"> + <template v-for="(code, i) of data"> + <div class="form-group form-group-sm has-feedback" v-if="code.set === true"> + <label class="col-sm-6 control-label" for="metaean">{{code.label}}</label> + <div class="col-sm-6"> + <div class="wpsg_field_wrap"> + <input type="text" class="form-control input-sm" :value="code.code" :name="'meta[' + code.code_key + ']'" /> + <a @click.stop.prevent="remove(code.code_key)" href="#" class="glyphicon glyphicon glyphicon-trash form-control-feedback" aria-hidden="true" style="pointer-events: auto;"></a> + </div> + </div> + <div class="clearfix wpsg_clear"></div> + </div> + <input v-else type="hidden" value="" :name="'meta[' + code.code_key + ']'" /> + </template> + </div> + + </div> + + <?php $GLOBALS['wpsg_vue_3.2.47_loaded'] = ($GLOBALS['wpsg_vue_3.2.47_loaded']??0) + 1; if ($GLOBALS['wpsg_vue_3.2.47_loaded'] <= 1) { ?> + <script src="<?php echo WPSG_URL_CONTENT.'plugins/'.WPSG_FOLDERNAME.'/views/js/vue-3.2.47.global.min.js'; ?>"></script> <?php } ?> + + <script> + + (() => { + + const ref = Vue.ref; + const computed = Vue.computed; + const onMounted = Vue.onMounted; + + const app = Vue.createApp({ + setup() { + + const data = ref(<?php echo json_encode($arData); ?>); + const add_code_key = ref(undefined); + + const codeKeyNotSet = computed(() => { + + let r = []; + + for (let c of Object.values(data.value)) { + + if (c.set !== true) r.push(c.code_key); + + } + + return r; + + }); + + const add = () => { + + if (add_code_key.value !== undefined && codeKeyNotSet.value.includes(add_code_key.value)) { + + data.value[add_code_key.value].set = true; + + } + + }; + const remove = (code_key) => { + + data.value[code_key].set = false; + + }; + + return { + data, add_code_key, + codeKeyNotSet, + add, remove + }; + + } + }).mount('#wpsg_mod_productcodes_app'); + + })(); + + </script> + + <br /> + + <p class="wpsg_hinweis"> + <?php if (\wpsg_ShopController::getShop()->hasMod('wpsg_mod_productvariants')) { ?> + Ist das Produkt ein Variantenprodukt, können die Codes unter Produktvarianten für einzelne Variationen überschrieben werden.<br /> + <?php } ?> + Änderungen müssen mit speichern bestätigt werden. + </p> <?php } else { ?> @@ -60,6 +150,7 @@ <?php } ?> + <?php echo wpsg_drawForm_AdminboxEnd(); ?> </div> </div> diff --git a/views/produkttemplates/standard.phtml b/views/produkttemplates/standard.phtml index e64a94e..c09c9f9 100644 --- a/views/produkttemplates/standard.phtml +++ b/views/produkttemplates/standard.phtml @@ -12,7 +12,8 @@ /** @var wpsg_product $oProduct */
$oProduct = $this->view['oProduct'];
-
+ if (($this->view['data']['product_key']??'') !== '') $oProduct->setProductKey($this->view['data']['product_key']);
+
?>
<div class="wpsg_produkt_wrapper">
@@ -23,7 +24,7 @@ <div class="wpsg_produkt wpsg_product_name">
<?php if (!$this->titleDisplayed) { ?>
- <h1 class="wpsg_producttitle"><?php echo $this->getProductName($this->view['data']['id']); ?></h1>
+ <h1 class="wpsg_producttitle"><?php echo $oProduct->getProductName(); ?></h1>
<h2 class="wpsg_productdetailtitle"><?php echo $this->view['data']['detailname']; ?></h2>
<?php } ?>
@@ -35,7 +36,7 @@ <div itemscope itemtype="http://schema.org/Product" class="wpsg_produkt wpsg_produkt_<?php echo $this->view['data']['id']; ?>">
- <meta itemprop="name" content="<?php echo wpsg_hspc($this->getProductName($this->view['data']['id'])); ?>" />
+ <meta itemprop="name" content="<?php echo wpsg_hspc($oProduct->getProductName()); ?>" />
<meta itemprop="detailname" content="<?php echo wpsg_hspc($this->view['data']['detailname']); ?>" />
<?php foreach ($oProduct->getAllProductCodes() as $product_code) { ?>
@@ -67,7 +68,7 @@ <meta itemprop="image" content="<?php echo $att[0]; ?>" />
- <a <?php if ($arAttachmentIDsAll[$i] != $arAttachmentID) echo 'style="display:none;"'; ?> rel="gallery-wpsg-<?php echo $this->getTemplateIndex(); ?>" title="<?php echo $this->getProductName($this->view['data']['id']); ?>" href="<?php echo $att[0]; ?>" class="thickbox">
+ <a <?php if ($arAttachmentIDsAll[$i] != $arAttachmentID) echo 'style="display:none;"'; ?> rel="gallery-wpsg-<?php echo $this->getTemplateIndex(); ?>" title="<?php echo $oProduct->getProductName(); ?>" href="<?php echo $att[0]; ?>" class="thickbox">
<?php echo wp_get_attachment_image($arAttachmentIDsAll[$i], array(300, 300), false, array()); ?>
|
