<? global $vis_language; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-4">
      <h3 class="m-b-xs text-black"><? echo $vis_language['TXTBILLING']; ?></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['TXTBILLING']; ?></li>
         </ul>
      </div>
   </div>
   <div class="col-sm-8 m-t-md pull-right">

    <div class="btn-group pull-right m-l">
			<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="#/billing/quick_view/<? echo $vis_language['TXTSUMMARY']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTSUMMARY']; ?>',{'vis_module':'billing', 'vis_operation':'quick_view'});"><? echo $vis_language['TXTSUMMARY']; ?></a></li>
			<li><a class="link" href="#/billing/get_orders/<? echo $vis_language['TXTORDERS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTORDERS']; ?>', {'vis_module':'billing', 'vis_operation':'get_orders'});"><? echo $vis_language['TXTORDERS']; ?></a></li>
			<li><a class="link" href="#/billing/get_invoices/<? echo $vis_language['TXTINVOICES']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTINVOICES']; ?>', {'vis_module':'billing', 'vis_operation':'get_invoices'})"><? echo $vis_language['TXTINVOICES']; ?></a></li>
			<li><a class="link" href="#/billing/get_transactions_list/<? echo $vis_language['TXTTRANSACTIONS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTTRANSACTIONS']; ?>', {'vis_module':'billing', 'vis_operation':'get_transactions_list'})"><? echo $vis_language['TXTTRANSACTIONS']; ?></a></li>
         </ul>
   </div>
		
		<div class="col-sm-6 input-group b-a b-2x rounded pull-right">
			<input class="form-control rounded input-sm no-border" type="text" placeholder="<?php echo $vis_language['TXTSEARCHINVOICE']."...";?>" value="<?php echo (isset($operation['vis_invoice_search']))?$operation['vis_invoice_search']:'';?>" id="search_invoice">
			<span class="input-group-btn rounded b-l b-3x">
			<button class="btn btn-sm btn-rounded bg-white b-white btn-icon" type="button" onclick=" var inv = $('#search_invoice').val(); if(inv.length>2){ $('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTINVOICES']; ?>', {'vis_module':'billing', 'vis_operation':'get_invoices','vis_invoice_search' : inv})} else { $('#vis_global_msg_div').visInterface('load_global_message', '<? echo $vis_language['TXTGLOBALSEARCHERROR'];?>'); }">
			<i class="vh vh-search"></i>
			</button>
			</span>
		</div>
   </div>
