<?php

session_start();
include '../dao/dao.php';
if (isset($_REQUEST['op'])) {
    $op = $_REQUEST['op'];
} else {
    header('Location: ../view/index.php');
}
switch ($op) {
    case 1:
        unset($_SESSION['lista']);
        $objDAO = new dao();
        $lista = $objDAO->listarUlt();
        $_SESSION['lista'] = $lista;
        header('Location: ../view/index.php');
        break;
    case 2:
        unset($_SESSION['detapro']);
        $objDAO = new dao();
        $codpro = $_REQUEST['codpro'];
        $ex = $_REQUEST['ex'];
        $_SESSION['codpro'] = $codpro;
        $detapro = $objDAO->detapro($codpro);
        $_SESSION['detapro'] = $detapro;
        if ($ex == 1) {
            header("Location: ../view/editarprod.php");
        } else {
            header("Location: ../view/detallepro.php");
        }
        break;