XML Export

XML export is available at address http://www.a-prague.com/xml/export.php. At this address, it is necessary to pass login name in parameter login and password in password in URL or POST data. Special privilege is needed to access the XML export.

Without other parameters, list of all possible tables are returned. Each of this table can be passed in GET parameter table. In this case, complete content of the table is returned.

Errors

In case of an error (authorization, invalid table name ...), a single element <error> with error description is returned.

Format of the Returned Data

Root document element is <resultset>; every row of a table is enclosed in <row> tag. In every table row, there is a list of <field> tags with name attribute holding the name of a column. All values are plain text data - if they contain HTML fragment, it is properly encoded. Empty values (NULL) are not passed.

Texts are available in several languages. These texts are saved in columns column_en, column_de and similar. These columns are described as column_LANG in documentation. List of used languages is available in table jazyky. All texts are available in English version, other translations may be missing - they are not transferred in this case.

All data are transferred in UTF-8 encoding.

Data Saving

Interface allows also saving new orders and hotel feedbacks. In this case, parameter save holding objednavka or hodnoceni is passed instead of table.

Price Calculation

There are several tables participating in price calculation. Basic price is stored in the pokoj_cenik table. Prices of extra services are stored in the hotel_cena table; no discounts are applied for these prices.

The hotel can apply a discount to all rooms - this is stored in the hotel_specialni_nabidka table. Discount can be expressed by absolute value or by percentage (determined by mena column) and can be valid only for some number of persons (min_osob, max_osob). In the same table, there are stored also offers "X nights for the price of Y" (in columns x, y and jednorazove) and offers of free transfer (in columns x and transfer).

Discounts for single room can be also applied - they are stored in the pokoj_cenik_sleva table. They can be expressed in absolute or relative way (mena) and they can be valid only from particular number of nights (min_noci).

Extra Beds

Number of beds is stored in pokoj table in pocet_luzek column. Maximal possible number of extra beds is stored in pristylka column. Extra beds are stored either in hotel_cena table in rows with specialni column set to extra_bed or in pokoj table in rows with byt column set to extra_bed. Second style is used in case when prices change during the year.

Data import

It is recommended to store the data from XML to own database and show them from the database on the web pages. Database should be created from the documentation of individual tables by the following PHP script:

<?php
$jazyky
= array();
$xml = simplexml_load_file("http://www.a-prague.com/xml/export.php?login=" . LOGIN . "&password=" . PASSWORD . "&table=jazyky");
foreach (
$xml->row as $row) {
$jazyk = array();
foreach (
$row->field as $field) {
$jazyk[(string) $field["name"]] = (string) $field;
}
$jazyky[] = $jazyk;
}

$file = file_get_contents("http://www.a-prague.com/xml-export-documentation");
preg_match_all('~<h3><a name="(.+)"(.*)</table>~sU', $file, $tables, PREG_SET_ORDER);
foreach (
$tables as $table) {
preg_match_all('~<th>(.+)</th>\\s*<td>(.+)</td>~sU', $table[2], $columns, PREG_SET_ORDER);
$create = array();
foreach (
$columns as $column) {
$typ = preg_replace('~ - .*~s', '', strip_tags($column[2]));
if (
substr($column[1], -5) == "_LANG") {
foreach (
$jazyky as $jazyk) {
$create[] = substr($column[1], 0, -4) . "$jazyk[id] $typ COLLATE utf8_$jazyk[mysql_kodovani]_ci";
}
} else {
$create[] = "$column[1] $typ";
}
}
mysql_query(
"CREATE TABLE $table[1] (\n\t" . implode(",\n\t", $create) . "\n);\n\n");
}

Data can be imported in PHP by the following script:

