<? global $vis_language; ?>
<? if($operation['vis_transaction']!=1){?>
<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['TXTTRANSACTIONS']; ?><span id="total_cnt"> (<? echo $transaction_info['count']; ?>)</span></h3>
	  <div>
		 <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
			<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><a class="link" href="#/billing/billing_menu/<? echo $vis_language['TXTBILLING'];?>"><? echo $vis_language['TXTBILLING']; ?></a></li>
			<li class="active"><? echo $vis_language['TXTTRANSACTIONS']; ?></li>
		 </ul>
		 </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>
<? }?>
<?
     $paging_list='';
    for($i=0;$i<$view_info['page_count'];$i++) $paging_list.='<option value="'.$i.'" '.(($transaction_info['page']==$i)?'selected="selected"':'').'>'.($i+1).'</option>';
    if($transactions==-1) include(VIS_PATH_TEMPLATE.'no_record_yet.php');
    else {
?>
<? if($operation['vis_transaction']!=1){?><section class="padder"><section class="panel panel-default"><? } ?>
 <form class="form-horizontal" role="form" id="vis_transaction_list_form" name="vis_transaction_list_form" method="post">
         <div class="row wrapper clr">
            <div class="col-sm-9 tkt_left_menu">
			<? if(isset($operation['vis_draft']) && $operation['vis_draft']==1) { ?>
			<div class="btn-group select">
			  </div>
			<? }
				else { ?>
			<div class="vis_mass_action">
			<div class="btn-group">
			  <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);" id="del_transaction" onclick="delete_transaction();"><? echo $vis_language['TXTDELETE']; ?></a></li>
				</ul>
			</div>
			</div>
			<? }//else ?>
		  </div>
            <div  class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
               	<? if($operation['vis_transaction']!=1): ?>
                <select name="pageing" class="input-sm form-control selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_workpanel_div').visExecution('load_area',{'vis_module':'billing', 'vis_operation':'get_transactions_list', 'vis_page':this.value})">
                <? else: ?>
				<select name="pageing" class="input-sm form-control selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_details_list').visExecution('load_area',{'vis_module':'billing', 'vis_operation':'get_transactions_list', 'vis_page':this.value,'vis_transaction':1, 'vis_page':this.value,'vis_client_id':'<? echo $operation['vis_client_id']; ?>'})">
                <? endif; ?>
               <? echo $paging_list;?>
               </select>
               <div class="text-muted pull-right label_page"><? echo $vis_language['TXTPAGE']; ?>:</div>
            </div>
         </div>
         <div class="table-responsive scroll-x">
			<table class="table table-hover b-t b-light m-b-none" data-ride="datatables">
   <thead class="table_head">
      <tr>
		 <th>
			<div class="btn-group">
				<label class="checkbox m-n m-r-sm i-checks"  style="float: left;"><input type="checkbox"><i></i></label>
			</div>
		 </th>
         <th><? echo $vis_language['TXTTRANSACTION']."#"; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTCLIENT']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTDESCRIPTION']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTCREATEDATE']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTAMOUNT']; ?></th>
         <th></th>
      </tr>
   </thead>
   <tbody>
      <?
		if($transactions!=-1) for($i=0;$i<count($transactions);$i++) {

        echo '<tr>';?>
        <?echo '<td width="30" id="checkbox_data"><label class="checkbox m-n i-checks"><input type="checkbox" name="vis_global_mass_chk_'.$i.'" id="vis_global_mass_chk_'.$i.'" value="'.$transactions[$i]['balance_id'].'" /><i></i></label></td>';	?>
        <td>#<? echo $transactions[$i]['transaction_id']; ?></td>
       <? echo '<td><a style="" href="#/client/client_details/'.$transactions[$i]['first_name'].' '.$transactions[$i]['last_name'].'/'.$transactions[$i]['client_id'].'" onclick="javascript:active_invoice('."'".$transactions[$i]['email']."'".');">'.$transactions[$i]['first_name'].' ('.$transactions[$i]['email'].')'.'</a></td>
        <td>'.$transactions[$i]['content'].'</td><td>'.format_datetime($transactions[$i]['entry_date']).'</td><td>'.$transactions[$i]['amount'].'</td>';?>
        <td align="center">
		<a class="text-muted"  href="javascript:void(0);"  data-toggle="ajaxModal" data-modal-arguments="vis_module=billing&vis_operation=get_delete_transaction&vis_transaction_id=<? echo $transactions[$i]['balance_id'];?>&vis_static_area=vis_ticket_transaction_form&vis_client_id=<? echo $transactions[$i]['client_id'];?>&vis_invoice_id=0" title="<? echo $vis_language['TXTDELETE']; ?>"><i class="vh vh-delete-round"></i></a></td>
		<input type="hidden" name="vis_client_id" value="<? echo $clientId;?>">
   <? } ?>
   </tbody>
