source: pro-violet-viettel/sourcecode/application/modules/admin/models/user_acc_model.php @ 432

Last change on this file since 432 was 432, checked in by namnd, 11 years ago
File size: 2.1 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class User_Acc_model extends MY_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['keyword'])
27                {
28                        $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
29                }
30                if ($data['status'] == 1){
31                        $sql.=" WHERE expire_date > NOW()";
32                }
33                if ($data['status'] == 2){
34                        $sql.=" WHERE expire_date < NOW()";
35                }
36                $order = "";
37                if ($data['sorting_order'] != "sorting") {
38                        if($data['sorting_field'] != "status"){
39                                $sort = "DESC";
40                                if ($data['sorting_order'] == "sorting_asc")
41                                        $sort = "ASC";
42                                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
43                        }
44                }
45                return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
46        }
47
48        function get_total_users($data)
49        {
50                $sql="SELECT COUNT(".$this->id_name.") AS total FROM ".$this->table_name;
51               
52                if ($data['status'] == 1){
53                        $sql.=" WHERE expire_date > NOW()";
54                }
55                if ($data['status'] == 2){
56                        $sql.=" WHERE expire_date < NOW()";
57                }
58               
59                if (isset($data['keyword']))
60                {
61                        if (strlen($data['keyword'])>0)
62                                $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
63                }
64                return $this->db->query($sql)->row_array()['total'];
65        }
66       
67        function get_user_info($src, $us_id, $token)
68        {
69                $data = $this->vservices->actionExecute('getinfo', array('src' => $src, 'us_id' => $us_id, 'token'=>$token), 'user');
70                return $data;
71        }
72}
Note: See TracBrowser for help on using the repository browser.