<script>
$(".selectpicker").selectpicker();
</script>
<style type="text/css">.reporttxtb{ display:inline-block !important; width:auto !important;}</style>
<? global $vis_language; ?>
<? if($hideHeader == 0): ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6">
      <h3 class="m-b-xs text-black"><? echo $vis_language['TXTREPORTS']; ?></h3>
      <div>
         <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
            <li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
            <li class="active"><? echo $vis_language['TXTREPORTS']; ?></li>
         </ul>
      </div>
   </div>
   <div class="col-sm-6 text-right text-left-xs m-t-lg">
   <? include(VIS_PATH_TEMPLATE.'report_left_menu.php'); ?>
   </div>
</section>
<div class="col-lg-12">
<form name="vis_tickets_overview_report_frm" id="vis_tickets_overview_report_frm" class="form-horizontal" method="post">
<section class="panel panel-default">
<br />
<div style="padding-left:15px;">
 <div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab'])){if(isset($operation['vis_tab']) && $operation['vis_tab']==1){?>btn-primary<? }?> <? }else{?>btn-primary<? }?> " onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'1'});" ><? echo $vis_language['TXTTICKETOVERVIEW']; ?></a>  
			   </div>

<div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab']) && $operation['vis_tab']==7){?>btn-primary<? }?>" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'7'});" ><? echo $vis_language['TXTTICKETLOAD']; ?></a>  
			   </div>

<div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab']) && $operation['vis_tab']==2){?>btn-primary<? }?>" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'2'});" ><? echo $vis_language['TXTTICKETSBYTYPE']; ?></a>  
			   </div>
 <div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab']) && $operation['vis_tab']==3){?>btn-primary<? }?>" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'3'});" ><? echo $vis_language['TXTTICKETSBYCHANNELS']; ?></a>  
			   </div>
 <div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab']) && $operation['vis_tab']==4){?>btn-primary<? }?>" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'4'});" ><? echo $vis_language['TXTTICKETSBYPRIORITIES']; ?></a>  
			   </div>
 <div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab']) && $operation['vis_tab']==5){?>btn-primary<? }?>" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'5'});" ><? echo $vis_language['TXTTICKSBYSTATUS']; ?></a>  
			   </div>
<? /* ?><div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab']) && $operation['vis_tab']==6){?>btn-primary<? }?>" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'6'});" ><? echo $vis_language['TXTLEADERBOARD']; ?></a>  
			   </div><? */ ?>
<div class="btn-group m-b-xs">
			       <a class="rtpcls btn btn-sm btn-rounded btn-default <? if(isset($operation['vis_tab']) && $operation['vis_tab']==8){?>btn-primary<? }?>" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'8'});" ><? echo $vis_language['TXTTICKETSBYLABEL']; ?></a>  
			   </div>
      </div>

