<? global $vis_language; ?>
<link href="<?= VIS_PATH_SCRIPT; ?>nestable/nestable.css" rel="stylesheet">
<div class="modal-dialog modal-md">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title"><? echo$vis_language['TXTCATEGORIES']; ?></h4>
        </div>
        <div class="modal-body" id="parent_list">
            <div class="row">
                <div class="col-sm-12">
					  <section class="scrollable wrapper" id="test">
              <div class="row m-b">
                <div class="col-sm-12">              
                  <div id="nestable1" class="dd">
                    <ol style="" class="dd-list">
                      <li data-id="1" class="dd-item">
					  <div class="dd-handle" style="border:none"><div class="dd-nodrag"><label class="m-r-sm"><a href="javascript:void(0);" class="m-r-sm" title="<? echo $vis_language['TXTROOT']; ?>"  onclick="select_parent('0','<? echo $vis_language['TXTROOT'];?>');"><? echo $vis_language['TXTROOT']; ?></a></label></div></div>
					  <ol class="dd-list">
  					   <? if(isset($config_details) && $config_details!=NULL && $config_details!=-1) { 
					 		  vis_show_subcategories($config_details); ?>
                       <? } ?>
					 </ol>
					    </li>
                  </ol>
                  </div>
                </div>
                
                
              </div>
              
            </section>
                    <?
    function vis_show_subcategories($details) {
        global $vis_language; 
        for($i=0;$i<count($details);$i++) { ?>
           <li data-id="<? echo $details[$i]['item_id']+1; ?>" class="dd-item" >
           <?php echo '<div class="dd-handle" style="border:none"><div class="dd-nodrag"><label><label class="">' ?>
             <a class="m-r-sm" href="javascript:void(0);" id="item_id_<?= $details[$i]['item_id'];?>" onclick="select_parent('<? echo $details[$i]['item_id'];?>','<? echo $details[$i]['name'];?>');"><? echo $details[$i]['name'];?></a> 
					</label>
                       </div>
					 </div> 
					
				<?php if(isset($details[$i]['subcat']) && $details[$i]['subcat']!=NULL) { 
               		   echo '<ol class="dd-list">';
						vis_show_subcategories($details[$i]['subcat'],'sub_cat'); 
					   echo '</ol></li>';
				
				}
				
		}
    }
?>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="<?= VIS_PATH_SCRIPT; ?>nestable/jquery.nestable.js"></script>
<script>
   $('#nestable1').nestable();
   function select_parent(parent_id ,parent_title)
   {
	   $("#vis_parent").val(parent_id);
	   document.getElementById("vis_parent_category").innerHTML =parent_title;
	   $(".modal").modal("toggle");
   }
</script>
<style>
.dd-handle{
padding:2px;
}
.dd-item > button {
    font-size: 15px !important;
	margin:-4px 0;
}
</style>
