fix sub families

This commit is contained in:
Marion Muszynski 2016-12-21 14:31:41 +01:00
parent 408a58409c
commit 469a0497ae
2 changed files with 8 additions and 6 deletions

View File

@ -74,8 +74,8 @@ class AdminAntCreationcategories extends AdminTab
$subcategory->add();
if(isset($families) && isset($families[$key]) && (int)$families[$key] != 0) {
if(isset($subfamilies) && isset($subfamilies[(int)$families[$key]]) && (int)$subfamilies[(int)$families[$key]] != 0) {
CategoryFamilyCore::addAssociations2($subcategory->id, $subfamilies[(int)$families[$key]]);
if(isset($subfamilies) && isset($subfamilies[$key]) && (int)$subfamilies[$key] != 0) {
CategoryFamilyCore::addAssociations2($subcategory->id, $subfamilies[$key]);
} else {
CategoryFamilyCore::addAssociations2($subcategory->id, $families[$key]);
}
@ -90,6 +90,7 @@ class AdminAntCreationcategories extends AdminTab
} elseif(Tools::isSubmit('submitAddSubCategories')) {
if(Tools::getValue('id_parent')) {
$id_parent = (int) Tools::getValue('id_parent');
$date = date('Y') . '-' . date('m');
if(Tools::getValue('subcategories2')) {
$subcategories = Tools::getValue('subcategories2');
$subcategories = explode(',',$subcategories);
@ -120,8 +121,8 @@ class AdminAntCreationcategories extends AdminTab
$subcategory->add();
if(isset($families) && isset($families[$key]) && (int)$families[$key] != 0) {
if(isset($subfamilies) && isset($subfamilies[(int)$families[$key]]) && (int)$subfamilies[(int)$families[$key]] != 0) {
CategoryFamilyCore::addAssociations2($subcategory->id, $subfamilies[(int)$families[$key]]);
if(isset($subfamilies) && isset($subfamilies[$key]) && (int)$subfamilies[$key] != 0) {
CategoryFamilyCore::addAssociations2($subcategory->id, $subfamilies[$key]);
} else {
CategoryFamilyCore::addAssociations2($subcategory->id, $families[$key]);
}
@ -156,6 +157,7 @@ class AdminAntCreationcategories extends AdminTab
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = c.`id_category`)
WHERE cl.`id_lang` = '.$cookie->id_lang.'
AND c.active = 1
AND c.id_parent = 1
ORDER BY c.`id_category` DESC
') as $row) {
$id_categories[] = array(

View File

@ -15,7 +15,7 @@ $childrens = CategoryFamilyCore::getAll($id_lang, $id_parent);
if ($childrens) {
$select='<div class="sub-cat" style="margin-bottom:10px;margin-top:10px;">
<select class="form-control select-families" name="subfamilies['.$id_parent.']" data-id-family="'.$select_upd.'">
<select class="form-control select-families" name="subfamilies[]" data-id-family="'.$select_upd.'">
<option value="0">-- Choisir -- </option>';
foreach ($childrens as $key => $children) {
$select.='<option value="'.$children['id_category_family'].'">'.$children['name'].'</option>';
@ -23,7 +23,7 @@ if ($childrens) {
$select.= '</select>
</div>';
} else {
$select = '';
$select = '<input type="hidden" name="subfamilies[]" value="0" />';
}
$data['data'] = $select;