<?php
$xmlreader
= new XMLReader;
$result = mysql_query("SHOW TABLES");
while (
$row = mysql_fetch_row($result)) {
$table = $row[0];
$xmlreader->open("http://www.a-prague.com/xml/export.php?login=" . LOGIN . "&password=" . PASSWORD . "&table=$table");
$columns = array();
$result1 = mysql_query("SHOW COLUMNS FROM $table");
while (
$row1 = mysql_fetch_assoc($result1)) {
$columns[$row1["Field"]] = $row1["Type"];
}
mysql_free_result($result1);
mysql_query("TRUNCATE $table");
$set = array();
while (
$xmlreader->read()) {
if (
$xmlreader->nodeType == XMLReader::ELEMENT && $xmlreader->name == "field") {
$column = $xmlreader->getAttribute("name");
$xmlreader->read();
if (isset(
$columns[$column])) {
$set[$column] = "'" . addslashes($xmlreader->value) . "'";
}
} elseif (
$xmlreader->nodeType == XMLReader::END_ELEMENT && $xmlreader->name == "row") {
mysql_query("INSERT INTO $table (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")");
$set = array();
}
}
$xmlreader->close();
}
mysql_free_result($result);
?>

Table Columns Description

hotel

id int Identifier
id_mesto int - nastaveni(id) City
id_typ int - hotel_typ(id) Type
jmeno_LANG varchar(127) Name
hvezdicky enum('1','2','3','4','5') Stars
hide_typ bool Hide type of a hotel
id_umisteni int - hotel_umisteni(id) Location
hodina_od time Check in
hodina_do time Check out
adresa_LANG tinytext Address
kontaktni_osoba varchar(127) Contact person
latitude double Latitude
longitude double Altitude
popis_description_LANG text Description
popis_location_LANG text Description - Location
popis_suitable_LANG text Description - Suitable for
pocet_pokoju int Total number of rooms - empties are computed from rooms
pocet_luzek int Total number of beds - empties are computed from rooms
hlaseni bool Show announce
hlaseni_LANG text Important notice (above description - in red)
search_note_LANG text Hotel description in search results
provize double(16,4) Provize [%]
provize_vypocet enum('bez_odectu','odecist_5proc','odecist_9proc','odecist_19proc') Way of computing
provize_dan double Tax percentage
skryt bool Hide in presentation
platba_predem bool Require payment in advance
skryt_cenik bool V prezentaci nezobrazovat ceník
platba_LANG tinytext Přijímaná platba
id_storno_podminky int - storno_podminky(id) Cancellation conditions
pevna_mena char(3) - kurzy(mena) Currency
alternativni_ceny set('Sun','Mon','Tue','Wed','Thu','Fri','Sat') Alternative prices
popularita int Popularity
popularita_obdobi int Popularita bez období
mistni_poplatek int Místní poplatek [Kč/osoba/noc]

kreditni_karty_hotelu

id_hotel int - hotel(id) Identifier

hotel_skupiny

id_hotel int - hotel(id) Identifier

hotel_storno

id int Identifier
id_hotel int - hotel(id) Identifier
od date From
do date To
storno_LANG text Cancellation

hotel_obsazeno

id int Identifier
id_hotel int - hotel(id) Identifier
datum_od date Occupied since
datum_do date Occupied till

foto

id int Identifier
id_hotel int - hotel(id) Identifier
pozice int Order
soubor varchar(127) File - ../data/hotel-
sirka int   -
vyska int   -
text_LANG varchar(127) Description

hotel_cena

id int Identifier
id_hotel int - hotel(id) Hotel
text_LANG varchar(127) Description
specialni enum('extra_bed') Special
cena_mena decimal(9,2) Price in currency
jednorazove bool One-off payment (not for each night)
provize bool Include to commission
skryt bool Hide in presentation

hotel_specialni_nabidka

id int Identifier
id_hotel int - hotel(id) Hotel
od date From
do date To
cena double Discount applied on all room-types
mena enum('mena', '%') Currency
x tinyint X (X nights for the price of Y)
y tinyint Yes
jednorazove bool One-off (only night for free)
transfer bool Free transfer above X nights
min_osob int Minimální počet osob
max_osob int Maximální počet osob
text_LANG varchar(127) Offer
vytvoreno datetime Changed

pokoj

id int Identifier
id_hotel int - hotel(id) Hotel
typ_LANG varchar(127) Room type
pocet_luzek int Beds
pristylka int Additional beds (not included)
byt enum('ne','ano','dormy','extra_bed') Apartment
mistnosti tinyint Místností
poschodi tinyint(4) Floor
pocet int Množství
alotment_pocet int Number of rooms in allotment
program bool Soujourn program
skryt bool Hide in presentation
popis_LANG text Description

