<?php
require_once './clases/industria.php';

class IndustriaController {

    private $ind;

    public function __construct(){
        $this->ind = new industria();
    }

    public function index(){
        require_once './vistas/industria/vista.certificado.php';
    }

    public function obtenerContribuyentes(){
        $data    = $this->ind->obtenerListadoContribuyentes($_REQUEST['term']);
        $results = array();
        foreach ($data as $row){
            $results[] = [ "id" => md5($row[0]), "value" => $row[1] ];
        }
        echo json_encode($results);
    }

    public function certificado(){
        ini_set('max_execution_time', 0);
        ob_start();
        session_start();
        $compania = $this->ind->obtenerCompania($_SESSION['compania']);
        $razonsocial    = $compania['razon'];
        $nombreTipoIden = 'NIT';
        $ruta           = $compania['log'];
        $numeroIdent    = $compania['nit'];
        $direccion      = $compania['dir'];
        $telefono       = $compania['tel'];
        $xcontribuyente = $this->ind->obtenerDataContribuyente($_REQUEST['txtIdC']);
        $fecha          = $this->ind->obtenerUltimaFechaPago($xcontribuyente['id']);
        require './fpdf/fpdf.php';
        require_once './vistas/industria/certificado.php';
    }
}