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

Last change on this file since 362 was 362, 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       
55        $result = array();
56        $input = $this->input->post();
57        $this->load->model('collabolator_model');
58        $this->collabolator_model->insert($input);
59        $result['success'] = 1;
60        echo json_encode($result);
61    }
62
63    public function test() {
64
65        for ($i = 1; $i <= 500; $i++) {
66            $collaborator = new Entities\Tblcollaborator();
67            $collaborator->setActivated(rand(0, 1));
68            $collaborator->setAuthor(1);
69            $collaborator->setCellphone('0' . (1695061706 + $i));
70            $collaborator->setCreatedTime(date("Y-m-d H:i:s"));
71            $collaborator->setFullName("Full Name " . $i);
72            $collaborator->setLoginName("loginname" . $i);
73            $collaborator->setPasswd(md5("12345678"));
74            $collaborator->setUpdatedTime(date("Y-m-d H:i:s"));
75            try {
76                $this->doctrine->em->persist($collaborator);
77                $this->doctrine->em->flush();
78                $result['success'] = 1;
79            } catch (Exception $e) {
80
81                echo $e;
82            }
83        }
84    }
85
86}
Note: See TracBrowser for help on using the repository browser.