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

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

collaborator

File size: 2.8 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        $admin_info = $this->session->userdata('adminInfo');
16        if ($admin_info) {
17            $data['content'] = $this->getCollaborators();
18            $this->load->view('collaborator/index', $data);
19        } else {
20            $this->load->view('login');
21        }
22    }
23
24    public function getCollaborators($filters = array()) {
25        $this->load->helper('pagging');
26        $this->load->model('collabolator_model');
27        $data['current_page'] = $this->uri->segment(4, 1);
28        $data['itemsoptions'] = array(10, 25, 50, 100);
29        $data['perpage'] = 10;
30        $data['keyword'] = "";
31
32        if ($this->input->post('items')) {
33            $data['perpage'] = $this->input->post('items');
34        }
35        if ($this->input->post('keyword')) {
36            $data['keyword'] = $this->input->post('keyword');
37        }
38       
39        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
40        $data['total'] = $this->collabolator_model->countCollaborator($data); 
41        $data['collaborators'] = $this->collabolator_model->getCollaborator($data);
42
43        $data['paging_url'] = base_url() . "/admin/cong_tac_vien/trang/";
44        $data['num_links'] = 2;
45        $data['paging'] = pagging($data);
46
47        if ($this->input->is_ajax_request()) {
48            return $this->load->view('collaborator/listview', $data);
49        }
50        return $this->load->view('collaborator/listview', $data, true);
51    }
52
53    public function addCollaborator() {
54        $result = array();
55        $input = $this->input->post();
56        $this->db->insert('tblcollaborator', $input);
57        $result['success'] = 1;
58        echo json_encode($result);
59    }
60
61    public function test() {
62
63        for ($i = 1; $i <= 500; $i++) {
64            $collaborator = new Entities\Tblcollaborator();
65            $collaborator->setActivated(rand(0, 1));
66            $collaborator->setAuthor(1);
67            $collaborator->setCellphone('0' . (1695061706 + $i));
68            $collaborator->setCreatedTime(date("Y-m-d H:i:s"));
69            $collaborator->setFullName("Full Name " . $i);
70            $collaborator->setLoginName("loginname" . $i);
71            $collaborator->setPasswd(md5("12345678"));
72            $collaborator->setUpdatedTime(date("Y-m-d H:i:s"));
73            try {
74                $this->doctrine->em->persist($collaborator);
75                $this->doctrine->em->flush();
76                $result['success'] = 1;
77            } catch (Exception $e) {
78
79                echo $e;
80            }
81        }
82    }
83
84}
Note: See TracBrowser for help on using the repository browser.