<?php

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

require_once dirname(__FILE__) . '/Exhibition_Controller.php';

class general extends Exhibition_Controller
{

    public function show_general_home()
    {
        $this->load->model('company/M_company', 'company');
        $this->load->model('tag/M_tag', 'tag');
        $this->load->model('team/M_team', 'team');
        $data['teams'] =  $this->team->get_all()->result();
        $data['companies'] =  $this->company->get_all()->result();
        $data['tags'] =  $this->tag->get_all()->result();
        $this->output_general('general/v_general_home', $data);
    }

    public function show_project_2()
    {
        $this->output_general('general/v_project_2');
    }

    public function show_project_3()
    {
        $this->output_general('general/v_project_3');
    }

    public function show_project_4()
    {
        $this->output_general('general/v_project_4');
    }

    public function get_num_project()
    {
        $year = $_GET['year'];
        $this->load->model('general/M_general', 'num_project');
        $data['num_project'] = $this->num_project->get_num_project($year)->row();
        echo json_encode($data);
    }

    public function get_project_2()
    {
        $year = $_GET['year'];
        $this->load->model('general/M_general', 'project_2');
        $data['project_2'] = $this->project_2->get_project_2($year)->result();
        echo json_encode($data);
    }

    public function get_project_year()
    {
        $this->load->model('general/M_general', 'year');
        $data['year'] = $this->year->get_project_year()->result();
        echo json_encode($data);
    }

    public function get_project_2_year()
    {
        $this->load->model('general/M_general', 'year');
        $data['year'] = $this->year->get_project_2_year()->result();
        echo json_encode($data);
    }

    public function get_project_3()
    {
        $year = $_GET['year'];
        $this->load->model('general/M_general', 'project_3');
        $data['project_3'] = $this->project_3->get_project_3($year)->result();
        echo json_encode($data);
    }

    public function get_project_3_year()
    {
        $this->load->model('general/M_general', 'year');
        $data['year'] = $this->year->get_project_3_year()->result();
        echo json_encode($data);
    }

    public function get_project_4()
    {
        $year = $_GET['year'];
        $this->load->model('general/M_general', 'project_4');
        $data['project_4'] = $this->project_4->get_project_4($year)->result();
        echo json_encode($data);
    }

    public function get_project_4_year()
    {
        $this->load->model('general/M_general', 'year');
        $data['year'] = $this->year->get_project_4_year()->result();
        echo json_encode($data);
    }

    public function get_data_pagination()
    {
        $year = $_GET['year'];
        $page = $_GET['page'];
        $limit = $_GET['limit'];
        $this->load->model('general/M_general', 'pagination');
        $data['pagination'] = $this->pagination->get_data_pagination($year, $page, $limit)->result();
        echo json_encode($data);
    }

    public function get_num_page()
    {
        $year = $_GET['year'];
        $this->load->model('general/M_general', 'num');
        $data['num'] = $this->num->get_num_page($year)->result();
        echo json_encode($data);
    }

    public function get_search()
    {
        // $year = $_GET['year'];
        // $this->load->model('general/M_general', 'num');
        // $data['num'] = $this->num->get_num_page($year)->result();
        // echo json_encode($data);
        $this->load->view('general/v_search');
    }
}
