@@ -26,36 +26,36 @@ discard block |
||
26 | 26 | { |
27 | 27 | //$logger->log(print_r($data,true));//exit; |
28 | 28 | |
29 | - //Initializing variables |
|
29 | + //Initializing variables |
|
30 | 30 | $origination_rate = array(); |
31 | 31 | $termination_rate = array(); |
32 | 32 | |
33 | - //FS CDR variables |
|
33 | + //FS CDR variables |
|
34 | 34 | $dataVariable = $data['variables']; |
35 | 35 | |
36 | - //FS CDR Call flow variables |
|
36 | + //FS CDR Call flow variables |
|
37 | 37 | $dataCallflow = $data['callflow']; |
38 | 38 | |
39 | - //Get account id |
|
39 | + //Get account id |
|
40 | 40 | $accountid = isset($dataVariable['account_id']) ? $dataVariable['account_id'] : '0'; |
41 | 41 | |
42 | - //Get caller id name and number |
|
42 | + //Get caller id name and number |
|
43 | 43 | $dataVariable['effective_caller_id_name'] = (isset($dataVariable['effective_caller_id_name'])) ? $dataVariable['effective_caller_id_name'] : $dataCallflow['caller_profile']['caller_id_name']; |
44 | 44 | $dataVariable['effective_caller_id_number'] = (isset($dataVariable['effective_caller_id_number'])) ? $dataVariable['effective_caller_id_number'] : $dataCallflow['caller_profile']['caller_id_number']; |
45 | 45 | |
46 | 46 | |
47 | - if ($dataVariable['billsec'] == 0 && $dataVariable['hangup_cause'] == 'NORMAL_CLEARING') |
|
48 | - { |
|
49 | - $hangup_cause = isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause']; |
|
50 | - }else{ |
|
51 | - $hangup_cause = $dataVariable['hangup_cause']; |
|
52 | - } |
|
47 | + if ($dataVariable['billsec'] == 0 && $dataVariable['hangup_cause'] == 'NORMAL_CLEARING') |
|
48 | + { |
|
49 | + $hangup_cause = isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause']; |
|
50 | + }else{ |
|
51 | + $hangup_cause = $dataVariable['hangup_cause']; |
|
52 | + } |
|
53 | 53 | |
54 | - if ($dataVariable['error_cdr'] == '1') |
|
55 | - { |
|
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']); |
|
58 | - } |
|
54 | + if ($dataVariable['error_cdr'] == '1') |
|
55 | + { |
|
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']); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | /*#### PATCH FOR ONE WAY AUDIO ####*/ |
61 | 61 | if ($hangup_cause == "NORMAL_UNSPECIFIED" && $dataVariable['billsec'] > 0) |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | } |
65 | 65 | /*#### ************* END *************####*/ |
66 | 66 | |
67 | - //Don't thing this will be useful anytime. Need to remove it after testing. |
|
67 | + //Don't thing this will be useful anytime. Need to remove it after testing. |
|
68 | 68 | if($hangup_cause == "NONE") |
69 | 69 | { |
70 | 70 | $hangup_cause = $dataVariable['current_application_data']; |
71 | 71 | } |
72 | 72 | |
73 | - $dataVariable['hangup_cause'] = $hangup_cause; |
|
73 | + $dataVariable['hangup_cause'] = $hangup_cause; |
|
74 | 74 | |
75 | 75 | if ( ($dataVariable['hangup_cause'] != 'NORMAL_CLEARING') && ($dataVariable['hangup_cause'] != 'ALLOTTED_TIMEOUT')) { |
76 | 76 | $dataVariable['billsec'] = 0; |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | $dataVariable['calltype'] = isset($dataVariable['calltype']) ? $dataVariable['calltype'] : "STANDARD"; |
86 | 86 | $actual_calltype = $dataVariable['calltype']; |
87 | 87 | |
88 | - //Normalize origination and termination rates array |
|
88 | + //Normalize origination and termination rates array |
|
89 | 89 | if(isset($dataVariable['origination_rates'])) |
90 | 90 | $origination_rate = normalize_origination_rate($dataVariable['origination_rates']); |
91 | 91 | if(isset($dataVariable['termination_rates'])) |
92 | 92 | $termination_rate = normalize_rate($dataVariable['termination_rates']); |
93 | 93 | |
94 | - //If receiver account id found then explicitly set call direction and call type |
|
94 | + //If receiver account id found then explicitly set call direction and call type |
|
95 | 95 | if(isset($dataVariable['receiver_accid'])) |
96 | 96 | { |
97 | 97 | $dataVariable['call_direction'] = "outbound"; |
98 | - $dataVariable['calltype'] = "STANDARD"; |
|
98 | + $dataVariable['calltype'] = "STANDARD"; |
|
99 | 99 | } |
100 | 100 | |
101 | - //Check if cusotmer have any package seconds left to use |
|
101 | + //Check if cusotmer have any package seconds left to use |
|
102 | 102 | if ($actual_duration > 0) |
103 | - { |
|
103 | + { |
|
104 | 104 | $package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger); |
105 | 105 | if(!empty($package_array)) |
106 | 106 | { |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - //Calculate debit of customer call |
|
112 | + //Calculate debit of customer call |
|
113 | 113 | $debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points); |
114 | 114 | |
115 | - //Calculate cost for customer call for provider |
|
115 | + //Calculate cost for customer call for provider |
|
116 | 116 | $provider_cost = calc_cost($dataVariable,$termination_rate,$logger,$decimal_points); |
117 | 117 | |
118 | - //Calculate parent cost if customer have any parent |
|
118 | + //Calculate parent cost if customer have any parent |
|
119 | 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); |
|
120 | + $logger->log("Debit :".$debit ." Cost : ".$cost ." Provider Cost : ".$parent_cost); |
|
121 | 121 | |
122 | - //Initialize final cost variable to use for billing |
|
122 | + //Initialize final cost variable to use for billing |
|
123 | 123 | $cost = ($parent_cost > 0) ? $parent_cost : $provider_cost; |
124 | 124 | |
125 | - //Outbound call entry for all type of calls |
|
125 | + //Outbound call entry for all type of calls |
|
126 | 126 | $logger->log("*********************** OUTBOUND CALL ENTRY START *************"); |
127 | 127 | |
128 | 128 | $cdr_string = get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger); |
@@ -131,60 +131,60 @@ discard block |
||
131 | 131 | $logger->log($query); |
132 | 132 | $db->run($query); |
133 | 133 | |
134 | - //Update customer balance |
|
134 | + //Update customer balance |
|
135 | 135 | if($debit > 0 && $dataVariable['calltype'] != "FREE") |
136 | 136 | { |
137 | 137 | update_balance($accountid, $debit, 0, $logger, $db); |
138 | 138 | } |
139 | 139 | |
140 | - //Update parent or provider balance |
|
140 | + //Update parent or provider balance |
|
141 | 141 | if($parent_cost > 0){ |
142 | 142 | update_balance($termination_rate['PROVIDER'], ($parent_cost * -1), 3, $logger, $db); |
143 | 143 | } |
144 | 144 | |
145 | - //Resellers CDR entry |
|
146 | - $flag_parent = false; |
|
147 | - insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points); |
|
145 | + //Resellers CDR entry |
|
146 | + $flag_parent = false; |
|
147 | + insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points); |
|
148 | 148 | |
149 | - $logger->log("*********************** OUTBOUND CALL ENTRY END *************"); |
|
149 | + $logger->log("*********************** OUTBOUND CALL ENTRY END *************"); |
|
150 | 150 | |
151 | 151 | |
152 | - //************ ADDING EXTRA ENTRY For local/DID Inbound call **************************** |
|
152 | + //************ ADDING EXTRA ENTRY For local/DID Inbound call **************************** |
|
153 | 153 | $receiver_parentid=0; |
154 | 154 | if(isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "") |
155 | 155 | { |
156 | - $logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING START *************"); |
|
156 | + $logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING START *************"); |
|
157 | 157 | |
158 | - //Explicitly set call direction and call type |
|
158 | + //Explicitly set call direction and call type |
|
159 | 159 | $dataVariable['call_direction'] = "inbound"; |
160 | - $dataVariable['calltype'] = "DID"; |
|
160 | + $dataVariable['calltype'] = "DID"; |
|
161 | 161 | |
162 | - //Override variables if call for DID PSTN |
|
163 | - if(isset($dataVariable['caller_did_account_id'])) |
|
164 | - { |
|
165 | - $dataVariable['receiver_accid'] = $dataVariable['caller_did_account_id']; |
|
166 | - $dataVariable['call_direction'] = "outbound"; |
|
167 | - $dataVariable['calltype'] = "STANDARD"; |
|
168 | - unset($termination_rate); |
|
169 | - unset($provider_cost); |
|
170 | - } |
|
162 | + //Override variables if call for DID PSTN |
|
163 | + if(isset($dataVariable['caller_did_account_id'])) |
|
164 | + { |
|
165 | + $dataVariable['receiver_accid'] = $dataVariable['caller_did_account_id']; |
|
166 | + $dataVariable['call_direction'] = "outbound"; |
|
167 | + $dataVariable['calltype'] = "STANDARD"; |
|
168 | + unset($termination_rate); |
|
169 | + unset($provider_cost); |
|
170 | + } |
|
171 | 171 | |
172 | 172 | |
173 | - //Get call receiver account information |
|
173 | + //Get call receiver account information |
|
174 | 174 | $receiver_carddata = get_accounts($dataVariable['receiver_accid'],$logger,$db); |
175 | 175 | $receiver_parentid = $receiver_carddata['reseller_id']; |
176 | 176 | |
177 | - //For additional cdr entry of receiver |
|
177 | + //For additional cdr entry of receiver |
|
178 | 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 | - //Insert parent reseller cdr |
|
183 | + //Insert parent reseller cdr |
|
184 | 184 | insert_parent_data($dataVariable,$actual_calltype,$receiver_parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points); |
185 | - $logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING END *************"); |
|
185 | + $logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING END *************"); |
|
186 | 186 | } |
187 | - //***************************************************************************************** |
|
187 | + //***************************************************************************************** |
|
188 | 188 | $logger->log("*************************** CDR ends ********************************"); |
189 | 189 | } |
190 | 190 | |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | |
201 | 201 | $debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points); |
202 | 202 | |
203 | - //If receiver account id found then explicitly set call direction and call type |
|
204 | - /*if(isset($dataVariable['receiver_accid'])) |
|
203 | + //If receiver account id found then explicitly set call direction and call type |
|
204 | + /*if(isset($dataVariable['receiver_accid'])) |
|
205 | 205 | { |
206 | 206 | $dataVariable['call_direction'] = "outbound"; |
207 | 207 | $dataVariable['calltype'] = "STANDARD"; |
208 | 208 | }*/ |
209 | 209 | |
210 | - //Check if reseller have any package seconds left to use |
|
210 | + //Check if reseller have any package seconds left to use |
|
211 | 211 | if ($actual_duration > 0) { |
212 | 212 | $package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger); |
213 | 213 | if(!empty($package_array)) |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - //Get parent id for cost calculation |
|
220 | + //Get parent id for cost calculation |
|
221 | 221 | $parentid = $carddata['reseller_id']; |
222 | 222 | $parent_cost = ($parentid > 0) ? calc_cost($dataVariable,$origination_rate[$parentid],$logger,$decimal_points) : $provider_cost; |
223 | 223 | $cost = ($parent_cost > 0) ? $parent_cost : $provider_cost; |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | $logger->log("********* IN RESELLER FOR RECEIVER ENTRY START ******"); |
228 | 228 | $flag_parent = true; |
229 | 229 | insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points); |
230 | - $logger->log("********* IN RESELLER FOR RECEIVER ENTRY END ******"); |
|
230 | + $logger->log("********* IN RESELLER FOR RECEIVER ENTRY END ******"); |
|
231 | 231 | return true; |
232 | 232 | |
233 | 233 | }else{ |
234 | 234 | |
235 | - $cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost); |
|
235 | + $cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost); |
|
236 | 236 | |
237 | 237 | $query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost, |
238 | 238 | reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)"; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | function get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger) |
303 | 303 | { |
304 | 304 | |
305 | - $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; |
|
305 | + $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; |
|
306 | 306 | |
307 | 307 | 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'."'").", |
308 | 308 | '".$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']."'" : "'".''."'" ).", |
@@ -313,33 +313,33 @@ discard block |
||
313 | 313 | //Generate CDR string for insert query for reseller |
314 | 314 | function get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost) |
315 | 315 | { |
316 | - $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; |
|
316 | + $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; |
|
317 | 317 | 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'])."'"; |
318 | 318 | } |
319 | 319 | |
320 | 320 | //Update user balance |
321 | 321 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
322 | - $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
323 | - $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id; |
|
324 | - $logger->log("Balance update : " . $query); |
|
325 | - $db->run($query); |
|
322 | + $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
323 | + $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id; |
|
324 | + $logger->log("Balance update : " . $query); |
|
325 | + $db->run($query); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | //Normalize rate string which we are getting from dialplan |
329 | 329 | function normalize_rate($dataVariable) |
330 | 330 | { |
331 | 331 | $rates = urldecode($dataVariable); |
332 | - $data = explode("|",$rates); |
|
332 | + $data = explode("|",$rates); |
|
333 | 333 | |
334 | 334 | $newarray = array(); |
335 | - foreach($data as $key => $value) |
|
336 | - { |
|
337 | - $data1 = explode(":",$value); |
|
338 | - foreach($data1 as $newkey => $newvalue) |
|
339 | - { |
|
340 | - $newarray[$data1[0]] = $data1[$newkey]; |
|
341 | - } |
|
342 | - } |
|
335 | + foreach($data as $key => $value) |
|
336 | + { |
|
337 | + $data1 = explode(":",$value); |
|
338 | + foreach($data1 as $newkey => $newvalue) |
|
339 | + { |
|
340 | + $newarray[$data1[0]] = $data1[$newkey]; |
|
341 | + } |
|
342 | + } |
|
343 | 343 | return $newarray; |
344 | 344 | } |
345 | 345 | |
@@ -373,19 +373,19 @@ discard block |
||
373 | 373 | $duration -= $rates['INCLUDEDSECONDS']; |
374 | 374 | if ($duration > 0 && ($dataVariable['hangup_cause'] == 'NORMAL_CLEARING' || $dataVariable['hangup_cause'] == 'ALLOTTED_TIMEOUT')) { |
375 | 375 | |
376 | - $rates['INC'] = ($rates['INC'] == 0) ? 1 : $rates['INC']; |
|
377 | - $call_cost = $rates['CONNECTIONCOST']; |
|
378 | - $call_cost += ($rates['INITIALBLOCK'] * $rates['COST']) / 60; |
|
379 | - $billseconds = $duration - $rates['INITIALBLOCK']; |
|
376 | + $rates['INC'] = ($rates['INC'] == 0) ? 1 : $rates['INC']; |
|
377 | + $call_cost = $rates['CONNECTIONCOST']; |
|
378 | + $call_cost += ($rates['INITIALBLOCK'] * $rates['COST']) / 60; |
|
379 | + $billseconds = $duration - $rates['INITIALBLOCK']; |
|
380 | 380 | |
381 | - if ($billseconds > 0) |
|
382 | - { |
|
383 | - $call_cost += (ceil($billseconds/$rates['INC'])*$rates['INC'])*($rates['COST']/60); |
|
384 | - } |
|
385 | - } |
|
386 | - $call_cost = number_format($call_cost,$decimal_points); |
|
387 | - $logger->log("Return cost ".$call_cost); |
|
388 | - return $call_cost; |
|
381 | + if ($billseconds > 0) |
|
382 | + { |
|
383 | + $call_cost += (ceil($billseconds/$rates['INC'])*$rates['INC'])*($rates['COST']/60); |
|
384 | + } |
|
385 | + } |
|
386 | + $call_cost = number_format($call_cost,$decimal_points); |
|
387 | + $logger->log("Return cost ".$call_cost); |
|
388 | + return $call_cost; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | // get intial package information |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | $counter = $db->run($query_counter); |
435 | 435 | $logger->log("GET Counters : " . $query_counter); |
436 | 436 | if($counter) |
437 | - return $counter[0]; |
|
437 | + return $counter[0]; |
|
438 | 438 | else |
439 | - return ""; |
|
439 | + return ""; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | //Get user info |
@@ -23,29 +23,29 @@ |
||
23 | 23 | |
24 | 24 | class logger { |
25 | 25 | |
26 | - var $fp; |
|
27 | - var $config; |
|
26 | + var $fp; |
|
27 | + var $config; |
|
28 | 28 | |
29 | - function logger($lib) { |
|
30 | - $this->config = $lib->config; |
|
31 | - $this->config['log_path'] = "/var/log/astpp/"; |
|
32 | - if ($this->config['debug'] == '0') |
|
33 | - $this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a'); |
|
34 | - } |
|
29 | + function logger($lib) { |
|
30 | + $this->config = $lib->config; |
|
31 | + $this->config['log_path'] = "/var/log/astpp/"; |
|
32 | + if ($this->config['debug'] == '0') |
|
33 | + $this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a'); |
|
34 | + } |
|
35 | 35 | |
36 | - function log($log) { |
|
37 | - if ($this->config['debug'] == '0') { |
|
38 | - if (is_array($log)) |
|
39 | - fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE)); |
|
40 | - else |
|
41 | - fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n"); |
|
42 | - } |
|
43 | - } |
|
36 | + function log($log) { |
|
37 | + if ($this->config['debug'] == '0') { |
|
38 | + if (is_array($log)) |
|
39 | + fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE)); |
|
40 | + else |
|
41 | + fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n"); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | - function close() { |
|
46 | - if ($this->config['debug'] == '0') |
|
47 | - fclose($this->fp); |
|
48 | - } |
|
45 | + function close() { |
|
46 | + if ($this->config['debug'] == '0') |
|
47 | + fclose($this->fp); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | } |
51 | 51 |
@@ -23,16 +23,16 @@ |
||
23 | 23 | |
24 | 24 | class lib { |
25 | 25 | |
26 | - var $config; |
|
26 | + var $config; |
|
27 | 27 | |
28 | - function get_configurations($db) { |
|
29 | - $query = "SELECT * FROM system WHERE group_title IN ('global','opensips')"; |
|
30 | - $res_conf = $db->run($query); |
|
31 | - foreach ($res_conf as $res_conf_key => $res_conf_value) |
|
32 | - $this->config[$res_conf_value['name']] = $res_conf_value['value']; |
|
28 | + function get_configurations($db) { |
|
29 | + $query = "SELECT * FROM system WHERE group_title IN ('global','opensips')"; |
|
30 | + $res_conf = $db->run($query); |
|
31 | + foreach ($res_conf as $res_conf_key => $res_conf_value) |
|
32 | + $this->config[$res_conf_value['name']] = $res_conf_value['value']; |
|
33 | 33 | |
34 | - return $this->config; |
|
35 | - } |
|
34 | + return $this->config; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | } |
38 | 38 |
@@ -25,15 +25,15 @@ |
||
25 | 25 | |
26 | 26 | $xml = ""; |
27 | 27 | if ($_REQUEST['key_value'] == 'sofia.conf') { |
28 | - $xml = load_sofia($logger, $db); |
|
29 | - header('Content-Type: text/xml'); |
|
30 | - echo $xml; |
|
28 | + $xml = load_sofia($logger, $db); |
|
29 | + header('Content-Type: text/xml'); |
|
30 | + echo $xml; |
|
31 | 31 | } elseif ($_REQUEST['key_value'] == 'acl.conf') { |
32 | - $xml = load_acl($logger, $db,$config); |
|
33 | - header('Content-Type: text/xml'); |
|
34 | - echo $xml; |
|
32 | + $xml = load_acl($logger, $db,$config); |
|
33 | + header('Content-Type: text/xml'); |
|
34 | + echo $xml; |
|
35 | 35 | } else { |
36 | - xml_not_found(); |
|
36 | + xml_not_found(); |
|
37 | 37 | } |
38 | 38 | $logger->log("*************************** Configuration Ends **********************************"); |
39 | 39 | exit(); |
@@ -27,12 +27,12 @@ |
||
27 | 27 | |
28 | 28 | |
29 | 29 | if (isset($_REQUEST['user']) && isset($_REQUEST['domain'])) { |
30 | - $xml = load_directory($logger, $db); |
|
31 | - if ($xml == "") |
|
32 | - xml_not_found(); |
|
33 | - echo $xml; |
|
30 | + $xml = load_directory($logger, $db); |
|
31 | + if ($xml == "") |
|
32 | + xml_not_found(); |
|
33 | + echo $xml; |
|
34 | 34 | }else { |
35 | - xml_not_found(); |
|
35 | + xml_not_found(); |
|
36 | 36 | } |
37 | 37 | $logger->log("*************************** Directory Ends **********************************"); |
38 | 38 | exit(); |
@@ -22,12 +22,12 @@ |
||
22 | 22 | <div class="pull-left"> |
23 | 23 | <ul class="breadcrumb"> |
24 | 24 | <?php $accountinfo=$this->session->userdata('accountinfo'); |
25 | - if($accountinfo['type']==1){ ?> |
|
25 | + if($accountinfo['type']==1){ ?> |
|
26 | 26 | <li><a href="<?= base_url() . "user/user_myprofile/"; ?>">My Profile</a></li> |
27 | 27 | <?php }else{ ?> |
28 | 28 | <li><a href="#">Configuration</a></li> |
29 | 29 | <?php } |
30 | - ?> |
|
30 | + ?> |
|
31 | 31 | |
32 | 32 | <li class='active'> |
33 | 33 | <a href="<?= base_url() . "user/user_ipmap/"; ?>">IP Settings</a> |
@@ -22,12 +22,12 @@ |
||
22 | 22 | <div class="pull-left"> |
23 | 23 | <ul class="breadcrumb"> |
24 | 24 | <?php $accountinfo=$this->session->userdata('accountinfo'); |
25 | - if($accountinfo['type']==1){ ?> |
|
25 | + if($accountinfo['type']==1){ ?> |
|
26 | 26 | <li><a href="<?= base_url() . "user/user_myprofile/"; ?>">My Profile</a></li> |
27 | 27 | <?php }else{ ?> |
28 | 28 | <li><a href="#">Configuration</a></li> |
29 | 29 | <?php } |
30 | - ?> |
|
30 | + ?> |
|
31 | 31 | |
32 | 32 | <li class='active'> |
33 | 33 | <a href="<?= base_url() . "user/user_ipmap/"; ?>">IP Settings</a> |
@@ -14,7 +14,7 @@ |
||
14 | 14 | <div class="w-section inverse no-padding"> |
15 | 15 | <?php echo $form; ?> |
16 | 16 | <?php |
17 | - if(isset($validation_errors) && $validation_errors != ''){ ?> |
|
17 | + if(isset($validation_errors) && $validation_errors != ''){ ?> |
|
18 | 18 | <script> |
19 | 19 | var ERR_STR = '<?php echo $validation_errors; ?>'; |
20 | 20 | print_error(ERR_STR); |
@@ -22,12 +22,12 @@ |
||
22 | 22 | <div class="pull-left"> |
23 | 23 | <ul class="breadcrumb"> |
24 | 24 | <?php $accountinfo=$this->session->userdata('accountinfo'); |
25 | - if($accountinfo['type']==1){ ?> |
|
25 | + if($accountinfo['type']==1){ ?> |
|
26 | 26 | <li><a href="<?= base_url() . "user/user_myprofile/"; ?>">My Profile</a></li> |
27 | 27 | <?php }else{ ?> |
28 | 28 | <li><a href="#">Configuration</a></li> |
29 | 29 | <?php } |
30 | - ?> |
|
30 | + ?> |
|
31 | 31 | |
32 | 32 | <li class='active'> |
33 | 33 | <a href="<?= base_url() . "user/user_ipmap/"; ?>">IP Settings</a> |