Fixed labels, using templates for HTML fragments
This commit is contained in:
@@ -27,7 +27,7 @@ use Thelia\Condition\Implementation\ConditionInterface;
|
|||||||
class ConditionCollection implements Iterator, Countable, ArrayAccess
|
class ConditionCollection implements Iterator, Countable, ArrayAccess
|
||||||
{
|
{
|
||||||
/** @var array Array of ConditionInterface */
|
/** @var array Array of ConditionInterface */
|
||||||
protected $conditions = array();
|
protected $conditions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (PHP 5 >= 5.0.0)
|
* (PHP 5 >= 5.0.0)
|
||||||
@@ -180,7 +180,7 @@ class ConditionCollection implements Iterator, Countable, ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$arrayToSerialize = array();
|
$arrayToSerialize = [];
|
||||||
/** @var ConditionInterface $condition */
|
/** @var ConditionInterface $condition */
|
||||||
foreach ($this as $condition) {
|
foreach ($this as $condition) {
|
||||||
$arrayToSerialize[] = $condition->getSerializableCondition();
|
$arrayToSerialize[] = $condition->getSerializableCondition();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class ConditionFactory
|
|||||||
);
|
);
|
||||||
$collection[] = $conditionNone;
|
$collection[] = $conditionNone;
|
||||||
}
|
}
|
||||||
$serializableConditions = array();
|
$serializableConditions = [];
|
||||||
/** @var $condition ConditionInterface */
|
/** @var $condition ConditionInterface */
|
||||||
foreach ($collection as $condition) {
|
foreach ($collection as $condition) {
|
||||||
$serializableConditions[] = $condition->getSerializableCondition();
|
$serializableConditions[] = $condition->getSerializableCondition();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use Thelia\Condition\SerializableCondition;
|
|||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Exception\InvalidConditionValueException;
|
use Thelia\Exception\InvalidConditionValueException;
|
||||||
|
use Thelia\Model\Base\CurrencyQuery;
|
||||||
use Thelia\Model\Currency;
|
use Thelia\Model\Currency;
|
||||||
use Thelia\Type\FloatType;
|
use Thelia\Type\FloatType;
|
||||||
|
|
||||||
@@ -35,10 +36,10 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
protected $serviceId = null;
|
protected $serviceId = null;
|
||||||
|
|
||||||
/** @var array Available Operators (Operators::CONST) */
|
/** @var array Available Operators (Operators::CONST) */
|
||||||
protected $availableOperators = array();
|
protected $availableOperators = [];
|
||||||
|
|
||||||
/** @var array Parameters validating parameters against */
|
/** @var array Parameters validating parameters against */
|
||||||
protected $validators = array();
|
protected $validators = [];
|
||||||
|
|
||||||
/** @var FacadeInterface Provide necessary value from Thelia */
|
/** @var FacadeInterface Provide necessary value from Thelia */
|
||||||
protected $facade = null;
|
protected $facade = null;
|
||||||
@@ -47,10 +48,10 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
protected $translator = null;
|
protected $translator = null;
|
||||||
|
|
||||||
/** @var array Operators set by Admin in BackOffice */
|
/** @var array Operators set by Admin in BackOffice */
|
||||||
protected $operators = array();
|
protected $operators = [];
|
||||||
|
|
||||||
/** @var array Values set by Admin in BackOffice */
|
/** @var array Values set by Admin in BackOffice */
|
||||||
protected $values = array();
|
protected $values = [];
|
||||||
|
|
||||||
/** @var ConditionEvaluator Conditions validator */
|
/** @var ConditionEvaluator Conditions validator */
|
||||||
protected $conditionValidator = null;
|
protected $conditionValidator = null;
|
||||||
@@ -64,6 +65,7 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
{
|
{
|
||||||
$this->facade = $facade;
|
$this->facade = $facade;
|
||||||
$this->translator = $facade->getTranslator();
|
$this->translator = $facade->getTranslator();
|
||||||
|
$this->parser = $facade->getParser();
|
||||||
$this->conditionValidator = $facade->getConditionEvaluator();
|
$this->conditionValidator = $facade->getConditionEvaluator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,9 +88,9 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
{
|
{
|
||||||
$this->validators = $this->generateInputs();
|
$this->validators = $this->generateInputs();
|
||||||
|
|
||||||
$translatedInputs = array();
|
$translatedInputs = [];
|
||||||
foreach ($this->validators as $key => $validator) {
|
foreach ($this->validators as $key => $validator) {
|
||||||
$translatedOperators = array();
|
$translatedOperators = [];
|
||||||
foreach ($validator['availableOperators'] as $availableOperators) {
|
foreach ($validator['availableOperators'] as $availableOperators) {
|
||||||
$translatedOperators[$availableOperators] = Operators::getI18n(
|
$translatedOperators[$availableOperators] = Operators::getI18n(
|
||||||
$this->translator,
|
$this->translator,
|
||||||
@@ -99,7 +101,7 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
$validator['availableOperators'] = $translatedOperators;
|
$validator['availableOperators'] = $translatedOperators;
|
||||||
$translatedInputs[$key] = $validator;
|
$translatedInputs[$key] = $validator;
|
||||||
}
|
}
|
||||||
$validators = array();
|
$validators = [];
|
||||||
$validators['inputs'] = $translatedInputs;
|
$validators['inputs'] = $translatedInputs;
|
||||||
$validators['setOperators'] = $this->operators;
|
$validators['setOperators'] = $this->operators;
|
||||||
$validators['setValues'] = $this->values;
|
$validators['setValues'] = $this->values;
|
||||||
@@ -216,27 +218,21 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
*/
|
*/
|
||||||
protected function drawBackOfficeInputOperators($inputKey)
|
protected function drawBackOfficeInputOperators($inputKey)
|
||||||
{
|
{
|
||||||
$selectHtml = '';
|
$html = '';
|
||||||
$optionHtml = '';
|
|
||||||
$inputs = $this->getValidators();
|
$inputs = $this->getValidators();
|
||||||
|
|
||||||
if (isset($inputs['inputs'][$inputKey])) {
|
if (isset($inputs['inputs'][$inputKey])) {
|
||||||
$operators = $inputs['inputs'][$inputKey]['availableOperators'];
|
|
||||||
foreach ($operators as $key => $operator) {
|
$html = $this->facade->getParser()->render('coupon/condition-fragments/condition-selector.html', [
|
||||||
$selected = '';
|
'operators' => $inputs['inputs'][$inputKey]['availableOperators'],
|
||||||
if (isset($this->operators) && isset($this->operators[$inputKey]) && $this->operators[$inputKey] == $key) {
|
'value' => isset($this->operators[$inputKey]) ? $this->operators[$inputKey] : '',
|
||||||
$selected = ' selected="selected"';
|
'inputKey' => $inputKey
|
||||||
}
|
]
|
||||||
$optionHtml .= '<option value="' . $key . '" '. $selected . '>' . $operator . '</option>';
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectHtml .= '
|
return $html;
|
||||||
<select class="form-control" id="' . $inputKey . '-operator" name="' . $inputKey . '[operator]">
|
|
||||||
' . $optionHtml . '
|
|
||||||
</select>
|
|
||||||
';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectHtml;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -251,26 +247,19 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
protected function drawBackOfficeBaseInputsText($label, $inputKey)
|
protected function drawBackOfficeBaseInputsText($label, $inputKey)
|
||||||
{
|
{
|
||||||
$operatorSelectHtml = $this->drawBackOfficeInputOperators($inputKey);
|
$operatorSelectHtml = $this->drawBackOfficeInputOperators($inputKey);
|
||||||
|
|
||||||
$currentValue = '';
|
$currentValue = '';
|
||||||
if (isset($this->values) && isset($this->values[$inputKey])) {
|
if (isset($this->values) && isset($this->values[$inputKey])) {
|
||||||
$currentValue = $this->values[$inputKey];
|
$currentValue = $this->values[$inputKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = '
|
return $this->facade->getParser()->render('coupon/conditions-fragments/base-input-text.html', [
|
||||||
<div id="condition-add-operators-values" class="form-group col-md-6">
|
'label' => $label,
|
||||||
<label for="operator">' . $label . '</label>
|
'inputKey' => $inputKey,
|
||||||
<div class="row">
|
'currentValue' => $currentValue,
|
||||||
<div class="col-lg-6">
|
'operatorSelectHtml' => $operatorSelectHtml
|
||||||
' . $operatorSelectHtml . '
|
]
|
||||||
</div>
|
);
|
||||||
<div class="input-group col-lg-6">
|
|
||||||
<input type="text" class="form-control" id="' . $inputKey . '-value" name="' . $inputKey . '[value]" value="' . $currentValue . '">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
';
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -285,23 +274,39 @@ abstract class ConditionAbstract implements ConditionInterface
|
|||||||
*/
|
*/
|
||||||
protected function drawBackOfficeInputQuantityValues($inputKey, $max = 10, $min = 0)
|
protected function drawBackOfficeInputQuantityValues($inputKey, $max = 10, $min = 0)
|
||||||
{
|
{
|
||||||
$selectHtml = '';
|
return $this->facade->getParser()->render('coupon/condition-fragments/quantity-selector.html', [
|
||||||
$optionHtml = '';
|
'min' => $min,
|
||||||
for ($i = $min; $i <= $max; $i++) {
|
'max' => $max,
|
||||||
$selected = '';
|
'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
|
||||||
if (isset($this->values) && isset($this->values[$inputKey]) && $this->values[$inputKey] == $i) {
|
'inputKey' => $inputKey
|
||||||
$selected = ' selected="selected"';
|
]
|
||||||
}
|
);
|
||||||
$optionHtml .= '<option value="' . $i . '" ' . $selected . '>' . $i . '</option>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectHtml .= '
|
/**
|
||||||
<select class="form-control" id="' . $inputKey . '-value" name="' . $inputKey . '[value]">
|
* Draw the currency input displayed in the BackOffice
|
||||||
' . $optionHtml . '
|
* allowing Admin to set its Coupon Conditions
|
||||||
</select>
|
*
|
||||||
';
|
* @param string $inputKey Input key (ex: self::INPUT1)
|
||||||
|
*
|
||||||
|
* @return string HTML string
|
||||||
|
*/
|
||||||
|
protected function drawBackOfficeCurrencyInput($inputKey)
|
||||||
|
{
|
||||||
|
$currencies = CurrencyQuery::create()->find();
|
||||||
|
|
||||||
return $selectHtml;
|
$cleanedCurrencies = [];
|
||||||
|
|
||||||
|
/** @var Currency $currency */
|
||||||
|
foreach ($currencies as $currency) {
|
||||||
|
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->facade->getParser()->render('coupon/condition-fragments/currency-selector.html', [
|
||||||
|
'currencies' => $cleanedCurrencies,
|
||||||
|
'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
|
||||||
|
'inputKey' => $inputKey
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ class MatchForEveryone extends ConditionAbstract
|
|||||||
protected $serviceId = 'thelia.condition.match_for_everyone';
|
protected $serviceId = 'thelia.condition.match_for_everyone';
|
||||||
|
|
||||||
/** @var array Available Operators (Operators::CONST) */
|
/** @var array Available Operators (Operators::CONST) */
|
||||||
protected $availableOperators = array();
|
protected $availableOperators = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check validators relevancy and store them
|
* Check validators relevancy and store them
|
||||||
@@ -51,8 +51,8 @@ class MatchForEveryone extends ConditionAbstract
|
|||||||
*/
|
*/
|
||||||
protected function setValidators()
|
protected function setValidators()
|
||||||
{
|
{
|
||||||
$this->operators = array();
|
$this->operators = [];
|
||||||
$this->values = array();
|
$this->values = [];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -75,8 +75,8 @@ class MatchForEveryone extends ConditionAbstract
|
|||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->translator->trans(
|
return $this->translator->trans(
|
||||||
'Everybody can use it (no condition)',
|
'Unconditional usage',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -90,8 +90,8 @@ class MatchForEveryone extends ConditionAbstract
|
|||||||
public function getToolTip()
|
public function getToolTip()
|
||||||
{
|
{
|
||||||
$toolTip = $this->translator->trans(
|
$toolTip = $this->translator->trans(
|
||||||
'Will return always true',
|
'This condition is always true',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -107,8 +107,8 @@ class MatchForEveryone extends ConditionAbstract
|
|||||||
public function getSummary()
|
public function getSummary()
|
||||||
{
|
{
|
||||||
$toolTip = $this->translator->trans(
|
$toolTip = $this->translator->trans(
|
||||||
'Will return always true',
|
'Unconditionnal usage',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class MatchForEveryone extends ConditionAbstract
|
|||||||
*/
|
*/
|
||||||
protected function generateInputs()
|
protected function generateInputs()
|
||||||
{
|
{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class MatchForTotalAmount extends ConditionAbstract
|
|||||||
{
|
{
|
||||||
return $this->translator->trans(
|
return $this->translator->trans(
|
||||||
'By cart total amount',
|
'By cart total amount',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ class MatchForTotalAmount extends ConditionAbstract
|
|||||||
{
|
{
|
||||||
$toolTip = $this->translator->trans(
|
$toolTip = $this->translator->trans(
|
||||||
'Check the total Cart amount in the given currency',
|
'Check the total Cart amount in the given currency',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ class MatchForTotalAmount extends ConditionAbstract
|
|||||||
protected function generateInputs()
|
protected function generateInputs()
|
||||||
{
|
{
|
||||||
$currencies = CurrencyQuery::create()->find();
|
$currencies = CurrencyQuery::create()->find();
|
||||||
$cleanedCurrencies = array();
|
$cleanedCurrencies = [];
|
||||||
/** @var Currency $currency */
|
/** @var Currency $currency */
|
||||||
foreach ($currencies as $currency) {
|
foreach ($currencies as $currency) {
|
||||||
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
|
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
|
||||||
@@ -240,7 +240,7 @@ class MatchForTotalAmount extends ConditionAbstract
|
|||||||
{
|
{
|
||||||
$labelPrice = $this->facade
|
$labelPrice = $this->facade
|
||||||
->getTranslator()
|
->getTranslator()
|
||||||
->trans('Price', array(), 'condition');
|
->trans('Cart total amount is', [], 'condition');
|
||||||
|
|
||||||
$html = $this->drawBackOfficeBaseInputsText($labelPrice, self::INPUT1);
|
$html = $this->drawBackOfficeBaseInputsText($labelPrice, self::INPUT1);
|
||||||
|
|
||||||
@@ -258,66 +258,17 @@ class MatchForTotalAmount extends ConditionAbstract
|
|||||||
*/
|
*/
|
||||||
protected function drawBackOfficeBaseInputsText($label, $inputKey)
|
protected function drawBackOfficeBaseInputsText($label, $inputKey)
|
||||||
{
|
{
|
||||||
$operatorSelectHtml = $this->drawBackOfficeInputOperators(self::INPUT1);
|
return $this->facade->getParser()->render('coupon/condition-fragments/cart-total-amount-condition.html', [
|
||||||
$currencySelectHtml = $this->drawBackOfficeCurrencyInput(self::INPUT2);
|
'label' => $label,
|
||||||
$selectedAmount = '';
|
'inputKey' => $inputKey,
|
||||||
if (isset($this->values) && isset($this->values[$inputKey])) {
|
'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
|
||||||
$selectedAmount = $this->values[$inputKey];
|
|
||||||
|
'field_1_name' => self::INPUT1,
|
||||||
|
'field_2_name' => self::INPUT2,
|
||||||
|
|
||||||
|
'operatorSelectHtml' => $this->drawBackOfficeInputOperators(self::INPUT1),
|
||||||
|
'currencySelectHtml' => $this->drawBackOfficeCurrencyInput(self::INPUT2),
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = '
|
|
||||||
<label for="operator">' . $label . '</label>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
' . $operatorSelectHtml . '
|
|
||||||
</div>
|
|
||||||
<div class="input-group col-lg-3">
|
|
||||||
<input type="text" class="form-control" id="' . self::INPUT1 . '-value" name="' . self::INPUT1 . '[value]" value="' . $selectedAmount . '">
|
|
||||||
</div>
|
|
||||||
<div class="input-group col-lg-3">
|
|
||||||
<input type="hidden" id="' . self::INPUT2 . '-operator" name="' . self::INPUT2 . '[operator]" value="==" />
|
|
||||||
' . $currencySelectHtml . '
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
';
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw the currency input displayed in the BackOffice
|
|
||||||
* allowing Admin to set its Coupon Conditions
|
|
||||||
*
|
|
||||||
* @param string $inputKey Input key (ex: self::INPUT1)
|
|
||||||
*
|
|
||||||
* @return string HTML string
|
|
||||||
*/
|
|
||||||
protected function drawBackOfficeCurrencyInput($inputKey)
|
|
||||||
{
|
|
||||||
$optionHtml = '';
|
|
||||||
|
|
||||||
$currencies = CurrencyQuery::create()->find();
|
|
||||||
$cleanedCurrencies = array();
|
|
||||||
/** @var Currency $currency */
|
|
||||||
foreach ($currencies as $currency) {
|
|
||||||
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($cleanedCurrencies as $key => $cleanedCurrency) {
|
|
||||||
$selected = '';
|
|
||||||
if (isset($this->values) && isset($this->values[$inputKey]) && $this->values[$inputKey] == $key) {
|
|
||||||
$selected = ' selected="selected"';
|
|
||||||
}
|
|
||||||
$optionHtml .= '<option value="' . $key . '" ' . $selected . '>' . $cleanedCurrency . '</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$selectHtml = '
|
|
||||||
<select class="form-control" id="' . $inputKey . '-value" name="' . $inputKey . '[value]">
|
|
||||||
' . $optionHtml . '
|
|
||||||
</select>
|
|
||||||
';
|
|
||||||
|
|
||||||
return $selectHtml;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -127,8 +127,8 @@ class MatchForXArticles extends ConditionAbstract
|
|||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->translator->trans(
|
return $this->translator->trans(
|
||||||
'By number of articles in cart',
|
'Cart item count condition',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -142,8 +142,8 @@ class MatchForXArticles extends ConditionAbstract
|
|||||||
public function getToolTip()
|
public function getToolTip()
|
||||||
{
|
{
|
||||||
$toolTip = $this->translator->trans(
|
$toolTip = $this->translator->trans(
|
||||||
'Check the amount of product in the Cart',
|
'The cart item count should match the condition',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ class MatchForXArticles extends ConditionAbstract
|
|||||||
);
|
);
|
||||||
|
|
||||||
$toolTip = $this->translator->trans(
|
$toolTip = $this->translator->trans(
|
||||||
'If cart products quantity is <strong>%operator%</strong> %quantity%',
|
'If cart item count is <strong>%operator%</strong> %quantity%',
|
||||||
array(
|
array(
|
||||||
'%operator%' => $i18nOperator,
|
'%operator%' => $i18nOperator,
|
||||||
'%quantity%' => $this->values[self::INPUT1]
|
'%quantity%' => $this->values[self::INPUT1]
|
||||||
@@ -200,7 +200,7 @@ class MatchForXArticles extends ConditionAbstract
|
|||||||
{
|
{
|
||||||
$labelQuantity = $this->facade
|
$labelQuantity = $this->facade
|
||||||
->getTranslator()
|
->getTranslator()
|
||||||
->trans('Quantity', array(), 'condition');
|
->trans('Cart item count is', [], 'condition');
|
||||||
|
|
||||||
$html = $this->drawBackOfficeBaseInputsText($labelQuantity, self::INPUT1);
|
$html = $this->drawBackOfficeBaseInputsText($labelQuantity, self::INPUT1);
|
||||||
|
|
||||||
@@ -218,24 +218,11 @@ class MatchForXArticles extends ConditionAbstract
|
|||||||
*/
|
*/
|
||||||
protected function drawBackOfficeBaseInputsText($label, $inputKey)
|
protected function drawBackOfficeBaseInputsText($label, $inputKey)
|
||||||
{
|
{
|
||||||
$operatorSelectHtml = $this->drawBackOfficeInputOperators($inputKey);
|
return $this->facade->getParser()->render('coupon/condition-fragments/cart-item-count-condition.html', [
|
||||||
$quantitySelectHtml = $this->drawBackOfficeInputQuantityValues($inputKey, 20, 1);
|
'label' => $label,
|
||||||
|
'operatorSelectHtml' => $this->drawBackOfficeInputOperators($inputKey),
|
||||||
$html = '
|
'quantitySelectHtml' => $this->drawBackOfficeInputQuantityValues($inputKey, 20, 1)
|
||||||
<div id="condition-add-operators-values" class="form-group col-md-6">
|
]
|
||||||
<label for="operator">' . $label . '</label>
|
);
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
' . $operatorSelectHtml . '
|
|
||||||
</div>
|
|
||||||
<div class="input-group col-lg-6">
|
|
||||||
' . $quantitySelectHtml . '
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
';
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -54,57 +54,57 @@ abstract class Operators
|
|||||||
switch ($operator) {
|
switch ($operator) {
|
||||||
case self::INFERIOR:
|
case self::INFERIOR:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'inferior to',
|
'Less than',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::INFERIOR_OR_EQUAL:
|
case self::INFERIOR_OR_EQUAL:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'inferior or equal to',
|
'Less than or equals',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::EQUAL:
|
case self::EQUAL:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'equal to',
|
'Equals to',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::SUPERIOR_OR_EQUAL:
|
case self::SUPERIOR_OR_EQUAL:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'superior or equal to',
|
'Greater than or equals',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::SUPERIOR:
|
case self::SUPERIOR:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'superior to',
|
'Greater than',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::DIFFERENT:
|
case self::DIFFERENT:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'different from',
|
'Not equals',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::IN:
|
case self::IN:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'in',
|
'In',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::OUT:
|
case self::OUT:
|
||||||
$ret = $translator->trans(
|
$ret = $translator->trans(
|
||||||
'not in',
|
'Not in',
|
||||||
array(),
|
[],
|
||||||
'condition'
|
'condition'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ class SerializableCondition
|
|||||||
public $conditionServiceId = null;
|
public $conditionServiceId = null;
|
||||||
|
|
||||||
/** @var array Operators set by Admin for this Condition */
|
/** @var array Operators set by Admin for this Condition */
|
||||||
public $operators = array();
|
public $operators = [];
|
||||||
|
|
||||||
/** @var array Values set by Admin for this Condition */
|
/** @var array Values set by Admin for this Condition */
|
||||||
public $values = array();
|
public $values = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -292,30 +292,42 @@ class CouponController extends BaseAdminController
|
|||||||
*/
|
*/
|
||||||
public function getConditionEmptyInputAjaxAction($conditionId)
|
public function getConditionEmptyInputAjaxAction($conditionId)
|
||||||
{
|
{
|
||||||
$this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW);
|
if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW))
|
||||||
|
return $response;
|
||||||
|
|
||||||
$this->checkXmlHttpRequest();
|
$this->checkXmlHttpRequest();
|
||||||
|
|
||||||
|
if (! empty($conditionId)) {
|
||||||
|
|
||||||
/** @var ConditionFactory $conditionFactory */
|
/** @var ConditionFactory $conditionFactory */
|
||||||
$conditionFactory = $this->container->get('thelia.condition.factory');
|
$conditionFactory = $this->container->get('thelia.condition.factory');
|
||||||
$inputs = $conditionFactory->getInputsFromServiceId($conditionId);
|
$inputs = $conditionFactory->getInputsFromServiceId($conditionId);
|
||||||
|
|
||||||
if (!$this->container->has($conditionId)) {
|
if (!$this->container->has($conditionId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var ConditionInterface $condition */
|
|
||||||
$condition = $this->container->get($conditionId);
|
|
||||||
|
|
||||||
if ($inputs === null) {
|
if ($inputs === null) {
|
||||||
return $this->pageNotFound();
|
return $this->pageNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var ConditionInterface $condition */
|
||||||
|
$condition = $this->container->get($conditionId);
|
||||||
|
|
||||||
|
$html = $condition->drawBackOfficeInputs();
|
||||||
|
$serviceId = $condition->getServiceId();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$html = '';
|
||||||
|
$serviceId = '';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'coupon/condition-input-ajax',
|
'coupon/condition-input-ajax',
|
||||||
array(
|
array(
|
||||||
'inputsDrawn' => $condition->drawBackOfficeInputs(),
|
'inputsDrawn' => $html,
|
||||||
'conditionServiceId' => $condition->getServiceId(),
|
'conditionServiceId' => $serviceId,
|
||||||
'conditionIndex' => -1,
|
'conditionIndex' => '',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user