Exemple #1
0
function updateFactura($id, $data = array(), $trasactional = true)
{
    try {
        if ($trasactional) {
            $transaction = new Transaction();
        }
        $factura = getFactura($id);
        $factura = DAOFactory::getFacturaDAO()->prepare($data, $id);
        DAOFactory::getFacturaDAO()->update($factura);
        if ($trasactional) {
            $transaction->commit();
        }
        return true;
    } catch (Exception $e) {
        var_dump($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
Exemple #2
0
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;
    }
}
Exemple #3
0
        $facturas[$pos]['url'] = "{$base_url}/facturacion?login_code={$login_code}&fcode={$factura_code}";
    }
    $total = count(getAllFacturas());
    $filtered = countFacturasByArgs($args);
    if (count($facturas)) {
        $total_facturado = '&euro;' . number_format($total_facturado, 2, ',', '');
        $total_comisiones = '&euro;' . 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'];
        $factura = getFactura($_POST['id']);
        $estadoAnterior = $factura->estado;
        cambiarEstadoFactura($facturaId, $estado);
        $result['msg'] = 'ok';
        $result['data'] = 'Se guardaron los datos correctamente';
    }
}
if (strcmp($action, 'enviarLink') == 0) {
    if (isset($_POST['idFactura'])) {
        //Temporal enviarEmailFactura($_POST['idFactura']);
        $result = array('msg' => 'ok', 'data' => 'Enviamos la dirección de la factura al email del hotel');
    } else {
        $result['data'] = 'Seleccione la factura';
    }
}
echo json_encode($result);
Exemple #4
0
<?php

$logged = $usuario_core->validateUser();
if ($logged) {
    if (isset($_GET['id'])) {
        $factura = getFactura($_GET['id']);
        $hotel = getHotelById($factura->hotelId);
        if ($hotel && $factura) {
            $moneda = 'EUR';
            $reservas = $factura->reservas;
            if (count($reservas)) {
                $hotel->empresa = getEmpresaById($hotel->empresaId);
                $totalFacturado = $factura->total;
                $totalComisiones = $factura->comision;
                $smarty->assign('factura', $factura);
                $smarty->assign('hotel', $hotel);
                $smarty->assign('reservas', $reservas);
                $smarty->assign('totalFacturado', $totalFacturado);
                $smarty->assign('totalComisiones', $totalComisiones);
                $smarty->assign('backUrl', $base_url . '/admin-factura-lista');
                $smarty->display('admin/factura1.tpl');
            } else {
                // header('Location:' . $base_url . '/admin-login');
            }
        } else {
            // header('Location:' . $base_url . '/admin-login');
        }
    } else {
        //header('Location:' . $base_url . '/admin-login');
    }
}
Exemple #5
0
<?php

if (isset($_REQUEST['login_code']) && isset($_REQUEST['fcode'])) {
    $login_code = $_REQUEST['login_code'];
    $fcode = $_REQUEST['fcode'];
    $hotelId = getHotelIdByLoginCode($login_code);
    $factura = getFactura(decryptId($fcode));
    if ($hotelId && $factura && $factura->hotelId == $hotelId) {
        $moneda = 'EUR';
        $reservas = $factura->reservas;
        if (count($reservas)) {
            $hotel = getHotelById($hotelId);
            $hotel->empresa = getEmpresaById($hotel->empresaId);
            $totalFacturado = $factura->total;
            $totalComisiones = $factura->comision;
            $smarty->assign('factura', $factura);
            $smarty->assign('hotel', $hotel);
            $smarty->assign('reservas', $reservas);
            $reserva = $reservas[0];
            $smarty->assign('cliente', $reserva->usuario);
            $smarty->assign('totalFacturado', $totalFacturado);
            $smarty->assign('totalComisiones', $totalComisiones);
            $smarty->assign('backUrl', $base_url);
            if ($factura->cliente == 'hotel') {
                $smarty->display('admin/factura1.tpl');
            } else {
                $smarty->display('admin/factura_cliente.tpl');
            }
        } else {
            // header('Location:' . $base_url . '/admin-login');
        }
 public function generarFactura()
 {
     if (Input::has("persona_id")) {
         $persona = User::find(Input::get('persona_id'));
     } else {
         $persona = Auth::user();
     }
     $residencia = $persona->residencia;
     $time = new Carbon();
     $mes = Input::get('mes', $time->month);
     $año = Input::get('año', $time->year);
     $factura = DB::select(DB::raw(getFactura($residencia->id, $mes, $año)));
     $cant_residencias = Residencias::where("id", "<>", "1")->count();
     $maestra = json_decode(File::get(app_path("config/maestra.php")), true);
     $html = View::make('pdf.factura')->withFactura($factura)->withResidencia($residencia)->withPersona($persona)->withMes($mes)->with('año', $año)->withMaestra($maestra)->with('cant_residencias', $cant_residencias);
     $html = renderVariables($html);
     header('Content-Type : application/pdf');
     $headers = array('Content-Type' => 'application/pdf');
     return Response::make(PDF::load($html, 'A4', 'portrait')->show('factura-' . $mes . "-" . $año), 200, $headers);
 }