Merge branch 'ticket-11201-updateAntCreationCategory' into develop
This commit is contained in:
commit
ecddce3f6e
@ -103,6 +103,9 @@ class AdminAntCreationcategories extends AdminTab
|
||||
$groups[] = $row['id_group'];
|
||||
}
|
||||
$id_parent = (int) Tools::getValue('id_parent');
|
||||
if(Tools::getValue('category_child')) {
|
||||
$id_parent = (int) Tools::getValue('category_child');
|
||||
}
|
||||
$date = date('Y') . '-' . date('m');
|
||||
if(Tools::getValue('subcategories2')) {
|
||||
$subcategories = Tools::getValue('subcategories2');
|
||||
@ -207,7 +210,7 @@ class AdminAntCreationcategories extends AdminTab
|
||||
),
|
||||
array(
|
||||
'type' => 'uploadImage',
|
||||
'label' => $this->l('Image Latéral : '),
|
||||
'label' => $this->l('Image Latérale : '),
|
||||
'label-class' => 'col-md-2',
|
||||
'input-class' => 'col-md-6',
|
||||
'name' => 'image_category',
|
||||
@ -354,6 +357,25 @@ class AdminAntCreationcategories extends AdminTab
|
||||
defaultText:\'Nom\'
|
||||
});
|
||||
|
||||
$(\'#id_parent\').trigger("change");
|
||||
$(\'#id_parent\').change(function(){
|
||||
var id_parent = $(\'#id_parent\').val();
|
||||
$.ajax({
|
||||
url : \'/modules/ant_creationcategories/ajax.php\',
|
||||
type : \'POST\',
|
||||
data : \'id_parent=\'+id_parent,
|
||||
dataType : \'json\',
|
||||
success : function(json, statut){
|
||||
if (json.errors == false) {
|
||||
if($(\'#id_parent\').parent().children(".cat-children").length > 0) {
|
||||
$(\'#id_parent\').parent().children(".cat-children").remove();
|
||||
}
|
||||
$(\'#id_parent\').parent().append(json.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$(\'#form1 .js-switch\').change(function(){
|
||||
if($(this).is(\':checked\')) {
|
||||
var nb_elements = $(\'#form1 div.tagsinput span.tag\').length;
|
||||
|
27
modules/ant_creationcategories/ajax.php
Normal file
27
modules/ant_creationcategories/ajax.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include_once('../../config/config.inc.php');
|
||||
|
||||
$data = array();
|
||||
$data['errors'] = false;
|
||||
$id_parent = Tools::getValue('id_parent', 0);
|
||||
$id_lang = 2;
|
||||
if($id_parent) {
|
||||
$children = Category::getChildren((int) $id_parent, $id_lang, true);
|
||||
if ($children) {
|
||||
$select='<div class="cat-children" style="margin-bottom:10px;margin-top:10px;">
|
||||
<select class="form-control select-children" name="category_child">
|
||||
<option value="0">-- Choisir -- </option>';
|
||||
foreach ($children as $key => $child) {
|
||||
$select.='<option value="'.$child['id_category'].'">'.$child['name'].'</option>';
|
||||
}
|
||||
$select.= '</select>
|
||||
</div>';
|
||||
} else {
|
||||
$data['errors'] = true;
|
||||
}
|
||||
} else {
|
||||
$data['errors'] = true;
|
||||
}
|
||||
|
||||
$data['data'] = $select;
|
||||
die(json_encode($data));
|
Loading…
Reference in New Issue
Block a user