<?php

include '../templates/header.php';
if (isset($_GET['action']) and $_GET['action'] == "edit") {
    $id = $_GET['id'];
    include '../model/produtos.php';
    $con = new Productos();
    $resultado = $con->GetById($id);
}
?>
<h3>Edicion de productos</h3>
<form action="../controller/productos.controller.php" method="post">
 <div class="row">
               <div class="panel panel-default">
                       <div class="panel-heading">Datos del Producto</div>
                       <div class="panel-body">
                           <div class="row">
                            <div class="col-lg-6">
                                                              
                                <div class="form-group">
                                    <label for="nombre">Nombre:</label>
                                    <input type="text" class="form-control" name="nom_pro"  placeholder="Descripcion"  required="" value="<?php 
echo $resultado['descripcion'];
?>
" />
                                </div>
                                
                                
                                
                            </div>
                            <div class="col-lg-6">
<?php

error_reporting(0);
session_start();
$id = $_POST['b'];
require_once '../model/productos.php';
$objAna = new Productos();
$_SESSION["productos"][$id][$nom][$uni] = $precio;
foreach ($_SESSION["productos"] as $id => $arreglo) {
    foreach ($arreglo as $id => $arreglo2) {
        foreach ($arreglo2 as $descripcion => $precio) {
            $producto = $objAna->GetById($id);
            $id = $producto["idproducto"];
            $precio = $producto["precio"];
            $nom = $producto["nom_pro"];
            $total = $total + $precio;
            echo "<tr>\n        <td>{$id}</td>\n        <td>{$nom}</td>\n        <td>{$precio}</td>\n        <td>{$total}</td>\n        \n        <td>\n                        <a href='../controller/productos.controller.php?action=delete&id='><img src='../recursos/images/delete.png'></a>\n                        <a href='productosEdit.php?action=edit&id='><img src='../recursos/images/edit.png'></a>\n        </td>\n        </tr>\n      \n        ";
        }
    }
}