<?
    global $vis_language;
  
    $paging_list='';
    for($i=0;$i<$view_info['page_count'];$i++) $paging_list.='<option value="'.$i.'" '.(($articles_info['page']==$i)?'selected="selected"':'').'>'.($i+1).'</option>'; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
	<div class="col-sm-4" id="url_header">
	  <h3 class="m-b-xs text-black"><? echo $operation['view_title']; ?><span id="total_cnt"> (<? echo $articles_info['total']; ?>)</span></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">
			<a href="javascript:void(0);" title="<?= $vis_language['TXTFILTERLIST']; ?>" class="btn btn-default btn-sm dropdown-toggle" onclick="$('#vis_filter_list').slideToggle();"><i style="font-size:10px;" class="vh vh-filter"></i></a>
     </div>
  <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'];?>" <?if(strpos($criteria,"'")!==false){?>value="<?php echo (isset($criteria))?$criteria:'';?>" <?}else {?> value='<?php echo (isset($criteria))?$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="submit" onclick="display_articles();">
			<i class="vh vh-search"></i>
			</button>
			</span>
		</div>
	</div>
</section>
<div class="col-lg-12">
  <? include_once(VIS_PATH_TEMPLATE.'article_search.php');?>
</div>
  <? if($view_info['page_count']>0)
  {
   ?>
<div class="col-lg-12">
   <form name="vis_<?php echo $operation['vis_operation']; ?>_form" id="vis_<?php echo $operation['vis_operation']; ?>_form">
   <input type="hidden" name="vis_current_operation" value="<?php echo $operation['vis_current_operation']; ?>" />
    <input type="hidden" value="" name="vis_filter_enable" id="vis_filter_enable">
      <section class="panel panel-default">
         <div class="row wrapper clr">
            <div class="col-sm-9 tkt_left_menu">
               <div class="vis_mass_action">
                  <div class="btn-group">
                     <button class="btn bg-empty btn-sm dropdown-toggle action_btn" data-toggle="dropdown">
                     <i class="vh vh-action"></i> <span class="caret"></span>
                     </button>
                     <ul class="dropdown-menu">
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'home', 'vis_operation':'change_setting_status', 'vis_form':'vis_<?php echo $operation['vis_operation']; ?>_form', 'vis_switch':'article','vis_current_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_current_operation':'<?php echo $operation['vis_operation2']; ?>','vis_is_enable':'1'})"><? echo $vis_language['TXTENABLE']; ?></a></li>
                        <li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'home', 'vis_operation':'change_setting_status', 'vis_form':'vis_<?php echo $operation['vis_operation']; ?>_form', 'vis_switch':'article','vis_current_module':'<?php echo $operation['vis_current_module']; ?>','vis_current_operation':'<?php echo $operation['vis_operation2']; ?>', 'vis_is_enable':'0'})"><? echo $vis_language['TXTDISABLE']; ?></a></li>
						<li><a class="m-r-sm v-middle" href="javascript:void(0);" id="del_articles" onclick="delete_articles();" title="<? echo $vis_language['TXTDELETE']; ?>"><? echo $vis_language['TXTDELETE']; ?></a></li>
                     </ul>
                  </div>
               </div>
            </div>
			<div  class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
				<? if(isset($operation['vis_form']) && $operation['vis_form']=='vis_view_selfhelp_form'){?>
				 <select name="pageing" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_workpanel_div').visExecution('load_area',{'vis_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_operation':'<?php echo $operation['vis_current_operation']; ?>', 'vis_page':this.value,'vis_form':'<?echo $operation['vis_form'];?>'})">
					<? echo $paging_list;?>
				  </select>
				  <? } else {?>
					   <select name="pageing" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_workpanel_div').visExecution('load_area',{'vis_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_operation':'<?php echo $operation['vis_current_operation']; ?>', 'vis_page':this.value,'vis_form':'<?echo $operation['vis_form'];?>'})">
					<? echo $paging_list;?>
				  </select><? } ?>
				  <div class="text-muted pull-right label_page"><? echo $vis_language['TXTPAGE']; ?>:</div>
			</div>
         </div>
         <div class="table-responsive scroll-x" id="vis_article_list">
			<? include_once(VIS_PATH_TEMPLATE.'article_list.php'); ?>
		</div>
         <footer class="wrapper panel-footer bg-white">
            <div class="row">
               <div class="col-sm-9 tkt_left_menu">
                  <div class="vis_mass_action_footer">
                     <div class="btn-group">
                        <button type="button" class="btn bg-empty btn-sm dropdown-toggle action_btn" data-toggle="dropdown">
                        <i class="vh vh-action"></i>
                        <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
							<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'home', 'vis_operation':'change_setting_status', 'vis_form':'vis_<?php echo $operation['vis_operation']; ?>_form', 'vis_switch':'article','vis_current_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_current_operation':'<?php echo $operation['vis_operation2']; ?>','vis_is_enable':'1'})"><? echo $vis_language['TXTENABLE']; ?></a></li>
							<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'home', 'vis_operation':'change_setting_status', 'vis_form':'vis_<?php echo $operation['vis_operation']; ?>_form', 'vis_switch':'article','vis_current_module':'<?php echo $operation['vis_current_module']; ?>','vis_current_operation':'<?php echo $operation['vis_operation2']; ?>', 'vis_is_enable':'0'})"><? echo $vis_language['TXTDISABLE']; ?></a></li>
                            <li><a class="m-r-sm v-middle" href="javascript:void(0);" id="del_articles1" onclick="delete_articles();" title="<? echo $vis_language['TXTDELETE']; ?>"><? echo $vis_language['TXTDELETE']; ?></a></li>
                        </ul>
                     </div>
                  </div>
               </div>
			<div  class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
				 <? if(isset($operation['vis_form']) && $operation['vis_form']=='vis_view_selfhelp_form'){?>
				 <select name="pageing" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_workpanel_div').visExecution('load_area',{'vis_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_operation':'<?php echo $operation['vis_current_operation']; ?>', 'vis_page':this.value,'vis_form':'<?echo $operation['vis_form'];?>'})">
					<? echo $paging_list;?>
				  </select>
				  <? } else {?>
					   <select name="pageing" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_workpanel_div').visExecution('load_area',{'vis_module':'<?php echo $operation['vis_current_module']; ?>', 'vis_operation':'<?php echo $operation['vis_current_operation']; ?>', 'vis_page':this.value,'vis_form':'<?echo $operation['vis_form'];?>'})">
					<? echo $paging_list;?>
				  </select><? } ?>
				  <div class="text-muted pull-right label_page"><? echo $vis_language['TXTPAGE']; ?>:</div>
			</div>
            </div>
         </footer>
      </section>
   </form>