<div class="m-t" id="tickets_overview_div">
<div class="wrapper-sm b-b">
<div class="row">
<div class="col-sm-10">
   <?if($operation['vis_tab']!=7){?>
	<h5 class="m-t-none pull-left m-r">
  <!--<option value="0"><? //echo $vis_language['TXTSELDOM']; ?></option>-->
		   <div class="text-muted pull-center label_page"><? echo $vis_language['TXTDOMAIN'].":"; ?>
			 <select  name="domain_id" class="selectpicker domain_id " <? if(count($domain) > 10) echo 'data-live-search="true"' ?>>
				
				 <?php if($domain!=-1) for($i=0;$i<count($domain);$i++) if($i==0){ echo '<option value="'.$domain[$i]['domain_id'].'" selected>'.$domain[$i]['domain_name'].'</option>'; }else{echo '<option value="'.$domain[$i]['domain_id'].'">'.$domain[$i]['domain_name'].'</option>';} ?>
			 </select>
    </div>
	</h5>
	<h5 class="m-t-none pull-left m-r">
	  <div class="text-muted pull-center label_page"><? echo $vis_language['TXTDURATION'].":"; ?>
	  <button data-toggle="dropdown" class="btn btn-sm btn-default dropdown-toggle" id="criteria" >
		<span class="dropdown-label"><? echo $vis_language['TXTLAST7DAYS']; ?></span>
		<span class="caret"></span>
	  </button>
	  <ul class="dropdown-menu dropdown-select" >
		  <li><a href="javascript:void(0)" onclick="setCriteria(1); showData(1)"><input type="radio" name="b"><? echo $vis_language['TXTLAST30DAYS']; ?></a></li>
		  <li><a href="javascript:void(0)" onclick="setCriteria(2); showData(2)"><input type="radio" name="b"><? echo $vis_language['TXTLAST7DAYS']; ?></a></li>
		  <li><a href="javascript:void(0)" onclick="setCriteria(3); showData(3)"><input type="radio" name="b"><? echo $vis_language['TXTLAST24HOURS']; ?></a></li>
    <li><a href="javascript:void(0)" onclick="setCriteria(4); showData(4)"><input type="radio" name="b"><? echo $vis_language['TXTCUSTOM']; ?></a></li>
	  </ul>
	</div>
 </h5>
  
 	<h5 id="divid" class="m-t-none pull-left m-r" style="display:none;">
                     <span class=""><? echo $vis_language['TXTFROM']; ?>:</span>
                      <span class="from_date"> <input type="text" name="from_date" id="vis_<?= $operation['vis_operation'] ?>_from_date" value="<?= date(VIS_EDITDATETIMEPICKER_FORMAT,strtotime(date('Y-m-d H:i')." -3 months") + VIS_TIMEZONE);?>" class="input-sm form-control reporttxtb" /></span>
                  </h5>
  <h5 id="divid1" class="m-t-none pull-left m-r" style="display:none;">
 
                     <span class=""><? echo $vis_language['TXTTO']; ?>:</span>
                      <span class="to_date"> <input type="text" name="to_date" id="vis_<?= $operation['vis_operation'] ?>_to_date" value="" class="input-sm form-control reporttxtb" /></span>
                  </h5>
	<?} else{?>	
<h5 class="m-t-none pull-left m-r">
	<div class="text-muted pull-center label_page"><? echo $vis_language['TXTDEPARTMENT'].":"; ?>
	  <select name="department_id" class="selectpicker" id="department_id"  <? if(count($departments) > 10) echo 'data-live-search="true"' ?>>
	 <option value="0"><? echo $vis_language['TXTALLDEPARTMENTS']; ?></option>
				  <?php if($departments!=-1) for($i=0;$i<count($departments);$i++) {
					 echo '<option value="'.$departments[$i]['department_id'].'">'.$departments[$i]['domain_name'].' :'.$departments[$i]['department_name'].'</option>';} ?>
                  </select>
				  </div>
   </h5> 
   
   <h5 class="m-t-none pull-left m-r">
	<div class="text-muted pull-center label_page"><? echo $vis_language['TXTASSIGNEDTICKETS'].":"; ?>
	  <select name="vis_range" class="selectpicker" id="vis_range">
	  <option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
	  <option value="1"> <? echo $vis_language['TXTLESSTHAN']; ?> 1 </option>
	  <option value="2">  <? echo $vis_language['TXTBETWEEN']; ?> 1 to 25 </option>
	  <option value="3"> <? echo $vis_language['TXTBETWEEN']; ?> 26 to 50 </option>
	  <option value="4"> <? echo $vis_language['TXTMORETHAN']; ?> 50 </option>
	 </select>
	 </div>
   </h5> 
   
<?}?>	
	<input type="hidden" name="criteria" value="2" id="vis_criteria">
	<input type="hidden" name="department_id" value="0" id="department_id">
	<input type="hidden" name="vis_range" value="0" id="vis_range">
	</div>
	<div class="col-sm-2 pull-right"><a class="btn btn-primary btn-sm" onclick="$('#tickets_overview_div').visExecution('load_operations', {'vis_module':'report', 'vis_operation':'report_list', 'show_report': '1','vis_form':'vis_tickets_overview_report_frm','vis_tab':'1'});"><?= $vis_language['TXTGENERATE'] ?></a></div>
</div>
</div>

