get_is_territorial()){ require $_SERVER["DOCUMENT_ROOT"].'/php/modules/language_domain.php'; } else { require $_SERVER["DOCUMENT_ROOT"].'/php/modules/language.php'; } require $_SERVER["DOCUMENT_ROOT"].'/php/class/metatag.php'; require $_SERVER["DOCUMENT_ROOT"].'/php/class/hotel.php'; require $_SERVER["DOCUMENT_ROOT"].'/php/class/roomtype.php'; require $_SERVER["DOCUMENT_ROOT"].'/php/class/package.php'; require $_SERVER["DOCUMENT_ROOT"].'/php/class/offer.php'; require_once('../config/lang/'.$_lang["code"].'.php'); require_once('../tcpdf.php'); ini_set("memory_limit","36M"); header("Content-Type:text/html; charset=UTF-8"); $id = $_GET["id"]; if (empty($id) || ctype_digit($id) === false ){ exit; } //Load Meta //Load hotel $hotel = new Hotel(); $hotel->load($id,$_lang["code"]);; $hotel->set_description(); $images = $hotel->get_normal_images(); $hotel->set_simple_images(); $hotel->set_location(); $texts_features = get_texts_features($hotel->get_id(),$_lang); $_type_rooms = $hotel->get_all_type_rooms(); $type_rooms = $_type_rooms; // Meta $meta = new Metatag(); $meta->set_id_domini($domain_info->get_id()); $meta->set_strip_description($hotel->get_description()); $meta->set_keywords($hotel->get_keywords()); $meta->set_title($hotel->get_name()." - ".$hotel->get_city()." (".$hotel->get_province().")"); /** Functions **/ function get_texts_features($id,$_lang){ //get connection $mysqli = new PDO(MY_TYPE.':host='.MY_HOST.';dbname='.MY_BDD.';charset='.MY_CHARSET, MY_USER, MY_PASS); $sql = " SELECT description_".$_lang["code"]." as description, description_type FROM hotel_caracteristicas WHERE id_hotel = ".$id." ORDER BY description_type ASC "; $stmt = $mysqli->prepare($sql); //bind parameters $stmt->bindValue(1, $id, PDO::PARAM_INT); //execute it $stmt->execute(); //extract result while ($reg = $stmt->fetch()){ $_texts[$reg["description_type"]] = $reg["description"]; } //close conection unset($stmt); unset($mysqli); return ($_texts); } function get_packages_of_hotel($id_hotel,$_lang){ $_packages = array(); //get connection $mysqli = new PDO(MY_TYPE.':host='.MY_HOST.';dbname='.MY_BDD.';charset='.MY_CHARSET, MY_USER, MY_PASS); $sql = "SELECT p.id, p.name_".$_lang["code"]." as name, p.description_".$_lang["code"]." as description, p.static_url_".$_lang["code"]." as static_url FROM paquets p, paquets_dates pd, agencies a, hotel_agencia ha WHERE p.id_hotel = ? AND p.deleted = 0 AND p.id = pd.id_paquet AND pd.dia >= ? AND p.id_hotel = ha.id_hotel AND ha.id_agencia = a.id AND a.website = 1 GROUP BY p.id ORDER BY p.position ASC "; $stmt = $mysqli->prepare($sql); //bind parameters $stmt->bindValue(1, $id_hotel, PDO::PARAM_INT); $stmt->bindValue(2, date("Y-m-d")." 00:00:00", PDO::PARAM_STR); //execute it $stmt->execute(); //extract result while ($reg = $stmt->fetch()){ $package = new Package(); $package->set_id($reg["id"]); $package->set_name($reg["name"]); $package->set_description(html_entity_decode($reg["description"])); $package->set_static_url($reg["static_url"]); //Search dates valid package; $sql = "SELECT DATE_FORMAT(dia, '%m/%Y') as mes FROM paquets_dates WHERE id_paquet = ".$package->get_id()." AND actiu AND dia >= '".date("Y-m-d")."' GROUP BY mes ORDER BY dia ASC;"; $result1 = mysql_query($sql); while ($reg1 = mysql_fetch_array($result1)){ $package->add_date($reg1["mes"]); } array_push($_packages,$package); } //close conection unset($stmt); unset($mysqli); return ($_packages); } function get_offers_of_hotel($id_hotel,$_lang){ $_offers = array(); //get connection $mysqli = new PDO(MY_TYPE.':host='.MY_HOST.';dbname='.MY_BDD.';charset='.MY_CHARSET, MY_USER, MY_PASS); $sql = "SELECT p.id, p.name_".$_lang["code"]." as name, p.description_".$_lang["code"]." as description, p.static_url_".$_lang["code"]." as static_url FROM ofertes p, ofertes_dates pd, agencies a, hotel_agencia ha WHERE p.id_hotel = ? AND p.deleted = 0 AND p.id = pd.id_oferta AND pd.dia >= ? AND p.id_hotel = ha.id_hotel AND ha.id_agencia = a.id AND a.website = 1 GROUP BY p.id ORDER BY p.position ASC "; $stmt = $mysqli->prepare($sql); //bind parameters $stmt->bindValue(1, $id_hotel, PDO::PARAM_INT); $stmt->bindValue(2, date("Y-m-d")." 00:00:00", PDO::PARAM_STR); //execute it $stmt->execute(); //extract result while ($reg = $stmt->fetch()){ $offer = new Offer(); $offer->set_id($reg["id"]); $offer->set_name($reg["name"]); $offer->set_description(html_entity_decode($reg["description"])); $offer->set_static_url($reg["static_url"]); //Search dates valid offer; $sql = "SELECT DATE_FORMAT(dia, '%m/%Y') as mes FROM ofertes_dates WHERE id_oferta = ".$offer->get_id()." AND actiu AND dia >= '".date("Y-m-d")."' GROUP BY mes ORDER BY dia ASC;"; $result1 = mysql_query($sql); while ($reg1 = mysql_fetch_array($result1)){ $offer->add_date($reg1["mes"]); } array_push($_offers,$offer); } //close conection unset($stmt); unset($mysqli); return ($_offers); } function get_texts_positions($section,$position,$_lang,$id_domini){ $_texts = array(); //get connection $mysqli = new PDO(MY_TYPE.':host='.MY_HOST.';dbname='.MY_BDD.';charset='.MY_CHARSET, MY_USER, MY_PASS); $sql = " SELECT name_".$_lang["code"]." as name, description_".$_lang["code"]." as description FROM wc_textos WHERE section = ? AND text_position = ? AND id_domini = ? ORDER BY text_order ASC; "; $stmt = $mysqli->prepare($sql); //bind parameters $stmt->bindValue(1, $section, PDO::PARAM_STR); $stmt->bindValue(2, $position, PDO::PARAM_STR); $stmt->bindValue(3, $id_domini, PDO::PARAM_INT); //execute it $stmt->execute(); //extract result while ($reg = $stmt->fetch()){ array_push($_texts,$reg); } //close conection unset($stmt); unset($mysqli); return ($_texts); } function get_urls($table,$_lang){ $_urls = array(); //get connection $mysqli = new PDO(MY_TYPE.':host='.MY_HOST.';dbname='.MY_BDD.';charset='.MY_CHARSET, MY_USER, MY_PASS); $sql = "SELECT id,name_".$_lang["code"]." as name,name_url_format as name_url FROM ".$table." ORDER BY id ASC"; $stmt = $mysqli->prepare($sql); //execute it $stmt->execute(); //extract result while ($reg = $stmt->fetch()){ $_urls[$reg["id"]]["url"] = "/".$reg["name_url"]."-".$_lang["hotels"].".html"; $_urls[$reg["id"]]["name"] = $reg["name"]; } //close conection unset($stmt); unset($mysqli); return ($_urls); } function get_date_small_formats($reg_mysql,$_lang){ $aux = split("-",substr($reg_mysql,0,10)); return ($aux[2]." ".$_lang["month_".$aux[1]]." ".$aux[0]); } function replace($string){ $string = str_replace("’","'",$string); $string = str_replace("‘","'",$string); $string = str_replace("•","",$string); return $string; } set_time_limit ( 600 ); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); if($_lang["code"]=="ru") $font = 'dejavusans'; else $font = "helvetica"; // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor($meta->get_autor()); $pdf->SetTitle($meta->get_title()); $pdf->SetSubject($meta->get_description()); $pdf->SetKeywords($meta->get_keywords()); // set default header data $pdf->SetHeaderData($root_domain.".jpg", "50", $meta->get_title(), $domain."\n".date('d')." ".$_lang["full_month_".date('m')]." ".date('Y, H:i:s')); // set header and footer fonts $pdf->setHeaderFont(Array($font, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array($font, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //HTML MARGIN $tagvs = array('p' => array(0 => array('h' => 0, 'n' => 0), 1 => array('h' => 0, 'n' => 0))); $pdf->setHtmlVSpace($tagvs); $pdf->setCellHeightRatio(1.25); $pdf->SetCellPadding(0); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont($font, '', 10); // add a page $pdf->AddPage(); // define some HTML content with style $html = '
'; if(file_exists($_SERVER["DOCUMENT_ROOT"].'/img/maps/'.$hotel->get_id().'.gif')){ $html .= ''; } $html .= '

