Changeset 758


Ignore:
Timestamp:
Feb 10, 2015 5:17:08 PM (10 years ago)
Author:
dungnv
Message:
 
Location:
pro-violet-viettel/sourcecode/application
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/config/config.php

    r695 r758  
    391391$config['mo_password'] = 'sbg571285';
    392392
     393$config['report_username'] = 'sbg';
     394$config['report_password'] = 'sbg150209';
     395
    393396$config['mt_username'] = 'sbg';
    394397$config['mt_password'] = 'sbg56ab77cdsgb';
  • pro-violet-viettel/sourcecode/application/config/routes.php

    r751 r758  
    4242$route['404_override'] = '';
    4343
    44 $route['violetservice/soanbai/subscribers-report'] = '';
    45 $route['violetservice/soanbai/subscribers-report/wsdl'] = '';
     44$route['violetservice/report'] = 'services/report/index';
     45$route['violetservice/report/'] = 'services/report/index';
     46$route['violetservice/report/wsdl'] = 'services/report/index/wsdl';
     47$route['violetservice/report/wsdl/'] = 'services/report/index/wsdl';
    4648
    47 $route['violetservice/soanbai/revenue-report'] = 'services/viettel/mo';
    48 $route['violetservice/soanbai/revenue-report/wsdl'] = 'services/viettel/mo';
     49$route['violetservice/report/getreport'] = 'services/report/get';
    4950
    5051$route['violetservice/soanbai/mo'] = 'services/viettel/mo';
  • pro-violet-viettel/sourcecode/application/language/message/messages_lang.php

    r753 r758  
    150150                                                'T074'=>'Trà Vinh',
    151151                                                'T027'=>'Tuyên Quang',
    152                                                 'Y029'=>'Yên Bái',
    153152                                                'V070'=>'VÄ©nh Long',
    154                                                 'V211'=>'VÄ©nh Phúc'
     153                                                'V211'=>'VÄ©nh Phúc',
     154                                                'Y029'=>'Yên Bái'
    155155                                                );
  • pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php

    r757 r758  
    7878                }
    7979            }
    80 
    81 
    8280
    8381            foreach ($tbns as $data) {
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/report.php

    r751 r758  
     1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     2/**
     3 * Report Class
     4 *
     5 * @author dzungnv02
     6 *
     7 */
     8
     9class Report extends MX_Controller {
     10       
     11        private $_server = null;
     12       
     13        function __construct() {
     14                parent::__construct ();
     15                ini_set ( "soap.wsdl_cache_enabled", "1" );
     16                $this->_server = new SoapServer ( NULL, array (
     17                                'soap_version' => SOAP_1_2,
     18                                'encoding' => 'UTF-8',
     19                                'uri' => 'http://tempuri.org/'
     20                ) );
     21        }
     22       
     23        function __destruct() {
     24                ini_set ( "soap.wsdl_cache_enabled", "0" );
     25        }
     26       
     27        public function index() {
     28                if ($this->uri->segment ( 3 ) == "wsdl") {
     29                        header ( 'Content-Type: text/xml; charset: utf-8' );
     30                        $this->load->view ( 'reportwsdl' );
     31                        return;
     32                }
     33                else {
     34                        header ( 'Content-Type: text/html; charset: utf-8' );
     35                        echo '<div>See Report service <a href="', base_url (), 'violetservice/report/wsdl">WSDL page</a></div>';
     36                }
     37        }
     38       
     39        public function get() {
     40                function revenueReport () {
     41                        $aryArgs = func_get_args ();   
     42                        list ( $username, $password, $fromDate, $toDate) = $aryArgs;
     43
     44                        $CI = & get_instance ();
     45                        if (!$toDate) $toDate = date('Y-m-d');
     46                        $message = validate ($aryArgs);                 
     47                        $success = $message == '' ? 1 : 0;// 0:error; 1:Success;
     48                       
     49                        if ($success == 1) {
     50                                $CI->load->model ( 'Services_model' );
     51                                $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();
     74                                        }
     75                                       
     76                                        $message = implode("\n", $aryResult);
     77                                        $success = 1;
     78                                }
     79                        }
     80                       
     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
     88                        $CI = & get_instance ();
     89                        $message = validate ($aryArgs);
     90                        $success = $message == '' ? 1 : 0;// 0:error; 1:Success;
     91                        $message = $message == '' ? 'subscribersReport' : $message;
     92                       
     93                        $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;
     101                       
     102                        $CI = & get_instance ();
     103                        $predefUsername = $CI->config->item ( 'report_username' );
     104                        $predefPassword = $CI->config->item ( 'report_password' );
     105                               
     106                        $message = '';
     107                               
     108                        if (! $username) {
     109                                $message = 'Username is required!';
     110                        }else if (! $password) {
     111                                $message =  'Password is required!';
     112                        }else if ($username != $predefUsername) {
     113                                $message =  'Username is not corrected!';
     114                        }else if ($password != $predefPassword) {
     115                                $message =  'Password is not corrected!';
     116                        }else if (! $fromDate) {
     117                                $message =  'fromDate is required!';
     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 =  'fromDate is not corrected!';
     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 =  'toDate is not corrected!';
     122                        }
     123
     124                        return $message;
     125                }
     126               
     127                $this->_server->addFunction ( array('revenueReport', 'subscribersReport'));
     128               
     129                try {
     130                        ob_start ();
     131                        $soapOutput = '';
     132                        $request = '';
     133                        $this->_server->handle ();
     134                       
     135                        if (ob_get_length () > 0) {
     136                                $soapOutput = ob_get_clean ();
     137                        }
     138                               
     139                        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':'');
     143                               
     144                                $pattern = '/<[^>]*[^\/]>/i';
     145                                $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');
     147                                $aryData = array ();
     148                                $aryData ['message'] = $aryOutput [1];
     149                                $aryData ['success'] = $aryOutput [2];
     150                                $aryData ['receiveTime'] = $aryOutput [3];
     151                                $aryData ['response'] = $response;
     152                                $xml = $this->load->view ( 'report', $aryData, TRUE );
     153                                header ( 'Content-Type: text/xml; charset: utf-8' );
     154                                echo $xml;
     155                        } else {
     156                                header ( 'Content-Type: text/html; charset: utf-8' );
     157                                echo 'See service <a href="' . base_url () . 'violetservice/report/wsdl">WSDL page</a>';
     158                        }
     159                } catch ( Exception $e ) {
     160                        $this->_server->fault ( 'Sender', $e->getMessage () );
     161                }               
     162        }
     163}
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php

    r716 r758  
    1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     1<?php
     2
     3if (! defined ( 'BASEPATH' ))
     4        exit ( 'No direct script access allowed' );
    25/**
    36 * Viettel Class
    4  * 
     7 *
    58 * @author dzungnv02
    6  *
     9 *       
    710 */
    8 
    9 class Viettel extends MX_Controller
    10 {
    11        
     11class Viettel extends MX_Controller {
    1212        private $_server = null;
    1313       
    1414        function __construct() {
    1515                parent::__construct ();
    16                 ini_set("soap.wsdl_cache_enabled","1");
    17                 $this->_server = new SoapServer(NULL,
    18                                 array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'uri' => 'http://tempuri.org/')
    19                 );
    20         }
    21 
    22         public function index ()
    23         {
    24                 if($this->uri->segment(4) == "wsdl") {
    25                         header('Content-Type: text/xml; charset: utf-8');
    26                         $this->load->view('mowsdl');
    27                 } else {
    28                         header('Content-Type: text/html; charset: utf-8');
    29                         echo 'See service <a href="'.base_url().'violetservice/soanbai/mo/wsdl">WSDL page</a>';
    30                 }                       
     16                ini_set ( "soap.wsdl_cache_enabled", "1" );
     17                $this->_server = new SoapServer ( NULL, array (
     18                                'soap_version' => SOAP_1_2,
     19                                'encoding' => 'UTF-8',
     20                                'uri' => 'http://tempuri.org/'
     21                ) );
    3122        }
    3223       
    33         public function mo()
    34         {       
    35                 function messageReceiver(){
    36                         $aryArgs = func_get_args();
    37                         $aryExport = array('Username' => $aryArgs[0], 'Password' => $aryArgs[1], 'RequestID' => $aryArgs[2],'UserID' => $aryArgs[3],'ReceiverID' => $aryArgs[4],'ServiceID' => $aryArgs[5],'CommandCode' => $aryArgs[6], 'Info' => $aryArgs[7], 'ReceiveTime' => $aryArgs[8]);
    38 
    39                         error_log(date('Y-m-d H:i:s').' -- VARIABLES: '. var_export($aryExport, TRUE). "\n", 3, '/srv/www/sbg/log/sms.log');
    40                         list($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info, $receiveTime) = $aryArgs;
     24        function __destruct() {
     25                ini_set ( "soap.wsdl_cache_enabled", "0" );
     26        }
     27       
     28        public function index() {
     29                if ($this->uri->segment ( 4 ) == "wsdl") {
     30                        header ( 'Content-Type: text/xml; charset: utf-8' );
     31                        $this->load->view ( 'mowsdl' );
     32                } else {
     33                        header ( 'Content-Type: text/html; charset: utf-8' );
     34                        echo 'See service <a href="' . base_url () . 'violetservice/soanbai/mo/wsdl">WSDL page</a>';
     35                }
     36        }
     37       
     38        public function mo() {
     39                function messageReceiver() {
     40                        $aryArgs = func_get_args ();
     41                        $aryExport = array (
     42                                        'Username' => $aryArgs [0],
     43                                        'Password' => $aryArgs [1],
     44                                        'RequestID' => $aryArgs [2],
     45                                        'UserID' => $aryArgs [3],
     46                                        'ReceiverID' => $aryArgs [4],
     47                                        'ServiceID' => $aryArgs [5],
     48                                        'CommandCode' => $aryArgs [6],
     49                                        'Info' => $aryArgs [7],
     50                                        'ReceiveTime' => $aryArgs [8]
     51                        );
    4152                       
    42                         $msgType = '0'; //text message
    43                         $errCode = '1'; //#1:error; 1:Success;
     53                        error_log ( date ( 'Y-m-d H:i:s' ) . ' -- VARIABLES: ' . var_export ( $aryExport, TRUE ) . "\n", 3, '/srv/www/sbg/log/sms.log' );
     54                        list ( $username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info, $receiveTime ) = $aryArgs;
    4455                       
    45                         $CI =& get_instance();                 
    46                         $mo_username = $CI->config->item('mo_username');
    47                         $mo_password = $CI->config->item('mo_password');
    48 
    49                         if (!$username) return '0|0|Username is required!';
    50                         if (!$password) return '0|0|Password is required!';
    51                         if ($username != $mo_username) return '0|0|Username is not corrected!';
    52                         if ($password != $mo_password) return '0|0|Password is not corrected!';
    53                         if (!$requestID) return '0|0|requestID is required!';                   
    54                         if (!$userID) return '0|0|UserID is required!';
    55                         if (!$serviceID) return '0|0|serviceID is required!';
    56                         if ($serviceID != '8062') return '0|0|serviceID is not corrected!';
    57 
    58                         $CI->load->model('Services_model');
    59                         $CI->load->model('frontend/User_model', 'objUserModel');
    60                         $result = $CI->Services_model->processMORequest($userID, $info);
    61                         error_log(date('Y-m-d H:i:s').' -- INFO VAR: '. var_export($info, TRUE). "\n\n", 3, '/srv/www/sbg/log/sms.log');
    62                         $CI->objUserModel->insertSmslog($receiverID, $serviceID, $commandCode, $info, $receiveTime);
     56                        $msgType = '0'; // text message
     57                        $errCode = '1'; // #1:error; 1:Success;
    6358                       
    64                         $aryResult = explode ('|', $result);
    65                         return $aryResult[0].'|'.$msgType.'|'.$aryResult[1];
     59                        $CI = & get_instance ();
     60                        $mo_username = $CI->config->item ( 'mo_username' );
     61                        $mo_password = $CI->config->item ( 'mo_password' );
     62                       
     63                        if (! $username)
     64                                return '0|0|Username is required!';
     65                        if (! $password)
     66                                return '0|0|Password is required!';
     67                        if ($username != $mo_username)
     68                                return '0|0|Username is not corrected!';
     69                        if ($password != $mo_password)
     70                                return '0|0|Password is not corrected!';
     71                        if (! $requestID)
     72                                return '0|0|requestID is required!';
     73                        if (! $userID)
     74                                return '0|0|UserID is required!';
     75                        if (! $serviceID)
     76                                return '0|0|serviceID is required!';
     77                        if ($serviceID != '8062')
     78                                return '0|0|serviceID is not corrected!';
     79                       
     80                        $CI->load->model ( 'Services_model' );
     81                        $CI->load->model ( 'frontend/User_model', 'objUserModel' );
     82                        $result = $CI->Services_model->processMORequest ( $userID, $info );
     83                        error_log ( date ( 'Y-m-d H:i:s' ) . ' -- INFO VAR: ' . var_export ( $info, TRUE ) . "\n\n", 3, '/srv/www/sbg/log/sms.log' );
     84                        $CI->objUserModel->insertSmslog ( $receiverID, $serviceID, $commandCode, $info, $receiveTime );
     85                       
     86                        $aryResult = explode ( '|', $result );
     87                        return $aryResult [0] . '|' . $msgType . '|' . $aryResult [1];
    6688                }
    6789               
    68                 $this->_server->addFunction('messageReceiver');
     90                $this->_server->addFunction ( 'messageReceiver' );
    6991               
    7092                try {
    71                         ob_start();
     93                        ob_start ();
    7294                        $soapOutput = '';
    73                         $this->_server->handle();
    74                                
    75                         if (ob_get_length() > 0) {
    76                                 $soapOutput = ob_get_clean();
     95                        $this->_server->handle ();
     96                       
     97                        if (ob_get_length () > 0) {
     98                                $soapOutput = ob_get_clean ();
    7799                        }
    78                                
     100                       
    79101                        if ($soapOutput != '') {
    80102                                $pattern = '/<[^>]*[^\/]>/i';
    81                                 $aryOutput = preg_split ($pattern, $soapOutput, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
    82                                 $aryData = array();
    83                                 $aryData['message'] = $aryOutput[1];
    84                                 $xml = $this->load->view('mo', $aryData, TRUE);
    85                                 header('Content-Type: text/xml; charset: utf-8');
     103                                $aryOutput = preg_split ( $pattern, $soapOutput, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
     104                                $aryData = array ();
     105                                $aryData ['message'] = $aryOutput [1];
     106                                $xml = $this->load->view ( 'mo', $aryData, TRUE );
     107                                header ( 'Content-Type: text/xml; charset: utf-8' );
    86108                                echo $xml;
     109                        } else {
     110                                header ( 'Content-Type: text/html; charset: utf-8' );
     111                                echo 'See service <a href="' . base_url () . 'violetservice/soanbai/mo/wsdl">WSDL page</a>';
    87112                        }
    88                         else {
    89                                 header('Content-Type: text/html; charset: utf-8');
    90                                 echo 'See service <a href="'.base_url().'violetservice/soanbai/mo/wsdl">WSDL page</a>';
    91                         }
    92                 }
    93                 catch (Exception $e) {
    94                         $this->_server->fault('Sender', $e->getMessage());
     113                } catch ( Exception $e ) {
     114                        $this->_server->fault ( 'Sender', $e->getMessage () );
    95115                }
    96116        }
Note: See TracChangeset for help on using the changeset viewer.