<?php

require_once('config.php');

$_hall = $_POST['hall'];
$_table = $_POST['table'];

$cart = odbc_exec($db,"SELECT Q_master_delete.sil, Q_master_delete.ReceteKodu, Q_master_delete.ReceteAdi, Q_master_delete.ozellik, Q_master_delete.adet, Q_master_detay.waiter, Q_master_detay.sip_time, Q_master_detay.total FROM Q_master_delete
  LEFT JOIN Q_master_detay ON Q_master_detay.sil=Q_master_delete.sil
  WHERE Q_master_delete.hall_name='$_hall' AND Q_master_delete.masa='$_table' ORDER BY Q_master_delete.QT_ID ASC");

$items = array();
while($item = odbc_fetch_array($cart) ) {

  $items[] = array(
    "id" => intval($item['sil']),
    "code" => $item['ReceteKodu'],
    "name" => utf8_encode($item['ReceteAdi']),
    "extra" => $item['ozellik'],
    "quantity" => $item['adet'],
    "total" => $item['total'],
    "time" => $item['sip_time'],
    "waiter" => $item['waiter']
  );

}

$response = array("successful" => true, "items" => $items);
utf8_print($response);

?>
