@@ -314,15 +314,15 @@ |
||
314 | 314 | // -------------------------------------------------------------------- |
315 | 315 | |
316 | 316 | /** |
317 | - * Parse major version |
|
318 | - * |
|
319 | - * Grabs the major version number from the |
|
320 | - * database server version string passed in. |
|
321 | - * |
|
322 | - * @access private |
|
323 | - * @param string $version |
|
324 | - * @return string major version number |
|
325 | - */ |
|
317 | + * Parse major version |
|
318 | + * |
|
319 | + * Grabs the major version number from the |
|
320 | + * database server version string passed in. |
|
321 | + * |
|
322 | + * @access private |
|
323 | + * @param string $version |
|
324 | + * @return string major version number |
|
325 | + */ |
|
326 | 326 | function _parse_major_version($version) |
327 | 327 | { |
328 | 328 | preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | //Generate CDR string for insert query for reseller |
319 | 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']; |
|
321 | + $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype']; |
|
322 | 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 | |
@@ -327,27 +327,27 @@ discard block |
||
327 | 327 | * @param integer $entity_id |
328 | 328 | */ |
329 | 329 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
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); |
|
333 | - $db->run($query); |
|
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); |
|
333 | + $db->run($query); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | //Normalize rate string which we are getting from dialplan |
337 | 337 | function normalize_rate($dataVariable) |
338 | 338 | { |
339 | 339 | $rates = urldecode($dataVariable); |
340 | - $data = explode("|", $rates); |
|
340 | + $data = explode("|", $rates); |
|
341 | 341 | |
342 | 342 | $newarray = array(); |
343 | - foreach ($data as $key => $value) |
|
344 | - { |
|
345 | - $data1 = explode(":", $value); |
|
346 | - foreach ($data1 as $newkey => $newvalue) |
|
347 | - { |
|
348 | - $newarray[$data1[0]] = $data1[$newkey]; |
|
349 | - } |
|
350 | - } |
|
343 | + foreach ($data as $key => $value) |
|
344 | + { |
|
345 | + $data1 = explode(":", $value); |
|
346 | + foreach ($data1 as $newkey => $newvalue) |
|
347 | + { |
|
348 | + $newarray[$data1[0]] = $data1[$newkey]; |
|
349 | + } |
|
350 | + } |
|
351 | 351 | return $newarray; |
352 | 352 | } |
353 | 353 |
@@ -24,97 +24,97 @@ discard block |
||
24 | 24 | |
25 | 25 | //Parse user and rates array which we got in cdr xml |
26 | 26 | function parse_rates_array($xml_rate, $constant_array, $logger) { |
27 | - $rates_array = array(); |
|
27 | + $rates_array = array(); |
|
28 | 28 | |
29 | - //decode string using urldecode |
|
30 | - $xml_rate = urldecode($xml_rate); |
|
31 | - $xml_rate_array = explode("||", $xml_rate); |
|
29 | + //decode string using urldecode |
|
30 | + $xml_rate = urldecode($xml_rate); |
|
31 | + $xml_rate_array = explode("||", $xml_rate); |
|
32 | 32 | |
33 | - foreach ($xml_rate_array as $rate_key => $rate_value) { |
|
34 | - $rates_array = explode("|", $rate_value); |
|
33 | + foreach ($xml_rate_array as $rate_key => $rate_value) { |
|
34 | + $rates_array = explode("|", $rate_value); |
|
35 | 35 | |
36 | - $user_id_param = $rates_array[count($rates_array) - 1]; |
|
37 | - $user_id = (substr($user_id_param, 0, 3) == 'UID') ? substr($user_id_param, 3) : 0; |
|
36 | + $user_id_param = $rates_array[count($rates_array) - 1]; |
|
37 | + $user_id = (substr($user_id_param, 0, 3) == 'UID') ? substr($user_id_param, 3) : 0; |
|
38 | 38 | |
39 | - foreach ($rates_array as $key => $value) { |
|
40 | - $rates_array_info[$user_id][$constant_array[substr($value, 0, 3)]] = substr($value, 3); |
|
41 | - } |
|
42 | - } |
|
43 | - return $rates_array_info; |
|
39 | + foreach ($rates_array as $key => $value) { |
|
40 | + $rates_array_info[$user_id][$constant_array[substr($value, 0, 3)]] = substr($value, 3); |
|
41 | + } |
|
42 | + } |
|
43 | + return $rates_array_info; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | //Process package |
47 | 47 | function process_package($xml_cdr, $user_id, $rates_array, $logger, $db) { |
48 | - $duration = $xml_cdr->variables->duration; |
|
49 | - $xml_cdr->variables->package_id = 0; |
|
50 | - $flag = false; |
|
51 | - if ($duration > 0 && $xml_cdr->variables->call_direction == 'outbound') { |
|
52 | - $destination_number = $xml_cdr->variables->effective_destination_number; |
|
53 | - |
|
54 | - $number_len = strlen($destination_number); |
|
55 | - $number_loop_str = '('; |
|
56 | - while ($number_len > 0) { |
|
57 | - $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR "; |
|
58 | - $number_len -= 1; |
|
59 | - } |
|
60 | - $number_loop_str .= " code='--')"; |
|
61 | - |
|
62 | - $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
63 | - $logger->log("Package Query : ".$query); |
|
64 | - $res_package = $db->run($query); |
|
65 | - |
|
66 | - foreach ($res_package as $res_package_key => $package_info) { |
|
67 | - if (isset($package_info['package_id'])) { |
|
68 | - $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info['code']." AND package_id=".$package_info['package_id']." AND user_id=".$user_id; |
|
69 | - $logger->log("Package usage Query : ".$query); |
|
70 | - $res_pkg_usg = $db->run($query); |
|
71 | - $package_usage_info = $res_pkg_usg[0]; |
|
72 | - |
|
73 | - $used_seconds = (isset($package_usage_info['used_seconds'])) ? $package_usage_info['used_seconds'] : 0; |
|
74 | - |
|
75 | - $logger->log("Included seconds : ".$package_info['includedseconds'].", Used seconds : ".$used_seconds); |
|
76 | - if ($package_info['includedseconds'] > $used_seconds) { |
|
77 | - $remaining_seconds = $package_info['includedseconds'] - ($duration + $used_seconds); |
|
78 | - if ($remaining_seconds > 0) { |
|
79 | - $dud_sec = $duration; |
|
80 | - $duration = 0; |
|
81 | - } else { |
|
82 | - $dud_sec = $duration - abs($remaining_seconds); |
|
83 | - $duration = abs($remaining_seconds); |
|
84 | - } |
|
85 | - $flag = true; |
|
86 | - $xml_cdr->variables->package_id = $package_info['package_id']; |
|
87 | - |
|
88 | - $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info['package_id'].",".$user_id.",'".$package_info['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec; |
|
89 | - $logger->log("Package Usage Query : ".$query); |
|
90 | - $db->run($query); |
|
91 | - |
|
92 | - break; |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - return array($duration, $flag); |
|
48 | + $duration = $xml_cdr->variables->duration; |
|
49 | + $xml_cdr->variables->package_id = 0; |
|
50 | + $flag = false; |
|
51 | + if ($duration > 0 && $xml_cdr->variables->call_direction == 'outbound') { |
|
52 | + $destination_number = $xml_cdr->variables->effective_destination_number; |
|
53 | + |
|
54 | + $number_len = strlen($destination_number); |
|
55 | + $number_loop_str = '('; |
|
56 | + while ($number_len > 0) { |
|
57 | + $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR "; |
|
58 | + $number_len -= 1; |
|
59 | + } |
|
60 | + $number_loop_str .= " code='--')"; |
|
61 | + |
|
62 | + $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
63 | + $logger->log("Package Query : ".$query); |
|
64 | + $res_package = $db->run($query); |
|
65 | + |
|
66 | + foreach ($res_package as $res_package_key => $package_info) { |
|
67 | + if (isset($package_info['package_id'])) { |
|
68 | + $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info['code']." AND package_id=".$package_info['package_id']." AND user_id=".$user_id; |
|
69 | + $logger->log("Package usage Query : ".$query); |
|
70 | + $res_pkg_usg = $db->run($query); |
|
71 | + $package_usage_info = $res_pkg_usg[0]; |
|
72 | + |
|
73 | + $used_seconds = (isset($package_usage_info['used_seconds'])) ? $package_usage_info['used_seconds'] : 0; |
|
74 | + |
|
75 | + $logger->log("Included seconds : ".$package_info['includedseconds'].", Used seconds : ".$used_seconds); |
|
76 | + if ($package_info['includedseconds'] > $used_seconds) { |
|
77 | + $remaining_seconds = $package_info['includedseconds'] - ($duration + $used_seconds); |
|
78 | + if ($remaining_seconds > 0) { |
|
79 | + $dud_sec = $duration; |
|
80 | + $duration = 0; |
|
81 | + } else { |
|
82 | + $dud_sec = $duration - abs($remaining_seconds); |
|
83 | + $duration = abs($remaining_seconds); |
|
84 | + } |
|
85 | + $flag = true; |
|
86 | + $xml_cdr->variables->package_id = $package_info['package_id']; |
|
87 | + |
|
88 | + $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info['package_id'].",".$user_id.",'".$package_info['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec; |
|
89 | + $logger->log("Package Usage Query : ".$query); |
|
90 | + $db->run($query); |
|
91 | + |
|
92 | + break; |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + return array($duration, $flag); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //Process user/vendor cdr |
101 | 101 | function do_cdr_process($xml_cdr, $debit, $cost, $vendor_cost, $rates_array, $parent_id = 0, $parent_rates, $carrier_rates_array, $logger, $db) { |
102 | - $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".@$carrier_rates_array['code']."','".@$carrier_rates_array['destination']."','".@$carrier_rates_array['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec; |
|
102 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".@$carrier_rates_array['code']."','".@$carrier_rates_array['destination']."','".@$carrier_rates_array['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec; |
|
103 | 103 | |
104 | - $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)"; |
|
104 | + $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)"; |
|
105 | 105 | |
106 | - $logger->log("CDR Query : ".$query); |
|
107 | - $db->run($query); |
|
106 | + $logger->log("CDR Query : ".$query); |
|
107 | + $db->run($query); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | //Process reseller cdr |
111 | 111 | function do_reseller_cdr_process($xml_cdr, $debit, $cost, $rates_array, $parent_id = 0, $parent_rates, $logger, $db) { |
112 | - $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".$xml_cdr->variables->call_direction."'"; |
|
112 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".$xml_cdr->variables->call_direction."'"; |
|
113 | 113 | |
114 | - $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)"; |
|
114 | + $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)"; |
|
115 | 115 | |
116 | - $logger->log("CDR Query : ".$query); |
|
117 | - $db->run($query); |
|
116 | + $logger->log("CDR Query : ".$query); |
|
117 | + $db->run($query); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | //Update user balance |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | * @param integer $entity_id |
123 | 123 | */ |
124 | 124 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
125 | - if ($amount > 0) { |
|
126 | - $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
127 | - $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id; |
|
128 | - $logger->log("Balance update : ".$query); |
|
129 | - $db->run($query); |
|
130 | - } |
|
125 | + if ($amount > 0) { |
|
126 | + $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
127 | + $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id; |
|
128 | + $logger->log("Balance update : ".$query); |
|
129 | + $db->run($query); |
|
130 | + } |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | //Get user info |
134 | 134 | function get_user_info($parent_id, $db) { |
135 | - $query = "SELECT * FROM tbl_users WHERE id=".$parent_id; |
|
136 | - $res_user = $db->run($query); |
|
137 | - return $res_user[0]; |
|
135 | + $query = "SELECT * FROM tbl_users WHERE id=".$parent_id; |
|
136 | + $res_user = $db->run($query); |
|
137 | + return $res_user[0]; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | ?> |
@@ -23,61 +23,61 @@ |
||
23 | 23 | |
24 | 24 | class db extends PDO { |
25 | 25 | |
26 | - private $error; |
|
27 | - private $sql; |
|
28 | - private $bind; |
|
29 | - private $errorCallbackFunction; |
|
30 | - private $errorMsgFormat; |
|
26 | + private $error; |
|
27 | + private $sql; |
|
28 | + private $bind; |
|
29 | + private $errorCallbackFunction; |
|
30 | + private $errorMsgFormat; |
|
31 | 31 | |
32 | - public function __construct($dsn = "", $user = "", $passwd = "") { |
|
32 | + public function __construct($dsn = "", $user = "", $passwd = "") { |
|
33 | 33 | |
34 | - $config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); |
|
34 | + $config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); |
|
35 | 35 | |
36 | - $options = array( |
|
37 | - PDO::ATTR_PERSISTENT => true, |
|
38 | - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
39 | - ); |
|
36 | + $options = array( |
|
37 | + PDO::ATTR_PERSISTENT => true, |
|
38 | + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
39 | + ); |
|
40 | 40 | |
41 | - try { |
|
42 | - parent::__construct("mysql:host=".$config['dbhost'].";dbname=".$config['dbname']."", $config['dbuser'], $config['dbpass'], $options); |
|
43 | - } catch (PDOException $e) { |
|
41 | + try { |
|
42 | + parent::__construct("mysql:host=".$config['dbhost'].";dbname=".$config['dbname']."", $config['dbuser'], $config['dbpass'], $options); |
|
43 | + } catch (PDOException $e) { |
|
44 | 44 | |
45 | - $this->error = $e->getMessage(); |
|
46 | - } |
|
47 | - echo $this->error; |
|
48 | - } |
|
45 | + $this->error = $e->getMessage(); |
|
46 | + } |
|
47 | + echo $this->error; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $bind |
|
52 | - */ |
|
53 | - public function cleanup($bind) { |
|
54 | - if ( ! is_array($bind)) { |
|
55 | - if ( ! empty($bind)) |
|
56 | - $bind = array($bind); |
|
57 | - else |
|
58 | - $bind = array(); |
|
59 | - } |
|
60 | - return $bind; |
|
61 | - } |
|
50 | + /** |
|
51 | + * @param string $bind |
|
52 | + */ |
|
53 | + public function cleanup($bind) { |
|
54 | + if ( ! is_array($bind)) { |
|
55 | + if ( ! empty($bind)) |
|
56 | + $bind = array($bind); |
|
57 | + else |
|
58 | + $bind = array(); |
|
59 | + } |
|
60 | + return $bind; |
|
61 | + } |
|
62 | 62 | |
63 | - public function run($sql, $bind = "") { |
|
64 | - $this->sql = trim($sql); |
|
65 | - $this->bind = $this->cleanup($bind); |
|
66 | - $this->error = ""; |
|
63 | + public function run($sql, $bind = "") { |
|
64 | + $this->sql = trim($sql); |
|
65 | + $this->bind = $this->cleanup($bind); |
|
66 | + $this->error = ""; |
|
67 | 67 | |
68 | - try { |
|
69 | - $pdostmt = $this->prepare($this->sql); |
|
70 | - if ($pdostmt->execute($this->bind) !== false) { |
|
71 | - if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) |
|
72 | - return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
73 | - elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) |
|
74 | - return $pdostmt->rowCount(); |
|
75 | - } |
|
76 | - } catch (PDOException $e) { |
|
77 | - $this->error = $e->getMessage(); |
|
78 | - return $this->error; |
|
79 | - } |
|
80 | - } |
|
68 | + try { |
|
69 | + $pdostmt = $this->prepare($this->sql); |
|
70 | + if ($pdostmt->execute($this->bind) !== false) { |
|
71 | + if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) |
|
72 | + return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
73 | + elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) |
|
74 | + return $pdostmt->rowCount(); |
|
75 | + } |
|
76 | + } catch (PDOException $e) { |
|
77 | + $this->error = $e->getMessage(); |
|
78 | + return $this->error; |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
83 | 83 |
@@ -314,15 +314,15 @@ |
||
314 | 314 | // -------------------------------------------------------------------- |
315 | 315 | |
316 | 316 | /** |
317 | - * Parse major version |
|
318 | - * |
|
319 | - * Grabs the major version number from the |
|
320 | - * database server version string passed in. |
|
321 | - * |
|
322 | - * @access private |
|
323 | - * @param string $version |
|
324 | - * @return string major version number |
|
325 | - */ |
|
317 | + * Parse major version |
|
318 | + * |
|
319 | + * Grabs the major version number from the |
|
320 | + * database server version string passed in. |
|
321 | + * |
|
322 | + * @access private |
|
323 | + * @param string $version |
|
324 | + * @return string major version number |
|
325 | + */ |
|
326 | 326 | function _parse_major_version($version) |
327 | 327 | { |
328 | 328 | preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); |
@@ -1429,7 +1429,7 @@ discard block |
||
1429 | 1429 | // $csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header); |
1430 | 1430 | |
1431 | 1431 | $csv_data = $this->utf8_converter($this->csvreader->parse_file($uploadedFile, $field_select, $check_header)); |
1432 | - if (!empty($csv_data)) |
|
1432 | + if (!empty($csv_data)) |
|
1433 | 1433 | { |
1434 | 1434 | $full_path = $this->config->item('rates-file-path'); |
1435 | 1435 | $actual_file_name = "ASTPP-TERMINATION-RATES-" . date("Y-m-d H:i:s") . "." . $ext; |
@@ -1566,11 +1566,11 @@ discard block |
||
1566 | 1566 | { |
1567 | 1567 | $result = $this->rates_model->bulk_insert_termination_rate($new_final_arr); |
1568 | 1568 | } |
1569 | - else |
|
1570 | - { |
|
1569 | + else |
|
1570 | + { |
|
1571 | 1571 | |
1572 | - $this->session->set_flashdata('astpp_errormsg', 'Error - Nothing selected to import/process!'); |
|
1573 | - redirect(base_url() . 'rates/termination_rates_list/'); |
|
1572 | + $this->session->set_flashdata('astpp_errormsg', 'Error - Nothing selected to import/process!'); |
|
1573 | + redirect(base_url() . 'rates/termination_rates_list/'); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | unlink($full_path . $terminationrate_file_name); |
@@ -7,19 +7,19 @@ discard block |
||
7 | 7 | }); |
8 | 8 | </script> <script type="text/javascript" language="javascript"><? |
9 | 9 | if (isset($mapto_fields) && !empty($mapto_fields)) { |
10 | - foreach($mapto_fields as $csv_key => $csv_value) { |
|
11 | - echo '$("#'.$csv_value .'-prefix").live("change", function () {'; |
|
12 | - echo 'var select = document.getElementById("'.$csv_value .'-select");'; |
|
13 | - echo 'var answer = select.options[select.selectedIndex].value;'; |
|
14 | - echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];'; |
|
15 | - echo '});'; |
|
16 | - echo '$("#'.$csv_value .'-select").live("change", function () {'; |
|
17 | - echo 'var select = document.getElementById("'.$csv_value .'-select");'; |
|
18 | - echo 'var answer = select.options[select.selectedIndex].value;'; |
|
19 | - echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];'; |
|
20 | - echo '});'; |
|
21 | - } |
|
22 | - } |
|
10 | + foreach($mapto_fields as $csv_key => $csv_value) { |
|
11 | + echo '$("#'.$csv_value .'-prefix").live("change", function () {'; |
|
12 | + echo 'var select = document.getElementById("'.$csv_value .'-select");'; |
|
13 | + echo 'var answer = select.options[select.selectedIndex].value;'; |
|
14 | + echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];'; |
|
15 | + echo '});'; |
|
16 | + echo '$("#'.$csv_value .'-select").live("change", function () {'; |
|
17 | + echo 'var select = document.getElementById("'.$csv_value .'-select");'; |
|
18 | + echo 'var answer = select.options[select.selectedIndex].value;'; |
|
19 | + echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];'; |
|
20 | + echo '});'; |
|
21 | + } |
|
22 | + } |
|
23 | 23 | ?></script> |
24 | 24 | <? |
25 | 25 | if (isset($csv_tmp_data) && !empty($csv_tmp_data)) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | echo 'var csv_tmp_data = ' . json_encode($csv_tmp_data) . ';'; |
28 | 28 | echo '</script>'; |
29 | 29 | } |
30 | - ?> |
|
30 | + ?> |
|
31 | 31 | <?php |
32 | 32 | endblock() ?> |
33 | 33 | <?php |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | <div class="w-box"> |
52 | 52 | <span style="margin-left:10px; text-align: center;background-color: none;color:#DD191D;"> |
53 | 53 | <?php |
54 | - if (isset($error) && !empty($error)) { |
|
55 | - echo $error; |
|
56 | - } ?> |
|
54 | + if (isset($error) && !empty($error)) { |
|
55 | + echo $error; |
|
56 | + } ?> |
|
57 | 57 | </span> |
58 | 58 | <h3 class="padding-t-10 padding-l-16">You must either select a field from your file OR provide a default value for the following fields:</h3> |
59 | 59 | <p>Code,Destination,Connect Cost,Included Seconds,Per Minute Cost,Increment,Precedence,Strip,Prepend.</p> |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | <label class="col-md-3">Trunk List:</label> |
68 | 68 | <div class="col-md-8"> |
69 | 69 | <?php |
70 | - $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array( |
|
71 | - "status " => "0" |
|
72 | - )) , ''); |
|
73 | - echo $trunklist; ?> |
|
70 | + $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array( |
|
71 | + "status " => "0" |
|
72 | + )) , ''); |
|
73 | + echo $trunklist; ?> |
|
74 | 74 | </div> |
75 | 75 | </div> |
76 | 76 | |
@@ -135,28 +135,28 @@ discard block |
||
135 | 135 | </thead> |
136 | 136 | <tbody> |
137 | 137 | <?php |
138 | - foreach($mapto_fields as $csv_key => $csv_value) { |
|
138 | + foreach($mapto_fields as $csv_key => $csv_value) { |
|
139 | 139 | |
140 | - echo "<tr>"; |
|
141 | - echo "<td>" . $csv_key . '(' . $csv_value . ")</td>"; |
|
142 | - echo "<td><input type='text' name='".$csv_value ."-prefix' id='".$csv_value ."-prefix'></td>"; |
|
143 | - echo "<td>"; |
|
144 | - echo "<select name='".$csv_value ."-select' id='".$csv_value ."-select'>"; |
|
145 | - ?> |
|
140 | + echo "<tr>"; |
|
141 | + echo "<td>" . $csv_key . '(' . $csv_value . ")</td>"; |
|
142 | + echo "<td><input type='text' name='".$csv_value ."-prefix' id='".$csv_value ."-prefix'></td>"; |
|
143 | + echo "<td>"; |
|
144 | + echo "<select name='".$csv_value ."-select' id='".$csv_value ."-select'>"; |
|
145 | + ?> |
|
146 | 146 | <option value=""></option> |
147 | 147 | <?php |
148 | - $keys = array_keys($file_data); |
|
149 | - for ($i = 0; $i < count($file_data); $i++) { ?> |
|
148 | + $keys = array_keys($file_data); |
|
149 | + for ($i = 0; $i < count($file_data); $i++) { ?> |
|
150 | 150 | <option value="<?php |
151 | - echo $file_data[$i]; ?>"><?php |
|
152 | - echo $file_data[$i]; ?></option> |
|
151 | + echo $file_data[$i]; ?>"><?php |
|
152 | + echo $file_data[$i]; ?></option> |
|
153 | 153 | <?php |
154 | - } |
|
155 | - echo "</td>"; |
|
156 | - echo "<td><input type='text' name='".$csv_value ."-display' id='".$csv_value ."-display'></td>"; |
|
157 | - echo "</tr>"; |
|
154 | + } |
|
155 | + echo "</td>"; |
|
156 | + echo "<td><input type='text' name='".$csv_value ."-display' id='".$csv_value ."-display'></td>"; |
|
157 | + echo "</tr>"; |
|
158 | 158 | |
159 | - } ?> |
|
159 | + } ?> |
|
160 | 160 | </tbody> |
161 | 161 | </table> |
162 | 162 | <input type="hidden" name="trunkid" value="<?php echo $trunkid ?>" /> |
@@ -174,25 +174,25 @@ discard block |
||
174 | 174 | <form id="import_form" name="import_form" action="<?=base_url()?>rates/termination_rate_rates_import/<?= $trunkid?>/<?=$check_header?>/" method="POST"> |
175 | 175 | <table width="100%" border="1" class="details_table table"> |
176 | 176 | <? $cnt =1; |
177 | - foreach($csv_tmp_data as $csv_key => $csv_value){ |
|
178 | - if($csv_key < 15){ |
|
179 | - echo "<tr>"; |
|
180 | - foreach($csv_value as $field_name => $field_val){ |
|
181 | - if($csv_key == 0){ |
|
182 | - echo "<th>".ucfirst($field_val)."</th>"; |
|
183 | - }else{ |
|
184 | - echo "<td class='portlet-content'>".$field_val."</td>"; |
|
185 | - $cnt++; |
|
186 | - } |
|
187 | - } |
|
188 | - echo "</tr>"; |
|
189 | - } |
|
190 | - } |
|
177 | + foreach($csv_tmp_data as $csv_key => $csv_value){ |
|
178 | + if($csv_key < 15){ |
|
179 | + echo "<tr>"; |
|
180 | + foreach($csv_value as $field_name => $field_val){ |
|
181 | + if($csv_key == 0){ |
|
182 | + echo "<th>".ucfirst($field_val)."</th>"; |
|
183 | + }else{ |
|
184 | + echo "<td class='portlet-content'>".$field_val."</td>"; |
|
185 | + $cnt++; |
|
186 | + } |
|
187 | + } |
|
188 | + echo "</tr>"; |
|
189 | + } |
|
190 | + } |
|
191 | 191 | |
192 | - echo "<tr><td colspan='".$cnt."'> |
|
192 | + echo "<tr><td colspan='".$cnt."'> |
|
193 | 193 | <a href='".base_url()."rates/termination_rates_list/'><input type='button' class='btn btn-line-sky pull-right margin-x-10' value='Back'/></a> |
194 | 194 | <input type='submit' class='btn btn-line-parrot pull-right'' id='Process' value='Process'/></td></tr>"; |
195 | - ?> </table></form> |
|
195 | + ?> </table></form> |
|
196 | 196 | </div> |
197 | 197 | </div> |
198 | 198 | </div> |