<?  global $vis_language;
    $paging_list='';
   // for($i=0;$i<$view_info['page_count'];$i++) $paging_list.='<option value="'.$i.'" '.(($ticket_info['page']==$i)?'selected="selected"':'').'>'.($i+1).'</option>';
  # print_r($operation);
    function get_lists($list, $operation, $options) {
		global $vis_language;
	    $name=$operation.'_name';
        $search = ($operation=='staff' && count($list)>9) ? ' data-live-search="true"' : ((count($list)>10) ? ' data-live-search="true"' : "");
        $return_value .= '<select class="form-control i-1x selectpicker" id="search_'.$operation.'" name="search_'.$operation.'" data-selector-label="Select"'.$search.'>';
        $return_value .='<option value="">'.$vis_language['TXTSELECT'].'</option>';
        if($operation=='staff') $return_value .= '<option value="0">'.$vis_language['TXTUNASSIGNED'].'</option>';
        $txt = $flag_color = $domain_id ='';
		for($i=0;$i<count($list);$i++) {
			if($operation=='flag') { $flag_color = 'style="color:'.$list[$i]['flag_color'].'"'; $txt = $list[$i][$name]; }
			else if($operation=='staff'){ $txt = $list[$i]['first_name'].' '.$list[$i]['last_name']; }
			else if($operation==strtolower($vis_language['TXTDEPARTMENT'])){
				if($domain_id=="" || ($domain_id!="" && $domain_id!=$list[$i]['domain_id'])){
					$domain_id = $list[$i]['domain_id'];
					if($i!=0) $return_value .= '</optgroup>';
				}
				$txt = $list[$i]['domain_name'] ." : ". $list[$i][$name];
			}
			else  $txt = $list[$i][$name];
			$return_value .= '<option value="'.$list[$i][$operation.'_id'].'" '.$flag_color.'>'.$txt.'</option>';
		}
		$return_value .= "</select>";
        return $return_value;
    }
