Guest User

Untitled

a guest
May 25th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. function login() {
  2. $data['base'] = $this->config->item('base_url');
  3. $data['css'] = $this->config->item('css');
  4. $this->load->helper(array('form', 'url')); // carrega o form
  5. $this->load->library('validation'); // carrega as validações
  6. $rules['username'] = 'trim|required|xss_clean|callback__check_logindata';
  7. $rules['password'] = 'trim|required|md5';
  8. // set values for repopulating fields
  9. $fields['username']='Username';
  10. $fields['password']= 'Password ';
  11. $this->validation->set_fields($fields);
  12. $this->validation->set_rules($rules);
  13.  
  14. if ($this->validation->run() == TRUE) {
  15. //$this->load->view('checkuser' , $data);
  16. $this->load->model('Mlogin','',TRUE);
  17. $password = $this->validation->password;
  18. $username = $this->validation->username;
  19.  
  20. if ($this->Mlogin->check_login_data($username, $password) == FALSE) {
  21. $this->validation->set_message('_check_logindata', 'Usuário ou senha inválidos!');
  22. return FALSE;
  23. }
  24. //$this->Mlogin->addHistory();
  25. //redirect('zimba/chamados');
  26. }
  27. else {
  28. $this->load->view('login_view' , $data);
  29. redirect('zimba/chamados');
  30. }
  31.  
  32. $this->db->select('cod_usuario');
  33. $this->db->from('tb_usuarios');
  34. $this->db->where('login =', $username);
  35.  
  36. $guardausuario = $this->db->get();
  37. return $guardausuario;
  38. }
  39.  
  40. function chamados($guardausuario) {
  41. /*if(empty($this->session('user')))
  42. { redirect('/login'); }
  43. try { $this->session('user'); }
  44. catch(Exception $e) { redirect('login'); }*/
  45.  
  46. $data['titulo'] = "Zimba's Desk";
  47. $data['heading'] = "Chamados";
  48.  
  49. $this->db->select('tb1.cod_os, tb1.descricao, tb2.nome');
  50. $this->db->from('tb_os tb1,tb_clientes tb2, tb_usuarios tb3');
  51. $this->db->where('tb1.cod_cliente = tb2.cod_cliente');
  52. $this->db->where('tb3.cod_cliente = tb2.cod_cliente');
  53. $this->db->orwhere('tb3.cod_usuario = tb1.cod_usuario');
  54.  
  55. $data['query'] = $this->db->get();
  56. //$data['query'] = $this->db->get('tb_os');
  57. $this->load->view('zimba_view', $data);
  58. }
Add Comment
Please, Sign In to add comment