<?
    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>';
    }
	$property=count($domain)>10?'data-live-search="true"':'';
    $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 $property ?>>
				<? echo $domain_option; ?>
                  </select>
               </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTHASHGENERATION']; ?></label>
               <div class="col-sm-10">
                 <div class="radio i-checks pull-left m-r-lg">
					  <label>
					  <input type="radio" name="vis_itil_hash_generation" id="vis_itil_sequential" value="2" <?php if(isset($module_setting['vis_itil_services_prefix']) || (!isset($module_setting['vis_itil_services_prefix']) &&  !isset($module_setting['vis_itil_hash_generation']))) echo 'checked="checked"'?>/><i></i>
					  <? echo $vis_language['TXTSEQUENTIAL']; ?>
					  </label>
				  </div>	
				  <div class="radio i-checks pull-left">
					  <label>
					  <input type="radio" name="vis_itil_hash_generation" id="vis_itil_random" value="1" <?php if(isset($module_setting['vis_itil_hash_generation']) && !isset($module_setting['vis_itil_services_prefix'])) echo 'checked="checked"'?>/><i></i>
					  <? echo $vis_language['TXTRANDOM']; ?></label>
				  </div>
               </div>
            </div>
			<div id="itil_setting">
			<div class="form-group" id="itil_setting_1">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSERVICESPREFIX']; ?></label>
               <div class="col-sm-10">
			   <? $val=(!isset($module_setting['vis_itil_hash_generation'])) ? 'SR' : $module_setting['vis_itil_services_prefix']; ?>
                  <input class="form-control input-sm" onkeyup="upper_prefix(this)" type="text" name="vis_itil_services_prefix" value="<?=$val ?>" >
               </div>
            </div>
			<div class="form-group" id="itil_setting_2">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTPROBLEMSPREFIX']; ?></label>
               <div class="col-sm-10">
			   <? $val=(!isset($module_setting['vis_itil_hash_generation'])) ? 'PRB' : $module_setting['vis_itil_problems_prefix']; ?>
                  <input class="form-control input-sm" onkeyup="upper_prefix(this)" type="text" name="vis_itil_problems_prefix" value="<?=$val ?>" >
               </div>
            </div>
			<div class="form-group" id="itil_setting_3">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTCHANGESPREFIX']; ?></label>
               <div class="col-sm-10">
			   <? $val=(!isset($module_setting['vis_itil_hash_generation'])) ? 'CHG' : $module_setting['vis_itil_changes_prefix']; ?>
                  <input class="form-control input-sm" onkeyup="upper_prefix(this)" type="text" name="vis_itil_changes_prefix" value="<?=$val ?>" >
               </div>
            </div>
			<div class="form-group" id="itil_setting_4">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTRELEASESPREFIX']; ?></label>
               <div class="col-sm-10">
			   <? $val=(!isset($module_setting['vis_itil_hash_generation'])) ? 'REL' : $module_setting['vis_itil_releases_prefix']; ?>
                  <input class="form-control input-sm" onkeyup="upper_prefix(this)" type="text" name="vis_itil_releases_prefix" value="<?=$val ?>" >
               </div>
            </div>
			<div class="form-group" id="itil_setting_5">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTCONTRACTSPREFIX']; ?></label>
               <div class="col-sm-10">
			   <? $val=(!isset($module_setting['vis_itil_hash_generation'])) ? 'CON' : $module_setting['vis_itil_contracts_prefix']; ?>
                  <input class="form-control input-sm" onkeyup="upper_prefix(this)" type="text" name="vis_itil_contracts_prefix" value="<?=$val ?>" >
               </div>
            </div>
			<div class="form-group" id="itil_setting_6">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTNUMERINGSTARTSFROM']; ?></label>
               <div class="col-sm-10">
			   <? $val=(!isset($module_setting['vis_itil_hash_generation'])) ? 1 : $module_setting['vis_itil_number']; ?>
                  <input class="form-control input-sm" type="text" name="vis_itil_starts_from" value="<?=$val ?>" >
               </div>
            </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="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_itil_setting', 'vis_form':'vis_module_form'})"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>
      </form>   
<script>	
   $(".selectpicker").selectpicker();
</script>
<script language="javascript" type="text/javascript">

if($('#vis_itil_sequential').is(":checked")){ $('#itil_setting').show();}
if($('#vis_itil_random').is(":checked")){ $('#itil_setting').hide();}

$("#vis_itil_sequential").click( function(){ 
	$("#itil_setting").show(); 
});
$("#vis_itil_random").click( function(){ 
	$("#itil_setting").hide();
});
function upper_prefix(obj) {
  obj.value=obj.value.toUpperCase();
}
</script>