<?
    global $vis_language;
?>
<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 $vis_language['TXTAVILABLEAGENTS']; ?></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 class="active"><? echo $vis_language['TXTAVILABLEAGENTS']; ?></li>
		 </ul>
	  </div>
	</div>
	<div class="col-sm-8 m-t-md pull-right"></div>
</section>
<div class="col-lg-12">
   <form name="vis_available_agent_form" id="vis_available_agent_form" class="form-horizontal"  method="post">
      <section class="panel panel-default">
	   <!-- <section class="panel-default">
         <header class="panel-heading sub_header"><? echo $vis_language['TXTTICKETASSIGNMENT']; ?></header>
        </section>-->
		<div class="panel-body">
              <div class="b-b" style="padding-bottom:10px;">		  
		       <div class="btn-group m-b-xs"> 
			       <a class="btn btn-sm btn-rounded <?php echo ($status == 1)?' btn-primary ':'btn-default'; ?> filtab" onclick="$('#vis_workpanel_div').visExecution('load_area', {'vis_module':'home', 'vis_operation':'change_available_agent_setting', 'vis_status_filter':1})"><? echo $vis_language['TXTACCEPTING']; ?></a>  
			   </div>
			    <div class="btn-group m-b-xs"> 
			       <a class="btn btn-sm btn-rounded <?php echo ($status == 0)?' btn-primary ':'btn-default'; ?> filtab" onclick="$('#vis_workpanel_div').visExecution('load_area', {'vis_module':'home', 'vis_operation':'change_available_agent_setting', 'vis_status_filter':0})"><? echo $vis_language['TXTNOTACCEPTING']; ?></a>  
			   </div>
		</div>
		<? if($staff!=-1 && !empty($staff[0])){ ?>
		<div class="row wrapper clr" id="view_action">
			  <div class="col-sm-9 tkt_left_menu"></div>
			  <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 class="pull-right"></div>
			  </div>
			</div><? } ?>
		<div class="m-r-n m-l-n">
  <table class="table table-hover m-b-none" data-ride="datatables" id="vis_staff_list">
	<tbody>
		<?php
        if($staff!=-1 && !empty($staff[0])){ for($i=0;$i<count($staff);$i++){ ?>
		<tr>
			
			<td>
			<?if($staff[$i]['image_name']=='' || $staff[$i]['image_name']=='default.jpg'){?>
				<? if($staff[$i]['staff_name']!=''){
	$namearr=explode(' ',$staff[$i]['staff_name']);
$fullname='';
if(count($namearr)>1){ 
$lastname=preg_split('//u', $namearr[1], -1, PREG_SPLIT_NO_EMPTY); 
$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
$fullname=ucfirst($firstname[0]).ucfirst($lastname[0]);
}else{
	$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
	$fullname=ucfirst($firstname[0]);
}
	?>
   <div class="l-avatar m-l"><div class="sm"><? echo $fullname; ?></div></div>
    <? }else{ ?>
				<div class="l-avatar m-l"><img class="sm" src="<?= VIS_PATH_PROFILE.'default.jpg';?>"></div>
				<? }} else{?>
				<div class="l-avatar m-l"><img src="<? echo VIS_PATH_PROFILE; echo $staff[$i]['image_name']; ?>" class="sm"></div>
           <?} echo $staff[$i]['staff_name'];?>
			</td>
			<td><? echo "Since ".count_remain_time(time()- $staff[$i]['modified_time']);?></td>
			<td>
			 <div class="form-group">
               <div class="col-sm-1">
                  <label class="switch sm">
					  <? $status = ($staff[$i]['access']==1)?"off":"on";?>
                  <input type="checkbox" <? if($staff[$i]['access']==1) echo 'checked="checked"'; else '';?> name="vis_status"  id="vis_status" onchange="<? if((VIS_SELF_AUTO_ASSIGN_TICKET==0 &&  $staff[$i]['staff_id']==VIS_STAFF_ID ) || ( $staff[$i]['staff_id']!=VIS_STAFF_ID && VIS_MANAGE_PARTICIPENTS==0)) { ?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>'); <?} else {?>$('#vis_workpanel_div').visExecution('load_area', {'vis_module':'staff', 'vis_operation':'change_auto_assign_setting', 'vis_status':'<?= $status; ?>','vis_staff_id':'<? echo $staff[$i]['staff_id']?>'})<?}?>">
                  <span ></span>
                  </label>
               </div>
            </div>
			</td>			
		</tr><? } }else { include(VIS_PATH_TEMPLATE.'no_record_yet.php'); }?>
	</tbody>
  </table>
  
 </div>
 <? if($staff!=-1){ ?>
 <footer class="wrapper panel-footer bg-white">
			  <div class="row">
				  <div class="col-sm-9 tkt_left_menu"></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><? } ?>
		</div>
      </form>
</div>
<script>
	function vis_apply_filter(vis_page){
	vis_page = (vis_page!=undefined && typeof(vis_page)!=undefined && vis_page != '') ? vis_page:'';
	var data = {'vis_status_filter':'1', 'vis_page':vis_page };
	$.ajax({
		url: 'index.php?vis_module=staff&vis_operation=change_available_agent_setting',
		data: data,
		type: "POST",
		success: function(data) {
			$("#vis_workpanel_div").html(data);
		},
		error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
	});
}
$('.pagination_cilent_list').twbsPagination({
	totalPages:<?php echo $view_info['page_count']; ?>,
	visiblePages:3,startPage:<?php echo ($staff_info['page']==0)?1:$staff_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);
	}
});
</script>
