Merge branch 'add-module-ant_creationcategories' into develop

This commit is contained in:
Marion Muszynski 2016-12-19 18:32:21 +01:00
commit e1e3a57040
2 changed files with 22 additions and 14 deletions

View File

@ -47,9 +47,11 @@ class AdminAntCreationcategories extends AdminTab
if(Tools::getValue('subcategories')) {
$subcategories = Tools::getValue('subcategories');
$subcategories = explode(',',$subcategories);
if(Tools::getValue('subfamilies') && Tools::getValue('families')) {
if(Tools::getValue('families')) {
$families = Tools::getValue('families');
$subfamilies = Tools::getValue('subfamilies');
if(Tools::getValue('subfamilies')) {
$subfamilies = Tools::getValue('subfamilies');
}
}
foreach ($subcategories as $key => $name) {
$meta_name = 'Vente privée '.$name;
@ -71,11 +73,14 @@ class AdminAntCreationcategories extends AdminTab
$subcategory->groupBox = $groups;
$subcategory->add();
if(isset($subfamilies) && isset($subfamilies[$key])){
CategoryFamilyCore::addAssociations2($subcategory->id, $subfamilies[$key]);
} elseif (isset($families) && isset($families[$key])){
CategoryFamilyCore::addAssociations2($subcategory->id, $families[$key]);
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]]);
} else {
CategoryFamilyCore::addAssociations2($subcategory->id, $families[$key]);
}
}
}
}
}
@ -88,9 +93,11 @@ class AdminAntCreationcategories extends AdminTab
if(Tools::getValue('subcategories2')) {
$subcategories = Tools::getValue('subcategories2');
$subcategories = explode(',',$subcategories);
if(Tools::getValue('subfamilies') && Tools::getValue('families')) {
if(Tools::getValue('families')) {
$families = Tools::getValue('families');
$subfamilies = Tools::getValue('subfamilies');
if(Tools::getValue('subfamilies')) {
$subfamilies = Tools::getValue('subfamilies');
}
}
foreach ($subcategories as $key => $name) {
$meta_name = 'Vente privée '.$name;
@ -112,10 +119,12 @@ class AdminAntCreationcategories extends AdminTab
$subcategory->groupBox = $groups;
$subcategory->add();
if(isset($subfamilies) && isset($subfamilies[$key])){
CategoryFamilyCore::addAssociations2($subcategory->id, $subfamilies[$key]);
} elseif (isset($families) && isset($families[$key])){
CategoryFamilyCore::addAssociations2($subcategory->id, $families[$key]);
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]]);
} else {
CategoryFamilyCore::addAssociations2($subcategory->id, $families[$key]);
}
}
}
Category::regenerateEntireNtree();
@ -289,7 +298,6 @@ class AdminAntCreationcategories extends AdminTab
dataType : \'json\',
success : function(json, statut){
if (json.errors == false) {
console.log(obj.next(".sub-cat").length);
if(obj.next(".sub-cat").length == 1) {
obj.next(".sub-cat").remove();
}

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[]" data-id-family="'.$select_upd.'">
<select class="form-control select-families" name="subfamilies['.$id_parent.']" 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>';