<?php
// gets all insurance invoices in json for autocomplete
include 'includes/database.php';
$db=new MySQLDatabase();
$db->open_connection();
$sql = mysqli_query($db->connection, "SELECT insno, idate, insurer, regno  FROM insrecs ORDER BY insno DESC;") or die (mysqli_error($db->connection) );
$larray = array();
while ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){
	$jd = substr($row['idate'],8,2)."-".substr($row['idate'],5,2)."-".substr($row['idate'] ,0,4);
    $row_array['value'] = $row['insno'].' - '.$jd.' - '.$row['insurer'].' - '.$row['regno'];
    array_push($larray, $row_array); 
    }
echo json_encode($larray);    
$db->close_connection();


?>