</div>
<script type="text/javascript">
	$(".selectpicker").selectpicker();
    $('#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 delete_articles()
   {
		var selected = [];
		var selected1 = [];
		var vis_action = "";
		$('#checkbox_data input:checked').each(function() {
		selected.push($(this).attr('name'));
		selected1.push($(this).attr('value'));
		vis_action +=$(this).attr('name')+"="+$(this).attr('value')+",";
		});
		if( selected.length > 0)
		 {
			 vis_action= vis_action.substring(0, vis_action.length-1);
			 $('#del_articles').attr('data-toggle','ajaxModal');
			 $('#del_articles').attr('data-modal-arguments','vis_module=selfhelp&vis_operation=get_mass_delete&vis_action='+vis_action+'&vis_delete=1&vis_static_area=vis_article_delete_area&vis_form=vis_<?php echo $operation['vis_operation']; ?>_form&vis_switch=Articles&vis_page=<? echo $articles_info['page']; ?>');
			 $('#del_articles1').attr('data-toggle','ajaxModal');
			 $('#del_articles1').attr('data-modal-arguments','vis_module=selfhelp&vis_operation=get_mass_delete&vis_action='+vis_action+'&vis_delete=1&vis_static_area=vis_article_delete_area&vis_form=vis_<?php echo $operation['vis_operation']; ?>_form&vis_switch=Articles&vis_page=<? echo $articles_info['page']; ?>');
		 }
		 else
		{
			$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['MSGARTNTSEL'];?>");
			return false;
		}
	}
</script>
<script src="<?= VIS_PATH_SCRIPT; ?>dropdown_dropup.js"></script>
<script>
function vis_apply_filter(vis_page){
	vis_page = (vis_page!=undefined && typeof(vis_page)!=undefined && vis_page != '') ? vis_page:'';
	var data = {'vis_filter_enable':'1', 'vis_page':vis_page, 'vis_action': $("#vis_filter_list input, #vis_filter_list select").serialize() };
    $.ajax({
		url: 'index.php?vis_module=selfhelp&vis_operation=view_articles',
		data: data,
		type: "POST",
		dataType: "json",
		success: function(data) {
			$(".tkt_right_menu").html(data.paging);
			$("#vis_article_list").html(data.list);
			$('#url_header').html('<h3 class="m-b-xs text-black"><? echo $vis_language['TXTFILTERRESULT']; ?><span id="total_cnt"> ('+data.total_cnt+')</span></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="#/setting/setting_menu/<? echo $vis_language['TXTSETTINGS'];?>"><? echo $vis_language['TXTSETTINGS'];?></a></li><li><a class="link" href="#/setting/view_articles/<? echo $vis_language['TXTARTICLE'];?>" onclick="location.reload();"><? echo $vis_language['TXTARTICLE'];?></a></li><li class="active"><? echo $vis_language['TXTFILTERRESULT']; ?></li></ul></div>').show();
			if(data.total_cnt==0){
				$("#vis_no_record_search").show();
				$("#vis_no_record_search").html(data.list);
			}else $("#vis_no_record_search").hide();
            toggle_mass_actions(); // To disable header & footer mass actions on list pages
		},
		error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
	});

}
</script>
<?
}
else
{
 include(VIS_PATH_TEMPLATE.'no_record_yet.php');
} ?>
