Skip to content
Code-Schnipsel Gruppen Projekte
Commit 43cbe638 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

fix: PriceByTimePeriod functionality candyman-gmbh/projektplanung#150

Übergeordneter 3a5dd7db
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -303,7 +303,7 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [
},
onSubmit: function (Win, value) {
self.$Price.value = value;
self.setPriceValue(value);
self.$calcBruttoPrice();
}
}
......@@ -342,8 +342,9 @@ define('package/quiqqer/products/bin/controls/fields/types/PriceByTimePeriod', [
});
}, {
'package': 'quiqqer/products',
price : this.$Price.value,
formatted: 1
price : self.$Price.value,
formatted: 1,
productId: self.$productId
});
}).delay(500, this);
}
......
......@@ -144,12 +144,53 @@ public function getJavaScriptSettings()
* is the value valid for the field type?
*
* @param mixed $value
* @return array
* @throws \QUI\ERP\Products\Field\Exception
*/
public function validate($value)
{
return $this->cleanup($value);
if (empty($value)) {
return;
}
if (\is_string($value)) {
$value = \json_decode($value, true);
if (\json_last_error() !== \JSON_ERROR_NONE) {
throw new QUI\ERP\Products\Field\Exception([
'quiqqer/products',
'exception.field.invalid',
[
'fieldId' => $this->getId(),
'fieldTitle' => $this->getTitle(),
'fieldType' => $this->getType()
]
]);
}
}
if (!\is_array($value)) {
throw new QUI\ERP\Products\Field\Exception([
'quiqqer/products',
'exception.field.invalid',
[
'fieldId' => $this->getId(),
'fieldTitle' => $this->getTitle(),
'fieldType' => $this->getType()
]
]);
}
if (!isset($value['price']) || !isset($value['from']) || !isset($value['to'])) {
throw new QUI\ERP\Products\Field\Exception([
'quiqqer/products',
'exception.field.invalid',
[
'fieldId' => $this->getId(),
'fieldTitle' => $this->getTitle(),
'fieldType' => $this->getType()
]
]);
}
}
/**
......@@ -225,4 +266,19 @@ 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'];
}
}
......@@ -191,7 +191,7 @@ public function __construct($pid, $product = [])
}
if ($Field instanceof QUI\ERP\Products\Field\Types\Price && !empty($field['value'])) {
$field['value'] = \floatval($field['value']);
$field['value'] = $Field->cleanup($field['value']);
}
try {
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren