From cbb94695e1162d24f0ab78213c6e684b891d3b5e Mon Sep 17 00:00:00 2001 From: sanketinx Date: Tue, 13 Dec 2022 11:14:29 +0530 Subject: [PATCH 1/5] [FIX] Balance Transferring --- .../astpp/application/models/common_model.php | 16 ++++------ .../modules/user/controllers/user.php | 32 +++++++++---------- 2 files changed, 23 insertions(+), 25 deletions(-) mode change 100755 => 100644 web_interface/astpp/application/models/common_model.php mode change 100755 => 100644 web_interface/astpp/application/modules/user/controllers/user.php diff --git a/web_interface/astpp/application/models/common_model.php b/web_interface/astpp/application/models/common_model.php old mode 100755 new mode 100644 index 737c26ab8..a95d971fd --- a/web_interface/astpp/application/models/common_model.php +++ b/web_interface/astpp/application/models/common_model.php @@ -277,12 +277,11 @@ function calculate_currency_customer($amount = 0, $from_currency = '', $to_curre return $cal_amount; } - function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { + function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true,$current_language = '') { // ASTPPCOM-857 Ashish start // Kinjal ASTPPCOM-1319 Start $current_language= $current_language == '' ? $this->session->userdata ( 'user_language' ):$current_language; // Kinjal ASTPPCOM-1319 END - $current_language=$this->session->userdata ( 'user_language' ); if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){ $amount = str_replace ( '.', ',', $amount ); }else{ @@ -295,24 +294,23 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = } $to_currency = ($to_currency == '') ? self::$global_config ['system_config'] ['base_currency'] : $to_currency; if (self::$global_config ['currency_list'] [$from_currency] > 0) { - $cal_amount = ($amount * self::$global_config ['currency_list'] [$to_currency]) / self::$global_config ['currency_list'] [$from_currency]; - - } else { + $cal_amount = str_replace(',','.',$cal_amount); + } else { $cal_amount = $amount; } + if ($format_currency) $cal_amount = $this->format_currency ( $cal_amount ); if ($append_currency) $cal_amount = $cal_amount . " " . $to_currency; // ASTPPCOM-857 Ashish start - if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){ + + if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE' )){ $cal_amount = str_replace ( '.', ',', $cal_amount ); }else{ $cal_amount = str_replace ( ',', '', $cal_amount ); } - // ASTPPCOM-857 end - return $cal_amount; } function to_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { @@ -562,4 +560,4 @@ function check_unique_data($action,$Select,$value,$tbl) { return $query; } -} +} \ No newline at end of file diff --git a/web_interface/astpp/application/modules/user/controllers/user.php b/web_interface/astpp/application/modules/user/controllers/user.php old mode 100755 new mode 100644 index 87afeb8a2..9c6e98264 --- a/web_interface/astpp/application/modules/user/controllers/user.php +++ b/web_interface/astpp/application/modules/user/controllers/user.php @@ -1063,7 +1063,7 @@ function user_invoices_list_json() $due_date = $this->common->convert_GMT_to_new('','',$value['due_date']); $from_currency = Common_model::$global_config['system_config']['base_currency']; $to_currency = $this->common->get_field_name('currency', 'currency', $accountinfo['currency_id']); - $charge_type = $this->common->get_field_name("charge_type","invoice_details",array("invoiceid"=>$value['id'])); + $charge_type = $this->common->get_field_name("charge_type","invoice_details",array("invoiceid"=>$value['id'])); if ($from_currency != $to_currency) { $outstanding = ($value['is_paid'] == 1) ? $value['debit'] - $value['credit'] : 0.00; @@ -1412,7 +1412,7 @@ function user_didlist_search() unset($action['dids.number']['number']); unset($action['dids.number']['number-string']); - } + } @@ -1978,6 +1978,7 @@ function user_fund_transfer_save() if ($accountinfo['posttoexternal'] != '1') { $data['page_title'] = gettext('Send Credit'); $post_array = $this->input->post(); + $accountinfo = $this->session->userdata('accountinfo'); $account = (array) $this->db->get_where('accounts', array( "id" => $accountinfo['id'] @@ -1999,9 +2000,7 @@ function user_fund_transfer_save() 'status' => 0, 'deleted' => 0 )); - $balance = ($account_info["posttoexternal"] == 1) ? ($account_info["credit_limit"] - $acc_balance) : ($acc_balance); - $toid = $this->common->get_field_name('id', 'accounts', array( 'number' => $post_array['toaccountid'], 'status' => 0, @@ -2021,7 +2020,6 @@ function user_fund_transfer_save() )); $balance = ($account_info["posttoexternal"] == 1) ? ($account_info["credit_limit"] - $acc_balance) : ($acc_balance); - $toid = $this->common->get_field_name('id', 'accounts', array( 'number' => $post_array['toaccountid'], 'status' => 0, @@ -2033,6 +2031,7 @@ function user_fund_transfer_save() 'deleted' => 0 ), 1)->first_row(); } + // echo $balance; die; if (! empty($toaccountinfo)) { if ($toaccountinfo['posttoexternal'] == 1) { $this->session->set_flashdata('astpp_notification', gettext('Can not trnasfer fund to postpaid customer')); @@ -2042,21 +2041,21 @@ function user_fund_transfer_save() $reseller_id = $toaccountinfo['reseller_id']; if (($toaccountinfo['type'] != 3) && ($toaccountinfo['type'] != 0)) { - $this->session->set_flashdata('astpp_notification', gettext('Access Denied! unable transfer fund to this account')); } - - $post_array['credit'] = number_format($this->common_model->add_calculate_currency($post_array['credit'], '', '', false, false), 4); - + // Kinjal ASTPPCOM-1319 Start $post_array['credit'] = number_format($this->common_model->add_calculate_currency($post_array['credit'], '', '', false, false,'en_En'), 4); // Kinjal ASTPPCOM-1319 END - $minimum_fund = (array) $this->db->get_where('system', array( "name" => "minimum_fund_transfer" ), 1)->first_row(); - $minimum_fund['value'] = number_format($this->common_model->add_calculate_currency($minimum_fund['value'], '', '', false, false), 4); + $minimum_fund['value'] = number_format($this->common_model->add_calculate_currency($minimum_fund['value'], '', '', false, false,'en_En'), 4); + // Kinjal ASTPPCOM-1319 Start + $from_currency = common_model::$global_config['system_config'] ['base_currency']; + $minimum_fund_value = number_format($this->common_model->add_calculate_currency($minimum_fund['value'],$from_currency, $currency['currency'], false, false,'en_En'), 4); + // Kinjal ASTPPCOM-1319 END if ($post_array['toaccountid'] == $account_info['number']) { $this->session->set_flashdata('astpp_notification', gettext('You can not transfer fund in same account.')); } elseif ($reseller_id != $account_info['reseller_id']) { @@ -2072,7 +2071,7 @@ function user_fund_transfer_save() } elseif ($post_array['credit'] < 0) { $this->session->set_flashdata('astpp_notification', gettext('Please enter amount greater then 0.')); } elseif ($minimum_fund['value'] > $post_array['credit']) { - $this->session->set_flashdata('astpp_notification', gettext(sprintf('You need to enter minimum %s for fund transfer. ', $minimum_fund['value']))); + $this->session->set_flashdata('astpp_notification', gettext('You need to enter minimum').' '.$minimum_fund_value.' '.gettext('for fund transfer.')); } elseif (! isset($toid) || ! isset($post_array['toaccountid'])) { $this->session->set_flashdata('astpp_notification', gettext('Please enter valid account number!')); } elseif ($post_array['credit'] < 0 || $post_array['credit'] > $balance) { @@ -2083,6 +2082,7 @@ function user_fund_transfer_save() $from['id'] = $post_array['id']; $from['account_currency'] = $post_array['account_currency']; $from['accountid'] = $post_array['fromaccountid']; + if ($account['posttoexternal'] == 1) { $from['credit'] = abs($post_array['credit']); $from['payment_type'] = '0'; @@ -2149,6 +2149,7 @@ function user_fund_transfer_save() "is_update_balance" => "true" ); $insert_payment_arr_from['is_apply_tax'] = "false"; + $this->payment->add_payments_transcation($insert_payment_arr_from, $from_account_info, $from_currency_info); $insert_payment_arr_to = array( @@ -2165,13 +2166,12 @@ function user_fund_transfer_save() "is_update_balance" => "true" ); $insert_payment_arr_to['is_apply_tax'] = "false"; + $this->payment->add_payments_transcation($insert_payment_arr_to, $to_account_info, $to_currency_info); $from_account_info['amount'] = $from['credit']; $to_account_info['to_currency'] = $this->common->get_field_name ( 'currency', 'currency', $to_account_info['currency_id']); $to_account_info['number'] = $from_account_info['number']; $to_account_info['amount'] = $from['credit']; - // $from_account_info['refillbalance'] = $from['credit']; - // $from_account_info['number'] = $to_account_info['number']; $this->common->mail_to_users('customer_refill_balance', $to_account_info); $from_account_info['number'] = $to_account_info['number']; $this->common->mail_to_users('balance_transfer', $from_account_info); @@ -2249,10 +2249,10 @@ private function check_calls_running(){ foreach ($calls as $key => $value) { $calls[$i]['presence_data'] = @$calls_final[$value['call_uuid']]['presence_data']; $livecall_data = explode("|||", $calls[$i]['presence_data']); - $account_explode=explode('(',$livecall_data[1]); + $account_explode=explode('(',$livecall_data[1]); if (isset($value['state']) && ($value['state'] == 'CS_EXCHANGE_MEDIA' || $value['state'] == 'CS_CONSUME_MEDIA') ) { if($accountinfo['number'] == rtrim($account_explode[1],')') || array_key_exists($value['initial_dest'],$sip_device_final_array)){ - $response_return=false; + $response_return=false; } } } From 0c1aa859ed3a00f06d0a1d18ad4cab964b29d0a6 Mon Sep 17 00:00:00 2001 From: sanketinx Date: Tue, 27 Dec 2022 17:21:52 +0530 Subject: [PATCH 2/5] [FIX] Balance Transferring --- .../astpp/application/models/common_model.php | 11 +++++++---- .../application/modules/user/controllers/user.php | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/web_interface/astpp/application/models/common_model.php b/web_interface/astpp/application/models/common_model.php index a95d971fd..f74823145 100644 --- a/web_interface/astpp/application/models/common_model.php +++ b/web_interface/astpp/application/models/common_model.php @@ -277,11 +277,13 @@ function calculate_currency_customer($amount = 0, $from_currency = '', $to_curre return $cal_amount; } + // ASTPPCOM-1319 Start function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true,$current_language = '') { - // ASTPPCOM-857 Ashish start - // Kinjal ASTPPCOM-1319 Start + // ASTPPCOM-1319 END + + // ASTPPCOM-857 Ashish start $current_language= $current_language == '' ? $this->session->userdata ( 'user_language' ):$current_language; - // Kinjal ASTPPCOM-1319 END + if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){ $amount = str_replace ( '.', ',', $amount ); }else{ @@ -295,7 +297,9 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = $to_currency = ($to_currency == '') ? self::$global_config ['system_config'] ['base_currency'] : $to_currency; if (self::$global_config ['currency_list'] [$from_currency] > 0) { $cal_amount = ($amount * self::$global_config ['currency_list'] [$to_currency]) / self::$global_config ['currency_list'] [$from_currency]; + // Kinjal ASTPPCOM-1319 Start $cal_amount = str_replace(',','.',$cal_amount); + // Kinjal ASTPPCOM-1319 End } else { $cal_amount = $amount; } @@ -305,7 +309,6 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = if ($append_currency) $cal_amount = $cal_amount . " " . $to_currency; // ASTPPCOM-857 Ashish start - if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE' )){ $cal_amount = str_replace ( '.', ',', $cal_amount ); }else{ diff --git a/web_interface/astpp/application/modules/user/controllers/user.php b/web_interface/astpp/application/modules/user/controllers/user.php index 9c6e98264..0c573ac78 100644 --- a/web_interface/astpp/application/modules/user/controllers/user.php +++ b/web_interface/astpp/application/modules/user/controllers/user.php @@ -2071,7 +2071,9 @@ function user_fund_transfer_save() } elseif ($post_array['credit'] < 0) { $this->session->set_flashdata('astpp_notification', gettext('Please enter amount greater then 0.')); } elseif ($minimum_fund['value'] > $post_array['credit']) { + // Kinjal ASTPPCOM-1319 Start $this->session->set_flashdata('astpp_notification', gettext('You need to enter minimum').' '.$minimum_fund_value.' '.gettext('for fund transfer.')); + // Kinjal ASTPPCOM-1319 END } elseif (! isset($toid) || ! isset($post_array['toaccountid'])) { $this->session->set_flashdata('astpp_notification', gettext('Please enter valid account number!')); } elseif ($post_array['credit'] < 0 || $post_array['credit'] > $balance) { @@ -2092,7 +2094,7 @@ function user_fund_transfer_save() } // Kinjal ASTPPCOM-1319 Start $from['credit'] = str_replace(',', '.', $from['credit']); - // Kinjal ASTPPCOM-1319 Start + // Kinjal ASTPPCOM-1319 END $from['posttoexternal'] = $account['posttoexternal']; $from['notes'] = $post_array['notes']; From 40404548a56b731ab853a9d1ce913f0b9cf39adc Mon Sep 17 00:00:00 2001 From: sanketinx Date: Tue, 27 Dec 2022 17:25:05 +0530 Subject: [PATCH 3/5] [FIX] Balance Transferring --- web_interface/astpp/application/models/common_model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_interface/astpp/application/models/common_model.php b/web_interface/astpp/application/models/common_model.php index f74823145..8a5d4c1fc 100644 --- a/web_interface/astpp/application/models/common_model.php +++ b/web_interface/astpp/application/models/common_model.php @@ -309,7 +309,7 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = if ($append_currency) $cal_amount = $cal_amount . " " . $to_currency; // ASTPPCOM-857 Ashish start - if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE' )){ + if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){ $cal_amount = str_replace ( '.', ',', $cal_amount ); }else{ $cal_amount = str_replace ( ',', '', $cal_amount ); From 2e8e2825d9bf8a565c6b34e669b2366df9f70d93 Mon Sep 17 00:00:00 2001 From: sanketinx Date: Tue, 27 Dec 2022 17:31:01 +0530 Subject: [PATCH 4/5] [FIX] Balance Transferring --- web_interface/astpp/application/models/common_model.php | 2 ++ .../astpp/application/modules/user/controllers/user.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/web_interface/astpp/application/models/common_model.php b/web_interface/astpp/application/models/common_model.php index 8a5d4c1fc..65b8a2224 100644 --- a/web_interface/astpp/application/models/common_model.php +++ b/web_interface/astpp/application/models/common_model.php @@ -314,6 +314,8 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = }else{ $cal_amount = str_replace ( ',', '', $cal_amount ); } + // ASTPPCOM-857 end + return $cal_amount; } function to_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { diff --git a/web_interface/astpp/application/modules/user/controllers/user.php b/web_interface/astpp/application/modules/user/controllers/user.php index 0c573ac78..f3537d254 100644 --- a/web_interface/astpp/application/modules/user/controllers/user.php +++ b/web_interface/astpp/application/modules/user/controllers/user.php @@ -2000,7 +2000,9 @@ function user_fund_transfer_save() 'status' => 0, 'deleted' => 0 )); + $balance = ($account_info["posttoexternal"] == 1) ? ($account_info["credit_limit"] - $acc_balance) : ($acc_balance); + $toid = $this->common->get_field_name('id', 'accounts', array( 'number' => $post_array['toaccountid'], 'status' => 0, @@ -2020,6 +2022,7 @@ function user_fund_transfer_save() )); $balance = ($account_info["posttoexternal"] == 1) ? ($account_info["credit_limit"] - $acc_balance) : ($acc_balance); + $toid = $this->common->get_field_name('id', 'accounts', array( 'number' => $post_array['toaccountid'], 'status' => 0, @@ -2031,7 +2034,6 @@ function user_fund_transfer_save() 'deleted' => 0 ), 1)->first_row(); } - // echo $balance; die; if (! empty($toaccountinfo)) { if ($toaccountinfo['posttoexternal'] == 1) { $this->session->set_flashdata('astpp_notification', gettext('Can not trnasfer fund to postpaid customer')); From 16a805c95720583b7d00319e4d8475fafe077820 Mon Sep 17 00:00:00 2001 From: sanketinx Date: Tue, 27 Dec 2022 17:37:04 +0530 Subject: [PATCH 5/5] [FIX] Balance Transferring --- web_interface/astpp/application/models/common_model.php | 7 ++----- .../astpp/application/modules/user/controllers/user.php | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/web_interface/astpp/application/models/common_model.php b/web_interface/astpp/application/models/common_model.php index 65b8a2224..a756ceb3e 100644 --- a/web_interface/astpp/application/models/common_model.php +++ b/web_interface/astpp/application/models/common_model.php @@ -280,10 +280,8 @@ function calculate_currency_customer($amount = 0, $from_currency = '', $to_curre // ASTPPCOM-1319 Start function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true,$current_language = '') { // ASTPPCOM-1319 END - // ASTPPCOM-857 Ashish start - $current_language= $current_language == '' ? $this->session->userdata ( 'user_language' ):$current_language; - + $current_language= $current_language == '' ? $this->session->userdata ( 'user_language' ):$current_language; if(isset($current_language) && ($current_language == 'es_ES' || $current_language == 'el_GR' || $current_language == 'de_DE')){ $amount = str_replace ( '.', ',', $amount ); }else{ @@ -314,8 +312,7 @@ function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = }else{ $cal_amount = str_replace ( ',', '', $cal_amount ); } - // ASTPPCOM-857 end - + // ASTPPCOM-857 end return $cal_amount; } function to_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { diff --git a/web_interface/astpp/application/modules/user/controllers/user.php b/web_interface/astpp/application/modules/user/controllers/user.php index f3537d254..63f7f1661 100644 --- a/web_interface/astpp/application/modules/user/controllers/user.php +++ b/web_interface/astpp/application/modules/user/controllers/user.php @@ -2043,18 +2043,19 @@ function user_fund_transfer_save() $reseller_id = $toaccountinfo['reseller_id']; if (($toaccountinfo['type'] != 3) && ($toaccountinfo['type'] != 0)) { + $this->session->set_flashdata('astpp_notification', gettext('Access Denied! unable transfer fund to this account')); - } - + } // Kinjal ASTPPCOM-1319 Start $post_array['credit'] = number_format($this->common_model->add_calculate_currency($post_array['credit'], '', '', false, false,'en_En'), 4); // Kinjal ASTPPCOM-1319 END + $minimum_fund = (array) $this->db->get_where('system', array( "name" => "minimum_fund_transfer" ), 1)->first_row(); - $minimum_fund['value'] = number_format($this->common_model->add_calculate_currency($minimum_fund['value'], '', '', false, false,'en_En'), 4); // Kinjal ASTPPCOM-1319 Start + $minimum_fund['value'] = number_format($this->common_model->add_calculate_currency($minimum_fund['value'], '', '', false, false,'en_En'), 4); $from_currency = common_model::$global_config['system_config'] ['base_currency']; $minimum_fund_value = number_format($this->common_model->add_calculate_currency($minimum_fund['value'],$from_currency, $currency['currency'], false, false,'en_En'), 4); // Kinjal ASTPPCOM-1319 END @@ -2153,7 +2154,6 @@ function user_fund_transfer_save() "is_update_balance" => "true" ); $insert_payment_arr_from['is_apply_tax'] = "false"; - $this->payment->add_payments_transcation($insert_payment_arr_from, $from_account_info, $from_currency_info); $insert_payment_arr_to = array(