<?
    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['TXTAUTOAPPROVEREGISTRATION']; ?></label>
               <div class="col-sm-10">
				  <select name="vis_approval" class="form-control input-sm selectpicker">
					<option value="1"><? echo $vis_language['TXTYES']; ?>
					</option><option value="0"<? echo (isset($module_setting['vis_approval']) && $module_setting['vis_approval']==0)?' selected="selected"':''; ?>><? echo $vis_language['TXTNO']; ?>
					</option>   				  
				  </select>               
				</div>
            </div>									
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTENABLECAPTCHAONREGISTER']; ?></label>
               <div class="col-sm-10">
                  <select  name="vis_captcha"  class="form-control input-sm selectpicker">
					<option value="1"><? echo$vis_language['TXTYES']; ?></option>
					<option value="0"<? echo (isset($module_setting['vis_captcha']) && $module_setting['vis_captcha']==0)?' selected="selected"':''; ?>><? echo$vis_language['TXTNO']; ?></option>   				  									 				  </select>
               </div>
            </div>	
<div class="form-group" >
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTAUTOGENRATEORG']; ?></label>
               <div class="col-sm-10">
                <label class="radio-inline i-checks"><input type="radio" name="vis_auto_organization" onclick= "load_domain_list(1);" id="vis_auto_organization_yes" value="1"<?= (isset($module_setting['vis_auto_organization']) && $module_setting['vis_auto_organization']==1)?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTYES']?></label>
					<label class="radio-inline i-checks"><input type="radio" name="vis_auto_organization"  onclick= "load_domain_list(0);"  value="0"<?= (isset($module_setting['vis_auto_organization']) && $module_setting['vis_auto_organization']==0) || !isset($module_setting['vis_auto_organization'])?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTNO']?></label>
               </div>
            </div>	

<div class="form-group" id="vis_show_domain_list" >
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTIGNOREORGANIZATION']; ?></label>
               <div class="col-sm-10" >
                  <textarea name="vis_ignore_domain_list" class="form-control input-sm"  id="vis_ignore_domain_list" ><?php echo $module_setting['vis_ignore_domain_list'];?></textarea>
                </div>
            </div>	
			
			<? if($module_details['module_id']>3) { ?>
			   <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="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTADDITIONALEMAILS']; ?></label>
               <div class="col-sm-10">
                  <select  name="vis_additional_emails"  class="form-control input-sm selectpicker">
					<option value="0" ><? echo$vis_language['TXTNO']; ?></option>
					<option value="1"<? echo (isset($module_setting['vis_additional_emails']) && $module_setting['vis_additional_emails']==1)?' selected="selected"':''; ?>><? echo$vis_language['TXTYES']; ?></option> 
					</select>
               </div>
            </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();
    load_domain_list(<?php echo $module_setting['vis_auto_organization']; ?>);
	function load_domain_list(chkdata)
	{ 
	   if(chkdata==1){ $('#vis_show_domain_list').show(); }
	   else $('#vis_show_domain_list').hide();
	   
	}
</script>
