} if (isset($_POST['table'])) { $_SESSION['lastHoteles'] = $hoteles; $result = array("iTotalRecords" => $cont, "iTotalDisplayRecords" => $cont, 'aaData' => $hoteles); } else { $smarty->assign('hoteles', $hs); $html = $smarty->fetch('admin/hotel/filtros.tpl'); $result['html'] = $html; $result['msg'] = 'ok'; } } else { if (strcmp($action, 'urlValidacion') == 0) { if (isset($_POST['id'])) { $id = $_POST['id']; $hotel_v = getHotelById($id); $login_code = getLoginCodeByHotelId($id); $nombre = $hotel_v->nombre; $body = "\n Hotel: {$nombre} <br>\n Para validar sus reservas haga click en el siguiente link o copie y pegue la dirección en su navegador:<br>\n <a href='{$vikahotel_url}/validar?login_code={$login_code}'>{$base_url}/validar?login_code={$login_code}</a><br>\n <i>Enviado desde " . $smarty->getConfigVariable('sistema_nombre') . "</i>\n "; try { $mail = new Core_Mailer(); $mail->send_email($hotel_v->distribuidor->emailReservas, 'Url de validación de reservas de ' . $nombre, $body); } catch (Exception $e) { print_r($e); } $result = array('msg' => 'ok', 'data' => 'Se le ha enviado un email al hotel con la url de validación de reservas'); } } else { if (strcmp($action, 'updatefields') == 0) { if (isset($_POST['edit'])) { $edit = $_POST['edit']; foreach ($edit as $idHotel => $data) {
function enviarEmailFactura($idFactura) { try { $factura = getFactura($idFactura); $hotel = getHotelById($factura->hotelId); global $vikahotel_url; global $base_url; $login_code = getLoginCodeByHotelId($factura->hotelId); $factura_code = encryptId($idFactura); $subject = "Url de Factura de " . $hotel->nombre . " del " . date('d/m/Y', strtotime($factura->tiempoCreacion)); $body = "Para ver la factura haga click en el siguiente link o copie y pegue la dirección en su navegador:<br>"; $body .= "<a href='{$vikahotel_url}/facturacion?login_code={$login_code}&fcode={$factura_code}'>{$vikahotel_url}/facturacion?login_code={$login_code}&fcode={$factura_code}</a>"; $email = $hotel->emailReservas; $mail = new Core_Mailer(); $mail->send_email($email, $subject, $body); } catch (Exception $e) { print_r($e); return false; } }
foreach ($facturas as $pos => $fact) { if ($fact['cliente'] == 'hotel') { $facturas[$pos]['clienteNombre'] = $fact['hotel']; } else { $factura = getFactura($fact['id']); $reserva = $factura->reservas[0]; if ($reserva) { $facturas[$pos]['clienteNombre'] = $reserva->usuario->nombre . ' ' . $reserva->usuario->apellido; } } $total_facturado += $fact['total']; $total_comisiones += $fact['comision']; $facturas[$pos]['tiempoCreacion'] = date('d-m-Y', strtotime($fact['tiempoCreacion'])); $facturas[$pos]['total'] = $fact['moneda'] . number_format($fact['total'], 2, ',', ''); $facturas[$pos]['comision'] = $fact['moneda'] . number_format($fact['comision'], 2, ',', ''); $login_code = getLoginCodeByHotelId($fact['hotelId']); $factura_code = encryptId($fact['id']); $facturas[$pos]['url'] = "{$base_url}/facturacion?login_code={$login_code}&fcode={$factura_code}"; } $total = count(getAllFacturas()); $filtered = countFacturasByArgs($args); if (count($facturas)) { $total_facturado = '€' . number_format($total_facturado, 2, ',', ''); $total_comisiones = '€' . number_format($total_comisiones, 2, ',', ''); $facturas[] = array('cliente' => '', 'clienteNombre' => '', 'estado' => '', 'hotel' => '', 'hotelId' => '', 'id' => '', 'total' => "<b>Total:<br> {$total_facturado}</b>", 'comision' => "<b>Comisión:<br> {$total_comisiones}</b>", 'numero' => '', 'tiempoCreacion' => '', 'url' => ''); } $result = array("iTotalRecords" => $total, "totalFacturado" => $total_facturado, "totalComisiones" => $total_comisiones, "iTotalDisplayRecords" => $filtered, 'aaData' => $facturas); } if (strcmp($action, 'cambiarEstado') == 0) { if (isset($_POST['id'])) { $facturaId = $_POST['id'];