<? global $vis_language; 

if($staff_details==-1 || $staff_details[0] == ''){ 
	include(VIS_PATH_TEMPLATE.'no_record_yet.php'); 
	echo '<script> $("#view_action").hide(); $("#vis_staff_form .panel-footer").hide(); $("#vis_staff_list").hide(); $(".fullFrame").removeClass("b-t").addClass("m-t-lg m-b-lg"); </script>';
 } else { ?>
<script> $("#view_action").show(); $("#vis_staff_form .panel-footer").show(); $("#vis_staff_list").show(); </script>
<table class="table table-hover b-t b-light m-b-none" data-ride="datatables">
   <thead class="table_head">
      <tr>
         <th>
            <div class="btn-group">
               <label class="checkbox m-n m-r-sm i-checks"  style="float: left;"><input type="checkbox"><i></i></label>		
            </div>
         </th>
         <th><? echo $vis_language['TXTFULLNAME']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTUSERNAME']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTEMAIL']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTSTAFFGROUP']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTDEPARTMENT']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTSTATUS']; ?></th>
         <?  if($operation['vis_sorted_by']=='is_enabled=1' || $operation['vis_sorted_by']== ''){?><th></th><? } ?>
         <th></th>
      </tr>
   </thead>
   <tbody>
      <? if($staff_details!=-1) for($i=0;$i<$staff_info['staff_count'];$i++) {
            if($staff_details[$i]['department_access']!=-1){ if($staff_details[$i]['is_enabled']==1){ $status = $vis_language['TXTENABLED'];$lbl='vh-green-bg';} else {$status = $vis_language['TXTDISABLED'];$lbl='label-default';}} else {$status = $vis_language['TXTDELETED'];$lbl='vh-danger-bg';}
             $department_access=$staff_details[$i]['department'];
             $href=($staff_details[$i]['department_access']!=-1)?'href="#/setting/staff_details/'.str_replace('/', ' ', $staff_details[$i]['user_name']).'/'.$staff_details[$i]['staff_id'].'"':'';
			 echo '<tr><td width="30"><label class="checkbox m-n i-checks"><input type="checkbox" name="vis_global_mass_chk_'.$i.'" id="vis_global_mass_chk_'.$i.'" value="'.$staff_details[$i]['staff_id'].'" '.(($staff_details[$i]['staff_id']==1)?'disabled="disabled"':'').' /><i></i></label></td>';
             echo '<td><a '.$href.'>'.$staff_details[$i]['first_name'].' '.$staff_details[$i]['last_name'].'</a></td>';
             echo '<td><a '.$href.'>'.$staff_details[$i]['user_name'].'</a></td>';
             echo '<td><a '.$href.'>'.$staff_details[$i]['email'].'</a></td>';
             echo '<td><a '.$href.'>'.$staff_details[$i]['group_name'].'</a></td>';
               ?>
      <td >
         <div class="<?php if(count($staff_details[$i]['department'])>5) echo 'dept_access'; ?>"><a <?= $href;?>>
            <?php if($staff_details[$i]['department_access']!=-1){ 
				  if($staff_details[$i]['department']!= -1) 
				  {
					   for($j=0;$j<count($staff_details[$i]['department']);$j++) {
					   echo $staff_details[$i]['department'][$j]['domain_name'];
					   if($staff_details[$i]['department'][$j]['domain_name']!='') echo ' :: ';
					   echo $staff_details[$i]['department'][$j]['department_name'].'<br />';
					   } 
				   }
				   else
				   {
					   echo $vis_language['TXTALLDEPARTMENTS'];
				   }
			}
			else echo $vis_language['TXTNOACCESS'];
            ?></a>
         </div>
      </td>
      <? echo '<td><span class="label '.$lbl.'">'.$status.'</span></td>';
        if($staff_details[$i]['is_enabled']==1 && $staff_details[$i]['department_access']!=-1){
        echo '<td align="right"><a class="link" href="#/setting/clone_staff/'.$staff_details[$i]['staff_id'].'">'.$vis_language['TXTCLONE'].'</a></td>';}
      if($staff_details[$i]['department_access']!=-1){?>
      <td align="center"><? if($staff_details[$i]['staff_id']!=1){ ?> <a class="text-muted" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=setting&vis_operation=get_staff_delete&vis_staff_id=<? echo $staff_details[$i]['staff_id']; ?>&vis_static_area=vis_staff_delete_form" title="<? echo $vis_language['TXTDELETE']; ?>"><i class="vh vh-delete-round"></a><? } ?></td><? } else { ?>
	  <td align="center"><? if($staff_details[$i]['staff_id']!=1){ ?> 
          <a class="btn btn-link link" href="javascript:void(0);" <? if(count($stafflist)<VIS_AGENT_COUNT){ ?>data-toggle="ajaxModal" data-modal-arguments="vis_module=setting&vis_operation=reset_staff&vis_staff_id=<? echo $staff_details[$i]['staff_id']; ?>&vis_static_area=vis_staff_delete_form"<? }else{ ?> onclick="$('#vis_workpanel_div').visExecution('load_module','staff',{'vis_module':'setting','vis_operation':'restore_staff'});" <? } ?>><? echo $vis_language['TXTRESTORE']; ?></a>
          <? } ?></td><? } ?>  
      </tr> <?
         } ?>
   </tbody>
</table><? } ?>
<script type="text/javascript">
   $(".selectpicker").selectpicker(); 
   $(document).ready(function() {	
   $('[data-ride="datatables"]').dataTable({		
          "bPaginate" : false,	
   		"sDom": 't', "bAutoWidth": false,
   		"aoColumns": [
   			{ "bSortable": false },
   		  	null,
   		  	null,
   		  	null,
   		  	null,
   		  	null,
   		  	null,	
            <? if($operation['vis_sorted_by']=='is_enabled=1' ||  $operation['vis_sorted_by']== ''){?>{ "bSortable": false },<? } ?>
   			{ "bSortable": false }
   		]
   	});
   });
   <? if(isset($operation['vis_filter_enable']) && $operation['vis_filter_enable']==1){?>
   $("#sorting").hide();
   <? } else { ?>$("#sorting").show();<? } ?>
</script>
