<?php
    global $vis_language;
    $paging_list='';
    //for($i=0;$i<$view_info['page_count'];$i++) $paging_list.='<option value="'.$i.'" '.(($client_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-6">
		<h3 class="m-b-xs text-black"><? echo $operation['view_title']; ?><span id="total_cnt"> (<? echo ($client_details!=-1)?$client_info['total']:'0' ; ?>)</span></h3>
		<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>
			<? if(isset($operation['vis_filter_enable']) || $operation['vis_filter_enable']==1) { ?>
				<li><a class="link" href="#/client/view_clients/<? echo $vis_language['TXTCLIENTS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTCLIENTS']; ?>',{'vis_module':'client','vis_operation':'view_clients'});"><? echo $vis_language['TXTCLIENTS']; ?></a></li>
				<? if($operation['vis_check_pagination']!='1'){ ?>
				 <li class="active"><? echo $vis_language['TXTFILTERLIST']; ?></li>
				<? } ?>
				 <? } else if(isset($operation['vis_group_id']) || $operation['vis_group_id']!='') { ?>
				 <li><a class="link" href="#/client/view_clients/<? echo $vis_language['TXTCLIENTS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTCLIENTS']; ?>',{'vis_module':'client','vis_operation':'view_clients'});"><? echo $vis_language['TXTCLIENTS']; ?></a></li>
				 <li><a  class="link" href="#/client/view_client_group/<? echo $vis_language['TXTORGANIZATION']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTORGANIZATION'];?>',{'vis_module':'client', 'vis_operation':'view_client_group'});"><? echo $vis_language['TXTORGANIZATION']; ?></a> </li>
				 <li class="active"><?echo $operation['vis_group_name'];?></li>
				 <? } else {?>
				 <li class="active"><? echo $operation['view_title']; ?></li><? } ?>
		</ul>
	</div>
	<div class="col-sm-6 text-right text-left-xs m-t-lg">
		<!--<ul class="navSeprator m-n bred_rlink">
		</ul>-->
  
  <div class="btn-group pull-right">&nbsp;
			<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="#/client/view_client_group/<? echo $vis_language['TXTORGANIZATION']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTORGANIZATION']; ?>',{'vis_module':'client','vis_operation':'view_client_group'});"><? echo $vis_language['TXTORGANIZATION']; ?></a></li>
           <li><a class="link" href="#/client/import_clients/<? echo $vis_language['TXTIMPORT']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTIMPORT']; ?>',{'vis_module':'client','vis_operation':'import_clients'});"><? echo $vis_language['TXTIMPORT']; ?></a></li>
		   
		   <li>
			<input type="hidden" value="client" name="vis_module">
			<input type="hidden" value="view_clients" name="vis_operation">
			<input type="hidden" value="<? echo $operation['vis_filter_enable']?>" name="vis_filter_enable" id="vis_filter_enable">
		    <input type="hidden" value="true" name="vis_export">
			<input type="hidden" value="<? echo $operation['vis_action']?>" name="vis_action">
			<a href="javascript:void(0);" class="link" data-toggle="ajaxModal" data-modal-arguments="vis_module=report&vis_operation=add_report_inqueue&vis_static_area=vis_open_new_dialog&report_type=15" type="button"><? echo $vis_language['TXTEXPORT']; ?></a></li>
          </ul>
   </div>
   
   <div class="btn-group pull-right">&nbsp;
  <a title="<?= $vis_language['TXTFILTERLIST']; ?>" href="javascript:void(0);" 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">&nbsp;
		<a class="btn btn-rounded btn-primary btn-sm dropdown-toggle" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTADDCLIENT']; ?>',{'vis_module':'client','vis_operation':'new_client', 'cache':true, 'vis_client_id':0});"><i style="font-size:10px;" class="vh vh-plus"></i>  <? echo $vis_language['TXTADD']; ?></a>
  </div>
  
 

	</div>
</section>
<div class="col-lg-12">
   <? include_once(VIS_PATH_TEMPLATE.'client_search.php'); // filter list?>
