[*] BO : #PSFV-94 - added AdminCurrencuesController

This commit is contained in:
tDidierjean
2011-10-19 09:29:49 +00:00
parent 909ec97e96
commit fc417ea952
8 changed files with 553 additions and 377 deletions
+103
View File
@@ -267,5 +267,108 @@ class HelperCore
echo $output;
}
protected function displayAssoShop($type = 'shop')
{
if (!Shop::isMultiShopActivated() || (!$this->id && $this->context->shop->getContextType() != Shop::CONTEXT_ALL))
return;
if ($type != 'shop' && $type != 'group_shop')
$type = 'shop';
$assos = array();
$sql = 'SELECT id_'.$type.', `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$type.'`';
foreach (Db::getInstance()->executeS($sql) as $row)
$assos[$row['id_'.$type]][] = $row[$this->identifier];
$html = <<<EOF
<script type="text/javascript">
$().ready(function()
{
// Click on "all shop"
$('.input_all_shop').click(function()
{
var checked = $(this).attr('checked');
$('.input_group_shop').attr('checked', checked);
$('.input_shop').attr('checked', checked);
});
// Click on a group shop
$('.input_group_shop').click(function()
{
$('.input_shop[value='+$(this).val()+']').attr('checked', $(this).attr('checked'));
check_all_shop();
});
// Click on a shop
$('.input_shop').click(function()
{
check_group_shop_status($(this).val());
check_all_shop();
});
// Initialize checkbox
$('.input_shop').each(function(k, v)
{
check_group_shop_status($(v).val());
check_all_shop();
});
});
function check_group_shop_status(id_group)
{
var groupChecked = true;
$('.input_shop[value='+id_group+']').each(function(k, v)
{
if (!$(v).attr('checked'))
groupChecked = false;
});
$('.input_group_shop[value='+id_group+']').attr('checked', groupChecked);
}
function check_all_shop()
{
var allChecked = true;
$('.input_group_shop').each(function(k, v)
{
if (!$(v).attr('checked'))
allChecked = false;
});
$('.input_all_shop').attr('checked', allChecked);
}
</script>
EOF;
$html .= '<div class="assoShop">';
$html .= '<table class="table" cellpadding="0" cellspacing="0" width="100%">
<tr><th>'.$this->l('Shop').'</th></tr>';
$html .= '<tr'.(($type == 'group_shop') ? ' class="alt_row"' : '').'><td><label class="t"><input class="input_all_shop" type="checkbox" /> '.$this->l('All shops').'</label></td></tr>';
foreach (Shop::getTree() as $groupID => $groupData)
{
$groupChecked = ($type == 'group_shop' && ((isset($assos[$groupID]) && in_array($this->id, $assos[$groupID])) || !$this->id));
$html .= '<tr'.(($type == 'shop') ? ' class="alt_row"' : '').'>';
$html .= '<td><img style="vertical-align: middle;" alt="" src="../img/admin/lv2_b.gif" /><label class="t"><input class="input_group_shop" type="checkbox" name="checkBoxGroupShopAsso_'.$this->table.'_'.$this->id.'_'.$groupID.'" value="'.$groupID.'" '.($groupChecked ? 'checked="checked"' : '').' /> '.$groupData['name'].'</label></td>';
$html .= '</tr>';
if ($type == 'shop')
{
$total = count($groupData['shops']);
$j = 0;
foreach ($groupData['shops'] as $shopID => $shopData)
{
$checked = ((isset($assos[$shopID]) && in_array($this->id, $assos[$shopID])) || !$this->id);
$html .= '<tr>';
$html .= '<td><img style="vertical-align: middle;" alt="" src="../img/admin/lv3_'.(($j < $total - 1) ? 'b' : 'f').'.png" /><label class="child">';
$html .= '<input class="input_shop" type="checkbox" value="'.$groupID.'" name="checkBoxShopAsso_'.$this->table.'_'.$this->id.'_'.$shopID.'" id="checkedBox_'.$shopID.'" '.($checked ? 'checked="checked"' : '').' /> ';
$html .= $shopData['name'].'</label></td>';
$html .= '</tr>';
$j++;
}
}
}
$html .= '</table></div>';
return $html;
}
}