Changeset 360 for pro-violet-viettel/sourcecode/application/modules/admin
- Timestamp:
- Oct 31, 2014 11:14:19 AM (11 years ago)
- Location:
- pro-violet-viettel/sourcecode/application/modules/admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php
r359 r360 12 12 13 13 public function index() { 14 $data =array();14 $data = array(); 15 15 $this->load->driver("pp"); 16 16 $admin_info = $this->session->userdata('adminInfo'); 17 17 if ($admin_info) { 18 18 $data['content'] = $this->getCollaborators(); 19 $this->load->view('collaborator/index', $data);19 $this->load->view('collaborator/index', $data); 20 20 } else { 21 21 $this->load->view('login'); 22 22 } 23 23 } 24 public function getCollaborators($filters=array()) 25 { 26 27 $data['current_page'] = $this->uri->segment(4,1); 28 $data['itemsoptions']=array(10,25,50,100); 29 $data['perpage'] = 10; 24 25 public function getCollaborators($filters = array()) { 26 $this->load->helper('pagging'); 27 $this->load->model('collabolator_model'); 28 $data['current_page'] = $this->uri->segment(4, 1); 29 $data['itemsoptions'] = array(10, 25, 50, 100); 30 $data['perpage'] = 10; 31 $data['keyword'] = ""; 32 33 if ($this->input->post('items')) { 34 $data['perpage'] = $this->input->post('items'); 35 } 36 if ($this->input->post('keyword')) { 37 $data['keyword'] = $this->input->post('keyword'); 38 } 30 39 31 if ($this->input->post('items')) 32 { 33 $data['perpage'] = $this->input->post('items'); 34 } 35 $sql="SELECT * FROM tblcollaborator"; 36 $data['keyword']=''; 37 38 if ($this->input->post('keyword')) 39 { 40 $data['keyword']=$this->input->post('keyword'); 41 $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%')"; 42 } 40 $data['start'] = ($data['current_page'] - 1) * $data['perpage']; 41 $data['total'] = $this->collabolator_model->countCollaborator($data); 42 $data['collaborators'] = $this->collabolator_model->getCollaborator($data); 43 43 44 $data['total']=$this->db->query($sql)->num_rows(); 45 $data['start']=($data['current_page']-1)*$data['perpage']; 46 $query = $this->db->query($sql." LIMIT ".$data['start'].", ".$data['perpage'].""); 47 $data['collaborators']=$query->result_array(); 48 $this->load->library('pagination'); 49 $url = "http://$_SERVER[HTTP_HOST]/admin/cong_tac_vien/trang/"; 50 $config['base_url'] = $url; 51 $config['total_rows'] = $data['total']; 52 $config['use_page_numbers'] = TRUE; 53 $config['per_page'] = $data['perpage']; 54 $config['num_tag_open'] = "<li>"; 55 $config['num_tag_close'] = "</li>"; 56 $config['cur_tag_open'] = "<li class='active'><a>"; 57 $config['cur_tag_close'] = '</a></li>'; 58 $config['last_link'] = '»'; 59 $config['first_link'] = '«'; 60 $config['first_tag_open'] = "<li title='Trang Äầu tiên'>"; 61 $config['first_tag_close'] = '</li>'; 62 $config['last_tag_open'] = "<li title='Trang cuá»i cùng'>"; 63 $config['last_tag_close'] = '</li>'; 64 $config['next_link'] = '>'; 65 $config['next_tag_open'] = "<li title='Trang kế tiếp'>"; 66 $config['next_tag_close'] = '</li>'; 67 $config['prev_link'] = '<'; 68 $config['prev_tag_open'] = "<li title='Trang trưá»c'>"; 69 $config['prev_tag_close'] = '</li>'; 70 $config['num_links'] = 2; 71 $config['current_page'] = $data['current_page']; 72 $config['ajax_class'] = 'ajax_paging'; 73 $this->pagination->initialize($config); 74 $data['paging'] = $this->pagination->create_links(); 44 $data['paging_url'] = base_url() . "/admin/cong_tac_vien/trang/"; 45 $data['num_links'] = 2; 46 $data['paging'] = pagging($data); 75 47 76 48 if ($this->input->is_ajax_request()) { 77 return $this->load->view('collaborator/listview', $data);49 return $this->load->view('collaborator/listview', $data); 78 50 } 79 return $this->load->view('collaborator/listview', $data, true);51 return $this->load->view('collaborator/listview', $data, true); 80 52 } 81 public function addCollaborator() 82 {83 $result =array();84 $input =$this->input->post();85 $this->db->insert('tblcollaborator', $input); 86 $result['success'] =1;53 54 public function addCollaborator() { 55 $result = array(); 56 $input = $this->input->post(); 57 $this->db->insert('tblcollaborator', $input); 58 $result['success'] = 1; 87 59 echo json_encode($result); 88 60 } 61 89 62 public function test() { 90 63 91 64 for ($i = 1; $i <= 500; $i++) { 92 65 $collaborator = new Entities\Tblcollaborator(); 93 66 $collaborator->setActivated(rand(0, 1)); 94 67 $collaborator->setAuthor(1); 95 $collaborator->setCellphone('0' . (1695061706 +$i));68 $collaborator->setCellphone('0' . (1695061706 + $i)); 96 69 $collaborator->setCreatedTime(date("Y-m-d H:i:s")); 97 $collaborator->setFullName("Full Name " .$i);98 $collaborator->setLoginName("loginname" .$i);70 $collaborator->setFullName("Full Name " . $i); 71 $collaborator->setLoginName("loginname" . $i); 99 72 $collaborator->setPasswd(md5("12345678")); 100 73 $collaborator->setUpdatedTime(date("Y-m-d H:i:s")); -
pro-violet-viettel/sourcecode/application/modules/admin/controllers/home.php
r357 r360 11 11 public function index () 12 12 { 13 13 14 $admin_info = $this->session->userdata('adminInfo'); 14 15 if ($admin_info) … … 23 24 public function login() 24 25 { 26 25 27 $username = $this->input->post('user_admin'); 26 28 $password = $this->input->post('password'); -
pro-violet-viettel/sourcecode/application/modules/admin/models/admin_model.php
r350 r360 16 16 $hash_password = md5($password); 17 17 $query = "SELECT * FROM tbladmin WHERE login_name = ? AND passwd = ?"; 18 18 $result = $this->db->query($query, array($login_name, $hash_password)); 19 19 if($result->num_rows() == 1){ 20 20 return $result->row(0); -
pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php
r328 r360 11 11 parent::__construct(); 12 12 } 13 13 function getCollaborator($data) 14 { 15 $sql="SELECT * FROM tblcollaborator"; 16 $data['keyword']=''; 17 18 if ($data['keyword']) 19 { 20 $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%')"; 21 } 22 return $this->db->query($sql." LIMIT ".$data['start'].", ".$data['perpage']."")->result_array(); 23 24 } 25 function countCollaborator($data) 26 { 27 $sql="SELECT COUNT(id) as total FROM tblcollaborator"; 28 if (isset($data['keyword'])) 29 { 30 $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%')"; 31 } 32 33 return $this->db->query($sql)->row_array()['total']; 34 35 } 14 36 }
Note: See TracChangeset
for help on using the changeset viewer.