<?
    global $vis_language;
    $paging_list='';
    for($i=0;$i<$view_info['page_count'];$i++) $paging_list.='<option value="'.$i.'" '.(($comments_info['page']==$i)?'selected="selected"':'').'>'.($i+1).'</option>';
?>
<link href="<?= VIS_PATH_SCRIPT; ?>nestable/nestable.css" rel="stylesheet">
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
	<div class="col-sm-4">
	  <h3 class="m-b-xs text-black"><? echo $operation['view_title']; ?></h3>
	  <div>
		 <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
			<li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
			<li><a class="link" href="#/selfhelp/view_selfhelp/<? echo $vis_language['TXTSELFHELP']; ?>"><? echo $vis_language['TXTSELFHELP']; ?></a></li>
			<li class="active"><? echo $operation['view_title']; ?></li>
		 </ul>
	  </div>
	</div>
	<div class="col-sm-8 m-t-md pull-right">
	 <div class="btn-group pull-right">
			<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="vh vh-action text-muted"></i> <b class="caret"></b></button>
     <ul class="dropdown-menu dropdown-menu-right text-left">
         <li><a class="link" href="#/selfhelp/view_categories/<? echo $vis_language['TXTCATEGORIES'];?>/<?= $select_domain_id[0];?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTCATEGORIES'].'/'.$domain; ?>', {'vis_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_operation':'<?php echo $operation['vis_operation3']; ?>','vis_domain_id':'<? echo $domains[0]['domain_id'];?>'})"><? echo $vis_language['TXTCATEGORIES']; ?></a></li>
			<li><a class="link" href="#/selfhelp/view_articles/<? echo $vis_language['TXTARTICLES']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTARTICLES']; ?>', {'vis_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_operation':'<?php echo $operation['vis_operation2']; ?>'});"><? echo $vis_language['TXTARTICLES']; ?></a></li>
			<li><a class="link" href="#/selfhelp/view_comments/<? echo $vis_language['TXTCOMMENTS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTCOMMENTS']; ?>', {'vis_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_operation':'<?php echo $operation['vis_operation4']; ?>'})"><? echo $vis_language['TXTCOMMENTS']; ?></a></li>
         </ul>
   </div>
   
   <div class="btn-group pull-right m-l">&nbsp;
         <a class="btn btn-rounded btn-primary btn-sm dropdown-toggle" href="#/selfhelp/new_article/<? echo $vis_language['TXTADDARTICLE'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTADDARTICLE'];?>', {'vis_module':'selfhelp', 'vis_operation':'new_article', 'cache':'true','vis_article':1})"><i style="font-size:10px;" class="vh vh-plus"></i>  <? echo $vis_language['TXTADDARTICLE']; ?></a>
      </div> 
   
		<div class="col-sm-6 input-group b-a b-2x rounded pull-right">
			<input class="form-control rounded input-sm no-border" type="text" placeholder="<?php echo $vis_language['MSGSERART'];?>" value="<?php echo (isset($operation['criteria']))?$operation['criteria']:'';?>" id="search_language_variables">
			<span class="input-group-btn rounded b-l b-3x">
			<button class="btn btn-sm btn-rounded bg-white b-white btn-icon" type="button" onclick="display_articles();">
			<i class="vh vh-search"></i>
			</button>
			</span>
		</div>
	</div>
</section>
<div class="col-lg-12">
   <form name="vis_<?php echo $operation['vis_operation']; ?>_form" id="vis_<?php echo $operation['vis_operation']; ?>_form" class="form-horizontal">
      <section class="panel panel-default">
	    <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['TXTDOMAIN']; ?></label>
               <div class="col-sm-8">
                  <select name="vis_domain" id="vis_domain" class="form-control input-sm selectpicker"  <? if(count($domains)>10) echo 'data-live-search="true"';?> onchange="$('#vis_workpanel_div').visExecution('load_module', '<?php echo $vis_language['TXTCATEGORIES']; ?>/'+$(this).val(), {'vis_module':'selfhelp', 'vis_operation':'<?php echo $operation['vis_current_operation']; ?>','vis_domain_id':$(this).val()});">
                      <? for($i=0;$i<count($domains);$i++) echo '<option value="'.$domains[$i]['domain_id'].'" '.(($domain==$domains[$i]['domain_id'])?'selected="selected"':'').'>'.$domains[$i]['domain_name'].'</option>'; ?>
                  </select>
               </div>
            </div>
		</div>
         <section class="scrollable wrapper" id="test">
              <div class="row m-b">
                <div class="col-sm-12">
                <div class="row">
                <div class="col-md-1 col-sm-4"><label ><? echo $vis_language['TXTVISIBLETO']; ?></label></div>
                <div class="col-md-1 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-1 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-2 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><a class="m-r-sm text-muted" href="#/selfhelp/add_new_category/<? echo $vis_language['TXTADDCATEGORY']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTADDCATEGORY']; ?>', {'vis_module':'selfhelp', 'vis_operation':'add_new_category', 'cache':'true', 'vis_parent_id':0, 'vis_domain_id':<? echo $domain; ?>})" title="<? echo $vis_language['TXTADDCATEGORY']; ?>" ><i class="vh vh-folder-add v-middle"  style="font-size:18px;"></i></a></div></div>
					  <ol class="dd-list">
  					  <?	if(isset($selfhelp) && $selfhelp!=NULL) {
					  vis_show_subcategories($selfhelp, $quick_insert, $domain,$attachmentids); ?>

					 <? } ?>
					 </ol>
					    </li>
                  </ol>
                  </div>
                </div>
              </div>
            </section>
      </section>
   </form>
