<? 
    global $vis_language;
    $domain_option='';
    $domain_id=0;
    for($i=0;$i<count($domain);$i++) {
        if($domain_id==0) $domain_id=(isset($operation['vis_domain_id']) && is_numeric($operation['vis_domain_id']))?$operation['vis_domain_id']:$domain[$i]['domain_id'];
        $domain_option.='<option value="'.$domain[$i]['domain_id'].'"'.(($domain[$i]['domain_id']==$domain_id)?' selected="selected"':'').'>'.$domain[$i]['domain_name'].'</option>';
    }
    $module_setting=$object->get_module_setting('domain_id='.$domain_id.' and module_id='.$module_details['module_id'], VIS_STAFF_ID, VIS_LOCATION_AREA);
    if($domain_option=='') {
        echo $vis_language['MSGDOMAINNOTFOUND'];
        return false;
    }
    else {
?>
				<input type="hidden" name="vis_module_id" value="<? echo $module_details['module_id']; ?>" />
				<input type="hidden" name="vis_department" value="0" />                 
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDOMAIN']; ?></label>
               <div class="col-sm-10">
				<select name="vis_domain" class="form-control input-sm selectpicker" onchange="$('#vis_module_details_list_<? echo $module_details['module_id']; ?>').visExecution('load_area',{'vis_module':'setting', 'vis_operation':'module_setting', 'vis_module_id':<? echo $module_details['module_id']; ?>, 'vis_domain_id':$(this).val()})"><? echo $domain_option; ?></select>
               </div>
            </div>	
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTAUTOAPPROVETOPICANDCOMMENT']; ?></label>
               <div class="col-sm-10">
                  <select  name="vis_approve"  class="form-control input-sm selectpicker">
						<option value="0"<? echo (isset($module_setting['vis_approve']) && $module_setting['vis_approve']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTNO']; ?></option>
						<option value="1"<? echo ((!isset($module_setting['vis_approve']))|| (isset($module_setting['vis_approve']) && $module_setting['vis_approve']==1))?' selected="selected"':''; ?>><? echo$vis_language['TXTYES']; ?></option>
						</select>
               </div>
            </div>		
              <div class="form-group" id="shareWith">
	   <label class="col-sm-2 control-label"><? echo $vis_language['TXTSENDEMAILNOTIFICATION']; ?></label>
               <div class="col-sm-10">
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" id="vis_staff_access_all" onchange="toggle_dept_list();" name="vis_staff_access_all" <? if($module_setting['vis_staff']==0 || $module_setting['vis_staff']=='') echo ' checked="checked"'; ?>><i></i><? echo $vis_language['TXTALLSTAFF']; ?></label>
               </div>
            </div>
             <div class="form-group" id="vis_team_section" style="display:none;">
               <label class="col-sm-2 control-label"></label>
               <div class="col-sm-10">
				<div class="dept_access_list">
                  <?
                     for($i=0; $i<count($staff_group); $i++) { ?>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" value="<? echo $staff_group[$i]['group_id']; ?>" name="vis_staff_group_access[]" <? if(in_array($staff_group[$i]['group_id'], $team_owner)) echo ' checked="checked"'; ?>/> <i></i><? echo $staff_group[$i]['group_name']; ?></label><br/>
                  <? } ?>
                </div>
               </div>
            </div>
             <div id="vis_dept_list_section" class="form-group" style="display:none;">
               <label class="col-sm-2 control-label"></label>
               <div class="col-sm-10">
				<div class="dept_access_list">
                  <?
                     for($i=0; $i<count($staff_list); $i++) { ?>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox"  class="vis_list_checkbox" value="<? echo $staff_list[$i]['staff_id']; ?>" name="vis_staff_access[]" <? if(in_array($staff_list[$i]['staff_id'], $staff_owner)) echo ' checked="checked"'; ?>/> <i></i><? echo $staff_list[$i]['first_name'].' '. $staff_list[$i]['last_name']; ?></label><br/>
                  <? } ?>
               </div>
               </div>
                </div>
	</div>								
			   <div class="form-group">
				  <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
				  <div class="col-sm-1">
					 <label class="switch  <? if($module_details['is_enabled']==0) echo 'radio-no-uncheck'; ?>">
					 <input type="checkbox" name="vis_status"  id="vis_status" <? if($module_details['is_enabled']==1) echo 'checked="checked"'; ?> > 
					 <span ></span>
					 </label>
				  </div>
			   </div>
            <div class="line b-b line-lg pull-in"></div>
            <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_setting', 'vis_form':'vis_module_form'})"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>
      </form> 
      <? } ?>
<script>	
   $(".selectpicker").selectpicker();
   toggle_dept_list();
   function toggle_dept_list(){
       if($('#vis_staff_access_all').is(":checked")) 
       {
		   $('#vis_dept_list_section').hide();
		   $('#vis_team_section').hide();
	   }
       else 
       {
		   $('#vis_dept_list_section').show();
		   $('#vis_team_section').show();
	   }
   }
</script>
