Files
bm/public_html/public/tickets/date.php
2025-09-24 13:26:28 +02:00

119 lines
3.4 KiB
PHP

<?php
/** loads a single event date
*
* @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 "loadDate": loadDate($_GET['id']);
break;
case "loadOrders": loadOrders($_GET['id']);
break;
}
/** loads a date
* @param id date id
*/
############################################
function loadDate($id){
############################################
// load all reductions
$allReductions = array();
$query = sprintf("SELECT id, classId, name FROM bruckm_index WHERE class = 'TicketReduction' ORDER BY name ASC");
$result = dbQuery($query);
while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){
$allReductions[] = $line;
}
foreach($allReductions as $i=>$r){
$query = sprintf("SELECT * FROM bruckm_ticketreduction WHERE id = %d", $r['classId']);
$result = dbQuery($query);
$line = mysqli_fetch_array($result, MYSQLI_ASSOC);
$allReductions[$i]['type'] = $line['type'];
$allReductions[$i]['value'] = $line['value'];
}
// load date
$query = sprintf("SELECT * FROM bruckm_ticketdate WHERE id = %d ORDER BY `date` ASC", $id);
$result = dbQuery($query);
$line = mysqli_fetch_array($result, MYSQLI_ASSOC);
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<date id="' . $line['id'] . '" eventid="' . $line['eventId'] . '" timestamp="' . strtotime($line['date']) . '" ';
$xml .= 'room="' . $line['room'] . '" seats="' . $line['seats'] .'" ';
$entries = explode("\t", $line['entries']);
$xml .= 'a="' . $entries[0] . '" ';
if(sizeof($entries) > 1) $xml .= 'b="' . $entries[1] . '" ';
if(sizeof($entries) > 2) $xml .= 'c="' . $entries[2] . '" ';
$xml .= '>';
$reductions = explode("\t", $line['reductions']);
foreach($allReductions as $r){
$xml .= '<reduction name="' . trim($r['name']) . '" type="' . $r['type'] . '" value="' . $r['value'] . '" id="' . $r['classId'] . '" ';
if (in_array($r['id'], $reductions)) { // 'id' is flexicon id!
// extra check for "frühbucherbonus"
if ($r['type'] == '14d') {
if (strtotime($line['date']) > time() + 9 * 86400) {
$xml .= 'enabled="true"';
}
else {
$xml .= 'enabled="false"';
}
}
else {
$xml .= 'enabled="true"';
}
}
else{
$xml .= 'enabled="false"';
}
$xml .= ' />';
}
$xml .= '</date>';
header('Content-Type: text/xml');
echo $xml;
}
/** loads all orders of the date
* @param id date id
*/
############################################
function loadOrders($id){
############################################
$query = sprintf("SELECT id, customerId, orderDate, payMethod FROM bruckm_ticketorder WHERE dateId = %d ORDER BY orderDate DESC", $id);
$result = dbQuery($query);
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<orders>';
while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){
$xml .= '<order id="' . $line['id'] . '" timestamp="' . strtotime($line['orderDate']) . '" paymethod="' . $line['payMethod'] .'" ';
$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 .= 'firstname="' . xmlstring($c['firstname']) . '" surname="' . xmlstring($c['surname']) . '" />';
}
$xml .= '</orders>';
header('Content-Type: text/xml');
echo $xml;
}
?>