</section>
<div class="wrapper">
   <div class="bg-white b-a">
      <section class="panel-default">
         <header class="panel-heading sub_header"><? echo $vis_language['TXTSUMMARY']; ?></header>
      </section>
      <div class="panel-body">
         <form name="vis_billing_form" id="vis_billing_form" class="form-horizontal">
            <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 selectpicker"  <? if(count($domains)>10) echo 'data-live-search="true"';?> onchange="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTBILLING']; ?>',{'vis_module':'billing', 'vis_operation':'quick_view','vis_domain_id':$(this).val()});" >
                  <? for($i=0;$i<count($domains);$i++) echo '<option value="'.$domains[$i]['domain_id'].'" '.(($domain==$domains[$i]['domain_id'])?'selected="selected"':'').'>'.$domains[$i]['domain_name'].'</option>'; ?>
                  </select>
               </div>
            </div>
         </form>
         <div class="rnd text-center" id="billing_quickview">
            <ul class="lg">
               <li>
                  <h4><? echo ($income['today_income']=='')?0:$income['today_income']; ?></h4>
                  <p> <? echo stripslashes($vis_language['TXTTODAYS'])." ".$vis_language['TXTINCOME']; ?></p>
               </li>
               <li>
                  <h4><? echo ($income['month_income']=='')?0:$income['month_income']; ?></h4>
                  <p> <? echo $vis_language['TXTMONTH']." ".$vis_language['TXTINCOME']; ?></p>
               </li>
               <li>
                  <h4><? echo ($income['year_income']=='')?0:$income['year_income']; ?></h4>
                  <p> <? echo $vis_language['TXTYEAR']." ".$vis_language['TXTINCOME']; ?></p>
               </li>
            </ul>
             <ul class="lg">
			   <? if($invoice['total_unpaid'] > 0):?>
			    <li>
				   <a href="javascript:void(0);" onclick="getDetails(1)"><h4><? echo $invoice['total_unpaid']; ?></h4>
					  <p><? echo $vis_language['TXTUNPAID']." ".$vis_language['TXTINVOICE']; ?></p>
				   </a>
				<? else:?>
				<li>
					<h4><? echo $invoice['total_unpaid']; ?></h4>
                    <p><? echo $vis_language['TXTUNPAID']." ".$vis_language['TXTINVOICE']; ?></p>
				<? endif; ?>
               </li>
			   <? if($invoice['total_overdue'] > 0):?>
			    <li>
					<a href="javascript:void(0);" onclick="getDetails(2)">
					  <h4><? echo $invoice['total_overdue']; ?></h4>
					  <p><? echo $vis_language['TXTOVERDUE']." ".$vis_language['TXTINVOICE']; ?></p>
					</a>
				<? else: ?>
				<li>
					<h4><? echo $invoice['total_overdue']; ?></h4>
					<p><? echo $vis_language['TXTOVERDUE']." ".$vis_language['TXTINVOICE']; ?></p>
				<? endif; ?>
               </li>
               <? if($invoice['total_new'] > 0):?>
               <li>
				   <a href="javascript:void(0);" onclick="getDetails(3)">
					  <h4><? echo $invoice['total_new']; ?></h4>
					  <p> <? echo $vis_language['TXTNEW']." ".$vis_language['TXTINVOICE']; ?></p>
				   </a>
               <? else: ?>
               <li>
				  <h4><? echo $invoice['total_new']; ?></h4>
				  <p> <? echo $vis_language['TXTNEW']." ".$vis_language['TXTINVOICE']; ?></p>
               <? endif; ?>
               </li>
               <? if($invoice['today_due'] > 0):?>
               <li>
					<a href="javascript:void(0);" onclick="getDetails(4)">
					  <h4><? echo $invoice['today_due']; ?></h4>
					  <p> <? echo stripslashes($vis_language['TXTTODAYSDUE'])." ".$vis_language['TXTINVOICE']; ?></p>
					</a>
				<? else: ?>
				<li>
					<h4><? echo $invoice['today_due']; ?></h4>
					<p> <? echo stripslashes($vis_language['TXTTODAYSDUE'])." ".$vis_language['TXTINVOICE']; ?></p>
				<? endif; ?>
               </li>
               <? if($invoice['today_paid'] > 0){?>
               <li>
					<a href="javascript:void(0);" onclick="getDetails(5)">
					  <h4><? echo $invoice['today_paid']; ?></h4>
					  <p> <? echo stripslashes($vis_language['TXTTODAYSPAID'])." ".$vis_language['TXTINVOICE']; ?></p>
					</a>
              <?php } ?>

            </ul>
         </div>
</div>
</div>
</div>
<script>
$(".selectpicker").selectpicker();
</script>
<script>
	/* $('#search_invoice').keyup(function(e){
    if(e.keyCode == 13)
    {
        var search_string = $("#search_invoice").val();
		if(search_string.length < 3)
				$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['TXTGLOBALSEARCHERROR'];?>");
		else
        $.post("index.php?vis_module=billing&vis_operation=get_invoices&vis_tmpst="+new Date().getTime(), {'vis_invoice_search': search_string }, function(data) {
            $("#search_invoice").parent().addClass('open');
            $('#vis_workpanel_div').show().html(data);
        });
    }
});*/
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
	{

	}
}
</script>
