source: pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php @ 684

Last change on this file since 684 was 610, checked in by namnd, 10 years ago
File size: 2.6 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class User_model extends CI_Model
4{
5       
6        protected $table_name = 'tbluser';
7        protected $id_name = 'us_id';
8
9        function __construct()
10        {
11                parent::__construct();
12                $this->vservices->setApiUrl($this->config->item('api_url'));
13                $this->vservices->setConnection($this->curl);
14        }
15       
16        function check_data($login_name)
17        {
18                $this->db->where('login_name', $login_name);
19                $query = $this->db->get($this->table_name);
20                return $query->num_rows();
21        }
22       
23        function get_list_users($data)
24        {
25                $sql="SELECT * FROM ".$this->table_name;
26                if ($data['status'] == 1){
27                        $sql.=" WHERE expire_date > NOW()";
28                }
29                if ($data['status'] == 2){
30                        $sql.=" WHERE expire_date < NOW()";
31                }
32                if (isset($data['keyword']))
33                {
34                        if (strlen($data['keyword'])>0){
35                                if ($data['status']==0){
36                                        $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
37                                }else
38                                {
39                                        $sql.=" AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
40                                }
41                        }
42                }
43                $order = "";
44                if ($data['sorting_order'] != "sorting") {
45                        if($data['sorting_field'] != "status"){
46                                $sort = "DESC";
47                                if ($data['sorting_order'] == "sorting_asc")
48                                        $sort = "ASC";
49                                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
50                        }
51                }
52                return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
53        }
54
55        function get_total_users($data)
56        {
57                $sql="SELECT COUNT(".$this->id_name.") AS total FROM ".$this->table_name;
58               
59                if ($data['status'] == 1){
60                        $sql.=" WHERE expire_date > NOW()";
61                }
62                if ($data['status'] == 2){
63                        $sql.=" WHERE expire_date < NOW()";
64                }
65               
66                if (isset($data['keyword']))
67                {
68                        if (strlen($data['keyword'])>0){
69                                if ($data['status']==0){
70                                        $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
71                                }else
72                                {
73                                        $sql.=" AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
74                                }
75                        }
76                }
77               
78                $query = $this->db->query($sql);
79                $row = $query->row_array();
80               
81                return $row['total'];
82        }
83       
84        function get_user_info($src, $us_id, $token)
85        {
86                $data = $this->vservices->actionExecute('getinfo', array('src' => $src, 'us_id' => $us_id, 'token'=>$token), 'user');
87        return $data;
88        }
89       
90}
Note: See TracBrowser for help on using the repository browser.