220 lines
12 KiB
PHP
220 lines
12 KiB
PHP
<?php
|
|
/** loads and saves room data
|
|
*
|
|
* @version 2.0.0
|
|
* @since 2008-02-13
|
|
* @author Martin Lenzelbauer
|
|
*/
|
|
|
|
define("ROOT", "../");
|
|
require_once(ROOT."include/config.inc.php");
|
|
require_once(ROOT."include/db.inc.php");
|
|
require_once(ROOT."include/xml.inc.php");
|
|
|
|
dbQuery("SET NAMES utf8");
|
|
|
|
switch($_GET['action']){
|
|
case "loadRoom": loadRoom($_GET['id']);
|
|
break;
|
|
case "saveRoom": saveRoom();
|
|
break;
|
|
case "loadReservations": loadReservations($_GET['dateId']);
|
|
break;
|
|
case "loadTickets": loadTickets($_GET['dateId']);
|
|
break;
|
|
}
|
|
|
|
|
|
/** loads room data
|
|
* @param id room id
|
|
*/
|
|
############################################
|
|
function loadRoom($id){
|
|
############################################
|
|
|
|
$query = sprintf("SELECT xml FROM bruckm_ticketroom WHERE id = %d", sqlnum($id));
|
|
$result = dbQuery($query);
|
|
$line = mysqli_fetch_array($result, MYSQLI_ASSOC);
|
|
|
|
header('Content-Type: text/xml');
|
|
echo $line['xml'];
|
|
|
|
}
|
|
|
|
|
|
/** saves room data
|
|
*/
|
|
############################################
|
|
function saveRoom(){
|
|
############################################
|
|
|
|
if ($_POST['id'] == 0) {
|
|
$query = sprintf("INSERT INTO bruckm_ticketroom (xml) VALUES (%s)", sqlstring(($_POST['xml'])));
|
|
dbQuery($query);
|
|
echo "&result=ok&id=" . mysqli_insert_id() . "&";
|
|
return;
|
|
}
|
|
|
|
$query = sprintf("UPDATE bruckm_ticketroom SET xml = %s WHERE id = %d",
|
|
sqlstring(($_POST['xml'])),
|
|
sqlnum($_POST['id']));
|
|
dbQuery($query);
|
|
echo "&result=ok&id=" . $_POST['id'] . "&";
|
|
|
|
}
|
|
|
|
|
|
/** loads all reservations for the given date
|
|
* @param dateId date id
|
|
*/
|
|
############################################
|
|
function loadReservations($dateId){
|
|
############################################
|
|
|
|
// if ($dateId == 482) {
|
|
// $xml = '<?xml version="1.0" encoding="utf-8"?'
|
|
// . '<reservations>'
|
|
// . '<ticket seatIndex="11" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="10" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="9" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="8" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="7" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="6" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="5" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="4" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="15" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="16" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="17" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="18" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="19" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="20" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="21" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="22" tableIndex="-1" rowIndex="7" floorIndex="0" />'
|
|
// . '<ticket seatIndex="15" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="16" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="17" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="18" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="19" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="20" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="11" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="10" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="15" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="16" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="15" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="16" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="17" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="18" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="19" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="11" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="10" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="9" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="8" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="7" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="11" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="10" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="9" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="15" tableIndex="-1" rowIndex="5" floorIndex="0" />'
|
|
// . '<ticket seatIndex="16" tableIndex="-1" rowIndex="5" floorIndex="0" />'
|
|
// . '<ticket seatIndex="11" tableIndex="-1" rowIndex="5" floorIndex="0" />'
|
|
// . '<ticket seatIndex="10" tableIndex="-1" rowIndex="5" floorIndex="0" />'
|
|
// . '<ticket seatIndex="8" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="7" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="6" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="5" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="4" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="11" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="10" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="9" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="8" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="9" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="8" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="17" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="18" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="19" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="20" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="21" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="22" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="23" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="24" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="25" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="26" tableIndex="-1" rowIndex="0" floorIndex="0" />'
|
|
// . '<ticket seatIndex="20" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="21" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="22" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="23" tableIndex="-1" rowIndex="2" floorIndex="0" />'
|
|
// . '<ticket seatIndex="21" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="22" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="23" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="24" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="25" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="26" tableIndex="-1" rowIndex="1" floorIndex="0" />'
|
|
// . '<ticket seatIndex="15" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="16" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="17" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="18" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="19" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '<ticket seatIndex="20" tableIndex="-1" rowIndex="3" floorIndex="0" />'
|
|
// . '</reservations>';
|
|
// header('Content-Type: text/xml');
|
|
// echo $xml;
|
|
// exit;
|
|
// }
|
|
|
|
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
|
$xml .= '<reservations>';
|
|
|
|
$query = sprintf("SELECT * FROM bruckm_ticket WHERE dateId = %d", sqlnum($dateId));
|
|
$result = dbQuery($query);
|
|
while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){
|
|
$xml .= '<ticket seatIndex="' . $line['seatIndex'] . '" tableIndex="' . $line['tableIndex'] . '" rowIndex="' . $line['rowIndex'] . '" floorIndex="' . $line['floorIndex'] . '" />';
|
|
}
|
|
|
|
$xml .= '</reservations>';
|
|
|
|
header('Content-Type: text/xml');
|
|
echo $xml;
|
|
|
|
}
|
|
|
|
|
|
/** loads all tickets for the given date
|
|
* @param dateId date id
|
|
*/
|
|
############################################
|
|
function loadTickets($dateId){
|
|
############################################
|
|
|
|
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
|
$xml .= '<tickets>';
|
|
|
|
// load all orders for this date
|
|
$query = sprintf("SELECT * FROM bruckm_ticketorder WHERE dateId = %d", sqlnum($dateId));
|
|
$result = dbQuery($query);
|
|
while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){
|
|
// load customer
|
|
$query = sprintf("SELECT firstname, surname FROM bruckm_ticketcustomer WHERE id = %d", sqlnum($line['customerId']));
|
|
$customer = dbQuery($query);
|
|
$c = mysqli_fetch_array($customer, MYSQLI_ASSOC);
|
|
$xml .= '<order id="' . $line['id'] . '" paid="' . $line['paid'] . '" paymethod="' . $line['payMethod'] . '" voucherValue="' . $line['voucherValue'] . '" ';
|
|
// $xml .= 'firstname="Max" surname="Mustermann">';
|
|
$xml .= 'firstname="' . htmlspecialchars($c['firstname']) . '" surname="' . htmlspecialchars($c['surname']) . '">';
|
|
|
|
// load all tickets of this order
|
|
$query = sprintf("SELECT * FROM bruckm_ticket WHERE orderId = %d", sqlnum($line['id']));
|
|
$tickets = dbQuery($query);
|
|
while($t = mysqli_fetch_array($tickets, MYSQLI_ASSOC)){
|
|
$xml .= '<ticket seatIndex="' . $t['seatIndex'] . '" tableIndex="' . $t['tableIndex'] . '" rowIndex="' . $t['rowIndex'] . '" floorIndex="' . $t['floorIndex'] . '" category="' . $t['category'] . '" reduction="' . $t['reductionId'] . '" />';
|
|
}
|
|
$xml .= '</order>';
|
|
}
|
|
|
|
$xml .= '</tickets>';
|
|
|
|
header('Content-Type: text/xml');
|
|
echo $xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|