Merge branch 'ticket-14161-UncombinableSale' into develop
This commit is contained in:
commit
3aaf570fdc
@ -363,6 +363,22 @@ class AdminPrivateSalesSales extends AdminTab {
|
|||||||
echo $helperForm->generateInput($input);
|
echo $helperForm->generateInput($input);
|
||||||
echo '<div class="clearfix"></div>';
|
echo '<div class="clearfix"></div>';
|
||||||
|
|
||||||
|
// Uncombinable
|
||||||
|
$input = array(
|
||||||
|
'type' => 'switch',
|
||||||
|
'name' => 'uncombinable',
|
||||||
|
'label' => $this->l('Non cumulable :'),
|
||||||
|
// 'label_on' => '<span class="anticon anticon-checkmark text-green-light"></span>',
|
||||||
|
// 'label_off' => '<span class="anticon anticon-cross text-rose"></span>',
|
||||||
|
'label-class' => 'col-sm-8',
|
||||||
|
'input-class' => 'col-sm-4',
|
||||||
|
'default' => ($this->cursale!==NULL?($this->cursale->uncombinable==0?0:1):0),
|
||||||
|
'checked' => ($this->cursale!==NULL?($this->cursale->uncombinable==0?0:1):0),
|
||||||
|
'required' => true,
|
||||||
|
);
|
||||||
|
echo $helperForm->generateInput($input);
|
||||||
|
echo '<div class="clearfix"></div>';
|
||||||
|
|
||||||
// Featured
|
// Featured
|
||||||
$input = array(
|
$input = array(
|
||||||
'type' => 'switch',
|
'type' => 'switch',
|
||||||
@ -1132,6 +1148,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
|||||||
$sale->logout = Tools::getValue('logout', 0);
|
$sale->logout = Tools::getValue('logout', 0);
|
||||||
$sale->new = Tools::getValue('new', 0);
|
$sale->new = Tools::getValue('new', 0);
|
||||||
$sale->braderie = Tools::getValue('braderie', 0);
|
$sale->braderie = Tools::getValue('braderie', 0);
|
||||||
|
$sale->uncombinable = Tools::getValue('uncombinable', 0);
|
||||||
$sale->forward_news = Tools::getValue('forward_news', 0);
|
$sale->forward_news = Tools::getValue('forward_news', 0);
|
||||||
$sale->pub = Tools::getValue('pub', 0);
|
$sale->pub = Tools::getValue('pub', 0);
|
||||||
$sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT'));
|
$sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT'));
|
||||||
@ -1216,6 +1233,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
|||||||
$sale->pub = Tools::getValue('pub', 0);
|
$sale->pub = Tools::getValue('pub', 0);
|
||||||
$sale->new = Tools::getValue('new', 0);
|
$sale->new = Tools::getValue('new', 0);
|
||||||
$sale->braderie = Tools::getValue('braderie', 0);
|
$sale->braderie = Tools::getValue('braderie', 0);
|
||||||
|
$sale->uncombinable = Tools::getValue('uncombinable', 0);
|
||||||
$sale->forward_news = Tools::getValue('forward_news', 0);
|
$sale->forward_news = Tools::getValue('forward_news', 0);
|
||||||
$sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT'));
|
$sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT'));
|
||||||
$sale->id_employee = (int) Tools::getValue('id_employee');
|
$sale->id_employee = (int) Tools::getValue('id_employee');
|
||||||
|
@ -14,6 +14,7 @@ class Sale {
|
|||||||
var $pub = 0;
|
var $pub = 0;
|
||||||
var $new = 0;
|
var $new = 0;
|
||||||
var $braderie = 0;
|
var $braderie = 0;
|
||||||
|
var $uncombinable = 0;
|
||||||
var $forward_news = 0;
|
var $forward_news = 0;
|
||||||
var $lock_position = 0;
|
var $lock_position = 0;
|
||||||
var $id_category;
|
var $id_category;
|
||||||
@ -41,6 +42,7 @@ class Sale {
|
|||||||
$this->pub = $sale['pub'];
|
$this->pub = $sale['pub'];
|
||||||
$this->new = $sale['new'];
|
$this->new = $sale['new'];
|
||||||
$this->braderie = $sale['braderie'];
|
$this->braderie = $sale['braderie'];
|
||||||
|
$this->uncombinable = $sale['uncombinable'];
|
||||||
$this->forward_news = $sale['forward_news'];
|
$this->forward_news = $sale['forward_news'];
|
||||||
$this->id_category = $sale['id_category'];
|
$this->id_category = $sale['id_category'];
|
||||||
$this->id_employee = $sale['id_employee'];
|
$this->id_employee = $sale['id_employee'];
|
||||||
@ -94,6 +96,7 @@ class Sale {
|
|||||||
`logout` = '.(int) $this->logout.',
|
`logout` = '.(int) $this->logout.',
|
||||||
`new` = '.(int) $this->new.',
|
`new` = '.(int) $this->new.',
|
||||||
`braderie` = '.(int) $this->braderie.',
|
`braderie` = '.(int) $this->braderie.',
|
||||||
|
`uncombinable` = '.(int) $this->uncombinable.',
|
||||||
`forward_news` = '.(int) $this->forward_news.',
|
`forward_news` = '.(int) $this->forward_news.',
|
||||||
`public` = '.(int) $this->pub.',
|
`public` = '.(int) $this->pub.',
|
||||||
`id_category` = '.(int) $this->id_category.',
|
`id_category` = '.(int) $this->id_category.',
|
||||||
@ -191,6 +194,7 @@ class Sale {
|
|||||||
'.(int) $this->pub.',
|
'.(int) $this->pub.',
|
||||||
'.(int) $this->new.',
|
'.(int) $this->new.',
|
||||||
'.(int) $this->braderie.',
|
'.(int) $this->braderie.',
|
||||||
|
'.(int) $this->uncombinable.',
|
||||||
'.(int) $this->forward_news.',
|
'.(int) $this->forward_news.',
|
||||||
'.(int) $this->id_category.',
|
'.(int) $this->id_category.',
|
||||||
'.(int) $this->id_employee.',
|
'.(int) $this->id_employee.',
|
||||||
@ -364,6 +368,7 @@ class Sale {
|
|||||||
'pub' => $ps[0]['public'],
|
'pub' => $ps[0]['public'],
|
||||||
'new' => $ps[0]['new'],
|
'new' => $ps[0]['new'],
|
||||||
'braderie' => $ps[0]['braderie'],
|
'braderie' => $ps[0]['braderie'],
|
||||||
|
'uncombinable' => $ps[0]['uncombinable'],
|
||||||
'forward_news' => $ps[0]['forward_news'],
|
'forward_news' => $ps[0]['forward_news'],
|
||||||
'position' => $ps[0]['position'],
|
'position' => $ps[0]['position'],
|
||||||
'lock_position' => $ps[0]['lock_position'],
|
'lock_position' => $ps[0]['lock_position'],
|
||||||
@ -1982,6 +1987,24 @@ class Sale {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the sale is tagged as uncombinable or not
|
||||||
|
* @param [int] $id_sale
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function isUncombinable($id_sale)
|
||||||
|
{
|
||||||
|
$result = Db::getInstance()->getValue('
|
||||||
|
SELECT `uncombinable`
|
||||||
|
FROM `'._DB_PREFIX_.'privatesale`
|
||||||
|
WHERE `id_sale` = '.(int)$id_sale.'
|
||||||
|
');
|
||||||
|
if($result && (int)$result == 1){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the combination of two sale in the cart
|
* Test the combination of two sale in the cart
|
||||||
* Only classic and particular delivery sales can be added together
|
* Only classic and particular delivery sales can be added together
|
||||||
@ -1993,8 +2016,35 @@ class Sale {
|
|||||||
* @param array(id_sale, delivery_delay, shipping) $adding_sale [the sale of the new added product]
|
* @param array(id_sale, delivery_delay, shipping) $adding_sale [the sale of the new added product]
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function isCombinable($current_sale, $adding_sale)
|
public static function isCombinable($sale, $added_sale)
|
||||||
{
|
{
|
||||||
|
if(is_array($sale) && is_array($added_sale)){
|
||||||
|
$current_sale = $sale;
|
||||||
|
$adding_sale = $added_sale;
|
||||||
|
} else {
|
||||||
|
// We can test with the attribute
|
||||||
|
if((int)$sale->uncombinable == 1 || (int)$added_sale->uncombinable == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $sale and $added_sale are Sale object
|
||||||
|
$current_sale = array(
|
||||||
|
'id_sale'=> (int) $sale->id,
|
||||||
|
'delivery_delay'=> (int) $sale->delivery_delay,
|
||||||
|
'shipping' => self::getShippingSale((int)$sale->id)
|
||||||
|
);
|
||||||
|
$adding_sale = array(
|
||||||
|
'id_sale'=> (int) $added_sale->id,
|
||||||
|
'delivery_delay'=> (int) $added_sale->delivery_delay,
|
||||||
|
'shipping' => self::getShippingSale((int)$added_sale->id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sale is uncombinable
|
||||||
|
if(self::isUncombinable((int)$current_sale['id_sale']) || self::isUncombinable((int)$adding_sale['id_sale'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Same sale
|
// Same sale
|
||||||
if((int)$adding_sale['id_sale'] == (int)$current_sale['id_sale']){
|
if((int)$adding_sale['id_sale'] == (int)$current_sale['id_sale']){
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user