<?php $_REQUEST['src']="ext2";require_once('../../functions/global.php');
$record=file_get_contents('insepections_due.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 'itemnumber' FROM `itemdetails` WHERE `duedate`>'$now' AND `duedate`<'$then' AND `statuslive`='1'  AND `clientnumber`='".$c."' LIMIT 1")or die(mysqli_error($GLOBALS['con']));
$stmt->execute();$ic=$stmt->get_result();$stmt->close();
$id=mysqli_num_rows($ic);
$count=$id;

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=Pending" 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;

}
$i=0;
$start = microtime(true);
$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('due','data',$l['clientnumber'],$l['clientname']);}

$dueFile = fopen("insepections_due.txt", "w");
fwrite($dueFile, date('d-m-Y')."|".$output);
fclose($dueFile);
}
$record=file_get_contents('insepections_due.txt');
$record=explode("|",$record);
?>
