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

Last change on this file since 740 was 740, checked in by quyenla, 10 years ago

dump

File size: 2.9 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        }else{
21                        if(strlen($data['daterange_start'])>0){
22                               
23                                $sql.=" WHERE paid_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'";
24                                write_file('./log/sql.log', date("m/d/Y H:i:s")." ".$sql."\n", FOPEN_WRITE_CREATE);
25                        }
26                }
27
28        $order = "";
29        if ($data['sorting_order'] != "sorting") {
30            if ($data['sorting_field'] != "money") {
31                $sort = "DESC";
32                if ($data['sorting_order'] == "sorting_asc")
33                    $sort = "ASC";
34                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
35            }
36        }
37        $sql=$sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
38      // echo $sql;
39        return $this->db->query($sql)->result_array();
40    }
41
42
43
44    function countPaidlog($data) {
45        $sql = "SELECT COUNT(".$this->id_name.") as total FROM " . $this->table_name." INNER JOIN tbluser ON tbluser.us_id = tblpaidlog.us_id";
46        if ($data['keyword']) {
47            if ($data['search_field'] == "cellphone") {
48                $sql.=" WHERE (cellphone LIKE '%" . $data['keyword'] . "%')";
49            }
50        }else{
51                        if(strlen($data['daterange_start'])>0){
52                               
53                                $sql.=" WHERE paid_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'";
54                                //write_file('./log/sql.log', date("m/d/Y H:i:s")." ".$sql."\n", FOPEN_WRITE_CREATE);
55                        }
56                }
57               
58       
59        $result = $this->db->query($sql)->row_array();
60        return $result['total'];
61    }
62    function getPaidlog($id)
63    {
64        $sql="SELECT * FROM ".$this->table_name." WHERE ".$this->id_name."=".$id." LIMIT 1";
65        $result = $this->db->query($sql)->row_array();
66        return $result;
67    }
68    function getAllPaidlogs($from)
69    {
70        // get all paidlogs from the last years until now
71        $from = date("Y-m-d 00:00:00",$from);
72        $sql="SELECT * FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.us_id = ".$this->table_name.".us_id WHERE ".$this->table_name.".paid_time > '".$from."'";
73        $result = $this->db->query($sql)->result_array();
74        foreach ($result as $index=>$paidlog)
75        {
76            $result[$index]['time']=  strtotime($paidlog['paid_time']);
77        }
78        $file = fopen("/srv/www/sbg/log/dump.log","w");
79        fwrite($file,  serialize($result));
80        fclose($file);
81        return $result;
82    }
83}
Note: See TracBrowser for help on using the repository browser.