'.$hotel->get_name().' '.$hotel->get_category_stars().'

'.$hotel->get_street().', '.$hotel->get_number().'
'.$hotel->get_postal_code()." ".$hotel->get_city().'('.$hotel->get_province().')
'; if ($hotel->get_show_info()) { $html .= '
Tel. '.$hotel->get_telephone().'
'.$hotel->get_email().'
'; } if (($hotel->get_image_logo("url") != "") && file_exists($_SERVER["DOCUMENT_ROOT"].$hotel->get_image_logo("url"))) { $html .= '
'; } $html .= '





'.replace($hotel->get_all_description_without_seo()).'

'; $i=0; foreach($type_rooms as $type){ $i++; if($i<=4) { $img = $type->get_first_image(); $html .= '

'.$type->get_name().'

'; if($img){ $html .= ''; } $html .= '
'.$type->get_first_image_title().''.replace($type->get_all_description()).'

'; } } // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); // --------------------------------------------------------- // add a page $pdf->AddPage(); // --------------------------------------------------------- $html = '
'; if($hotel->get_wifi() != ""){ $html .= 'Wifi - HotSpot'; } $html .= '

'.$_lang['hotel_features'].'

'; if(isset($texts_features['propiedad']) && $texts_features['propiedad'] != ""){ $html .= '

