Discount only for applications

This commit is contained in:
Michael RICOIS 2017-11-06 12:00:30 +01:00
parent cd73ae71a8
commit 2fb0bd187d
2 changed files with 28 additions and 6 deletions

View File

@ -77,6 +77,7 @@ class AdminDiscounts extends AdminTab
$object->cumulable = (!isset($_POST['cumulable']) ? false : true);
$object->cumulable_reduction = (!isset($_POST['cumulable_reduction']) ? false : true);
$object->appli = (!isset($_POST['appli']) ? 0 : 1);
}
public function postProcess()
@ -133,7 +134,6 @@ class AdminDiscounts extends AdminTab
$this->_errors[] = Tools::displayError('Please set a category for this voucher.');
$this->copyFromPost($object, $this->table);
$result = $object->update(true, false, $categories);
// @Override Antadis - link discount to custom group
if ($discount_custom_group_id = Tools::getValue("discount_custom_group")) {
CustomGroup::linkToDiscount($discount_custom_group_id, $object->id);
@ -350,6 +350,13 @@ class AdminDiscounts extends AdminTab
</p>
</div>
<div class="margin-form">
<p>
<input type="checkbox" name="appli"'.(($this->getFieldValue($obj, 'appli') == 1) ? ' checked="checked"' : '').' id="appli_on" value="1" />
<label class="t" for="appli_on"> '.$this->l('Only with application').'</label>
</p>
</div>
<label for="discount_custom_group">'.$this->l('Limiter à un segment :').'</label>
<div class="margin-form">
<select name="discount_custom_group" id="discount_custom_group" style="vertical-align: middle; width: 250px;">

View File

@ -61,7 +61,10 @@ class DiscountCore extends ObjectModel
/** @var integer Indicate if discount is cumulable with already bargained products */
public $cumulable_reduction;
/** vars integer Indicate if discount is only applicable with applications */
public $appli = 0;
/** @var integer Date from wich discount become active */
public $date_from;
@ -90,10 +93,21 @@ class DiscountCore extends ObjectModel
protected $fieldsRequired = array('id_discount_type', 'name', 'value', 'quantity', 'quantity_per_user', 'date_from', 'date_to');
protected $fieldsSize = array('name' => '32', 'date_from' => '32', 'date_to' => '32');
protected $fieldsValidate = array('id_customer' => 'isUnsignedId', 'id_group' => 'isUnsignedId', 'id_discount_type' => 'isUnsignedId', 'id_currency' => 'isUnsignedId',
'name' => 'isDiscountName', 'value' => 'isPrice', 'quantity' => 'isUnsignedInt', 'quantity_per_user' => 'isUnsignedInt',
'cumulable' => 'isBool', 'cumulable_reduction' => 'isBool', 'date_from' => 'isDate',
'date_to' => 'isDate', 'minimal' => 'isUnsignedFloat', 'active' => 'isBool');
protected $fieldsValidate = array(
'id_customer' => 'isUnsignedId',
'id_group' => 'isUnsignedId',
'id_discount_type' => 'isUnsignedId',
'id_currency' => 'isUnsignedId',
'name' => 'isDiscountName', 'value' => 'isPrice',
'quantity' => 'isUnsignedInt',
'quantity_per_user' => 'isUnsignedInt',
'cumulable' => 'isBool',
'cumulable_reduction' => 'isBool',
'date_from' => 'isDate',
'date_to' => 'isDate',
'minimal' => 'isUnsignedFloat',
'active' => 'isBool'
);
protected $fieldsRequiredLang = array('description');
protected $fieldsSizeLang = array('description' => 128);
protected $fieldsValidateLang = array('description' => 'isVoucherDescription');
@ -142,6 +156,7 @@ class DiscountCore extends ObjectModel
$fields['quantity_per_user'] = (int)($this->quantity_per_user);
$fields['cumulable'] = (int)($this->cumulable);
$fields['cumulable_reduction'] = (int)($this->cumulable_reduction);
$fields['appli'] = (int)($this->appli);
$fields['date_from'] = pSQL($this->date_from);
$fields['date_to'] = pSQL($this->date_to);
$fields['minimal'] = (float)($this->minimal);