<? global $vis_language;?>
<form class="form-horizontal" data-validate="parsley" id="vis_staff_form" name="vis_staff_form" method="post" >
	<input type="hidden" name="vis_staff_id" id="vis_staff_id" value="<? echo $staff_details[0]['staff_id']; ?>" />
   <div class="panel-body">
	    <div class="form-group">
		   <label class="col-sm-2 control-label"><? echo $vis_language['TXTSCHEDULE']; ?></label>
		   <div class="col-sm-10">
			  <select name="vis_schedule_id" id="vis_schedule_id" class="form-control input-sm selectpicker"  <? if(count($schedule)>10) echo 'data-live-search="true"';?>>
				 <? for($i=0;$i<count($schedule);$i++) echo '<option value="'.$schedule[$i]['schedule_id'].'"'.(($schedule[$i]['schedule_id']==$staff['schedule_id'])?' selected="selected"':'').'>'.$schedule[$i]['schedule_name'].'</option>'; ?>
			  </select>
		</div>
		</div>
      <div class="form-group">
         <label class="col-sm-2 control-label"><? echo $vis_language['TXTTEAM']; ?></label>
         <div class="col-sm-10 p-r-none">
            <select name="vis_group" id="vis_group" class="form-control input-sm selectpicker" <? if(count($staff_group)>10) echo 'data-live-search="true"';?>><?
               for($i=0;$i<count($staff_group);$i++) echo '<option value="'.$staff_group[$i]['group_id'].'"'.(($staff_group[$i]['group_id']==$staff['group_id'])?' selected="selected"':'').'>'.$staff_group[$i]['group_name'].'</option>'; ?>
            </select>
         </div>
      </div>
      <div class="form-group">
         <label class="col-sm-2 control-label"><? echo $vis_language['TXTASGNDEPT']; ?></label>
         <div class="col-sm-10">
            <div class="radio i-checks m-r-lg pull-left"><label>
            <input type="radio" name="vis_access" <? if($staff['department_access']==-2) echo ' checked="checked"'; ?> id="vis_access_yes" value="0" /><i></i>
            <? echo $vis_language['TXTYES']; ?></label> </div>
            <div class="radio i-checks m-r-lg pull-left"><label>
            <input type="radio" name="vis_access" <? if(($staff['department_access']==0)||($staff['department_access']!=-2)) echo ' checked="checked"'; ?> id="vis_access_no" value="1"/><i></i>
            <? echo $vis_language['TXTNO']; ?>
            </label> </div>
         </div>
      </div>
      <div id="department_access123">
         <div class="form-group">
            <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENTACCESS']; ?></label>
            <div class="col-sm-10">
               <div class="checkbox-inline i-checks"><label>
               <input type="checkbox"  value="0" id="vis_department_all" name="vis_department_all" onchange="toggle_dept_list();" <? if(is_numeric($staff['department_access']) && $staff['department_access']==0) echo ' checked="checked"'; ?>><i></i> <? echo $vis_language['TXTALLDEPARTMENTS']; ?>
               </label> </div>
            </div>
         </div>
         <div id="vis_dept_list_section" class="form-group" style="<?= ($staff['department_access']==0)?'display:none':'';?>">
            <label class="col-sm-2 control-label"></label>
            <div class="col-sm-10">
				<div class="dept_access_list">
               <? $dept_list=array();
                  for($i=0;$i<count($department_details);$i++) { ?>
               <label class="checkbox-inline i-checks">
               <input type="checkbox"  value="<? echo $department_details[$i]['department_id']; ?>" id="vis_department" name="vis_department[]" <? if($staff['department_access']==0 || in_array($department_details[$i]['department_id'], $department_access)) echo ' checked="checked"'; ?> /> <i></i><? echo $department_details[$i]['domain_name'].' :: '.$department_details[$i]['department_name']; ?></label><br/>
               <?
                  $dept_list[]=$department_details[$i]['department_id'];
				}?><input type="hidden" name="vis_dept_all_list" value="<?= implode(',',$dept_list) ?>" />
            </div>
            </div>
         </div>
      </div>
   </div>
   <input type="hidden" name="vis_department_count" id="vis_department_count" value="<? echo count($department_details); ?>" />
   <div class="line b-b line-lg pull-in"></div>
   <br/><br/>
   <div class="form-group">
      <div class="col-sm-4 col-sm-offset-2">
         <button type="button" class="btn btn-primary" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'update_staff_department', 'vis_form':'vis_staff_form'})"><? echo $vis_language['TXTUPDATE']; ?></button>
      </div>
   </div>
</form>
<script type="text/javascript">
   if ($(vis_access_yes).is(":checked"))
   {
    $('#department_access123').hide();
   }
	$(document).ready(function () {
	   $('#vis_access_yes').click(function () {
		  $('#department_access123').hide();
   });
   $('#vis_access_no').click(function () {                   
		 $('#department_access123').show();
	});
  });
     $(".selectpicker").selectpicker();
   function toggle_dept_list(){
       if($('#vis_department_all').is(":checked")){ $('#vis_dept_list_section').hide();
							}else{ $('#vis_dept_list_section').show();
							$('.dept_access_list').each(function(index) {
        $(this).find('input[type="checkbox"]').removeAttr('checked');
       });
							}
   }
</script>
