<?php
$ticketTypes = [
"ticketTypes" => [
"557968" => [
"section" => "235606",
"amount" => "1"
],
"604142"=> [
"section"=> "253594",
"amount"=> "2"
]
],
"delivery"=> [
"digitalPrintPass",
"willcall",
"mail"
]
];
$resultTypes = [];
$deliveryOptions = [];
$deliveryValues = "";
foreach ($ticketTypes as $key => $value) {
if($key == 'ticketTypes'){
// print_r($key); -- printing "tickettypes"
// print_r($value);
$i = 0;
foreach($value as $ticketTypeId => $sectionInfo){
$resultTypes[$i] = [
"ticketTypeId" => $ticketTypeId,
"sectionId" => $sectionInfo['section'],
"sectionAmount" => $sectionInfo['amount']
];
$i++;
}
print_r($resultTypes);
}elseif($key == 'delivery'){
foreach($value as $deliveryOption){
switch ($deliveryOption) {
case "digitalPrintPass":
$deliveryOptions[] = 'H';
break;
case "willcall":
$deliveryOptions[] = 'W';
break;
case "mail":
$deliveryOptions[] = 'M';
break;
}
}
$deliveryValues = implode(",", $deliveryOptions);
}
echo $deliveryValues;
}
// DONE -----> expect an array of price types (TICKET_TYPE) matched with a section and a quantity
// DONE -----> create an empty array called something like matchingRequests
// loop through all requests still in "REQUESTED" (see WAITLIST_STATUS table) state (possibly limited only to requests with selected price types), ordered by earliest submission time first. waitlist status table requested is id 1
// SQL_BSWAITLISTREPORTGET is a good starting point to find these requests, but we might want to make this a function in the waitlist class
// if a request cannot be fulfilled in full (ticket type wasn't selected or quantity is no longer available) skip it
// if the request can be fulfilled, include it in the matchingRequests array and decrement requested quantity for the section
// return the matchingRequests as a json object
// $a = json_encode($b);
// echo $a;
// $a = {
// "ticketTypes": {
// "557968": {
// "section": "235606",
// "amount": "1"
// },
// "604142": {
// "section": "253594",
// "amount": "2"
// }
// },
// "delivery": {
// "digitalPrintPass",
// "willcall"
// }
// };