vybaveni_hotelu_pokoje

id_umisteni int - pokoj(id) Identifier

pokoj_min_noci

id int Identifier
id_pokoj int - pokoj(id) Identifier
od date From
do date To
min_noci int Minimum stay (nights)

pokoj_obsazeno

id int Identifier
id_pokoj int - pokoj(id) Identifier
od date From
do date To
pocet int Number of free rooms

pokoj_cenik

id int Identifier
id_hotel int - hotel(id) Identifier
id_pokoj int - pokoj(id) Room
od date From
do date To
cena double Price
alternativni_cena double Alternative price

pokoj_cenik_sleva

id int Identifier
id_hotel int - hotel(id) Identifier
id_pokoj int - pokoj(id) Room
od date From
do date To
cena double Discount
mena enum('mena','%') Type of discount (currency/%)
min_noci int Minimum stay (nights)

hodnoceni

id int Identifier
id_hotel int - hotel(id) Hotel
id_objednavka int - objednavka(id) Order
jmeno varchar(50) Name
email varchar(50) E-mail
jazyk char(2) - jazyky(id) Language
datum date Date
hodina time Time
id_druh int - hodnoceni_druh(id) Type
text text Message
plus text Plus
minus text Mínus
odpoved text Our answer

hodnoceni_text

id_hodnoceni int - hodnoceni(id) Identifier
znamka int Grade

hodnoceni_druh

id int Identifier
poradi int Order
nazev_LANG varchar(30) Name

hodnoceni_typ

id int Identifier
poradi int Order
nazev_LANG varchar(30) Name

hotel_skupina

id int Identifier
poradi int Order
nazev_LANG varchar(30) Name

nastaveni

mesto_LANG varchar(50) City
stat char(2) - staty(idf) Country
latitude double Latitude
longitude double Altitude

jazyky

id char(2) Identifier
kod char(2) Code for HTML
poradi int Order
nazev varchar(30) Name
vlajecka varchar(250) Flag - ../data/jazyk-
admin bool Use in admin
mena char(3) - kurzy(mena) Default currency
mysql_kodovani enum('general','icelandic','latvian','romanian','slovenian','polish','estonian','spanish','swedish','turkish','czech','danish','lithuanian','slovak','spanish2','roman','persian') MySQL encoding
datum_format varchar(20) Date format for PHP date()

staty

id int Identifier
idf char(2) Code
stat_LANG varchar(30) Country

hotel_typ

id int Identifier
poradi int Order
ikona varchar(100) Icon on map - ../data/typ-
text_LANG varchar(127) Type
texty_LANG varchar(127) Typ v množném čísle

hotel_umisteni

id int Identifier
id_mesto int - nastaveni(id) City
id_umisteni enum('out','near','centrum') Area
poradi int Order
text_LANG varchar(255) City part
hranice varchar(250) Hranice městské části (EncodedPolyline)
hranice_levels varchar(64) Hranice městské části (EncodedLevels)
latitude double Zeměpisná šířka nadpisu
longitude double Zeměpisná délka nadpisu

storno_podminky

id int Identifier
storno_LANG text Text

kreditni_karty

id int Identifier
poradi int Order
ikona varchar(50) Icon - ../data/kreditka-
text_LANG varchar(127) Name
bookable bool Použitelná pro platbu

vybaveni

id int Identifier
ikona varchar(50) Icon - ../data/vybaveni-
text_LANG varchar(255) Vybavení

kurzy

id int Identifier
mena char(3) Currency
kurz double(16,4) Rate
predchozi_kurz float Previous rate
datum date Date

url

id int Identifier
id_mesto int - nastaveni(id) City
titulek_LANG tinytext Page title
url_LANG varchar(250) Friendly URL
slogan_LANG tinytext Slogan above menu
keywords_LANG tinytext META Keywords
description_LANG tinytext META Description
noindex bool Don't index by robots
tabulka_id int - hotel(id) smazání provádí u všech typů objektů url_1a.inc.php