<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Stock extends MY_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('almacen/Stock_model');
        $this->load->model('configuracion/Empresa_model');
    }

    public function index() {
        $this->validar_permiso('stock_ver');

        $almacen_id   = $this->input->get('almacen_id', TRUE) ?: null;
        $categoria_id = $this->input->get('categoria_id', TRUE) ?: null;

        $data['titulo']       = 'Reporte de Stock';
        $data['almacenes']    = $this->Stock_model->listar_almacenes();
        $data['categorias']   = $this->Stock_model->listar_categorias();
        $data['stock']        = $this->Stock_model->listar_stock($almacen_id, $categoria_id);
        $data['almacen_id']   = $almacen_id;
        $data['categoria_id'] = $categoria_id;
        $data['fecha_reporte']= date('d/m/Y H:i');
        $data['empresa']      = $this->Empresa_model->obtener_activa();

        $this->layout('almacen/stock/index', $data);
    }
}