Exemple #1
0
 public function novedades()
 {
     $libro = new Libro();
     $ultimos = $libro->find('all', array('limit' => 5, 'order' => array('Libro.id' => 'desc')));
     if (empty($ultimos)) {
         $contenido = $this->_dameContenido('novedades');
         $this->set(array('contenido' => $contenido['texto'], 'fecha' => $contenido['fecha']));
     }
     if ($this->RequestHandler->isRss()) {
         return $this->set(compact('ultimos'));
     }
 }
 public function getDetailsbook()
 {
     $View = View::make('vistas.libro.details');
     $View->Titulo = 'Share On - Lee, es gratis - Estadisticas';
     $View->Libros = Libro::all();
     $View->Usuarios = Usuario::all();
     $View->Activo = Usuario::where('estadoUsuario', 1)->get();
     $View->Inactivo = Usuario::where('estadoUsuario', 0)->get();
     return $View;
 }
 public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     DB::table('libros')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         # code...
         Libro::create(['titulo' => $faker->text(40), 'isbn' => $faker->numberBetween(100, 999), 'precio' => $faker->randomFloat(2, 3, 150), 'publicado' => $faker->numberBetween(0, 1), 'descripcion' => $faker->text(400), 'autor_id' => $faker->numberBetween(1, 3), 'categoria_id' => $faker->numberBetween(1, 3)]);
     }
     // Uncomment the below to run the seeder
     // DB::table('libros')->insert($libros);
 }
