diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 9e66242e..ec0acb72 100755 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -1541,6 +1541,7 @@ class Gestion extends CI_Controller $this->historique($network_id,$this->input->get('d'),$this->input->get('f'),$this->input->get('history')); }else{ $taux = $this->user_model->getTaux($network_id); + $data['currency'] = $this->user_model->getCurrency($network_id); if ($taux != null) { $taux = $taux->first_row(); $data['idConfig'] = $taux->id; diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 50a24a85..a666c4ce 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -1,6 +1,11 @@ session->userdata('currency_code'))->formatTo('fr_FR'); } @@ -419,9 +424,10 @@ class Hyperviseur_dash extends CI_Controller } $row = $res->first_row(); - $data["commission"] = $row->balance_com; - $data["principal"] = $row->balance_princ; + $data["commission"] = Money::of($row->balance_com, $this->session->userdata('currency_code'))->formatTo('fr_FR'); + $data["principal"] = Money::of($row->balance_princ, $this->session->userdata('currency_code'))->formatTo('fr_FR'); $data['wallet_id'] = $row->wallet_id; + $data['curreny_code'] = $this->session->userdata('currency_code'); $res = $this->user_model->getWalletPassword($id_network); @@ -929,23 +935,25 @@ class Hyperviseur_dash extends CI_Controller function calculateFees1(array $paliers, $montant) { $size = sizeof($paliers); - $min = $paliers[0]->min; - $max = $size > 0 ? $paliers[$size - 1]->max : 0; - $palier = null; - foreach ($paliers as $p) { - if ($montant >= $p->min && $montant <= $p->max) { - $palier = $p; - break; + if($size > 0){ + $min = $paliers[0]->min; + $max = $size > 0 ? $paliers[$size - 1]->max : 0; + $palier = null; + foreach ($paliers as $p) { + if ($montant >= $p->min && $montant <= $p->max) { + $palier = $p; + break; + } } - } - if ($palier) { - return (($palier->min + $palier->max) / 2 * $palier->taux / 100); - } else { - if ($montant < $min) - return $min * $paliers[0]->taux / 100; - else if ($montant > $max) - return $max * $paliers[$size - 1]->taux / 100; + if ($palier) { + return (($palier->min + $palier->max) / 2 * $palier->taux / 100); + } else { + if ($montant < $min) + return $min * $paliers[0]->taux / 100; + else if ($montant > $max) + return $max * $paliers[$size - 1]->taux / 100; + } } } diff --git a/application/controllers/Users.php b/application/controllers/Users.php index 774a02cc..50f00a9d 100755 --- a/application/controllers/Users.php +++ b/application/controllers/Users.php @@ -89,6 +89,7 @@ $this->session->set_userdata('lastname', $data->lastname); $this->session->set_userdata('adresse', $data->adresse); $this->session->set_userdata('agent_id', $data->agent_id); + $this->session->set_userdata('currency_code', $data->currency_code); if($user_login['user_role']==1){ $this->session->set_userdata('country', $data->country); diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 61b5ba7c..d72bc9c3 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -396,4 +396,10 @@ $lang ['sharing_updated'] = 'Sharing rate updated'; $lang ['not_defined'] = 'Not defined'; $lang ['no_network'] = 'No network'; $lang ['activated_countries'] = 'Countries activated'; +$lang ['paying_networks_accounts'] = 'Paying network accounts'; +$lang ['user_name'] = 'User name'; +$lang ['fees'] = 'Fees'; +$lang ['tax'] = 'Tax'; +$lang ['customer_net_amount_init'] = 'Net customer amount from the country of departure'; +$lang ['customer_net_amount_final'] = 'Net customer amount from the country of arrival'; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 2c5d5a25..34b58107 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -412,4 +412,6 @@ $lang['paying_networks_accounts'] = 'Comptes des reseaux payeurs'; $lang['user_name'] = 'Nom de l\'utilisateur'; $lang['fees'] = 'Frais'; $lang['tax'] = 'Taxe'; +$lang['customer_net_amount_init'] = 'Montant net client du pays de départ'; +$lang['customer_net_amount_final'] = 'Montant net client du pays d\'arrivée'; ?> diff --git a/application/models/User_model.php b/application/models/User_model.php index b388a6ca..5a8876bd 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -2498,7 +2498,7 @@ class User_model extends CI_Model } public function getPayingNetworksByConfigWallet($id_config){ - $query = $this->db->query("SELECT n.name , n.id , cw.type , c.name as country , pw.taux_partage as rate , pw.balance_com FROM networks n INNER JOIN countries c ON n.country_id=c.id + $query = $this->db->query("SELECT n.name , n.id , cw.type , c.name as country ,c.currency_code, pw.taux_partage as rate , pw.balance_com FROM networks n INNER JOIN countries_currencies c ON n.country_id=c.id INNER JOIN configWallet cw ON cw.id_network = n.id INNER JOIN paying_networks pw ON pw.id_network = n.id WHERE n.id IN ( SELECT id_network FROM paying_networks pw WHERE id_configWallet = $id_config )"); if($query->num_rows()>0){ return $query; @@ -2529,4 +2529,14 @@ class User_model extends CI_Model return false; } } + + public function getCurrency($id_network){ + $query = $this->db->query("SELECT cc.currency_code as code FROM networks n INNER JOIN countries_currencies cc ON cc.id = n.country_id + WHERE n.id = '".$id_network."'"); + if($query->num_rows()>0){ + return $query->first_row(); + }else{ + return false; + } + } } diff --git a/application/views/gestion_wallet_autre.php b/application/views/gestion_wallet_autre.php index c17e06af..0d6d5911 100755 --- a/application/views/gestion_wallet_autre.php +++ b/application/views/gestion_wallet_autre.php @@ -7,6 +7,7 @@ href=""> db->query("SELECT * FROM infos_transaction AND date_created BETWEEN '" . $startDate . "' AND '" . $endDate . "' AND type_transac='credit'"); -if ($transactions != false) { - $transac = $transactions->num_rows(); - $array_transac = array(); - $num = 0; - if ($transac > 0) { - foreach ($transactions->result() as $row) { - $num++; - $array_transac[] = $row->type_transac; - } - $vals_transac = array_count_values($array_transac); - $pieChart = array(); - foreach (array_keys($vals_transac) as $paramName) { - $color = dechex(rand(0x000000, 0xFFFFFF)); - $trash = array("value" => $vals_transac[$paramName], - "color" => "#" . $color, - "highlight" => "#" . $color, - "label" => $paramName); - - $pieChart[] = $trash; - } - } -} else { - $pieChart = array(); -} +//if ($transactions != false) { +// $transac = $transactions->num_rows(); +// $array_transac = array(); +// $num = 0; +// if ($transac > 0) { +// foreach ($transactions->result() as $row) { +// $num++; +// $array_transac[] = $row->type_transac; +// } +// $vals_transac = array_count_values($array_transac); +// $pieChart = array(); +// foreach (array_keys($vals_transac) as $paramName) { +// $color = dechex(rand(0x000000, 0xFFFFFF)); +// $trash = array("value" => $vals_transac[$paramName], +// "color" => "#" . $color, +// "highlight" => "#" . $color, +// "label" => $paramName); +// +// $pieChart[] = $trash; +// } +// } +//} else { +// $pieChart = array(); +//} $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); ?> @@ -174,7 +175,7 @@ $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL );
-

format($commission); ?>FCFA

+

code : 'XAF')->formatTo('fr_FR'); ?>

lang->line('Solde Commission') ?>

diff --git a/application/views/gestion_wallet_ilink.php b/application/views/gestion_wallet_ilink.php index 6f4ecb04..7f24b0ff 100755 --- a/application/views/gestion_wallet_ilink.php +++ b/application/views/gestion_wallet_ilink.php @@ -7,6 +7,7 @@ href=""> " . $walletHyper->first_row()->lastname . " - " . $fmt->format($walletHyper->first_row()->balance_princ) . " - " . $fmt->format($walletHyper->first_row()->balance_com) . " - " . $fmt->format($totalCommissionBanque) . ""; + " . Money::of($walletHyper->first_row()->balance_princ, $currency ? $currency->code : 'XAF')->formatTo('fr_FR'). " + " .Money::of($walletHyper->first_row()->balance_com, $currency ? $currency->code : 'XAF')->formatTo('fr_FR'). " + " .Money::of($totalCommissionBanque, $currency ? $currency->code : 'XAF')->formatTo('fr_FR') . ""; echo "" . $depots->num_rows() . " " . $retraits->num_rows() . " diff --git a/application/views/gestion_wallet_ilink_hyp.php b/application/views/gestion_wallet_ilink_hyp.php index f534aae3..4bd84932 100755 --- a/application/views/gestion_wallet_ilink_hyp.php +++ b/application/views/gestion_wallet_ilink_hyp.php @@ -92,6 +92,7 @@ }
-

format($principal); ?>FCFA

+

lang->line('Solde Principal') ?>

@@ -273,7 +274,7 @@
-

format($commission); ?>FCFA

+

lang->line('Solde Commission') ?>

@@ -285,7 +286,7 @@
-

format($totalCommissionBanque); ?>FCFA

+

lang->line('Total commission de la banque') ?>

@@ -993,7 +994,6 @@ result() as $row) { $wallet = null; @@ -1011,8 +1011,8 @@ } echo " ".$row->lastname." - ".$fmt->format($princ)." - ".$fmt->format($com).""; + ".Money::of($princ, $this->session->userdata('currency_code'))->formatTo('fr_FR')." + ".Money::of($com, $this->session->userdata('currency_code'))->formatTo('fr_FR').""; $nb_depots = 0; $nb_retraits = 0; $commission_banque = 0; @@ -1028,7 +1028,7 @@ $commission_banque+= $retrait->commission_banque; } } - echo "".$fmt->format($commission_banque)." + echo "".Money::of($commission_banque, $this->session->userdata('currency_code'))->formatTo('fr_FR')." ".$nb_depots." ".$nb_retraits." "; diff --git a/application/views/gestion_wallet_ilink_paying_network_account.php b/application/views/gestion_wallet_ilink_paying_network_account.php index 157f09b7..7afb9672 100755 --- a/application/views/gestion_wallet_ilink_paying_network_account.php +++ b/application/views/gestion_wallet_ilink_paying_network_account.php @@ -11,6 +11,7 @@ lang->line('paying_networks_accounts')?> - format($row->balance_com)?> + balance_com, $row->currency_code ? $row->currency_code : 'XAF')->formatTo('fr_FR')?> db->hostname . ';dbname=' . $this->db->database, $this->db->username, $this->db->password); + + $configuration = new PDOProviderConfiguration(); + + $configuration->tableName = 'exchange_rate'; + $configuration->exchangeRateColumnName = 'exchange_rate'; + $configuration->targetCurrencyColumnName = 'target_currency'; + $configuration->sourceCurrencyCode = $baseCurrency; + + // this provider loads exchange rates from your database + $provider = new PDOProvider($pdo, $configuration); + + // this provider calculates exchange rates relative to the base currency + $provider = new BaseCurrencyProvider($provider, $baseCurrency); + + // this currency converter can now handle any currency pair + $converter = new CurrencyConverter($provider); ?>
@@ -93,7 +121,8 @@ Type Operation lang->line('cart_number') ?> - lang->line('customer_net_amount') ?> + lang->line('customer_net_amount_init') ?> + lang->line('customer_net_amount_final') ?> lang->line('fees') ?> lang->line('tax') ?> lang->line('Commission de la banque') ?> @@ -124,18 +153,21 @@ }else{ $net = $row->montant_retrait ; } + $moneyNetInit = Money::of($net, $row->init_currency ); + $moneyNetFinal = $converter->convert($moneyNetInit, $row->final_currency ? $row->final_currency : 'XAF', RoundingMode::DOWN); echo " $row->id ".strtoupper($type)." ".strtoupper($row->acteur).' - '.$row->operation." ".join(" ", str_split($row->numero_carte, 4))." - ".$fmt->format($net)." - ".$fmt->format( $row->frais)." - ".$fmt->format( $row->taxe)." - ".$fmt->format( $row->commission_banque)." - ".$fmt->format( $row->commission_hyp)." - ".$fmt->format( $row->commission_sup)." - ".$fmt->format( $row->commission_ag)." + ".$moneyNetInit->formatTo('fr_FR')." + ".$moneyNetFinal->formatTo('fr_FR')." + ".Money::of($row->frais, $row->init_currency)->formatTo('fr_FR')." + ".Money::of($row->taxe, $row->init_currency)->formatTo('fr_FR')." + ".Money::of($row->commission_banque ? $row->commission_banque : 0, $row->init_currency)->formatTo('fr_FR')." + ".Money::of($row->commission_hyp ? $row->commission_hyp : 0, $row->init_currency)->formatTo('fr_FR')." + ".Money::of($row->commission_sup ? $row->commission_sup : 0 , $row->init_currency)->formatTo('fr_FR')." + ".Money::of($row->commission_ag ? $row->commission_ag : 0, $row->init_currency)->formatTo('fr_FR')." ".$row->agent." ".$row->user." ".toLocateDate($row->date,$this->session->userdata('timezone')).""; @@ -205,7 +237,7 @@ $('#transactions').DataTable({ "aaSorting": [[ 0, "desc" ]], "columnDefs": [ { - targets: 13, + targets: 14, render: $.fn.dataTable.render.moment( 'YYYY-MM-DD HH:mm:ss' , 'D MMMM YYYY HH:mm:ss', format) }] });