public function newPasswordEmail() { if ($this->isPost()) { $email = $_POST['email']; $User = M('User'); if ($currUser = $User->where("email = '{$email}'")->field("user_id, user_name")->find()) { $token = encryptId($currUser['user_id']); $subject = '[考评牛马] 重置密码'; $body = $this->prepareEmailBody($currUser['user_name'], $token); require_once COMMON_PATH . '/Mail/mail.php'; if (sendMail(array($email), $subject, $body)) { $this->success('几分钟后,您将收到重置密码的电子邮件'); } else { $this->error('重置密码邮件发送失败'); } } else { $this->error('该邮箱没有找到'); } } }
foreach ($emails as $email) { if (strlen(trim($email)) > 0) { $enviado = $mail->send_email($email, $subject, $body); } } } //$result['email'] = $body; } catch (Exception $e) { print_r($e); } } else { if ($estado == 'Aprobada') { set_time_limit(0); try { $reservacion = getReserva($reservaId); $reservacion->id = encryptId($reservaId); $hotel = getHotelById($reserva->hotelId); $subject = 'New Booking ' . $hotel->nombres->es . ' [Confirmed]'; $smarty->assign('hotel', $hotel); $smarty->assign('usuario', get_object_vars($reservacion->usuario)); $apartamento = $reservacion->alojamiento[0]; $smarty->assign('reserva', $reservacion); $smarty->assign('entrada', $apartamento->inicio); $smarty->assign('salida', $apartamento->final); $noches = ceil((strtotime($apartamento->final) - strtotime($apartamento->inicio)) / (24 * 60 * 60)); $smarty->assign('noches', $noches); if ($hotel && $hotel->campaniaId) { $campania = getCampania($hotel->campaniaId); $smarty->assign('campania', $campania); } if ($reservacion->idiomaId) {
function enviarEmailNuevaReserva($idReserva) { try { global $smarty; $reservacion = getReserva($idReserva); $reservacion->id = encryptId($idReserva); $smarty->assign('reserva', $reservacion); $cart = $reservacion->cart; $data_user = array('nombre' => $reservacion->usuario->nombre, 'apellido' => $reservacion->usuario->apellido, 'email' => $reservacion->usuario->email, 'telefono' => $reservacion->usuario->telefono); $smarty->assign('usuario', $data_user); $hotel = getHotelById($reservacion->hotelId); $subject = 'New Booking ' . $hotel->nombres->es . ' [' . $reservacion->localizador . ']'; $smarty->assign('entrada', $reservacion->alojamiento[0]->inicio); $smarty->assign('salida', $reservacion->alojamiento[0]->final); $noches = ceil((strtotime($reservacion->alojamiento[0]->final) - strtotime($reservacion->alojamiento[0]->inicio)) / (24 * 60 * 60)); $smarty->assign('noches', $noches); $pais = getPais($reservacion->usuario->paisId); $smarty->assign('pais', $pais->nombre); $smarty->assign('base_url', $cart->url); $smarty->assign('currency', $moneda); $campania = false; $smarty->assign('hotel', $hotel); if ($hotel && $hotel->campaniaId) { $campania = getCampania($hotel->campaniaId); $smarty->assign('campania', $campania); } $body = $smarty->fetch('confirmacionEmail_nodesign.tpl'); $cobroAnticipado = 0; foreach ($reservacion->productos as $producto) { $cobroAnticipado += $producto->importeInicial; } //generar factura if ($cobroAnticipado && $reservacion->estado == 'Aprobada') { $factura = generarFactura($reservacion, $hotel); } else { $factura = 0; } $mail = new Core_Mailer(); /* enviando email al usuario */ $enviado = $mail->send_email($data_user['email'], $subject, $body, $factura); if ($factura) { //TODO: eliminar pdf $mail = new Core_Mailer(); @unlink($factura); } $emails = $hotel->emailReservas; $emails = explode(',', $emails); $reserva_url = getReservaUrl($idReserva); $smarty->assign('reserva_url', $reserva_url); $body = $smarty->fetch('reservaEmail_nodesign.tpl'); if ($campania) { $subject = 'New Booking ' . $reservacion->localizador . ' [contrato ' . $campania->localizador . ']'; } else { $subject = 'New Booking ' . $hotel->nombres->es . ' ' . $reservacion->localizador; } $emailDistribuidor = explode(',', $hotel->distribuidor->emailReservas); if ($emailDistribuidor && count($emailDistribuidor)) { foreach ($emailDistribuidor as $email) { if (strlen(trim($email)) > 0) { $enviado = $mail->send_email($email, $subject, $body); } } } if ($reservacion->estado == 'Aprobada') { //cuando no es onrequest foreach ($emails as $email) { if (strlen(trim($email)) > 0) { $enviado = $mail->send_email($email, $subject, $body); } } if ($reservacion->extras) { foreach ($reservacion->extras as $excursion) { if ($excursion->emails && explode(',', $excursion->emails)) { $smarty->assign('excursion', $excursion); $body = $smarty->fetch('confirmacionExcursion_nodesign.tpl'); $emails = explode(',', $excursion->emails); $subject = 'New Booking ' . $excursion->localizador; foreach ($emails as $email) { if (strlen(trim($email))) { $mail->send_email($email, $subject, $body); } } } } } } } catch (Exception $ex) { print_r($ex); } }
function decryptToken($token) { $idStr = decryptAlphabetToNum(substr($token, 10, strlen($token) - 20)); if (encryptId($idStr) == $token) { return $idStr; } else { return false; } }
function getLoginCodeByHotelId($id) { try { $hotel = DAOFactory::getHotelDAO()->load($id); $loginCode = encryptId($id); $loginCode .= '-' . encryptId(date('Y', strtotime($hotel->tiempoCreacion))); $loginCode .= '-' . encryptId(date('m', strtotime($hotel->tiempoCreacion))); $loginCode .= '-' . encryptId(date('d', strtotime($hotel->tiempoCreacion))); return $loginCode; } catch (Exception $e) { return false; } }
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']; $estado = $_POST['estado'];
<?php /* $reservaId = 276; $reservacion = getReserva($reservaId); $reservacion->id = encryptId($reservaId); $hotel = getHotelById($reserva->hotelId); print_r($reservacion->cart->apto); $subject = 'New Booking ' . $hotel->nombres->es . ' [Confirmed]'; $smarty->assign('hotel', $hotel); $smarty->assign('usuario', get_object_vars($reservacion->usuario)); $apartamento = $reservacion->alojamiento[0]; $smarty->assign('reserva', $reservacion); $smarty->assign('entrada', $apartamento->inicio); $smarty->assign('salida', $apartamento->final); $noches = ceil((strtotime($apartamento->final) - strtotime($apartamento->inicio))/(24*60*60)); $smarty->assign('noches', $noches); if($hotel && $hotel->campaniaId){ $campania = getCampania($hotel->campaniaId); $smarty->assign('campania',$campania); } if($reservacion->idiomaId) { $smarty->configLoad($reservacion->idioma->codigo . '.conf'); } $smarty->display('reservaEmail_nodesign.tpl');*/ $reserva = getReserva(432); $hotel = getHotelById($reserva->hotelId); $reserva->id = encryptId($reserva->id); generarFactura($reserva, $hotel);
$data_excursiones[$pos]['telefonoContacto'] = $reservacion->evento->telefono; $data_excursiones[$pos]['entradas'] = json_encode($reservacion->entradas); }*/ /** **/ $idioma_actual = isset($lang_set) ? getIdiomaByCodigo($lang_set) : getIdioma($hotel->idiomaId); $data_reserva['idiomaId'] = $idioma_actual->id; $idReserva = insertReserva($hotel->id, $data_reserva, $data_apartamento, $data_excursiones, $data_user, $data_pago, str_replace(',', '.', (string) $precio)); if ($idReserva) { $result = array(); $result['msg'] = 'ok'; $result['data'] = 'Se guardaron los datos correctamente'; $result['reserva_id'] = encryptId($idReserva); //$_SESSION['data_usuario'] = $data_user; $smarty->assign('usuario', $data_user); $reservacion = getReserva($idReserva); $reservacion->id = encryptId($idReserva); $smarty->assign('reserva', $reservacion); $subject = 'New Booking ' . $hotel->nombres->es . ' [' . $reservacion->localizador . ']'; $smarty->assign('entrada', $data_apartamento['inicio']); $smarty->assign('salida', $data_apartamento['final']); $noches = ceil((strtotime($data_apartamento['final']) - strtotime($data_apartamento['inicio'])) / (24 * 60 * 60)); $smarty->assign('noches', $noches); $pais = getPais($data_user['paisId']); $smarty->assign('pais', $pais->nombre); $smarty->assign('base_url', $cart->url); //$smarty->assign('currency', $moneda); $campania = false; $smarty->assign('hotel', $hotel); if ($hotel && $hotel->campaniaId) { $campania = getCampania($hotel->campaniaId); $smarty->assign('campania', $campania);