2155 lines
111 KiB
PHP
2155 lines
111 KiB
PHP
<?php
|
|
/**
|
|
* Copyright ETS Software Technology Co., Ltd
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This file is not open source! Each license that you purchased is only available for 1 website only.
|
|
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
|
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
* versions in the future.
|
|
*
|
|
* @author ETS Software Technology Co., Ltd
|
|
* @copyright ETS Software Technology Co., Ltd
|
|
* @license Valid for 1 website (or project) for each purchase of license
|
|
*/
|
|
|
|
if (!defined('_PS_VERSION_'))
|
|
exit;
|
|
class Ets_pr_condition_rule extends Ets_pr_obj
|
|
{
|
|
public static $instance;
|
|
public $id_ets_pr_rule;
|
|
public $parent_codition;
|
|
public $condition;
|
|
public $id_customers;
|
|
public $id_groups;
|
|
public $only_apply_on_default_group;
|
|
public $id_genders;
|
|
public $age_from;
|
|
public $age_to;
|
|
public $on_customer_birthday;
|
|
public $verified_customer;
|
|
public $customer_signed_up_from;
|
|
public $customer_signed_up_to;
|
|
public $days_since_signed_up_cal;
|
|
public $days_since_singed_up_day;
|
|
public $newsletter_registration;
|
|
public $order_criteria;
|
|
public $first_order_of_customer;
|
|
public $number_of_order_cal;
|
|
public $number_of_order;
|
|
public $number_of_product_cal;
|
|
public $number_of_product;
|
|
public $amount_of_money_spent_cal;
|
|
public $amount_of_money_spent;
|
|
public $amount_of_money_spent_tax_incl;
|
|
public $amount_of_money_spent_shipping_incl;
|
|
public $amount_of_money_spent_discount_incl;
|
|
public $order_time_in;
|
|
public $order_time_in_from;
|
|
public $order_time_in_to;
|
|
public $order_time_in_last_day;
|
|
public $order_status_in;
|
|
public $cart_amount_cal;
|
|
public $cart_amount;
|
|
public $cart_amount_tax_incl;
|
|
public $cart_amount_shipping_incl;
|
|
public $cart_amount_discount_incl;
|
|
public $total_product_quantity_cal;
|
|
public $total_product_quantity;
|
|
public $quantity_of_same_product_cal;
|
|
public $quantity_of_same_product;
|
|
public $number_of_different_product_cal;
|
|
public $number_of_different_product;
|
|
public $number_of_product_in_same_category_cal;
|
|
public $number_of_product_in_same_category;
|
|
public $apply_for_discounted_products;
|
|
public $products_with_different_attribute;
|
|
public $applicable_product_categories;
|
|
public $include_specific_products;
|
|
public $exclude_products;
|
|
public $apply_all_attribute;
|
|
public $select_attributes;
|
|
public $apply_all_features;
|
|
public $select_features;
|
|
public $apply_all_supplier;
|
|
public $select_suppliers;
|
|
public $apply_all_manufacturer;
|
|
public $select_manufacturers;
|
|
public $apply_for_product_price_cal;
|
|
public $apply_for_product_price;
|
|
public $apply_for_availabled_quantity_stock_cal;
|
|
public $apply_for_availabled_quantity_stock;
|
|
public $delivery_total_cart_weight_cal;
|
|
public $delivery_total_cart_weight;
|
|
public $delivery_apply_to_carriers;
|
|
public $delivery_id_zone;
|
|
public $delivery_id_country;
|
|
public $delivery_id_state;
|
|
public $delivery_speed_grade_cal;
|
|
public $delivery_speed_grade;
|
|
public $payments;
|
|
public $specific_occasion;
|
|
public $specific_occasion_hour_of_day_from;
|
|
public $specific_occasion_hour_of_day_to;
|
|
public $specific_occasion_day_of_week;
|
|
public $specific_occasion_day_of_week_from;
|
|
public $specific_occasion_day_of_week_to;
|
|
public $specific_occasion_month_of_year;
|
|
public $specific_occasion_month_of_year_from;
|
|
public $specific_occasion_month_of_year_to;
|
|
public $specific_occasion_date_from;
|
|
public $specific_occasion_date_to;
|
|
public $include_sub_categories;
|
|
public $applicable_categories;
|
|
public static $definition = array(
|
|
'table' => 'ets_pr_condition_rule',
|
|
'primary' => 'id_ets_pr_condition_rule',
|
|
'fields' => array(
|
|
'id_ets_pr_rule' => array('type' => self::TYPE_INT),
|
|
'parent_codition' => array('type' => self::TYPE_STRING),
|
|
'condition' => array('type' => self::TYPE_STRING),
|
|
'id_customers' => array('type' => self::TYPE_STRING),
|
|
'id_groups' => array('type' => self::TYPE_STRING),
|
|
'only_apply_on_default_group' => array('type' => self::TYPE_INT),
|
|
'id_genders' => array('type' => self::TYPE_STRING),
|
|
'age_from' => array('type' => self::TYPE_INT),
|
|
'age_to' => array('type' => self::TYPE_INT),
|
|
'on_customer_birthday' => array('type' => self::TYPE_INT),
|
|
'verified_customer' => array('type' => self::TYPE_INT),
|
|
'customer_signed_up_from' => array('type' => self::TYPE_DATE),
|
|
'customer_signed_up_to' => array('type' => self::TYPE_DATE),
|
|
'days_since_signed_up_cal' => array('type' => self::TYPE_HTML),
|
|
'days_since_singed_up_day' => array('type' => self::TYPE_INT),
|
|
'newsletter_registration' => array('type' => self::TYPE_STRING),
|
|
'order_criteria' => array('type' => self::TYPE_STRING),
|
|
'first_order_of_customer' => array('type' => self::TYPE_INT),
|
|
'number_of_order_cal' => array('type' => self::TYPE_HTML),
|
|
'number_of_order' => array('type' => self::TYPE_INT),
|
|
'number_of_product_cal' => array('type' => self::TYPE_HTML),
|
|
'number_of_product' => array('type' => self::TYPE_INT),
|
|
'amount_of_money_spent_cal' => array('type' => self::TYPE_HTML),
|
|
'amount_of_money_spent' => array('type' => self::TYPE_FLOAT),
|
|
'amount_of_money_spent_tax_incl' => array('type' => self::TYPE_INT),
|
|
'amount_of_money_spent_shipping_incl' => array('type' => self::TYPE_INT),
|
|
'amount_of_money_spent_discount_incl' => array('type' => self::TYPE_INT),
|
|
'order_time_in' => array('type' => self::TYPE_STRING),
|
|
'order_time_in_last_day' => array('type' => self::TYPE_INT),
|
|
'order_time_in_from' => array('type' => self::TYPE_DATE),
|
|
'order_time_in_to' => array('type' => self::TYPE_DATE),
|
|
'order_status_in' => array('type' => self::TYPE_STRING),
|
|
'cart_amount_cal' => array('type' => self::TYPE_HTML),
|
|
'cart_amount' => array('type' => self::TYPE_FLOAT),
|
|
'cart_amount_tax_incl' => array('type' => self::TYPE_INT),
|
|
'cart_amount_shipping_incl' => array('type' => self::TYPE_INT),
|
|
'cart_amount_discount_incl' => array('type' => self::TYPE_INT),
|
|
'total_product_quantity_cal' => array('type' => self::TYPE_HTML),
|
|
'total_product_quantity' => array('type' => self::TYPE_INT),
|
|
'quantity_of_same_product_cal' => array('type' => self::TYPE_HTML),
|
|
'quantity_of_same_product' => array('type' => self::TYPE_INT),
|
|
'number_of_different_product_cal' => array('type' => self::TYPE_HTML),
|
|
'number_of_different_product' => array('type' => self::TYPE_INT),
|
|
'number_of_product_in_same_category_cal' => array('type' => self::TYPE_HTML),
|
|
'number_of_product_in_same_category' => array('type' => self::TYPE_INT),
|
|
'apply_for_discounted_products' => array('type' => self::TYPE_INT),
|
|
'products_with_different_attribute' => array('type' => self::TYPE_INT),
|
|
'applicable_product_categories' => array('type' => self::TYPE_STRING),
|
|
'include_specific_products' => array('type' => self::TYPE_STRING),
|
|
'exclude_products' => array('type' => self::TYPE_STRING),
|
|
'apply_all_attribute' => array('type' => self::TYPE_INT),
|
|
'select_attributes' => array('type' => self::TYPE_STRING),
|
|
'apply_all_features' => array('type' => self::TYPE_INT),
|
|
'select_features' => array('type' => self::TYPE_STRING),
|
|
'apply_all_supplier' => array('type' => self::TYPE_INT),
|
|
'select_suppliers' => array('type' => self::TYPE_STRING),
|
|
'apply_all_manufacturer' => array('type' => self::TYPE_INT),
|
|
'select_manufacturers' => array('type' => self::TYPE_STRING),
|
|
'apply_for_product_price_cal' => array('type' => self::TYPE_HTML),
|
|
'apply_for_product_price' => array('type' => self::TYPE_FLOAT),
|
|
'apply_for_availabled_quantity_stock_cal' => array('type' => self::TYPE_HTML),
|
|
'apply_for_availabled_quantity_stock' => array('type' => self::TYPE_INT),
|
|
'delivery_total_cart_weight_cal' => array('type' => self::TYPE_HTML),
|
|
'delivery_total_cart_weight' => array('type' => self::TYPE_FLOAT),
|
|
'delivery_apply_to_carriers' => array('type' => self::TYPE_STRING),
|
|
'delivery_id_zone' => array('type' => self::TYPE_INT),
|
|
'delivery_id_country' => array('type' => self::TYPE_INT),
|
|
'delivery_id_state' => array('type' => self::TYPE_INT),
|
|
'delivery_speed_grade_cal' => array('type' => self::TYPE_HTML),
|
|
'delivery_speed_grade' => array('type' => self::TYPE_FLOAT),
|
|
'payments' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_hour_of_day_from' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_hour_of_day_to' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_day_of_week' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_day_of_week_from' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_day_of_week_to' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_month_of_year' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_month_of_year_from' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_month_of_year_to' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_date_from' => array('type' => self::TYPE_STRING),
|
|
'specific_occasion_date_to' => array('type' => self::TYPE_STRING),
|
|
'include_sub_categories' => array('type' => self::TYPE_INT),
|
|
'applicable_categories' => array('type' => self::TYPE_STRING),
|
|
)
|
|
);
|
|
public function __construct($id_item = null, $id_lang = null, $id_shop = null)
|
|
{
|
|
parent::__construct($id_item, $id_lang, $id_shop);
|
|
}
|
|
public static function getInstance()
|
|
{
|
|
if (!(isset(self::$instance)) || !self::$instance) {
|
|
self::$instance = new Ets_pr_condition_rule();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
public function l($string,$file_name='')
|
|
{
|
|
return Translate::getModuleTranslation('ets_promotion', $string, $file_name ? : pathinfo(__FILE__, PATHINFO_FILENAME));
|
|
}
|
|
public function getListFields()
|
|
{
|
|
$configs = array(
|
|
'id_ets_pr_rule' => array(
|
|
'type' => 'hidden',
|
|
'label' => '',
|
|
'default' => $this->id_ets_pr_rule,
|
|
'validate'=>'isUnsignedId',
|
|
),
|
|
'parent_codition'=>array(
|
|
'type'=>'select',
|
|
'label'=>$this->l('Condition'),
|
|
'options' => array(
|
|
'optiongroup' => array(
|
|
'query' => array(
|
|
array(
|
|
'label' => $this->l('Customer'),
|
|
'options' => array(
|
|
array(
|
|
'label' => $this->l('Specific customer'),
|
|
'value' => 'specific_customer'
|
|
),
|
|
array(
|
|
'label' => $this->l('Customer group'),
|
|
'value' => 'customer_group'
|
|
),
|
|
array(
|
|
'label' => $this->l('Customer personal information'),
|
|
'value' => 'customer_personal',
|
|
),
|
|
array(
|
|
'label' => $this->l('Customer membership'),
|
|
'value' => 'customer_membership',
|
|
),
|
|
array(
|
|
'label' => $this->l('Orders placed by customer'),
|
|
'value' => 'order_from_customer',
|
|
),
|
|
)
|
|
),
|
|
array(
|
|
'label' => $this->l('Shopping cart'),
|
|
'options' => array(
|
|
array(
|
|
'label' =>$this->l('Cart amount'),
|
|
'value' => 'cart_amount',
|
|
),
|
|
array(
|
|
'label' => $this->l('Products in cart'),
|
|
'value' => 'product_in_cart',
|
|
),
|
|
array(
|
|
'label' => $this->l('Delivery'),
|
|
'value' => 'delivery',
|
|
),
|
|
array(
|
|
'label' => $this->l('Payment methods'),
|
|
'value' => 'payments',
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'label' => $this->l('Others'),
|
|
'options' => array(
|
|
array(
|
|
'label' => $this->l('Specific occasion'),
|
|
'value' => 'specific_occasion'
|
|
)
|
|
),
|
|
),
|
|
),
|
|
'label' => 'label',
|
|
|
|
),
|
|
'options' => array(
|
|
'query' => 'options',
|
|
'id' => 'value',
|
|
'name' => 'label'
|
|
),
|
|
'default' => array(
|
|
'value' => '',
|
|
'label' => $this->l('-- Select condition --'),
|
|
),
|
|
),
|
|
'required' => true,
|
|
),
|
|
'id_customers' => array(
|
|
'type' => 'search_customer',
|
|
'label' => $this->l('Customer'),
|
|
'form_group_class' => 'parent_codition specific_customer',
|
|
'validate'=>'isCleanHtml',
|
|
'showRequired' => true,
|
|
'placeholder' => $this->l('Search by customer name, email')
|
|
),
|
|
'id_groups' => array(
|
|
'type' => 'checkbox',
|
|
'label' => $this->l('Customer group'),
|
|
'form_group_class' => 'parent_codition customer_group',
|
|
'values' => array(
|
|
'query' => $this->getGroups(),
|
|
'id' => 'id_group',
|
|
'name' => 'name'
|
|
),
|
|
'validate'=>'isCleanHtml',
|
|
'showRequired' => true,
|
|
),
|
|
'only_apply_on_default_group' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Only apply on the default group'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'only_apply_on_default_group_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'only_apply_on_default_group_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition customer_group',
|
|
'validate'=>'isUnsignedId',
|
|
),
|
|
'id_genders' => array(
|
|
'type' => 'checkbox',
|
|
'label' => $this->l('Gender'),
|
|
'form_group_class' => 'parent_codition customer_personal',
|
|
'values' => array(
|
|
'query' => $this->getGenders(),
|
|
'id' => 'id_gender',
|
|
'name' => 'name'
|
|
),
|
|
'validate'=>'isCleanHtml',
|
|
),
|
|
'age_from' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('From age'),
|
|
'form_group_class' => 'parent_codition customer_personal',
|
|
'validate' => 'isUnsignedInt',
|
|
),
|
|
'age_to' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('To age'),
|
|
'form_group_class' => 'parent_codition customer_personal',
|
|
'validate' => 'isUnsignedInt'
|
|
),
|
|
'on_customer_birthday' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('On customer birthday'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'on_customer_birthday_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'on_customer_birthday_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition customer_personal',
|
|
'validate' => 'isUnsignedInt'
|
|
),
|
|
'verified_customer' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Verified customer'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'verified_customer_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'verified_customer_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition customer_personal',
|
|
'validate' => 'isUnsignedInt'
|
|
),
|
|
'customer_signed_up_from' => array(
|
|
'type' => 'date',
|
|
'label' => $this->l('Registration date from'),
|
|
'form_group_class' => 'parent_codition customer_membership',
|
|
'validate' => 'isDate',
|
|
),
|
|
'customer_signed_up_to' => array(
|
|
'type' => 'date',
|
|
'label' => $this->l('Registration date to'),
|
|
'form_group_class' => 'parent_codition customer_membership',
|
|
'validate' => 'isDate',
|
|
),
|
|
'days_since_signed_up_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Days since registration'),
|
|
'form_group_class' => 'parent_codition customer_membership',
|
|
'validate' => 'isCleanHtml'
|
|
),
|
|
'days_since_singed_up_day' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Days since registration'),
|
|
'validate'=>'isUnsignedInt',
|
|
'form_group_class' => 'parent_codition customer_membership',
|
|
|
|
),
|
|
'newsletter_registration' => array(
|
|
'type'=>'checkbox',
|
|
'label'=>$this->l('Newsletter registration'),
|
|
'values' => array(
|
|
'query' => array(
|
|
array(
|
|
'name' => $this->l('Receive offers from partners'),
|
|
'id' => 'reccive_offers'
|
|
),
|
|
array(
|
|
'name' => $this->l('Sign up for newsletter'),
|
|
'id' => 'sign_up'
|
|
)
|
|
),
|
|
'id' => 'id',
|
|
'name' => 'name'
|
|
),
|
|
'form_group_class' => 'parent_codition customer_membership',
|
|
'validate' => 'isCleanHtml'
|
|
),
|
|
'first_order_of_customer' => array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('On the first order of customer'),
|
|
'default' => 0,
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'first_order_of_customer_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'first_order_of_customer_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'order_criteria'=> array(
|
|
'type' => 'radio',
|
|
'label' => 'Order criteria',
|
|
'default' => 'number_of_orders',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'order_criteria_number_of_orders',
|
|
'value' => 'number_of_orders',
|
|
'label' => $this->l('Number of orders'),
|
|
),
|
|
array(
|
|
'id' => 'order_criteria_amount_of_money_spent',
|
|
'value' => 'amount_of_money_spent',
|
|
'label' => $this->l('Amount of money spent'),
|
|
),
|
|
array(
|
|
'id' => 'order_criteria_number_of_products',
|
|
'value' => 'number_of_products',
|
|
'label' => $this->l('Number of products'),
|
|
),
|
|
),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'number_of_product_cal' => array(
|
|
'type'=>'select',
|
|
'label' =>$this->l('Number of products'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'number_of_product' => array(
|
|
'type'=>'text',
|
|
'label' =>$this->l('Number of products'),
|
|
'suffix' => $this->l('Products'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isUnsignedInt'
|
|
),
|
|
'number_of_order_cal' => array(
|
|
'type'=>'select',
|
|
'label' =>$this->l('Number of orders'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'number_of_order' => array(
|
|
'type'=>'text',
|
|
'label' =>$this->l('Number of orders'),
|
|
'suffix' => $this->l('Orders'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isUnsignedInt'
|
|
),
|
|
'amount_of_money_spent_cal' => array(
|
|
'type'=>'select',
|
|
'label' =>$this->l('Amount of money spent'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'amount_of_money_spent' => array(
|
|
'type'=>'text',
|
|
'label' =>$this->l('Amount of money spent'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'suffix' => Context::getContext()->currency->sign,
|
|
'validate' => 'isUnsignedFloat'
|
|
),
|
|
'amount_of_money_spent_tax_incl' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Tax included'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'amount_of_money_spent_tax_incl_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'amount_of_money_spent_tax_incl_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'amount_of_money_spent_shipping_incl' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Shipping included'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'amount_of_money_spent_shipping_incl_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'amount_of_money_spent_shipping_incl_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'amount_of_money_spent_discount_incl' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Discount included'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'amount_of_money_spent_discount_incl_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'amount_of_money_spent_discount_incl_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'order_time_in' => array(
|
|
'type' => 'radio',
|
|
'label' => $this->l('Ordered time in'),
|
|
'default' => 'this_year',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'order_time_in_all',
|
|
'value' => 'all',
|
|
'label' => $this->l('All time'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_this_year',
|
|
'value' => 'this_year',
|
|
'label' => $this->l('This year'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_year_1',
|
|
'value' => 'year_1',
|
|
'label' => $this->l('Year -1'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_this_month',
|
|
'value' => 'this_month',
|
|
'label' => $this->l('This month'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_month_1',
|
|
'value' => 'month_1',
|
|
'label' => $this->l('Month -1'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_this_week',
|
|
'value' => 'this_week',
|
|
'label' => $this->l('This week'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_week_1',
|
|
'value' => 'week_1',
|
|
'label' => $this->l('Week -1'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_from_to',
|
|
'value' => 'from_to',
|
|
'label' => $this->l('From -To'),
|
|
),
|
|
array(
|
|
'id' => 'order_time_in_in_last_day',
|
|
'value' => 'in_last_day',
|
|
'label' => $this->l('X day(s) ago'),
|
|
),
|
|
),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'order_time_in_from' => array(
|
|
'type' => 'date',
|
|
'label' => $this->l('Ordered time from'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'default' => date('Y-m-d H:i:s', strtotime('-1 months')),
|
|
),
|
|
'order_time_in_to' => array(
|
|
'type' => 'date',
|
|
'label' => $this->l('Ordered time to'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'default' => date('Y-m-d H:i:s'),
|
|
),
|
|
'order_time_in_last_day' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Ordered time in the last'),
|
|
'suffix' => $this->l('Days'),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' =>'isUnsignedInt',
|
|
'showRequired' => true,
|
|
),
|
|
'order_status_in' => array(
|
|
'type' => 'checkbox',
|
|
'label' => $this->l('Order status is'),
|
|
'values' => array(
|
|
'query' => $this->getOrderStates(),
|
|
'id' => 'id_order_state',
|
|
'name' => 'name'
|
|
),
|
|
'form_group_class' => 'parent_codition order_from_customer',
|
|
'validate' => 'isCleanHtml',
|
|
'default' => $this->getOrderStatesPaid(),
|
|
),
|
|
'cart_amount_cal' => array(
|
|
'label' =>$this->l('Cart amount calculator'),
|
|
'type' => "select",
|
|
'form_group_class' => 'parent_codition cart_amount',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'cart_amount' => array(
|
|
'label' =>$this->l('Cart amount'),
|
|
'type' => "text",
|
|
'suffix' => Context::getContext()->currency->sign,
|
|
'form_group_class' => 'parent_codition cart_amount',
|
|
),
|
|
'cart_amount_tax_incl' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Tax included'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'cart_amount_tax_incl_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'cart_amount_tax_incl_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition cart_amount',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'cart_amount_shipping_incl' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Shipping included'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'cart_amount_shipping_incl_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'cart_amount_shipping_incl_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition cart_amount',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'cart_amount_discount_incl' => array(
|
|
'type'=>'switch',
|
|
'label'=>$this->l('Discount included'),
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'cart_amount_discount_incl_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'cart_amount_discount_incl_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition cart_amount',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'total_product_quantity_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Total product quantity calculator'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'total_product_quantity' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Total product quantity'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isUnsignedInt',
|
|
),
|
|
'quantity_of_same_product_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Quantity of same product calculator'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'quantity_of_same_product' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Quantity of same product'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isUnsignedInt',
|
|
),
|
|
'number_of_different_product_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Number of different product calculator'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'number_of_different_product' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Number of different products'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isUnsignedInt',
|
|
),
|
|
'number_of_product_in_same_category_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Number of product in same category calculator'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'number_of_product_in_same_category' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Number of product in same category '),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isUnsignedInt',
|
|
),
|
|
'apply_for_discounted_products' => array(
|
|
'type' => 'switch',
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'apply_for_discounted_products_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'apply_for_discounted_products_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'label' => $this->l('Apply for discounted products'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isUnsignedInt',
|
|
'default'=>1,
|
|
),
|
|
'products_with_different_attribute' => array(
|
|
'type' => 'switch',
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'products_with_different_attribute_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'products_with_different_attribute_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'label' => $this->l('Product with different attributes are counted as different products'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isUnsignedInt',
|
|
'default'=>1,
|
|
),
|
|
'applicable_product_categories' => array(
|
|
'type' => 'radio',
|
|
'label' => $this->l('Applicable product categories'),
|
|
'default' => 'all_product',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'applicable_product_categories_all_product',
|
|
'value' => 'all_product',
|
|
'label' => $this->l('All product categories'),
|
|
),
|
|
array(
|
|
'id' => 'applicable_product_categories_specific_product',
|
|
'value' => 'specific_product',
|
|
'label' => $this->l('Specific product categories'),
|
|
),
|
|
),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'applicable_categories' => array(
|
|
'label' => $this->l('Select categories to apply condition'),
|
|
'type' => 'categories',
|
|
'tree' => array(
|
|
'id' => 'loyalty-categories-tree',
|
|
'selected_categories' => $this->applicable_categories ? explode(',',$this->applicable_categories):array(),
|
|
'disabled_categories' => null,
|
|
'use_checkbox' => true,
|
|
'root_category' => Category::getRootCategory()->id
|
|
),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
),
|
|
'include_sub_categories' => array(
|
|
'type' => 'switch',
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'include_sub_categories_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'include_sub_categories_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'label' => $this->l('Include products in subcategories'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isUnsignedInt',
|
|
),
|
|
'include_specific_products' => array(
|
|
'type' => 'search_product',
|
|
'label' => $this->l('Include specific products'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
'placeholder' => $this->l('Search by product name, reference, id')
|
|
),
|
|
'exclude_products' => array(
|
|
'type' => 'search_product',
|
|
'label' => $this->l('Exclude products'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
'placeholder' => $this->l('Search by product name, reference, id')
|
|
),
|
|
'apply_all_attribute' => array(
|
|
'type' => 'switch',
|
|
'default' => 1,
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'apply_all_attribute_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'apply_all_attribute_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'label' => $this->l('Apply to all attributes'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'select_attributes' => array(
|
|
'type'=> 'checkbox',
|
|
'label' => $this->l('Select attributes'),
|
|
'values' => array(
|
|
'query' => $this->getAttributes(),
|
|
'id' => 'id_attribute',
|
|
'name' => 'name'
|
|
),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
'showRequired' => true,
|
|
),
|
|
'apply_all_features' => array(
|
|
'type' => 'switch',
|
|
'default' => 1,
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'apply_all_features_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'apply_all_features_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'label' => $this->l('Apply to all features'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'select_features' => array(
|
|
'type'=> 'checkbox',
|
|
'label' => $this->l('Select features'),
|
|
'values' => array(
|
|
'query' => $this->getFeatures(),
|
|
'id' => 'id_feature',
|
|
'name' => 'name'
|
|
),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
'showRequired' => true,
|
|
),
|
|
'apply_all_supplier' => array(
|
|
'type' => 'switch',
|
|
'default' => 1,
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'apply_all_supplier_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'apply_all_supplier_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'label' => $this->l('Apply to all suppliers'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'select_suppliers' => array(
|
|
'type'=> 'checkbox',
|
|
'label' => $this->l('Select suppliers'),
|
|
'values' => array(
|
|
'query' => $this->getSuppliers(),
|
|
'id' => 'id_supplier',
|
|
'name' => 'name'
|
|
),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
'showRequired' => true,
|
|
),
|
|
'apply_all_manufacturer' => array(
|
|
'type' => 'switch',
|
|
'default' => 1,
|
|
'values' => array(
|
|
array(
|
|
'label' => $this->l('Yes'),
|
|
'id' => 'apply_all_manufacturer_on',
|
|
'value' => 1,
|
|
),
|
|
array(
|
|
'label' => $this->l('No'),
|
|
'id' => 'apply_all_manufacturer_off',
|
|
'value' => 0,
|
|
)
|
|
),
|
|
'label' => $this->l('Apply to all manufacturers'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'select_manufacturers' => array(
|
|
'type'=> 'checkbox',
|
|
'label' => $this->l('Select manufacturers'),
|
|
'values' => array(
|
|
'query' => $this->getManufacturers(),
|
|
'id' => 'id_manufacturer',
|
|
'name' => 'name'
|
|
),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
'showRequired' => true,
|
|
),
|
|
'apply_for_product_price_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Apply for product price calculator'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'apply_for_product_price' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Apply for product price'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'suffix' => Context::getContext()->currency->sign,
|
|
'validate' => 'isPrice',
|
|
),
|
|
'apply_for_availabled_quantity_stock_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Apply for available stock quantity calculator'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'apply_for_availabled_quantity_stock' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Apply for available stock quantity'),
|
|
'form_group_class' => 'parent_codition product_in_cart',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'delivery_total_cart_weight_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Total cart weight calculator'),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'delivery_total_cart_weight' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Total cart weight'),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'suffix' => 'kg',
|
|
'validate'=>'isUnsignedFloat',
|
|
),
|
|
'delivery_apply_to_carriers' => array(
|
|
'type' => 'checkbox',
|
|
'values' => array(
|
|
'query' => $this->getCarriers(),
|
|
'id' => 'id_reference',
|
|
'name' => 'name'
|
|
),
|
|
'label' => $this->l('Apply to carriers'),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'delivery_id_zone' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Delivery zone'),
|
|
'options' => array(
|
|
'query' => $this->getListZones(),
|
|
'id' => 'id_zone',
|
|
'name' => 'name',
|
|
'default' => array(
|
|
'value' => '0',
|
|
'label' => $this->l('-- Select zone --')
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'delivery_id_country' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Delivery country'),
|
|
'options' => array(
|
|
'query' => $this->getListCountries($this->delivery_id_zone),
|
|
'id' => 'id_country',
|
|
'name' => 'name',
|
|
'default' => array(
|
|
'value' => '0',
|
|
'label' => $this->l('-- Select country --')
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'delivery_id_state' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Delivery state'),
|
|
'options' => array(
|
|
'query' => $this->getListStates($this->delivery_id_country),
|
|
'id' => 'id_state',
|
|
'name' => 'name',
|
|
'default' => array(
|
|
'value' => '0',
|
|
'label' => $this->l('-- Select state --')
|
|
)
|
|
),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'validate'=>'isUnsignedInt',
|
|
),
|
|
'delivery_speed_grade_cal' => array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Speed grade calculator'),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'delivery_speed_grade' => array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Speed grade'),
|
|
'form_group_class' => 'parent_codition delivery',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'payments' => array(
|
|
'type' => 'checkbox',
|
|
'label' => $this->l('Payment methods'),
|
|
'values' => array(
|
|
'query' => $this->getPaymentModules(),
|
|
'id' => 'id_module',
|
|
'name' => 'name'
|
|
),
|
|
'form_group_class' => 'parent_codition payments',
|
|
'validate' => 'isCleanHtml',
|
|
'showRequired' => true,
|
|
),
|
|
'specific_occasion' => array(
|
|
'type' => 'radio',
|
|
'default' => 'hour_of_day',
|
|
'label' => $this->l('Specific occasion'),
|
|
'values' => array(
|
|
array(
|
|
'id' => 'specific_occasion_hour_of_day',
|
|
'value' => 'hour_of_day',
|
|
'label' => $this->l('Hour of day'),
|
|
),
|
|
array(
|
|
'id' => 'specific_occasion_day_of_week',
|
|
'value' => 'day_of_week',
|
|
'label' => $this->l('Day of week'),
|
|
),
|
|
array(
|
|
'id' => 'specific_occasion_month_of_year',
|
|
'value' => 'month_of_year',
|
|
'label' => $this->l('Month of year'),
|
|
),
|
|
array(
|
|
'id' => 'specific_occasion_from_to',
|
|
'value' => 'from_to',
|
|
'label' => $this->l('From - To'),
|
|
),
|
|
),
|
|
'form_group_class' => 'parent_codition specific_occasion',
|
|
'validate' => 'isCleanHtml',
|
|
),
|
|
'specific_occasion_hour_of_day_from' => array(
|
|
'label' => '',
|
|
'type' => 'html',
|
|
'html_content' => $this->displayFormHourOfDay(),
|
|
'form_group_class' => 'parent_codition specific_occasion',
|
|
),
|
|
'specific_occasion_day_of_week' => array(
|
|
'type' => 'html',
|
|
'label' => '',
|
|
'html_content' => $this->displayFormDayOfWeek(),
|
|
'form_group_class' => 'parent_codition specific_occasion',
|
|
),
|
|
'specific_occasion_month_of_year' => array(
|
|
'type' => 'html',
|
|
'label' => '',
|
|
'html_content' => $this->displayFormMonthOfYear(),
|
|
'form_group_class' => 'parent_codition specific_occasion',
|
|
),
|
|
'specific_occasion_date_from' => array(
|
|
'type' => 'html',
|
|
'label' => '',
|
|
'html_content' => $this->displayFormDateFromTo(),
|
|
'form_group_class' => 'parent_codition specific_occasion',
|
|
),
|
|
);
|
|
if(!Module::isEnabled('ets_free_downloads'))
|
|
unset($configs['verified_customer']);
|
|
return array(
|
|
'form' => array(
|
|
'legend' => array(
|
|
'title' => $this->id ? $this->l('Edit discount condition') : $this->l('Add new condition') ,
|
|
),
|
|
'input' => array(),
|
|
'submit' => array(
|
|
'title' => $this->l('Save'),
|
|
),
|
|
'buttons'=> array(
|
|
array(
|
|
'title' => $this->l('Cancel'),
|
|
'type' => 'submit',
|
|
'class' => 'pull-left',
|
|
'name' => 'btncancel',
|
|
'icon' => 'process-icon-cancel',
|
|
)
|
|
),
|
|
'name' => 'condition_rule',
|
|
'key' => 'id_ets_pr_condition_rule',
|
|
),
|
|
'configs' =>$configs,
|
|
);
|
|
}
|
|
public function validateCustomField(&$errors)
|
|
{
|
|
$parent_codition = Tools::getValue('parent_codition');
|
|
if($parent_codition=='specific_customer')
|
|
{
|
|
$id_customers = trim(Tools::getValue('id_customers'),',');
|
|
if(!$id_customers)
|
|
$errors[] = $this->l('Customer is required');
|
|
elseif(!Validate::isCleanHtml($id_customers))
|
|
$errors[] = $this->l('Customer is not valid');
|
|
|
|
}
|
|
elseif($parent_codition=='customer_group')
|
|
{
|
|
$customer_group = Tools::getValue('id_groups');
|
|
if(!$customer_group)
|
|
$errors[] = $this->l('Customer group is required');
|
|
elseif(!Ets_promotion::validateArray($customer_group))
|
|
$errors[] = $this->l('Customer group is not valid');
|
|
}
|
|
elseif($parent_codition=='customer_personal')
|
|
{
|
|
$age_from = Tools::getValue('age_from');
|
|
$age_to = Tools::getValue('age_to');
|
|
if($age_from!='' && !Validate::isUnsignedInt($age_from))
|
|
$errors[] = $this->l('"From" age is not valid');
|
|
if($age_to!='' && !Validate::isUnsignedInt($age_to))
|
|
$errors[] = $this->l('"To" age is not valid');
|
|
if($age_from > 0 && $age_to > 0 && Validate::isUnsignedInt($age_from) && Validate::isUnsignedInt($age_to) && $age_from >= $age_to)
|
|
$errors[] = $this->l('"From" age must be greater than "To" age');
|
|
}
|
|
elseif($parent_codition=='customer_membership')
|
|
{
|
|
$customer_signed_up_from = Tools::getValue('customer_signed_up_from');
|
|
$customer_signed_up_to = Tools::getValue('customer_signed_up_to');
|
|
if($customer_signed_up_from!='' && $customer_signed_up_from!='0000-00-00 00:00:00' && !Validate::isDate($customer_signed_up_from))
|
|
$errors[] = $this->l('Registration date from is not valid');
|
|
if($customer_signed_up_to!='' && $customer_signed_up_to!='0000-00-00 00:00:00' && !Validate::isDate($customer_signed_up_to))
|
|
$errors[] = $this->l('Registration date to is not valid');
|
|
if($customer_signed_up_from && $customer_signed_up_from!='0000-00-00 00:00:00' && Validate::isDate($customer_signed_up_from) && $customer_signed_up_to && $customer_signed_up_to!='0000-00-00 00:00:00' && Validate::isDate($customer_signed_up_to) && strtotime($customer_signed_up_from) >= strtotime($customer_signed_up_to))
|
|
$errors[] = $this->l('Registration date from must be greater than Registration date to');
|
|
|
|
}
|
|
elseif($parent_codition=='order_from_customer')
|
|
{
|
|
$first_order_of_customer = (int)Tools::getValue('first_order_of_customer');
|
|
if(!$first_order_of_customer)
|
|
{
|
|
$order_criteria = Tools::getValue('order_criteria');
|
|
if($order_criteria=='number_of_orders')
|
|
{
|
|
$number_of_order = Tools::getValue('number_of_order');
|
|
if($number_of_order=='')
|
|
$errors[] = $this->l('Number of orders is required');
|
|
elseif(!Validate::isUnsignedInt($number_of_order) || $number_of_order==0)
|
|
$errors[] = $this->l('Number of orders is not valid');
|
|
|
|
}
|
|
elseif($order_criteria=='amount_of_money_spent')
|
|
{
|
|
$amount_of_money_spent = Tools::getValue('amount_of_money_spent');
|
|
if($amount_of_money_spent=='')
|
|
$errors[] = $this->l('Amount of money spent is required');
|
|
elseif(!Validate::isUnsignedFloat($amount_of_money_spent) || $amount_of_money_spent==0)
|
|
$errors[] = $this->l('Amount of money spent is not valid');
|
|
}
|
|
elseif($order_criteria=='number_of_products')
|
|
{
|
|
$number_of_product = Tools::getValue('number_of_product');
|
|
if($number_of_product=='')
|
|
$errors[] = $this->l('Number of products is required');
|
|
elseif(!Validate::isUnsignedInt($number_of_product) || $number_of_product==0)
|
|
$errors[] = $this->l('Number of products is not valid');
|
|
}
|
|
$order_time_in = Tools::getValue('order_time_in');
|
|
if($order_time_in=='from_to')
|
|
{
|
|
$order_time_in_from = Tools::getValue('order_time_in_from');
|
|
$order_time_in_to =Tools::getValue('order_time_in_to');
|
|
if($order_time_in_from=='')
|
|
$errors[] = $this->l('Ordered time from is required');
|
|
elseif(!Validate::isDate($order_time_in_from))
|
|
$errors[] = $this->l('Ordered time from is not valid');
|
|
if($order_time_in_to=='')
|
|
$errors[] = $this->l('Ordered time to is required');
|
|
elseif(!Validate::isDate($order_time_in_to))
|
|
$errors[] = $this->l('Ordered time to is not valid');
|
|
if(Validate::isDate($order_time_in_from) && Validate::isDate($order_time_in_to) && strtotime($order_time_in_from) >= strtotime($order_time_in_to))
|
|
$errors[] = $this->l('Ordered time from must be greater than Ordered time to');
|
|
}
|
|
elseif($order_time_in=='in_last_day')
|
|
{
|
|
$order_time_in_last_day = Tools::getValue('order_time_in_last_day');
|
|
if($order_time_in_last_day=='')
|
|
$errors[] = $this->l('Ordered time in the last X days is required');
|
|
elseif(!Validate::isUnsignedInt($order_time_in_last_day) || $order_time_in_last_day <=0)
|
|
$errors[] = $this->l('Ordered time in the last X days is not valid');
|
|
}
|
|
}
|
|
}
|
|
elseif($parent_codition=='cart_amount')
|
|
{
|
|
$cart_amount = Tools::getValue('cart_amount');
|
|
if($cart_amount=='')
|
|
$errors[] = $this->l('Cart amount is required');
|
|
elseif($cart_amount=='0' || !Validate::isPrice($cart_amount))
|
|
$errors[] = $this->l('Cart amount is not valid');
|
|
}
|
|
elseif($parent_codition=='product_in_cart')
|
|
{
|
|
$advance_setting = true;
|
|
$total_product_quantity = (int)Tools::getValue('total_product_quantity');
|
|
$quantity_of_same_product = (int)Tools::getValue('quantity_of_same_product');
|
|
$number_of_different_product = (int)Tools::getValue('number_of_different_product');
|
|
$number_of_product_in_same_category = (int)Tools::getValue('number_of_product_in_same_category');
|
|
if(!$total_product_quantity && !$quantity_of_same_product && !$number_of_different_product && !$number_of_product_in_same_category)
|
|
$errors[] = $this->l('The products in the cart need to meet at least one of the conditions listed below.');
|
|
}
|
|
elseif($parent_codition =='specific_occasion')
|
|
{
|
|
$specific_occasion = Tools::getValue('specific_occasion');
|
|
if($specific_occasion=='hour_of_day')
|
|
{
|
|
$specific_occasion_hour_of_day_from = Tools::getValue('specific_occasion_hour_of_day_from');
|
|
$specific_occasion_hour_of_day_to = Tools::getValue('specific_occasion_hour_of_day_to');
|
|
if($specific_occasion_hour_of_day_from && count($specific_occasion_hour_of_day_from)!=count($specific_occasion_hour_of_day_to))
|
|
$errors[] = $this->l('Hour of day is not valid');
|
|
else
|
|
{
|
|
$ok = false;
|
|
if($specific_occasion_hour_of_day_from)
|
|
{
|
|
foreach($specific_occasion_hour_of_day_from as $index => $from)
|
|
{
|
|
if($from!=='' && isset($specific_occasion_hour_of_day_to[$index]) && $specific_occasion_hour_of_day_to[$index]!=='')
|
|
{
|
|
$ok = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(!$ok)
|
|
$errors[] = $this->l('Hour of day is required');
|
|
if($specific_occasion_hour_of_day_from)
|
|
{
|
|
foreach($specific_occasion_hour_of_day_from as $index => $from)
|
|
{
|
|
if($from && (!Validate::isUnsignedInt($from) || $from > 23 ))
|
|
{
|
|
$errors[] = $this->l('Hour of day is not valid');
|
|
break;
|
|
}
|
|
if($specific_occasion_hour_of_day_to[$index] && (!Validate::isUnsignedInt($specific_occasion_hour_of_day_to[$index]) || $specific_occasion_hour_of_day_to[$index] > 23 ) )
|
|
{
|
|
$errors[] = $this->l('Hour of day is not valid');
|
|
break;
|
|
}
|
|
if($from && $specific_occasion_hour_of_day_to[$index] && $from > $specific_occasion_hour_of_day_to[$index])
|
|
{
|
|
$errors[] = $this->l('Hour of day from must be greater than hour of day to');
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!$errors)
|
|
{
|
|
|
|
$this->specific_occasion_hour_of_day_from = json_encode($specific_occasion_hour_of_day_from);
|
|
$this->specific_occasion_hour_of_day_to = json_encode($specific_occasion_hour_of_day_to);
|
|
}
|
|
|
|
}
|
|
elseif($specific_occasion=='day_of_week')
|
|
{
|
|
$specific_occasion_day_of_week_from = Tools::getValue('specific_occasion_day_of_week_from');
|
|
$specific_occasion_day_of_week_to = Tools::getValue('specific_occasion_day_of_week_to');
|
|
$specific_occasion_day_of_week = Tools::getValue('specific_occasion_day_of_week');
|
|
if(!Ets_promotion::validateArray($specific_occasion_day_of_week))
|
|
$errors[] = $this->l('Day of week is not valid');
|
|
elseif($specific_occasion_day_of_week_from)
|
|
{
|
|
foreach($specific_occasion_day_of_week_from as $index => $from)
|
|
{
|
|
$ok = true;
|
|
if($from && !Validate::isUnsignedInt($from))
|
|
{
|
|
$errors[] = $this->l('Day of week from is not valid');
|
|
$ok = false;
|
|
}
|
|
if($specific_occasion_day_of_week_to[$index] && !Validate::isUnsignedInt($specific_occasion_day_of_week_to[$index]))
|
|
{
|
|
$errors[] = $this->l('Day of week to is not valid');
|
|
$ok = false;
|
|
}
|
|
if($from && $specific_occasion_day_of_week_to[$index] && $from > $specific_occasion_day_of_week_to[$index])
|
|
{
|
|
$errors[] = $this->l('Day of week from must be greater than Day of week to');
|
|
$ok = false;
|
|
}
|
|
if(!$ok)
|
|
break;
|
|
|
|
}
|
|
}
|
|
if(!$errors)
|
|
{
|
|
|
|
$this->specific_occasion_day_of_week = json_encode($specific_occasion_day_of_week);
|
|
$this->specific_occasion_day_of_week_from = json_encode($specific_occasion_day_of_week_from);
|
|
$this->specific_occasion_day_of_week_to = json_encode($specific_occasion_day_of_week_to);
|
|
}
|
|
}
|
|
elseif($specific_occasion=='month_of_year')
|
|
{
|
|
$specific_occasion_month_of_year_from = Tools::getValue('specific_occasion_month_of_year_from');
|
|
$specific_occasion_month_of_year_to = Tools::getValue('specific_occasion_month_of_year_to');
|
|
$specific_occasion_month_of_year = Tools::getValue('specific_occasion_month_of_year');
|
|
if($specific_occasion_month_of_year_from)
|
|
{
|
|
foreach($specific_occasion_month_of_year_from as $index => $from)
|
|
{
|
|
$ok = true;
|
|
if($from && !Validate::isUnsignedInt($from))
|
|
{
|
|
$errors[] = $this->l('Month of year from is not valid');
|
|
$ok = false;
|
|
}
|
|
if($specific_occasion_month_of_year_to[$index] && !Validate::isUnsignedInt($specific_occasion_month_of_year_to[$index]) )
|
|
{
|
|
$errors[] = $this->l('Month of year to is not valid');
|
|
$ok = false;
|
|
}
|
|
if($from && $specific_occasion_month_of_year_to[$index] && $from > $specific_occasion_month_of_year_to[$index])
|
|
{
|
|
$errors[] = $this->l('Month of year from must be greater than Month of year to');
|
|
$ok = false;
|
|
}
|
|
if(!$ok)
|
|
break;
|
|
}
|
|
}
|
|
if(!$errors)
|
|
{
|
|
$this->specific_occasion_month_of_year = json_encode($specific_occasion_month_of_year);
|
|
$this->specific_occasion_month_of_year_from = json_encode($specific_occasion_month_of_year_from);
|
|
$this->specific_occasion_month_of_year_to = json_encode($specific_occasion_month_of_year_to);
|
|
}
|
|
}
|
|
elseif($specific_occasion=='from_to')
|
|
{
|
|
$specific_occasion_date_from = Tools::getValue('specific_occasion_date_from');
|
|
$specific_occasion_date_to = Tools::getValue('specific_occasion_date_to');
|
|
if($specific_occasion_date_from && count($specific_occasion_date_from)!=count($specific_occasion_date_to))
|
|
$errors[] = $this->l('From - To is not valid');
|
|
else
|
|
{
|
|
$ok = false;
|
|
if($specific_occasion_date_from)
|
|
{
|
|
foreach($specific_occasion_date_from as $index => $from)
|
|
{
|
|
if($from && isset($specific_occasion_date_to[$index]) && $specific_occasion_date_to[$index])
|
|
{
|
|
$ok = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(!$ok)
|
|
$errors[] = $this->l('From - To is required');
|
|
if($specific_occasion_date_from)
|
|
{
|
|
foreach($specific_occasion_date_from as $index => $from)
|
|
{
|
|
if($from && !Validate::isDate($from))
|
|
{
|
|
$errors[] = $this->l('From - To is not valid');
|
|
break;
|
|
}
|
|
if($specific_occasion_date_to[$index] && !Validate::isDate($specific_occasion_date_to[$index]))
|
|
{
|
|
$errors[] = $this->l('From - To is not valid');
|
|
break;
|
|
}
|
|
if($from && $specific_occasion_date_to[$index] && strtotime($from) > strtotime($specific_occasion_date_to[$index]))
|
|
{
|
|
$errors[] = $this->l('From must be greater than To');
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!$errors)
|
|
{
|
|
$this->specific_occasion_date_from = json_encode($specific_occasion_date_from);
|
|
$this->specific_occasion_date_to = json_encode($specific_occasion_date_to);
|
|
}
|
|
}
|
|
}
|
|
if(isset($advance_setting) && $advance_setting)
|
|
{
|
|
$apply_all_attribute = (int)Tools::getValue('apply_all_attribute');
|
|
$select_attributes = Tools::getValue('select_attributes');
|
|
$apply_all_features = (int)Tools::getValue('apply_all_features');
|
|
$select_features = Tools::getValue('select_features');
|
|
$apply_all_manufacturer = (int)Tools::getValue('apply_all_manufacturer');
|
|
$select_manufacturers = Tools::getValue('select_manufacturers');
|
|
$apply_all_supplier = (int)Tools::getValue('apply_all_supplier');
|
|
$select_suppliers = Tools::getValue('select_suppliers');
|
|
if(!$apply_all_attribute && !$select_attributes)
|
|
$errors[] = $this->l('Select attributes is required');
|
|
elseif($select_attributes && !Ets_promotion::validateArray($select_attributes))
|
|
$errors[] = $this->l('Select attributes is not valid');
|
|
if(!$apply_all_features && !$select_features)
|
|
$errors[] = $this->l('Select features is required');
|
|
elseif($select_features && !Ets_promotion::validateArray($select_features))
|
|
$errors[] = $this->l('Select features is not valid');
|
|
if(!$apply_all_supplier && !$select_suppliers)
|
|
$errors[] = $this->l('Select suppliers is required');
|
|
elseif($select_suppliers && !Ets_promotion::validateArray($select_suppliers))
|
|
$errors[] = $this->l('Select supplier is not valid');
|
|
if(!$apply_all_manufacturer && !$select_manufacturers)
|
|
$errors[] = $this->l('Select manufacturers is required');
|
|
elseif($select_manufacturers && !Ets_promotion::validateArray($select_manufacturers))
|
|
$errors[] = $this->l('Select manufacturers is not valid');
|
|
}
|
|
}
|
|
public function getHours()
|
|
{
|
|
return array(
|
|
'0' => '00:00',
|
|
'1' => '01:00',
|
|
'2' => '02:00',
|
|
'3' => '03:00',
|
|
'4' => '04:00',
|
|
'5' => '05:00',
|
|
'6' => '06:00',
|
|
'7' => '07:00',
|
|
'8' => '08:00',
|
|
'9' => '09:00',
|
|
'10' => '10:00',
|
|
'11' => '11:00',
|
|
'12' => '12:00',
|
|
'13' => '13:00',
|
|
'14' => '14:00',
|
|
'15' => '15:00',
|
|
'16' => '16:00',
|
|
'17' => '17:00',
|
|
'18' => '18:00',
|
|
'19' => '19:00',
|
|
'20' => '20:00',
|
|
'21' => '21:00',
|
|
'22' => '22:00',
|
|
'23' => '23:00',
|
|
);
|
|
}
|
|
public function getDays()
|
|
{
|
|
return array(
|
|
'1' => $this->l('Monday'),
|
|
'2' => $this->l('Tuesday'),
|
|
'3' => $this->l('Wednesday'),
|
|
'4' => $this->l('Thursday'),
|
|
'5' => $this->l('Friday'),
|
|
'6' => $this->l('Saturday'),
|
|
'7' => $this->l('Sunday'),
|
|
);
|
|
}
|
|
public function getMonths()
|
|
{
|
|
return array(
|
|
'1' => $this->l('January'),
|
|
'2' => $this->l('February'),
|
|
'3' => $this->l('March'),
|
|
'4' => $this->l('April'),
|
|
'5' => $this->l('May'),
|
|
'6' => $this->l('June'),
|
|
'7' => $this->l('July'),
|
|
'8' => $this->l('August'),
|
|
'9' => $this->l('September'),
|
|
'10' => $this->l('October'),
|
|
'11' => $this->l('November'),
|
|
'12' => $this->l('December'),
|
|
);
|
|
}
|
|
public function displayFormDateFromTo()
|
|
{
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'specific_occasion_date_from' => $this->specific_occasion_date_from ? json_decode($this->specific_occasion_date_from,true):array(),
|
|
'specific_occasion_date_to' => $this->specific_occasion_date_to ? json_decode($this->specific_occasion_date_to,true):array(),
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/from_to.tpl');
|
|
}
|
|
public function displayFormMonthOfYear()
|
|
{
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'specific_occasion_month_of_year' => $this->specific_occasion_month_of_year ? json_decode($this->specific_occasion_month_of_year,true):array(),
|
|
'specific_occasion_month_of_year_from' => $this->specific_occasion_month_of_year_from ? json_decode($this->specific_occasion_month_of_year_from,true):array(),
|
|
'specific_occasion_month_of_year_to' => $this->specific_occasion_month_of_year_to ? json_decode($this->specific_occasion_month_of_year_to,true):array(),
|
|
'months' => $this->getMonths(),
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/month_of_year.tpl');
|
|
}
|
|
public function displayFormDayOfWeek()
|
|
{
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'specific_occasion_day_of_week' => $this->specific_occasion_day_of_week ? json_decode($this->specific_occasion_day_of_week,true):array(),
|
|
'specific_occasion_day_of_week_from' => $this->specific_occasion_day_of_week_from ? json_decode($this->specific_occasion_day_of_week_from,true):array(),
|
|
'specific_occasion_day_of_week_to' => $this->specific_occasion_day_of_week_to ? json_decode($this->specific_occasion_day_of_week_to,true):array(),
|
|
'days' => $this->getDays(),
|
|
'hours' => $this->getHours(),
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/day_of_week.tpl');
|
|
}
|
|
public function displayFormHourOfDay()
|
|
{
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'specific_occasion_hour_of_day_from' => $this->specific_occasion_hour_of_day_from ? json_decode($this->specific_occasion_hour_of_day_from,true):array(),
|
|
'specific_occasion_hour_of_day_to' => $this->specific_occasion_hour_of_day_to ? json_decode($this->specific_occasion_hour_of_day_to,true):array(),
|
|
'hours' => $this->getHours(),
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/hour_of_day.tpl');
|
|
}
|
|
public function getListConditionsByRule($id_rule)
|
|
{
|
|
$sql ='SELECT * FROM `'._DB_PREFIX_.'ets_pr_condition_rule` WHERE id_ets_pr_rule='.(int)$id_rule;
|
|
$conditions = Db::getInstance()->executeS($sql);
|
|
if($conditions)
|
|
{
|
|
foreach($conditions as &$condition)
|
|
{
|
|
|
|
switch($condition['parent_codition'])
|
|
{
|
|
case 'specific_customer':
|
|
$condition['condition'] = $this->l('Customer - Specific customer');
|
|
$condition['detail'] = self::displayListCustomer($condition);
|
|
break;
|
|
case 'customer_group':
|
|
$condition['condition'] = $this->l('Customer - Customer group');
|
|
$condition['detail'] = self::displayListGroup($condition);
|
|
break;
|
|
case 'customer_personal':
|
|
$condition['condition'] = $this->l('Customer - Customer personal information');
|
|
$condition['detail'] = self::displayCustomerPersonal($condition);
|
|
break;
|
|
case 'customer_membership':
|
|
$condition['condition'] = $this->l('Customer - Customer membership');
|
|
$condition['detail'] = self::displayCustomerMembership($condition);
|
|
break;
|
|
case 'order_from_customer':
|
|
$condition['condition'] = $this->l('Customer - Orders placed by customer');
|
|
$condition['detail'] = self::displayOrderFromCustomer($condition);
|
|
break;
|
|
case 'cart_amount':
|
|
$condition['condition'] = $this->l('Shopping cart - Cart amount');
|
|
$condition['detail'] = self::displayCartAmount($condition);
|
|
break;
|
|
case 'product_in_cart':
|
|
$condition['condition'] = $this->l('Shopping cart - Products in cart');
|
|
$condition['detail'] = self::displayProductInCart($condition);
|
|
break;
|
|
case 'delivery':
|
|
$condition['condition'] = $this->l('Shopping cart - Delivery');
|
|
$condition['detail'] = self::displayDelivery($condition);
|
|
break;
|
|
case 'payments':
|
|
$condition['condition'] = $this->l('Shopping cart - Payment methods');
|
|
$condition['detail'] = self::displayPayments($condition);
|
|
break;
|
|
case 'specific_occasion':
|
|
$condition['condition'] = $this->l('Specific occasion');
|
|
$condition['detail'] =self::displaySpecificOccasions($condition);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return $conditions;
|
|
}
|
|
public static function displayListCustomer($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$id_customers = $condition['id_customers'];
|
|
}
|
|
else
|
|
{
|
|
$id_customers = $condition->id_customers;
|
|
}
|
|
if($id_customers)
|
|
{
|
|
$customers = self::getCustomersByIds($id_customers);
|
|
if($customers)
|
|
{
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'condition_customers' => $customers,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/specific_customer.tpl');
|
|
}
|
|
}
|
|
}
|
|
public static function getCustomersByIds($id_customers)
|
|
{
|
|
if($id_customers)
|
|
{
|
|
if(!is_array($id_customers))
|
|
{
|
|
$id_customers = explode(',',$id_customers);
|
|
}
|
|
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'customer` WHERE id_customer IN ('.implode(',',array_map('intval',$id_customers)).')');
|
|
}
|
|
return array();
|
|
}
|
|
public static function displayListGroup($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$id_groups = $condition['id_groups'];
|
|
$only_apply_on_default_group = (int)$condition['only_apply_on_default_group'];
|
|
}
|
|
else
|
|
{
|
|
$id_groups = $condition->id_groups;
|
|
$only_apply_on_default_group = (int)$condition->only_apply_on_default_group;
|
|
}
|
|
if($id_groups && $id_groups!='all')
|
|
{
|
|
$id_groups = explode(',',$id_groups);
|
|
$customer_groups = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'group` g
|
|
INNER JOIN `'._DB_PREFIX_.'group_shop` gs ON (g.id_group = gs.id_group AND gs.id_shop="'.(int)Context::getContext()->shop->id.'")
|
|
LEFT JOIN `'._DB_PREFIX_.'group_lang` gl ON (g.id_group = gl.id_group AND gl.id_lang="'.(int)Context::getContext()->language->id.'")
|
|
WHERE g.id_group IN ('.implode(',',array_map('intval',$id_groups)).')');
|
|
}
|
|
else
|
|
$customer_groups = 'all';
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'customer_groups' => $customer_groups,
|
|
'only_apply_on_default_group' => $only_apply_on_default_group,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/customer_group.tpl');
|
|
}
|
|
public static function displayCustomerPersonal($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$id_genders = $condition['id_genders'];
|
|
$age_from = $condition['age_from'];
|
|
$age_to = $condition['age_to'];
|
|
$on_customer_birthday = (int)$condition['on_customer_birthday'];
|
|
$verified_customer = (int)$condition['verified_customer'];
|
|
}
|
|
else
|
|
{
|
|
$id_genders = $condition->id_genders;
|
|
$age_from = $condition->age_from;
|
|
$age_to = $condition->age_to;
|
|
$on_customer_birthday = (int)$condition->on_customer_birthday;
|
|
$verified_customer = (int)$condition->verified_customer;
|
|
}
|
|
if($id_genders && $id_genders!='all')
|
|
{
|
|
$id_genders = explode(',',$id_genders);
|
|
$customer_genders = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'gender` g
|
|
LEFT JOIN `'._DB_PREFIX_.'gender_lang` gl ON (g.id_gender = gl.id_gender AND gl.id_lang="'.(int)Context::getContext()->language->id.'")
|
|
WHERE g.id_gender IN ('.implode(',',array_map('intval',$id_genders)).')');
|
|
}
|
|
else
|
|
$customer_genders = 'all';
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'customer_genders' => $customer_genders,
|
|
'age_from' => $age_from,
|
|
'age_to' => $age_to,
|
|
'on_customer_birthday' => $on_customer_birthday,
|
|
'verified_customer' => $verified_customer,
|
|
'ets_free_downloads' => Module::isEnabled('ets_free_downloads'),
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/customer_personal.tpl');
|
|
}
|
|
public static function displayCustomerMembership($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$customer_signed_up_from = $condition['customer_signed_up_from'];
|
|
$customer_signed_up_to = $condition['customer_signed_up_to'];
|
|
$days_since_signed_up_cal = $condition['days_since_signed_up_cal'];
|
|
$days_since_singed_up_day = $condition['days_since_singed_up_day'];
|
|
$newsletter_registration = $condition['newsletter_registration'];
|
|
}
|
|
else
|
|
{
|
|
$customer_signed_up_from = $condition->customer_signed_up_from;
|
|
$customer_signed_up_to = $condition->customer_signed_up_to;
|
|
$days_since_signed_up_cal = $condition->days_since_signed_up_cal;
|
|
$days_since_singed_up_day = $condition->days_since_singed_up_day;
|
|
$newsletter_registration = $condition->newsletter_registration;
|
|
}
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'customer_signed_up_from' => $customer_signed_up_from!='0000-00-00 00:00:00' ? $customer_signed_up_from:'',
|
|
'customer_signed_up_to' => $customer_signed_up_to!='0000-00-00 00:00:00' ? $customer_signed_up_to :'',
|
|
'days_since_signed_up_cal' => $days_since_signed_up_cal,
|
|
'days_since_singed_up_day' => $days_since_singed_up_day,
|
|
'newsletter_registration' => $newsletter_registration ? explode(',',$newsletter_registration):'',
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/customer_membership.tpl');
|
|
}
|
|
public static function displayOrderFromCustomer($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$first_order_of_customer = (int)$condition['first_order_of_customer'];
|
|
$order_criteria = $condition['order_criteria'];
|
|
$number_of_order_cal = $condition['number_of_order_cal'];
|
|
$number_of_order = $condition['number_of_order'];
|
|
$number_of_product_cal = $condition['number_of_product_cal'];
|
|
$number_of_product = $condition['number_of_product'];
|
|
$amount_of_money_spent_cal = $condition['amount_of_money_spent_cal'];
|
|
$amount_of_money_spent = $condition['amount_of_money_spent'];
|
|
$amount_of_money_spent_tax_incl = (int)$condition['amount_of_money_spent_tax_incl'];
|
|
$amount_of_money_spent_shipping_incl = (int)$condition['amount_of_money_spent_shipping_incl'];
|
|
$amount_of_money_spent_discount_incl = (int)$condition['amount_of_money_spent_discount_incl'];
|
|
$order_time_in = $condition['order_time_in'];
|
|
$order_status_in = $condition['order_status_in'];
|
|
$order_time_in_from = $condition['order_time_in_from'];
|
|
$order_time_in_to = $condition['order_time_in_to'];
|
|
$order_time_in_last_day = $condition['order_time_in_last_day'];
|
|
}
|
|
else{
|
|
$first_order_of_customer = (int)$condition->first_order_of_customer;
|
|
$order_criteria = $condition->order_criteria;
|
|
$number_of_order_cal = $condition->number_of_order_cal;
|
|
$number_of_order = $condition->number_of_order;
|
|
$number_of_product_cal = $condition->number_of_product_cal;
|
|
$number_of_product = $condition->number_of_product;
|
|
$amount_of_money_spent_cal = $condition->amount_of_money_spent_cal;
|
|
$amount_of_money_spent = $condition->amount_of_money_spent;
|
|
$amount_of_money_spent_tax_incl = (int)$condition->amount_of_money_spent_tax_incl;
|
|
$amount_of_money_spent_shipping_incl = (int)$condition->amount_of_money_spent_shipping_incl;
|
|
$amount_of_money_spent_discount_incl = (int)$condition->amount_of_money_spent_discount_incl;
|
|
$order_time_in = $condition->order_time_in;
|
|
$order_status_in = $condition->order_status_in;
|
|
$order_time_in_from = $condition->order_time_in_from;
|
|
$order_time_in_to = $condition->order_time_in_to;
|
|
$order_time_in_last_day = $condition->order_time_in_last_day;
|
|
}
|
|
if($order_status_in && $order_status_in!='all')
|
|
{
|
|
$id_lang = Context::getContext()->language->id;
|
|
$id_order_status = explode(',',$order_status_in);
|
|
$order_status = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'order_state` os
|
|
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.id_order_state=osl.id_order_state AND osl.id_lang="'.(int)$id_lang.'")
|
|
WHERE os.id_order_state IN ('.implode(',',array_map('intval',$id_order_status)).')');
|
|
}
|
|
else
|
|
$order_status='all';
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'first_order_of_customer' => $first_order_of_customer,
|
|
'order_criteria' => $order_criteria,
|
|
'number_of_order_cal' => $number_of_order_cal,
|
|
'number_of_order' => $number_of_order,
|
|
'number_of_product_cal' => $number_of_product_cal,
|
|
'number_of_product' => $number_of_product,
|
|
'amount_of_money_spent_cal' => $amount_of_money_spent_cal,
|
|
'amount_of_money_spent' => Tools::displayPrice($amount_of_money_spent),
|
|
'amount_of_money_spent_tax_incl' => $amount_of_money_spent_tax_incl,
|
|
'amount_of_money_spent_shipping_incl' => $amount_of_money_spent_shipping_incl,
|
|
'amount_of_money_spent_discount_incl' => $amount_of_money_spent_discount_incl,
|
|
'order_time_in' => $order_time_in,
|
|
'order_status' => $order_status,
|
|
'order_time_in_from' => $order_time_in_from,
|
|
'order_time_in_to' => $order_time_in_to,
|
|
'order_time_in_last_day' => $order_time_in_last_day,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/order_from_customer.tpl');
|
|
}
|
|
public static function displayPayments($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$payments = $condition['payments'];
|
|
}
|
|
else
|
|
{
|
|
$payments = $condition->payments;
|
|
}
|
|
if($payments && $payments!='all')
|
|
{
|
|
$id_payments = explode(',',$payments);
|
|
$modules = Ets_pr_condition_rule::getInstance()->getPaymentModules();
|
|
$payments = array();
|
|
if($modules && $id_payments)
|
|
{
|
|
foreach($modules as $module)
|
|
{
|
|
if(in_array($module['id_module'],$id_payments))
|
|
$payments[]= $module;
|
|
}
|
|
}
|
|
}
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'payments' => $payments,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/payments.tpl');
|
|
}
|
|
public static function displayCartAmount($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$cart_amount_cal = $condition['cart_amount_cal'];
|
|
$cart_amount = $condition['cart_amount'];
|
|
$cart_amount_tax_incl = (int)$condition['cart_amount_tax_incl'];
|
|
$cart_amount_shipping_incl = (int)$condition['cart_amount_shipping_incl'];
|
|
$cart_amount_discount_incl = (int)$condition['cart_amount_discount_incl'];
|
|
}
|
|
else
|
|
{
|
|
$cart_amount_cal = $condition->cart_amount_cal;
|
|
$cart_amount = $condition->cart_amount;
|
|
$cart_amount_tax_incl = (int)$condition->cart_amount_tax_incl;
|
|
$cart_amount_shipping_incl = (int)$condition->cart_amount_shipping_incl;
|
|
$cart_amount_discount_incl = (int)$condition->cart_amount_discount_incl;
|
|
}
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'cart_amount_cal' => $cart_amount_cal,
|
|
'cart_amount' => Tools::displayPrice($cart_amount),
|
|
'cart_amount_tax_incl' => $cart_amount_tax_incl,
|
|
'cart_amount_shipping_incl' =>$cart_amount_shipping_incl,
|
|
'cart_amount_discount_incl' => $cart_amount_discount_incl,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/cart_amount.tpl');
|
|
}
|
|
public static function displayProductInCart($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$total_product_quantity_cal = $condition['total_product_quantity_cal'];
|
|
$total_product_quantity = (int)$condition['total_product_quantity'];
|
|
$quantity_of_same_product_cal = $condition['quantity_of_same_product_cal'];
|
|
$quantity_of_same_product = (int)$condition['quantity_of_same_product'];
|
|
$number_of_different_product_cal = $condition['number_of_different_product_cal'];
|
|
$number_of_different_product = (int)$condition['number_of_different_product'];
|
|
$number_of_product_in_same_category_cal = $condition['number_of_product_in_same_category_cal'];
|
|
$number_of_product_in_same_category = (int)$condition['number_of_product_in_same_category'];
|
|
$apply_for_discounted_products = (int)$condition['apply_for_discounted_products'];
|
|
$products_with_different_attribute = (int)$condition['products_with_different_attribute'];
|
|
$applicable_product_categories = $condition['applicable_product_categories'];
|
|
$applicable_categories = $condition['applicable_categories'];
|
|
$include_sub_categories = $condition['include_sub_categories'];
|
|
$exclude_products = $condition['exclude_products'];
|
|
$include_specific_products = $condition['include_specific_products'];
|
|
$apply_all_attribute = (int)$condition['apply_all_attribute'];
|
|
$select_attributes = $condition['select_attributes'];
|
|
$apply_all_features = (int)$condition['apply_all_features'];
|
|
$select_features = $condition['select_features'];
|
|
$apply_all_manufacturer = (int)$condition['apply_all_manufacturer'];
|
|
$select_manufacturers = $condition['select_manufacturers'];
|
|
$apply_all_supplier = (int)$condition['apply_all_supplier'];
|
|
$select_suppliers = $condition['select_suppliers'];
|
|
$apply_for_product_price_cal = $condition['apply_for_product_price_cal'];
|
|
$apply_for_product_price = $condition['apply_for_product_price'];
|
|
$apply_for_availabled_quantity_stock_cal = $condition['apply_for_availabled_quantity_stock_cal'];
|
|
$apply_for_availabled_quantity_stock = (int)$condition['apply_for_availabled_quantity_stock'];
|
|
}
|
|
else
|
|
{
|
|
$total_product_quantity_cal = $condition->total_product_quantity_cal;
|
|
$total_product_quantity = (int)$condition->total_product_quantity;
|
|
$quantity_of_same_product_cal = $condition->quantity_of_same_product_cal;
|
|
$quantity_of_same_product = (int)$condition->quantity_of_same_product;
|
|
$number_of_different_product_cal = $condition->number_of_different_product_cal;
|
|
$number_of_different_product = (int)$condition->number_of_different_product;
|
|
$number_of_product_in_same_category_cal = $condition->number_of_product_in_same_category_cal;
|
|
$number_of_product_in_same_category = $condition->number_of_product_in_same_category;
|
|
$apply_for_discounted_products = (int)$condition->apply_for_discounted_products;
|
|
$products_with_different_attribute = (int)$condition->products_with_different_attribute;
|
|
$applicable_product_categories = $condition->applicable_product_categories;
|
|
$applicable_categories = $condition->applicable_categories;
|
|
$include_sub_categories = $condition->include_sub_categories;
|
|
$exclude_products = $condition->exclude_products;
|
|
$include_specific_products = $condition->include_specific_products;
|
|
$apply_all_attribute = (int)$condition->apply_all_attribute;
|
|
$select_attributes = $condition->select_attributes;
|
|
$apply_all_features = (int)$condition->apply_all_features;
|
|
$select_features = $condition->select_features;
|
|
$apply_all_manufacturer = (int)$condition->apply_all_manufacturer;
|
|
$select_manufacturers = $condition->select_manufacturers;
|
|
$apply_all_supplier = (int)$condition->apply_all_supplier;
|
|
$select_suppliers = $condition->select_suppliers;
|
|
$apply_for_product_price_cal = $condition->apply_for_product_price_cal;
|
|
$apply_for_product_price = $condition->apply_for_product_price;
|
|
$apply_for_availabled_quantity_stock_cal = $condition->apply_for_availabled_quantity_stock_cal;
|
|
$apply_for_availabled_quantity_stock = (int)$condition->apply_for_availabled_quantity_stock;
|
|
}
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'total_product_quantity_cal' => $total_product_quantity_cal,
|
|
'total_product_quantity' => $total_product_quantity,
|
|
'quantity_of_same_product_cal' => $quantity_of_same_product_cal,
|
|
'quantity_of_same_product' => $quantity_of_same_product,
|
|
'number_of_different_product_cal' => $number_of_different_product_cal,
|
|
'number_of_different_product' => $number_of_different_product,
|
|
'number_of_product_in_same_category_cal' => $number_of_product_in_same_category_cal,
|
|
'number_of_product_in_same_category' => $number_of_product_in_same_category,
|
|
'apply_for_discounted_products' => $apply_for_discounted_products,
|
|
'products_with_different_attribute' => $products_with_different_attribute,
|
|
'applicable_product_categories' => $applicable_product_categories,
|
|
'applicable_categories' => $applicable_product_categories=='specific_product' && $applicable_categories ? Ets_pr_defines::getCategoriesById($applicable_categories):'',
|
|
'include_sub_categories' => $include_sub_categories,
|
|
'exclude_products' => $exclude_products ? Ets_pr_defines::getProductsByIds($exclude_products):false,
|
|
'include_specific_products' => $include_specific_products ? Ets_pr_defines::getProductsByIds($include_specific_products):false,
|
|
'apply_all_attribute' => $apply_all_attribute,
|
|
'select_attributes' => $select_attributes && $select_attributes!='all' && !$apply_all_attribute ? Ets_pr_condition_rule::getInstance()->getAttributes(' AND a.id_attribute IN ('.implode(',',array_map('intval',explode(',',$select_attributes))).')'):$select_attributes,
|
|
'apply_all_features' => $apply_all_features,
|
|
'select_features' => $select_features && $select_features!='all' && !$apply_all_features ? Ets_pr_condition_rule::getInstance()->getFeatures(' AND f.id_feature IN ('.implode(',',array_map('intval',explode(',',$select_features))).')'):$select_features,
|
|
'apply_all_manufacturer' => $apply_all_manufacturer,
|
|
'select_manufacturers' => $select_manufacturers && $select_manufacturers!='all' && !$apply_all_manufacturer ? Ets_pr_condition_rule::getInstance()->getManufacturers(' AND m.id_manufacturer IN ('.implode(',',array_map('intval',explode(',',$select_manufacturers))).')'):$select_manufacturers,
|
|
'apply_all_supplier' => $apply_all_supplier,
|
|
'select_suppliers' => $select_suppliers && $select_suppliers!='all' && !$apply_all_supplier ? Ets_pr_condition_rule::getInstance()->getSuppliers(' AND s.id_supplier IN ('.implode(',',array_map('intval',explode(',',$select_suppliers))).')'):$select_suppliers,
|
|
'apply_for_product_price_cal' => $apply_for_product_price_cal,
|
|
'apply_for_product_price' => $apply_for_product_price >0 ? Tools::displayPrice($apply_for_product_price) : false,
|
|
'apply_for_availabled_quantity_stock_cal' => $apply_for_availabled_quantity_stock_cal,
|
|
'apply_for_availabled_quantity_stock' => $apply_for_availabled_quantity_stock,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/product_in_cart.tpl');
|
|
}
|
|
public static function displayDelivery($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$delivery_total_cart_weight_cal = $condition['delivery_total_cart_weight_cal'];
|
|
$delivery_total_cart_weight = $condition['delivery_total_cart_weight'];
|
|
$delivery_apply_to_carriers = $condition['delivery_apply_to_carriers'];
|
|
$delivery_id_zone = (int)$condition['delivery_id_zone'];
|
|
$delivery_id_country = (int)$condition['delivery_id_country'];
|
|
$delivery_id_state = (int)$condition['delivery_id_state'];
|
|
$delivery_speed_grade_cal = $condition['delivery_speed_grade_cal'];
|
|
$delivery_speed_grade = $condition['delivery_speed_grade'];
|
|
}
|
|
else
|
|
{
|
|
$delivery_total_cart_weight_cal = $condition->delivery_total_cart_weight_cal;
|
|
$delivery_total_cart_weight = $condition->delivery_total_cart_weight;
|
|
$delivery_apply_to_carriers = $condition->delivery_apply_to_carriers;
|
|
$delivery_id_zone = (int)$condition->delivery_id_zone;
|
|
$delivery_id_country = (int)$condition->delivery_id_country;
|
|
$delivery_id_state = (int)$condition->delivery_id_state;
|
|
$delivery_speed_grade_cal = $condition->delivery_speed_grade_cal;
|
|
$delivery_speed_grade = $condition->delivery_speed_grade;
|
|
}
|
|
$id_lang = Context::getContext()->language->id;
|
|
if($delivery_id_country)
|
|
$country = new Country($delivery_id_country,$id_lang);
|
|
if($delivery_id_state)
|
|
$state = new State($delivery_id_state,$id_lang);
|
|
if($delivery_id_zone)
|
|
$zone = new Zone($delivery_id_zone,$id_lang);
|
|
if($delivery_apply_to_carriers!='all' && $delivery_apply_to_carriers)
|
|
{
|
|
$id_carriers = explode(',',$delivery_apply_to_carriers);
|
|
$delivery_apply_to_carriers = Ets_pr_condition_rule::getInstance()->getCarriers(' AND c.id_reference IN ('.implode(',',array_map('intval',$id_carriers)).')');
|
|
}
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'country_name' => isset($country) ? $country->name:'',
|
|
'state_name' => isset($state) && $state->id_country == $delivery_id_country ? $state->name :'',
|
|
'zone_name' => isset($zone) ? $zone->name :'',
|
|
'delivery_total_cart_weight_cal' => $delivery_total_cart_weight_cal,
|
|
'delivery_total_cart_weight' => $delivery_total_cart_weight,
|
|
'delivery_apply_to_carriers' => $delivery_apply_to_carriers,
|
|
'delivery_speed_grade_cal' => $delivery_speed_grade_cal,
|
|
'delivery_speed_grade' => $delivery_speed_grade,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/delivery.tpl');
|
|
}
|
|
public static function displaySpecificOccasions($condition)
|
|
{
|
|
if(is_array($condition))
|
|
{
|
|
$specific_occasion = $condition['specific_occasion'];
|
|
$specific_occasion_hour_of_day_from = $condition['specific_occasion_hour_of_day_from'] ? json_decode($condition['specific_occasion_hour_of_day_from'],true):array();
|
|
$specific_occasion_hour_of_day_to = $condition['specific_occasion_hour_of_day_to'] ? json_decode($condition['specific_occasion_hour_of_day_to'],true):array();
|
|
$specific_occasion_day_of_week = $condition['specific_occasion_day_of_week'] ? json_decode($condition['specific_occasion_day_of_week'],true) : array();
|
|
$specific_occasion_day_of_week_from = $condition['specific_occasion_day_of_week_from'] ? json_decode($condition['specific_occasion_day_of_week_from'],true) : array();
|
|
$specific_occasion_day_of_week_to = $condition['specific_occasion_day_of_week_to'] ? json_decode($condition['specific_occasion_day_of_week_to'],true) : array();
|
|
$specific_occasion_month_of_year = $condition['specific_occasion_month_of_year'] ? json_decode($condition['specific_occasion_month_of_year'],true) : array();
|
|
$specific_occasion_month_of_year_from = $condition['specific_occasion_month_of_year_from'] ? json_decode($condition['specific_occasion_month_of_year_from'],true) : array();
|
|
$specific_occasion_month_of_year_to = $condition['specific_occasion_month_of_year_to'] ? json_decode($condition['specific_occasion_month_of_year_to'],true) : array();
|
|
$specific_occasion_date_from = $condition['specific_occasion_date_from'] ? json_decode($condition['specific_occasion_date_from'],true):array();
|
|
$specific_occasion_date_to = $condition['specific_occasion_date_to'] ? json_decode($condition['specific_occasion_date_to'],true):array();
|
|
}
|
|
else
|
|
{
|
|
$specific_occasion = $condition->specific_occasion;
|
|
$specific_occasion_hour_of_day_from = $condition->specific_occasion_hour_of_day_from ? json_decode($condition->specific_occasion_hour_of_day_from,true):array();
|
|
$specific_occasion_hour_of_day_to = $condition->specific_occasion_hour_of_day_to? json_decode($condition->specific_occasion_hour_of_day_to,true):array();
|
|
$specific_occasion_day_of_week = $condition->specific_occasion_day_of_week ? json_decode($condition->specific_occasion_day_of_week,true) : array();
|
|
$specific_occasion_day_of_week_from = $condition->specific_occasion_day_of_week_from ? json_decode($condition->specific_occasion_day_of_week_from,true) : array();
|
|
$specific_occasion_day_of_week_to = $condition->specific_occasion_day_of_week_to ? json_decode($condition->specific_occasion_day_of_week_to,true) : array();
|
|
$specific_occasion_month_of_year = $condition->specific_occasion_month_of_year ? json_decode($condition->specific_occasion_month_of_year,true) : array();
|
|
$specific_occasion_month_of_year_from = $condition->specific_occasion_month_of_year_from ? json_decode($condition->specific_occasion_month_of_year_from,true) : array();
|
|
$specific_occasion_month_of_year_to = $condition->specific_occasion_month_of_year_to ? json_decode($condition->specific_occasion_month_of_year_to,true) : array();
|
|
$specific_occasion_date_from = $condition->specific_occasion_date_from ? json_decode($condition->specific_occasion_date_from,true):array();
|
|
$specific_occasion_date_to = $condition->specific_occasion_date_to ? json_decode($condition->specific_occasion_date_to,true):array();
|
|
}
|
|
Context::getContext()->smarty->assign(
|
|
array(
|
|
'days' => Ets_pr_condition_rule::getInstance()->getDays(),
|
|
'months' => Ets_pr_condition_rule::getInstance()->getMonths(),
|
|
'specific_occasion' => $specific_occasion,
|
|
'specific_occasion_hour_of_day_from' => $specific_occasion_hour_of_day_from,
|
|
'specific_occasion_hour_of_day_to' => $specific_occasion_hour_of_day_to,
|
|
'specific_occasion_day_of_week' => $specific_occasion_day_of_week,
|
|
'specific_occasion_day_of_week_from' => $specific_occasion_day_of_week_from,
|
|
'specific_occasion_day_of_week_to' => $specific_occasion_day_of_week_to,
|
|
'specific_occasion_month_of_year' => $specific_occasion_month_of_year,
|
|
'specific_occasion_month_of_year_from' => $specific_occasion_month_of_year_from,
|
|
'specific_occasion_month_of_year_to' => $specific_occasion_month_of_year_to,
|
|
'specific_occasion_date_from' => $specific_occasion_date_from,
|
|
'specific_occasion_date_to' => $specific_occasion_date_to,
|
|
)
|
|
);
|
|
return Context::getContext()->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/condition/specific_occasions.tpl');
|
|
}
|
|
|
|
public function delete()
|
|
{
|
|
$this->module->_clearSmartyCacheWhenUpdateConditionRule();
|
|
return parent::delete(); // TODO: Change the autogenerated stub
|
|
}
|
|
} |