diff --git a/bin/controls/fields/types/PriceByTimePeriod.css b/bin/controls/fields/types/PriceByTimePeriod.css index 043a89bce6fc465cee01c787154ca4bb6fe75461..d9338a0e774e068d63661c7a74a0d70e46f85c87 100644 --- a/bin/controls/fields/types/PriceByTimePeriod.css +++ b/bin/controls/fields/types/PriceByTimePeriod.css @@ -49,7 +49,29 @@ display: flex; /*width: calc(100% - 200px);*/ } + .quiqqer-products-priceByTimePeriod-settings-groups-values { display: inline-block; width: 100%; } + +.quiqqer-products-field-priceByTimePeriod-time { + padding: 0 10px; +} + +.quiqqer-products-field-priceByTimePeriod-time:first-of-type { + border-right: 1px solid #e4dfda; + margin-right: 10px; +} + +.quiqqer-products-field-priceByTimePeriod-time label { + float: none !important; +} + +.quiqqer-products-field-priceByTimePeriod-time label > span { + display: block; +} + +.quiqqer-products-field-priceByTimePeriod-time label > input { + width: 100%; +} \ No newline at end of file diff --git a/bin/controls/fields/types/PriceByTimePeriod.html b/bin/controls/fields/types/PriceByTimePeriod.html index 732b12921e47eb285d0faabcbd85bf83a2288e67..178d71d6058f913371615d0d24f9f262971c204c 100644 --- a/bin/controls/fields/types/PriceByTimePeriod.html +++ b/bin/controls/fields/types/PriceByTimePeriod.html @@ -4,20 +4,39 @@ placeholder="{{placeholderPrice}}" /> <span class="quiqqer-products-field-priceByTimePeriod-currency"></span> - <label> - <span>{{labelFrom}}</span> - <input type="date" - class="quiqqer-products-field-priceByTimePeriod-date" - name="from" - /> - </label> - <label> - <span>{{labelTo}}</span> - <input type="date" - class="quiqqer-products-field-priceByTimePeriod-date" - name="to" - /> - </label> + <div class="quiqqer-products-field-priceByTimePeriod-time"> + <label> + <span>{{labelFrom}}</span> + <input type="date" + class="quiqqer-products-field-priceByTimePeriod-date" + name="from" + /> + </label> + <label> + <span>{{labelFromTime}}</span> + <input type="time" + class="quiqqer-products-field-priceByTimePeriod-date" + name="from_time" + /> + </label> + </div> + + <div class="quiqqer-products-field-priceByTimePeriod-time"> + <label> + <span>{{labelTo}}</span> + <input type="date" + class="quiqqer-products-field-priceByTimePeriod-date" + name="to" + /> + </label> + <label> + <span>{{labelToTime}}</span> + <input type="time" + class="quiqqer-products-field-priceByTimePeriod-date" + name="to_time" + /> + </label> + </div> <span class="field-container-item quiqqer-products-field-priceByTimePeriod-bruttoinput"> <span class="fa fa-spinner fa-spin"></span> diff --git a/bin/controls/fields/types/PriceByTimePeriod.js b/bin/controls/fields/types/PriceByTimePeriod.js index 591e5c6d3661d5777766517b14ce88761c6550c8..f85b86c4b2e0fe539b9fff3fbe55d29c0b43c6eb 100644 --- a/bin/controls/fields/types/PriceByTimePeriod.js +++ b/bin/controls/fields/types/PriceByTimePeriod.js @@ -45,7 +45,9 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [ this.$productId = null; this.$From = null; + this.$FromTime = null; this.$To = null; + this.$ToTime = null; this.$calcTimer = null; this.$Formatter = QUILocale.getNumberFormatter({ @@ -80,11 +82,11 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [ */ $onImport: function () { var self = this; - var Elm = this.getElm(), data = { - price : false, - quantity: '' + price: false, + from : false, + to : false }; Elm.type = 'hidden'; @@ -116,6 +118,8 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [ placeholderPrice : self.$Formatter.format(1000), labelTo : QUILocale.get(lg, lgPrefix + 'labelTo'), labelFrom : QUILocale.get(lg, lgPrefix + 'labelFrom'), + labelToTime : QUILocale.get(lg, lgPrefix + 'labelToTime'), + labelFromTime : QUILocale.get(lg, lgPrefix + 'labelFromTime'), titleBruttoCalcBtn: QUILocale.get(lg, 'fields.control.price.brutto') }) }).inject(this.$Input, 'after'); @@ -143,22 +147,30 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [ }.bind(this)); // Date inputs - this.$To = this.$Elm.getElement('input.quiqqer-products-field-priceByTimePeriod-date[name="to"]'); - this.$To.value = data.to; - + this.$To = this.$Elm.getElement('input.quiqqer-products-field-priceByTimePeriod-date[name="to"]'); this.$To.addEvents({ change: this.refresh, blur : this.refresh }); - this.$From = this.$Elm.getElement('input.quiqqer-products-field-priceByTimePeriod-date[name="from"]'); - this.$From.value = data.from; + this.$ToTime = this.$Elm.getElement('input.quiqqer-products-field-priceByTimePeriod-date[name="to_time"]'); + this.$ToTime.addEvents({ + change: this.refresh, + blur : this.refresh + }); + this.$From = this.$Elm.getElement('input.quiqqer-products-field-priceByTimePeriod-date[name="from"]'); this.$From.addEvents({ change: this.refresh, blur : this.refresh }); + this.$FromTime = this.$Elm.getElement('input.quiqqer-products-field-priceByTimePeriod-date[name="from_time"]'); + this.$FromTime.addEvents({ + change: this.refresh, + blur : this.refresh + }); + // Total (brutto) calculator this.$Brutto = this.$Elm.getElement('span.quiqqer-products-field-priceByTimePeriod-btn-bruttocalc'); this.$Brutto.addEvent('click', this.openBruttoInput); @@ -173,6 +185,7 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [ } } + this.setValue(data); this.refresh(); this.$calcBruttoPrice(); }, @@ -181,10 +194,21 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [ * refresh */ refresh: function () { + var from = this.$From.value, + to = this.$To.value; + + if (from && this.$FromTime.value) { + from += ' ' + this.$FromTime.value; + } + + if (to && this.$ToTime.value) { + to += ' ' + this.$ToTime.value; + } + this.$Input.value = JSON.encode({ price: this.$Price.value, - from : this.$From.value, - to : this.$To.value + from : from, + to : to }); this.fireEvent('change', [this]); @@ -211,38 +235,46 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [ this.setPriceValue(value); } + if (typeOf(value) === 'string' && value.match('{')) { + try { + value = JSON.decode(value); + } catch (e) { + } + } + if (typeOf(value) === 'object') { if ("price" in value) { this.setPriceValue(value.price); } - if ("from" in value) { - this.$From.value = value.from; - } - - if ("to" in value) { - this.$To.value = value.to; - } - } + if ("from" in value && value.from) { + var from = value.from; - if (typeOf(value) === 'string' && value.match('{')) { - try { - value = JSON.decode(value); + if (from.indexOf(' ') !== -1) { + from = from.split(' '); - if ("price" in value) { - this.setPriceValue(value.price); + this.$From.value = from[0]; + this.$FromTime.value = from[1]; + } else { + this.$From.value = from; } + } - if ("from" in value) { - this.$From.value = value.from; - } + if ("to" in value && value.to) { + var to = value.to; - if ("to" in value) { - this.$To.value = value.to; + if (to.indexOf(' ') !== -1) { + to = to.split(' '); + + this.$To.value = to[0]; + this.$ToTime.value = to[1]; + } else { + this.$To.value = to; } - } catch (e) { } - } else if (typeOf(value) === 'string') { + } + + if (typeOf(value) === 'string') { this.setPriceValue(value); } diff --git a/locale.xml b/locale.xml index 77b2e643d02f85c52f26a0872dbacabbacca5586..8680267d972a8f27ad34e2660a819e446122fa2e 100644 --- a/locale.xml +++ b/locale.xml @@ -2138,12 +2138,20 @@ </locale> <locale name="controls.fields.types.PriceByTimePeriod.template.labelFrom"> - <de><![CDATA[gültig von]]></de> - <en><![CDATA[valid from]]></en> + <de><![CDATA[gültig von (Datum)]]></de> + <en><![CDATA[valid from (date)]]></en> </locale> <locale name="controls.fields.types.PriceByTimePeriod.template.labelTo"> - <de><![CDATA[gültig bis]]></de> - <en><![CDATA[valid to]]></en> + <de><![CDATA[gültig bis (Datum)]]></de> + <en><![CDATA[valid to (date)]]></en> + </locale> + <locale name="controls.fields.types.PriceByTimePeriod.template.labelToTime"> + <de><![CDATA[gültig von (Uhrzeit)]]></de> + <en><![CDATA[valid from (time)]]></en> + </locale> + <locale name="controls.fields.types.PriceByTimePeriod.template.labelFromTime"> + <de><![CDATA[gültig bis (Uhrzeit)]]></de> + <en><![CDATA[valid to (time)]]></en> </locale> <locale name="control.variant.reset.fields"> diff --git a/src/QUI/ERP/Products/Field/Types/PriceByTimePeriod.php b/src/QUI/ERP/Products/Field/Types/PriceByTimePeriod.php index cde76e44fd9b136b93e1a9aa7437450be14f7b61..2e6d76b3ae3bbe327a874f69327d2c100cb17420 100644 --- a/src/QUI/ERP/Products/Field/Types/PriceByTimePeriod.php +++ b/src/QUI/ERP/Products/Field/Types/PriceByTimePeriod.php @@ -240,8 +240,8 @@ public function cleanup($value) return [ 'price' => $price, - 'from' => $From ? $From->format('Y-m-d') : false, - 'to' => $To ? $To->format('Y-m-d') : false + 'from' => $From ? $From->format('Y-m-d H:i') : false, + 'to' => $To ? $To->format('Y-m-d H:i') : false ]; } @@ -256,7 +256,7 @@ public function isEmpty() $value = $this->value; } - if (!isset($value['price']) || !isset($value['quantity'])) { + if (!isset($value['price'])) { return true; } @@ -266,19 +266,4 @@ public function isEmpty() return false; } - - /** - * Return value for use in product search cache - * - * @param QUI\Locale|null $Locale - * @return string - */ - public function getSearchCacheValue($Locale = null) - { - if ($this->isEmpty()) { - return null; - } - - return $this->value['price']; - } }