<?php

class Links extends MY_Controller {

    public $links = array();
    public $newsletters = array();

    function __construct() {
        parent::__construct();
    }

    function index() {
        $this->show_auditoria();
    }
    
    function show_motores_busca() {
        $this->title = $this->lang->line('Links-motores-busca');
        parent::renderPage('links_motores_busca_view');
    }
    
    function show_impostos() {
        $this->title = $this->lang->line('Links-impostos');
        
        parent::renderPage('links_impostos_view');
    }
    
    function show_ministerios_organismos_publicos() {
        $this->title = $this->lang->line('Links-show-ministerios-organismos-publicos');
        parent::renderPage('links_ministerios_organismos_publicos_view');
    }
    
    function show_comissao_europeia_organismos_internacionais() {
        $this->title = $this->lang->line('Links-show-comissao-europeia-organismos-internacionais');
        parent::renderPage('links_comissao_europeia_organismos_internacionais_view');
    }
    
    function show_institutos_profissionais() {
        $this->title = $this->lang->line('Links-show-institutos-profissionais');
        parent::renderPage('links_institutos_profissionais_view');
    }
    
    function show_mercado_valores_mobiliarios() {
        $this->title = $this->lang->line('Links-show-mercado-valores-mobiliarios');
        parent::renderPage('links_mercado_valores_mobiliarios_view');
    }
    
    function show_contabilidade() {
        $this->title = $this->lang->line('Links-contabilidade');
        parent::renderPage('links_contabilidade_view');
    }
    
    function show_auditoria() {
        $this->title = $this->lang->line('Links-auditoria');
        parent::renderPage('links_auditoria_view');
    }
    
    
    function show_newsletters() {
        $this->title = $this->lang->line('Links-documentos');
        
        
        $this->load->model('newsletter_model');

        $offset = $this->uri->segment(2);

        $this->load->library('pagination');
        $this->load->library('table');

        $config['per_page'] = 12;

        $config['base_url'] = base_url() . $this->uri->segment(1);
        $config['total_rows'] = $this->newsletter_model->get_count_newsletters();
        $config['uri_segment'] = 2;

        $config['num_links'] = 3;
        
        $config['last_link'] = '>>';
        $config['last_tag_open'] = '<div class="number">';
        $config['last_tag_close'] = '</div>';
        
        $config['first_link'] = '<<';
        $config['first_tag_open'] = '<div class="number">';
        $config['first_tag_close'] = '</div>';

        $config['prev_link'] = '<';
        $config['prev_tag_open'] = '<div class="number"><span>';
        $config['prev_tag_close'] = '</span></div>';

        $config['next_link'] = '>';
        $config['next_tag_open'] = '<div class="number"><span>';
        $config['next_tag_close'] = '</span></div>';

        $config['cur_tag_open'] = '<div class="number active"><a><span>';
        $config['cur_tag_close'] = '</span></a></div>';

        $config['num_tag_open'] = '<div class="number"><span>';
        $config['num_tag_close'] = '</span></div>';


        $this->pagination->initialize($config);

        $newsletter_data = $this->newsletter_model->get_newsletters($config['per_page'], $offset);
        if ($newsletter_data->num_rows > 0) {
            $this->newsletters = $newsletter_data->result_array();
        }
        
        
        parent::renderPage('newsletters_view');
    }
}