Exemple #4
0
 public static function getUser($nombre, $pass)
 {
     $conexion = BD::getConexion();
     $select = "select * from usuario where nombre = :nombre AND password = :password";
     $query = $conexion->prepare($select);
     $query->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, "Usuario");
     $query->execute([":nombre" => $nombre, ":password" => $pass]);
     $usuario = $query->fetch();
     if ($usuario) {
         $usuario->setLibros(Libro::getLibros($usuario->getId_usuario()));
     }
     return $usuario;
 }
 /**
  * Filter the query by a related Libro object
  *
  * @param     Libro|PropelCollection $libro The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    Libro_colaboradorQuery The current query, for fluid interface
  */
 public function filterByLibro($libro, $comparison = null)
 {
     if ($libro instanceof Libro) {
         return $this->addUsingAlias(Libro_colaboradorPeer::IDLIBRO, $libro->getId(), $comparison);
     } elseif ($libro instanceof PropelCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(Libro_colaboradorPeer::IDLIBRO, $libro->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByLibro() only accepts arguments of type Libro or PropelCollection');
     }
 }
         $libroObj->save();
         file_put_contents(SITE_PATH . "/libros/libro_" . $libroObj->getId() . ".txt", $datos->texto);
         echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $libroObj->getId()));
     } else {
         $libroObj = LibroQuery::create()->findOneById($datos->idlibro);
         $libroObj->setNombre($datos->nombrelibro);
         //$libroObj->setTexto($datos->texto);
         $libroObj->save();
         file_put_contents(SITE_PATH . "/libros/libro_" . $datos->idlibro . ".txt", $datos->texto);
         echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $datos->idlibro));
     }
     break;
 case "version":
     //diff -y  -T --suppress-common-lines -a --strip-trailing-cr indexold.php index.php
     if ($datos->idlibro == "") {
         $libroObj = new Libro();
         $libroObj->setNombre($datos->nombrelibro);
         $libroObj->save();
         $idLibro = $libroObj->getId();
     } else {
         $idLibro = $datos->idlibro;
     }
     $libroVersion = new Libro_version();
     $libroVersion->setIdlibro($idLibro);
     $libroVersion->setFecha(date("Y-m-d"));
     $libroVersion->setHora(date("H:i:s"));
     $libroVersion->setIdusuario($_SESSION['userid']);
     $libroVersion->save();
     file_put_contents(SITE_PATH . "/libros_version/libro_" . $idLibro . "_" . $libroVersion->getId() . ".txt", base64_decode($datos->texto));
     echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $idLibro));
     break;
 /**
  * Filter the query by a related Libro object
  *
  * @param     Libro $libro  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    PrivacidadQuery The current query, for fluid interface
  */
 public function filterByLibro($libro, $comparison = null)
 {
     if ($libro instanceof Libro) {
         return $this->addUsingAlias(PrivacidadPeer::ID, $libro->getId_privacidad(), $comparison);
     } elseif ($libro instanceof PropelCollection) {
         return $this->useLibroQuery()->filterByPrimaryKeys($libro->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByLibro() only accepts arguments of type Libro or PropelCollection');
     }
 }
<?php

include_once 'servicio.php';
include_once 'Libro.php';
switch ($_GET['op']) {
    case 'bu':
        $Libro = new Libro();
        echo $Libro->traerLibros($_POST['busqueda']);
        break;
    case 'aglibro':
        $Libro = new Libro();
        echo $Libro->sumarLibro($_POST['libros'], $_POST['ultimoagregado']);
        break;
    case 'aglista':
        $Libro = new Libro();
        echo $Libro->crearLista($_POST['libros'], $_POST['iduser'], $_POST['nombrelista'], $_POST['generolista'], $_POST['privacidadlista'], $_POST['compartircon']);
        break;
    case 'visualizacion':
        $Libro = new Libro();
        echo $Libro->agregarVisualizacion($_POST['idlista'], $_POST['iduser']);
        break;
    case 'voto':
        $Libro = new Libro();
        echo $Libro->votarLista($_POST['idlista'], $_POST['iduser']);
        break;
}
 public function actionSearch()
 {
     $model = new Libro('search');
     $model->unsetAttributes();
     if (isset($_GET['search_key'])) {
         $model->Titulo = $_GET['search_key'];
     }
     $this->render('search', array('model' => $model));
 }
 public function postLibrosgenero()
 {
     return Libro::whereHas('libros_has_generos', function ($query) {
         $query->where("nombreGenero", Input::all());
     })->get();
 }
 public function __construct()
 {
     $this->model = Libro::singletonLibro();
 }
 /**
  * Exclude object from result
  *
  * @param     Libro $libro Object to remove from the list of results
  *
  * @return    LibroQuery The current query, for fluid interface
  */
 public function prune($libro = null)
 {
     if ($libro) {
         $this->addUsingAlias(LibroPeer::ID, $libro->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
     $_SESSION['usuarioBuscar'] = new Usuario();
     $_SESSION['autorSeleccionadoAdmin'] = null;
     $_SESSION['autorBuscar'] = new Autor();
     $_SESSION['editorialSeleccionadaAdmin'] = null;
     $_SESSION['editorialBuscar'] = new Editorial();
     $_SESSION['solicitudBuscar'] = new Solicitud();
     $_SESSION['solicitudBuscar']->setUsuario(new Usuario());
     $_SESSION['solicitudBuscar']->setLibro(new Libro());
     //Si el usuario logueado tiene rol "Usuario"
     if (isset($_SESSION['usuarioLogueado']) && $_SESSION['usuarioLogueado']->getRol() == "USUARIO") {
         $_SESSION['solicitudBuscar']->getUsuario()->setIdUsuario($_SESSION['usuarioLogueado']->getIdUsuario());
     }
     echo true;
     break;
 case 'buscarLibro':
     $libro = new Libro();
     if (trim($_POST['titulo']) != "") {
         $libro->setTitulo(trim($_POST['titulo']));
     }
     if (trim($_POST['isbn']) != "") {
         $libro->setIsbn(trim($_POST['isbn']));
     }
     if (trim($_POST['codTopografico']) != "") {
         $libro->setCodigoTopografico(trim($_POST['codTopografico']));
     }
     if (trim($_POST['temas']) != "") {
         $libro->setTemas(trim($_POST['temas']));
     }
     if ($_POST['idEditorial'] != "") {
         $libro->setEditorial(buscarEditorialPorId($_POST['idEditorial']));
     }
<div style="margin-bottom: 20px; width:100%; clear:left;">
<?php 
/*
    <div class="row" style="width:200px;float: left;">
        <?php echo CHtml::activeLabelEx($model, '[' . $index . ']IdLinea'); ?>
        <?php echo CHtml::activeTextField($model, '[' . $index . ']IdLinea', array('size' => 20, 'maxlength' => 255)); ?>
        <?php echo CHtml::error($model, '[' . $index . ']IdLinea'); ?>
    </div>
*/
?>
	<div class="row">
		<?php 
echo CHtml::activeLabelEx($model, '[' . $index . ']Titulo');
?>
		<?php 
echo CHtml::activeDropDownList($model, '[' . $index . ']IdLibro', CHtml::listData(Libro::model()->findAll(array('order' => 'Titulo')), 'IdLibro', 'Titulo'), array('prompt' => 'Seleccione un Libro'));
?>
		<?php 
echo CHtml::error($model, '[' . $index . ']IdLibro');
?>
	</div>
	
    <div class="row">
        <?php 
echo CHtml::activeLabelEx($model, '[' . $index . ']Cantidad');
?>
        <?php 
echo CHtml::activeTextField($model, '[' . $index . ']Cantidad');
?>
        <?php 
echo CHtml::error($model, '[' . $index . ']Cantidad');
     //Retorna los dias de mora concatenado con el valor base de la multa
     echo $diasDiferencia . '_' . $valorMultaBase;
     die;
     break;
 case 'guardarMulta':
     $param = array('idSolicitud' => $_POST['idSolicitud'], 'valorSugerido' => $_POST['valorSugerido'], 'valorCancelado' => $_POST['valorCancelado'], 'diasMora' => $_POST['diasMora'], 'nota' => $_POST['nota']);
     $response = $client->call('guardarMulta', $param);
     if ($response == 0) {
         //Error almacenando en la BD
         echo false;
     } else {
         echo true;
     }
     break;
 case 'buscarSolicitud':
     $libro = new Libro();
     $usuario = new Usuario();
     $solicitud = new Solicitud();
     //Libro
     if (trim($_POST['titulo']) != "") {
         $libro->setTitulo(trim($_POST['titulo']));
     }
     if (trim($_POST['isbn']) != "") {
         $libro->setIsbn(trim($_POST['isbn']));
     }
     if (trim($_POST['codTopografico']) != "") {
         $libro->setCodigoTopografico(trim($_POST['codTopografico']));
     }
     //Usuario
     if (trim($_POST['codUsuario']) != "") {
         $usuario->setCodigo(trim($_POST['codUsuario']));
 public function actionCarrito()
 {
     $model = array();
     if (isset($_GET['IdLibro'])) {
         if (Yii::app()->user->getState('carrito')) {
             $model = Yii::app()->user->getState('carrito');
         }
         if ($model_libro = Libro::model()->findByPk($_GET['IdLibro'])) {
             if (isset($model[$model_libro->IdLibro])) {
                 if (isset($_GET['Borrar'])) {
                     if (isset($model[$model_libro->IdLibro])) {
                         unset($model[$model_libro->IdLibro]);
                         Yii::app()->user->setState('carrito', $model);
                     }
                 } elseif (isset($_GET['Restar'])) {
                     if (isset($model[$model_libro->IdLibro])) {
                         $model[$model_libro->IdLibro]->Cantidad--;
                         $model[$model_libro->IdLibro]->Importe = $model[$model_libro->IdLibro]->Precio * $model[$model_libro->IdLibro]->Cantidad;
                         if ($model[$model_libro->IdLibro]->Cantidad <= 0) {
                             unset($model[$model_libro->IdLibro]);
                             Yii::app()->user->setState('carrito', $model);
                         }
                     }
                 } else {
                     $model[$model_libro->IdLibro]->Cantidad++;
                     $model[$model_libro->IdLibro]->Importe = $model[$model_libro->IdLibro]->Precio * $model[$model_libro->IdLibro]->Cantidad;
                 }
             } else {
                 $model[$model_libro->IdLibro] = new Linea();
                 $model[$model_libro->IdLibro]->IdLibro = $model_libro->IdLibro;
                 $model[$model_libro->IdLibro]->Cantidad = 1;
                 $model[$model_libro->IdLibro]->Precio = $model_libro->Precio;
                 $model[$model_libro->IdLibro]->Importe = $model[$model_libro->IdLibro]->Precio * $model[$model_libro->IdLibro]->Cantidad;
                 Yii::app()->user->setState('carrito', $model);
             }
         }
     }
     $this->render('carrito');
 }
 /**
  * @param	Libro $libro The libro object to add.
  */
 protected function doAddLibro($libro)
 {
     $this->collLibros[] = $libro;
     $libro->setPrivacidad($this);
 }
     }
     $libroObj->save();
     $status = "Libro actualizado correctamente";
     echo $status;
     break;
 case "d":
     //Delete
     $libroObj = LibroQuery::create()->findOneById($_POST["id"]);
     $libroObj->setDebaja("s");
     $libroObj->save();
     echo "Libro borrado correctamente";
     break;
 case "n":
     //New
     include 'notificacion_data.php';
     $libroObj = new Libro();
     //$libroObj->setNombre($datos->nombre);
     $libroObj->setNombre($_POST["nombrelibro"]);
     $libroObj->setId_genero($_POST["vinculogenero"]);
     $libroObj->setFecha(date('Y-m-d'));
     $libroObj->setAutor($_POST["autor"]);
     $libroObj->setEs_editable("n");
     $libroObj->setSinopsis($_POST["sinopsis"]);
     $libroObj->setId_privacidad($_POST["privacidad"]);
     $libroObj->setId_usuario($_SESSION["userid"]);
     $libroObj->save();
     $idImage = $libroObj->getId();
     $mesajeNotificacion = "<span onclick=\"refreshDivs('cuerpocentro','pages/layout/perfillibro.php?id=" . $idImage . "')\">El usuario '" . UsuarioQuery::create()->findOneById($_SESSION["userid"])->getNombre() . "' ha subido un libro.</span>";
     guardarNotificacion(ID_ADMIN_USER, $mesajeNotificacion, 6);
     // obtenemos los datos del archivo
     //$tamano = $_FILES["image"]['size'];
 /**
  * @param	Libro $libro The libro object to add.
  */
 protected function doAddLibro($libro)
 {
     $this->collLibros[] = $libro;
     $libro->setGenero($this);
 }
<html>
<head>
<title>Admin</title>
<meta http-equiv='Content-Type' content='text/html' charset="utf-8" />
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/admin.js"></script>
<link href="../css/cuerpo.css" type="text/css"  rel="stylesheet"/>
<link href="../css/encabezado.css" type="text/css"  rel="stylesheet"/>

</head>
<body style="font-family:Arial;width:600px;margin:0px auto;">
<?php 
@session_start();
include '../php/Libro.php';
$libros = new Libro();
$libro = $libros->traerTodosLosLibros();
?>
<div id="columna_centro" style="width:650px;height:auto;">
<table id="tabla" style="float:left;">
	<tr>
    	<td style="color:#520C06;width:300px;">
        Nombre
        </td>
        <td style="color:#520C06;width:300px;">
        Fecha de subida
        </td>
        <td style="color:#520C06;width:300px;">
        Género
        </td>
        <td style="color:#520C06;width:300px;">
        Autor
/**
 * Metodo encardado de setear los valores desde la BD (Soap) a un Libro.
 * @param libroSoap Objeto Soap que contiene los datos de libro para ser setados.
 * @return
 */
function obtenerLibroSoapNew($libroSoap)
{
    $lib = new Libro();
    $lib->setIdLibro($libroSoap["ID_LIBRO"]);
    if ($libroSoap["TITULO"] != null) {
        $lib->setTitulo($libroSoap["TITULO"]);
    }
    if ($libroSoap["ISBN"] != null) {
        $lib->setIsbn($libroSoap["ISBN"]);
    }
    if ($libroSoap["COD_TOPOGRAFICO"] != null) {
        $lib->setCodigoTopografico($libroSoap["COD_TOPOGRAFICO"]);
    }
    if ($libroSoap["TEMAS"] != null) {
        $lib->setTemas($libroSoap["TEMAS"]);
    }
    if ($libroSoap["PAGINAS"] != null) {
        $lib->setPaginas($libroSoap["PAGINAS"]);
    }
    if ($libroSoap["VALOR"] != null) {
        $lib->setValor($libroSoap["VALOR"]);
    }
    if ($libroSoap["RADICADO"] != null) {
        $lib->setRadicado($libroSoap["RADICADO"]);
    }
    if ($libroSoap["FECHA_INGRESO"] != null) {
        $lib->setFechaIngreso($libroSoap["FECHA_INGRESO"]);
    }
    if ($libroSoap["SERIE"] != null) {
        $lib->setSerie($libroSoap["SERIE"]);
    }
    if ($libroSoap["ANIO"] != null) {
        $lib->setAnio($libroSoap["ANIO"]);
    }
    //Editorial
    if ($libroSoap["ID_EDITORIAL"] != null) {
        $editorial = new Editorial();
        $editorial->setIdEditorial($libroSoap["ID_EDITORIAL"]);
        $editorial->setDescripcion($libroSoap["DES_EDITORIAL"]);
        $lib->setEditorial($editorial);
    }
    //Area
    if ($libroSoap["ID_AREA"] != null) {
        $area = new Area();
        $area->setIdArea($libroSoap["ID_AREA"]);
        $area->setDescripcion($libroSoap["DES_AREA"]);
        $lib->setArea($area);
    }
    //Sede
    if ($libroSoap["ID_SEDE"] != null) {
        $sede = new Sede();
        $sede->setIdSede($libroSoap["ID_SEDE"]);
        $sede->setDescripcion($libroSoap["DES_SEDE"]);
        $lib->setSede($sede);
    }
    //Ciudad
    if ($libroSoap["ID_CIUDAD"] != null) {
        $ciudad = new Ciudad();
        $ciudad->setIdCiudad($libroSoap["ID_CIUDAD"]);
        $ciudad->setNombre($libroSoap["NOM_CIUDAD"]);
        $pais = new Pais();
        $pais->setIdPais($libroSoap["ID_PAIS"]);
        $pais->setNombre($libroSoap["NOM_PAIS"]);
        $ciudad->setPais($pais);
        $lib->setCiudad($ciudad);
    }
    if ($libroSoap["ADQUISICION"] != null) {
        $lib->setAdquisicion($libroSoap["ADQUISICION"]);
    }
    if ($libroSoap["EST_LIBRO"] != null) {
        $lib->setEstado($libroSoap["EST_LIBRO"]);
    }
    if ($libroSoap["CANTIDAD"] != null) {
        $lib->setCantidad($libroSoap["CANTIDAD"]);
    }
    if ($libroSoap["DISPONIBILIDAD"] != null) {
        $lib->setDisponibilidad($libroSoap["DISPONIBILIDAD"]);
    }
    return $lib;
}
Exemple #22
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
/*GENERAL - USUARIOS SIN REGISTRAR*/
Route::get('/', function () {
    $Libros = Libro::with('comentarios')->get();
    return View::make('vistas.home')->with('books', $Libros);
});
Route::get('user/adduser', 'UriController@getAdduser');
Route::get('user/profile', 'UriController@getProfile');
Route::get('user/search', 'UriController@getSearchbook');
Route::controller('/actionuser', 'UsuarioController');
Route::controller('/auth', 'LoginController');
Route::group(array('before' => 'administrador'), function () {
    /*ADMINISTRADOR*/
    Route::get('book/addbook', 'UriController@getAddbook');
    Route::get('book/editbook', 'UriController@getEditbook');
    Route::get('book/details', 'UriController@getDetailsbook');
    Route::controller('actionbook', 'LibroController');
    Route::get('user/show', 'UriController@getShowusers');
    Route::get('search', 'UriController@getSearch');
    Route::get('find/book/{codigoLibro}', 'LibroController@getselectlibro');
 /**
  * Declares an association between this object and a Libro object.
  *
  * @param      Libro $v
  * @return     Slider_mae The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setLibro(Libro $v = null)
 {
     if ($v === null) {
         $this->setId_libro(NULL);
     } else {
         $this->setId_libro($v->getId());
     }
     $this->aLibro = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Libro object, it will not be re-added.
     if ($v !== null) {
         $v->addSlider_mae($this);
     }
     return $this;
 }
Exemple #24
0
require_once 'class/Usuario.php';
require_once 'class/Libro.php';
session_start();
if (isset($_SESSION["user"])) {
    $user = $_SESSION["user"];
    if (empty($_POST)) {
        $vistas = "menu";
        include 'vistas/menu.php';
    } else {
        if (isset($_POST["add"])) {
            $vistas = "addLibro";
            include 'vistas/addLibro.php';
        } else {
            if (isset($_POST["addLibro"])) {
                $datos = $_POST["libro"];
                $libro = new Libro($datos["titulo"], $datos["editorial"], $datos["escritor"], $datos["publicacion"], $datos["paginas"], $user->getId_usuario());
                if ($libro->persist()) {
                    $errorAdd = "false";
                    $user->getLibros()->add($libro);
                } else {
                    $errorAdd = "true";
                }
                $vistas = "addLibro";
                include 'vistas/addLibro.php';
            } else {
                if (isset($_POST["delete"])) {
                    if (!isset($_POST["libro"])) {
                        $errorDelete = "true";
                        $vistas = "menu";
                        include 'vistas/menu.php';
                    } else {