示例#1
0
<?php

$db = new phpDB();
$db->connect();
$query = "SELECT * FROM categoria";
$db->exec($query, array());
?>


<div class="table-responsive">
    <table class="table table-hover table-bordered">
        <tbody>
            <?php 
do {
    $rs = $db->fobject();
    ?>
                <tr>
                    <td class="capitalize"><?php 
    echo $rs->nombre_categoria;
    ?>
</td>
                </tr>
            <?php 
} while ($db->nextRow());
?>
        </tbody>
    </table>
</div>
示例#2
0
function load()
{
    $id_plat_cat = array();
    $platos_cat = array();
    $platos_obj = array();
    $platos_obj_r = array();
    $platos_rango = array();
    $i = 0;
    $j = 0;
    $k = 0;
    if (!isset($_POST) || !isset($_SESSION['user_bd13']) || $_SESSION['user_bd13']->rol != 1) {
        header('Location: ../login.php');
        exit;
    } else {
        $db = new phpDB();
        $db->connect();
        if (isset($_POST['filtro_busqueda_categ'])) {
            $categoria = $_POST['categoria'];
            $query = "SELECT * FROM categoria WHERE nombre_categoria LIKE '%{$categoria}%'";
            $db->exec($query, array());
            $rs1 = $db->fobject();
            if (is_null($rs1)) {
                echo '<div class="alert alert-info"> No hay resultados para la búsqueda</div>';
                return;
            } else {
                do {
                    $id_plat_cat[$i] = $rs1->id_categoria;
                    $i++;
                } while ($db->nextRow());
                foreach ($id_plat_cat as $key => $value) {
                    $query2 = "SELECT * FROM plato WHERE id_categoria = '{$value}'";
                    $db->exec($query2, array());
                    do {
                        $rs2 = $db->fobject();
                        $platos_cat[$k] = $rs2->nombre_plato;
                        $platos_obj[$k] = $rs2;
                        $k++;
                    } while ($db->nextRow());
                }
            }
        }
        if (isset($_POST['filtro_busqueda_rango'])) {
            $rango_start = $_POST['start'];
            $rango_end = $_POST['end'];
            if ($rango_start > $rango_end || $rango_start == 0 && $rango_end == 0) {
                echo '<div class="alert alert-danger"> Se ingreso mal los rangos de búsqueda</div>';
                return;
            }
            $query3 = "SELECT * FROM plato WHERE precio BETWEEN {$rango_start} AND {$rango_end}";
            $db->exec($query3, array());
            do {
                $rs3 = $db->fobject();
                $platos_rango[$j] = $rs3->nombre_plato;
                $platos_obj_r[$j] = $rs3;
                $j++;
            } while ($db->nextRow());
        }
        if (isset($_POST['filtro_busqueda_categ']) && isset($_POST['filtro_busqueda_rango'])) {
            $result = array();
            $indice = 0;
            foreach ($platos_obj as $key => $value) {
                foreach ($platos_obj_r as $key2 => $value2) {
                    if ($value->id_plato == $value2->id_plato) {
                        $result[$indice] = $value;
                        $indice++;
                    }
                }
            }
            //$result = array_intersect($platos_obj, $platos_obj_r);
            ?>
            <div class="well table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>Nombre</th>
                            <th>Precio</th>
                            <th>Cantidad</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
            foreach ($result as $key => $pl) {
                ?>
                            <tr>
                                <td>
                                    <button class="btn btn-link" data-toggle="modal" data-target="#myModal<?php 
                echo $pl->id_plato;
                ?>
">
                                        <?php 
                echo $pl->nombre_plato;
                ?>
                                    </button>
                                    <?php 
                include 'modal_busqueda.php';
                ?>
                                </td>
                                <td> $
                                    <?php 
                echo $pl->precio . "<br>";
                ?>
                                </td>
                                <td>
                                    <form method="post" id ="cant<?php 
                echo $pl->id_plato;
                ?>
" action="handlers/add_carrito_handler.php?idprod=<?php 
                echo $pl->id_plato;
                ?>
&nombre=<?php 
                echo $pl->nombre_plato;
                ?>
&precio=<?php 
                echo $pl->precio;
                ?>
&dir=carta.php&descrip=<?php 
                echo str_replace(' ', '+', $pl->descripcion);
                ?>
">
                                        <input type = "number" min = "1" max = "20" step = "1" value = "1" size = "3" name="cantidad"> 
                                        <button type="submit" class="btn btn-success btn-xs">Agregar</button>
                                    </form>
                                </td>
                            </tr>
                        <?php 
            }
            ?>
                    </tbody>
                </table>
            </div>
            <?php 
        } else {
            if (!empty($platos_cat)) {
                ?>
                <div class="well table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>Nombre</th>
                                <th>Precio</th>
                                <th>Cantidad</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                foreach ($platos_cat as $key => $pl) {
                    ?>
                                <tr>
                                    <td>
                                        <button class="btn btn-link" data-toggle="modal" data-target="#myModal<?php 
                    echo $platos_obj[$key]->id_plato;
                    ?>
">
                                            <?php 
                    echo $platos_obj[$key]->nombre_plato;
                    ?>
                                        </button>
                                        <?php 
                    include 'descripcionModal.php';
                    ?>
                                    </td>
                                    <td> $
                                        <?php 
                    echo $platos_obj[$key]->precio . "<br>";
                    ?>
                                    </td>
                                    <td>
                                        <form method="post" id ="cant<?php 
                    echo $platos_obj[$key]->id_plato;
                    ?>
" action="handlers/add_carrito_handler.php?idprod=<?php 
                    echo $platos_obj[$key]->id_plato;
                    ?>
&nombre=<?php 
                    echo $platos_obj[$key]->nombre_plato;
                    ?>
&precio=<?php 
                    echo $platos_obj[$key]->precio;
                    ?>
&dir=carta.php&descrip=<?php 
                    echo str_replace(' ', '+', $platos_obj[$key]->descripcion);
                    ?>
">
                                            <input type = "number" min = "1" max = "20" step = "1" value = "1" size = "3" name="cantidad"> 
                                            <button type="submit" class="btn btn-success btn-xs">Agregar</button>
                                        </form>
                                    </td>
                                </tr>
                            <?php 
                }
                ?>
                        </tbody>
                    </table>
                </div>
                <?php 
            } elseif (!empty($platos_rango)) {
                ?>
                <div class="well table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>Nombre</th>
                                <th>Precio</th>
                                <th>Cantidad</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                foreach ($platos_rango as $key => $pl) {
                    ?>
                                <tr>
                                    <td>
                                        <button class="btn btn-link" data-toggle="modal" data-target="#myModal<?php 
                    echo $platos_obj_r[$key]->id_plato;
                    ?>
">
                                            <?php 
                    echo $platos_obj_r[$key]->nombre_plato;
                    ?>
                                        </button>
                                        <?php 
                    include 'descripcionModal.php';
                    ?>
                                    </td>
                                    <td> $
                                        <?php 
                    echo $platos_obj_r[$key]->precio . "<br>";
                    ?>
                                    </td>
                                    <td>
                                        <form method="post" id ="cant<?php 
                    echo $platos_obj_r[$key]->id_plato;
                    ?>
" action="handlers/add_carrito_handler.php?idprod=<?php 
                    echo $platos_obj_r[$key]->id_plato;
                    ?>
&nombre=<?php 
                    echo $platos_obj_r[$key]->nombre_plato;
                    ?>
&precio=<?php 
                    echo $platos_obj_r[$key]->precio;
                    ?>
&dir=carta.php&descrip=<?php 
                    echo str_replace(' ', '+', $platos_obj_r[$key]->descripcion);
                    ?>
">
                                            <input type = "number" min = "1" max = "20" step = "1" value = "1" size = "3" name="cantidad"> 
                                            <button type="submit" class="btn btn-success btn-xs">Agregar</button>
                                        </form>
                                    </td>
                                </tr>
                            <?php 
                }
                ?>

                        </tbody>
                    </table>
                </div>
                <?php 
            } else {
                echo '<div class="alert alert-info"> Marque una opción de búsqueda para iniciar el proceso</div>';
            }
        }
    }
}
示例#3
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once "../include/db.php";
# Permite la comunicación con la bd
session_start();
if (!isset($_POST) || !isset($_SESSION['user_bd13']) || $_SESSION['user_bd13']->rol != 0) {
    header('Location: ../login.php');
} else {
    $db = new phpDB();
    $db->connect();
    $query = "INSERT INTO categoria(nombre_categoria) values (\$1)";
    $db->exec($query, array($_POST['name_categoria']));
    header('Location: ../add_categoria.php?agregado=true');
}
示例#4
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once "../include/db.php";
# Permite la comunicación con la bd
# Se hace la conexión a la BD #
$db = new phpDB();
# La variable $db guarda la referencia a la BD
$db->connect();
# Se hacen distintas cosas dependiendo del valor del parámetro "action" #
if (isset($_POST)) {
    $query = "SELECT * FROM usuario WHERE rut = \$1";
    $db->exec($query, array(RUT_formatear($_POST['r-rut'])));
    if ($db->numRows() == 1) {
        echo "existe";
        header('Location: ../login.php?registro=true&error=invalidrut');
    } else {
        $query2 = "INSERT INTO usuario (rut,password,nombre,apellido,email,rol) VALUES (\$1,\$2,\$3,\$4,\$5,\$6)";
        echo $query2;
        $db->exec($query2, array(RUT_formatear($_POST['r-rut']), $_POST['rpasswd'], $_POST['rname'], $_POST['rapellido'], $_POST['remail'], 1));
        header('Location: ../login.php?registrado=true');
    }
} else {
    header('Location: ../login.php?registro=true');
}
function RUT_formatear($rut)
{
    return $rut_formato = str_replace('.', '', substr($rut, 0, -2));
}
示例#5
0
                  $sql1 = "UPDATE `transiciones` SET `position` = (`position`+1) WHERE `position` >= " . $_POST['position'];
                  $sql2 = "INSERT INTO transiciones (`ID`,`archivo`,`position`,`link`,`comentario`)
                  VALUES ('NULL','" . $ImageName . '-' . $RandomNumber . '.' . $ImageExt . "','" . $_POST['position'] . "','" . $_POST['link'] . "','" . nl2br($_POST['comentario']) . "');";
        
                  $query1 = mysql_query($sql1);
                  $query2 = mysql_query($sql2);
        
                  if ($query1 && $query2)
                  header('Location:../index.php?option=transiciones&sql=true');
                  else
                  header('Location:../index.php?option=transiciones&sql=false');
                 * 
                 */
    }
}
$db = new phpDB();
# La variable $db guarda la referencia a la BD
$db->connect();
if (isset($_FILES['ImageFile'])) {
    $img = $ImageName . '-' . $RandomNumber . '.' . $ImageExt;
    $query = "INSERT INTO plato(nombre_plato, id_categoria, precio, descripcion, img) values (\$1,\$2,\$3,\$4,\$5)";
    $db->exec($query, array($_POST['name_plato'], $_POST['categoria'], $_POST['precio'], $_POST['descripcion'], $img));
} else {
    $query = "INSERT INTO plato(nombre_plato, id_categoria, precio, descripcion) values (\$1,\$2,\$3,\$4)";
    $db->exec($query, array($_POST['name_plato'], $_POST['categoria'], $_POST['precio'], $_POST['descripcion']));
}
header('Location: ../add_plato.php?agregado=true');
function resizeImg($CurWidth, $CurHeight, $DestFolder, $srcImage, $Quality, $ImageType, $NewWidth, $NewHeight)
{
    $NewCanves = imagecreatetruecolor($NewWidth, $NewHeight);
    if (imagecopyresized($NewCanves, $srcImage, 0, 0, 0, 0, $NewWidth, $NewHeight, $CurWidth, $CurHeight)) {
示例#6
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once '../include/carrito.class.php';
require_once "../include/db.php";
session_start();
if (!isset($_SESSION['carrito_bd13'])) {
    header('Location: ../carrito.php');
} else {
    $db = new phpDB();
    $db->connect();
    $query1 = "insert into pedidos(rut,comentarios) values(\$1,\$2) RETURNING id_pedidos";
    $db->exec($query1, array($_SESSION['user_bd13']->rut, $_POST['comentarios']));
    $pedido = $db->farray();
    $id_pedido = $pedido["id_pedidos"];
    $productos = $_SESSION['carrito_bd13']->getProductos();
    foreach ($productos as $key => $value) {
        $id_temp = $value->getIdProd();
        $query_temp = "insert into plato_pedidos(id_pedidos, id_plato, cantidad) values (\$1,\$2,\$3)";
        $db->exec($query_temp, array($id_pedido, $id_temp, $value->getCantidad()));
    }
    header('Location: ../carrito.php?compra=true');
}
示例#7
0
<?php

require_once 'include/pedido.class.php';
$db = new phpDB();
$db->connect();
$query1 = '';
if ($_SESSION['user_bd13']->rol == '1') {
    $query1 = "SELECT * from pedidos WHERE rut = \$1";
    $db->exec($query1, array($_SESSION['user_bd13']->rut));
} elseif ($_SESSION['user_bd13']->rol == '0') {
    $query1 = "SELECT * from pedidos";
    $db->exec($query1, array());
}
$pedidos = array();
$plato_pedidos = array(array());
$index = 0;
do {
    $rs1 = $db->fobject();
    $pedido = new pedido($rs1->id_pedidos, $rs1->rut, $rs1->fecha);
    $pedidos[$index] = $pedido;
    $index++;
} while ($db->nextRow());
foreach ($pedidos as $key => $value) {
    $id = $value->getID();
    $query2 = "SELECT * from plato_pedidos WHERE id_pedidos = '{$id}'";
    $db->exec($query2, array());
    $platos = array(array());
    $i = 0;
    do {
        $rs2 = $db->fobject();
        $platos[$i] = array($rs2->id_plato, $rs2->cantidad);
示例#8
0
<?php

require_once "../include/db.php";
# Permite la comunicación con la bd
# Se hace la conexión a la BD #
$db = new phpDB();
# La variable $db guarda la referencia a la BD
$db->connect();
# Se hacen distintas cosas dependiendo del valor del parámetro "action" #
if ($_GET['action'] == 'login') {
    $query = "SELECT * FROM usuario WHERE rut = \$1 and password = \$2";
    $db->exec($query, array(RUT_formatear($_POST['rut']), $_POST['password']));
    # Si hay un resultado, el login fue correcto #
    if ($db->numRows() == 1) {
        session_start();
        $_SESSION['user_bd13'] = $db->fobject();
        $db->close();
        if ($_SESSION['user_bd13']->rol == '0') {
            header('Location: ../login_cajero.php');
        } else {
            header('Location: ../index.php');
            # Redirecciona a /index.php
        }
    } else {
        header('Location: ../login.php?error=true');
        # Redirecciona al login con error
    }
} else {
    if ($_GET['action'] == 'logout') {
        $db->close();
        session_start();
示例#9
0
文件: showCarta.php 项目: jnaxo/bd13
<?php

$db = new phpDB();
$db->connect();
$query1 = "SELECT * from categoria ";
$db->exec($query1, array());
$categorias = array();
do {
    $rs1 = $db->fobject();
    $categorias[$rs1->id_categoria] = $rs1->nombre_categoria;
} while ($db->nextRow());
//var_dump($categorias);
?>

<?php 
foreach ($categorias as $key => $value) {
    $query2 = "SELECT * from plato WHERE id_categoria = '{$key}' ";
    $db->exec($query2, array());
    ?>
    <div class="well table-responsive">
        <table class="table table-hover">
            <caption><h2><?php 
    echo $value;
    ?>
</h2></caption> 
            <thead>
                <tr>
                    <th>Nombre</th>
                    <th>Precio</th>
                    <th>Cantidad</th>
                </tr>