| @@ -29,23 +29,23 @@ | ||
| 29 | 29 | parent::__construct(); | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | -	function index(){ | |
| 32 | +	function index() { | |
| 33 | 33 | $data['account_info'] = $this->session->userdata['accountinfo']; | 
| 34 | 34 |  		$data['username'] = $this->session->userdata('user_name'); | 
| 35 | 35 | $data['page_title'] = "Test Mail"; | 
| 36 | -		$this->load->view('view_newmail',$data); | |
| 36 | +		$this->load->view('view_newmail', $data); | |
| 37 | 37 | } | 
| 38 | -	function customer_mail_result($flag=FALSE){ | |
| 38 | +	function customer_mail_result($flag = FALSE) { | |
| 39 | 39 | $account_info = $this->session->userdata['accountinfo']; | 
| 40 | 40 | $post_array = $this->input->post(); | 
| 41 | - $post_array['accountid']=$account_info['id']; | |
| 42 | - $post_array['history_id']=0; | |
| 43 | - $post_array['email']=$post_array['to']; | |
| 41 | + $post_array['accountid'] = $account_info['id']; | |
| 42 | + $post_array['history_id'] = 0; | |
| 43 | + $post_array['email'] = $post_array['to']; | |
| 44 | 44 | unset($post_array['to']); | 
| 45 | - $this->email_lib->send_email($post_array,$post_array,'','',0,0); | |
| 45 | + $this->email_lib->send_email($post_array, $post_array, '', '', 0, 0); | |
| 46 | 46 | $this->thanks(); | 
| 47 | 47 | } | 
| 48 | -	function thanks(){ | |
| 48 | +	function thanks() { | |
| 49 | 49 |              $this->load->view('view_mail_response'); | 
| 50 | 50 | } | 
| 51 | 51 | |
| @@ -21,19 +21,19 @@ | ||
| 21 | 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 
| 22 | 22 | ############################################################################### | 
| 23 | 23 | |
| 24 | -if (!defined('BASEPATH')) | |
| 24 | +if ( ! defined('BASEPATH')) | |
| 25 | 25 |      exit('No direct script access allowed'); | 
| 26 | 26 | |
| 27 | 27 | /** | 
| 28 | 28 | * Dynamically build forms for display | 
| 29 | 29 | */ | 
| 30 | -class Global_locale{ | |
| 30 | +class Global_locale { | |
| 31 | 31 | |
| 32 | 32 |      function __construct($library_name = '') { | 
| 33 | 33 | |
| 34 | 34 | $this->CI = & get_instance(); | 
| 35 | 35 |  	header("Expires: Tue, 01 Jan 2000 00:00:00 GMT"); | 
| 36 | -	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | |
| 36 | +	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); | |
| 37 | 37 |  	header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); | 
| 38 | 38 |  	header("Cache-Control: post-check=0, pre-check=0", false); | 
| 39 | 39 |  	header("Pragma: no-cache"); | 
| @@ -21,13 +21,13 @@ discard block | ||
| 21 | 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 
| 22 | 22 | ############################################################################### | 
| 23 | 23 | |
| 24 | -if (!defined('BASEPATH')) | |
| 24 | +if ( ! defined('BASEPATH')) | |
| 25 | 25 |      exit('No direct script access allowed'); | 
| 26 | 26 | |
| 27 | 27 | /** | 
| 28 | 28 | * Dynamically build forms for display | 
| 29 | 29 | */ | 
| 30 | -class locale_Menu{ | |
| 30 | +class locale_Menu { | |
| 31 | 31 | |
| 32 | 32 |      function __construct($library_name = '') { | 
| 33 | 33 | |
| @@ -35,7 +35,7 @@ discard block | ||
| 35 | 35 |          $this->CI->load->model('db_model'); | 
| 36 | 36 |          $this->CI->load->library('email'); | 
| 37 | 37 |          $this->CI->load->library('session'); | 
| 38 | -	$current_locale=$this->CI->session->userdata('user_language'); | |
| 38 | +	$current_locale = $this->CI->session->userdata('user_language'); | |
| 39 | 39 |  	putenv("LC_ALL=$current_locale"); | 
| 40 | 40 | setlocale(LC_ALL, $current_locale); | 
| 41 | 41 | bindtextdomain(WEBSITE_DOMAIN, FCPATH.'/application/modules/dashboard/language'); | 
| @@ -22,16 +22,16 @@ discard block | ||
| 22 | 22 | ############################################################################### | 
| 23 | 23 | |
| 24 | 24 |  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
 | 
| 25 | -class freeswitch_lib{
 | |
| 25 | +class freeswitch_lib {
 | |
| 26 | 26 | |
| 27 | -	function event_socket_create($host='127.0.0.1', $port='8021', $password='ClueCon') {
 | |
| 27 | +	function event_socket_create($host = '127.0.0.1', $port = '8021', $password = 'ClueCon') {
 | |
| 28 | 28 | $fp = @fsockopen($host, $port, $errno, $errdesc); | 
| 29 | 29 |  // 	    or die("Connection to $host failed");
 | 
| 30 | 30 | // socket_set_blocking($fp,false); | 
| 31 | 31 | |
| 32 | 32 |  	    if ($fp) {
 | 
| 33 | - socket_set_blocking($fp,false); | |
| 34 | -		while (!feof($fp)) {
 | |
| 33 | + socket_set_blocking($fp, false); | |
| 34 | +		while ( ! feof($fp)) {
 | |
| 35 | 35 | $buffer = fgets($fp, 1024); | 
| 36 | 36 | usleep(100); //allow time for reponse | 
| 37 | 37 |  		    if (trim($buffer) == "Content-Type: auth/request") {
 | 
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | $response = ""; | 
| 55 | 55 | $i = 0; | 
| 56 | 56 | $contentlength = 0; | 
| 57 | -		while (!feof($fp)) {
 | |
| 57 | +		while ( ! feof($fp)) {
 | |
| 58 | 58 | $buffer = fgets($fp, 4096); | 
| 59 | 59 |  		    if ($contentlength > 0) {
 | 
| 60 | 60 | $response .= $buffer; | 
| @@ -7,15 +7,15 @@ | ||
| 7 | 7 | */ | 
| 8 | 8 | |
| 9 | 9 |  $astpp_config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); | 
| 10 | -$config['SERVER_NAME'] = $astpp_config['base_url']; // Your web site url | |
| 11 | -$config['CRON_TIME_LIMIT'] = 0; // 0 = no time limit | |
| 12 | -$config['argv']			= array("LowBalance"=>"lowbalance/low_balance", | |
| 10 | +$config['SERVER_NAME'] = $astpp_config['base_url']; // Your web site url | |
| 11 | +$config['CRON_TIME_LIMIT'] = 0; // 0 = no time limit | |
| 12 | +$config['argv'] = array("LowBalance"=>"lowbalance/low_balance", | |
| 13 | 13 | "Lowcredit"=>"lowcreditlimit/low_creditlimit", | 
| 14 | 14 | "UpdateBalance" => "updateBalance/GetUpdateBalance", | 
| 15 | 15 | "CurrencyUpdate" => "currencyupdate/update_currency", | 
| 16 | 16 | "GenerateInvoice" => "generateInvoice/getInvoiceData", | 
| 17 | 17 | "FeedBack"=>"feedback/customer_feedback_result/TRUE", | 
| 18 | 18 | "BroadcastEmail" => "broadcastemail/broadcast_email"); | 
| 19 | -$config['CRON_BETA_MODE'] = false; // Beta Mode (useful for blocking submissions for testing) | |
| 19 | +$config['CRON_BETA_MODE'] = false; // Beta Mode (useful for blocking submissions for testing) | |
| 20 | 20 | |
| 21 | 21 | ?> | 
| @@ -16,7 +16,7 @@ | ||
| 16 | 16 | <div class="col-md-12"> | 
| 17 | 17 | <div class="w-box"> | 
| 18 | 18 | <span style="margin-left:10px; text-align: center;background-color: none;color:#1c8400;"> | 
| 19 | -                    <? if(isset($error) && !empty($error)) { | |
| 19 | +                    <? if (isset($error) && ! empty($error)) { | |
| 20 | 20 | echo $error; | 
| 21 | 21 | }?> | 
| 22 | 22 | </span> | 
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | if ($xml == "") | 
| 32 | 32 | xml_not_found(); | 
| 33 | 33 | echo $xml; | 
| 34 | -}else { | |
| 34 | +} else { | |
| 35 | 35 | xml_not_found(); | 
| 36 | 36 | } | 
| 37 | 37 |  $logger->log("*************************** Directory Ends **********************************"); | 
| @@ -256,6 +256,7 @@ | ||
| 256 | 256 | //Insert callee cdr entry for DID calls | 
| 257 | 257 | /** | 
| 258 | 258 | * @param boolean $flag_parent | 
| 259 | + * @param string $provider_cost | |
| 259 | 260 | */ | 
| 260 | 261 | function insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points) | 
| 261 | 262 |  { | 
| @@ -46,15 +46,15 @@ discard block | ||
| 46 | 46 | |
| 47 | 47 | if ($dataVariable['billsec'] == 0 && $dataVariable['hangup_cause'] == 'NORMAL_CLEARING') | 
| 48 | 48 |  	{ | 
| 49 | - $hangup_cause = isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause']; | |
| 50 | -	}else{ | |
| 49 | + $hangup_cause = isset($dataVariable['last_bridge_hangup_cause']) ? $dataVariable['last_bridge_hangup_cause'] : $dataVariable['hangup_cause']; | |
| 50 | +	} else { | |
| 51 | 51 | $hangup_cause = $dataVariable['hangup_cause']; | 
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 | if ($dataVariable['error_cdr'] == '1') | 
| 55 | 55 |  	{ | 
| 56 | 56 | //Get actual hangup cause | 
| 57 | - $hangup_cause= (isset($dataVariable['error_cdr'])) ? $dataVariable['last_bridge_hangup_cause'] : (isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause']); | |
| 57 | + $hangup_cause = (isset($dataVariable['error_cdr'])) ? $dataVariable['last_bridge_hangup_cause'] : (isset($dataVariable['last_bridge_hangup_cause']) ? $dataVariable['last_bridge_hangup_cause'] : $dataVariable['hangup_cause']); | |
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | /*#### PATCH FOR ONE WAY AUDIO ####*/ | 
| @@ -65,14 +65,14 @@ discard block | ||
| 65 | 65 | /*#### ************* END *************####*/ | 
| 66 | 66 | |
| 67 | 67 | //Don't thing this will be useful anytime. Need to remove it after testing. | 
| 68 | - if($hangup_cause == "NONE") | |
| 68 | + if ($hangup_cause == "NONE") | |
| 69 | 69 |  	{ | 
| 70 | 70 | $hangup_cause = $dataVariable['current_application_data']; | 
| 71 | 71 | } | 
| 72 | 72 | |
| 73 | 73 | $dataVariable['hangup_cause'] = $hangup_cause; | 
| 74 | 74 | |
| 75 | -	if ( ($dataVariable['hangup_cause'] != 'NORMAL_CLEARING') && ($dataVariable['hangup_cause'] != 'ALLOTTED_TIMEOUT')) { | |
| 75 | +	if (($dataVariable['hangup_cause'] != 'NORMAL_CLEARING') && ($dataVariable['hangup_cause'] != 'ALLOTTED_TIMEOUT')) { | |
| 76 | 76 | $dataVariable['billsec'] = 0; | 
| 77 | 77 | } | 
| 78 | 78 | |
| @@ -86,13 +86,13 @@ discard block | ||
| 86 | 86 | $actual_calltype = $dataVariable['calltype']; | 
| 87 | 87 | |
| 88 | 88 | //Normalize origination and termination rates array | 
| 89 | - if(isset($dataVariable['origination_rates'])) | |
| 89 | + if (isset($dataVariable['origination_rates'])) | |
| 90 | 90 | $origination_rate = normalize_origination_rate($dataVariable['origination_rates']); | 
| 91 | - if(isset($dataVariable['termination_rates'])) | |
| 91 | + if (isset($dataVariable['termination_rates'])) | |
| 92 | 92 | $termination_rate = normalize_rate($dataVariable['termination_rates']); | 
| 93 | 93 | |
| 94 | 94 | //If receiver account id found then explicitly set call direction and call type | 
| 95 | - if(isset($dataVariable['receiver_accid'])) | |
| 95 | + if (isset($dataVariable['receiver_accid'])) | |
| 96 | 96 |  	{ | 
| 97 | 97 | $dataVariable['call_direction'] = "outbound"; | 
| 98 | 98 | $dataVariable['calltype'] = "STANDARD"; | 
| @@ -101,23 +101,23 @@ discard block | ||
| 101 | 101 | //Check if cusotmer have any package seconds left to use | 
| 102 | 102 | if ($actual_duration > 0) | 
| 103 | 103 |  	{ | 
| 104 | - $package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger); | |
| 105 | - if(!empty($package_array)) | |
| 104 | + $package_array = package_calculation($dataVariable['effective_destination_number'], $origination_rate[$accountid]['RATEGROUP'], $actual_duration, $dataVariable['call_direction'], $accountid, $db, $logger); | |
| 105 | + if ( ! empty($package_array)) | |
| 106 | 106 |  			{ | 
| 107 | 107 | $dataVariable['calltype'] = "FREE"; | 
| 108 | - $dataVariable['package_id']= $package_array['package_id']; | |
| 108 | + $dataVariable['package_id'] = $package_array['package_id']; | |
| 109 | 109 | } | 
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | 112 | //Calculate debit of customer call | 
| 113 | - $debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points); | |
| 113 | + $debit = calc_cost($dataVariable, $origination_rate[$accountid], $logger, $decimal_points); | |
| 114 | 114 | |
| 115 | 115 | //Calculate cost for customer call for provider | 
| 116 | - $provider_cost = calc_cost($dataVariable,$termination_rate,$logger,$decimal_points); | |
| 116 | + $provider_cost = calc_cost($dataVariable, $termination_rate, $logger, $decimal_points); | |
| 117 | 117 | |
| 118 | 118 | //Calculate parent cost if customer have any parent | 
| 119 | - $parent_cost = ($parentid > 0) ? calc_cost($dataVariable,$origination_rate[$parentid],$logger,$decimal_points) : $provider_cost; | |
| 120 | -	$logger->log("Debit :".$debit ." Cost : ".$cost ." Provider Cost : ".$parent_cost); | |
| 119 | + $parent_cost = ($parentid > 0) ? calc_cost($dataVariable, $origination_rate[$parentid], $logger, $decimal_points) : $provider_cost; | |
| 120 | +	$logger->log("Debit :".$debit." Cost : ".$cost." Provider Cost : ".$parent_cost); | |
| 121 | 121 | |
| 122 | 122 | //Initialize final cost variable to use for billing | 
| 123 | 123 | $cost = ($parent_cost > 0) ? $parent_cost : $provider_cost; | 
| @@ -125,33 +125,33 @@ discard block | ||
| 125 | 125 | //Outbound call entry for all type of calls | 
| 126 | 126 |  	$logger->log("*********************** OUTBOUND CALL ENTRY START *************"); | 
| 127 | 127 | |
| 128 | - $cdr_string = get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger); | |
| 128 | + $cdr_string = get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger); | |
| 129 | 129 | |
| 130 | 130 | $query = "INSERT INTO cdrs (uniqueid,accountid,type,callerid,callednum,billseconds,trunk_id,trunkip,callerip,disposition,callstart,debit,cost,provider_id,pricelist_id,package_id,pattern,notes,rate_cost,reseller_id,reseller_code,reseller_code_destination,reseller_cost,provider_code,provider_code_destination,provider_cost,provider_call_cost,call_direction,calltype,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($cdr_string)"; | 
| 131 | 131 | $logger->log($query); | 
| 132 | 132 | $db->run($query); | 
| 133 | 133 | |
| 134 | 134 | //Update customer balance | 
| 135 | - if($debit > 0 && $dataVariable['calltype'] != "FREE") | |
| 135 | + if ($debit > 0 && $dataVariable['calltype'] != "FREE") | |
| 136 | 136 |  	{ | 
| 137 | 137 | update_balance($accountid, $debit, 0, $logger, $db); | 
| 138 | 138 | } | 
| 139 | 139 | |
| 140 | 140 | //Update parent or provider balance | 
| 141 | -	if($parent_cost > 0){ | |
| 141 | +	if ($parent_cost > 0) { | |
| 142 | 142 | update_balance($termination_rate['PROVIDER'], ($parent_cost * -1), 3, $logger, $db); | 
| 143 | 143 | } | 
| 144 | 144 | |
| 145 | 145 | //Resellers CDR entry | 
| 146 | 146 | $flag_parent = false; | 
| 147 | - insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points); | |
| 147 | + insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points); | |
| 148 | 148 | |
| 149 | 149 |  	$logger->log("*********************** OUTBOUND CALL ENTRY END *************"); | 
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | //************ ADDING EXTRA ENTRY For local/DID Inbound call **************************** | 
| 153 | - $receiver_parentid=0; | |
| 154 | - if(isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "") | |
| 153 | + $receiver_parentid = 0; | |
| 154 | + if (isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "") | |
| 155 | 155 |  	{ | 
| 156 | 156 |  		$logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING START *************");             | 
| 157 | 157 | |
| @@ -160,7 +160,7 @@ discard block | ||
| 160 | 160 | $dataVariable['calltype'] = "DID"; | 
| 161 | 161 | |
| 162 | 162 | //Override variables if call for DID PSTN | 
| 163 | - if(isset($dataVariable['caller_did_account_id'])) | |
| 163 | + if (isset($dataVariable['caller_did_account_id'])) | |
| 164 | 164 |  		{ | 
| 165 | 165 | $dataVariable['receiver_accid'] = $dataVariable['caller_did_account_id']; | 
| 166 | 166 | $dataVariable['call_direction'] = "outbound"; | 
| @@ -171,17 +171,17 @@ discard block | ||
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | //Get call receiver account information | 
| 174 | - $receiver_carddata = get_accounts($dataVariable['receiver_accid'],$logger,$db); | |
| 174 | + $receiver_carddata = get_accounts($dataVariable['receiver_accid'], $logger, $db); | |
| 175 | 175 | $receiver_parentid = $receiver_carddata['reseller_id']; | 
| 176 | 176 | |
| 177 | 177 | //For additional cdr entry of receiver | 
| 178 | - insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$receiver_parentid,$flag_parent,$dataVariable['receiver_accid'],$logger,$db,$decimal_points); | |
| 178 | + insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $receiver_parentid, $flag_parent, $dataVariable['receiver_accid'], $logger, $db, $decimal_points); | |
| 179 | 179 | |
| 180 | 180 | $flag_parent = true; | 
| 181 | 181 | $dataVariable['uuid'] = $dataVariable['uuid'].$dataVariable['calltype']."_".$receiver_parentid; | 
| 182 | 182 | |
| 183 | 183 | //Insert parent reseller cdr | 
| 184 | - insert_parent_data($dataVariable,$actual_calltype,$receiver_parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points); | |
| 184 | + insert_parent_data($dataVariable, $actual_calltype, $receiver_parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points); | |
| 185 | 185 |  		$logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING END *************");             | 
| 186 | 186 | } | 
| 187 | 187 | //***************************************************************************************** | 
| @@ -193,16 +193,16 @@ discard block | ||
| 193 | 193 | * @param string $provider_cost | 
| 194 | 194 | * @param boolean $flag_parent | 
| 195 | 195 | */ | 
| 196 | -function insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points) | |
| 196 | +function insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points) | |
| 197 | 197 |  { | 
| 198 | - while($parentid > 0 ) | |
| 198 | + while ($parentid > 0) | |
| 199 | 199 |  	{ | 
| 200 | 200 |  		$logger->log("*************** IN PARENT DATA SECTION ********"); | 
| 201 | 201 | $dataVariable['calltype'] = $actual_calltype; | 
| 202 | - $carddata = get_accounts($parentid,$logger,$db); | |
| 202 | + $carddata = get_accounts($parentid, $logger, $db); | |
| 203 | 203 | $accountid = $carddata['id']; | 
| 204 | 204 | |
| 205 | - $debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points); | |
| 205 | + $debit = calc_cost($dataVariable, $origination_rate[$accountid], $logger, $decimal_points); | |
| 206 | 206 | |
| 207 | 207 | //If receiver account id found then explicitly set call direction and call type | 
| 208 | 208 | /*if(isset($dataVariable['receiver_accid'])) | 
| @@ -212,31 +212,31 @@ discard block | ||
| 212 | 212 | }*/ | 
| 213 | 213 | |
| 214 | 214 | //Check if reseller have any package seconds left to use | 
| 215 | -		if ($actual_duration > 0)		{ | |
| 216 | - $package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger); | |
| 217 | - if(!empty($package_array)) | |
| 215 | +		if ($actual_duration > 0) { | |
| 216 | + $package_array = package_calculation($dataVariable['effective_destination_number'], $origination_rate[$accountid]['RATEGROUP'], $actual_duration, $dataVariable['call_direction'], $accountid, $db, $logger); | |
| 217 | + if ( ! empty($package_array)) | |
| 218 | 218 |  			{ | 
| 219 | 219 | $dataVariable['calltype'] = "FREE"; | 
| 220 | - $dataVariable['package_id']= $package_array['package_id']; | |
| 220 | + $dataVariable['package_id'] = $package_array['package_id']; | |
| 221 | 221 | } | 
| 222 | 222 | } | 
| 223 | 223 | |
| 224 | 224 | //Get parent id for cost calculation | 
| 225 | 225 | $parentid = $carddata['reseller_id']; | 
| 226 | - $parent_cost = ($parentid > 0) ? calc_cost($dataVariable,$origination_rate[$parentid],$logger,$decimal_points) : $provider_cost; | |
| 226 | + $parent_cost = ($parentid > 0) ? calc_cost($dataVariable, $origination_rate[$parentid], $logger, $decimal_points) : $provider_cost; | |
| 227 | 227 | $cost = ($parent_cost > 0) ? $parent_cost : $provider_cost; | 
| 228 | 228 | |
| 229 | - if(isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "" && $flag_parent == true) | |
| 229 | + if (isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "" && $flag_parent == true) | |
| 230 | 230 |  		{ | 
| 231 | 231 |  			$logger->log("********* IN RESELLER FOR RECEIVER ENTRY START ******"); | 
| 232 | 232 | $flag_parent = true; | 
| 233 | - insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points); | |
| 233 | + insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points); | |
| 234 | 234 |  			$logger->log("********* IN RESELLER FOR RECEIVER ENTRY END ******"); | 
| 235 | 235 | return true; | 
| 236 | 236 | |
| 237 | -		} else{ | |
| 237 | +		} else { | |
| 238 | 238 | |
| 239 | - $cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost); | |
| 239 | + $cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost); | |
| 240 | 240 | |
| 241 | 241 | $query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost, | 
| 242 | 242 | reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)"; | 
| @@ -257,38 +257,38 @@ discard block | ||
| 257 | 257 | /** | 
| 258 | 258 | * @param boolean $flag_parent | 
| 259 | 259 | */ | 
| 260 | -function insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points) | |
| 260 | +function insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points) | |
| 261 | 261 |  { | 
| 262 | 262 | $localVariable = $dataVariable; | 
| 263 | 263 | $localVariable['call_direction'] = "inbound"; | 
| 264 | 264 | $localVariable['uuid'] = $localVariable['uuid'].$dataVariable['calltype']."_".$accountid; | 
| 265 | 265 | |
| 266 | - if($dataVariable['calltype'] == "LOCAL") | |
| 266 | + if ($dataVariable['calltype'] == "LOCAL") | |
| 267 | 267 |  		{ | 
| 268 | 268 | $origination_rate[$accountid]['CODE'] = $dataVariable['effective_destination_number']; | 
| 269 | 269 | $origination_rate[$accountid]['DESTINATION'] = $dataVariable['calltype']; | 
| 270 | -			if($flag_parent == false){ | |
| 271 | - $cdr_string = get_cdr_string($localVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,0,0,$logger); | |
| 272 | -			} else{ | |
| 273 | - $cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost); | |
| 270 | +			if ($flag_parent == false) { | |
| 271 | + $cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, 0, 0, $logger); | |
| 272 | +			} else { | |
| 273 | + $cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost); | |
| 274 | 274 | } | 
| 275 | -		} else{ | |
| 275 | +		} else { | |
| 276 | 276 | |
| 277 | 277 | $origination_rate_did = normalize_origination_rate($dataVariable['origination_rates_did']); | 
| 278 | - $debit = calc_cost($dataVariable,$origination_rate_did[$accountid],$logger,$decimal_points); | |
| 278 | + $debit = calc_cost($dataVariable, $origination_rate_did[$accountid], $logger, $decimal_points); | |
| 279 | 279 | |
| 280 | -			if($flag_parent == false){ | |
| 280 | +			if ($flag_parent == false) { | |
| 281 | 281 | |
| 282 | - $cdr_string = get_cdr_string($localVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate_did,$provider_cost,$parentid,$debit,0,$logger); | |
| 283 | -			} else{ | |
| 284 | - $cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost); | |
| 282 | + $cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate_did, $provider_cost, $parentid, $debit, 0, $logger); | |
| 283 | +			} else { | |
| 284 | + $cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost); | |
| 285 | 285 | } | 
| 286 | 286 | } | 
| 287 | 287 | |
| 288 | - if($flag_parent == false) | |
| 288 | + if ($flag_parent == false) | |
| 289 | 289 |  		{ | 
| 290 | 290 | $query = "INSERT INTO cdrs(uniqueid,accountid,type,callerid,callednum,billseconds,trunk_id,trunkip,callerip,disposition,callstart,debit,cost,provider_id,pricelist_id,package_id,pattern,notes,rate_cost,reseller_id,reseller_code,reseller_code_destination,reseller_cost,provider_code,provider_code_destination,provider_cost,provider_call_cost,call_direction,calltype,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($cdr_string)"; | 
| 291 | -		} else{ | |
| 291 | +		} else { | |
| 292 | 292 | $query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost, | 
| 293 | 293 | reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)"; | 
| 294 | 294 | } | 
| @@ -304,22 +304,22 @@ discard block | ||
| 304 | 304 | } | 
| 305 | 305 | |
| 306 | 306 | //Generate CDR string for insert query for customer. | 
| 307 | -function get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger) | |
| 307 | +function get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger) | |
| 308 | 308 |  { | 
| 309 | 309 | |
| 310 | - $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; | |
| 310 | + $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER') ? "DID" : $dataVariable['calltype']; | |
| 311 | 311 | |
| 312 | - return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".$account_type."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."',".(($termination_rate['TRUNK']) ? $termination_rate['TRUNK'] : '0').",".(($dataVariable['sip_via_host']) ? "'".$dataVariable['sip_via_host']."'" : '').",".(($dataVariable['sip_contact_host']) ? "'".$dataVariable['sip_contact_host']."'" : '').",'".($dataVariable['hangup_cause'])."','".urldecode($dataVariable['callstart'])."','".$debit."','".$cost."',".(($termination_rate['PROVIDER']) ? $termination_rate['PROVIDER'] : '0').",'".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".htmlentities($origination_rate[$accountid]['DESTINATION'],ENT_COMPAT, 'UTF-8')."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").", | |
| 313 | -'".$parentid."',".(($origination_rate[$parentid]['CODE'] ) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($termination_rate['CODE']) ? "'".$termination_rate['CODE']."'" : "'".''."'" ).", | |
| 312 | + return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".$account_type."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."',".(($termination_rate['TRUNK']) ? $termination_rate['TRUNK'] : '0').",".(($dataVariable['sip_via_host']) ? "'".$dataVariable['sip_via_host']."'" : '').",".(($dataVariable['sip_contact_host']) ? "'".$dataVariable['sip_contact_host']."'" : '').",'".($dataVariable['hangup_cause'])."','".urldecode($dataVariable['callstart'])."','".$debit."','".$cost."',".(($termination_rate['PROVIDER']) ? $termination_rate['PROVIDER'] : '0').",'".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".htmlentities($origination_rate[$accountid]['DESTINATION'], ENT_COMPAT, 'UTF-8')."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").", | |
| 313 | +'".$parentid."',".(($origination_rate[$parentid]['CODE']) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($termination_rate['CODE']) ? "'".$termination_rate['CODE']."'" : "'".''."'").", | |
| 314 | 314 | ".(($termination_rate['DESTINATION']) ? "'".$termination_rate['DESTINATION']."'" : "'".''."'").",".(($termination_rate['COST']) ? "'".$termination_rate['COST']."'" : '0').",'".$provider_cost."',".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."','".convert_to_gmt(urldecode($dataVariable['profile_start_stamp']))."','".convert_to_gmt(urldecode($dataVariable['answer_stamp']))."','".convert_to_gmt(urldecode($dataVariable['bridge_stamp']))."','".convert_to_gmt(urldecode(@$dataVariable['progress_stamp']))."','".convert_to_gmt(urldecode(@$dataVariable['progress_media_stamp']))."','".convert_to_gmt(urldecode($dataVariable['end_stamp']))."',".$dataVariable['billmsec'].",'".$dataVariable['answermsec']."','".$dataVariable['waitmsec']."','".$dataVariable['progress_mediamsec']."','".$dataVariable['flow_billmsec']."'"; | 
| 315 | 315 | |
| 316 | 316 | } | 
| 317 | 317 | |
| 318 | 318 | //Generate CDR string for insert query for reseller | 
| 319 | -function get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost) | |
| 319 | +function get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost) | |
| 320 | 320 |  { | 
| 321 | - $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; | |
| 322 | - return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."','".($dataVariable['hangup_cause'])."','".convert_to_gmt(urldecode($dataVariable['callstart']))."','".$debit."','".$cost."','".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".$origination_rate[$accountid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",'".$parentid."',".(($origination_rate[$parentid]['CODE'] ) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."'"; | |
| 321 | + $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER') ? "DID" : $dataVariable['calltype']; | |
| 322 | + return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."','".($dataVariable['hangup_cause'])."','".convert_to_gmt(urldecode($dataVariable['callstart']))."','".$debit."','".$cost."','".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".$origination_rate[$accountid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",'".$parentid."',".(($origination_rate[$parentid]['CODE']) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."'"; | |
| 323 | 323 | } | 
| 324 | 324 | |
| 325 | 325 | //Update user balance | 
| @@ -328,8 +328,8 @@ discard block | ||
| 328 | 328 | */ | 
| 329 | 329 |  function update_balance($user_id, $amount, $entity_id, $logger, $db) { | 
| 330 | 330 | $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; | 
| 331 | - $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id; | |
| 332 | -    $logger->log("Balance update : " . $query); | |
| 331 | + $query = "UPDATE accounts SET balance=balance-".$amount." WHERE id=".$user_id; | |
| 332 | +    $logger->log("Balance update : ".$query); | |
| 333 | 333 | $db->run($query); | 
| 334 | 334 | } | 
| 335 | 335 | |
| @@ -388,46 +388,46 @@ discard block | ||
| 388 | 388 | |
| 389 | 389 | if ($billseconds > 0) | 
| 390 | 390 |  			{ | 
| 391 | - $call_cost += (ceil($billseconds/$rates['INC'])*$rates['INC'])*($rates['COST']/60); | |
| 391 | + $call_cost += (ceil($billseconds / $rates['INC']) * $rates['INC']) * ($rates['COST'] / 60); | |
| 392 | 392 | } | 
| 393 | 393 | } | 
| 394 | - $call_cost = number_format($call_cost,$decimal_points); | |
| 394 | + $call_cost = number_format($call_cost, $decimal_points); | |
| 395 | 395 |  	$logger->log("Return cost ".$call_cost); | 
| 396 | 396 | return $call_cost; | 
| 397 | 397 | } | 
| 398 | 398 | |
| 399 | 399 | // get intial package information | 
| 400 | -function package_calculation($destination_number,$pricelist_id,$duration,$call_direction,$accountid,$db,$logger) | |
| 400 | +function package_calculation($destination_number, $pricelist_id, $duration, $call_direction, $accountid, $db, $logger) | |
| 401 | 401 |  { | 
| 402 | 402 | $package_array = array(); | 
| 403 | - $custom_destination = number_loop($destination_number,"patterns",$db); | |
| 403 | + $custom_destination = number_loop($destination_number, "patterns", $db); | |
| 404 | 404 | |
| 405 | 405 | $query = "SELECT * FROM packages as P inner join package_patterns as PKGPTR on P.id = PKGPTR.package_id WHERE ".$custom_destination." AND status = 0 AND pricelist_id = ".$pricelist_id." ORDER BY LENGTH(PKGPTR.patterns) DESC LIMIT 1"; | 
| 406 | 406 | |
| 407 | 407 | $package_info = $db->run($query); | 
| 408 | -	if($package_info){ | |
| 408 | +	if ($package_info) { | |
| 409 | 409 | $package_info = $package_info[0]; | 
| 410 | 410 | |
| 411 | -		if( ($package_info['applicable_for'] == "0" && $call_direction == "outbound") || ($package_info['applicable_for'] == "1" && $call_direction == "inbound") || ($package_info['applicable_for'] == "2") ) { | |
| 411 | +		if (($package_info['applicable_for'] == "0" && $call_direction == "outbound") || ($package_info['applicable_for'] == "1" && $call_direction == "inbound") || ($package_info['applicable_for'] == "2")) { | |
| 412 | 412 | |
| 413 | - $counter_info = get_counters($accountid,$package_info['package_id'],$db,$logger); | |
| 413 | + $counter_info = get_counters($accountid, $package_info['package_id'], $db, $logger); | |
| 414 | 414 | |
| 415 | -			if(!$counter_info) { | |
| 415 | +			if ( ! $counter_info) { | |
| 416 | 416 |  				$Insert_Query = "INSERT INTO counters (package_id,accountid) VALUES (".$package_info['package_id'].",".$accountid.")";		 | 
| 417 | -				$logger->log("Insert Counters  : " . $Insert_query); | |
| 417 | +				$logger->log("Insert Counters  : ".$Insert_query); | |
| 418 | 418 | $db->run($Insert_Query); | 
| 419 | - $counter_info = get_counters($accountid,$package_info['package_id'],$db,$logger); | |
| 419 | + $counter_info = get_counters($accountid, $package_info['package_id'], $db, $logger); | |
| 420 | 420 | |
| 421 | 421 | } | 
| 422 | 422 | //print_r($counter_info); | 
| 423 | -			if ( $package_info['includedseconds'] > ($counter_info['seconds'] )) { | |
| 423 | +			if ($package_info['includedseconds'] > ($counter_info['seconds'])) { | |
| 424 | 424 | $availableseconds = $package_info['includedseconds'] - $counter_info['seconds']; | 
| 425 | 425 | $freeseconds = ($availableseconds >= $duration) ? $duration : $availableseconds; | 
| 426 | 426 | $duration = ($availableseconds >= $duration) ? $duration : $availableseconds; | 
| 427 | - $update_query = "UPDATE counters SET seconds = ".($counter_info['seconds'] + $freeseconds ). " WHERE id = ". $counter_info['id']; | |
| 428 | -				$logger->log("Update Counters  : " . $update_query); | |
| 427 | + $update_query = "UPDATE counters SET seconds = ".($counter_info['seconds'] + $freeseconds)." WHERE id = ".$counter_info['id']; | |
| 428 | +				$logger->log("Update Counters  : ".$update_query); | |
| 429 | 429 | $db->run($update_query); | 
| 430 | - $package_array['package_id']= $package_info['package_id']; | |
| 430 | + $package_array['package_id'] = $package_info['package_id']; | |
| 431 | 431 | $package_array['calltype'] = "FREE"; | 
| 432 | 432 | } | 
| 433 | 433 | } | 
| @@ -436,21 +436,21 @@ discard block | ||
| 436 | 436 | } | 
| 437 | 437 | |
| 438 | 438 | // Getting used package minutes in counter table | 
| 439 | -function get_counters($accountid,$package_id,$db,$logger) | |
| 439 | +function get_counters($accountid, $package_id, $db, $logger) | |
| 440 | 440 |  { | 
| 441 | 441 | $query_counter = "SELECT id,seconds FROM counters WHERE accountid = ".$accountid." AND package_id = ".$package_id." AND status=1 LIMIT 1"; | 
| 442 | 442 | $counter = $db->run($query_counter); | 
| 443 | -	$logger->log("GET Counters  : " . $query_counter); | |
| 444 | - if($counter) | |
| 443 | +	$logger->log("GET Counters  : ".$query_counter); | |
| 444 | + if ($counter) | |
| 445 | 445 | return $counter[0]; | 
| 446 | 446 | else | 
| 447 | 447 | return ""; | 
| 448 | 448 | } | 
| 449 | 449 | |
| 450 | 450 | //Get user info | 
| 451 | -function get_accounts($parent_id,$logger, $db) { | |
| 452 | - $query = "SELECT * FROM accounts WHERE id=" . $parent_id; | |
| 453 | -	$logger->log("GET configuration  : " . $query); | |
| 451 | +function get_accounts($parent_id, $logger, $db) { | |
| 452 | + $query = "SELECT * FROM accounts WHERE id=".$parent_id; | |
| 453 | +	$logger->log("GET configuration  : ".$query); | |
| 454 | 454 | $res_user = $db->run($query); | 
| 455 | 455 | return $res_user[0]; | 
| 456 | 456 | } | 
| @@ -460,7 +460,7 @@ discard block | ||
| 460 | 460 |  { | 
| 461 | 461 | $query = "SELECT name,value FROM system WHERE name='decimal_points' and group_title = 'global'"; | 
| 462 | 462 | $config = $db->run($query); | 
| 463 | -	$logger->log("GET configuration  : " . $query); | |
| 463 | +	$logger->log("GET configuration  : ".$query); | |
| 464 | 464 | return $config[0]; | 
| 465 | 465 | } | 
| 466 | 466 | |
| @@ -468,16 +468,16 @@ discard block | ||
| 468 | 468 | /** | 
| 469 | 469 | * @param string $field | 
| 470 | 470 | */ | 
| 471 | -function number_loop($destination,$field,$db) | |
| 471 | +function number_loop($destination, $field, $db) | |
| 472 | 472 |  { | 
| 473 | - $max_len_prefix = strlen($destination); | |
| 473 | + $max_len_prefix = strlen($destination); | |
| 474 | 474 |  	$number_prefix = '('; | 
| 475 | - while ($max_len_prefix > 0) | |
| 475 | + while ($max_len_prefix > 0) | |
| 476 | 476 |  	{ | 
| 477 | - $number_prefix .= "$field='^".substr($destination,0,$max_len_prefix).".*' OR "; | |
| 477 | + $number_prefix .= "$field='^".substr($destination, 0, $max_len_prefix).".*' OR "; | |
| 478 | 478 | $max_len_prefix--; | 
| 479 | 479 | } | 
| 480 | - $number_prefix .= "$field='^defaultprefix.*')";//echo $number_prefix;exit; | |
| 480 | + $number_prefix .= "$field='^defaultprefix.*')"; //echo $number_prefix;exit; | |
| 481 | 481 | return $number_prefix; | 
| 482 | 482 | } | 
| 483 | 483 | |
| @@ -487,6 +487,6 @@ discard block | ||
| 487 | 487 | */ | 
| 488 | 488 | function convert_to_gmt($date) | 
| 489 | 489 |  { | 
| 490 | -	return gmdate('Y-m-d H:i:s', strtotime($date) ); | |
| 490 | +	return gmdate('Y-m-d H:i:s', strtotime($date)); | |
| 491 | 491 | } | 
| 492 | 492 | ?> | 
| @@ -115,6 +115,10 @@ | ||
| 115 | 115 | $this->process_invoice($account_value, $start_date, $end_date); | 
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | + /** | |
| 119 | + * @param string $start_date | |
| 120 | + * @param string $end_date | |
| 121 | + */ | |
| 118 | 122 |      function process_invoice($accountdata, $start_date, $end_date) { | 
| 119 | 123 | //Get Invoice configuration using single query instead of multiple queries. | 
| 120 | 124 | $invoice_conf = array(); |