<? global $vis_language; //echo "<pre>"; print_r($operation); echo "</pre>";
?>
<link href="<?= VIS_PATH_SCRIPT; ?>nestable/nestable.css" rel="stylesheet">
<div class="modal-dialog modal-lg">
    <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 class="row">
                <div class="col-md-2 col-sm-4"><label ><? echo $vis_language['TXTVISIBLETO']; ?></label></div>
                <div class="col-md-2 col-sm-4"><i class="vh vh-square vh-green"></i>&nbsp;<span class="text-muted"><? echo $vis_language['TXTEVERYBODY']; ?></span></div>
                <div class="col-md-2 col-sm-4"><i class="vh vh-square vh-red"></i>&nbsp;<span class="text-muted"><? echo $vis_language['TXTSTAFFONLY']; ?></span></div>
                <div class="col-md-3 col-sm-4"><i class="vh vh-square vh-yellow"></i>&nbsp;<span class="text-muted"><? echo $vis_language['TXTLOGGEDINCLIENT']; ?></span></div>
                 </div>           
                  <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></div></div>
					  <ol class="dd-list">
  					  <?	if(isset($selfhelp) && $selfhelp!=NULL) { 
					  vis_show_subcategories($selfhelp,$categories, $quick_insert, $domain,$attachmentids); ?>
                      
					 <? } ?>
					 </ol>
					    </li>
                  </ol>
                  </div>
                </div>
                
                
              </div>
              
            </section>
                    <?
    function vis_show_subcategories($details,$categories, $links, $domain, $attachmentids='') {
        global $vis_language; 
         $vis_type = array(0=>$vis_language['TXTKNOWLEDGEBASE'],1=>$vis_language['TXTSUGGESTION'],2=>$vis_language['TXTQUESTIONANDANSWER']);
			$vis_display = array(0=>$vis_language['TXTEVERYBODY'],1 => $vis_language['TXTLOGGEDINCLIENT'], 2 => $vis_language['TXTSTAFFONLY']);
        for($i=0;$i<count($details);$i++) { $a =  "'".$details[$i]['content_type']."'";
            if(isset($details[$i]['subcat']) && $details[$i]['subcat']!=NULL) {$class='vis-icon vis-icon-arrow-open';} else { $class='vis-icon-med vis-icon-category'; } ?>
			<li data-id="<? echo $details[$i]['selfhelp_id']+1; ?>" class="dd-item" >
					<?php if($links==-1) {
						if($details[$i]['display_status']==0){$stylecode='<i class="vh vh-square vh-green" title="'.$vis_display[$details[$i]['display_status']].'"></i> ';
							}else if($details[$i]['display_status']==1){$stylecode='<i class="vh vh-square vh-yellow" title="'.$vis_display[$details[$i]['display_status']].'"></i> ';
							}else if($details[$i]['display_status']==2){$stylecode='<i class="vh vh-square vh-red" title="'.$vis_display[$details[$i]['display_status']].'"></i> ';}
							
					 echo '<div class="dd-handle" style="border:none"><div class="dd-nodrag"><label><label class="">' ?>
					<? if($details[$i]['solution_id']!=1){ ?> <a class="m-r-sm" href="javascript:void(0);" id="selfhelp_id_<?= $details[$i]['selfhelp_id'];?>" onclick="select_parent('<?= $details[$i]['selfhelp_id'];?>','<? echo rawurlencode(str_replace('%22','"',trim($details[$i]['selfhelp_title'])));?>','<? echo $details[$i]['language_name'];?>','<? echo $details[$i]['display_status'];?>')"><?php echo ($details[$i]['parent_id']==0)?$stylecode:'';?><? echo $details[$i]['selfhelp_title'];?></a>
       <? }else{?>
     <a class="m-r-sm" href="javascript:void(0);" id="selfhelp_id_<?= $details[$i]['selfhelp_id'];?>" ><?php echo ($details[$i]['parent_id']==0)?$stylecode:'';?><? echo $details[$i]['selfhelp_title'];?></a>
     <? } ?>
					</label></div>
					 </div> 
					<?  } else { echo '<div class="dd-handle" style="border:none">' . $details[$i]['selfhelp_title'] . '</div>'; } 
				if(isset($details[$i]['subcat']) && $details[$i]['subcat']!=NULL) { ?>
			<ol class="dd-list" style=""> <?
				vis_show_subcategories($details[$i]['subcat'],$categories, $links, $domain); ?></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 ,lang_name ,visible_to)
   {
	   if(parent_id=='<?php echo $operation['vis_category_id']; ?>')
	   {
			parent_id="";	
			//alert(parent_id);
	   }
	   else
	   {
		   if(visible_to==2) $('#vis_permissions').hide(); else $('#vis_permissions').show();
		   document.getElementById("vis_parent").value =parent_id;
		   document.getElementById("vis_parent_category").innerHTML =parent_title.replace(/%22/g,'"'); 
	   }
		   $(".modal").modal("toggle");
	  
   }
</script>
<style>
.dd-handle{
padding:2px;
}
.dd-item > button {
    font-size: 15px !important;
	margin:-4px 0;
}
</style>