?>
<section id="breadcrumb" class="row m-b m-l m-r">
	<div class="no-padder">
	<div class="pull-right m-t">
 <div class="btn-group">&nbsp;
 <? if($operation['vis_filter_id']==20){?>
	  <a class="btn btn-rounded btn btn-primary btn-sm dropdown-toggle" href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTITILREQUESTSERVICE']; ?>', {'vis_module':'ticket', 'vis_operation':'service_request'});"><i style="font-size:10px;" class="vh vh-plus"></i>  <? echo $vis_language['TXTNEW']; ?></a>
	 <?}else{?>
         <a class="btn btn-rounded btn btn-primary btn-sm dropdown-toggle" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&vis_operation=new_ticket_step_one&vis_static_area=vis_open_new_dialog"><i style="font-size:10px;" class="vh vh-plus"></i>  <? echo $vis_language['TXTNEW']; ?></a><? } ?>
      </div> 
      
	<?php if($operation['vis_filter_id']!=21 && $operation['vis_search']!=3){  ?>
	  <div class="btn-group">
		<div class="dropdown" id="viewslist">
			<button class="btn btn-default btn-sm dropdown-toggle action_btn" data-toggle="dropdown" onclick="$('#viewslist').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_view_list','filter_id':'<?= $operation['filter_id'];?>','view_id':'<?= $view_info['view_id']; ?>','view_operation':'<?= $view_info['vis_operation']; ?>'});">
			<span class="dropdown-label"><? echo $vis_language['TXTVIEWS']; ?></span>
			<span class="caret"></span>
			</button>
		</div>
	  </div>
	  <div class="btn-group">
		<div class="dropdown" id="labelslist">
			<button class="btn btn-default btn-sm dropdown-toggle action_btn" data-toggle="dropdown" onclick="$('#labelslist').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_label_list'});">
			<span class="dropdown-label"><? echo $vis_language['TXTLABELS']; ?></span>
			<span class="caret"></span>
			</button>
		</div>
	  </div>
   
   <div class="btn-group" id="filter_lists">
			<a title="<?= $vis_language['TXTFILTERLIST']; ?>" href="javascript:void(0);" class="btn btn-default btn-sm dropdown-toggle" onclick="$('#vis_filter_list').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_filter_list'});"><i style="font-size:10px;" class="vh vh-filter"></i></a>
		</div>
  
  <div class="btn-group">
			<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="vh vh-action text-muted"></i> <b class="caret"></b></button>
     <ul class="dropdown-menu dropdown-menu-right text-left">
          <li><a class="link" href="#/ticket/list_tags/<? echo $vis_language['TXTTAGS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTTAGS']; ?>', {'vis_module':'ticket', 'vis_operation':'list_tags'});"><? echo $vis_language['TXTTAGS']; ?></a></li>
			<li><a class="link" href="#/ticket/ticket_search/Search" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTSEARCH']; ?>', {'vis_module':'ticket', 'vis_operation':'ticket_search'})"><? echo $vis_language['TXTADVANCEDSEARCH']; ?></a></li>
   <li><a class="link" href="#/ticket/view_filters/<? echo $vis_language['TXTFILTERS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTFILTERS']; ?>', {'vis_module':'ticket', 'vis_operation':'view_filters'})"><? echo $vis_language['TXTFILTERS']; ?></a></li>
         </ul>
   </div>
  
	  <!--<ul class="navSeprator no-padder m-l m-t-xs pull-right m-b-n">
		<li ><a class="link" href="javascript:void(0);" onclick="$('#vis_filter_list').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_filter_list'});"><?= $vis_language['TXTFILTERLIST']; ?></a></li>
			<li><a class="link" href="#/ticket/list_tags/<? echo $vis_language['TXTTAGS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTTAGS']; ?>', {'vis_module':'ticket', 'vis_operation':'list_tags'});"><? echo $vis_language['TXTTAGS']; ?></a></li>
			<li><a class="link" href="#/ticket/ticket_search/Search" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTSEARCH']; ?>', {'vis_module':'ticket', 'vis_operation':'ticket_search'})"><? echo $vis_language['TXTADVANCEDSEARCH']; ?></a></li>
		</ul>-->
	<?php } ?>
	</div>
	<h3 class="m-b-xs text-black"><? echo (isset($operation['vis_draft']) && $operation['vis_draft']==1)?$vis_language['TXTDRAFT']:$operation['view_title']; ?><span id="total_cnt"> (<? echo ($ticket_info['total']=='')?0:$ticket_info['total']; ?>)</span></h3>
	<ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
        <li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><?= $vis_language['TXTHOME'];?></a></li>
		<? if($operation['vis_operation'] == 'filter_ticket_group') { ?>
		   <li><a class="link" href="#/ticket/filter_ticket/<? echo $vis_language['TXTTICKETS']; ?>/1"><?= $vis_language['TXTINBOX']; ?></a></li>
		  <?php /*?> <li><a class="link" href="#/ticket/filter_ticket/<? echo $operation['view_title']; ?>/<? echo $operation['filter_id']; ?>"><?=$operation['view_title']; ?></a></li><?php */?>
		<? } ?>
        <?  $filter_arr = array(1,5,6,7,21);
            $filter_id = isset($operation['vis_filter_id']) ? $operation['vis_filter_id'] : $operation['filter_id'];
            if($operation['vis_operation']=='search_label_tickets'
            || $operation['vis_operation']=='tag_search'
            || !in_array($filter_id, $filter_arr)
            && ($operation['vis_search']!=1
            && $operation['vis_search']!=2
			&& $operation['vis_search']!=3
            && $operation['vis_operation']!='filter_queue_ticket')){ ?> 
			<li><a class="link" href="#/ticket/filter_ticket/<? echo $vis_language['TXTTICKETS']; ?>/1"><?= $vis_language['TXTINBOX']; ?></a></li>
			<?php /*?><li><a class="link" href="#/ticket/filter_ticket/<? echo $operation['view_title']; ?>/<? echo $filter_id; ?>"><?= $operation['view_title'];?></a></li><?php */?>
			<? } ?>
        <? if($operation['vis_operation']=='tag_search'){ ?>
			<li><a class="link" href="#/ticket/list_tags/<? echo $vis_language['TXTTAGS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTTAGS']; ?>', {'vis_module':'ticket', 'vis_operation':'list_tags'});"><? echo $vis_language['TXTTAGS']; ?></a></li>
        <? } if($operation['vis_search']==2) { // saved filter list page ?>
        <li><a class="link" href="#/ticket/filter_ticket/<? echo $vis_language['TXTTICKETS']; ?>/1"><?= $vis_language['TXTINBOX']; ?></a></li>
        <li ><a class="link" href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTSEARCH']; ?>', {'vis_module':'ticket', 'vis_operation':'ticket_search'})"><? echo $vis_language['TXTSEARCH']; ?></a></li>
        <li ><a class="link" href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTFILTERS']; ?>', {'vis_module':'ticket', 'vis_operation':'view_filters'})"><? echo $vis_language['TXTFILTERS']; ?></a></li><? } ?>
