- Timestamp:
- Feb 14, 2015 10:38:40 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/services/controllers/report.php
r758 r765 1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 1 <?php 2 3 if (! defined ( 'BASEPATH' )) 4 exit ( 'No direct script access allowed' ); 2 5 /** 3 6 * Report Class 4 * 7 * 5 8 * @author dzungnv02 6 * 9 * 7 10 */ 8 9 11 class Report extends MX_Controller { 10 11 12 private $_server = null; 12 13 14 /** 15 * 16 */ 13 17 function __construct() { 14 18 parent::__construct (); … … 17 21 'soap_version' => SOAP_1_2, 18 22 'encoding' => 'UTF-8', 19 'uri' => 'http://tempuri.org/' 23 'uri' => 'http://tempuri.org/' 20 24 ) ); 21 25 } 22 26 27 /** 28 * 29 */ 23 30 function __destruct() { 24 31 ini_set ( "soap.wsdl_cache_enabled", "0" ); 25 32 } 26 33 34 /** 35 * 36 */ 27 37 public function index() { 28 38 if ($this->uri->segment ( 3 ) == "wsdl") { … … 30 40 $this->load->view ( 'reportwsdl' ); 31 41 return; 32 } 33 else { 42 } else { 34 43 header ( 'Content-Type: text/html; charset: utf-8' ); 35 44 echo '<div>See Report service <a href="', base_url (), 'violetservice/report/wsdl">WSDL page</a></div>'; … … 37 46 } 38 47 48 /** 49 * 50 * @return multitype:string number |string 51 */ 39 52 public function get() { 40 function revenueReport () { 41 $aryArgs = func_get_args (); 42 list ( $username, $password, $fromDate, $toDate) = $aryArgs; 43 53 54 /** 55 * 56 * @return multitype:string number 57 */ 58 function revenueReport() { 59 $aryArgs = func_get_args (); 60 list ( $username, $password, $fromDate, $toDate ) = $aryArgs; 61 44 62 $CI = & get_instance (); 45 if (!$toDate) $toDate = date('Y-m-d'); 46 $message = validate ($aryArgs); 47 $success = $message == '' ? 1 : 0;// 0:error; 1:Success; 63 if (! $toDate) 64 $toDate = date ( 'Y-m-d' ); 65 $message = validate ( $aryArgs ); 66 $success = $message == '' ? 1 : 0; // 0:error; 1:Success; 48 67 49 68 if ($success == 1) { 50 69 $CI->load->model ( 'Services_model' ); 51 70 $CI->load->model ( 'admin/Reportmodel', 'objReportModel' ); 52 $from = explode('-', $fromDate); 53 $to = explode('-', $toDate); 54 $input = array('year' => $from[0], 'month' => $from[1], 'to_year' => $to[0], 'to_month' => $to[1], 'to_date' => $to[2]); 55 $result = $CI->objReportModel->exportProvince( $input ); 56 57 if (count($result) > 0 && is_array($result)) { 58 //1|20140915|A076|0|0|0|100000|0|0 59 $aryTmp = array(); 60 $aryResult = array(); 61 foreach ($result as $provinceCode => $record) { 62 //No|toDate|ProvCode|TBngay|LKTBThang|TongTBNam|DTngay|LuyKeTBThang|TongDTNam 63 $aryTmp[] = $record['stt']; 64 $aryTmp[] = implode('', $to); 65 $aryTmp[] = $provinceCode; 66 $aryTmp[] = $record['tbng']; 67 $aryTmp[] = $record['tbt']; 68 $aryTmp[] = $record['tbn']; 69 $aryTmp[] = $record['dtng']; 70 $aryTmp[] = $record['dtt']; 71 $aryTmp[] = $record['dtn']; 72 $aryResult[] = implode('|', $aryTmp); 73 $aryTmp = array(); 71 $from = explode ( '-', $fromDate ); 72 $to = explode ( '-', $toDate ); 73 $input = array ( 74 'year' => $from [0], 75 'month' => $from [1], 76 'to_year' => $to [0], 77 'to_month' => $to [1], 78 'to_date' => $to [2] 79 ); 80 $result = $CI->objReportModel->exportProvince ( $input ); 81 82 if (count ( $result ) > 0 && is_array ( $result )) { 83 // 1|20140915|A076|0|0|0|100000|0|0 84 $aryTmp = array (); 85 $aryResult = array (); 86 foreach ( $result as $provinceCode => $record ) { 87 // No|toDate|ProvCode|TBngay|LKTBThang|TongTBNam|DTngay|LuyKeTBThang|TongDTNam 88 $aryTmp [] = $record ['stt']; 89 $aryTmp [] = implode ( '', $to ); 90 $aryTmp [] = $record ['ma']; 91 $aryTmp [] = $record ['thue_bao_ngay']; 92 $aryTmp [] = $record ['thue_bao_thang']; 93 $aryTmp [] = $record ['thue_bao_nam']; 94 $aryTmp [] = $record ['doanh_thu_ngay']; 95 $aryTmp [] = $record ['doanh_thu_thang']; 96 $aryTmp [] = $record ['doanh_thu_nam']; 97 $aryResult [] = implode ( '|', $aryTmp ); 98 $aryTmp = array (); 74 99 } 75 100 76 $message = implode ("\n", $aryResult);101 $message = implode ( "\n", $aryResult ); 77 102 $success = 1; 78 103 } 79 104 } 80 105 81 return array($message, $success, date('YmdHis')); 82 } 83 84 function subscribersReport () { 85 $aryArgs = func_get_args (); 86 list ( $username, $password, $fromDate, $toDate) = $aryArgs; 87 106 return array ( 107 $message, 108 $success, 109 date ( 'YmdHis' ) 110 ); 111 } 112 113 /** 114 * 115 * @return multitype:string number 116 */ 117 function subscribersReport() { 118 $aryArgs = func_get_args (); 119 list ( $username, $password, $fromDate, $toDate ) = $aryArgs; 120 88 121 $CI = & get_instance (); 89 $message = validate ($aryArgs); 90 $success = $message == '' ? 1 : 0;// 0:error; 1:Success; 91 $message = $message == '' ? 'subscribersReport' : $message; 122 $message = validate ( $aryArgs ); 123 $success = $message == '' ? 1 : 0; // 0:error; 1:Success; 124 125 if ($success == 1) { 126 $CI->load->model ( 'Services_model' ); 127 $CI->load->model ( 'admin/Reportmodel', 'objReportModel' ); 128 $from = explode ( '-', $fromDate ); 129 $to = explode ( '-', $toDate ); 130 $input = array ( 131 'year' => $from [0], 132 'month' => $from [1], 133 'date' => $from [2], 134 'to_year' => $to [0], 135 'to_month' => $to [1], 136 'to_date' => $to [2] 137 ); 138 $result = $CI->objReportModel->exportPackage ( $input ); 139 140 if (count ( $result ) > 0 && is_array ( $result )) { 141 $aryTmp = array (); 142 $aryResult = array (); 143 foreach ( $result as $provinceCode => $record ) { 144 $aryTmp [] = $record ['stt']; 145 $aryTmp [] = implode ( '', $to ); 146 $aryTmp [] = $record ['ma']; 147 $aryTmp [] = $record ['tong_so_VIP 1']; 148 $aryTmp [] = $record ['ti_le_VIP 1']; 149 $aryTmp [] = $record ['tong_so_VIP 3']; 150 $aryTmp [] = $record ['ti_le_VIP 3']; 151 $aryTmp [] = $record ['tong_so_VIP 6']; 152 $aryTmp [] = $record ['ti_le_VIP 6']; 153 $aryTmp [] = $record ['tong_so_VIP 12']; 154 $aryTmp [] = $record ['ti_le_VIP 12']; 155 $aryTmp [] = $record ['tong_so_tb']; 156 $aryResult [] = implode ( '|', $aryTmp ); 157 $aryTmp = array (); 158 } 159 160 $message = implode ( "\n", $aryResult ); 161 $success = 1; 162 } 163 } 92 164 93 165 $CI->load->model ( 'Services_model' ); 94 $CI->load->model ( 'admin/Reportmodel', 'objReportModel' ); 95 96 return array($message, $success, date('YmdHis')); 97 } 98 99 function validate ($aryArgs) { 100 list ( $username, $password, $fromDate, $toDate) = $aryArgs; 166 $CI->load->model ( 'admin/Reportmodel', 'objReportModel' ); 167 168 return array ( 169 $message, 170 $success, 171 date ( 'YmdHis' ) 172 ); 173 } 174 175 /** 176 * 177 * @param unknown $aryArgs 178 * @return string 179 */ 180 function validate($aryArgs) { 181 list ( $username, $password, $fromDate, $toDate ) = $aryArgs; 101 182 102 183 $CI = & get_instance (); 103 184 $predefUsername = $CI->config->item ( 'report_username' ); 104 185 $predefPassword = $CI->config->item ( 'report_password' ); 105 186 106 187 $message = ''; 107 188 108 189 if (! $username) { 109 190 $message = 'Username is required!'; 110 } else if (! $password) {111 $message = 112 } else if ($username != $predefUsername) {113 $message = 114 } else if ($password != $predefPassword) {115 $message = 116 } else if (! $fromDate) {117 $message = 118 } else if (!preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $fromDate)) {119 $message = 120 } else if ($toDate && !preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $toDate)) {121 $message = 122 } 123 191 } else if (! $password) { 192 $message = 'Password is required!'; 193 } else if ($username != $predefUsername) { 194 $message = 'Username is not corrected!'; 195 } else if ($password != $predefPassword) { 196 $message = 'Password is not corrected!'; 197 } else if (! $fromDate) { 198 $message = 'fromDate is required!'; 199 } else if (! preg_match ( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $fromDate )) { 200 $message = 'fromDate is not corrected!'; 201 } else if ($toDate && ! preg_match ( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $toDate )) { 202 $message = 'toDate is not corrected!'; 203 } 204 124 205 return $message; 125 206 } 126 207 127 $this->_server->addFunction ( array('revenueReport', 'subscribersReport')); 208 $this->_server->addFunction ( array ( 209 'revenueReport', 210 'subscribersReport' 211 ) ); 128 212 129 213 try { … … 136 220 $soapOutput = ob_get_clean (); 137 221 } 138 222 139 223 if ($soapOutput != '') { 140 error_log (var_export($soapOutput, true) . "\n\n\n", 3, '/srv/www/sbg/log/reportservicexml.log');141 142 $response = preg_match ('/revenueReportResponse/', $soapOutput) ? 'revenueReportResponse' : (preg_match('/subscribersReportResponse/', $soapOutput) ? 'subscribersReportResponse':'');224 error_log ( var_export ( $soapOutput, true ) . "\n\n\n", 3, '/srv/www/sbg/log/reportservicexml.log' ); 225 226 $response = preg_match ( '/revenueReportResponse/', $soapOutput ) ? 'revenueReportResponse' : (preg_match ( '/subscribersReportResponse/', $soapOutput ) ? 'subscribersReportResponse' : ''); 143 227 144 228 $pattern = '/<[^>]*[^\/]>/i'; 145 229 $aryOutput = preg_split ( $pattern, $soapOutput, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); 146 error_log (var_export($aryOutput, true) . "\n\n\n", 3, '/srv/www/sbg/log/reportservice.log');230 error_log ( var_export ( $aryOutput, true ) . "\n\n\n", 3, '/srv/www/sbg/log/reportservice.log' ); 147 231 $aryData = array (); 148 232 $aryData ['message'] = $aryOutput [1]; … … 159 243 } catch ( Exception $e ) { 160 244 $this->_server->fault ( 'Sender', $e->getMessage () ); 161 } 245 } 162 246 } 163 247 }
Note: See TracChangeset
for help on using the changeset viewer.