<?php

/**
 * Description of photo
 * 信息管理
 * @author  杨靖
 */
class info_manager extends CI_Controller {

    //put your code here

    function __construct() {

        parent::__construct();
        $this->load->library('grocery_CRUD');
        $this->load->model('model_cmf');
    }

    public function manager_photo() {
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');

        $this->load->model('model_cmf');

        $table_name = "photo_info";

        $this->model_cmf->setDisplayTag($crud, $table_name);

        $crud->columns('id', 'title', 'photo', 'click', 'end_time');

        $crud->set_subject('广告位时间管理');

        $crud->set_field_upload('photo', 'assets/uploads/photo');

        if ($crud->getState() == "add") {
            $crud->default_data->state = "正常";
        }

        $output = $crud->render();

        $this->load->view('crud.php', $output);
    }

    public function manager_article() {
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');

        $this->load->model('model_cmf');

        $table_name = "statistics_info";

        $this->model_cmf->setDisplayTag($crud, $table_name);

        $crud->columns('article_id', 'edit_time');

        //     $crud->field_type('fullname', 'hidden');
        $crud->set_relation("article_id", "cms_article", "title", "content", "click");

        $crud->set_subject('文章管理');
        $crud->add_action('相关文章', '', '/manage/info_manager/article_info', '');
        $crud->unset_edit();
        $output = $crud->render();

        $this->load->view('crud.php', $output);
    }

    public function article_info($id) {
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');

        $sql = "select * from statistics_info where id = " . $id;

        $statistics = $this->db->query($sql)->row();

        $sql = "select * from cms_article where id = " . $statistics->article_id;

      //  $acticles = $this->db->query($sql)->row();
        $data['文章'] = $this->db->query($sql)->result();

        $this->parser->parse('article_info.php', $data);
        
    }

}

?>