<?  if($operation['vis_search']==3) { // saved filter list page ?>
        <li><a class="link" href="#/report/report_list/<? echo $vis_language['TXTREPORTS']; ?>"><? echo $vis_language['TXTREPORTS']; ?></a></li>
		   
        <li ><a class="link" href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTCUSTOM']; ?>', {'vis_module':'ticket', 'vis_operation':'view_filters','custom_show_report':'7'})"><? echo $vis_language['TXTCUSTOMREPORT']; ?></a></li><? } ?>
		
        <? if($operation['vis_search']==1) { // advanced search page ?>
        <li><a class="link" href="#/ticket/filter_ticket/<? echo $vis_language['TXTTICKETS']; ?>/1"><?= $vis_language['TXTINBOX']; ?></a></li>
        <li ><a class="link" href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTSEARCH']; ?>', {'vis_module':'ticket', 'vis_operation':'ticket_search','vis_is_report':1})"><? echo $vis_language['TXTSEARCH']; ?></a></li><? } ?>
        <? if(isset($operation['vis_operation']) && $operation['vis_operation']=='filter_queue_ticket') {?>
        <li><a class="link" href="#/ticket/filter_ticket/<? echo $vis_language['TXTTICKETS']; ?>/1"><?= $vis_language['TXTINBOX']; ?></a></li>
        <li class="active"><? echo $operation['view_title1']; ?> : <? echo (isset($operation['vis_draft']) && $operation['vis_draft']==1)?$vis_language['TXTDRAFT']:$operation['view_title']; ?></li>
        <? } else { ?>
        <li class="active"><? echo (isset($operation['vis_draft']) && $operation['vis_draft']==1)?$vis_language['TXTDRAFT']:$operation['view_title']; ?></li><? } ?>
	</ul>
  </div>
</section>
<section class="col-lg-12">
	<div class="wrapper bg-white clr" id="vis_filter_list" style="display:none;"></div>
