[+] BO: Add Specific prices bulk generator
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11056 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -222,6 +222,7 @@ var product_prices = new Array();
|
||||
<table style="text-align: center;width:100%" class="table" cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="cell border" style="width: 12%;">{l s='Rule'}</th>
|
||||
<th class="cell border" style="width: 12%;">{l s='Combination'}</th>
|
||||
<th class="cell border" style="width: 12%;">{l s='Shop'}</th>
|
||||
<th class="cell border" style="width: 12%;">{l s='Currency'}</th>
|
||||
@@ -237,7 +238,6 @@ var product_prices = new Array();
|
||||
</thead>
|
||||
<tbody>
|
||||
{$specificPriceModificationForm}
|
||||
|
||||
<script type="text/javascript">
|
||||
calcPriceTI();
|
||||
unitPriceWithTax('unit');
|
||||
|
||||
@@ -105,7 +105,7 @@ class FeatureValueCore extends ObjectModel
|
||||
* @return array Array with feature's values
|
||||
* @static
|
||||
*/
|
||||
public static function getFeatureValuesWithLang($id_lang, $id_feature)
|
||||
public static function getFeatureValuesWithLang($id_lang, $id_feature, $custom = false)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
@@ -113,7 +113,7 @@ class FeatureValueCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` vl
|
||||
ON (v.`id_feature_value` = vl.`id_feature_value` AND vl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE v.`id_feature` = '.(int)$id_feature.'
|
||||
AND (v.`custom` IS NULL OR v.`custom` = 0)
|
||||
'.(!$custom ? 'AND (v.`custom` IS NULL OR v.`custom` = 0)' : '').'
|
||||
ORDER BY vl.`value` ASC
|
||||
');
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
class SpecificPriceCore extends ObjectModel
|
||||
{
|
||||
public $id_product;
|
||||
public $id_specific_price_rule = 0;
|
||||
public $id_product_attribute;
|
||||
public $id_shop;
|
||||
public $id_currency;
|
||||
@@ -54,6 +55,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
public function getFields()
|
||||
{
|
||||
$this->validateFields();
|
||||
$fields['id_specific_price_rule'] = (int)$this->id_specific_price_rule;
|
||||
$fields['id_product'] = (int)$this->id_product;
|
||||
$fields['id_product_attribute'] = (int)$this->id_product_attribute;
|
||||
$fields['id_shop'] = (int)$this->id_shop;
|
||||
|
||||
Executable
+240
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7158 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class SpecificPriceRuleCore extends ObjectModel
|
||||
{
|
||||
public $name;
|
||||
public $id_shop;
|
||||
public $id_currency;
|
||||
public $id_country;
|
||||
public $id_group;
|
||||
public $from_quantity;
|
||||
public $price;
|
||||
public $reduction;
|
||||
public $reduction_type;
|
||||
public $from;
|
||||
public $to;
|
||||
|
||||
protected $fieldsRequired = array('id_shop', 'id_currency', 'id_country', 'id_group', 'from_quantity', 'reduction', 'reduction_type', 'from', 'to');
|
||||
protected $fieldsValidate = array('id_shop' => 'isUnsignedId', 'id_country' => 'isUnsignedId', 'id_group' => 'isUnsignedId', 'from_quantity' => 'isUnsignedInt', 'reduction' => 'isPrice', 'reduction_type' => 'isReductionType', 'from' => 'isDateFormat', 'to' => 'isDateFormat');
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'specific_price_rule',
|
||||
'primary' => 'id_specific_price_rule',
|
||||
);
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
$this->validateFields();
|
||||
|
||||
$fields['name'] = pSQL($this->name);
|
||||
$fields['id_shop'] = (int)$this->id_shop;
|
||||
$fields['id_currency'] = (int)$this->id_currency;
|
||||
$fields['id_country'] = (int)$this->id_country;
|
||||
$fields['id_group'] = (int)$this->id_group;
|
||||
$fields['from_quantity'] = (int)$this->from_quantity;
|
||||
$fields['reduction'] = (float)$this->reduction;
|
||||
$fields['reduction_type'] = pSQL($this->reduction_type);
|
||||
$fields['from'] = pSQL($this->from);
|
||||
$fields['to'] = pSQL($this->to);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$ids_condition_group = Db::getInstance()->executeS('SELECT id_specific_price_rule_condition_group
|
||||
FROM '._DB_PREFIX_.'specific_price_rule_condition_group
|
||||
WHERE id_specific_price_rule='.(int)$this->id);
|
||||
if ($ids_condition_group)
|
||||
foreach ($ids_condition_group as $row)
|
||||
{
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price_rule_condition_group
|
||||
WHERE id_specific_price_rule_condition_group='.(int)$row['id_specific_price_rule_condition_group']);
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price_rule_condition
|
||||
WHERE id_specific_price_rule_condition_group='.(int)$row['id_specific_price_rule_condition_group']);
|
||||
}
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE id_specific_price_rule='.(int)$this->id);
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
public function addConditions($conditions)
|
||||
{
|
||||
if (!is_array($conditions))
|
||||
return;
|
||||
if (!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'specific_price_rule_condition_group` (`id_specific_price_rule_condition_group`, `id_specific_price_rule`)
|
||||
VALUES(\'\', '.(int)$this->id.')'))
|
||||
return false;
|
||||
$id_specific_price_rule_condition_group = (int)Db::getInstance()->Insert_ID();
|
||||
foreach ($conditions as $condition)
|
||||
if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'specific_price_rule_condition (id_specific_price_rule_condition, id_specific_price_rule_condition_group, type, value)
|
||||
VALUES(\'\', '.(int)$id_specific_price_rule_condition_group.', \''.pSQL($condition['type']).'\', \''.pSQL($condition['value']).'\')'))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function apply($products = false)
|
||||
{
|
||||
$this->resetApplication();
|
||||
$products = $this->getAffectedProducts($products);
|
||||
foreach ($products as $product)
|
||||
SpecificPriceRule::applyRuleToProduct((int)$this->id, (int)$product['id_product'], (int)$product['id_product_attribute']);
|
||||
}
|
||||
|
||||
public function resetApplication()
|
||||
{
|
||||
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE id_specific_price_rule='.(int)$this->id);
|
||||
}
|
||||
|
||||
public static function applyAllRules($products = false)
|
||||
{
|
||||
$rules = new Collection('SpecificPriceRule');
|
||||
foreach ($rules as $rule)
|
||||
$rule->apply($products);
|
||||
}
|
||||
|
||||
public function getConditions()
|
||||
{
|
||||
$conditions = Db::getInstance()->executeS('SELECT sprd.*
|
||||
FROM '._DB_PREFIX_.'specific_price_rule_condition_group sprdg
|
||||
LEFT JOIN '._DB_PREFIX_.'specific_price_rule_condition sprd ON (sprd.id_specific_price_rule_condition_group = sprdg.id_specific_price_rule_condition_group)
|
||||
WHERE sprdg.id_specific_price_rule='.(int)$this->id);
|
||||
$conditions_group = array();
|
||||
if ($conditions)
|
||||
{
|
||||
foreach ($conditions AS &$condition)
|
||||
{
|
||||
if ($condition['type'] == 'attribute')
|
||||
$condition['id_attribute_group'] = Db::getInstance()->getValue('SELECT id_attribute_group
|
||||
FROM '._DB_PREFIX_.'attribute
|
||||
WHERE id_attribute='.(int)$condition['value']);
|
||||
elseif ($condition['type'] == 'feature')
|
||||
$condition['id_feature'] = Db::getInstance()->getValue('SELECT id_feature
|
||||
FROM '._DB_PREFIX_.'feature_value
|
||||
WHERE id_feature_value='.(int)$condition['value']);
|
||||
$conditions_group[(int)$condition['id_specific_price_rule_condition_group']][] = $condition;
|
||||
}
|
||||
}
|
||||
return $conditions_group;
|
||||
}
|
||||
|
||||
public function getAffectedProducts($products = false)
|
||||
{
|
||||
$conditions_group = $this->getConditions();
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('p.id_product');
|
||||
$query->from('product p');
|
||||
$query->groupBy('p.id_product');
|
||||
|
||||
$attributes = false;
|
||||
$categories = false;
|
||||
$features = false;
|
||||
$where = false;
|
||||
|
||||
if ($conditions_group)
|
||||
{
|
||||
$where = '(';
|
||||
foreach ($conditions_group as $id_condition_group => $condition_group)
|
||||
{
|
||||
foreach ($condition_group as $condition)
|
||||
{
|
||||
$field = false;
|
||||
if ($condition['type'] == 'category')
|
||||
{
|
||||
$field = 'cp.id_category';
|
||||
$categories = true;
|
||||
}
|
||||
elseif ($condition['type'] == 'manufacturer')
|
||||
$field = 'p.id_manufacturer';
|
||||
elseif ($condition['type'] == 'supplier')
|
||||
$field = 'p.id_supplier';
|
||||
elseif ($condition['type'] == 'feature')
|
||||
{
|
||||
$field = 'fp.id_feature_value';
|
||||
$features = true;
|
||||
}
|
||||
elseif ($condition['type'] == 'attribute')
|
||||
{
|
||||
$field = 'pac.id_attribute';
|
||||
$attributes = true;
|
||||
}
|
||||
if ($field)
|
||||
$where .= $field.'='.(int)$condition['value'].' AND ';
|
||||
|
||||
}
|
||||
$where = rtrim($where, ' AND ').') OR (';
|
||||
}
|
||||
$where = rtrim($where, 'OR (');
|
||||
if ($products && count($products))
|
||||
$where .= ' AND p.id_product IN ('.implode(', ', array_map('intval', $products)).')';
|
||||
}
|
||||
|
||||
if ($attributes)
|
||||
{
|
||||
$query->select('pa.id_product_attribute');
|
||||
$query->leftJoin('product_attribute pa ON (p.id_product = pa.id_product)');
|
||||
$query->leftJoin('product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute)');
|
||||
$query->groupBy('pa.id_product_attribute');
|
||||
}
|
||||
else
|
||||
$query->select('NULL id_product_attribute');
|
||||
|
||||
if ($features)
|
||||
$query->leftJoin('feature_product fp ON (p.id_product = fp.id_product)');
|
||||
if ($categories)
|
||||
$query->leftJoin('category_product cp ON (p.id_product = cp.id_product)');
|
||||
if ($where)
|
||||
$query->where($where);
|
||||
|
||||
return Db::getInstance()->executeS($query);
|
||||
}
|
||||
|
||||
public static function applyRuleToProduct($id_rule, $id_product, $id_product_attribute = null)
|
||||
{
|
||||
$rule = new SpecificPriceRule((int)$id_rule);
|
||||
if (!Validate::isLoadedObject($rule))
|
||||
return false;
|
||||
|
||||
$specific_price = new SpecificPrice();
|
||||
$specific_price->id_specific_price_rule = (int)$rule->id;
|
||||
$specific_price->id_product = (int)$id_product;
|
||||
$specific_price->id_product_attribute = (int)$id_product_attribute;
|
||||
$specific_price->id_shop = (int)$rule->id_shop;
|
||||
$specific_price->id_country = (int)$rule->id_country;
|
||||
$specific_price->id_currency = (int)$rule->id_currency;
|
||||
$specific_price->id_group = (int)$rule->id_group;
|
||||
$specific_price->from_quantity = (int)$rule->from_quantity;
|
||||
$specific_price->price = (int)$rule->price;
|
||||
$specific_price->reduction_type = pSQL($rule->reduction_type);
|
||||
$specific_price->reduction = (float)$rule->reduction;
|
||||
$specific_price->from = $rule->from;
|
||||
$specific_price->to = $rule->to;
|
||||
|
||||
return $specific_price->add();
|
||||
}
|
||||
}
|
||||
@@ -2458,8 +2458,13 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
else
|
||||
$attributes_name = $this->l('All combinations');
|
||||
|
||||
$rule = new SpecificPriceRule((int)$specificPrice['id_specific_price_rule']);
|
||||
$rule_name = ($rule->id ? $rule->name : '--');
|
||||
|
||||
$content .= '
|
||||
<tr '.($i%2 ? 'class="alt_row"' : '').'>
|
||||
<td class="cell border">'.$rule_name.'</td>
|
||||
<td class="cell border">'.$attributes_name.'</td>
|
||||
<td class="cell border">'.($specificPrice['id_shop'] ? $shops[$specificPrice['id_shop']]['name'] : $this->l('All shops')).'</td>
|
||||
<td class="cell border">'.($specificPrice['id_currency'] ? $currencies[$specificPrice['id_currency']]['name'] : $this->l('All currencies')).'</td>
|
||||
@@ -2470,7 +2475,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
<td class="cell border">'.$period.'</td>
|
||||
<td class="cell border">'.$specificPrice['from_quantity'].'</th>
|
||||
<td class="cell border"><b>'.Tools::displayPrice(Tools::ps_round((float)($this->_getFinalPrice($specificPrice, (float)($obj->price), $taxRate)), 2), $current_specific_currency).'</b></td>
|
||||
<td class="cell border"><a href="'.self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.(int)(Tools::getValue('id_product')).'&updateproduct&deleteSpecificPrice&id_specific_price='.(int)($specificPrice['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/delete.gif" alt="'.$this->l('Delete').'" /></a></td>
|
||||
<td class="cell border">'.(!$rule->id ? '<a href="'.self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.(int)(Tools::getValue('id_product')).'&updateproduct&deleteSpecificPrice&id_specific_price='.(int)($specificPrice['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/delete.gif" alt="'.$this->l('Delete').'" /></a>': '').'</td>
|
||||
</tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 8971 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminSpecificPriceRuleController extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'specific_price_rule';
|
||||
$this->className = 'SpecificPriceRule';
|
||||
$this->lang = false;
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->_select = 's.name shop_name, cu.name currency_name, cl.name country_name, gl.name group_name';
|
||||
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'shop s ON (s.id_shop = a.id_shop)
|
||||
LEFT JOIN '._DB_PREFIX_.'currency cu ON (cu.id_currency = a.id_currency)
|
||||
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = a.id_country AND cl.id_lang='.(int)$this->context->language->id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'group_lang gl ON (gl.id_group = a.id_group AND gl.id_lang='.(int)$this->context->language->id.')';
|
||||
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_specific_price_rule' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 25
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 200
|
||||
),
|
||||
'shop_name' => array(
|
||||
'title' => $this->l('Shop'),
|
||||
'width' => 300
|
||||
),
|
||||
'currency_name' => array(
|
||||
'title' => $this->l('Currency'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'country_name' => array(
|
||||
'title' => $this->l('Country'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'group_name' => array(
|
||||
'title' => $this->l('Group'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'from_quantity' => array(
|
||||
'title' => $this->l('From quantity'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'reduction_type' => array(
|
||||
'title' => $this->l('Reduction type'),
|
||||
'align' => 'center',
|
||||
'type' => 'select',
|
||||
'filter_key' => 'a!reduction_type',
|
||||
'list' => array(
|
||||
'percentage' => $this->l('Percentage'),
|
||||
'amount' => $this->l('Amount')
|
||||
),
|
||||
),
|
||||
'reduction' => array(
|
||||
'title' => $this->l('Reduction'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'from' => array(
|
||||
'title' => $this->l('From'),
|
||||
'align' => 'center',
|
||||
|
||||
),
|
||||
'to' => array(
|
||||
'title' => $this->l('To'),
|
||||
'align' => 'center',
|
||||
|
||||
),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
public function renderForm()
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Specific price rules'),
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name:'),
|
||||
'name' => 'name',
|
||||
'size' => 33,
|
||||
'maxlength' => 32,
|
||||
'required' => true,
|
||||
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Shop:'),
|
||||
'name' => 'id_shop',
|
||||
'options' => array(
|
||||
'query' => array_merge(array(0 => array('id_shop' => 0, 'name' => $this->l('All shops'))), Shop::getShops()),
|
||||
'id' => 'id_shop',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Currency:'),
|
||||
'name' => 'id_currency',
|
||||
'options' => array(
|
||||
'query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()),
|
||||
'id' => 'id_currency',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Country:'),
|
||||
'name' => 'id_country',
|
||||
'options' => array(
|
||||
'query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int)$this->context->language->id)),
|
||||
'id' => 'id_country',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Group:'),
|
||||
'name' => 'id_group',
|
||||
'options' => array(
|
||||
'query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int)$this->context->language->id)),
|
||||
'id' => 'id_group',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('From quantity:'),
|
||||
'name' => 'from_quantity',
|
||||
'size' => 6,
|
||||
'maxlength' => 10,
|
||||
'value' => '1'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Price:'),
|
||||
'name' => 'price',
|
||||
'size' => 6,
|
||||
'maxlength' => 10,
|
||||
'value' => '0',
|
||||
'suffix' => $this->context->currency->getSign('right'),
|
||||
),
|
||||
array(
|
||||
'type' => 'date',
|
||||
'label' => $this->l('From:'),
|
||||
'name' => 'from',
|
||||
'size' => 12,
|
||||
),
|
||||
array(
|
||||
'type' => 'date',
|
||||
'label' => $this->l('To:'),
|
||||
'name' => 'to',
|
||||
'size' => 12,
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Reduction type:'),
|
||||
'name' => 'reduction_type',
|
||||
'options' => array(
|
||||
'query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))),
|
||||
'id' => 'reduction_type',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Reduction:'),
|
||||
'name' => 'reduction',
|
||||
'required' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$attribute_groups = array();
|
||||
$attributes = Attribute::getAttributes((int)$this->context->language->id);
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
if (!isset($attribute_groups[$attribute['id_attribute_group']]))
|
||||
$attribute_groups[$attribute['id_attribute_group']] = array(
|
||||
'id_attribute_group' => $attribute['id_attribute_group'],
|
||||
'name' => $attribute['attribute_group']
|
||||
);
|
||||
$attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array(
|
||||
'id_attribute' => $attribute['id_attribute'],
|
||||
'name' => $attribute['name']
|
||||
);
|
||||
}
|
||||
$features = Feature::getFeatures((int)$this->context->language->id);
|
||||
foreach ($features AS &$feature)
|
||||
$feature['values'] = FeatureValue::getFeatureValuesWithLang((int)$this->context->language->id, $feature['id_feature'], true);
|
||||
|
||||
$this->tpl_form_vars = array(
|
||||
'manufacturers' => Manufacturer::getManufacturers(),
|
||||
'suppliers' => Supplier::getSuppliers(),
|
||||
'attributes_group' => $attribute_groups,
|
||||
'features' => $features,
|
||||
'categories' => Category::getSimpleCategories((int)$this->context->language->id),
|
||||
'conditions' => $this->object->getConditions()
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function processSave($token)
|
||||
{
|
||||
$conditions = array();
|
||||
if (Validate::isLoadedObject(($object = parent::processSave($token))))
|
||||
{
|
||||
foreach ($_POST as $key => $values)
|
||||
{
|
||||
if (preg_match('/^condition_group_([0-9]+)$/Ui', $key, $condition_group))
|
||||
{
|
||||
$conditions = array();
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$condition = explode('_', $value);
|
||||
$conditions[] = array('type' => $condition[0], 'value' => $condition[1]);
|
||||
}
|
||||
$object->addConditions($conditions);
|
||||
}
|
||||
}
|
||||
}
|
||||
$object->apply();
|
||||
}
|
||||
}
|
||||
+35
-1
@@ -1576,6 +1576,7 @@ CREATE TABLE `PREFIX_search_word` (
|
||||
|
||||
CREATE TABLE `PREFIX_specific_price` (
|
||||
`id_specific_price` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_specific_price_rule` INT(11) UNSIGNED NOT NULL,
|
||||
`id_product` INT UNSIGNED NOT NULL,
|
||||
`id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1',
|
||||
`id_currency` INT UNSIGNED NOT NULL,
|
||||
@@ -1589,7 +1590,8 @@ CREATE TABLE `PREFIX_specific_price` (
|
||||
`from` DATETIME NOT NULL,
|
||||
`to` DATETIME NOT NULL,
|
||||
PRIMARY KEY(`id_specific_price`),
|
||||
KEY (`id_product`, `id_shop`, `id_currency`, `id_country`, `id_group`, `from_quantity`, `from`, `to`)
|
||||
KEY (`id_product`, `id_shop`, `id_currency`, `id_country`, `id_group`, `from_quantity`, `from`, `to`),
|
||||
KEY (`id_specific_price_rule`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_state` (
|
||||
@@ -2290,3 +2292,35 @@ CREATE TABLE `PREFIX_order_carrier` (
|
||||
KEY `id_carrier` (`id_carrier`),
|
||||
KEY `id_order_invoice` (`id_order_invoice`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` (
|
||||
`id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`id_shop` int(11) unsigned NOT NULL DEFAULT '1',
|
||||
`id_currency` int(10) unsigned NOT NULL,
|
||||
`id_country` int(10) unsigned NOT NULL,
|
||||
`id_group` int(10) unsigned NOT NULL,
|
||||
`from_quantity` mediumint(8) unsigned NOT NULL,
|
||||
`price` DECIMAL(20,6),
|
||||
`reduction` decimal(20,6) NOT NULL,
|
||||
`reduction_type` enum('amount','percentage') NOT NULL,
|
||||
`from` datetime NOT NULL,
|
||||
`to` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_specific_price_rule`),
|
||||
KEY `id_product` (`id_shop`,`id_currency`,`id_country`,`id_group`,`from_quantity`,`from`,`to`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_specific_price_rule_condition_group` (
|
||||
`id_specific_price_rule_condition_group` INT(11) UNSIGNED NOT NULL,
|
||||
`id_specific_price_rule` INT(11) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY ( `id_specific_price_rule_condition_group`, `id_specific_price_rule` )
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_specific_price_rule_condition` (
|
||||
`id_specific_price_rule_condition` INT(11) UNSIGNED NOT NULL,
|
||||
`id_specific_price_rule_condition_group` INT(11) UNSIGNED NOT NULL,
|
||||
`type` VARCHAR(255) NOT NULL,
|
||||
`value` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id_specific_price_rule_condition`),
|
||||
INDEX (`id_specific_price_rule_condition_group`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -962,7 +962,8 @@ INSERT INTO `PREFIX_tab` (`id_tab`, `class_name`, `id_parent`, `position`) VALUE
|
||||
(105, 'AdminCmsCategories', -1, 0),
|
||||
(106, 'AdminCms', -1, 0),
|
||||
(107, 'AdminLogin', -1 , 0),
|
||||
(108, 'AdminStockConfiguration', 95, 7);
|
||||
(108, 'AdminStockConfiguration', 95, 7),
|
||||
(109, 'AdminSpecificPriceRule', 1, 11);
|
||||
|
||||
INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) (SELECT 1, id_tab, 1, 1, 1, 1 FROM `PREFIX_tab`);
|
||||
|
||||
@@ -994,7 +995,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(1, 104, 'Export'),
|
||||
(1, 105, 'CMS categories'),
|
||||
(1, 106, 'CMS pages'),
|
||||
(1, 108, 'Configuration');
|
||||
(1, 108, 'Configuration'),
|
||||
(1, 109, 'Catalog price rules');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(2, 1, 'Catalogue'),(2, 2, 'Clients'),(2, 3, 'Commandes'),(2, 4, 'Paiement'),(2, 5, 'Transport'),
|
||||
@@ -1024,7 +1026,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(2, 104, 'Export'),
|
||||
(2, 105, 'Catégories CMS'),
|
||||
(2, 106, 'Pages CMS'),
|
||||
(2, 108, 'Configuration');
|
||||
(2, 108, 'Configuration'),
|
||||
(2, 109, 'Règles de prix catalogue');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(3, 1, 'Catálogo'),(3, 2, 'Clientes'),(3, 3, 'Pedidos'),(3, 4, 'Pago'),(3, 5, 'Transporte'),
|
||||
@@ -1053,7 +1056,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(3, 104, 'Export'),
|
||||
(3, 105, 'CMS categories'),
|
||||
(3, 106, 'CMS pages'),
|
||||
(3, 108, 'Configuration');
|
||||
(3, 108, 'Configuration'),
|
||||
(3, 110, 'Catalog price rules');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(4, 1, 'Katalog'),(4, 2, 'Kunden'),(4, 3, 'Bestellungen'),(4, 4, 'Zahlung'),
|
||||
@@ -1083,7 +1087,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(4, 104, 'Export'),
|
||||
(4, 105, 'CMS categories'),
|
||||
(4, 106, 'CMS pages'),
|
||||
(4, 108, 'Configuration');
|
||||
(4, 108, 'Configuration'),
|
||||
(4, 109, 'Catalog price rules');
|
||||
|
||||
INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(5, 1, 'Catalogo'),(5, 2, 'Clienti'),(5, 3, 'Ordini'),(5, 4, 'Pagamento'),
|
||||
@@ -1113,7 +1118,8 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(5, 104, 'Export'),
|
||||
(5, 105, 'CMS categories'),
|
||||
(5, 106, 'CMS pages'),
|
||||
(5, 108, 'Configuration');
|
||||
(5, 108, 'Configuration'),
|
||||
(5, 109, 'Catalog price rules');
|
||||
|
||||
INSERT IGNORE INTO `PREFIX_tab_lang` (`id_tab`, `id_lang`, `name`)
|
||||
(SELECT `id_tab`, id_lang, (SELECT tl.`name`
|
||||
|
||||
@@ -6,7 +6,40 @@ INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `del
|
||||
INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ('4', '108', '0', '0', '0', '0');
|
||||
INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ('5', '108', '0', '0', '0', '0');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` (
|
||||
`id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`id_shop` int(11) unsigned NOT NULL DEFAULT '1',
|
||||
`id_currency` int(10) unsigned NOT NULL,
|
||||
`id_country` int(10) unsigned NOT NULL,
|
||||
`id_group` int(10) unsigned NOT NULL,
|
||||
`from_quantity` mediumint(8) unsigned NOT NULL,
|
||||
`price` DECIMAL(20,6),
|
||||
`reduction` decimal(20,6) NOT NULL,
|
||||
`reduction_type` enum('amount','percentage') NOT NULL,
|
||||
`from` datetime NOT NULL,
|
||||
`to` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_specific_price_rule`),
|
||||
KEY `id_product` (`id_shop`,`id_currency`,`id_country`,`id_group`,`from_quantity`,`from`,`to`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_specific_price_rule_condition_group` (
|
||||
`id_specific_price_rule_condition_group` INT(11) UNSIGNED NOT NULL,
|
||||
`id_specific_price_rule` INT(11) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY ( `id_specific_price_rule_condition_group`, `id_specific_price_rule` )
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_specific_price_rule_condition` (
|
||||
`id_specific_price_rule_condition` INT(11) UNSIGNED NOT NULL,
|
||||
`id_specific_price_rule_condition_group` INT(11) UNSIGNED NOT NULL,
|
||||
`type` VARCHAR(255) NOT NULL,
|
||||
`value` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id_specific_price_rule_condition`),
|
||||
INDEX (`id_specific_price_rule_condition_group`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `PREFIX_specific_price` ADD `id_specific_price_rule` INT(11) UNSIGNED NOT NULL AFTER `id_specific_price`, ADD INDEX (`id_specific_price_rule`);
|
||||
/* PHP:add_new_tab(AdminSpecificPriceRule, es:Catalog price rules|it:Catalog price rules|en:Catalog price rules|de:Catalog price rules|fr:Règles de prix catalogue, 1); */;
|
||||
|
||||
ALTER TABLE `PREFIX_orders` DROP COLUMN `id_warehouse`;
|
||||
ALTER TABLE `PREFIX_order_detail` ADD COLUMN `id_warehouse` int(10) unsigned DEFAULT 0 AFTER `id_order_invoice`;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<ul class="step" id="order_step">
|
||||
<li class="{if $current_step=='summary'}step_current{else}{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address' || $current_step=='login'}step_done{else}step_todo{/if}{/if}">
|
||||
{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address' || $current_step=='login'}
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&multi-shipping={$multi_shipping}")}">
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&multi-shipping={if isset($multi_shipping) && $multi_shipping}{$multi_shipping}{/if}")}">
|
||||
{l s='Summary'}
|
||||
</a>
|
||||
{else}
|
||||
@@ -42,7 +42,7 @@
|
||||
</li>
|
||||
<li class="{if $current_step=='login'}step_current{else}{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address'}step_done{else}step_todo{/if}{/if}">
|
||||
{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address'}
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1&multi-shipping={$multi_shipping}")}">
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1&multi-shipping={if isset($multi_shipping) && $multi_shipping}{$multi_shipping}{/if}")}">
|
||||
{l s='Login'}
|
||||
</a>
|
||||
{else}
|
||||
@@ -51,7 +51,7 @@
|
||||
</li>
|
||||
<li class="{if $current_step=='address'}step_current{else}{if $current_step=='payment' || $current_step=='shipping'}step_done{else}step_todo{/if}{/if}">
|
||||
{if $current_step=='payment' || $current_step=='shipping'}
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1&multi-shipping={$multi_shipping}")}">
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1&multi-shipping={if isset($multi_shipping) && $multi_shipping}{$multi_shipping}{/if}")}">
|
||||
{l s='Address'}
|
||||
</a>
|
||||
{else}
|
||||
@@ -60,7 +60,7 @@
|
||||
</li>
|
||||
<li class="{if $current_step=='shipping'}step_current{else}{if $current_step=='payment'}step_done{else}step_todo{/if}{/if}">
|
||||
{if $current_step=='payment'}
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=2&multi-shipping={$multi_shipping}")}">
|
||||
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=2&multi-shipping={if isset($multi_shipping) && $multi_shipping}{$multi_shipping}{/if}")}">
|
||||
{l s='Shipping'}
|
||||
</a>
|
||||
{else}
|
||||
|
||||
Reference in New Issue
Block a user