Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
a45724cfcd
@ -363,6 +363,22 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
echo $helperForm->generateInput($input);
|
||||
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
|
||||
$input = array(
|
||||
'type' => 'switch',
|
||||
@ -1132,6 +1148,7 @@ class AdminPrivateSalesSales extends AdminTab {
|
||||
$sale->logout = Tools::getValue('logout', 0);
|
||||
$sale->new = Tools::getValue('new', 0);
|
||||
$sale->braderie = Tools::getValue('braderie', 0);
|
||||
$sale->uncombinable = Tools::getValue('uncombinable', 0);
|
||||
$sale->forward_news = Tools::getValue('forward_news', 0);
|
||||
$sale->pub = Tools::getValue('pub', 0);
|
||||
$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->new = Tools::getValue('new', 0);
|
||||
$sale->braderie = Tools::getValue('braderie', 0);
|
||||
$sale->uncombinable = Tools::getValue('uncombinable', 0);
|
||||
$sale->forward_news = Tools::getValue('forward_news', 0);
|
||||
$sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT'));
|
||||
$sale->id_employee = (int) Tools::getValue('id_employee');
|
||||
|
@ -14,6 +14,7 @@ class Sale {
|
||||
var $pub = 0;
|
||||
var $new = 0;
|
||||
var $braderie = 0;
|
||||
var $uncombinable = 0;
|
||||
var $forward_news = 0;
|
||||
var $lock_position = 0;
|
||||
var $id_category;
|
||||
@ -41,6 +42,7 @@ class Sale {
|
||||
$this->pub = $sale['pub'];
|
||||
$this->new = $sale['new'];
|
||||
$this->braderie = $sale['braderie'];
|
||||
$this->uncombinable = $sale['uncombinable'];
|
||||
$this->forward_news = $sale['forward_news'];
|
||||
$this->id_category = $sale['id_category'];
|
||||
$this->id_employee = $sale['id_employee'];
|
||||
@ -94,6 +96,7 @@ class Sale {
|
||||
`logout` = '.(int) $this->logout.',
|
||||
`new` = '.(int) $this->new.',
|
||||
`braderie` = '.(int) $this->braderie.',
|
||||
`uncombinable` = '.(int) $this->uncombinable.',
|
||||
`forward_news` = '.(int) $this->forward_news.',
|
||||
`public` = '.(int) $this->pub.',
|
||||
`id_category` = '.(int) $this->id_category.',
|
||||
@ -191,6 +194,7 @@ class Sale {
|
||||
'.(int) $this->pub.',
|
||||
'.(int) $this->new.',
|
||||
'.(int) $this->braderie.',
|
||||
'.(int) $this->uncombinable.',
|
||||
'.(int) $this->forward_news.',
|
||||
'.(int) $this->id_category.',
|
||||
'.(int) $this->id_employee.',
|
||||
@ -364,6 +368,7 @@ class Sale {
|
||||
'pub' => $ps[0]['public'],
|
||||
'new' => $ps[0]['new'],
|
||||
'braderie' => $ps[0]['braderie'],
|
||||
'uncombinable' => $ps[0]['uncombinable'],
|
||||
'forward_news' => $ps[0]['forward_news'],
|
||||
'position' => $ps[0]['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
|
||||
* 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]
|
||||
* @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
|
||||
if((int)$adding_sale['id_sale'] == (int)$current_sale['id_sale']){
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user