<div class="m-t" >
				  <section class="panel-info portlet-item">
					<div class="panel-body text-center">
					  <div class="list-group no-radius no-border text-xs text-left">
         <div class="rnd text-center" id="billing_quickview">
            <ul class="lg">
			    <li>
				    <h4><? echo $report['totalTicks']; ?></h4>
					<p><? echo $vis_language['TXTTOTALTICKETS']; ?></p>
				</li>
				<li>
					<h4><? echo $report['avgTicksHour']; ?></h4>
                    <p><? echo $vis_language['TXTTICKETSPERHOUR']; ?></p>
                </li>
			    <li>
					<h4><? echo $report['totalTicksReplied']; ?></h4>
					<p><? echo $vis_language['TXTTOTALTICKETSREPLIED']; ?></p>
				</li>
				<li>
					<h4><? echo $report['avgTicksReplHour']; ?></h4>
					<p><? echo $vis_language['TICKETSREPLEDPERHOUR']; ?></p>
                </li>
                <li>
				    <h4><? echo $report['totalTicksClosed']; ?></h4>
					<p><? echo $vis_language['TXTTOTALTICKETSCLOSED']; ?></p>
				</li>
				<li>
				  <h4><? echo $report['avgTicksClosedHour']; ?></h4>
				  <p> <? echo $vis_language['TXTTICKETSCLOSEDPERHOUR']; ?></p>
                </li>
                <li>
				   <h4><? echo $report['totalOverdueTicks']; ?></h4>
					<p><? echo $vis_language['TXTOTALOVERDUETICKETS']; ?></p>
				 </li>
				<li>
					<h4>
						<?	
							/*if($total_sla_seconds > $sla_used){
								$avg_sla_response_time = round($total_time,2);
							}else{*/
								$avg_sla_response_time = round(($total_time/$total_post),2);
							//}
                        	echo ($total_post==0?'0':count_remain_time($avg_sla_response_time)); 
						?>
                    </h4>
					<p><? echo $vis_language['TXTAVGRESPONSE']; ?></p>
                </li>
                <li>
					<? /*?><h4><? echo (($report_cnt==0)?0:round(((($responseCount+$resolutionCount)/count($report2))*100), 2)).'%' ?></h4><? */?>
                    <? /*?><h4><? echo (($report_cnt==0) ? 0 : round(((($responseCount)/count($report2))*100), 2)).'%';?></h4><? */?>
                    <h4><? echo (($report_cnt==0) ? 0 : round(((($responseCount)/$totalposts)*100), 2)).'%';?></h4>
					<p><? echo $vis_language['TXTAVGSLAMAINTAINED']; ?></p>
                </li>
			</ul>
         </div>
        
</div>
</div>
</section>
</div>
</div>
</section>
</form>
</div>
<? endif;?>

<script>
function getDetails(selOption)
{
	var selDomain = $('#vis_domain').val();
	if(selOption == 1)
	{
		$('#vis_billing_details_list').visExecution('load_module','<? echo $vis_language['TXTBILLING']; ?>',{'vis_module':'billing','vis_operation':'get_invoices', 'vis_headerd':true, 'vis_filter':'invoice_status=0 and domain_id= '+selDomain+' ','vis_title':'<? echo $vis_language['TXTUNPAID']; ?>'});
	}
	else if(selOption == 2)
	{
		$('#vis_billing_details_list').visExecution('load_module','<? echo $vis_language['TXTBILLING']; ?>',{'vis_module':'billing','vis_operation':'get_invoices', 'vis_headerd':true, 'vis_filter':'invoice_status=0 and domain_id= '+selDomain+'  and due_date<unix_timestamp()', 'vis_title':'<? echo $vis_language['TXTOVERDUE']; ?>'})
	}
	else if(selOption == 3)
	{
		$('#vis_billing_details_list').visExecution('load_module','<? echo $vis_language['TXTBILLING']; ?>',{'vis_module':'billing','vis_operation':'get_invoices', 'vis_headerd':true, 'vis_filter':'invoice_status=0 and domain_id= '+selDomain+'  and due_date>=unix_timestamp()', 'vis_title':'<? echo $vis_language['TXTNEW']; ?>'})
	}
	else if(selOption == 4)
	{
		$('#vis_billing_details_list').visExecution('load_module','<? echo $vis_language['TXTBILLING']; ?>',{'vis_module':'billing','vis_operation':'get_invoices', 'vis_headerd':true, 'vis_filter':'invoice_status=0 and domain_id= '+selDomain+'  and due_date>=<? echo mktime(0, 0, 0, date('n'), date('j'), date('Y')); ?> and due_date<unix_timestamp()+86400', 'vis_title':'1'})
	}
	else if(selOption == 5)
	{
		$('#vis_billing_details_list').visExecution('load_module','<? echo $vis_language['TXTBILLING']; ?>',{'vis_module':'billing','vis_operation':'get_invoices', 'vis_headerd':true, 'vis_filter':'invoice_status=1 and domain_id= '+selDomain+'  and paid_date>=<? echo mktime(0, 0, 0, date('n'), date('j'), date('Y')); ?> and paid_date<=(<? echo mktime(0, 0, 0, date('n'), date('j'), date('Y')); ?>+86400)', 'vis_title':'2'})
	}
	else
	{
	}
}
function setCriteria(criteria)
{
	$('#vis_criteria').val(criteria);
}

function showData(data)
{
    
    if(data=="4")
    {
         document.getElementById("divid").style.display="block";
         document.getElementById("divid1").style.display="block";
    }
    else
    {
         document.getElementById("divid").style.display="none";
         document.getElementById("divid1").style.display="none";
    }
}

$('.from_date').datetimepicker({
        format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
	 });
	 $('.to_date').datetimepicker({
			format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
	 });
	 $('.to_date').click();
	 $('.bootstrap-datetimepicker-widget').hide();
		
		$('.rtpcls').click(function() {
   $('.rtpcls').removeClass('btn-primary');
			$(this).addClass('btn-primary');
  });
			
		
		
</script>