</section>
<? if($ticket_details!=-1  && $ticket_details !='') {?>
<div class="col-lg-12">
	<form name="vis_ticket_form" id="vis_ticket_form" method="POST">
	<input type="hidden" id="vis_operation" value=<? echo $operation['vis_operation'];?> />
	
	

		<section class="panel panel-default">
		<div class="row wrapper clr" id="view_action">
		<header class="col-sm-12">
			<div class="pull-right" id="pg_1">
					<div class="btn-group">
						<div class="tkt_right_menu" id="paging" style="width:auto !important;">
							<div class="text-right">
	   <ul style="margin:0px;" class="pagination pagination-sm m-t-xs pagination_ticket_list"><li class="first"><a href="javascript:void(0);"><i class="vh vh-angle-double-left"></i></a></li><li class="prev"><a href="javascript:void(0);"><i class="vh vh-angle-left"></i></a></li><li class="page active"><a href="javascript:void(0);">1</a></li><li class="next"><a href="javascript:void(0);"><i class="vh vh-angle-right"></i></a></li><li class="last"><a href="javascript:void(0);"><i class="vh vh-angle-double-right"></i></a></li></ul>
	</div>
						</div>
					  </div>
                   <input type="hidden" name="vis_total_page" id="vis_total_page" value="<?= $view_info['page_count']; ?>"/>
                   <input type="hidden" name="vis_total_ticket" id="vis_total_ticket" value="<?= ($ticket_details!=-1)?count($ticket_details):0; ?>"/>
                   <? if(isset($operation['vis_group_id']) && $operation['vis_group_id']!=''){ ?>
                    <input type="hidden" name="vis_group_id" id="vis_group_id" value="<?= $operation['vis_group_id']; ?>"/>
                    <input type="hidden" name="vis_group_name" id="vis_group_name" value="<?= $operation['vis_group_name']; ?>"/>
				
                   <? } ?>
				  
				  </div>
			<div class="pull-right">
				<ul class="m-n footer_link">
					<li>
					  <? if($operation['vis_draft']!=1) { ?>
						  <input type="hidden" value="export" name="vis_module">
						  <input type="hidden" id="Exportall" name="Exportall">
						  <input type="hidden" value="ticket_export" name="vis_operation">
						  <input type="hidden" name="vis_filter_id" id= "vis_filter_id" value="<?php echo $operation['filter_id']; ?>">
						  <input type="hidden" value="<? echo $view_info['vis_operation']; ?>" id="vis_export_function" name="vis_export_function">
							<!--	<? //if($operation['view_title']=='Search Result' && isset($operation['vis_report']) && $operation['vis_report']==1) {
								//if(isset($operation['vis_is_report']) && $operation['vis_is_report']==1) { ?>
                            <a href="javascript:void(0);" class="link" data-toggle="ajaxModal" data-modal-arguments="vis_module=report&vis_operation=add_report_inqueue&vis_static_area=vis_open_new_dialog&vis_filter_id=<? echo $operation['filter_id'];?>&report_type=14" type="button"><? //echo $vis_language['TXTEXPORTALL']; ?></a><?// } ?>-->
						<? } ?>
					</li>
				</ul>
			</div> <!--/ .pull-right -->
			<div id="tkt_left_menu">
			  <?  if((isset($operation['vis_draft']) && $operation['vis_draft']==1) || $operation['vis_filter_id']==21) {  
			  			if((isset($operation['vis_draft']) && $operation['vis_draft']==1) ||($operation['vis_filter_id']==21 && VIS_SCHEDULE_TICKET_MANAGE_ACCESS == 1)){ ?>
				<div class="btn-group select vis_mass_action hide">
				  <div class="btn bg-empty btn-sm action_btn" onclick="$('#vis_global_msg_div').visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'delete_ticket','vis_filter_id': <?php echo $operation['vis_filter_id']; ?>, 'vis_form': 'vis_ticket_form'})"><?= $vis_language['TXTDELETE'];?></div>
				  </div>
				<? } }
				elseif($operation['vis_filter_id']==5) { ?>
					<div class="btn-group vis_mass_action hide">
						<div class="btn bg-empty btn-sm action_btn" onclick="$('#vis_global_msg_div').visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'delete_ticket', 'vis_filter_id': 5, 'vis_form': 'vis_ticket_form'})"><?= $vis_language['TXTDELETE'];?></div>
					</div>
					<? if(VIS_ADMIN_ACCESS!=-1){?>
						<div class="btn-group">
							<div class="btn bg-empty btn-sm action_btn" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&vis_operation=confirm_delete_trash&vis_static_area=vis_trash_conf"><?= $vis_language['TXTEMPTYTRASH'];?></div>
						</div>
					<? } ?>
					<div class="btn-group">
						<div class="btn bg-empty btn-sm action_btn" onclick="$(this).visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'update_properties', 'vis_action': 'delete', 'vis_form': 'vis_ticket_form', 'vis_update_id': 0})"><?= $vis_language['TXTMOVETOINBOX'];?></div>
					</div>
				<?  }
				else { ?>
				<div class="vis_mass_action hide">
                    <div class="pull-left">
                      <button class="btn bg-empty btn-sm dropdown-toggle action_btn" data-toggle="dropdown">
                        <i class="vh vh-action"></i> <span class="caret"></span>
                      </button>
                        <ul class="dropdown-menu">
							<li><a href="javascript:void(0);" onclick="$('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'is_read', 'vis_form':'vis_ticket_form', 'vis_update_id':1,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTMARKREAD']; ?></a></li>
							<li><a href="javascript:void(0);" onclick="$('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'is_read', 'vis_form':'vis_ticket_form', 'vis_update_id':0,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTMARKUNREAD']; ?></a></li>
                            <li><a href="javascript:void(0);" id="merge_ticket" onclick="merge_ticket();"><? echo $vis_language['TXTMERGETICKET']; ?></a></li>
							<li><a href="javascript:void(0);" id="link_ticket" onclick="get_tickets_link();"><? echo $vis_language['TXTLINKTICKET']; ?></a></li>
                            <li><a href="javascript:void(0);" id="del" onclick="change_sla();" ><?= $vis_language['TXTCHANGESLA'] ?></a></li>
                            <li><a href="javascript:void(0);" onclick="$('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'delete', 'vis_form':'vis_ticket_form', 'vis_update_id':1,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTMOVETOTRASH']; ?></a></li>
                            <?
                            if($operation['vis_filter_id']==6) {?>
                                <li><a href="javascript:void(0);" onclick="$('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'spam', 'vis_form':'vis_ticket_form', 'vis_update_id':0});"><? echo $vis_language['TXTREMOVESPAM']; ?></a></li><?
                            }
                            else { ?>
                                <li><a href="javascript:void(0);" onclick="$('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'spam', 'vis_form':'vis_ticket_form', 'vis_update_id':1,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTMARKSPAM']; ?></a></li><?
                            }?>
                            <li><a href="javascript:void(0);" onclick="$('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'ban', 'vis_form':'vis_ticket_form', 'vis_update_id':1,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTBAN']; ?></a></li>
                            <? $link=(VIS_EXPORT_TO_PDF_ACCESS==1)?'onclick="show_access(1);"':'onclick="show_access(2);"';?>
                            <li><a href="javascript:void(0);" <?= $link;?>><? echo $vis_language['TXTEXPORTTOPDF']; ?></a></li>
							<li><a href="javascript:void(0);" id="reply_ticket" onclick="reply_ticket();"><? echo $vis_language['TXTMASSREPLY']; ?></a></li>
                        </ul>
                    </div>
                    <div class="pull-left" id="get_staff_up">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_staff_up').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_staff', 'vis_subaction': 'up', 'vis_staff_location': 1});"><span class="filter-option pull-left"><?= $vis_language['TXTASSIGNTO']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_departments_up">
						<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_departments_up').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_departments', 'vis_subaction': 'up'});"><span class="filter-option pull-left"><?= $vis_language['TXTMOVETO']; ?>&nbsp;</span><span class="caret"></span></button>
			        </div>
                    <div class="pull-left" id="get_status_up">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_status_up').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_status', 'vis_subaction': 'up'});"><span class="filter-option pull-left"><?= $vis_language['TXTSTATUS']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_priorities_up">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_priorities_up').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_priorities', 'vis_subaction': 'up'});"><span class="filter-option pull-left"><?= $vis_language['TXTPRIORITY']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_types_up">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_types_up').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_types', 'vis_subaction': 'up'});"><span class="filter-option pull-left"><?= $vis_language['TXTTYPE']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_flags_up">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_flags_up').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_flags', 'vis_subaction': 'up'});"><span class="filter-option pull-left"><?= $vis_language['TXTFLAG']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_labels_up">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_labels_up').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_labels', 'vis_subaction': 'up'});"><span class="filter-option pull-left"><?= $vis_language['TXTLABELS']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                </div>
				<? } ?>
			</div>
		</header>
		</div>
			<div class="table-responsive scroll-x" id="vis_ticket_list"> 
			
			<? include_once(VIS_PATH_TEMPLATE.'ticket_list.php'); ?>
                <input type="hidden" id="vis_domain_id" name="vis_domain_id" value="<?= $operation['vis_domain_id']; ?>" />
			</div>
			<footer class="wrapper panel-footer bg-white">
			  <div class="row">
				  <div class="col-sm-9 tkt_left_menu" id="tkt_left_menu">
				<? if((isset($operation['vis_draft']) && $operation['vis_draft']==1)|| $operation['vis_filter_id']==21) {
						if((isset($operation['vis_draft']) && $operation['vis_draft']==1) ||($operation['vis_filter_id']==21 && VIS_SCHEDULE_TICKET_MANAGE_ACCESS == 1)){ ?>
				<div class="btn-group dropup vis_mass_action hide">
				  <div class="btn bg-empty btn-sm action_btn" onclick="$('#vis_global_msg_div').visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'delete_ticket','vis_filter_id': <?php echo $operation['vis_filter_id']; ?>, 'vis_form': 'vis_ticket_form'})"><?= $vis_language['TXTDELETE'];?></div>
				  </div>
				<? } }
				elseif($operation['vis_filter_id']==5) { ?>
					<div class="btn-group vis_mass_action hide">
						<div class="btn bg-empty btn-sm action_btn" onclick="$('#vis_global_msg_div').visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'delete_ticket', 'vis_filter_id':5, 'vis_form': 'vis_ticket_form'})"><?= $vis_language['TXTDELETE'];?></div>
					</div>
					<? if(VIS_ADMIN_ACCESS!=-1){?>
						<div class="btn-group">
							<div class="btn bg-empty btn-sm action_btn" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&vis_operation=confirm_delete_trash&vis_static_area=vis_trash_conf"><?= $vis_language['TXTEMPTYTRASH'];?></div>
						</div>
					<? } ?>
					<div class="btn-group">
						<div class="btn bg-empty btn-sm action_btn" onclick="$(this).visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'update_properties', 'vis_action': 'delete', 'vis_form': 'vis_ticket_form', 'vis_update_id': 0})"><?= $vis_language['TXTMOVETOINBOX'];?></div>
					</div>
				<? }
				else { ?>
				<div class="vis_mass_action_footer hide">
				<div class="pull-left">
				  <button type="button" class="btn bg-empty btn-sm dropdown-toggle action_btn" data-toggle="dropdown">
					<i class="vh vh-action"></i>
					<span class="caret"></span>
				  </button>
					<ul class="dropdown-menu" role="menu">
						<li><a href="javascript:void(0);" id="merge_ticket1" onclick="merge_ticket();"><? echo $vis_language['TXTMERGETICKET']; ?></a></li>
						<li><a href="javascript:void(0);" id="link_ticket1" onclick="get_tickets_link();"><? echo $vis_language['TXTLINKTICKET']; ?></a></li>
						 <li><a href="javascript:void(0);" id="del1" onclick="change_sla();" ><?= $vis_language['TXTCHANGESLA'] ?></a></li>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'delete', 'vis_form':'vis_ticket_form', 'vis_update_id':1,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTMOVETOTRASH']; ?></a></li>
						<?
						if($operation['vis_filter_id']==6) {?>
							<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'spam', 'vis_form':'vis_ticket_form', 'vis_update_id':0});"><? echo $vis_language['TXTREMOVESPAM']; ?></a></li><?
						}
						else { ?>
							<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'spam', 'vis_form':'vis_ticket_form', 'vis_update_id':1,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTMARKSPAM']; ?></a></li><?
						}?>
						<li><a href="javascript:void(0);" onclick="$(this).visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action':'ban', 'vis_form':'vis_ticket_form', 'vis_update_id':1,'view_title':'<? echo $operation['view_title'];?>'});"><? echo $vis_language['TXTBAN']; ?></a></li>
						<? $link=(VIS_EXPORT_TO_PDF_ACCESS==1)?'onclick="show_access(1);"':'onclick="show_access(2);"';?>
						<li><a href="javascript:void(0);" <?= $link;?>><? echo $vis_language['TXTEXPORTTOPDF']; ?></a></li>
						<li><a href="javascript:void(0);" id="reply_ticket1" onclick="reply_ticket();"><? echo $vis_language['TXTMASSREPLY']; ?></a></li>
					</ul>
				</div>
				<div class="pull-left" id="get_staff_down">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_staff_down').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_staff', 'vis_subaction': 'down', 'vis_staff_location': 1});"><span class="filter-option pull-left"><?= $vis_language['TXTASSIGNTO']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_departments_down">
						<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_departments_down').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_departments', 'vis_subaction': 'down'});"><span class="filter-option pull-left"><?= $vis_language['TXTMOVETO']; ?>&nbsp;</span><span class="caret"></span></button>
			        </div>
                    <div class="pull-left" id="get_status_down">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_status_down').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_status', 'vis_subaction': 'down'});"><span class="filter-option pull-left"><?= $vis_language['TXTSTATUS']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_priorities_down">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_priorities_down').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_priorities', 'vis_subaction': 'down'});"><span class="filter-option pull-left"><?= $vis_language['TXTPRIORITY']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_types_down">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_types_down').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_types', 'vis_subaction': 'down'});"><span class="filter-option pull-left"><?= $vis_language['TXTTYPE']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_flags_down">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_flags_down').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_flags', 'vis_subaction': 'down'});"><span class="filter-option pull-left"><?= $vis_language['TXTFLAG']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
                    <div class="pull-left" id="get_labels_down">
                        <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="$('#get_labels_down').visExecution('load_operations', {'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action': 'get_labels', 'vis_subaction': 'down'});"><span class="filter-option pull-left"><?= $vis_language['TXTLABELS']; ?>&nbsp;</span><span class="caret"></span></button>
                    </div>
			</div>
				<? } ?>
			  </div>
			  <div class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
				<input type="hidden" name="pdf_set" id="pdf_set" value="" />
					<div class="text-right">
	   <ul style="margin:0px;" class="pagination pagination-sm m-t-xs pagination_ticket_list"><li class="first"><a href="javascript:void(0);"><i class="vh vh-angle-double-left"></i></a></li><li class="prev"><a href="javascript:void(0);"><i class="vh vh-angle-left"></i></a></li><li class="page active"><a href="javascript:void(0);">1</a></li><li class="next"><a href="javascript:void(0);"><i class="vh vh-angle-right"></i></a></li><li class="last"><a href="javascript:void(0);"><i class="vh vh-angle-double-right"></i></a></li></ul>
	</div>
			  </div>

			  </div>
			</footer>
		  </section>
	</form>
