<?php

require_once('config.php');

$_hall = $_POST['hall'];
$_table = $_POST['table'];
$_items = explode(',', $_POST['items']);

foreach($_items as $item){
  $mars = odbc_fetch_array(odbc_exec($db, "SELECT * FROM Q_Mars WHERE hall_name='$_hall' AND Masa='$_table' AND MDY_ID='$item'"));
  $aktar = odbc_exec($db, "INSERT INTO Q_Pda_rezerve (hall_name,masa,MADI,adet) VALUES ('$mars[hall_name]', '$mars[Masa]', '$mars[MADI]', '$mars[adet]')");
  $sil = odbc_exec($db, "DELETE FROM Q_Mars WHERE MDY_ID='$item'");
}

$process = odbc_exec($db, "INSERT INTO Q_PDA_PROCESS (hall_name,masa) VALUES ('$_hall', '$_table')");

if($process)
  $response = array("successful" => true);
else
  $response = array("successful" => false);
utf8_print($response);

?>
