// Fix default shop associations in helper shop #PSTEST-770

This commit is contained in:
rMalie
2012-02-16 14:10:30 +00:00
parent e9d113dac7
commit c02982a8f8
8 changed files with 81 additions and 81 deletions
-60
View File
@@ -309,66 +309,6 @@ class HelperCore
return Translate::getAdminTranslation($string, get_class($this), $addslashes, $htmlentities);
}
/**
* Render an area to determinate shop association
*
* @param string $type 'shop' or 'group_shop'
*
* @return string
*/
public function renderAssoShop($type = 'shop')
{
if (!Shop::isFeatureActive())
return;
if ($type != 'shop' && $type != 'group_shop')
$type = 'shop';
$assos = array();
if ((int)$this->id)
{
$sql = 'SELECT `id_'.$type.'`, `'.bqSQL($this->identifier).'`
FROM `'._DB_PREFIX_.bqSQL($this->table).'_'.$type.'`
WHERE `'.bqSQL($this->identifier).'` = '.(int)$this->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$assos[$row['id_'.$type]] = $row['id_'.$type];
}
else
{
switch (Context::shop())
{
case Shop::CONTEXT_SHOP :
$assos[$this->context->shop->id] = $this->context->shop->id;
break;
case Shop::CONTEXT_GROUP :
foreach (Shop::getShops(false, $this->context->shop->getGroupID(), true) as $id_shop)
$assos[$id_shop] = $id_shop;
break;
default :
foreach (Shop::getShops(false, null, true) as $id_shop)
$assos[$id_shop] = $id_shop;
break;
}
}
$tpl = $this->createTemplate('helpers/assoshop.tpl');
$tpl->assign(array(
'input' => array(
'type' => $type,
'values' => Shop::getTree(),
),
'fields_value' => array(
'shop' => $assos
),
'form_id' => $this->id,
'table' => $this->table
));
return $tpl->fetch();
}
/**
* Render a form with potentials required fields
*