[*] BO #PSFV-94 : Added AdminFeatureController
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10137 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1863,6 +1863,13 @@ class AdminControllerCore extends Controller
|
||||
return $this->_languages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of fields value
|
||||
*
|
||||
* @param object $obj Object
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldsValue($obj)
|
||||
{
|
||||
foreach ($this->fields_form as $fieldset)
|
||||
@@ -1873,11 +1880,12 @@ class AdminControllerCore extends Controller
|
||||
{
|
||||
if ($obj->id)
|
||||
{
|
||||
$assos = array();
|
||||
$sql = 'SELECT `id_'.$input['type'].'`, `'.pSQL($this->identifier).'`
|
||||
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$input['type'].'`
|
||||
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
|
||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
||||
if ($input['type'] == 'group_shop')
|
||||
$result = GroupShop::getGroupShopById((int)$obj->id, $this->identifier, $this->table);
|
||||
else
|
||||
$result = Shop::getShopById((int)$obj->id, $this->identifier, $this->table);
|
||||
|
||||
foreach ($result as $row)
|
||||
$this->fields_value['shop'][$row['id_'.$input['type']]][] = $row[$this->identifier];
|
||||
}
|
||||
}
|
||||
|
||||
+67
-42
@@ -28,17 +28,20 @@
|
||||
class FeatureCore extends ObjectModel
|
||||
{
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
public $position;
|
||||
public $name;
|
||||
public $position;
|
||||
|
||||
protected $fieldsRequiredLang = array('name');
|
||||
protected $fieldsSizeLang = array('name' => 128);
|
||||
protected $fieldsValidateLang = array('name' => 'isGenericName', 'position' => 'isInt');
|
||||
protected $fieldsRequiredLang = array('name');
|
||||
protected $fieldsSizeLang = array('name' => 128);
|
||||
protected $fieldsValidateLang = array(
|
||||
'name' => 'isGenericName',
|
||||
'position' => 'isInt'
|
||||
);
|
||||
|
||||
protected $table = 'feature';
|
||||
protected $identifier = 'id_feature';
|
||||
protected $table = 'feature';
|
||||
protected $identifier = 'id_feature';
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
protected $webserviceParameters = array(
|
||||
'objectsNodeName' => 'product_features',
|
||||
'objectNodeName' => 'product_feature',
|
||||
'fields' => array(),
|
||||
@@ -46,7 +49,7 @@ class FeatureCore extends ObjectModel
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
return array('id_feature' => NULL, 'position' => (int)$this->position);
|
||||
return array('id_feature' => null, 'position' => (int)$this->position);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,10 +74,12 @@ class FeatureCore extends ObjectModel
|
||||
public static function getFeature($id_lang, $id_feature)
|
||||
{
|
||||
return Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON ( f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)($id_lang).')
|
||||
WHERE f.`id_feature` = '.(int)($id_feature));
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl
|
||||
ON ( f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE f.`id_feature` = '.(int)$id_feature
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,10 +92,12 @@ class FeatureCore extends ObjectModel
|
||||
public static function getFeatures($id_lang)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON (f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)($id_lang).')
|
||||
ORDER BY f.`position` ASC');
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl
|
||||
ON (f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)$id_lang.')
|
||||
ORDER BY f.`position` ASC
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +109,8 @@ class FeatureCore extends ObjectModel
|
||||
public function deleteSelection($selection)
|
||||
{
|
||||
/* Also delete Attributes */
|
||||
foreach ($selection AS $value) {
|
||||
foreach ($selection as $value)
|
||||
{
|
||||
$obj = new Feature($value);
|
||||
if (!$obj->delete())
|
||||
return false;
|
||||
@@ -123,13 +131,22 @@ class FeatureCore extends ObjectModel
|
||||
public function delete()
|
||||
{
|
||||
/* Also delete related attributes */
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_value_lang` WHERE `id_feature_value` IN (SELECT id_feature_value FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)($this->id).')');
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)($this->id));
|
||||
Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'feature_value_lang`
|
||||
WHERE `id_feature_value` IN (SELECT id_feature_value FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)$this->id.')
|
||||
');
|
||||
Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'feature_value`
|
||||
WHERE `id_feature` = '.(int)$this->id
|
||||
);
|
||||
/* Also delete related products */
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_product` WHERE `id_feature` = '.(int)($this->id));
|
||||
Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'feature_product`
|
||||
WHERE `id_feature` = '.(int)$this->id
|
||||
);
|
||||
|
||||
$return = parent::delete();
|
||||
if($return)
|
||||
if ($return)
|
||||
Hook::exec('afterDeleteFeature', array('id_feature' => $this->id));
|
||||
|
||||
/* Reinitializing position */
|
||||
@@ -174,7 +191,7 @@ class FeatureCore extends ObjectModel
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT COUNT(ag.`id_feature`) as nb
|
||||
FROM `'._DB_PREFIX_.'feature` ag
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` agl ON (ag.`id_feature` = agl.`id_feature` AND `id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` agl ON (ag.`id_feature` = agl.`id_feature` AND `id_lang` = '.(int)$id_lang.')
|
||||
ORDER BY `name` ASC');
|
||||
return ($result['nb']);
|
||||
}
|
||||
@@ -188,9 +205,14 @@ class FeatureCore extends ObjectModel
|
||||
*/
|
||||
public static function addFeatureImport($name, $position = false)
|
||||
{
|
||||
$rq = Db::getInstance()->getRow('SELECT `id_feature` FROM '._DB_PREFIX_.'feature_lang WHERE `name` = \''.pSQL($name).'\' GROUP BY `id_feature`');
|
||||
$rq = Db::getInstance()->getRow('
|
||||
SELECT `id_feature`
|
||||
FROM '._DB_PREFIX_.'feature_lang
|
||||
WHERE `name` = \''.pSQL($name).'\'
|
||||
GROUP BY `id_feature`
|
||||
');
|
||||
if (!empty($rq))
|
||||
return (int)($rq['id_feature']);
|
||||
return (int)$rq['id_feature'];
|
||||
// Feature doesn't exist, create it
|
||||
$feature = new Feature();
|
||||
$languages = Language::getLanguages();
|
||||
@@ -210,8 +232,8 @@ class FeatureCore extends ObjectModel
|
||||
return false;
|
||||
|
||||
$ids = '';
|
||||
foreach($list_ids_product as $id)
|
||||
$ids .= (int)($id).',';
|
||||
foreach ($list_ids_product as $id)
|
||||
$ids .= (int)$id.',';
|
||||
|
||||
$ids = rtrim($ids, ',');
|
||||
|
||||
@@ -219,14 +241,17 @@ class FeatureCore extends ObjectModel
|
||||
return false;
|
||||
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT * , COUNT(*) as nb
|
||||
FROM `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON f.`id_feature` = fp.`id_feature`
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON f.`id_feature` = fl.`id_feature`
|
||||
WHERE fp.`id_product` IN ('.$ids.')
|
||||
AND `id_lang` = '.(int)($id_lang).'
|
||||
GROUP BY f.`id_feature`
|
||||
ORDER BY nb DESC');
|
||||
SELECT * , COUNT(*) as nb
|
||||
FROM `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_product` fp
|
||||
ON f.`id_feature` = fp.`id_feature`
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl
|
||||
ON f.`id_feature` = fl.`id_feature`
|
||||
WHERE fp.`id_product` IN ('.$ids.')
|
||||
AND `id_lang` = '.(int)$id_lang.'
|
||||
GROUP BY f.`id_feature`
|
||||
ORDER BY nb DESC
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,11 +280,11 @@ class FeatureCore extends ObjectModel
|
||||
))
|
||||
return false;
|
||||
|
||||
foreach ($res AS $feature)
|
||||
foreach ($res as $feature)
|
||||
if ((int)$feature['id_feature'] == (int)$this->id)
|
||||
$movedFeature = $feature;
|
||||
$moved_feature = $feature;
|
||||
|
||||
if (!isset($movedFeature) || !isset($position))
|
||||
if (!isset($moved_feature) || !isset($position))
|
||||
return false;
|
||||
|
||||
// < and > statements rather than BETWEEN operator
|
||||
@@ -269,12 +294,12 @@ class FeatureCore extends ObjectModel
|
||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||
WHERE `position`
|
||||
'.($way
|
||||
? '> '.(int)$movedFeature['position'].' AND `position` <= '.(int)$position
|
||||
: '< '.(int)$movedFeature['position'].' AND `position` >= '.(int)$position))
|
||||
AND Db::getInstance()->execute('
|
||||
? '> '.(int)$moved_feature['position'].' AND `position` <= '.(int)$position
|
||||
: '< '.(int)$moved_feature['position'].' AND `position` >= '.(int)$position))
|
||||
&& Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'feature`
|
||||
SET `position` = '.(int)$position.'
|
||||
WHERE `id_feature`='.(int)$movedFeature['id_feature']));
|
||||
WHERE `id_feature`='.(int)$moved_feature['id_feature']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+65
-51
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -28,23 +28,27 @@
|
||||
class FeatureValueCore extends ObjectModel
|
||||
{
|
||||
/** @var integer Group id which attribute belongs */
|
||||
public $id_feature;
|
||||
|
||||
public $id_feature;
|
||||
|
||||
/** @var string Name */
|
||||
public $value;
|
||||
|
||||
public $value;
|
||||
|
||||
/** @var boolean Custom */
|
||||
public $custom = 0;
|
||||
|
||||
protected $fieldsRequired = array('id_feature');
|
||||
protected $fieldsValidate = array('id_feature' => 'isUnsignedId', 'custom' => 'isBool');
|
||||
protected $fieldsRequiredLang = array('value');
|
||||
protected $fieldsSizeLang = array('value' => 255);
|
||||
protected $fieldsValidateLang = array('value' => 'isGenericName');
|
||||
|
||||
protected $table = 'feature_value';
|
||||
protected $identifier = 'id_feature_value';
|
||||
|
||||
public $custom = 0;
|
||||
|
||||
protected $fieldsRequired = array('id_feature');
|
||||
protected $fieldsValidate = array(
|
||||
'id_feature' => 'isUnsignedId',
|
||||
'custom' => 'isBool'
|
||||
);
|
||||
|
||||
protected $fieldsRequiredLang = array('value');
|
||||
protected $fieldsSizeLang = array('value' => 255);
|
||||
protected $fieldsValidateLang = array('value' => 'isGenericName');
|
||||
|
||||
protected $table = 'feature_value';
|
||||
protected $identifier = 'id_feature_value';
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectsNodeName' => 'product_feature_values',
|
||||
'objectNodeName' => 'product_feature_value',
|
||||
@@ -62,7 +66,7 @@ class FeatureValueCore extends ObjectModel
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check then return multilingual fields for database interaction
|
||||
*
|
||||
@@ -73,7 +77,7 @@ class FeatureValueCore extends ObjectModel
|
||||
$this->validateFieldsLang();
|
||||
return $this->getTranslationsFields(array('value'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all values for a given feature
|
||||
*
|
||||
@@ -84,11 +88,12 @@ class FeatureValueCore extends ObjectModel
|
||||
public static function getFeatureValues($id_feature)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature_value`
|
||||
WHERE `id_feature` = '.(int)$id_feature);
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature_value`
|
||||
WHERE `id_feature` = '.(int)$id_feature
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all values for a given feature and language
|
||||
*
|
||||
@@ -100,11 +105,14 @@ class FeatureValueCore extends ObjectModel
|
||||
public static function getFeatureValuesWithLang($id_lang, $id_feature)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature_value` v
|
||||
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)
|
||||
ORDER BY vl.`value` ASC');
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature_value` v
|
||||
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)
|
||||
ORDER BY vl.`value` ASC
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,12 +125,13 @@ class FeatureValueCore extends ObjectModel
|
||||
public static function getFeatureValueLang($id_feature_value)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature_value_lang`
|
||||
WHERE `id_feature_value` = '.(int)$id_feature_value.'
|
||||
ORDER BY `id_lang`');
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'feature_value_lang`
|
||||
WHERE `id_feature_value` = '.(int)$id_feature_value.'
|
||||
ORDER BY `id_lang`
|
||||
');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select the good lang in tab
|
||||
*
|
||||
@@ -137,32 +146,34 @@ class FeatureValueCore extends ObjectModel
|
||||
if ($tab['id_lang'] == $id_lang)
|
||||
return $tab['value'];
|
||||
}
|
||||
|
||||
|
||||
public static function addFeatureValueImport($id_feature, $name)
|
||||
{
|
||||
$rq = Db::getInstance()->executeS('
|
||||
SELECT fv.`id_feature_value`
|
||||
FROM '._DB_PREFIX_.'feature_value fv
|
||||
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value`)
|
||||
WHERE `value` = \''.pSQL($name).'\'
|
||||
AND fv.`id_feature` = '.(int)$id_feature.'
|
||||
AND fv.`custom` = 0
|
||||
GROUP BY fv.`id_feature_value` LIMIT 1');
|
||||
SELECT fv.`id_feature_value`
|
||||
FROM '._DB_PREFIX_.'feature_value fv
|
||||
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl
|
||||
ON (fvl.`id_feature_value` = fv.`id_feature_value`)
|
||||
WHERE `value` = \''.pSQL($name).'\'
|
||||
AND fv.`id_feature` = '.(int)$id_feature.'
|
||||
AND fv.`custom` = 0
|
||||
GROUP BY fv.`id_feature_value` LIMIT 1
|
||||
');
|
||||
|
||||
if (!isset($rq[0]['id_feature_value']) OR !$id_feature_value = (int)$rq[0]['id_feature_value'])
|
||||
if (!isset($rq[0]['id_feature_value']) || !$id_feature_value = (int)$rq[0]['id_feature_value'])
|
||||
{
|
||||
// Feature doesn't exist, create it
|
||||
$featureValue = new FeatureValue();
|
||||
|
||||
$feature_value = new FeatureValue();
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
foreach ($languages AS $language)
|
||||
$featureValue->value[$language['id_lang']] = strval($name);
|
||||
foreach ($languages as $language)
|
||||
$feature_value->value[$language['id_lang']] = strval($name);
|
||||
|
||||
$featureValue->id_feature = (int)$id_feature;
|
||||
$featureValue->custom = 1;
|
||||
$featureValue->add();
|
||||
$feature_value->id_feature = (int)$id_feature;
|
||||
$feature_value->custom = 1;
|
||||
$feature_value->add();
|
||||
|
||||
return (int)$featureValue->id;
|
||||
return (int)$feature_value->id;
|
||||
}
|
||||
return (int)$id_feature_value;
|
||||
}
|
||||
@@ -178,9 +189,12 @@ class FeatureValueCore extends ObjectModel
|
||||
public function delete()
|
||||
{
|
||||
/* Also delete related products */
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_product` WHERE `id_feature_value` = '.(int)$this->id);
|
||||
Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'feature_product`
|
||||
WHERE `id_feature_value` = '.(int)$this->id
|
||||
);
|
||||
$return = parent::delete();
|
||||
|
||||
|
||||
if ($return)
|
||||
Hook::exec('afterDeleteFeatureValue', array('id_feature_value' => $this->id));
|
||||
return $return;
|
||||
|
||||
+18
-15
@@ -48,6 +48,9 @@ class HelperListCore extends Helper
|
||||
/** @var string Default ORDER BY clause when $orderBy is not defined */
|
||||
public $_defaultOrderBy = false;
|
||||
|
||||
/** @var array : list of vars for button delete*/
|
||||
public $tpl_delete_link_vars = array();
|
||||
|
||||
/** @var string Order way (ASC, DESC) determined by arrows in list header */
|
||||
public $orderWay;
|
||||
|
||||
@@ -100,7 +103,8 @@ class HelperListCore extends Helper
|
||||
'id_attribute' => 'id_attribute',
|
||||
'id_attribute_group' => 'id_attribute_group',
|
||||
'id_carrier' => 'id_carrier',
|
||||
'id_tab' => 'id_tab'
|
||||
'id_tab' => 'id_tab',
|
||||
'id_feature' => 'id_feature'
|
||||
);
|
||||
|
||||
/** @var if not null, a title will be added on that list */
|
||||
@@ -219,7 +223,7 @@ class HelperListCore extends Helper
|
||||
|
||||
if (method_exists($this->context->controller, $method_name))
|
||||
$this->_list[$index][$action] = $this->context->controller->$method_name($token, $id);
|
||||
elseif (method_exists($this, $method_name))
|
||||
else if (method_exists($this, $method_name))
|
||||
$this->_list[$index][$action] = $this->$method_name($token, $id);
|
||||
|
||||
}
|
||||
@@ -248,9 +252,9 @@ class HelperListCore extends Helper
|
||||
Tools::getValue('id_product')
|
||||
);
|
||||
}
|
||||
elseif (isset($params['activeVisu']))
|
||||
else if (isset($params['activeVisu']))
|
||||
$this->_list[$index][$key] = (bool)$tr[$key];
|
||||
elseif (isset($params['position']))
|
||||
else if (isset($params['position']))
|
||||
{
|
||||
$this->_list[$index][$key] = array(
|
||||
'position' => $tr[$key],
|
||||
@@ -262,7 +266,7 @@ class HelperListCore extends Helper
|
||||
'&way=0&position='.((int)$tr['position'] - 1).'&token='.$this->token
|
||||
);
|
||||
}
|
||||
elseif (isset($params['image']))
|
||||
else if (isset($params['image']))
|
||||
{
|
||||
// item_id is the product id in a product image context, else it is the image id.
|
||||
$item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id;
|
||||
@@ -276,24 +280,24 @@ class HelperListCore extends Helper
|
||||
|
||||
$this->_list[$index][$key] = cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
|
||||
}
|
||||
elseif (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
|
||||
else if (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
|
||||
$this->_list[$index][$key] = isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'];
|
||||
elseif (isset($params['float']))
|
||||
else if (isset($params['float']))
|
||||
$this->_list[$index][$key] = rtrim(rtrim($tr[$key], '0'), '.');
|
||||
elseif (isset($params['type']) && $params['type'] == 'price')
|
||||
else if (isset($params['type']) && $params['type'] == 'price')
|
||||
{
|
||||
$currency = isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency;
|
||||
$this->_list[$index][$key] = Tools::displayPrice($tr[$key], $currency, false);
|
||||
}
|
||||
elseif (isset($params['type']) && $params['type'] == 'date')
|
||||
else if (isset($params['type']) && $params['type'] == 'date')
|
||||
$this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id);
|
||||
elseif (isset($params['type']) && $params['type'] == 'datetime')
|
||||
else if (isset($params['type']) && $params['type'] == 'datetime')
|
||||
$this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id, true);
|
||||
elseif (isset($tr[$key]))
|
||||
else if (isset($tr[$key]))
|
||||
{
|
||||
if ($key == 'price')
|
||||
$echo = round($tr[$key], 2);
|
||||
elseif (isset($params['maxlength']) && Tools::strlen($tr[$key]) > $params['maxlength'])
|
||||
else if (isset($params['maxlength']) && Tools::strlen($tr[$key]) > $params['maxlength'])
|
||||
$echo = '<span title="'.$tr[$key].'">'.Tools::substr($tr[$key], 0, $params['maxlength']).'...</span>';
|
||||
else
|
||||
$echo = $tr[$key];
|
||||
@@ -393,7 +397,7 @@ class HelperListCore extends Helper
|
||||
$tpl->assign(array(
|
||||
'id' => $id,
|
||||
'controller' => str_replace('Controller', '', get_class($this->context->controller)),
|
||||
'token' => $this->token,
|
||||
'token' => $token != null ? $token : $this->token,
|
||||
'action' => self::$cache_lang['Details'],
|
||||
'params' => $this->ajax_params
|
||||
));
|
||||
@@ -496,7 +500,7 @@ class HelperListCore extends Helper
|
||||
isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : null
|
||||
);
|
||||
|
||||
$this->is_dnd_identifier = array_key_exists($this->identifier,$this->identifiersDnd);
|
||||
$this->is_dnd_identifier = array_key_exists($this->identifier, $this->identifiersDnd);
|
||||
/*
|
||||
if ($is_dnd_identifier)
|
||||
{
|
||||
@@ -605,7 +609,6 @@ class HelperListCore extends Helper
|
||||
'current' => $this->currentIndex,
|
||||
'simple_header' => $this->simple_header,
|
||||
'bulk_actions' => $this->bulk_actions,
|
||||
|
||||
'back' => Tools::getValue('back'),
|
||||
'no_back' => $this->no_back,
|
||||
)));
|
||||
|
||||
+45
-24
@@ -30,31 +30,31 @@
|
||||
*/
|
||||
class GroupShopCore extends ObjectModel
|
||||
{
|
||||
public $name;
|
||||
public $active;
|
||||
public $share_customer;
|
||||
public $share_order;
|
||||
public $deleted;
|
||||
public $name;
|
||||
public $active;
|
||||
public $share_customer;
|
||||
public $share_order;
|
||||
public $deleted;
|
||||
|
||||
protected $fieldsSize = array('name' => 64);
|
||||
protected $fieldsValidate = array(
|
||||
protected $fieldsSize = array('name' => 64);
|
||||
protected $fieldsValidate = array(
|
||||
'active' => 'isBool',
|
||||
'share_customer' => 'isBool',
|
||||
'share_order' => 'isBool',
|
||||
'name' => 'isGenericName',
|
||||
);
|
||||
protected $table = 'group_shop';
|
||||
protected $identifier = 'id_group_shop';
|
||||
protected $table = 'group_shop';
|
||||
protected $identifier = 'id_group_shop';
|
||||
|
||||
private static $assoTables = array(
|
||||
'attribute_group' => array('type' => 'group_shop'),
|
||||
'attribute' => array('type' => 'group_shop'),
|
||||
'feature' => array('type' => 'group_shop'),
|
||||
'group' => array('type' => 'group_shop'),
|
||||
'manufacturer' => array('type' => 'group_shop'),
|
||||
'supplier' => array('type' => 'group_shop'),
|
||||
'zone' => array('type' => 'shop'),
|
||||
'tax_rules_group' => array('type' => 'group_shop'),
|
||||
'attribute_group' => array('type' => 'group_shop'),
|
||||
'attribute' => array('type' => 'group_shop'),
|
||||
'feature' => array('type' => 'group_shop'),
|
||||
'group' => array('type' => 'group_shop'),
|
||||
'manufacturer' => array('type' => 'group_shop'),
|
||||
'supplier' => array('type' => 'group_shop'),
|
||||
'zone' => array('type' => 'shop'),
|
||||
'tax_rules_group' => array('type' => 'group_shop'),
|
||||
);
|
||||
|
||||
public function getFields()
|
||||
@@ -71,9 +71,11 @@ class GroupShopCore extends ObjectModel
|
||||
|
||||
public static function getGroupShops($active = true)
|
||||
{
|
||||
return Db::getInstance()->executeS('SELECT *
|
||||
FROM '._DB_PREFIX_.'group_shop
|
||||
WHERE `deleted`= 0 AND `active`='.(int)$active);
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM '._DB_PREFIX_.'group_shop
|
||||
WHERE `deleted`= 0 AND `active`='.(int)$active
|
||||
);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
@@ -81,7 +83,7 @@ class GroupShopCore extends ObjectModel
|
||||
if (!$res = parent::delete())
|
||||
return false;
|
||||
|
||||
foreach (Shop::getAssoTables() AS $table_name => $row)
|
||||
foreach (Shop::getAssoTables() as $table_name => $row)
|
||||
{
|
||||
$id = 'id_'.$row['type'];
|
||||
if ($row['type'] == 'fk_group_shop')
|
||||
@@ -96,7 +98,7 @@ class GroupShopCore extends ObjectModel
|
||||
|
||||
public static function getAssoTables()
|
||||
{
|
||||
return self::$assoTables;
|
||||
return self::$assoTables;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +106,7 @@ class GroupShopCore extends ObjectModel
|
||||
*/
|
||||
public static function getTotalGroupShops($active = true)
|
||||
{
|
||||
return sizeof(GroupShop::getGroupShops($active));
|
||||
return count(GroupShop::getGroupShops($active));
|
||||
}
|
||||
|
||||
public function haveShops()
|
||||
@@ -134,9 +136,28 @@ class GroupShopCore extends ObjectModel
|
||||
return (int)Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of group shop by id
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $identifier
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public static function getGroupShopById($id, $identifier, $table)
|
||||
{
|
||||
$sql = sprintf('
|
||||
SELECT `id_group_shop`, `%s`
|
||||
FROM `'._DB_PREFIX_.'%s_group_shop`
|
||||
WHERE `%s` = %d'
|
||||
, $identifier, $table, $identifier, $id);
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
public function copyGroupShopData($old_id, $tables_import = false, $deleted = false)
|
||||
{
|
||||
foreach (GroupShop::getAssoTables() AS $table_name => $row)
|
||||
foreach (GroupShop::getAssoTables() as $table_name => $row)
|
||||
{
|
||||
if ($tables_import && !isset($tables_import[$table_name]))
|
||||
continue;
|
||||
|
||||
+35
-5
@@ -167,7 +167,10 @@ class ShopCore extends ObjectModel
|
||||
$id = 'id_shop';
|
||||
else
|
||||
$table_name .= '_'.$row['type'];
|
||||
$res &= Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.$table_name.'` WHERE `'.$id.'`='.(int)$this->id);
|
||||
$res &= Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.$table_name.'`
|
||||
WHERE `'.$id.'`='.(int)$this->id
|
||||
);
|
||||
}
|
||||
|
||||
Shop::cacheShops(true);
|
||||
@@ -183,13 +186,21 @@ class ShopCore extends ObjectModel
|
||||
public static function has_dependency($id_shop)
|
||||
{
|
||||
$has_dependency = false;
|
||||
$nbr_customer = (int)Db::getInstance()->getValue('SELECT `id_customer` FROM `'._DB_PREFIX_.'customer` WHERE `id_shop`='.(int)$id_shop);
|
||||
if($nbr_customer)
|
||||
$nbr_customer = (int)Db::getInstance()->getValue('
|
||||
SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `id_shop`='.(int)$id_shop
|
||||
);
|
||||
if ($nbr_customer)
|
||||
$has_dependency = true;
|
||||
else
|
||||
{
|
||||
$nbr_order= (int)Db::getInstance()->getValue('SELECT `id_order` FROM `'._DB_PREFIX_.'orders` WHERE `id_shop`='.(int)$id_shop);
|
||||
if($nbr_order)
|
||||
$nbr_order = (int)Db::getInstance()->getValue('
|
||||
SELECT `id_order`
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_shop`='.(int)$id_shop
|
||||
);
|
||||
if ($nbr_order)
|
||||
$has_dependency = true;
|
||||
}
|
||||
|
||||
@@ -609,6 +620,25 @@ class ShopCore extends ObjectModel
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of shop by id
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $identifier
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public static function getShopById($id, $identifier, $table)
|
||||
{
|
||||
$sql = sprintf('
|
||||
SELECT `id_shop`, `%s`
|
||||
FROM `'._DB_PREFIX_.'%s_shop`
|
||||
WHERE `%s` = %d'
|
||||
, $identifier, $table, $identifier, $id);
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current shop context in FO or BO
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user