Exemplo n.º 1
0
 public function getTotal()
 {
     // Calculamos el valor de la pasta
     $total = $this->getPasta()->getPrecio();
     // Calculamos el valor del queso
     $queso = FactoryTipoIngrediente::getTipoIngrediente(CarneVegetalQueso::QUESO);
     $precioxgramo = $queso->getPrecio() / 100;
     $total += $this->getQueso() * $precioxgramo;
     foreach ($this->getLista_ingredientes() as $ingrediente) {
         $total += $ingrediente->getTotal();
     }
     return $total;
 }
<h2 class="page-header">Editar Ingrediente</h2>

<?php 
if (isset($_GET['submit'])) {
    $id = $_GET['id'];
    $descripcion = ucwords(strtolower(trim($_GET['descripcion'])));
    $tipo_ingrediente = $_GET['tipo_ingrediente'];
    $costo_adicional = trim($_GET['costo_adicional']);
    if (isset($_GET['activo'])) {
        $activo = 1;
    } else {
        $activo = 0;
    }
    $obj_tipo_ingrediente = FactoryTipoIngrediente::getTipoIngrediente($tipo_ingrediente);
    $ingrediente = new Ingrediente($id, $descripcion, $costo_adicional, $obj_tipo_ingrediente, $activo);
    try {
        $resultado = ingredienteBLL::modificar($ingrediente);
    } catch (Exception $ex) {
        $resultado = $ex->getMessage();
    }
    if ($resultado) {
        echo "<div class=\"alert alert-success\" role=\"alert\">\n    \t\t          <strong>Éxito!</strong> Ingrediente <strong>{$descripcion}</strong> editado correctamente.\n    \t\t      </div>";
    } else {
        echo "<div class=\"alert alert-danger\" role=\"alert\">\n    \t\t          <strong>Error!</strong> No se pudo editar el ingrediente.<strong>{$resultado}</strong>\n    \t\t     </div>";
    }
    echo "<p class=\"text-right\">\n    \t<a href=\"mantenimiento.php?view=modificar_ingrediente\"\n    \t\t\t  \tclass=\"btn btn-primary\">\n    \t\t\t\t\t<span class=\"glyphicon glyphicon-edit\"></span>\n    \t\t\t  \t\tEditar Otro Ingrediente\n    \t\t\t  \t</a>\n    \t\t\t  </p>";
    return;
}
if (isset($_GET['modificar'])) {
    $id = -1;
    if (isset($_GET['id'])) {
Exemplo n.º 3
0
 public static function iterarObjetos($lista)
 {
     $lista_ingredientes = array();
     while ($row = mysqli_fetch_assoc($lista)) {
         $id = $row['id'];
         $descripcion = $row['descripcion'];
         $costo_adicional = $row['costo_adicional'];
         $tipo_ingrediente = $row['tipo_ingrediente'];
         $activo = $row['activo'];
         $obj_tipo_ingrediente = FactoryTipoIngrediente::getTipoIngrediente($tipo_ingrediente);
         $ingrediente = new Ingrediente($id, $descripcion, $costo_adicional, $obj_tipo_ingrediente, $activo);
         array_push($lista_ingredientes, $ingrediente);
     }
     mysqli_free_result($lista);
     return $lista_ingredientes;
 }