</div>
<section class="fullFrame m-n" id="vis_no_record_search" style="display:none;">
</section>
<? }
else
{
	include(VIS_PATH_TEMPLATE.'no_record_yet.php');
} ?>
<script type="text/javascript">
	function change_sla(){
		var selected = [];		var vis_action = "";
		$('#checkbox_data input:checked').each(function() {
		selected.push($(this).attr('value'));
		vis_action +=$(this).attr('value')+",";
		});
		if( selected.length > 0){ 
			 vis_action= vis_action.substring(0, vis_action.length-1);
			 $('#del, #del1').attr('data-toggle','ajaxModal');
			 $('#del, #del1').attr('data-modal-arguments','vis_module=ticket&vis_operation=get_sla_plan&vis_ticket_id='+vis_action+'&vis_form=vis_sla_form&vis_static_area=vis_set_sla_form&vis_inbox=1');
			  }
}
function submit_form_export(tabid,ticket_count){
	if(ticket_count==0) $("#vis_global_msg_div").visInterface("load_global_message", "<?php echo $vis_language['MSGERROPRT']; ?>");
	else if ($('#vis_ticket_form input:checkbox:checked').length > 0){
        $("#Exportall").attr('disabled',true);
        $('#vis_ticket_form').submit();
        $("#Exportall").attr('disabled',false);
    }
	else $("#vis_global_msg_div").visInterface("load_global_message", "<?php echo $vis_language['MSGSNGLTKTEXPORT']; ?>");
}
function vis_apply_filter(vis_page, vis_filter_id){
	var data=arg='', ticket_operation=$("#vis_export_function").val();
	if(vis_page!=undefined && typeof(vis_page)!=undefined && vis_filter_id!=undefined && typeof(vis_filter_id)!=undefined){
		if(vis_filter_id==1 && ticket_operation=='filter_ticket_group') arg = 'filter_ticket_group';
        else if(vis_filter_id>0) arg = 'filter_ticket';
		else arg = ticket_operation;
        data = {'vis_module':'ticket', 'vis_operation':'apply_filter', 'ticket_operation': arg, 'vis_filter_id':vis_filter_id, 'vis_page':vis_page <? if(isset($operation['vis_group_id']) && $operation['vis_group_id']!=''){ ?>, 'vis_group_id':<?= $operation['vis_group_id']; ?>, 'vis_group_name':'<?= $operation['vis_group_name']; ?>'<? } ?>};
	
	}
	else{
		internal_ticket_check ='';
		var txt = txt1 = "";
	    {$("#vis_filter_list [id^='search_']").each(function() { if( $( this ).val() != "") txt1=1 });}
	    if($("#search1_internal_ticket").is(":checked")==true) txt=1; else if($("#search1_internal_ticket").is(":checked")==false) txt="";
		if(txt=="" && txt1==""){ $("#vis_global_msg_div").visInterface("load_global_message", "Please select any field");  return;}
		if($("#search1_internal_ticket").is(":checked")) internal_ticket_check='1'; else internal_ticket_check='0';
		data = {'vis_module':'ticket','vis_operation':'apply_filter', 'ticket_operation': 'filter_ticket','view_title':'<? echo $operation['view_title'];?>','vis_filter_enable': 1, 'search_domain':$("#search_domain").val(), 'search_dept':$("#search_department").val(), 'search_status':$("#search_status").val(),'search_priority':$("#search_priority").val(),'search_owner':$("#search_staff").val(),'search_type':$("#search_type").val(),'search_flag':$("#search_flag").val(),'search_category':$("#search_category").val(),'search_subcategory':$("#search_subcategory").val(),'search_item':$("#search_item").val(),'search_level':$("#search_level").val(),'search_location':$("#search_location").val() , 'search_internal_ticket':+internal_ticket_check };
	
	}
	$.ajax({
		url: 'index.php?vis_tmpst=new Date().getTime()',
		data: data,
		type: "POST",
		dataType: "json",
		success: function(data) {
		
            if (data.fid) {
                    document.location = "#/ticket/filter_ticket/Tickets/" + data.fid;
            } else {
                $("#total_cnt").html('('+data.total_cnt+')');
                /*$(".tkt_right_menu").html(data.paging);*/
                $("#vis_ticket_list").html(data.list);
                $("#vis_filter_id").val(data.filter_id);
                $("#vis_total_page").val(data.total_pages);
                $("#vis_total_ticket").val(data.total_tickets);
                if(data.total_cnt==0){
                    $("#vis_no_record_search").show();
                    $("#vis_no_record_search").html(data.list);
                }else $("#vis_no_record_search").hide();
                toggle_mass_actions(); // To disable header & footer mass actions on list pages
            }
		},
		error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
	});
}
function update_properties(new_value, selector){
	var dept = new Array(); var vis_action='';
	$("[id^='vis_ticket_mass_chk_']:checked").each(function(i){
		var status = vis_action = '';
		var dept_id = $(this).attr('data-dept-id');
		var old_status_id = $(this).attr('data-status');
		if(selector == 2){ // status
			vis_action = 'status';
			vis_dept=dept_id;
			if(new_value!=3 && $("#vis_lp_department_"+dept_id+"_status_"+new_value).length){ status += new_value + ','; }
			if(old_status_id!=3 && $("#vis_lp_department_"+dept_id+"_status_"+old_status_id).length){ status += old_status_id; }
			if(status!='') dept[i] = dept_id + '-'+status;
		}
		else if(selector == 1){ // dept
			vis_action = 'department';
			if(old_status_id != 3 && $("#vis_lp_department_"+dept_id+"_status_"+old_status_id).length){
				dept[i++] = dept_id + '-'+old_status_id;
			}
			if(old_status_id != 3 && $("#vis_lp_department_"+new_value+"_status_"+old_status_id).length){
				dept[i++] = new_value + '-'+old_status_id;
			}
		}
	});
	$('#vis_global_msg_div').visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'update_properties', 'vis_action': vis_action, 'vis_form':'vis_ticket_form', 'vis_update_id': new_value ,'vis_dept_id':'<? echo $operation['vis_department_id'];?>', 'dept': dept });
}
function vis_change_view(update_id,ticket_module,filter_id) {
       $.ajax({
           url: 'index.php?vis_module=staff&vis_operation=update_properties&vis_action=view',
           data: { 'vis_update_id':update_id,'ticket_module':ticket_module,'vis_filter_id':filter_id },
           type: "POST",
           success: function(data) {
              $('#vis_global_msg_div').html(data);
           }
       });
   }
    function update_ticket_property(update_id,action_id) { // update owner properties i.e. assign new/remove
        if(action_id==2){
            update_properties(update_id, 1);
        }else if(action_id==3){
            update_properties(update_id, 2);
        }else{
            var dept = new Array(); var vis_action='';
            $("[id^='vis_ticket_mass_chk_']:checked").each(function(i){
                var dept_id = $(this).attr('data-dept-id');
                dept[i] = dept_id + '-'+dept_id;

            });
            if(action_id==1) var action='staff';
            else if(action_id==4) var action='priority';
            else if(action_id==5) var action='type';
            else if(action_id==6) var action='flag';
            else if(action_id==7) var action='label';
            $('#vis_global_msg_div').visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'update_properties', 'vis_action': action, 'vis_form':'vis_ticket_form', 'vis_update_id': update_id ,'vis_dept_id': '<? echo $operation['vis_department_id'];?>','dept':dept});
        }
    }
   function merge_ticket(){
		var selected = [];  var vis_action='';
		$('#checkbox_data input:checked').each(function() {
		selected.push($(this).attr('value'));
		vis_action +=$(this).attr('value')+",";
		});
		if( selected.length > 0){
			 vis_action= vis_action.substring(0, vis_action.length-1);
			 $('#merge_ticket, #merge_ticket1').attr('data-toggle','ajaxModal');
			 $('#merge_ticket, #merge_ticket1').attr('data-modal-arguments','vis_module=ticket&vis_operation=get_tickets_merge&vis_ticket_id='+vis_action+'&vis_form=vis_ticket_form');
    }
	}
	function get_tickets_link(){
		var selected = [];  var vis_action='';
		$('#checkbox_data input:checked').each(function() {
		selected.push($(this).attr('value'));
		vis_action +=$(this).attr('value')+",";
		});
		if( selected.length > 0){
			 vis_action= vis_action.substring(0, vis_action.length-1);
			 $('#link_ticket, #link_ticket1').attr('data-toggle','ajaxModal');
			 $('#link_ticket, #link_ticket1').attr('data-modal-arguments','vis_module=ticket&vis_operation=get_tickets_link&vis_ticket_id='+vis_action+'&vis_filter_id=<?=$operation['vis_filter_id']?>&vis_form=vis_ticket_form');
    }
	}
