<?
    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['TXTNUMBEROFATTACHMENTS']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_attachment" value="<? echo $module_setting['vis_attachment']; ?>" >
               </div>
            </div>			
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTALLOWEDEXTENSIONS']; ?></label>
               <div class="col-sm-10">
                  <textarea name="vis_extensions" class="form-control input-sm"><? echo $module_setting['vis_extensions']; ?></textarea>
               </div>
            </div>	
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTMAXALLOWEDSIZEFORATTACHMENT']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_maxsize" value="<? echo $module_setting['vis_maxsize']; ?>" >
               </div>
            </div>								
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTADDMERGEDTICKETSEMAILASRECIPENTS']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_add_recipient" class="form-control input-sm selectpicker">
                    <option value="1"><? echo $vis_language['TXTYES']; ?></option>
                    <option value="0"<? echo (isset($module_setting['vis_add_recipient']) && $module_setting['vis_add_recipient']==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['TXTTICKETHASHGENERATION']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
				  <label>
                  <input type="radio" name="vis_ticket_hash_generation" id="vis_ticket_random" value="1" <?php if(!isset($module_setting['vis_ticket_prefix'])) echo 'checked="checked"'?>/><i></i>
                  <? echo $vis_language['TXTRANDOM']; ?></label></div>
                  <div class="radio i-checks pull-left">
				  <label>
                  <input type="radio" name="vis_ticket_hash_generation" id="vis_ticket_sequential" value="2" <?php if(isset($module_setting['vis_ticket_prefix'])) echo 'checked="checked"';?>/><i></i>
                  <? echo $vis_language['TXTSEQUENTIAL']; ?>
                  </label></div>
               </div>
            </div>		
			<div class="form-group" id="ticket_setting_1" style="<? if(!isset($module_setting['vis_ticket_prefix'])) echo 'display:none;'?>" >
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTPREFIX']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" onkeyup="upper_prefix(this)" type="text" name="vis_ticket_prefix" value="<?  if(isset($module_setting['vis_ticket_prefix'])) echo $module_setting['vis_ticket_prefix']; ?>" >
               </div>
            </div>		
			<div class="form-group" id="ticket_setting_2" style="<?php if(!isset($module_setting['vis_ticket_prefix'])) echo 'display:none;'?>">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTNUMERINGSTARTSFROM']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_ticket_starts_from" value="<?  if(isset($module_setting['vis_ticket_number'])) echo $module_setting['vis_ticket_number']; ?>" >
               </div>
            </div>	
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETPOSTCOUNT']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" value="<?php echo (isset($module_setting['vis_post_count']) && $module_setting['vis_post_count'] != '') ? $module_setting['vis_post_count'] : '10'; ?>" name="vis_post_count" >
               </div>
            </div>	
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTPRIORITY']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_show_priority" class="form-control input-sm selectpicker">
                  <option value="0" <?= (isset($module_setting['vis_show_priority']) && $module_setting['vis_show_priority']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>  
                  <option value="1" <?= (isset($module_setting['vis_show_priority']) && $module_setting['vis_show_priority']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANAGEPORTAL']; ?></option>
                   <option value="2" <?= ((!isset($module_setting['vis_show_priority'])) || (isset($module_setting['vis_show_priority']) && $module_setting['vis_show_priority']==2))?' selected="selected"':''; ?>><? echo $vis_language['TXTMANGAEANDCLIENTPORTAL']; ?></option>
                   
                    
                  </select>
               </div>
            </div>
			 <div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTTICKETTYPE']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_show_tickettype" class="form-control input-sm selectpicker">
                      <option value="0" <?= (isset($module_setting['vis_show_tickettype']) && $module_setting['vis_show_tickettype']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>             
                    <option value="1" <?= (isset($module_setting['vis_show_tickettype']) && $module_setting['vis_show_tickettype']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANAGEPORTAL']; ?></option>
                    <option value="2" <?= ((!isset($module_setting['vis_show_tickettype'])) || (isset($module_setting['vis_show_tickettype']) && $module_setting['vis_show_tickettype']==2))?' selected="selected"':''; ?>><? echo $vis_language['TXTMANGAEANDCLIENTPORTAL']; ?></option>
                    
                    
                  </select>
               </div>
            </div>
              <!--new code-->
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTTICKETCATEGORY']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_show_category" class="form-control input-sm selectpicker" onchange="change_category(this.value)">
                    <option value="0" <?= (isset($module_setting['vis_show_category']) && $module_setting['vis_show_category']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>
                    <option value="1" <?= (isset($module_setting['vis_show_category']) && $module_setting['vis_show_category']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANAGEPORTAL']; ?></option>
                    <option value="2" <?= (isset($module_setting['vis_show_category']) && $module_setting['vis_show_category']==2)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANGAEANDCLIENTPORTAL']; ?></option>
                  </select>
               </div>
            </div>
			<div class="form-group" id="subcategory_div" <? if(!isset($module_setting['vis_show_subcategory'])){?>style="display:none;"<?php }?>>
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTDISPSUBCATEGORY']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_show_subcategory" class="form-control input-sm selectpicker" onchange="change_subcategory(this.value)">
                   <option value="0" <?= (isset($module_setting['vis_show_subcategory']) && $module_setting['vis_show_subcategory']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>
                    <? if($module_setting['vis_show_category']==1 || $module_setting['vis_show_category']==2){ ?>
						<option value="1" <?= (isset($module_setting['vis_show_subcategory']) && $module_setting['vis_show_subcategory']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANAGEPORTAL']; ?></option>
					<?php }
					if($module_setting['vis_show_category']==2){ ?>
						<option value="2" <?= (isset($module_setting['vis_show_subcategory']) && $module_setting['vis_show_subcategory']==2)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANGAEANDCLIENTPORTAL']; ?></option>
					<?php } ?>
                  </select>
               </div>
            </div>
            
            <div class="form-group" id="item_div" <? if(!isset($module_setting['vis_show_item'])){?>style="display:none;"<?php }?>>
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTDISPITEM']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_show_item" class="form-control input-sm selectpicker">
                   <option value="0" <?= (isset($module_setting['vis_show_item']) && $module_setting['vis_show_item']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>
                    <? if(($module_setting['vis_show_category']==1 || $module_setting['vis_show_category']==2) && ($module_setting['vis_show_subcategory']==1 || $module_setting['vis_show_subcategory']==2)){ ?>
						<option value="1" <?= (isset($module_setting['vis_show_item']) && $module_setting['vis_show_item']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANAGEPORTAL']; ?></option>
					<?php }
					if(($module_setting['vis_show_category']==1 || $module_setting['vis_show_category']==2) &&   $module_setting['vis_show_subcategory']==2){ ?>
						<option value="2" <?= (isset($module_setting['vis_show_item']) && $module_setting['vis_show_item']==2)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANGAEANDCLIENTPORTAL']; ?></option>
					<?php } ?>
                  </select>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTTICKETLEVEL']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_show_level" class="form-control input-sm selectpicker">
                   <option value="0" <?= (isset($module_setting['vis_show_level']) && $module_setting['vis_show_level']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>
                    <option value="1" <?= (isset($module_setting['vis_show_level']) && $module_setting['vis_show_level']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANAGEPORTAL']; ?></option>
                    <option value="2" <?= (isset($module_setting['vis_show_level']) && $module_setting['vis_show_level']==2)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANGAEANDCLIENTPORTAL']; ?></option>
                   
                  </select>
               </div>
            </div>
            <?php if(VIS_ITIL==1){ ?>
              <div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTLOCATION']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_show_location" class="form-control input-sm selectpicker">
                  <option value="0" <?= (isset($module_setting['vis_show_location']) && $module_setting['vis_show_location']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>  
                  <option value="1" <?= (isset($module_setting['vis_show_location']) && $module_setting['vis_show_location']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTMANAGEPORTAL']; ?></option>
                   <option value="2" <?= ((!isset($module_setting['vis_show_location'])) || (isset($module_setting['vis_show_location']) && $module_setting['vis_show_location']==2))?' selected="selected"':''; ?>><? echo $vis_language['TXTMANGAEANDCLIENTPORTAL']; ?></option>
                   
                    
                  </select>
               </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTATTACHCI']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_ci_attach" class="form-control input-sm selectpicker">
                  <option value="0" <?= (isset($module_setting['vis_ci_attach']) && $module_setting['vis_ci_attach']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTNONE']; ?></option>  
                  <option value="1" <?= (isset($module_setting['vis_ci_attach']) && $module_setting['vis_ci_attach']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTCLIENTPORTAL']; ?></option>
                  
                  </select>
               </div>
            </div>  
            <?php }?>
            <!--end new code-->
            
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo stripslashes($vis_language['TXTENABLESUBJECTMATCHING']); ?></label>
               <div class="col-sm-10">
                  <select name="vis_enable_subject_match" class="form-control input-sm selectpicker">
                  <option value="0" <?= (isset($module_setting['vis_enable_subject_match']) && $module_setting['vis_enable_subject_match']==0)?' selected="selected"':''; ?> ><? echo $vis_language['TXTBASEDTICKHASSUBJLINE']; ?></option>  
                  <option value="1" <?= (isset($module_setting['vis_enable_subject_match']) && $module_setting['vis_enable_subject_match']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTBASEDTICKSUB']; ?></option>
                  
                  </select>
               </div>
            </div>  
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSHOWINLINEIMG']; ?></label>
               <div class="col-sm-10">
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_inline_image" id="vis_show_inline_image_yes" value="1"<?= (isset($module_setting['vis_show_inline_image']) && $module_setting['vis_show_inline_image']==1)?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTYES']?></label>
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_inline_image"  id="vis_show_inline_image_no" value="0"<?= ((isset($module_setting['vis_show_inline_image']) && $module_setting['vis_show_inline_image']==0 ) || !isset($module_setting['vis_show_ip_addr']))?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTNO']?></label>
               </div>
            </div>
            <div class="form-group">
				<label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYIPADDRESSTOSTAFF']; ?></label>
				<div class="col-sm-10">
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_ip_addr" id="vis_show_ip_addr_yes" value="1"<?= (isset($module_setting['vis_show_ip_addr']) && $module_setting['vis_show_ip_addr']==1) || !isset($module_setting['vis_show_ip_addr'])?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTYES']?></label>
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_ip_addr"  id="vis_show_ip_addr_no" value="0"<?= (isset($module_setting['vis_show_ip_addr']) && $module_setting['vis_show_ip_addr']==0)?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTNO']?></label>
				</div>				
            </div>
            <div class="form-group">
				<label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYNOTEONTICKETDETAILS']; ?></label>
				<div class="col-sm-10">
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_note" id="vis_show_note_yes" value="1"<?= (isset($module_setting['vis_show_note']) && $module_setting['vis_show_note']==1)?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTYES']?></label>
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_note"  id="vis_show_note_no" value="0"<?= (isset($module_setting['vis_show_note']) && $module_setting['vis_show_note']==0) || !isset($module_setting['vis_show_note'])?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTNO']?></label>
				</div>				
            </div>
            <div class="form-group">
				<label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYCUSTOMONTICKETDETAILS']; ?></label>
				<div class="col-sm-10">
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_custom_field" id="vis_show_note_yes" value="1"<?= (isset($module_setting['vis_show_custom_field']) && $module_setting['vis_show_custom_field']==1)?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTYES']?></label>
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_custom_field"  id="vis_show_note_no" value="0"<?= (isset($module_setting['vis_show_custom_field']) && $module_setting['vis_show_custom_field']==0) || !isset($module_setting['vis_show_custom_field'])?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTNO']?></label>
				</div>				
            </div>
            
            <div class="form-group">
				<label class="col-sm-2 control-label"><? echo $vis_language['TXTREADTICKETENTRYTOADUITLOG']; ?></label>
				<div class="col-sm-10">
					<label class="radio-inline i-checks"><input type="radio" name="vis_add_read_ticket_tolog" id="vis_add_read_ticket_tolog_yes" value="1"<?= (isset($module_setting['vis_add_read_ticket_tolog']) && $module_setting['vis_add_read_ticket_tolog']==1)?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTYES']?></label>
					<label class="radio-inline i-checks"><input type="radio" name="vis_add_read_ticket_tolog"  id="vis_add_read_ticket_tolog_no" value="0"<?= (isset($module_setting['vis_add_read_ticket_tolog']) && $module_setting['vis_add_read_ticket_tolog']==0) || !isset($module_setting['vis_add_read_ticket_tolog'])?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTNO']?></label>
				</div>				
            </div>
    
    <div class="form-group">
				<label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYAMOUNTONTIMETRACK']; ?></label>
				<div class="col-sm-10">
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_time_track_amount" id="vis_show_time_track_amount_yes" value="1"<?= (isset($module_setting['vis_show_time_track_amount']) && $module_setting['vis_show_time_track_amount']==1) || !isset($module_setting['vis_show_time_track_amount'])?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTYES']?></label>
					<label class="radio-inline i-checks"><input type="radio" name="vis_show_time_track_amount"  id="vis_show_time_track_amount_no" value="0"<?= (isset($module_setting['vis_show_time_track_amount']) && $module_setting['vis_show_time_track_amount']==0)?' checked="checked"':''; ?>><i></i> <?= $vis_language['TXTNO']?></label>
				</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_setting', 'vis_form':'vis_module_form'})"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>

      </form>   
<script>	
   $(".selectpicker").selectpicker();
</script>
<script language="javascript" type="text/javascript">
$("#vis_ticket_sequential").click( function(){ 
	$("#ticket_setting_1").show(); $("#ticket_setting_2").show(); 
});
$("#vis_ticket_random").click( function(){ 
	$("#ticket_setting_1").hide(); $("#ticket_setting_2").hide(); 	
});
function upper_prefix(obj) {
  obj.value=obj.value.toUpperCase();
}
<? if(isset($module_setting['vis_show_category']) && $module_setting['vis_show_category']==0) {?> change_category(0); <? } ?>
<? if(isset($module_setting['vis_show_subcategory']) && $module_setting['vis_show_subcategory']==0) {?> change_subcategory(0); <? } ?>
function change_category(id) {
	$("#subcategory_div").css("display", "none");
	$("#item_div").css("display", "none");
	if(id!=0){   
		$.ajax({
			url: 'index.php',
			data: {'vis_module': "setting", 'vis_operation': "change_category", 'category_id': id},
			type: "POST",
			success: function(data) {
				$("#subcategory_div").css("display", "block");
				$("#subcategory_div").html(data);
			}
		});
	}
}
function change_subcategory(id) {
	
		$("#item_div").css("display", "none");
    if(id!=0){         
		$.ajax({
			url: 'index.php',
			data: {'vis_module': "setting", 'vis_operation': "change_subcategory", 'category_id': id},
			type: "POST",
			success: function(data) {
				$("#item_div").css("display", "block");
				$("#item_div").html(data);
			}
		});
	}
}
</script>
