source: pro-violet-viettel/sourcecode/application/modules/admin/models/paidlog_model.php @ 444

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

paidlogs

File size: 2.2 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class Paidlog_model extends MY_Model
4{
5       
6        protected $table_name = 'tblpaidlog';
7        protected $id_name = 'paid_id';
8
9        function __construct()
10        {
11                parent::__construct();
12
13        }
14        function getPaidlogs($data) {
15        $sql = "SELECT * FROM " . $this->table_name. " INNER JOIN tbluser ON tbluser.us_id = tblpaidlog.us_id ";
16        if ($data['keyword']) {
17            if ($data['search_field'] == "cellphone") {
18                $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%')";
19            }
20        }
21
22        $order = "";
23        if ($data['sorting_order'] != "sorting") {
24            if ($data['sorting_field'] != "money") {
25                $sort = "DESC";
26                if ($data['sorting_order'] == "sorting_asc")
27                    $sort = "ASC";
28                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
29            }
30        }
31        $sql=$sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
32      // echo $sql;
33        return $this->db->query($sql)->result_array();
34    }
35
36
37
38    function countPaidlog($data) {
39        $sql = "SELECT COUNT(".$this->id_name.") as total FROM " . $this->table_name." INNER JOIN tbluser ON tbluser.us_id = tblpaidlog.us_id";
40        if ($data['keyword']) {
41            if ($data['search_field'] == "cellphone") {
42                $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%')";
43            }
44        }
45       
46        $result = $this->db->query($sql)->row_array();
47        return $result['total'];
48    }
49    function getPaidlog($id)
50    {
51        $sql="SELECT * FROM ".$this->table_name." WHERE ".$this->id_name."=".$id." LIMIT 1";
52        $result = $this->db->query($sql)->row_array();
53        return $result;
54    }
55    function getAllPaidlogs($from)
56    {
57        // get all paidlogs from the last years until now
58        $from = date("Y-m-d 00:00:00",$from);
59        $sql="SELECT * FROM ".$this->table_name." WHERE paid_time > '".$from."'";
60        $result = $this->db->query($sql)->result_array();
61        foreach ($result as $index=>$paidlog)
62        {
63            $result[$index]['time']=  strtotime($paidlog['paid_time']);
64        }
65        return $result;
66    }
67}
Note: See TracBrowser for help on using the repository browser.