source: pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php @ 354

Last change on this file since 354 was 354, checked in by quyenla, 11 years ago

collaborator

File size: 3.9 KB
Line 
1<?php
2
3if (!defined('BASEPATH'))
4    exit('No direct script access allowed');
5
6class Collaborator extends MX_Controller {
7
8    public function __construct() {
9        parent::__construct();
10        $this->load->helper('cookie');
11    }
12
13    public function index() {
14        $data=array();
15        $this->load->driver("pp");
16        $admin_info = $this->session->userdata('adminInfo');
17        if ($admin_info) {
18            $data['content'] = $this->getCollaborators();
19            $this->load->view('collaborator/index',$data);
20        } else {
21            $this->load->view('login');
22        }
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;   
30       
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        $sql.=" WHERE (full_name LIKE '%".$this->input->post('keyword')."%' OR login_name LIKE '%".$this->input->post('keyword')."%')";
41        }
42
43        $data['total']=500;
44        $data['start']=($data['current_page']-1)*$data['perpage'];
45        $query = $this->db->query($sql." LIMIT ".$data['start'].", ".$data['perpage']."");
46        $data['collaborators']=$query->result_array();
47        $this->load->library('pagination');
48        $url = "http://$_SERVER[HTTP_HOST]/admin/cong_tac_vien/trang/";
49        $config['base_url'] = $url;
50        $config['total_rows'] = $data['total'];
51        $config['use_page_numbers'] = TRUE;
52        $config['per_page'] = $data['perpage'];
53        $config['num_tag_open'] = "<li>";
54        $config['num_tag_close'] = "</li>";
55        $config['cur_tag_open'] = "<li class='active'><a>";
56        $config['cur_tag_close'] = '</a></li>';
57        $config['last_link'] = '»';
58        $config['first_link'] = '«';
59        $config['first_tag_open'] = "<li title='Trang đầu tiên'>";
60        $config['first_tag_close'] = '</li>';
61        $config['last_tag_open'] = "<li title='Trang cuối cùng'>";
62        $config['last_tag_close'] = '</li>';
63        $config['next_link'] = '>';
64        $config['next_tag_open'] = "<li title='Trang kế tiếp'>";
65        $config['next_tag_close'] = '</li>';
66        $config['prev_link'] = '<';
67        $config['prev_tag_open'] = "<li title='Trang trước'>";
68        $config['prev_tag_close'] = '</li>';
69        $config['num_links'] = 2;
70        $config['current_page'] = $data['current_page'];
71        $config['ajax_class'] = 'ajax_paging';
72        $this->pagination->initialize($config);
73        $data['paging'] = $this->pagination->create_links();
74
75        if ($this->input->is_ajax_request()) {
76        return $this->load->view('collaborator/listview', $data);   
77        }
78        return $this->load->view('collaborator/listview', $data,true);   
79    }
80    public function test() {
81        $data=$this->db->get_where('tblcollaborator');
82        print_r ($data->result_array());
83        die();
84        for ($i = 1; $i <= 500; $i++) {
85            $collaborator = new Entities\Tblcollaborator();
86            $collaborator->setActivated(rand(0, 1));
87            $collaborator->setAuthor(1);
88            $collaborator->setCellphone('0' . (1695061706+$i));
89            $collaborator->setCreatedTime(date("Y-m-d H:i:s"));
90            $collaborator->setFullName("Full Name ".$i);
91            $collaborator->setLoginName("loginname".$i);
92            $collaborator->setPasswd(md5("12345678"));
93            $collaborator->setUpdatedTime(date("Y-m-d H:i:s"));
94            try {
95                $this->doctrine->em->persist($collaborator);
96                $this->doctrine->em->flush();
97                $result['success'] = 1;
98            } catch (Exception $e) {
99
100                echo $e;
101            }
102        }
103    }
104
105}
Note: See TracBrowser for help on using the repository browser.