<?  global $vis_language, $request_data; 
    $note='';
    $depts='';
    $checked='';
    for($i=0;$i<count($departments);$i++) {
        if(isset($department_get) && $department_get == $departments[$i]['department_id']) {
            $selected='selected="selected"';
            $checked=$departments[$i]['department_id'];
            if($departments[$i]['registration']==1 && IS_LOGIN==0) $note=$vis_language['TXTREGISTRATIONREQUIRED'];
        }
        else {
            $selected='';
        }
        $depts.='<option value="'.$departments[$i]['department_id'].'" '.$selected.' >'.$departments[$i]['department_name'].'</option>';
    }
    if($checked=='' && $departments[0]['registration']==1 && IS_LOGIN==0) $note=$vis_language['TXTREGISTRATIONREQUIRED'];?>
    <header class="vis_login_head">
		<? if(isset($operation['message']) && $operation['message']!='' && $operation['message']!='domain') { ?> <script> $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").html('<? echo $operation['message']; ?>'); </script><? }else { ?> <div id="vis_submit_msg_div" class="alert text-center alert-success" style="display:none"></div>  <? } ?>
	</header>
<?if(VIS_VIEW_SELFTICKET!=0) { ?>
<section class="container m-t-md">
   <div class="row">
      <div class="col-md-12">
         <section class="container">        
                <div class="panel-body">
                  <div class="form-horizontal" >
					<!--<form class="form-horizontal" name="vis_submit_ticket" method="post">-->
                    <div class="col-md-12">
                      <div class="wrapper"> 
					  <? if(VIS_SATELLITE_HELPDESK == 3) { ?>						  
					  <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTDOMAIN']; ?> </label>
                            <div class="col-sm-8">
                              <select name="vis_domain" id="vis_domain" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($domains)>10 && !is_mobile()) echo ' data-live-search="true"';?> onchange="onchange_domain(this.value);">
								<? for($i=0; $i<count($domains); $i++) {
									$selected_domain =($domains[$i]['domain_id']==$data[4])?'selected="selected"':'';
								     echo '<option value="'.$domains[$i]['domain_id'].'"'.$selected_domain.'>'.$domains[$i]['domain_name'].'</option>'; ?>
							  <? } ?></select>
                            </div>                            
                          </div>
						 <? } ?>
                          <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENT']; ?> </label>
                            <div class="col-sm-8">
                              <select name="vis_department" id="vis_department" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($departments)>10 && !is_mobile()) echo ' data-live-search="true"';?> onchange="onchange_department(this.value)"><? for($i=0;$i<count($departments);$i++) {
								echo '<option value="'.$departments[$i]['department_id'].'" '.(($departments[$i]['department_id']==$operation['departmentid'])?' selected="selected"':'').' >'.$departments[$i]['department_name'].'</option>';
							} ?></select>
                            </div>                            
                          </div>
                          <? if(IS_LOGIN==0) { ?>
                          <div class="form-group">
                            <label for="FirstName" class="col-sm-2 control-label"><? echo $vis_language['TXTFIRSTNAME']; ?> </label>
                            <div class="col-sm-8">
                              <input type="text" class="form-control input-sm" data-type="text" data-required="true" name="vis_firstname" id="FirstName" value="<? echo $request_data['vis_firstname']; ?>" />
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="LastName" class="col-sm-2 control-label"><? echo $vis_language['TXTLASTNAME']; ?></label>
                            <div class="col-sm-8">
                              <input type="text" class="form-control input-sm" data-type="text" data-required="true" name="vis_lastname" id="LastName" value="<? echo $request_data['vis_lastname']; ?>" />
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="PersonalEmail" class="col-sm-2 control-label"><? echo $vis_language['TXTEMAIL']; ?></label>
                            <div class="col-sm-8">
                              <input type="email" class="form-control input-sm" data-type="email" data-required="true" name="vis_email" id="PersonalEmail" value="<?= $request_data['vis_email']; ?>" />
                              <? if($note!='') { ?><span class="help-block m-b-none"><?  echo $note; ?></span><? } ?>
                            </div>
                          </div><?php } ?>
                          <? if($ticket_priority != -1): ?>
                          <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTPRIORITY']; ?></label>
                            <div class="col-sm-8">
                              <select name="vis_priority" id="vis_priority" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($ticket_priority)>10 && !is_mobile()) echo ' data-live-search="true"';?>">
                                <? for($i=0;$i<count($ticket_priority);$i++){
								echo '<option value="'.$ticket_priority[$i]['priority_id'].'">'.$ticket_priority[$i]['priority_name'].'</option>'; } ?>
                              </select>
                            </div>
                          </div>
                          <? endif; ?>
                          <? if($ticket_type != -1): ?>
                          <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTTYPE']; ?></label>
                            <div class="col-sm-8">
                              <select name="vis_type" id="vis_type" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($ticket_type)>10 && !is_mobile()) echo ' data-live-search="true"';?>">
                                <?php for($i=0;$i<count($ticket_type);$i++){
								echo '<option value="'.$ticket_type[$i]['type_id'].'">'.$ticket_type[$i]['type_name'].'</option>'; } ?>
                              </select>
                            </div>
                          </div>
                          <? endif; ?>
                           <? if($ticket_cat_details != -1 && (isset($module_setting['vis_show_category']) && $module_setting['vis_show_category']==2)): ?>
                          <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETCATEGORY']; ?></label>
                            <div class="col-sm-8">
                              <select name="vis_category" id="vis_category" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($ticket_cat_details)>10 && !is_mobile()) echo ' data-live-search="true"';?> onchange='get_subcategory(this.value);'>
                              <option value="0"><? echo 'Select'; ?></option>
                                <?php for($i=0;$i<count($ticket_cat_details);$i++){
								echo '<option value="'.$ticket_cat_details[$i]['category_id'].'">'.$ticket_cat_details[$i]['title'].'</option>'; } ?>
                              </select>
                            </div>
                          </div>
                           <? if(isset($module_setting['vis_show_subcategory']) && $module_setting['vis_show_subcategory']==2): ?>
                          <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETSUBCATEGORY']; ?></label>
                            <div class="col-sm-8"  id="ajax_subcategory">
                              <select name="vis_subcategory" id="vis_subcategory" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; ?> onchange='getitem(this.value);'>
                               <option value="0"><? echo 'Select'; ?></option>
                                </select>
                            </div>
                          </div> 
                           <? endif; if(isset($module_setting['vis_show_item']) && $module_setting['vis_show_item']==2): ?>
                          <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETITEM']; ?></label>
                            <div class="col-sm-8"  id="ajax_item">
                              <select name="vis_item" id="vis_item" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; ?>>
                               <option value="0"><? echo 'Select'; ?></option>
                                </select>
                            </div>
                          </div>
                          <? endif; endif;?>
                          <? if($ticket_level_details != -1 && (isset($module_setting['vis_show_level']) && $module_setting['vis_show_level']==2)): ?>
                           <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETLEVEL']; ?></label>
                            <div class="col-sm-8">
                              <select name="vis_ticket_level" id="vis_ticket_level" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($ticket_level_details)>10 && !is_mobile()) echo ' data-live-search="true"';?>>
                              <option value="0"><? echo 'Select'; ?></option>
                                <?php for($i=0;$i<count($ticket_level_details);$i++){
								echo '<option value="'.$ticket_level_details[$i]['level_id'].'">'.$ticket_level_details[$i]['title'].'</option>'; } ?>
                              </select>
                            </div>
                          </div>
                           <? endif; ?>
                           <? if($location_assets != -1 && VIS_ITIL==1 && VIS_MODULE_ACCESS_ITIL==1): ?>
                            <div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTLOCATION']; ?></label>
                            <div class="col-sm-8">
                              <select name="vis_assets_location" id="vis_assets_location" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($location_assets)>10 && !is_mobile()) echo ' data-live-search="true"';?>">
                              <option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
									    <?	if(isset($location_assets) && $location_assets!=NULL && $location_assets!=-1) {
										vis_show_subcategories($location_assets,''); ?>
										<?  } ?>
                              </select>
                            </div>
                          </div>
                          <? endif;
							if(IS_LOGIN==1 && VIS_ITIL==1 && (isset($module_setting['vis_ci_attach']) && $module_setting['vis_ci_attach']==1)){ ?>
								<div class="form-group">
									<label class="col-sm-2 control-label"><? echo $vis_language['TXTCITYPE']; ?></label>
									<div class="col-sm-8" id="citype_list">
										<select name="vis_ci_type" id="vis_ci_type" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($config_details)>10 && !is_mobile()) echo ' data-live-search="true"';?>">
									  <option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
										<? 	for($i=0;$i<count($config_details);$i++){
												echo '<option value="'.$config_details[$i]['item_id'].'">'.$config_details[$i]['name'].'</option>'; 
											} 
										?>
									  </select>
									</div>
									<input type="hidden" name="vis_show_asset_list" id="vis_show_asset_list" value="" />
								</div>
								<div id="assets_list"></div>
								<?  
							}
							if($custom_field_var != '') echo $custom_field_var; ?>
							<div class="form-group">
								<label for="Subject" class="col-sm-2 control-label"><? echo $vis_language['TXTSUBJECT']; ?></label>
								<div class="col-sm-8">
								  <input type="text" class="form-control input-sm" name="vis_subject" id="vis_subject" value="<?= $request_data['vis_subject']; ?>" <?php if($selfhelp==1 && VIS_MODULE_ACCESS_SELFHELP==1) echo ' onchange="vis_suggest_selfhelp(this)"'; ?>>
								</div>
							</div>
						 <? if($assets_details != -1 && (isset($module_setting_assetsvar['vis_head_menu_assets']) && $module_setting_assetsvar['vis_head_menu_assets']==1)): ?>
						<div class="form-group">
                            <label class="col-sm-2 control-label"><? echo $vis_language['TXTASSETS']; ?></label>
                            <div class="col-sm-8">
                              <select name="vis_assets" id="vis_assets" class="form-control input-sm<? if(!is_mobile()) echo ' selectpicker"'; else echo '"'; if(count($assets_details)>10 && !is_mobile()) echo ' data-live-search="true"';?>">
							   <option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
                                <? for($i=0;$i<count($assets_details);$i++){
								echo '<option value="'.$assets_details[$i]['assets_id'].'">'.$assets_details[$i]['name'].'</option>'; } ?>
                              </select>
                            </div>
                          </div>
                          <? endif; ?>
							<div class="form-group" id="vis_selfhelp_suggest_div" style="display:none;">
								<label class="col-sm-2 control-label"></label>
								<div class="col-sm-8">
									<div id="vis_selfhelp_suggest" class="vis_selfhelp_suggest" style="display:none;"></div>
								</div>
							</div>
							<div class="form-group">
								<label for="Message" class="col-sm-2 control-label"><? echo $vis_language['TXTMESSAGE']; ?></label>
								<div class="col-sm-8">
									<textarea class="form-control input-sm" rows="6" name="vis_ticket_post" id="vis_ticket_post"><?= $request_data['vis_ticket_post']; ?></textarea>
								</div>
							</div>
                          	<div class="form-group m-b-none">
								<label for="Message" class="col-sm-2 control-label"></label>
								<div class="col-sm-6 p-l-none">
									<div id="progress" class="progress" style="display:none; height:14px;"><div class="progress-bar progress-bar-success"></div></div>
								</div>
								<div class="col-sm-2 control-label" style="<?= ($attachment>0)?'':'display:none'; ?>">
									<span class="btn btn-link btn-sm link btn_upload_file" id="vis_attach_file"><?= $vis_language['TXTATTACHFILE']; ?> <input class="form-control" type="file" id="fileupload"></span>
									<input type="hidden" id="vis_max_attach" name="vis_max_attach" value="<?= ($attachment-1); ?>" />
									<input type="hidden" id="vis_attachment_count" name="vis_attachment_count" value="0" />
									<div style="display:none;" id="vis_attachments"></div>
								</div>
							</div>
							<div class="form-group">
								<label for="Message" class="col-sm-2 control-label"></label>
								<div id="vis_new_attachments" class="col-sm-8 p-l-none"></div>
							</div>
                          <? if(IS_LOGIN!=1 && ($setting_details == -1 || $setting_details[0]['content'] == 1)){ ?>
                            <div class="form-group">
                                <label for="Password" class="col-sm-2 control-label"><? echo $vis_language['TXTIMGVERIFY']; ?></label>
                                <div class="col-sm-8">
                                    <div class="col-sm-10">	
                                      <img src="<?= VIS_PATH_TEMPLATE ?>get_captcha.php?clr=<? echo str_replace("#",'',VIS_THEME_COLOR); ?>" alt="" id="captcha" class="col-sm-4"/>
                                      <div id="refresh" class="col-sm-3 m-t link"><i class="vh vh-lg vh-refresh"></i> <? echo $vis_language['TXTREFRESH']; ?></div>
                                    </div> 
                                      <input type="text" class="form-control input-sm" name="captchacode"  id="captchacode" autocomplete="off"/>
                                </div>
                            </div><? } ?>
                          <div class="line line-dashed b-b line-lg pull-in"></div>
                      </div> <!-- /.wrapper -->
                    </div> <!-- /.col-md-12 -->
                    
                    <div class="col-lg-offset-2 col-lg-8 m-b-lg col-0">
						  <input type="hidden" name="vis_module" id="vis_module" value="ticket" /> 
						  <input type="hidden" name="vis_operation" id="vis_operation" value="open_new_ticket" />
						  <input type="hidden" name="vis_status" value="1" />
						  <? if(VIS_SATELLITE_HELPDESK == 3) { ?>
						  <input type="hidden" name="vis_domain" id="vis_domain" value="1" />
						  <? } else { ?>
						  <input type="hidden" name="vis_domain" id="vis_domain" value="<? echo $domainid; ?>" />
						  <? } ?>
						  <input type="hidden" name="vis_channel" value="5" />
						  <button id="btn_submit_ticket" type="button" class="btn btn-primary" onclick="submit_form(<? echo VIS_HEAD_MENU_VIEWTICKET;?>); "><? echo $vis_language['TXTSUBMIT']; ?></button>
                         <!-- <button type="submit" class="btn btn-primary"><? echo $vis_language['TXTSUBMIT']; ?></button>
                          <input type="hidden" name="vis_module" value="ticket" /><input type="hidden" name="vis_operation" value="open_new_ticket" />-->
                          <?php if(IS_LOGIN==1) { ?>
						  <input type="hidden" name="vis_client" value="<? echo $client['client_id']; ?>" />
						  <input type="hidden" name="vis_from_name" value="<? echo $client['first_name'].' '.$client['last_name']; ?>" />
						  <input type="hidden" name="vis_from_email" value="<? echo $client['email']; ?>" />
						  <? } ?>
                          <?php if(IS_LOGIN!=1){ ?><input type="hidden" name="vis_honeypot" id="vis_honeypot" /><? } ?>
                    </div>
                   <!-- </form>-->
                  </div>
                </div>
            </section> <!-- / .panel -->
		</div>
      </div><!-- /.row --><?}?>
 </section> <!-- / .panel -->
 <?php
