<?php require_once('includes/master/finance_functions.php');
if(empty($_REQUEST['mode'])){$_REQUEST['mode']="pending";}
if(empty($_REQUEST['clientnumber'])){$_REQUEST['clientnumber']=0;$name="All ".ucfirst($_REQUEST['mode'])." Inspections";}
else{$name=ucfirst($_REQUEST['mode'])." inspections for ".getMasterDetails('name');}
?>
<div class="row justify-content-between">
<div class="col-md-3">
<h2>Filter by client: <?= listClient($_REQUEST['clientnumber'],"client","select")?></h2>
</div>
<?php if($_REQUEST['clientnumber']!='0'){?>
<div class="col-md-3">
<h2>Filter by site: <?= getSites($_REQUEST['clientnumber'],$_REQUEST['site'])?></h2>
</div>
<?php }?>

<div class="col-md-3">
<div class="btn-group" role="group" aria-label="...">
  <a href="index.php?t=includes/master&p=inspection_schedule.php&clientnumber=<?= $_REQUEST['clientnumber']?>&mode=pending" class="btn btn-warning">Pending</a>
  <a href="index.php?t=includes/master&p=inspection_schedule.php&clientnumber=<?= $_REQUEST['clientnumber']?>&mode=overdue" class="btn btn-danger">Overdue</a>
  <a href="index.php?t=includes/master&p=inspection_schedule.php" class="btn btn-secondary">Reset</a>
</div>
</div>
</div>
<div class="clearfix spacer"></div>
<hr>
<p class="lead"><?= $name?></p>

<div class="clearfix spacer"></div>
<table id="datatable" class="table table-striped table-sm responsive" width="100%">
<thead>
<tr><th>Company</th><th>Location</th><th>Item</th><th>Plantnumber</th><th>Serialnumber</th><th></th></tr>
</thead>
<tbody>
<?= checkRenewal($_REQUEST['mode'],$_REQUEST['site'],$_REQUEST['clientnumber'])?>
</tbody>
</table>



<script>
$('#navBox').html('<a href="javascript:void(0)" class="sa1">Imminent Inspections</a>');
$('#client').change(function(){
$('#client_single').load('includes/finance/finance_client.php?mode=<?= $_REQUEST['mode']?>&clientnumber='+$(this).val())
})

$('[data-toggle="tooltip"]').tooltip()


$(".formButton,.transferButton,.archiveButton").click(function(){//alert("2")
$('#popupBox .modal-body').html('');
var target = $(this).data('href');
var string = $(this).data('values');
var dest=encodeURI(target+"?data="+string)
$('#popupBox').modal('show');
$('#popupBox .modal-body').load(dest);
})

$('#client').change(function(){
window.location='index.php?t=includes/master&p=inspection_schedule.php&mode=<?= $_REQUEST['mode']?>&clientnumber='+$(this).val()
})

$('#site').change(function(){
window.location='index.php?t=includes/master&p=inspection_schedule.php&mode=<?= $_REQUEST['mode']?>&clientnumber=<?= $_REQUEST['clientnumber']?>&site='+$(this).val()
})
</script>

<?php
$table="datatable";
require_once('includes/single_table.engine');

?>