</table>
         </div>
         <footer class="wrapper panel-footer bg-white">
            <div class="row">
            <div class="col-sm-9 tkt_left_menu">
			<? if(isset($operation['vis_draft']) && $operation['vis_draft']==1) { ?>
			<div class="btn-group select">
			  </div>
			<? }
				else { ?>
			<div class="vis_mass_action">
			<div class="btn-group">
			  <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);" id="del_transaction1" onclick="delete_transaction();"><? echo $vis_language['TXTDELETE']; ?></a></li>
				</ul>
			</div>
			</div>
			<? }//else ?>
		  </div>
               <div class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
				<? if($operation['vis_transaction']!=1): ?>
                  <select name="pageing" class="input-sm form-control selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_workpanel_div').visExecution('load_area',{'vis_module':'billing', 'vis_operation':'get_transactions_list', 'vis_page':this.value})">
                <? else: ?>
					<select name="pageing" class="input-sm form-control selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_details_list').visExecution('load_area',{'vis_module':'billing', 'vis_operation':'get_transactions_list','vis_transaction':1, 'vis_page':this.value,'vis_client_id':'<? echo $operation['vis_client_id']; ?>'})">
                <? endif; ?>
                  <? echo $paging_list;?>
                  </select>
                  <div class="text-muted pull-right label_page"><? echo $vis_language['TXTPAGE']; ?>:</div>
               </div>
            </div>
         </footer>
         </form>
         <? if($operation['vis_transaction']!=1){?></section></section><? } ?>
         <? } ?>

<script type="text/javascript">
	$(".selectpicker").selectpicker();
   $(document).ready(function() {
   $('[data-ride="datatables"]').dataTable({
           "bPaginate" : false,
            "aaSorting" : [],
   		"sDom": 't', "bAutoWidth": false,
   		"aoColumns": [
   		{ "bSortable": false },
   		  	null,
   		  	null,
   		  	null,
   		  	null,
   		  	null,
   			{ "bSortable": false }
   		]
   	});
   });
  /* $('#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 delete_transaction()
{
		var selected = [];
		var selected1 = [];
		var vis_action = "";
		$('#checkbox_data input:checked').each(function() {
		selected.push($(this).attr('name'));
		selected1.push($(this).attr('value'));
		vis_action +=$(this).attr('name')+"="+$(this).attr('value')+",";
		});
		if( selected.length > 0)
		{
			vis_action= vis_action.substring(0, vis_action.length-1);
			$('#del_transaction').attr('data-toggle','ajaxModal');
			$('#del_transaction').attr('data-modal-arguments','vis_module=billing&vis_operation=get_delete_transaction&vis_action='+vis_action+'&vis_static_area=vis_transaction_list_delete_area');
			$('#del_transaction1').attr('data-toggle','ajaxModal');
			$('#del_transaction1').attr('data-modal-arguments','vis_module=billing&vis_operation=get_delete_transaction&vis_action='+vis_action+'&vis_static_area=vis_transaction_list_delete_area');
		}
		 else
		{
			$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['MSGLGNTSEL'];?>");
			return false;
		}
}
</script>
