<?php
/**
 * Created by PhpStorm.
 * User: CHALONG LATEX
 * Date: 14-Sep-16
 * Time: 4:22 PM
 */
if(!defined('BASEPATH')) exit('No direct script access allowed');

class Menuadmin extends MX_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('admin_menu_model') ;
        $this->load->model('user_model');

//       checklogin();
    }

    public function index()
    {
        $data['lists'] = $this->admin_menu_model->get_all();
        $this->load->view('menu/menu',$data);
    }
    public function menubyactive($active = "")
    {
        $string_uri = explode('/',uri_string());
        $data['lists'] = $this->admin_menu_model->get_all();
        $data['active'] =  $active;

        if(count($string_uri)>=2)
            $data['active_sub'] = $string_uri[1];

        $user_id = getCookie('userid');

//        print_r($user_id);exit;
        if(isset($user_id)&&$user_id!='')
        {
            $user_info = $this->user_model->get($user_id);
            $data['user'] = $user_info;
        }
        $this->load->view('menuadmin/menuadmin',$data);
    }
    public function lang($lang_id='')
    {
        $data['lists'] = $this->dbmod->getAllIsActive("lang");
        $data['lang_active'] = $this->dbmod->getByID($lang_id,"lang");
        $this->load->view('menuadmin/langview',$data);
    }
    public function changelang($lang_id='')
    {
        set_lang($lang_id);

        $where = "user_id ='" .$_COOKIE[getcookiename('userid')] . "' ";
        $data = array('user_langid' => $lang_id);
        $sql = $this->db->update_string('june_user', $data, $where);

        return $this->db->query($sql);
    }

}