'.$_lang['hotel_features'].'

'; $html .= replace($texts_features['propiedad']); } if(isset($texts_features['parking']) && $texts_features['parking'] != ""){ $html .= '

'.$_lang['hotel_parking'].'

'; $html .= replace($texts_features['parking']); } if(isset($texts_features['tiendas']) && $texts_features['tiendas'] != ""){ $html .= '

'.$_lang['hotel_shops'].'

'; $html .= replace($texts_features['tiendas']); } $html .= ''; if(isset($texts_features['restaurantes']) && $texts_features['restaurantes'] != ""){ $html .= '

'.$_lang['hotel_dining'].'

'; $html .= replace($texts_features['restaurantes']); } if(isset($texts_features['accesibilidad']) && $texts_features['accesibilidad'] != ""){ $html .= '

'.$_lang['hotel_accessibility'].'

'; $html .= replace($texts_features['accesibilidad']); } if(isset($texts_features['animales']) && $texts_features['animales'] != ""){ $html .= '

'.$_lang['hotel_policy'].'

'; $html .= replace($texts_features['animales']); } if(isset($texts_features['habitaciones']) && $texts_features['habitaciones'] != ""){ $html .= '

'.$_lang['hotel_room_features'].'

'; $html .= replace($texts_features['habitaciones']); } $html .= '
'; if(isset($texts_features['facilidades']) && $texts_features['facilidades'] != ""){ $html .= '

'.$_lang['hotel_facilities'].'

'; $html .= replace($texts_features['facilidades']); } if(isset($texts_features['gastronomia']) && $texts_features['gastronomia'] != ""){ $html .= '

'.$_lang['hotel_gastronomy'].'

'; $html .= replace($texts_features['gastronomia']); } if(isset($texts_features['actividades']) && $texts_features['actividades'] != ""){ $html .= '

'.$_lang['hotel_entertaiment'].'

'; $html .= replace($texts_features['actividades']); } $html .= '
'; $html .= ''; $html .= ''; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); // --------------------------------------------------------- /* // add a page $pdf->AddPage(); // --------------------------------------------------------- $html = '

'.$_lang['main_specials_offers'].'

'; foreach($offers as $offer){ $html .= '

'.$offer->get_name().'

'; foreach($offer->get_dates() as $date){ $html .= '

· '.$date.'

'; } $html .= '
'; } if(count($offers) == 0){ $html .= '

· '.$_lang['offer_no_found'].'

'; } $html .= '

'.$_lang['main_packages'].'

'; $i=0; foreach($packages as $package){ $i++; $html .= '

'.$package->get_name().'

'; foreach($package->get_dates() as $date){ $html .= '

· '.$date.'

'; } $html .= '
'; } if(count($packages) == 0){ $html .= '

· '.$_lang['package_no_found'].'

'; } $html .= '
'; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); */ //Close and output PDF document $pdf->Output('example_'.rand().'.pdf', 'I'); ?>