<? global $vis_language; 
include_once(VIS_PATH_CLASS.VIS_CLASS_PREFIX.'client.php');
$database=new class_database();
$client_object=new class_client($database);
list($client_info, $clientdetails)=$client_object->get_client('client_id='.VIS_CLIENT_ID, '', 0, '', VIS_CLIENT_ID, VIS_LOCATION_AREA);
 $clientdetails=$clientdetails[0];
 
   $paging_list='';
      for($i=0;$i<$page_count;$i++) $paging_list.='<option value="'.$i.'" '.(($ticket_info['page']==$i)?'selected="selected"':'').'>'.($i+1).'</option>'; 
    $status=$operation['vis_status'];
     // echo"==status==".$status; ?>
<section  class="container">
	<div class="row">
	   <div class="col-md-12">
		  <section class="container m-t-md">
			 <? if(isset($operation['message']) && $operation['message']!='') { ?> <script> $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").html('<? echo $operation['message']; ?>'); </script><? }
				if(isset($operation['err_message']) && $operation['err_message']!='') { ?> <script> $("#vis_submit_err_div").show(); $("#vis_submit_err_div").html('<? echo $operation['err_message']; ?>'); </script><? } ?>          
			 <form class="vis_tickets_list_form" method="post" id="vis_task_form1" name="vis_task_form1">
				<?/*if($vis_count > 0 || $closed_total>0) {*/?>
				<div class="row padder clr">
					 <div class="col-sm-12 m-t-xs m-b" id="sortedby">
      <div class="b-b" style="padding-bottom:10px;">		  
		       <div class="btn-group m-b-xs"> 
			       <a class="btn btn-xs btn-rounded <?php echo ($status == 0)?' btn-primary ':'btn-default'; ?> filtab" onclick="vis_load_page_sort(0);"><? echo $vis_language['TXTUNSOLVED']; ?></a>  
			   </div>
			    <div class="btn-group m-b-xs"> 
			       <a class="btn btn-xs btn-rounded <?php echo ($status == 3)?' btn-primary ':'btn-default'; ?> filtab" onclick="vis_load_page_sort(3);"><? echo $vis_language['TXTSOLVED']; ?></a>  
			   </div>
      <? if($clientdetails['is_manager']==1){?>
			   <div class="btn-group m-b-xs">
			       <a class="btn btn-xs btn-rounded <?php echo ($status == 4)?' btn-primary ':'btn-default'; ?> filtab" onclick="vis_load_page_sort(4);"><? echo $vis_language['TXTORGANIZATION']; ?></a>  
			   </div>		
      <? }?>
      
      <div class="btn-group m-b-xs"> 
			       <a id="fitertb" class="btn btn-xs btn-rounded btn-default" onclick="$('#vis_filter_list').slideToggle();"><? echo $vis_language['TXTAPPLYFILTERCLIENT']; ?></a>  
			   </div>
      
		       </div>
         
					  <!--<div class="m-t-none pull-left m-r"><?= $vis_language['TXTVIEW']; ?>:
       <div class="btn-group" role="group">
					  <select onchange="vis_load_page_sort(this.value);" class="form-control input-sm <? if(!is_mobile()) echo 'selectpicker'; ?> paging v-middle pull-left" id="sorted_by" name="sorted_by">
						 <option value="0"><? echo $vis_language['TXTUNSOLVED']; ?></option>
						 <option value="3" <? if($status == 3) echo "selected=selected"?>><? echo $vis_language['TXTSOLVED']; ?></option>
						 <? if($clientdetails['is_manager']==1){?><option value="4" <? if($status == 4) echo "selected=selected"?> ><? echo $vis_language['TXTORGANIZATION']; ?></option><?}?>
					  </select>
       </div>
       </div>-->
					   
       
       
       
				   </div>
				  
      <div class="col-sm-12 clr">
      
     <div id="vis_filter_list" class="b-b m-b" style="display:none;">
     <? include_once(VIS_PATH_TEMPLATE.'advanced_search.php'); ?>
     <br />

     </div>
     </div>
     
     <div class="col-sm-8 m-t-xs">
     <div class="pull-left m-r">
        <div class="btn-group" role="group">
					 <div class="dropdown" id="viewslist">
 <button class="btn btn-default btn-sm dropdown-toggle action_btn" data-toggle="dropdown"> <span class="dropdown-label"><? echo $vis_language['TXTSORTBY']; ?>&nbsp;</span><span class="caret"></span></button>
 <ul name="sortby" class="dropdown-menu">
  <li><a href="javascript:void(0);" id="ordby_1" onclick="vis_load_page_view(0);"><? if($order==0){ echo '<i class="vh vh-check pull-right"></i>'; }?><? echo $vis_language['TXTMODIFICATIONDATE']; ?></a></li>
  <li><a href="javascript:void(0);" id="ordby_2" onclick="vis_load_page_view(1);"><? if($order==1){ echo '<i class="vh vh-check pull-right"></i>'; }?><? echo $vis_language['TXTCREATIONDATE']; ?></a></li>
 </ul>
</div>
       </div></div>
     </div>
				   <div class="col-sm-4 text-right text-center-xs tkt_right_menu m-t-n" id="clittkpagingt">
			     
				  <div class="btn-group">
					  <ul class="pagination-sm pagination" id="task_pagination"></ul>
				</div>
				   </div>
				   <input type="hidden" name="vis_status" id="vis_status" value="<?= $status; ?>"/>
				    <input type="hidden" name="vis_order" id="vis_order" value="<?= $order; ?>"/>
        <input type="hidden" name="sorted_byView" id="vis_sorted_byView" value="<?= $order; ?>"/>
				</div>
				<? /*} */?>
				<div class="list-unstyled padder m-b-none table-responsive scroll-x" id="vis_ticket_list" <? if($ticket_details==-1) echo 'style="display:none;"'; ?>>
				   <? include_once(VIS_PATH_TEMPLATE.'ticket_list.php'); ?>
				</div>
				 
				<div class="row padder clr m-b m-t" id="paging_bottom" <? if($ticket_details==-1) echo 'style="display:none;"'; ?>>
				   <div class="col-sm-8"></div>
				   <div class="col-sm-4 text-right text-center-xs tkt_right_menu" id="clittkpagingb">
					  <ul class="pagination-sm pagination" id="task_pagination1"></ul>
				   </div>
				   <input type="hidden" id="vis_status" value="<?= $status; ?>"/>
				</div>
				<section class="wrapper fullFrame" id="no_record_found" <? if($ticket_details!=-1) echo 'style="display:none;"'; ?>>
				   <div class="fullMiddle m-xl text-center h4"><?= $vis_language['TXTNOTHINGTODISPLAY']; ?></div>
				</section>
				<input type="hidden" name="vis_page" id="vis_page" value="">
				<input type="hidden" name="vis_module" value="ticket">
				<input type="hidden" name="vis_operation" value="view_ticket">
				<input type="hidden" name="vis_filter_enable" id="vis_filter_enable" value="">
			 </form>
		  </section>
	   </div>
	</div>
</section>
<script>
   <? if($page_count>0) {?>
       $('.pagination-sm').twbsPagination({
   		totalPages:<?php echo $page_count; ?>,
   		visiblePages:3,
   		first:false,
   		last:false,
   		onPageClick: function (event, page) {     
   		$.ajax({
   		url: 'index.php',
   		data: {'vis_module':"ticket", 'vis_operation':"view_ticket", 'vis_action':"<?= $operation['vis_action']?>",'vis_page':page-1, 'vis_form':'vis_task_form1', 'vis_change':1, 'vis_status':"<?= $operation['vis_status']?>", 'sorted_byView':"<?= $order;?>",'search_domain':"<?= $operation['search_domain']?>",'search_subject':"<?= $operation['search_subject']?>",'search_department':"<?= $operation['search_department']?>",'search_status':"<?= $operation['search_status']?>",'search_priority':"<?= $operation['search_priority']?>",'search_staff':"<?= $operation['search_staff']?>",'search_type':"<?= $operation['search_type']?>",'search_flag':"<?= $operation['search_flag']?>",'search_category':"<?= $operation['search_category']?>",'search_subcategory':"<?= $operation['search_subcategory']?>",'search_item':"<?= $operation['search_item']?>",'search_level':"<?= $operation['search_level']?>",'search_location':"<?= $operation['search_location']?>"},
   		type: "POST",
   		success: function(data) {            
   			$("#vis_ticket_list").html(data);
   		}
   		});
             }
         });
   <? }?>
   function vis_load_page(page) {
   	var status = $("#sorted_by").val();
   	$('#vis_page').val(page);
   	$('#vis_status').val(status);
   	$(".vis_tickets_list_form").submit();
   }
   function vis_load_page_sort(status) {
   	$('#vis_status').val(status);
   	$(".vis_tickets_list_form").submit();
   }
    function vis_load_page_view(view) {
   	$('#vis_order').val(view);
	$('#vis_sorted_byView').val(view);
   	$(".vis_tickets_list_form").submit();
   }
   
   function vis_apply_filter(page) {
	   //alert('hiiii');
	  var vis_filter_enable = 1;
	  $('#vis_filter_enable').val(vis_filter_enable);
	  $(".vis_tickets_list_form").submit();
      }
</script>
