<?php

include 'database.php';

class ProductosV extends DataBase{
    
    public function __construct() {
        parent::__construct();
    }
    
    public function buscar($producto, $bodega){

if(isset($_SESSION['datosV'])){
unset($_SESSION['datosV']);
}else{

$_SESSION['datosV'] = array();
$sth = $this->prepare('SELECT * FROM productos WHERE descripcion LIKE "%'.$producto.'%" AND bodega LIKE "%'.$bodega.'%" ORDER BY descripcion');
$sth->execute();
$result = $sth->fetchAll();
        foreach ($result as $key => $value) {
$_SESSION['datosV'][] = array("value" => $value['descripcion'],
                "codigoProducto" => $value['codigo'],
                "precioProducto" => $value['precio1'],
                "costoProducto" => $value['costo'],
                "ivaProducto" => $value['iva'],
                "saldoProducto" => $value['saldo']);
        }
}

        
        return $_SESSION['datosV'];



    }
    
}