</div>
<?
    function vis_show_subcategories($details, $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 id="test" ><label class="">'; ?>
					 <a class="m-r-sm" href="#/selfhelp/view_category/<? echo rawurlencode(str_replace('/', ' ', $details[$i]['selfhelp_title'])).'/'.$details[$i]['selfhelp_id'];?>"  onclick="$('vis_workpanel_div').visExecution('load_module', '<? echo addslashes(substr($details[$i]['selfhelp_title'],0,15)).'/'.$details[$i]['selfhelp_id']; ?>', {'vis_module':'selfhelp', 'vis_operation':'view_category', 'vis_category_id':'<? echo $details[$i]['selfhelp_id']; ?>','vis_domain_id':<? echo $domain; ?>})" title="<? echo $vis_language['TXTADDCATEGORY']; ?>" ><?php echo ($details[$i]['parent_id']==0)?$stylecode:'';?><? echo $details[$i]['selfhelp_title'];?></a>
					</label><? if($details[$i]['solution_id']==0){?><label class=""  id="selfhelp_id_<?= $details[$i]['selfhelp_id'];?>"><a class="m-r-sm text-muted" href="#/selfhelp/add_new_category/<? echo $vis_language['TXTADDCATEGORY']; ?>/<? echo $details[$i]['selfhelp_id']; ?>" onclick="$('vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTADDCATEGORY'].'/'.$details[$i]['selfhelp_id']; ?>', {'vis_module':'selfhelp', 'vis_operation':'add_new_category', 'cache':'true', 'vis_parent_id':<? echo $details[$i]['selfhelp_id']; ?>, 'vis_domain_id':<? echo $domain; ?>})" title="<? echo $vis_language['TXTADDCATEGORY']; ?>" ><i class="vh vh-folder-add v-middle"  style="font-size:18px;"></i></a></label><? } if($details[$i]['solution_id']!=1){ ?><label class="" id="selfhelp_id1_<?= $details[$i]['selfhelp_id'];?>"><a class="m-r-sm text-muted" href="#/selfhelp/new_article/<? echo $vis_language['TXTADDARTICLE'];?>/<? echo $details[$i]['selfhelp_id']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTADDARTICLE'].'/'.$details[$i]['selfhelp_id']; ?>', {'vis_module':'selfhelp', 'vis_operation':'new_article', 'cache':'true', 'vis_category_id':<? echo $details[$i]['selfhelp_id']; ?>, 'vis_domain_id':<? echo $domain; ?>})" title="<? echo $vis_language['TXTADDARTICLE']; ?>" ><i class="vh vh-article-add v-middle"  style="font-size:17px;"></i></a></label><? }?>
					</label><? if($details[$i]['solution_id']==0){	echo '<a class="link" data-toggle="ajaxModal" data-modal-arguments="vis_module=selfhelp&vis_operation=clone_category&vis_cat_id='.$details[$i]['selfhelp_id'].'&vis_domain_id='.$domain.'" title="'.$vis_language['TXTCLONE'].'" href="javascript:void(0);" >'.$vis_language['TXTCLONE'].'</a>'; }
					 ?></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'], $links, $domain); ?></ol></li>
			<?
				}
		}
    }
?>
<script src="<?= VIS_PATH_SCRIPT; ?>nestable/jquery.nestable.js"></script>
<script>
  $(".selectpicker").selectpicker();
   $('#nestable1').nestable();
    $('#search_language_variables').keyup(function(e){
    if(e.keyCode == 13)
    {
        var search_string = $("#search_language_variables").val();
        if(search_string.length < 3)
						$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['TXTGLOBALSEARCHERROR'];?>");
		else
        $.post("index.php?vis_module=selfhelp&vis_operation=view_articles&vis_tmpst="+new Date().getTime(), { 'vis_action':'no_load','criteria': search_string }, function(data) {
            $("#search_language_variables").parent().addClass('open');
            $('#vis_workpanel_div').show().html(data);
        });
    }
	});
    function display_articles()
    {
		var article = $('#search_language_variables').val();
		if(article.length < 3)
			$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['TXTGLOBALSEARCHERROR'];?>");
		else if(article!="")
		$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTARTICLES']; ?>', {'vis_module':'selfhelp', 'vis_operation':'view_articles', 'vis_action':'no_load','criteria':article});
		else
		$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['MSGSERARTBOX'];?>");
	}
	/* function show_icon(pinId)
    {
    	$('#selfhelp_id_'+pinId).show();
    	$('#selfhelp_id1_'+pinId).show();
    }
    function hide_icon(pinId)
    {
    	$('#selfhelp_id_'+pinId).hide();
    	$('#selfhelp_id1_'+pinId).hide();
    }*/

</script>
<style>
.dd-handle{
padding:2px;
}
.dd-item > button {
    font-size: 15px !important;
	margin:-4px 0;
}
</style>
