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