<?php

require_once('config.php');

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

$master_delete = odbc_exec($db, "SELECT * FROM Q_master_delete WHERE hall_name='$_hall' AND masa='$_table'");

while($item = odbc_fetch_array($master_delete) ) {
  if(in_array("REZERVE", explode(" ", $item['ozellik'])))
    odbc_exec($db, "INSERT INTO Q_Mars (MADI,hall_name,Masa,adet) VALUES ('$item[ReceteAdi]','$_hall','$_table', '$item[adet]')");
}

if($_print)
  $order_delete = odbc_exec($db,"UPDATE Q_master_delete SET pda=1 WHERE hall_name='$_hall' AND masa='$_table'");
else
  $order_delete = odbc_exec($db,"DELETE FROM Q_master_delete WHERE hall_name='$_hall' AND masa='$_table'");

$order_detay = odbc_exec($db,"UPDATE Q_master_detay SET yaz=1 WHERE hall_name='$_hall' AND masa='$_table'");
odbc_exec($db, "UPDATE Q_master_table SET adisyaz='0' WHERE hall_name='$_hall' AND Masa='$_table'");

if($order_delete && $order_detay)
  $response = array("successful" => true);
else
  $response = array("successful" => false);
utf8_print($response);

?>
