<? global $vis_language; ?>
<link href="<?= VIS_PATH_SCRIPT; ?>nestable/nestable.css" rel="stylesheet">

   <form name="vis_<?php echo $operation['vis_operation']; ?>_form" id="vis_<?php echo $operation['vis_operation']; ?>_form" class="form-horizontal">
		<section class="panel-default">
         <header class="panel-heading sub_header"><? echo $operation['view_title']; ?></header>
		</section>
	    <div class="panel-body">
               <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
               <div class="col-sm-8">
                  <select name="vis_department" id="vis_department" class="form-control input-sm selectpicker"  <? if(count($departments)>10) echo 'data-live-search="true"';?> onchange="$('#vis_workpanel_div').visExecution('load_module', '<? echo $operation['view_title']; ?>/'+$(this).val(), {'vis_module':'setting', 'vis_operation':'view_location', 'vis_department_id':$(this).val()});">
						<!--<option value="0"><? echo $vis_language['TXTALL']; ?></option>-->
                      <? for($i=0;$i<count($departments);$i++) echo '<option value="'.$departments[$i]['department_id'].'" '.(($department_id==$departments[$i]['department_id'])?'selected="selected"':'').'>'.$departments[$i]['domain_name'].' :: '.$departments[$i]['department_name'].'</option>'; ?>
                  </select>
               </div>
            </div>
		</div>
		<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 class="m-r-sm" title="<? echo $vis_language['TXTROOT']; ?>" ><? echo $vis_language['TXTROOT']; ?></a></label><a class="m-r-sm text-muted" href="#/setting/new_location/<? echo $vis_language['TXTADDLOCATION']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTADDLOCATION']; ?>',{'vis_module':'setting','vis_operation':'new_location'});" title="<? echo $vis_language['TXTADDLOCATION']; ?>" ><i class="vh vh-folder-add v-middle"  style="font-size:18px;"></i></a></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>
   </form>
<?php
function vis_show_subcategories($config_details,$call=NULL) {
        global $vis_language; 
        for($i=0;$i<count($config_details);$i++) { ?>
            <li data-id="<? echo $config_details[$i]['location_id']+1;?>" class="dd-item" >
            <?php    
             echo '<div class="dd-handle" style="border:none"><div class="dd-nodrag"><label id="test" ><label class="">' ?>
             <a href="#/setting/edit_location/<?php echo rawurlencode(str_replace('/', ' ',$config_details[$i]['name']));?>/<?= $config_details[$i]['location_id'];?>"><? echo ucfirst($config_details[$i]['name']);?></a> 
           </label>
           <label class=""  id="item_id_<?= $config_details[$i]['location_id'];?>"><a id="location_id_<?= $config_details[$i]['location_id'];?>" class="m-r-sm text-muted" href="#/setting/new_location/<? echo $vis_language['TXTADDLOCATION']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTADDLOCATION']; ?>',{'vis_module':'setting','vis_operation':'new_location','vis_parent_id':'<?= $config_details[$i]['location_id']; ?>'});" title="<? echo $vis_language['TXTADDLOCATION']; ?>" ><i class="vh vh-folder-add v-middle"  style="font-size:18px;"></i></a></label>
            </div> 
           </div>
				 <?php 
				if(isset($config_details[$i]['subcat']) && $config_details[$i]['subcat']!=NULL) { 
					 echo '<ol class="dd-list">';
					  vis_show_subcategories($config_details[$i]['subcat'],'sub_cat'); 
					 echo '</ol></li>';
				
				}
		}
		
    }
	?>
<script src="<?= VIS_PATH_SCRIPT; ?>nestable/jquery.nestable.js"></script>
<script type="text/javascript">
   $(".selectpicker").selectpicker();
   $('#nestable1').nestable(); 
   $(document).ready(function() {	
   $('[data-ride="datatables"]').dataTable({		
          "bPaginate" : false,	
   		"sDom": 't', "bAutoWidth": false,
   		"aoColumns": [
   			{ "bSortable": false },
   		  	null,
   		  	null,
   		  	null,
   			{ "bSortable": false }
   		]
   	});
   });
</script>
<style>
.dd-handle{
padding:2px;
}
.dd-item > button {
    font-size: 15px !important;
	margin:-4px 0;
}
</style>
