diff --git a/definitions/hotel.json b/definitions/hotel.json index 81f9993..6dca51b 100644 --- a/definitions/hotel.json +++ b/definitions/hotel.json @@ -1,196 +1,208 @@ { - "bookingAgent_name": { - "title": "Name", - "type": "text", - "required": false, - "group": "Booking Agency", - "short": true + "groups": { + "0": "Hotel Information", + "1": "Date", + "2": "Booking Information", + "3": "Program Membership", + "4": "Booking Agency", + "5": "Hotlinks", + "6": "Metadata" }, - "bookingAgent_url": { - "title": "URL", - "type": "url", - "required": false, - "group": "Booking Agency" - }, - "bookingTime": { - "title": "Booking Date", - "type": "datetime", - "required": false, - "group": "Booking Agency" - }, - "cancelReservationUrl": { - "title": "Cancel URL", - "type": "url", - "required": false, - "group": "Hotlinks" - }, - "checkinDate": { - "title": "Checkin Time", - "type": "datetime", - "required": true, - "group": "Date" - }, - "checkoutDate": { - "title": "Checkout Time", - "type": "datetime", - "required": true, - "group": "Date" - }, - "confirmReservationUrl": { - "title": "Confirm URL", - "type": "url", - "required": false, - "group": "Hotlinks" - }, - "lodgingUnitDescription": { - "title": "Room Description", - "type": "text", - "required": false, - "group": "Booking Information" - }, - "modifiedTime": { - "title": "Modified Time", - "type": "datetime", - "required": false, - "group": "Metadata" - }, - "modifyReservationUrl": { - "title": "Modify URL", - "type": "url", - "required": false, - "group": "Hotlinks" - }, - "numAdults": { - "title": "Number of Adults", - "type": "number", - "required": false, - "group": "Booking Information", - "short": true - }, - "numChildren": { - "title": "Number of Children", - "type": "number", - "required": false, - "group": "Booking Information", - "short": true - }, - "price": { - "title": "Price", - "type": "decimal", - "required": false, - "group": "Booking Information", - "short": true - }, - "priceCurrency": { - "title": "Currency", - "type": "text", - "required": false, - "group": "Booking Information", - "short": true - }, - "programMembership_memberNumber": { - "title": "Member No.", - "type": "text", - "required": false, - "group": "Program Membership", - "short": true - }, - "programMembership_program": { - "title": "Name of Program", - "type": "text", - "required": false, - "group": "Program Membership", - "short": true - }, - "reservationFor_address_addressCountry": { - "title": "Country", - "type": "country", - "required": true, - "group": "Hotel Information" - }, - "reservationFor_address_addressLocality": { - "title": "City", - "type": "text", - "required": true, - "group": "Hotel Information" - }, - "reservationFor_address_addressRegion": { - "title": "Region", - "type": "text", - "required": true, - "group": "Hotel Information", - "short": true - }, - "reservationFor_address_postalCode": { - "title": "Zip Code", - "type": "number", - "required": true, - "group": "Hotel Information", - "short": true - }, - "reservationFor_address_streetAddress": { - "title": "Street", - "type": "text", - "required": true, - "group": "Hotel Information" - }, - "reservationFor_name": { - "title": "Hotel Name", - "type": "text", - "required": true, - "group": "Hotel Information" - }, - "reservationFor_image": { - "title": "Hotel Image URL", - "type": "url", - "required": false, - "group": "Hotel Information" - }, - "reservationFor_telephone": { - "title": "Telephone", - "type": "tel", - "required": true, - "group": "Hotel Information", - "short": true - }, - "reservationFor_url": { - "title": "Website URL", - "type": "url", - "required": false, - "group": "Hotel Information" - }, - "reservationNumber": { - "title": "Reservation #", - "type": "text", - "required": true, - "group": "Booking Information", - "short": true - }, - "reservationStatus": { - "title": "Status", - "type": "status", - "required": true, - "group": "Booking Information", - "short": true - }, - "underName_name": { - "title": "Name on Reservation", - "type": "text", - "required": true, - "group": "Booking Information", - "default": "USER_NAME" - }, - "underName_email": { - "title": "Email address", - "type": "email", - "required": false, - "group": "Booking Information", - "default": "USER_EMAIL" - }, - "url": { - "title": "Booking URL", - "type": "url", - "required": false, - "group": "Hotlinks" + "fields": { + "bookingAgent_name": { + "title": "Name", + "type": "text", + "required": false, + "group": 4, + "short": true + }, + "bookingAgent_url": { + "title": "URL", + "type": "url", + "required": false, + "group": 4 + }, + "bookingTime": { + "title": "Booking Date", + "type": "datetime", + "required": false, + "group": 4 + }, + "cancelReservationUrl": { + "title": "Cancel URL", + "type": "url", + "required": false, + "group": 5 + }, + "checkinDate": { + "title": "Checkin Time", + "type": "datetime", + "required": true, + "group": 1 + }, + "checkoutDate": { + "title": "Checkout Time", + "type": "datetime", + "required": true, + "group": 1 + }, + "confirmReservationUrl": { + "title": "Confirm URL", + "type": "url", + "required": false, + "group": 5 + }, + "lodgingUnitDescription": { + "title": "Room Description", + "type": "text", + "required": false, + "group": 2 + }, + "modifiedTime": { + "title": "Modified Time", + "type": "datetime", + "required": false, + "group": 6 + }, + "modifyReservationUrl": { + "title": "Modify URL", + "type": "url", + "required": false, + "group": 5 + }, + "numAdults": { + "title": "Number of Adults", + "type": "number", + "required": false, + "group": 2, + "short": true + }, + "numChildren": { + "title": "Number of Children", + "type": "number", + "required": false, + "group": 2, + "short": true + }, + "price": { + "title": "Price", + "type": "decimal", + "required": false, + "group": 2, + "short": true + }, + "priceCurrency": { + "title": "Currency", + "type": "text", + "required": false, + "group": 2, + "short": true + }, + "programMembership_memberNumber": { + "title": "Member No.", + "type": "text", + "required": false, + "group": 3, + "short": true + }, + "programMembership_program": { + "title": "Name of Program", + "type": "text", + "required": false, + "group": 3, + "short": true + }, + "reservationFor_address_addressCountry": { + "title": "Country", + "type": "country", + "required": true, + "group": 0 + }, + "reservationFor_address_addressLocality": { + "title": "City", + "type": "text", + "required": true, + "group": 0 + }, + "reservationFor_address_addressRegion": { + "title": "Region", + "type": "text", + "required": true, + "group": 0, + "short": true + }, + "reservationFor_address_postalCode": { + "title": "Zip Code", + "type": "number", + "required": true, + "group": 0, + "short": true + }, + "reservationFor_address_streetAddress": { + "title": "Street", + "type": "text", + "required": true, + "group": 0 + }, + "reservationFor_name": { + "title": "Hotel Name", + "type": "text", + "required": true, + "group": 0 + }, + "reservationFor_image": { + "title": "Hotel Image URL", + "type": "url", + "required": false, + "group": 0 + }, + "reservationFor_telephone": { + "title": "Telephone", + "type": "tel", + "required": true, + "group": 0, + "short": true + }, + "reservationFor_url": { + "title": "Website URL", + "type": "url", + "required": false, + "group": 0 + }, + "reservationNumber": { + "title": "Reservation #", + "type": "text", + "required": true, + "group": 2, + "short": true + }, + "reservationStatus": { + "title": "Status", + "type": "status", + "required": true, + "group": 2, + "short": true + }, + "underName_name": { + "title": "Name on Reservation", + "type": "text", + "required": true, + "group": 2, + "default": "USER_NAME" + }, + "underName_email": { + "title": "Email address", + "type": "email", + "required": false, + "group": 2, + "default": "USER_EMAIL" + }, + "url": { + "title": "Booking URL", + "type": "url", + "required": false, + "group": 5 + } } } + diff --git a/index.php b/index.php index 816b268..b7aee28 100644 --- a/index.php +++ b/index.php @@ -97,6 +97,8 @@ if (!$tpl_done && isset($_SESSION['access_token']) && $_SESSION['access_token']) case 'hotel': $tpl = $m->loadTemplate('hotel_html'); $tpl_done = true; + $action = 'hotel'; + require 'prep_form.php'; break; default: if (!$tpl_done) { diff --git a/prep_form.php b/prep_form.php new file mode 100644 index 0000000..111720d --- /dev/null +++ b/prep_form.php @@ -0,0 +1,34 @@ +$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);