<?php

include 'database.php';

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

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

$_SESSION['datosI'] = 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['datosI'][] = array("value" => $value['descripcion'],
                "codigoProducto" => $value['codigo'],
                "precioProducto" => $value['precio1'],
                "costoProducto" => $value['costo'],
                "ivaProducto" => $value['iva'],
                "saldoProducto" => $value['saldo']);
        }
}

        
        return $_SESSION['datosI'];



    }
    
}