function show_access(data){
	if(data==1){ 
		$("#pdf_set").val(1);
		$("#vis_ticket_form").attr("target", "_blank");submit_form_export(<? echo $operation['filter_id'];?>,<? echo $ticket_info['ticket_count'];?>);
	}else{
		$("#pdf_set").val('');
		$("#vis_global_msg_div").visInterface("load_global_message", "<?php echo  $vis_language['MSGACCSSDND'] ;?>");
		return false;
	}
}
	function reply_ticket(){
		var selected = []; var vis_action='';
		$('#checkbox_data input:checked').each(function() {
		selected.push($(this).attr('value'));
		vis_action +=$(this).attr('value')+",";
		});
		if( selected.length > 0){
			 vis_action= vis_action.substring(0, vis_action.length-1);
			 $('#reply_ticket, #reply_ticket1').attr('data-toggle','ajaxModal');
			 $('#reply_ticket, #reply_ticket1').attr('data-modal-arguments','vis_module=ticket&vis_operation=get_tickets_reply&vis_ticket_id='+vis_action+'&vis_form=vis_ticket_form');
		 }
	}
	
	$('.pagination_ticket_list').twbsPagination({
totalPages:<?php echo $view_info['page_count']; ?>,visiblePages:3,startPage: 1,first:'<i class="vh vh-angle-double-left"></i>',prev:'<i class="vh vh-angle-left"></i>',next:'<i class="vh vh-angle-right"></i>',last:'<i class="vh vh-angle-double-right"></i>',
	onPageClick: function (event, page) { page=parseInt(page)-1;	vis_apply_filter(page,'<?= $operation['filter_id'];?>');}
});


	
</script>
