1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| <?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Auth extends CI_Controller {
function Auth(){
parent::__construct();
$this->lang->load('en_admin_lang','english');
$this->load->helper('form');
$this->load->model('users_model');
$this->load->helper('html');
$this->load->library('form_validation');//mcharger form_validation any am library
$this->load->library('pagination');
}
public function index(){
$this->login();
}
function login(){
$msg = "";
if ($this->input->post('password')){
$stat = $this->check_login();
$msg = $stat['msg'];
if ($stat['result'] == 'OK'){
redirect ('auth/admin_main_menu');
}
else
{
$this->session->sess_destroy();
}
}
$view_setup['msg'] = $msg;
$this->load->view('../common/header');
$this->load->view('login_view.php', $view_setup);
$this->load->view('../common/footer');
}
function check_login(){
$user_name = $this->input->post('user_name');
$password = $this->input->post('password');
$ret = array();
$user_record = $this->users_model->check_login($user_name, $password);
if ($user_record){
$this->session->set_userdata ('user_id', $user_record->id);
$this->session->set_userdata ('user_name', $user_record->user_name);
//$this->session->set_userdata ('role', $user_record->role);
$ret ['result'] = 'OK';
$ret ['msg'] = 'Logged-in';
}else{
$ret ['result'] = 'NON OK';
$ret ['msg'] = 'Invalid User/Pass - Try Again !!!!';
}
return $ret;
}
function logout (){
$this->session->sess_destroy();
redirect('auth');
}
function admin_main_menu(){
$view_setup['uid'] = $this->session->userdata('user_id');
$view_setup['user_name'] = $this->session->userdata('user_name');
//$view_setup['role'] = $this->session->userdata('role');
$view_setup['menu'] = "Add user/Modify User/ Delete User";
$this->load->view('../common/header');
$this->load->view('accueil1.php', $view_setup);
$this->load->view('../common/footer');
}
function accueil(){
$view_setup['uid'] = $this->session->userdata('user_id');
$view_setup['user_name'] = $this->session->userdata('user_name');
$this->load->view('../common/header');
$this->load->view('/accueil1', $view_setup);
$this->load->view('menu/acc', $view_setup);
$this->load->view('../common/footer');
}
function vehicule(){
$data['uid'] = $this->session->userdata('user_id');
$data['user_name'] = $this->session->userdata('user_name');
$page = $this->uri->segment(4,0);
$config['per_page'] = '5';//nbre de page
$config['uri_segment'] = 4;
$vehicules = $this->users_model->findAll($config['per_page'],$page);
$config['first_link'] = 'Début ';
$config['next_link'] = ' Suivant ';
$config['prev_link'] = ' Précédent ';
$config['last_link'] = ' Fin';
$config['total_rows'] = $this->users_model->getCountTable();
$data['context'] = 'list';
$data['titre'] = 'Liste de compositeurs';
$data['liste_veh'] = array('liste_veh'=>$vehicules);
$this->load->view('../common/header');
$this->load->view('/accueil1', $data);
$this->load->view('menu/veh', $data);
$this->load->view('../common/footer');
}
}
?> |
Partager