| @@ 329-334 (lines=6) @@ | ||
| 326 | /** |
|
| 327 | * @param integer $entity_id |
|
| 328 | */ |
|
| 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); |
|
| 334 | } |
|
| 335 | ||
| 336 | //Normalize rate string which we are getting from dialplan |
|
| 337 | function normalize_rate($dataVariable) |
|
| @@ 124-131 (lines=8) @@ | ||
| 121 | /** |
|
| 122 | * @param integer $entity_id |
|
| 123 | */ |
|
| 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 | } |
|
| 131 | } |
|
| 132 | ||
| 133 | //Get user info |
|
| 134 | function get_user_info($parent_id, $db) { |
|