Refined JSON. Added form preparation.
This commit is contained in:
parent
c582af6e79
commit
891c9db21d
@ -1,196 +1,208 @@
|
|||||||
{
|
{
|
||||||
"bookingAgent_name": {
|
"groups": {
|
||||||
"title": "Name",
|
"0": "Hotel Information",
|
||||||
"type": "text",
|
"1": "Date",
|
||||||
"required": false,
|
"2": "Booking Information",
|
||||||
"group": "Booking Agency",
|
"3": "Program Membership",
|
||||||
"short": true
|
"4": "Booking Agency",
|
||||||
|
"5": "Hotlinks",
|
||||||
|
"6": "Metadata"
|
||||||
},
|
},
|
||||||
"bookingAgent_url": {
|
"fields": {
|
||||||
"title": "URL",
|
"bookingAgent_name": {
|
||||||
"type": "url",
|
"title": "Name",
|
||||||
"required": false,
|
"type": "text",
|
||||||
"group": "Booking Agency"
|
"required": false,
|
||||||
},
|
"group": 4,
|
||||||
"bookingTime": {
|
"short": true
|
||||||
"title": "Booking Date",
|
},
|
||||||
"type": "datetime",
|
"bookingAgent_url": {
|
||||||
"required": false,
|
"title": "URL",
|
||||||
"group": "Booking Agency"
|
"type": "url",
|
||||||
},
|
"required": false,
|
||||||
"cancelReservationUrl": {
|
"group": 4
|
||||||
"title": "Cancel URL",
|
},
|
||||||
"type": "url",
|
"bookingTime": {
|
||||||
"required": false,
|
"title": "Booking Date",
|
||||||
"group": "Hotlinks"
|
"type": "datetime",
|
||||||
},
|
"required": false,
|
||||||
"checkinDate": {
|
"group": 4
|
||||||
"title": "Checkin Time",
|
},
|
||||||
"type": "datetime",
|
"cancelReservationUrl": {
|
||||||
"required": true,
|
"title": "Cancel URL",
|
||||||
"group": "Date"
|
"type": "url",
|
||||||
},
|
"required": false,
|
||||||
"checkoutDate": {
|
"group": 5
|
||||||
"title": "Checkout Time",
|
},
|
||||||
"type": "datetime",
|
"checkinDate": {
|
||||||
"required": true,
|
"title": "Checkin Time",
|
||||||
"group": "Date"
|
"type": "datetime",
|
||||||
},
|
"required": true,
|
||||||
"confirmReservationUrl": {
|
"group": 1
|
||||||
"title": "Confirm URL",
|
},
|
||||||
"type": "url",
|
"checkoutDate": {
|
||||||
"required": false,
|
"title": "Checkout Time",
|
||||||
"group": "Hotlinks"
|
"type": "datetime",
|
||||||
},
|
"required": true,
|
||||||
"lodgingUnitDescription": {
|
"group": 1
|
||||||
"title": "Room Description",
|
},
|
||||||
"type": "text",
|
"confirmReservationUrl": {
|
||||||
"required": false,
|
"title": "Confirm URL",
|
||||||
"group": "Booking Information"
|
"type": "url",
|
||||||
},
|
"required": false,
|
||||||
"modifiedTime": {
|
"group": 5
|
||||||
"title": "Modified Time",
|
},
|
||||||
"type": "datetime",
|
"lodgingUnitDescription": {
|
||||||
"required": false,
|
"title": "Room Description",
|
||||||
"group": "Metadata"
|
"type": "text",
|
||||||
},
|
"required": false,
|
||||||
"modifyReservationUrl": {
|
"group": 2
|
||||||
"title": "Modify URL",
|
},
|
||||||
"type": "url",
|
"modifiedTime": {
|
||||||
"required": false,
|
"title": "Modified Time",
|
||||||
"group": "Hotlinks"
|
"type": "datetime",
|
||||||
},
|
"required": false,
|
||||||
"numAdults": {
|
"group": 6
|
||||||
"title": "Number of Adults",
|
},
|
||||||
"type": "number",
|
"modifyReservationUrl": {
|
||||||
"required": false,
|
"title": "Modify URL",
|
||||||
"group": "Booking Information",
|
"type": "url",
|
||||||
"short": true
|
"required": false,
|
||||||
},
|
"group": 5
|
||||||
"numChildren": {
|
},
|
||||||
"title": "Number of Children",
|
"numAdults": {
|
||||||
"type": "number",
|
"title": "Number of Adults",
|
||||||
"required": false,
|
"type": "number",
|
||||||
"group": "Booking Information",
|
"required": false,
|
||||||
"short": true
|
"group": 2,
|
||||||
},
|
"short": true
|
||||||
"price": {
|
},
|
||||||
"title": "Price",
|
"numChildren": {
|
||||||
"type": "decimal",
|
"title": "Number of Children",
|
||||||
"required": false,
|
"type": "number",
|
||||||
"group": "Booking Information",
|
"required": false,
|
||||||
"short": true
|
"group": 2,
|
||||||
},
|
"short": true
|
||||||
"priceCurrency": {
|
},
|
||||||
"title": "Currency",
|
"price": {
|
||||||
"type": "text",
|
"title": "Price",
|
||||||
"required": false,
|
"type": "decimal",
|
||||||
"group": "Booking Information",
|
"required": false,
|
||||||
"short": true
|
"group": 2,
|
||||||
},
|
"short": true
|
||||||
"programMembership_memberNumber": {
|
},
|
||||||
"title": "Member No.",
|
"priceCurrency": {
|
||||||
"type": "text",
|
"title": "Currency",
|
||||||
"required": false,
|
"type": "text",
|
||||||
"group": "Program Membership",
|
"required": false,
|
||||||
"short": true
|
"group": 2,
|
||||||
},
|
"short": true
|
||||||
"programMembership_program": {
|
},
|
||||||
"title": "Name of Program",
|
"programMembership_memberNumber": {
|
||||||
"type": "text",
|
"title": "Member No.",
|
||||||
"required": false,
|
"type": "text",
|
||||||
"group": "Program Membership",
|
"required": false,
|
||||||
"short": true
|
"group": 3,
|
||||||
},
|
"short": true
|
||||||
"reservationFor_address_addressCountry": {
|
},
|
||||||
"title": "Country",
|
"programMembership_program": {
|
||||||
"type": "country",
|
"title": "Name of Program",
|
||||||
"required": true,
|
"type": "text",
|
||||||
"group": "Hotel Information"
|
"required": false,
|
||||||
},
|
"group": 3,
|
||||||
"reservationFor_address_addressLocality": {
|
"short": true
|
||||||
"title": "City",
|
},
|
||||||
"type": "text",
|
"reservationFor_address_addressCountry": {
|
||||||
"required": true,
|
"title": "Country",
|
||||||
"group": "Hotel Information"
|
"type": "country",
|
||||||
},
|
"required": true,
|
||||||
"reservationFor_address_addressRegion": {
|
"group": 0
|
||||||
"title": "Region",
|
},
|
||||||
"type": "text",
|
"reservationFor_address_addressLocality": {
|
||||||
"required": true,
|
"title": "City",
|
||||||
"group": "Hotel Information",
|
"type": "text",
|
||||||
"short": true
|
"required": true,
|
||||||
},
|
"group": 0
|
||||||
"reservationFor_address_postalCode": {
|
},
|
||||||
"title": "Zip Code",
|
"reservationFor_address_addressRegion": {
|
||||||
"type": "number",
|
"title": "Region",
|
||||||
"required": true,
|
"type": "text",
|
||||||
"group": "Hotel Information",
|
"required": true,
|
||||||
"short": true
|
"group": 0,
|
||||||
},
|
"short": true
|
||||||
"reservationFor_address_streetAddress": {
|
},
|
||||||
"title": "Street",
|
"reservationFor_address_postalCode": {
|
||||||
"type": "text",
|
"title": "Zip Code",
|
||||||
"required": true,
|
"type": "number",
|
||||||
"group": "Hotel Information"
|
"required": true,
|
||||||
},
|
"group": 0,
|
||||||
"reservationFor_name": {
|
"short": true
|
||||||
"title": "Hotel Name",
|
},
|
||||||
"type": "text",
|
"reservationFor_address_streetAddress": {
|
||||||
"required": true,
|
"title": "Street",
|
||||||
"group": "Hotel Information"
|
"type": "text",
|
||||||
},
|
"required": true,
|
||||||
"reservationFor_image": {
|
"group": 0
|
||||||
"title": "Hotel Image URL",
|
},
|
||||||
"type": "url",
|
"reservationFor_name": {
|
||||||
"required": false,
|
"title": "Hotel Name",
|
||||||
"group": "Hotel Information"
|
"type": "text",
|
||||||
},
|
"required": true,
|
||||||
"reservationFor_telephone": {
|
"group": 0
|
||||||
"title": "Telephone",
|
},
|
||||||
"type": "tel",
|
"reservationFor_image": {
|
||||||
"required": true,
|
"title": "Hotel Image URL",
|
||||||
"group": "Hotel Information",
|
"type": "url",
|
||||||
"short": true
|
"required": false,
|
||||||
},
|
"group": 0
|
||||||
"reservationFor_url": {
|
},
|
||||||
"title": "Website URL",
|
"reservationFor_telephone": {
|
||||||
"type": "url",
|
"title": "Telephone",
|
||||||
"required": false,
|
"type": "tel",
|
||||||
"group": "Hotel Information"
|
"required": true,
|
||||||
},
|
"group": 0,
|
||||||
"reservationNumber": {
|
"short": true
|
||||||
"title": "Reservation #",
|
},
|
||||||
"type": "text",
|
"reservationFor_url": {
|
||||||
"required": true,
|
"title": "Website URL",
|
||||||
"group": "Booking Information",
|
"type": "url",
|
||||||
"short": true
|
"required": false,
|
||||||
},
|
"group": 0
|
||||||
"reservationStatus": {
|
},
|
||||||
"title": "Status",
|
"reservationNumber": {
|
||||||
"type": "status",
|
"title": "Reservation #",
|
||||||
"required": true,
|
"type": "text",
|
||||||
"group": "Booking Information",
|
"required": true,
|
||||||
"short": true
|
"group": 2,
|
||||||
},
|
"short": true
|
||||||
"underName_name": {
|
},
|
||||||
"title": "Name on Reservation",
|
"reservationStatus": {
|
||||||
"type": "text",
|
"title": "Status",
|
||||||
"required": true,
|
"type": "status",
|
||||||
"group": "Booking Information",
|
"required": true,
|
||||||
"default": "USER_NAME"
|
"group": 2,
|
||||||
},
|
"short": true
|
||||||
"underName_email": {
|
},
|
||||||
"title": "Email address",
|
"underName_name": {
|
||||||
"type": "email",
|
"title": "Name on Reservation",
|
||||||
"required": false,
|
"type": "text",
|
||||||
"group": "Booking Information",
|
"required": true,
|
||||||
"default": "USER_EMAIL"
|
"group": 2,
|
||||||
},
|
"default": "USER_NAME"
|
||||||
"url": {
|
},
|
||||||
"title": "Booking URL",
|
"underName_email": {
|
||||||
"type": "url",
|
"title": "Email address",
|
||||||
"required": false,
|
"type": "email",
|
||||||
"group": "Hotlinks"
|
"required": false,
|
||||||
|
"group": 2,
|
||||||
|
"default": "USER_EMAIL"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"title": "Booking URL",
|
||||||
|
"type": "url",
|
||||||
|
"required": false,
|
||||||
|
"group": 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ if (!$tpl_done && isset($_SESSION['access_token']) && $_SESSION['access_token'])
|
|||||||
case 'hotel':
|
case 'hotel':
|
||||||
$tpl = $m->loadTemplate('hotel_html');
|
$tpl = $m->loadTemplate('hotel_html');
|
||||||
$tpl_done = true;
|
$tpl_done = true;
|
||||||
|
$action = 'hotel';
|
||||||
|
require 'prep_form.php';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!$tpl_done) {
|
if (!$tpl_done) {
|
||||||
|
34
prep_form.php
Normal file
34
prep_form.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// FOR TESTING:
|
||||||
|
$action = 'hotel';
|
||||||
|
$skey = 'form_' . $action;
|
||||||
|
|
||||||
|
$field_data_json = file_get_contents('definitions/' . $action . '.json');
|
||||||
|
$field_data = json_decode($field_data_json, true);
|
||||||
|
|
||||||
|
foreach ($field_data['groups'] as $id=>$group) {
|
||||||
|
$by_group[$group] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($field_data['fields'] as $key=>$meta) {
|
||||||
|
$group_name = $field_data['groups'][$meta['group']];
|
||||||
|
$meta['group_name'] = $group_name;
|
||||||
|
if (isset($_SESSION[$skey][$key])) {
|
||||||
|
$meta['value'] = $_SESSION[$skey][$key];
|
||||||
|
} elseif (isset($meta['default'])) {
|
||||||
|
switch ($meta['default']) {
|
||||||
|
case 'USER_NAME':
|
||||||
|
$meta['value'] = 'User Name';
|
||||||
|
break;
|
||||||
|
case 'USER_EMAIL':
|
||||||
|
$meta['value'] = 'user@email.com';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$meta['value'] = $meta['default'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$by_group[$group_name][$key] = $meta;
|
||||||
|
}
|
||||||
|
print_r($by_group);
|
Reference in New Issue
Block a user