<?php $logged = $usuario_core->validateUser(); exit; $hoteles = getAllHoteles(); $keys = array(); foreach ($hoteles as $h_k => $hotel) { $key = getClaveByHotel($hotel->id); $keys[$h_k]['hotel'] = $hotel->nombre; $keys[$h_k]['key'] = $key; } include 'Lib/excel/PHPExcel.php'; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Matias Barbarroja")->setTitle("d")->setSubject("Exportadas"); $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'Hotel')->setCellValue('B1', 'Key'); if (count($keys)) { $counter = 2; foreach ($keys as $k) { $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $counter, $k['hotel'])->setCellValue('B' . $counter, $k['key']); $counter++; } header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="Keys.xls"'); header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be needed header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
function getHotelesByUsuario($idUsuario, $data = true) { try { $usuario = DAOFactory::getUsuarioDAO()->load($idUsuario); if ($usuario->usuarioGrupoId == 1) { return getAllHoteles(); } $hoteles = DAOFactory::getHotelDAO()->queryByUsuarioId($idUsuario); if (!$data) { return $hoteles; } foreach ($hoteles as $hotel) { if ($hotel->nombre && strlen(trim($hotel->nombre)) > 2 && $hotel->nombre[0] == '{' && $hotel->nombre[strlen($hotel->nombre) - 1] == '}') { $hotel->nombre = json_decode(trim($hotel->nombre))->es; } if ($hotel->descripcionCorta && strlen(trim($hotel->descripcionCorta)) > 0) { $hotel->descripcionesCortas = json_decode(trim($hotel->descripcionCorta)); } if ($hotel->descripcionLarga && strlen(trim($hotel->descripcionLarga)) > 0) { $hotel->descripcionesLargas = json_decode(trim($hotel->descripcionLarga)); } $hotel->dominios = DAOFactory::getHotelDominiosDAO()->queryByHotelId($hotel->id); $hotel->campania = DAOFactory::getCampaniaDAO()->load($hotel->campaniaId); } return $hoteles; } catch (Exception $e) { return false; } }