<?php $_REQUEST['src']="ext2";require_once('../../functions/global.php');
$record=file_get_contents('insepections_overdue.txt');
$record=explode("|",$record);

if(strtotime($record[0]) < strtotime('today')){
function checkInsp2($t,$m,$c,$n){
$now=strtotime('now');
$count=0;
$then=strtotime('now +1 month');



$stmt = $GLOBALS['con']->prepare("SELECT `clientnumber` FROM `itemdetails` WHERE `statuslive`='1' AND `duedate` < '$now' AND `clientnumber`='".$c."' LIMIT 1")or die(mysqli_error($GLOBALS['con']));
$stmt->execute();$ic=$stmt->get_result();$stmt->close();
while($id=mysqli_fetch_array($ic)){
$count++;

}
if($count!=0){
$data='<tr><th>'.$n.'</th>
<td>
<div class="btn-group" role="group" style="float:right">
<a href="index.php?t=includes/master&p=client.php&clientnumber='.$c.'&view=asset&search=Overdue" class="btn btn-secondary noprint" data-mdb-tooltip-init data-mdb-placement="top" data-mdb-trigger="hover" title="View Schedule"><i class="fad fa-th-list"></i></a>
</div>
</td></tr>';
}
return $$m;
}


$stmt = $GLOBALS['con']->prepare("SELECT `clientnumber`,`clientname` FROM `clientdetails` WHERE `statuslive`='1'")or die(mysqli_error("GET_INV_NO: ".$GLOBALS['con']));
$stmt->execute();$iv=$stmt->get_result();$stmt->close();
while($list=mysqli_fetch_assoc($iv)){$data[]=$list;}
mysqli_free_result($iv);

foreach($data as $l){$output.=checkInsp2('clientOver','data',$l['clientnumber'],$l['clientname']);}

$overdueFile = fopen("insepections_overdue.txt", "w");
fwrite($overdueFile, date('d-m-Y')."|".$output);
fclose($overdueFile);
}

