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) {
Total commission de la banque
+Total commission de la banque
+