<?php require_once('../../includes/connection.php');
function getName($clientnumber){
$stmt = $GLOBALS['con']->prepare("SELECT `clientname` FROM `clientdetails` WHERE `clientnumber`='".$clientnumber."'")or die(mysqli_error($GLOBALS['con']));
$stmt->execute();$ic=$stmt->get_result();$stmt->close();
$id=mysqli_fetch_array($ic);
return $id['clientname'];
}
$count=0;
if($_REQUEST['filter']=="client"){};
if($_REQUEST['filter']=="site"){};
if($_REQUEST['filter']=="item"){
$stmt = $GLOBALS['con']->prepare("SELECT `clientnumber`,`itemnumber`,`locnumber`,`desc`, `plantnumber`,`serialnumber`,`duedate` FROM `itemdetails` WHERE `statuslive`='1' AND `desc` LIKE '%".$_REQUEST['searchstr']."%' ORDER BY abs(clientnumber) ASC ")or die(mysqli_error($GLOBALS['con']));
$stmt->execute();$ic=$stmt->get_result();$stmt->close();
$c=1;$n=$cd=mysqli_num_rows($ic);
while($id=mysqli_fetch_array($ic)){
$results.='<tr><th>'.getName($id['clientnumber']).'</th><th>'.$id['itemnumber'].'</th><td>'.$id['desc'].'</td><td>'.$id['plantnumber'].'</td><td>'.$id['serialnumber'].'</td><td>
<div class="btn-group" role="group" style="float:right"><a href="javascript:void(0)" class="btn btn-secondary noprint formButton" data-values="18|19|315" data-href="includes/master/form.php"><i class="fad fa-file-alt" aria-hidden="true"></i></a><a href="index.php?t=includes/master&amp;p=items.php&amp;data=18|19|315&amp;view=list" class="btn btn-secondary noprint filesButton" data-values="'.$id['clientnumber'].'|'.$id['locnumber'].'|'.$id['itemnumber'].'" data-href="includes/master/files.php"><i class="fad fa-copy" aria-hidden="true"></i></a><a href="javascript:void(0)" class="btn btn-secondary noprint transferButton" data-values="'.$id['clientnumber'].'|'.$id['locnumber'].'|'.$id['itemnumber'].'" data-href="includes/master/transfer.php"><i class="fad fa-exchange-alt" aria-hidden="true"></i></a><a href="javascript:void(0)" class="btn btn-secondary noprint archiveButton" data-values="'.$id['clientnumber'].'|'.$id['locnumber'].'|'.$id['itemnumber'].'|archive" data-href="includes/master/archive.php"><i class="fad fa-archive" aria-hidden="true"></i></a><a href="index.php?t=includes/master&amp;p=asset.php&amp;view=edit_attached&amp;data='.$id['clientnumber'].'|'.$id['locnumber'].'|'.$id['itemnumber'].'" class="btn btn-secondary noprint"><i class="fad fa-info-circle" aria-hidden="true"></i></a></div>
</td></tr>';
$count++;
}
}
?>
<table class="table table-striped is-sticky">
<thead>
<tr><th>Client</th><th>Item Number</th><th>Description</th><th>Plant Number</th><th>Serial Number</th><th></th></tr>
</thead>
<tbody>
<?= $results?>
</tbody>
</table>

<script>
$('#searchLabel').html('Searching for <strong><?= $_REQUEST['searchstr']?></strong> in <strong><?= $_REQUEST['filter']?></strong> with <?= $count?> results')
</script>