Esempio n. 1
0
function mostrar()
{
    require_once 'modulos/platillos/modelos/ingredienteModelo.php';
    $idIngrediente = $_GET['i'];
    $idGrupoIngredientes = getIdGrupoIngredientesDeIngrediente($idIngrediente);
    require_once 'modulos/platillos/modelos/grupoIngredientesModelo.php';
    $idPlatillo = getIdPlatilloDeGrupoIngredientes($idGrupoIngredientes);
    require_once 'modulos/platillos/modelos/platilloModelo.php';
    $idRestaurante = getIdRestauranteDePlatillo($idPlatillo);
    if (validarAdministrador() || validarRestauranteLoggeadoId($idRestaurante)) {
        $ingrediente = getIngrediente($idIngrediente);
        echo '<table border=1>';
        Ingrediente::printIngredienteHeader();
        $ingrediente->printIngrediente();
        echo '</table>';
    } else {
        goToIndex();
    }
}
Esempio n. 2
0
<div class="row-fluid"><div class="span12"></div></div>
<h2>Ingredientes del grupo: <?php 
echo $grupoIngredientes->nombre;
?>
</h2>
<h4>
    <a href="<?php 
echo "ingredientes.php?a=agregarIngrediente&g=" . $grupoIngredientes->idGrupoIngredientes;
?>
">
        Agregar ingrediente
    </a>
</h4>
<table border="1">
    <?php 
require_once 'modulos/platillos/clases/Ingrediente.php';
Ingrediente::printIngredienteHeader();
if (isset($ingredientes)) {
    foreach ($ingredientes as $ingrediente) {
        $ingrediente->printIngrediente();
    }
}
?>
</table>
<a href="grupoIngredientes.php?&i=<?php 
echo $grupoIngredientes->idPlatillo;
?>
">Regresar</a>

<?php 
require_once 'layout/footer.php';
function deleteIngrediente()
{
    $ingrediente = new Ingrediente();
    return $ingrediente->deleteBy("nombreIng", $_POST['nombre']);
}
            $dir_subida = 'img/ingredientes/';
            //Crear la carpeta de avatares si aún no está creada.
            if (!is_dir($dir_subida)) {
                mkdir($dir_subida, 0777);
            }
            $nombre_nuevo_avatar = basename($_FILES['imagen']['name']);
            $url_nuevo_avatar = $dir_subida . $nombre_nuevo_avatar;
            //Comprobar que la imagen se ha subido correctamente y se ha movido a la carpeta de avatares
            if (@move_uploaded_file($_FILES['imagen']['tmp_name'], $url_nuevo_avatar)) {
                //Cambiarle los permisos a la imagen para después poder borrarla
                chmod($url_nuevo_avatar, 0777);
            } else {
                //Error al mover el archivo, probablemente por los permisos de la carpeta de destino
                $errorPermisosImagen = true;
            }
        } else {
            //El formato del archivo es incorrecto, avisar
            $errorTipoImagen = true;
        }
    }
    //Comprobar los errores y los campos necesarios
    if (!$errorTipoImagen && !$errorPermisosImagen && !empty($_FILES['imagen']['name']) && !empty($_POST['nombre']) && !empty($_POST['descripcion'])) {
        //Crear una instancia de Ingrediente y meter los datos del ingrediente que se esta modificando
        $ingrediente = new Ingrediente();
        $ingrediente->setImagen(basename($_FILES['imagen']['name']));
        $ingrediente->setNombre($_POST['nombre']);
        $ingrediente->setDescripcion($_POST['descripcion']);
        //Llamamos a los funcion insertarMasa del modelo.
        insertarIngrediente($ingrediente);
    }
}
Esempio n. 5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit()
 {
     $categorias = Categoria::lists('categoria', 'id');
     $ingredientes = Ingrediente::lists('ingrediente', 'id');
     return view('pizza.edit', ['pizza' => $this->pizza, 'categorias' => $categorias, 'ingrediente' => $ingredientes]);
 }
<?php

require_once "modelo/gestionIngredientes.php";
require_once "modelo/clases/Ingrediente.php";
//Si no se viene desde la página de gestión de usuarios, o no se está enviando el formulario de modificacion, redireccionar a gestión de usuarios
if (!isset($_POST['editar']) && !isset($_POST['enviar'])) {
    header('Location: gestion-ingredientes.php');
}
$errorTipoImagen = false;
$errorPermisosImagen = false;
if (isset($_POST['editar']) || isset($_POST['enviar'])) {
    $result = getIngrediente($_POST['idIngrediente']);
    //Crear instancias de Ingrediente a modificar a partir de los datos de la BD
    $datosIngrediente = $result->fetch_assoc();
    $ingrediente = new Ingrediente();
    $ingrediente->setIdIngrediente($datosIngrediente['id_ingrediente']);
    $ingrediente->setNombre($datosIngrediente['nombreIng']);
    $ingrediente->setDescripcion($datosIngrediente['descripcion']);
    $ingrediente->setImagen($datosIngrediente['imagen']);
    $ingrediente->setStock($datosIngrediente['stock']);
}
if (isset($_POST['enviar'])) {
    //Comprobar si se quiere cambiar la imagen de la pizza
    if (!empty($_FILES['imagen']['name'])) {
        /**
         * El siguiente código comprueba el MIME TYPE del archivo para comprobar que es una imagen
         *
         * Código modificado a partir de un snippet sacado de PHP.NET;
         *
         * http://php.net/manual/es/features.file-upload.php#114004
         */
<?php

require_once "modelo/gestionIngredientes.php";
require_once "modelo/clases/Ingrediente.php";
if (isset($_POST['cambiarStock']) && isset($_POST['idIngrediente'])) {
    //Poner o quitar el ingrediente del stock
    cambiarStockIngrediente($_POST['idIngrediente'], $_POST['stock']);
}
$result = getIngredientes();
//Array de todos los ingredientes de la BD
$arrayIngredientes = array();
while ($row = $result->fetch_assoc()) {
    $ingrediente = new Ingrediente();
    $ingrediente->setIdIngrediente($row['id_ingrediente']);
    $ingrediente->setNombre($row['nombreIng']);
    $ingrediente->setDescripcion($row['descripcion']);
    $ingrediente->setImagen($row['imagen']);
    $ingrediente->setStock($row['stock']);
    $arrayIngredientes[] = $ingrediente;
}
function getAllIngredientes()
{
    $ingrediente = new Ingrediente();
    return $ingrediente->getAll();
}