<? global $vis_language;?>
<form class="form-horizontal" data-validate="parsley" id="vis_client_form" name="vis_client_form" method="post" >
	<input type="hidden" name="vis_client_id" id="vis_client_id" value="<? echo $client_details['client_id']; ?>" />
   <div class="panel-body">
      <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($client_details['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="<?= ($client_details['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();
                 if($department_details!=-1){
                  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($client_details['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':'client', 'vis_operation':'update_client_department', 'vis_form':'vis_client_form','client_id':<? echo $client_details['client_id']; ?>,'vis_domain_id':<? echo $operation['vis_domain_id']; ?>})"><? echo $vis_language['TXTUPDATE']; ?></button>
      </div>
   </div>
</form>
<script type="text/javascript">
   $(".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>
