<?php

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

class Admin extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->database();
        $this->user_data = $this->ion_auth->check_user_privilege(array('Admin'), true);
        $this->breadcrumbs->push('Admin', '/Admin');
        $this->base_url = base_url() . '/admin/' . $this->router->fetch_method();
    }

    public function index() {
        $this->load->view('Base_header');
        $this->load->view('admin/index');
        $this->load->view('Base_footer');
    }

    public function firmy() {
        $this->breadcrumbs->push('Firmy', '/admin/firmy/');
        $this->load->config('pagination', true);
        $config = $this->config->config['pagination'];
        $config['base_url'] = $this->base_url;
        $config['total_rows'] = $this->users_model->get_users_list(null, null, true, 'firma');
        $page = $this->uri->segment(3, 1);
        $data['firmy'] = $this->users_model->get_users_list($config['per_page'], $page, false, 'firma');
        $this->pagination->initialize($config);
        $data['pagination'] = $this->pagination->create_links();
        $this->load->view('Base_header');
        $this->load->view('admin/firmy', $data);
        $this->load->view('Base_footer');
    }

    public function studenci() {
        $this->breadcrumbs->push('Studenci', '/admin/studenci/');
        $this->load->config('pagination', true);
        $config = $this->config->config['pagination'];
        $config['base_url'] = $this->base_url;
        $config['total_rows'] = $this->users_model->get_users_list(null, null, true, 'student');
        $page = $this->uri->segment(3, 1);
        $data['studenci'] = $this->users_model->get_users_list($config['per_page'], $page, false, 'student');
        $this->pagination->initialize($config);
        $data['pagination'] = $this->pagination->create_links();
        $this->load->view('Base_header');
        $this->load->view('admin/studenci', $data);
        $this->load->view('Base_footer');
    }

}
