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

Last change on this file since 360 was 360, 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        $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
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        }
39       
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
44        $data['paging_url'] = base_url() . "/admin/cong_tac_vien/trang/";
45        $data['num_links'] = 2;
46        $data['paging'] = pagging($data);
47
48        if ($this->input->is_ajax_request()) {
49            return $this->load->view('collaborator/listview', $data);
50        }
51        return $this->load->view('collaborator/listview', $data, true);
52    }
53
54    public function addCollaborator() {
55        $result = array();
56        $input = $this->input->post();
57        $this->db->insert('tblcollaborator', $input);
58        $result['success'] = 1;
59        echo json_encode($result);
60    }
61
62    public function test() {
63
64        for ($i = 1; $i <= 500; $i++) {
65            $collaborator = new Entities\Tblcollaborator();
66            $collaborator->setActivated(rand(0, 1));
67            $collaborator->setAuthor(1);
68            $collaborator->setCellphone('0' . (1695061706 + $i));
69            $collaborator->setCreatedTime(date("Y-m-d H:i:s"));
70            $collaborator->setFullName("Full Name " . $i);
71            $collaborator->setLoginName("loginname" . $i);
72            $collaborator->setPasswd(md5("12345678"));
73            $collaborator->setUpdatedTime(date("Y-m-d H:i:s"));
74            try {
75                $this->doctrine->em->persist($collaborator);
76                $this->doctrine->em->flush();
77                $result['success'] = 1;
78            } catch (Exception $e) {
79
80                echo $e;
81            }
82        }
83    }
84
85}
Note: See TracBrowser for help on using the repository browser.