</div>
   <? if($view_info['page_count']>0)
   {
   ?>

	<div class="col-lg-12" id="filter_client">
	<form name="vis_client_form" id="vis_client_form" method="POST">
		<section class="panel panel-default">
		<div class="row wrapper clr" id="view_action">
			  <div class="col-sm-9 tkt_left_menu">
				<div class="vis_mass_action pull-left">	
				<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': 'client', 'vis_operation': 'client_approval', 'vis_form': 'vis_client_form', 'vis_approve':1});"><? echo $vis_language['TXTAPPROVE']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'client_approval','vis_form':'vis_client_form','vis_approve':0});"><? echo $vis_language['TXTDISAPPROVE']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'ban_client', 'vis_form': 'vis_client_form', 'vis_remove_ban':0});"><? echo $vis_language['TXTBAN']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'ban_client', 'vis_form':'vis_client_form','vis_remove_ban':1});"><? echo $vis_language['TXTREMOVEBAN']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'toggle_spam', 'vis_form': 'vis_client_form', 'vis_spam':0});"><? echo $vis_language['TXTMARKSPAM']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'toggle_spam', 'vis_form':'vis_client_form','vis_spam':1});"><? echo $vis_language['TXTREMOVESPAM']; ?></a></li>
					</ul>
				</div>
				 <div class="btn-group" id="get_organization_up">
						<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_organization_up').visExecution('load_operations', {'vis_module': 'client', 'vis_operation': 'list_contents', 'vis_action': 'get_organization', 'vis_subaction': 'up'});"><span class="filter-option pull-left"><?= $vis_language['TXTORGANIZATION']; ?>&nbsp;</span><span class="caret"></span></button>
			        </div>
				</div>
			  </div>
			   <? if($operation['vis_operation']=='approved_client'){
				   $current_operation="approved_client";
			   } else if($operation['vis_operation']=='unapproved_client'){
				   $current_operation="unapproved_client";
			   } else if($operation['vis_operation']=='banned_client'){
					$current_operation="banned_client";
			   } else { $current_operation="view_clients"; } ?>
			  <div  class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
				 <div class="pull-right" id="pg_1">
						<div class="text-right">
	  <ul style="margin:0px 0px 0px 10px;" class="pagination pagination-sm m-t-xs pagination_cilent_list"><li class="first"><a href="javascript:void(0);"><i class="vh vh-angle-double-left"></i></a></li><li class="prev"><a href="javascript:void(0);"><i class="vh vh-angle-left"></i></a></li><li class="page active"><a href="javascript:void(0);">1</a></li><li class="next"><a href="javascript:void(0);"><i class="vh vh-angle-right"></i></a></li><li class="last"><a href="javascript:void(0);"><i class="vh vh-angle-double-right"></i></a></li></ul>
	</div>
				    </div>
				 </div>
			</div>
			<div class="table-responsive scroll-x" id="vis_client_list">
			<? include_once(VIS_PATH_TEMPLATE.'client_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': 'client', 'vis_operation': 'client_approval', 'vis_form': 'vis_client_form', 'vis_approve':1});"><? echo $vis_language['TXTAPPROVE']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'client_approval','vis_form':'vis_client_form','vis_approve':0});"><? echo $vis_language['TXTDISAPPROVE']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'ban_client', 'vis_form': 'vis_client_form', 'vis_remove_ban':0});"><? echo $vis_language['TXTBAN']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'ban_client', 'vis_form':'vis_client_form','vis_remove_ban':1});"><? echo $vis_language['TXTREMOVEBAN']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'toggle_spam', 'vis_form': 'vis_client_form', 'vis_spam':0});"><? echo $vis_language['TXTMARKSPAM']; ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form', {'vis_module': 'client', 'vis_operation':'toggle_spam', 'vis_form':'vis_client_form','vis_spam':1});"><? echo $vis_language['TXTREMOVESPAM']; ?></a></li>
					</ul>
				</div>
				 <div class="btn-group" id="get_organization_down">
						<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_organization_down').visExecution('load_operations', {'vis_module': 'client', 'vis_operation': 'list_contents', 'vis_action': 'get_organization', 'vis_subaction': 'down'});"><span class="filter-option pull-left"><?= $vis_language['TXTORGANIZATION']; ?>&nbsp;</span><span class="caret"></span></button>
			        </div>
	</div>

			  </div>
			  <div class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
				<div class="pull-right" id="pg_2">
					 <div class="text-right">
	  <ul style="margin:0px;" class="pagination pagination-sm m-t-xs pagination_cilent_list"><li class="first"><a href="javascript:void(0);"><i class="vh vh-angle-double-left"></i></a></li><li class="prev"><a href="javascript:void(0);"><i class="vh vh-angle-left"></i></a></li><li class="page active"><a href="javascript:void(0);">1</a></li><li class="next"><a href="javascript:void(0);"><i class="vh vh-angle-right"></i></a></li><li class="last"><a href="javascript:void(0);"><i class="vh vh-angle-double-right"></i></a></li></ul>
	</div>
				  </div>
				</div>
		  </div>
		</footer>
	  </section>

	</form>
	</div>
<section class="fullFrame m-n" id="vis_no_record_search" style="display:none;">
</section>
<? }
else
{
 include(VIS_PATH_TEMPLATE.'no_record_yet.php');
} ?>

<script>
	$(".selectpicker").selectpicker();
function vis_apply_filter(vis_page,vis_paginate){
	vis_page = (vis_page!=undefined && typeof(vis_page)!=undefined && vis_page != '') ? vis_page:'';
	var data = {'vis_filter_enable':'1', 'vis_page':vis_page, 'vis_check_pagination':vis_paginate, 'vis_action': $("#vis_filter_list input, #vis_filter_list select").serialize() };
	$.ajax({
		url: 'index.php?vis_module=client&vis_operation=view_clients',
		data: data,
		type: "POST",
		dataType: "json",
		success: function(data) {
			$("#vis_workpanel_div").html(data.list);
			$(".selectpicker").selectpicker();
            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(); 
		},
		error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
	});
}
function update_client_property(update_id) {
	$('#vis_global_msg_div').visExecution('submit_form', {'vis_module': 'client', 'vis_operation': 'update_properties', 'vis_form':'vis_client_form', 'vis_update_id': update_id });
}

$('.pagination_cilent_list').twbsPagination({
	totalPages:<?php echo $view_info['page_count']; ?>,
	visiblePages:3,startPage:<?php echo ($client_info['page']==0)?1:$client_info['page']+1; ?>,
first:'<i class="vh vh-angle-double-left"></i>',prev:'<i class="vh vh-angle-left"></i>',next:'<i class="vh vh-angle-right"></i>',last:'<i class="vh vh-angle-double-right"></i>',
	onPageClick: function (event, page) { 
page=parseInt(page)-1;
		vis_apply_filter(page,paginate='1');
	}
});
</script>
