[*] BO : Add reduction groups in the categories, and bug fix: reduction that is not an integer or a percentage (TD001 - TD002 - TD003)

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8536 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2011-09-13 13:17:32 +00:00
parent fc7612f010
commit 5cae5358fa
5 changed files with 40 additions and 7 deletions
+1 -1
View File
@@ -798,7 +798,7 @@ class AdminCustomers extends AdminTab
echo '<option value="'.(int)($group['id_group']).'"'.($group['id_group'] == $obj->id_default_group ? ' selected="selected"' : '').'>'.htmlentities($group['name'], ENT_NOQUOTES, 'utf-8').'</option>';
echo '
</select>
<p>'.$this->l('Apply non-cumulative rules (e.g., price, display method, reduction)').'</p>
<div class="hintGroup">'.$this->l('The group will be as applied by default.').'</div>
</div>
<label>'.$this->l('Groups:').' </label>
<div class="margin-form">';
+15 -5
View File
@@ -93,7 +93,9 @@ class AdminGroups extends AdminTab
<div class="margin-form">';
if ($groupReductions)
{
echo '<table>
echo '
<table>
<tr>
<th>'.$this->l('Category').'</th>
<th>'.$this->l('Value').'</th>
@@ -141,6 +143,7 @@ class AdminGroups extends AdminTab
<form action="'.self::$currentIndex.'&update'.$this->table.'&id_group='.$obj->id.'&token='.$this->token.'" method="post" class="width3">
<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />
<fieldset><legend><img src="../img/admin/tab-groups.gif" />'.$this->l('New group discount').'</legend>
<div class="hintGroup">'.$this->l('Beware the reduction applied to a category does not stack with the overall reduction but replaces. The group is automatically added to the category.').'</div>
<label>'.$this->l('Category:').' </label>
<div class="margin-form">
<select name="id_category">';
@@ -151,7 +154,7 @@ class AdminGroups extends AdminTab
</div>
<label>'.$this->l('Discount (in %):').' </label>
<div class="margin-form">
<input type="text" name="reduction" value="" /><sup>*</sup>
<input type="text" name="reductionByCategory" value="" /><sup>*</sup>
</div>
<div class="clear">&nbsp;</div>
<div class="margin-form">
@@ -306,12 +309,17 @@ class AdminGroups extends AdminTab
$groupReduction = new GroupReduction();
if (!$id_category = Tools::getValue('id_category') OR !Validate::isUnsignedId($id_category))
$this->_errors[] = Tools::displayError('Wrong category ID');
elseif (!$reduction = Tools::getValue('reduction') OR !Validate::isPrice($reduction))
elseif (!$reduction = Tools::getValue('reductionByCategory') OR !Validate::isPrice($reduction))
$this->_errors[] = Tools::displayError('Invalid reduction (must be a percentage)');
elseif (GroupReduction::doesExist((int)($obj->id), $id_category))
elseif (Tools::getValue('reductionByCategory') > 100 OR Tools::getValue('reductionByCategory') < 0)
$this->_errors[] = Tools::displayError('Reduction value is incorrect');
elseif (GroupReduction::doesExist((int)($obj->id), $id_category)){
$this->_errors[] = Tools::displayError('A reduction already exists for this category.');
}
else
{
$category = new Category((int)$id_category);
$category->addGroupsIfNoExist(Tools::getValue('id_group'));
$groupReduction->id_category = (int)($id_category);
$groupReduction->id_group = (int)($obj->id);
$groupReduction->reduction = (float)($reduction) / 100;
@@ -338,7 +346,9 @@ class AdminGroups extends AdminTab
{
foreach ($id_group_reductions AS $key => $id_group_reduction)
if (!Validate::isUnsignedId($id_group_reductions[$key]) OR !Validate::isPrice($reductions[$key]))
$this->_errors[] = Tools::displayError();
$this->_errors[] = Tools::displayError('Invalid reduction (must be a percentage)');
elseif ($reductions[$key] > 100 OR $reductions[$key] < 0)
$this->_errors[] = Tools::displayError('Reduction value is incorrect');
else
{
$groupReduction = new GroupReduction((int)($id_group_reductions[$key]));
+12
View File
@@ -849,6 +849,18 @@ class CategoryCore extends ObjectModel
$groups[] = $group['id_group'];
return $groups;
}
public function addGroupsIfNoExist($id_group)
{
$groups = $this->getGroups();
p($groups);
foreach($groups as $group){
if($group != $id_group)
return false;
else
$this->addGroups(array((int)($id_group)));
}
}
/**
* checkAccess return true if id_customer is in a group allowed to see this category.
+10
View File
@@ -762,6 +762,16 @@ div.hint {
position: relative;
}
.hintGroup{
position: relative;
margin-top: 10px;
margin-bottom: 10px;
border: 1px solid #50B0EC;
padding: 8px 6px 8px 40px;
color: #383838;
background: #DDE9F7 url(../img/admin/help2.png) no-repeat 6px 5px;
}
/* The pointer image is added by using another span */
.hint .hint-pointer {
+2 -1
View File
@@ -727,7 +727,7 @@ $_LANGADM['AdminCustomers8d218b952c9ef571cd270aaef8f849d1'] = 'Autoriser ou non
$_LANGADM['AdminCustomerscca344269d726c206f3d3894c85cae5a'] = 'Client abonné à la newsletter';
$_LANGADM['AdminCustomers5ed5ce582affef97f07fa474c6751302'] = 'Client acceptant de recevoir des publicités';
$_LANGADM['AdminCustomers8d177b48ffca1fb18c3bfd1e8c0eb645'] = 'Groupe par défaut:';
$_LANGADM['AdminCustomers7aea94ad2dc662cb934bc6746775fd3f'] = 'Le groupe à partir du quelle s\'appliquent les règles non cumulatives (par exemple, la méthode d\'affichage des prix, réduction)';
$_LANGADM['AdminCustomersbf935f3541fafe3c2a68d2c52b0856b5'] = 'Le groupe par défaut est le groupe qui appliquera les règles non cumulatives (par exemple, la méthode d\'affichage des prix, réduction)';
$_LANGADM['AdminCustomers8783bc7ae2b9e8d93a2bc15150aaefa8'] = 'Groupes :';
$_LANGADM['AdminCustomersc6155aaecccf794cd2a00fcc35898022'] = 'Nom du groupe';
$_LANGADM['AdminCustomers3cf21846659529ae741430ff2ddf287f'] = 'Cochez tous les groupes auxquels appartient le membre';
@@ -1020,6 +1020,7 @@ $_LANGADM['AdminGroups817b35caca2afa11b6c1efc428315470'] = 'Groupe de boutiques
$_LANGADM['AdminGroups38fb7d24e0d60a048f540ecb18e13376'] = 'Enregistrer';
$_LANGADM['AdminGroups19f823c6453c2b1ffd09cb715214813d'] = 'Champs requis';
$_LANGADM['AdminGroupsc53a3dc4f27d93e065c2c5be5a78b74f'] = 'Nouvelle réduction de groupe';
$_LANGADM['AdminGroupsf3301519f560b65be8d8e67336df5b07'] = 'Attention, la réduction appliqué à une catégorie ne se cumule pas avec la réduction global mais la remplace. Le groupe est automatiquement ajoutée à la catégorie.';
$_LANGADM['AdminGroups56a8a9eb05f9014da51a4f9b57322ac7'] = 'Catégorie :';
$_LANGADM['AdminGroups60c4a9a7f56f6b9669f84977ebd0f93d'] = 'Seuls les produits qui ont cette catégorie par défaut seront ajoutés';
$_LANGADM['AdminGroups567183b8b1122180690be51cc6df2b74'] = 'Réduction (en %) :';