- Timestamp:
- Mar 24, 2015 2:15:02 PM (10 years ago)
- Location:
- pro-violet-viettel/sourcecode/application/modules/admin/models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/admin/models/paidlog_model.php
r777 r818 1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 2 2 3 3 class Paidlog_model extends MY_Model … … 37 37 if ($data['paid_type'] ==0){ 38 38 $sql.=" WHERE paid_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'"; 39 //write_file('./log/sql.log', date("m/d/Y H:i:s")." ".$sql."\n", FOPEN_WRITE_CREATE);40 39 }else{ 41 40 $sql.=" AND paid_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'"; … … 45 44 46 45 $order = ""; 47 if ($data['sorting_order'] != "sorting") { 48 if ($data['sorting_field'] != "money") { 49 $sort = "DESC"; 50 if ($data['sorting_order'] == "sorting_asc") 51 $sort = "ASC"; 52 $order = "ORDER BY " . $data['sorting_field'] . " " . $sort; 53 } 54 } 55 $sql=$sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " "; 46 if ($data['sorting_order']){ 47 if ($data['sorting_order'] != "sorting") { 48 if ($data['sorting_field'] != "money") { 49 $sort = "DESC"; 50 if ($data['sorting_order'] == "sorting_asc") 51 $sort = "ASC"; 52 $order = "ORDER BY " . $data['sorting_field'] . " " . $sort; 53 } 54 } 55 } 56 if ($data['start']){ 57 $sql=$sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " "; 58 } 56 59 //return $this->db->query($sql)->result_array(); 57 60 $re = $this->db->query($sql)->result_array(); -
pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php
r765 r818 45 45 46 46 // Tinh thue bao theo tinh theo nam 47 $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >= '" . $input ['year'] . "-01-01' AND tbluser.created_time <= '" . ($input ['year'] + 1) . "-01-01' GROUP BY tbluser.province"; 48 $query = $this->db->query ( $sql ); 47 $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >= '" . $input ['year'] . "-01-01 00:00:00' AND tbluser.created_time <= '" . ($input ['year'] + 1) . "-01-01 23:59:59' GROUP BY tbluser.province"; 48 $query = $this->db->query ( $sql ); 49 write_file('./log/test.log', date('d-m-Y H:i:s').": ".$sql."\n", FOPEN_WRITE_CREATE); 49 50 $tbns = $query->result_array (); 50 51 51 52 // tinh thue bao theo thang 52 $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND $to GROUP BY tbluser.province"; 53 //$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND $to GROUP BY tbluser.province"; 54 $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . '01 00:00:00' . "' AND created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 23:59:59' GROUP BY tbluser.province"; 53 55 $query = $this->db->query ( $sql ); 54 56 $tbts = $query->result_array (); … … 56 58 // tinh thue bao theo ngay 57 59 $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >='" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 00:00:00' AND tbluser.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 23:59:59' GROUP BY tbluser.province"; 58 59 60 $query = $this->db->query ( $sql ); 60 61 $tbng = $query->result_array (); 61 62 62 $dem = 1; 63 64 $totalTbng = 0; 65 $totalTbth = 0; 66 $totalTbn = 0; 67 $totalDtng = 0; 68 $totalDtth = 0; 69 $totalDtn = 0; 63 70 64 71 foreach ( $provinces as $index2 => $province ) { … … 104 111 } 105 112 } 113 114 $totalTbng = $totalTbng + $provinces [$index2] ['tbng']; 115 $totalTbth = $totalTbth + $provinces [$index2] ['tbt']; 116 $totalTbn = $totalTbn + $provinces [$index2] ['tbn']; 117 118 $totalDtng = $totalDtng + $provinces [$index2] ['dtng']; 119 $totalDtth = $totalDtth + $provinces [$index2] ['dtt']; 120 $totalDtn = $totalDtn + $provinces [$index2] ['dtn']; 121 106 122 $dem ++; 107 123 } 108 109 return $provinces; 124 125 $data['provinces'] = $provinces; 126 127 $data['totalTbng'] = $totalTbng; 128 $data['totalTbth'] = $totalTbth; 129 $data['totalTbn'] = $totalTbn; 130 131 $data['totalDtng'] = $totalDtng; 132 $data['totalDtth'] = $totalDtth; 133 $data['totalDtn'] = $totalDtn; 134 135 //return $provinces; 136 return $data; 110 137 } 111 138 … … 118 145 $provinces = lang ( '_PROVINCES_' ); 119 146 // tinh thue bao theo thang 120 $sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id WHERE tbluser.created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tbluser.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblservicepackage.p_period > 0 "; 147 //$sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id LEFT JOIN tblregisterpackagelog ON tbluser.cellphone = tblregisterpackagelog.username WHERE tbluser.updated_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tbluser.updated_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblregisterpackagelog.created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tblregisterpackagelog.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblservicepackage.p_period > 0 "; 148 $sql = "SELECT * FROM tbluser LEFT JOIN tblregisterpackagelog ON tbluser.cellphone = tblregisterpackagelog.username WHERE tbluser.updated_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tbluser.updated_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblregisterpackagelog.created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tblregisterpackagelog.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "'"; 121 149 $query = $this->db->query ( $sql ); 122 150 $users = $query->result_array (); … … 128 156 $packages [$index] ['users'] = array (); 129 157 foreach ( $users as $user ) { 130 if ($user ['p_ id'] == $package ['p_id']) {158 if ($user ['p_code'] == $package ['p_code']) { 131 159 $packages [$index] ['users'] [] = $user; 132 160 } 133 161 } 134 162 } 135 136 163 foreach ( $provinces as $index => $province ) { 137 164 $provinces [$index] = array ( … … 139 166 ); 140 167 } 168 141 169 $dem = 1; 170 142 171 foreach ( $provinces as $index => $province ) { 143 172 $provinces [$index] ['stt'] = $dem; … … 154 183 $provinces [$index] ['total'] = $totaluser; 155 184 $provinces [$index] ['packages'] [$package ['p_name']] ['total'] = $total; 185 $provinces [$index] ['packages'] [$package ['p_name']] ['users'] [] = $user; 156 186 157 $provinces [$index] ['packages'] [$package ['p_name']] ['users'] [] = $user;158 187 } 159 188 } … … 161 190 $dem ++; 162 191 } 192 193 $totalByVIP = array(); 194 195 foreach ($packages as $index => $package){ 196 $totalByVIP[$package ['p_name']] = 0; 197 foreach ( $provinces as $index=>$province){ 198 foreach ($province['packages'] as $index2 => $p){ 199 if ($index2 == $package['p_name']) 200 $totalByVIP[$package ['p_name']] = $totalByVIP[$package ['p_name']] + $p['total']; 201 } 202 } 203 } 204 205 $totalVip = 0; 206 207 foreach ($totalByVIP as $vipName=>$total){ 208 $totalVip = $totalVip + $total; 209 } 210 211 $totalByVIP['total'] = $totalVip; 212 163 213 foreach ( $provinces as $index => $province ) { 164 214 foreach ( $packages as $index2 => $package ) { … … 172 222 $data ['packages'] = $packages; 173 223 $data ['provinces'] = $provinces; 224 $data['totalVip'] = $totalByVIP; 174 225 return $data; 175 226 } -
pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php
r769 r818 69 69 $sql.=" WHERE province = '".$data['province_code']."' AND created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'"; 70 70 }else{ 71 $sql.=" AND(created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";71 $sql.=" WHERE (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')"; 72 72 } 73 73 }else{ … … 101 101 } 102 102 } 103 write_file('./log/test.log', date("d-m-Y: H:i:s"). ": ".$sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage'] , FOPEN_WRITE_CREATE); 103 104 return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array(); 104 105 }
Note: See TracChangeset
for help on using the changeset viewer.