<?php require('includes/finance/finance_functions.php');?>

<div class="col-md-12 mt-n5">
<p class="lead">Renewals this month</p>
<table id="expenseTable" class="table table-sm table-striped">
<thead>
<tr>
<th>Client</th>
<th>Agent</th>
<th>Status</th>
<th>Amount</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php 
$stmt = $GLOBALS['con']->prepare("SELECT * FROM `clientdetails` ORDER BY abs(renewal_date) ASC")or die(mysqli_error("GET_INV_NO: ".$GLOBALS['con']));
$stmt->execute();$iv=$stmt->get_result();$stmt->close();
while($list=mysqli_fetch_array($iv)){
if($list['renewal_date']!=="" && $list['renewal_status']!="LAPSED"){
$status=countdown($list['renewal_date'],"no");

if($status=="NULL"){}else{?>
<tr id="R<?php echo $list['clientnumber']?>">
<td class="align-middle"><a href="index.php?t=includes/master&p=client.php&clientnumber=<?php echo $list['clientnumber']?>&view=edit"><?php echo $list['clientname']?></a></td>
<td class="align-middle"><a href="index.php?t=includes/master&p=agent.php&agent_number=<?php echo $list['agent_number']?>&view=edit"><?php echo getAgentName($list['agent_number'])?></a></td>
<td><?php echo $status?></td>
<td class="align-middle text-center">&pound;<?php echo number_format($list['rate_per_hour'],2)?></td>
<td class="text-right">
<button type="button" id="invButtonClient" class="btn btn-secondary functionButtons" onClick="loadInvoice('invoice')" disabled>Client Invoice</button>
<button type="button" id="emailButton" class="btn btn-secondary emailButton functionButtons" data-values="" data-href="includes/master/mailer.php" data-toggle="tooltip" data-placement="top" data-original-title="Email Client"><i class="fad fa-envelope"></i></button>
<button type="button" id="removeButton" class="btn btn-info removeButton functionButtons" data-toggle="tooltip" data-placement="top" data-original-title="Lapse Renewal" data-values="<?php echo $list['clientnumber']?>"><i class="fad fa-archive"></i></button>
</td>
</tr>
<?php }
}
}
?>
</tbody>
</table>
</div>

<?php
$table="expenseTable";
require('includes/single_table.engine');
?>
<script>
$('#navBox').html('<li class="breadrumb-item"><a href="javascript:void(0)">Finance</a><i class="fad fa-angle-double-right mx-2 mt-1"" aria-hidden="true"></i></li><li class="breadrumb-item active">Renewals</li>')
</script>