<?php

class Newsletters extends MY_Controller {

    public $newsletters = array();

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

    function index() {
        $this->show_newsletters();
    }
    
    
    function show_flash() {
        
        $this->load->model('link_documento_model');

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

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

        $config['per_page'] = 4;

        $config['base_url'] = base_url() . '/flash-news/' . $this->uri->segment(2);
        $config['total_rows'] = $this->link_documento_model->get_count_links();
        $config['uri_segment'] = 3;

        $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);

        $links_data = $this->link_documento_model->get_links($config['per_page'], $offset);
        if ($links_data->num_rows > 0) {
            $this->links = $links_data->result_array();
        }
        
        
        parent::renderPage('flash_news_view');
    }
    
    function show_newsletters() {
        
        $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');
    }
}

