<?
    global $vis_language;
     $paging_list='';
    $prodStatus = array('1' => $vis_language['TXTACTIVE'],'2' => $vis_language['TXTPENDING'],'3' => $vis_language['TXTINCOMPLETE'],'4' => $vis_language['TXTCANCELED']);
    for($i=0;$i<$view_info['page_count'];$i++) $paging_list.='<option value="'.$i.'" '.(($product_info['page']==$i)?'selected="selected"':'').'>'.($i+1).'</option>';
    if(VIS_BILLING_VIEW_ACCESS==0) {echo $vis_language['MSGACCSSDND']; return false;}
    if($client_product_count!=0) {
?>
<? if($operation['vis_product']!=1){?><section class="padder"> <? } ?> 
         <div class="row wrapper clr">
         
            <div class="col-sm-9 tkt_left_menu"></div>
            <div  class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
               <select name="pageing" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_details_list').visExecution('load_area',{'vis_module':'billing', 'vis_operation':'client_products_list', 'vis_page':this.value ,'vis_client_id':'<? echo $operation['vis_client_id']; ?>'})">
               <? 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><? echo $vis_language['TXTPRODUCTID']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTTITLE']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTBILLINGCYCLE']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTPAIDDATE']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTEXPIRYDATE']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTAMOUNT']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTSTATUS']; ?></th>
      </tr>
   </thead>
   <tbody>
      <?
    for($i=0;$i<$client_product_count;$i++) {
		
		if($client_product[$i]['product_status'] == 2)
		{
			$lableCol = 'vh-danger-bg';
		}
		else if($client_product[$i]['product_status'] == 1)
		{
			$lableCol = 'label vh-green-bg';
		}
		else
		{
			$lableCol = 'label label-default';
		}	
		if($client_product[$i]['validity']==0) 
		{
			$expiry=$client_product[$i]['entry_date'];
		}
		else if($client_product[$i]['validity']==1) 
		{
			$current_date=format_date($client_product[$i]['entry_date']);
			$expiry = strtotime(date("Y-m-d", strtotime($current_date)) . "+1 month");
		}
		else if($client_product[$i]['validity']==2) 
		{
			$current_date=format_date($client_product[$i]['entry_date']);
			$expiry = strtotime(date("Y-m-d", strtotime($current_date)) . " +4 month");
		}
		else if($client_product[$i]['validity']==3) 
		{
			$current_date=format_date($client_product[$i]['entry_date']);
			$expiry = strtotime(date("Y-m-d", strtotime($current_date)) . " +6 month");
		}
		else if($client_product[$i]['validity']==4) 
		{
			$current_date=format_date($client_product[$i]['entry_date']);
			$expiry = strtotime(date("Y-m-d", strtotime($current_date)) . " +12 month");
		}
		
         echo '<tr><td><a href="javascript:void(0);" style="color:#797d87" class="text-muted" data-toggle="ajaxModal" data-modal-arguments="vis_module=billing&vis_operation=get_update_product_status&vis_invoice_id='.$client_product[$i]['invoice_id'].'&vis_static_area=vis_order_list_form&vis_page='.$view_info['page'].'" >#'.$client_product[$i]['product_id'].'</a></td><td>'.$client_product[$i]['title'].'</td><td>'.$vis_language['TXTVALIDITY'.$client_product[$i]['validity']].'</td><td>'.format_date($client_product[$i]['entry_date']).'</td><td>'.format_date($expiry).'</td><td>'.$client_product[$i]['amount'].'</td><td><span class="label '.$lableCol.'">'.$prodStatus[$client_product[$i]['product_status']].'</span></td></tr>';
    } ?>
   </tbody>
</table>
         </div>
         <footer class="wrapper panel-footer bg-white">
            <div class="row">
               <div class="col-sm-9 tkt_left_menu"></div>
               <div class="col-sm-3 text-right text-center-xs tkt_right_menu" id="paging">
                  <select name="pageing" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="$(this).parents('#vis_details_list').visExecution('load_area',{'vis_module':'billing', 'vis_operation':'client_products_list', 'vis_page':this.value,'vis_client_id':'<? echo $operation['vis_client_id']; ?>'})">
                  <? echo $paging_list;?>
                  </select>
                  <div class="text-muted pull-right label_page"><? echo $vis_language['TXTPAGE']; ?>:</div>
               </div>
            </div>
         </footer>
         <? }
    else {
     include(VIS_PATH_TEMPLATE.'no_record_yet.php');
    }
?>
  <? if($operation['vis_product']!=1){?></section><? } ?> 
<script type="text/javascript">
	$(".selectpicker").selectpicker();
   $(document).ready(function() {	
   $('[data-ride="datatables"]').dataTable({		
           "bPaginate" : false,	
            "aaSorting" : [],
   		"sDom": 't', "bAutoWidth": false,
   		"aoColumns": [
   		  	null,
   		  	null,
   		  	null,
   		  	null,
   		  	null,
   		  	null,
			null,
   		]
   	});
   });
</script>