From a44199c01631e67bd86b6d0dece0d61dae511e50 Mon Sep 17 00:00:00 2001 From: DJERY-TOM Date: Sun, 19 Apr 2020 09:51:28 +0100 Subject: [PATCH] + Add comission banque --- application/controllers/Gestion.php | 24 ++++++++++----- application/controllers/Hyperviseur_dash.php | 13 +++++++- application/controllers/Superviseur_dash.php | 13 +++++++- application/models/User_model.php | 2 +- application/views/gestion_wallet.php | 7 ++++- application/views/gestion_wallet_hyp.php | 29 ++++++++++++++---- application/views/gestion_wallet_sup.php | 31 ++++++++++++++++---- application/views/gestion_wallets.php | 22 +++++++------- 8 files changed, 107 insertions(+), 34 deletions(-) diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 51770e9d..59b5b6e9 100644 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -1560,6 +1560,13 @@ class Gestion extends CI_Controller $data['taux_bq_r'] = $taux->part_banque_retrait; $data['frais_d'] = $taux->frais_min_banque_depot; $data['transactions'] = $this->user_model->getTransactions($network_id); + $totalCommissionBanque = 0; + if($data['transactions']){ + foreach ($data['transactions']->result() as $row) { + $totalCommissionBanque += $row->commission_banque; + } + } + $data['totalCommissionBanque'] = $totalCommissionBanque ; } else { $data["taux_client_r"] = "N/A"; @@ -1571,6 +1578,7 @@ class Gestion extends CI_Controller $data['taux_bq_d'] = "N/A"; $data['taux_bq_r'] = "N/A"; $data['frais_d'] = "N/A"; + $data['totalCommissionBanque'] = "N/A"; $data["transactions"] = false; } @@ -1620,6 +1628,8 @@ class Gestion extends CI_Controller if($method == 'create') { $res = $this->user_model->addConfigWallet($network_id , $taux_client_r , $taux_client_d , $taux_ag_r ,$taux_ag_d , $taux_sup_r , $taux_sup_d, $taux_bq_r , $taux_bq_d , $frais_d); + if($res) + $this->generateAllWallets($network_id); } else if($method = 'update'){ @@ -1666,11 +1676,11 @@ class Gestion extends CI_Controller return true; } - public function generateAllWallets(){ - if($this->isLogged()) { - if (isset($_POST)) { - - $network_id = $_POST['network_id']; + public function generateAllWallets($network_id){ +// if($this->isLogged()) { +// if (isset($_POST)) { +// +// $network_id = $_POST['network_id']; // Fetch all agents , hyperviseur , superviseur $f_agents = $this->user_model->getAllAgentsForNetwork($network_id) ; if ($f_agents){ @@ -1686,8 +1696,8 @@ class Gestion extends CI_Controller } } - } - } +// } +// } } diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index d1689016..5bf5f4fa 100644 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -289,6 +289,14 @@ class Hyperviseur_dash extends CI_Controller $agent_id = $this->session->userdata('agent_id'); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); + //Create wallet if it not exist + $res = $this->user_model->getWallet($agent_id ); + if($res == false){ + if($data['hasWallet']){ + $this->user_model->addWallet($agent_id ); + } + } + $res = $this->user_model->getWallet($agent_id); if ($res!=null){ $row = $res->first_row(); @@ -298,6 +306,7 @@ class Hyperviseur_dash extends CI_Controller //Fetch all transactions of any geolocated agent of the network $data["transactions"] = array(); + $totalCommissionBanque = 0; if($agents_g){ foreach($agents_g->result() AS $row){ $wallet = $this->user_model->getWallet($row->agent_id); @@ -305,6 +314,7 @@ class Hyperviseur_dash extends CI_Controller $transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id); if($transactions){ foreach($transactions->result() AS $trans){ + $totalCommissionBanque += $trans->commission_banque; $trans->code_parrain = $row->code_parrain ; // Add code parrain to transaction array_push( $data['transactions'], $trans); } @@ -312,10 +322,11 @@ class Hyperviseur_dash extends CI_Controller } } } - + $data["totalCommissionBanque"] = $totalCommissionBanque; }else{ $data["commission"] = "N/A"; $data["principal"] = "N/A"; + $data["totalCommissionBanque"] = "N/A"; $data["transactions"] = false; } diff --git a/application/controllers/Superviseur_dash.php b/application/controllers/Superviseur_dash.php index 8c0b5566..7111ac35 100644 --- a/application/controllers/Superviseur_dash.php +++ b/application/controllers/Superviseur_dash.php @@ -183,6 +183,14 @@ class Superviseur_dash extends CI_Controller $agent_id = $this->session->userdata('agent_id'); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); + //Create wallet if it not exist + $res = $this->user_model->getWallet($agent_id ); + if($res == false){ + if($data['hasWallet']){ + $this->user_model->addWallet($agent_id ); + } + } + $res = $this->user_model->getWallet($agent_id); if ($res!=null){ $row = $res->first_row(); @@ -193,6 +201,7 @@ class Superviseur_dash extends CI_Controller //Fetch all transactions of any geolocated agent of the network $data["transactions"] = array(); + $totalCommissionBanque = 0; if($agents_g){ foreach($agents_g->result() AS $row){ $wallet = $this->user_model->getWallet($row->agent_id); @@ -200,6 +209,7 @@ class Superviseur_dash extends CI_Controller $transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id); if($transactions){ foreach($transactions->result() AS $trans){ + $totalCommissionBanque += $trans->commission_banque; $trans->agent_id = $row->agent_id ; // Add agent id to transaction array_push( $data['transactions'], $trans); } @@ -207,10 +217,11 @@ class Superviseur_dash extends CI_Controller } } } - + $data["totalCommissionBanque"] = $totalCommissionBanque; }else{ $data["commission"] = "N/A"; $data["principal"] = "N/A"; + $data["totalCommissionBanque"] = "N/A"; $data["transactions"] = false; } diff --git a/application/models/User_model.php b/application/models/User_model.php index 9c8eb59e..8f0b8db9 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -1849,7 +1849,7 @@ class User_model extends CI_Model } public function getTransactions($id_network){ - $query = $this->db->query("SELECT id,type_transac + $query = $this->db->query("SELECT id,type_transac , commission_banque FROM infos_transaction WHERE `network_id`=".$id_network); if($query->num_rows()>0){ diff --git a/application/views/gestion_wallet.php b/application/views/gestion_wallet.php index 90ada2c9..cef5abbf 100644 --- a/application/views/gestion_wallet.php +++ b/application/views/gestion_wallet.php @@ -304,6 +304,9 @@ if ($transactions != false) {

Retraits et dépots des 12 derniers moislang->line('Souscription des 12 derniers mois'); ?>

+
@@ -336,6 +339,7 @@ if ($transactions != false) { Nom Solde Princ. Solde Com. + Com. Banque Dépots Retraits @@ -346,7 +350,8 @@ if ($transactions != false) { echo " " . $walletHyper->first_row()->lastname . " " . $walletHyper->first_row()->balance_princ . " - " . $walletHyper->first_row()->balance_com . ""; + " . $walletHyper->first_row()->balance_com . " + " . $totalCommissionBanque . ""; echo "" . $depots->num_rows() . " " . $retraits->num_rows() . " diff --git a/application/views/gestion_wallet_hyp.php b/application/views/gestion_wallet_hyp.php index 21ba4681..c89f9de7 100644 --- a/application/views/gestion_wallet_hyp.php +++ b/application/views/gestion_wallet_hyp.php @@ -81,7 +81,8 @@ $retraits = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){ $date = strtotime($trans->date); - return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ; +// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ; + return $trans->type == 'debit' ; }); /** @@ -101,7 +102,8 @@ } $depots = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){ $date = strtotime($trans->date); - return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ; +// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ; + return $trans->type == 'credit' ; }); if($transactions!=false){ @@ -179,7 +181,6 @@
-
@@ -193,10 +194,21 @@
- - + +
+
+
+

FCFA

+

Total commission de la banque

+
+
+ +
+
+
+
@@ -232,6 +244,7 @@ Nom Solde Princ. Solde Com. + Com. Banque Dépots Retraits @@ -260,17 +273,21 @@ ".$com.""; $nb_depots = 0; $nb_retraits = 0; + $commission_banque = 0; foreach($depots as $depot){ if($depot->code_parrain == $row->member_code) { $nb_depots ++; + $commission_banque+= $depot->commission_banque; } } foreach($retraits as $retrait){ if($retrait->code_parrain == $row->member_code) { $nb_retraits ++; + $commission_banque+= $retrait->commission_banque; } } - echo "".$nb_depots." + echo "".$commission_banque." + ".$nb_depots." ".$nb_retraits." "; } diff --git a/application/views/gestion_wallet_sup.php b/application/views/gestion_wallet_sup.php index b84f3c51..0ba0890f 100644 --- a/application/views/gestion_wallet_sup.php +++ b/application/views/gestion_wallet_sup.php @@ -81,7 +81,9 @@ $retraits = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){ $date = strtotime($trans->date); - return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ; +// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ; + return $trans->type == 'debit' ; + }); /** @@ -101,7 +103,9 @@ } $depots = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){ $date = strtotime($trans->date); - return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ; +// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ; + return $trans->type == 'credit' ; + }); if($transactions!=false){ @@ -178,7 +182,6 @@
-
@@ -191,10 +194,21 @@
- -
+ +
+
+
+

FCFA

+

Total commission de la banque

+
+
+ +
+
+
+
@@ -230,6 +244,7 @@ Nom Solde Princ. Solde Com. + Com. Banque Dépots Retraits @@ -258,17 +273,21 @@ ".$com.""; $nb_depots = 0; $nb_retraits = 0; + $commission_banque = 0; foreach($depots as $depot){ if($depot->agent_id == $row->agent_id) { $nb_depots ++; + $commission_banque+= $depot->commission_banque; } } foreach($retraits as $retrait){ if($retrait->agent_id == $row->agent_id) { $nb_retraits ++; + $commission_banque+= $retrait->commission_banque; } } - echo "".$nb_depots." + echo "".$commission_banque." + ".$nb_depots." ".$nb_retraits." "; } diff --git a/application/views/gestion_wallets.php b/application/views/gestion_wallets.php index 689db51f..406d8c63 100755 --- a/application/views/gestion_wallets.php +++ b/application/views/gestion_wallets.php @@ -281,17 +281,17 @@ console.log(resultat+" "+error ); } }).done(function () { - $.ajax({ - url : '', - type : 'POST', - dataType : 'json', - data : {"network_id": network_id}, - timeout : 0, - async : true , - success : function () { - console.log("All wallets are generated"); - } - }); + //$.ajax({ + // url : '//', + // type : 'POST', + // dataType : 'json', + // data : {"network_id": network_id}, + // timeout : 0, + // async : true , + // success : function () { + // console.log("All wallets are generated"); + // } + //}); }); }