function vis_show_subcategories($location_assets,$call=NULL) {
         
        for($i=0;$i<count($location_assets);$i++) { ?>
		 <? echo '<option value="'.$location_assets[$i]['location_id'].'">'.ucfirst($location_assets[$i]['name']). '</option>';?>
				 <?php 
				if(isset($location_assets[$i]['subcat']) && $location_assets[$i]['subcat']!=NULL) { 
					 
					  vis_show_subcategories($location_assets[$i]['subcat'],'sub_cat'); 
					}
		}
		
    }
	?>
<script>
 $('.start').datetimepicker();
 var curr_stamp=0;
 
 $(function(){
	$("#vis_ci_type").change(function(){
		var id   = $(this).val();
		var data = { 'vis_ci_type':id }; 
		$.ajax({
			url: 'index.php?vis_module=ticket&vis_operation=get_allassets',
			data: data,
			type: "POST",
			dataType: "json",
			success: function(response) {
				$("#assets_list").html('');
				if(response!=-1){
					$("#assets_list").html(response.list);
					$("#vis_show_asset_list").val('1');
					$(".selectpicker").selectpicker();
				}else{
					$("#ci_list").hide();
					$("#vis_show_asset_list").val('0');
				}
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});
	}); 
 });

function onchange_domain(id){
    window.location = '<? echo (defined('IS_WHMCS')?'submitticket.php':'index.php')?>?/ticket/get-department/domain/'+id;
}
function onchange_department(id){
	var sate = <?= VIS_SATELLITE_HELPDESK ;?>;
	var str = ( sate == 3) ? ('/domain/'+$('#vis_domain').val()) : '';
    window.location = '<? echo (defined('IS_WHMCS')?'submitticket.php':'index.php')?>?/ticket/get-department/department/'+id+str;
}
function submit_form(view_ticket) {
    if(curr_stamp==0 || (curr_stamp < (Date.now()-10000))){
        var btn = $("#btn_submit_ticket");
        btn.button('loading');
        curr_stamp = Date.now();
        var tempcustom=Array();
        var i=0;
         $('[id^="field"]' ).each(function(){
			if($(this).is(":checkbox") || $(this).is(":radio")){
				if($(this).is(":checked")){
				   tempcustom[i]={cid:this.id,value:this.value};
				   i=i+1;
				}
			}
			else {
				 tempcustom[i]={cid:this.id,value:$(this).val()};
				   i=i+1;
			   }
            });
          
			<? $dmn = (VIS_SATELLITE_HELPDESK == 2 || VIS_SATELLITE_HELPDESK == 3) ? '$("#vis_domain").val()' : $domainid; ?>
         $.ajax({
            url: 'index.php',
            dataType: 'json',
            data: {'vis_module':"ticket", 'vis_operation':"open_new_ticket", 'vis_firstname':$("#FirstName").val(), 'vis_lastname':$("#LastName").val(), 'vis_department':$("#vis_department").val(), 'vis_email':$("#PersonalEmail").val(), 'vis_priority':$("#vis_priority").val(),'vis_channel':'5','vis_attachments':$("#vis_attachments").html(), 'vis_type':$("#vis_type").val(),  'vis_category':$("#vis_category").val(), 'vis_subcategory':$("#vis_subcategory").val(), 'vis_item':$("#vis_item").val(), 'vis_ticket_level':$("#vis_ticket_level").val(), 'vis_assets_location':$("#vis_assets_location").val(),'vis_subject':$("#vis_subject").val(),'vis_assets':$("#vis_assets").val(), 'vis_ticket_post':$("#vis_ticket_post").val(), 'vis_status':'1', 'vis_status':'1', <? if($client['client_id']!='') { ?> 'vis_client':<? echo $client['client_id']; ?>,'vis_spam':<? echo $client['is_spam']; ?>,'vis_from_email':"<? echo $client['email']; ?>",'vis_from_name':"<? echo $client['first_name'].' '.$client['last_name']; ?>",<? } ?> 'vis_domain':<?= $dmn; ?><? if(IS_LOGIN!=1) { ?> ,'captchacode':$("#captchacode").val() <? } ?>,'vis_honeypot':$("#vis_honeypot").val(),'custom_field':tempcustom,'vis_ci_type':$("#vis_ci_type").val(),'vis_ci_attach':$("#vis_asset_id").val(),'vis_cilist_visible':$("#vis_show_asset_list").val()},
            type: "POST",
            success: function(data) {
                if(data.vis_submitted=='true')
                {
                    if(view_ticket==1)			 
                        window.location = "index.php?/ticket/view_ticket/"+data.vis_msg;	
                    else
                        window.location = "index.php?/ticket/submit-ticket/"+data.vis_msg;	

                }
                else if(data.vis_submitted=='false') { window.location = "index.php?/ticket/submit-ticket/"+data.vis_msg; }
                else if(data.vis_error_msg!='') { var btn = $("#btn_submit_ticket"); btn.button('reset'); $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").removeClass('alert-success').addClass('alert-danger'); $("#vis_submit_msg_div").html(data.vis_error_msg); window.scrollTo(0,0);}		 
            }
        });
    }
}
function vis_suggest_selfhelp(e) {
    $.ajax({
        url: 'index.php',
        data: {'vis_module':"selfhelp", 'vis_operation':"suggest_help", 'vis_topic':$(e).val() },
        type: "POST",
        success: function(data) {
            if(data!='') $("#vis_selfhelp_suggest_div").css('display', '');
            else $("#vis_selfhelp_suggest_div").css('display', 'none');
			$("#vis_selfhelp_suggest").css('display', '');
            $("#vis_selfhelp_suggest").html(data);
        }
    });
}
function vis_remove_attachment(attach_id){
	$.ajax({
        url: 'index.php',
        data: {'vis_module':"ticket", 'vis_operation':"remove_attachment", 'vis_attachment_id':attach_id },
        type: "POST",
        success: function(data) {  }
    });
    var attachments=$("#vis_attachment_count").val();
	$("#vis_attachment_count").val(eval(parseInt(attachments)-1));
	var max_attach=$("#vis_max_attach").val();
	if((attachments-1)<=max_attach) $("#vis_attach_file").css('display','');
}
$(function () {
	var url = 'index.php?vis_module=ticket&vis_operation=upload_file';
	$('#fileupload').fileupload({
		url: url,
		pasteZone : null,
		done: function (e, data) {
			if(data.result == 1) {
				  $("#vis_submit_err_div").show(); 
				 $("#vis_submit_err_div").html('<?php echo addslashes($vis_language['ERRORMSGEXTENSION']); ?>'); window.scrollTo(0,0);
				 setTimeout(function(){$("#vis_submit_err_div").hide();},10000);
				
			}
			else if(data.result == 2) {
				 $("#vis_submit_err_div").show(); 
				 $("#vis_submit_err_div").html('<?php echo $vis_language['MSGSIZEERROR']; ?>'); window.scrollTo(0,0);
				 setTimeout(function(){$("#vis_submit_err_div").hide();},10000);
				
			}
			else
			{
			    $("#vis_new_attachments").append(data.result);
				var max_attach=$("#vis_max_attach").val();
				var attachments=$("#vis_attachment_count").val();
				$("#vis_attachment_count").val(eval(parseInt(attachments)+1));
				if(attachments>=max_attach) $("#vis_attach_file").css('display','none');
				
			}
			 $('#progress').css( 'display','none');
			 $('#progress .progress-bar').css( 'width','0%');
		},
        progressall: function (e, data) {
			$('#progress').css( 'display','');
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .progress-bar').css(
                'width',
                progress + '%'
            );
        }
	});
});
$('#refresh').click(function() {  
    change_captcha();
 });
<? if(!defined('VIS_HEAD_MENU_HTML_EDITOR') || VIS_HEAD_MENU_HTML_EDITOR==1) { ?>    
$(function(){
	$('#vis_ticket_post').redactor({
		buttonSource: true,
		minHeight: 180, // pixels
		maxHeight: 180,
		imageUpload: "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_image_upload",
		fileUpload:  "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_file_upload",  
		imageUploadParam: 'files',		
		focus: true,
		plugins: ['source'],
		deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet']
	});
});
<? } ?>
function get_subcategory(catid) {
    $.ajax({
        url: 'index.php',
        data: {'vis_module':"staff", 'vis_operation':"get_ticket_drp_subcategory", 'vis_category_id':catid,'vis_client':'1'},
        type: "POST",
        success: function(data) {
            $("#ajax_subcategory").html(data);
            $(".selectpicker").selectpicker();
        }
    });
}
function getitem(subcat_id) {
    $.ajax({
        url: 'index.php',
        data: {'vis_module':"staff", 'vis_operation':"get_ticket_drp_item", 'vis_subcategory_id':subcat_id,'vis_client':'1'},
        type: "POST",
        success: function(data) {
            $("#ajax_item").html(data);
            $(".selectpicker").selectpicker();
        }
    });
}
function change_captcha(){
    document.getElementById('captcha').src="<?= VIS_PATH_TEMPLATE ?>get_captcha.php?clr=<? echo str_replace("#",'',VIS_THEME_COLOR); ?>&rnd=" + Math.random();
 }

$(function(){
   $("#vis_subject").focus();
});
 

</script>
<script src="<? echo VIS_PATH_SCRIPT; ?>file-upload/jquery.ui.widget.js"></script>
<script src="<? echo VIS_PATH_SCRIPT; ?>file-upload/jquery.fileupload.js"></script>
 <script src="<?php echo VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>

<script type="text/javascript">
$('body').on('drop', function (e) {
     return false;
});
$(document).on('click','.selectpicker',function(e){
	var winwdt=$(window).width();
	if(winwdt <810){
var lilen=$(this).next('#lst').children('ul').children().length;
$(this).next('#lst').css('overflow-y','scroll');
		if(lilen <3 && lilen>1)
		{$(this).next('#lst').css('min-height',(40*parseInt(lilen))+'px');
		}else{		$(this).next('#lst').css('min-height','120px');}
	}
	});
</script>

