From cac703c271b8e38b0a7e53b66e216bb76a2ff169 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Tue, 27 Oct 2020 11:50:41 +0100 Subject: [PATCH] + Management of banks --- application/controllers/Gestion.php | 146 +++++- application/controllers/Hyperviseur_dash.php | 66 +++ application/language/english/message_lang.php | 15 + application/language/french/message_lang.php | 16 + application/models/Wallet_model.php | 43 ++ application/views/gestion_banques_admin.php | 425 ++++++++++++++++++ application/views/gestion_banques_hyp.php | 234 ++++++++++ application/views/header_gestion.php | 8 +- application/views/header_hyp.php | 6 + .../views/historique_transactions_ilink.php | 4 +- 10 files changed, 960 insertions(+), 3 deletions(-) create mode 100755 application/views/gestion_banques_admin.php create mode 100755 application/views/gestion_banques_hyp.php diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 920bbf7b..ff436426 100755 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -265,7 +265,7 @@ class Gestion extends CI_Controller $hyper = $this->session->userdata('current_hyper'); $pays = $this->session->userdata('current_pays'); - $data['list_villes'] = $this->user_model->getAllVilles(); +// $data['list_villes'] = $this->user_model->getAllVilles(); $data['pays'] = $this->user_model->getAllCountries(); $data['game_pays'] = $this->user_model->getGameCountry(); $data['alert'] = ""; @@ -2286,5 +2286,149 @@ class Gestion extends CI_Controller } } + public function banks() + { + if ($this->isLogged()) { + + $data['banks'] = $this->wallet_model->getAllBanksCountries(); + $data['pays'] = $this->user_model->getAllPays(); + $data['game_pays'] = $this->user_model->getGameCountry(); + $data['alert'] = ""; + $data['active'] = "banks"; + $data['distinct_banks'] = $this->wallet_model->getAllBanks(); + + $this->load->view('header_gestion', $data); + $this->load->view('gestion_banques_admin'); + $this->load->view('footer'); + } + + } + + public function add_bank() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $data = array( + 'nom' => $this->input->post('name'), + ); + + $query = $this->db->insert('banks', $data); + if ($query) { + echo json_encode("completed"); + } else { + echo json_encode("error"); + } + } + } + } + + public function delete_bank() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $id_bank = $this->input->post('id_bank'); + $id_country = $this->input->post('id_country'); + + $query = $this->wallet_model->deleteBankCountry($id_bank, $id_country); + if ($query) { + echo json_encode("completed"); + } else { + echo json_encode("error"); + } + } + } + } + + public function assign_bank() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $id_bank = $this->input->post('id_bank'); + $existe = 0; + $this->db->trans_begin(); + foreach ($_POST['id_country'] AS $country) { + $res = $this->wallet_model->checkIfBankAssignationExist($country, $id_bank); + if ($res == false) { + $data = array('id_country' => $country , 'id_bank' => $id_bank); + $this->db->insert('banks_countries', $data); + } else { + $existe = $existe + 1; + } + } + if ($this->db->trans_status() === FALSE) { + $this->db->trans_rollback(); + echo json_encode("error"); + } elseif ($existe > 0) { + $this->db->trans_commit(); + echo json_encode("existe"); + } else { + $this->db->trans_commit(); + echo json_encode("completed"); + } + + } + } + } + + public function update_bank() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $id_bank = $this->input->post('id_bank'); + $id_country = $this->input->post('id_country'); + $name = $this->input->post('name'); + $address = $this->input->post('address'); + + $res = $this->wallet_model->updateBank($id_bank, $id_country ,$name , $address); + + if ($res == true) { + echo json_encode("completed"); + } else { + echo json_encode("error"); + } + } + } + } + + public function change_bank_status() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $activations = $this->input->post('activations'); + $desactivation = $this->input->post('desactivations'); + + $this->db->trans_begin(); + if (!empty($_POST['activations'])) { + foreach ($_POST['activations'] AS $row) { + + $data = array('status' => 1); + $this->db->where('id_bank', $row['id_bank']); + $this->db->where('id_country', $row['id_country']); + $this->db->update('banks_countries', $data); + + } + } + if (!empty($_POST['desactivations'])) { + foreach ($_POST['desactivations'] AS $row) { + + $data = array('status' => 0); + $this->db->where('id_bank', $row['id_bank']); + $this->db->where('id_country', $row['id_country']); + $this->db->update('banks_countries', $data); + + } + } + if ($this->db->trans_status() === FALSE) { + $this->db->trans_rollback(); + echo json_encode("error"); + } else { + $this->db->trans_commit(); + echo json_encode("completed"); + } + + } + } + } + } diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 0914d622..d0a60954 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -1539,6 +1539,72 @@ class Hyperviseur_dash extends CI_Controller } } } + + public function banks() + { + + if ($this->isLogged()) { + + $data['active'] = "banks"; + $data['alert'] = ""; + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['email'] = $this->session->userdata('email'); + $data['network'] = $this->session->userdata('network'); + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['networks'] = $this->user_model->getActiveNetwork(); + $data['currency_code'] = $this->session->userdata('currency_code'); + $data['category'] = $this->session->userdata('category'); + + $data['hasWallet'] = $this->wallet_model->getConfigWallet($this->session->userdata('network_id')); + $data['banks'] = $this->wallet_model->getBanksForNetwork($this->session->userdata('network_id')); + + + $this->load->view('header_hyp', $data); + $this->load->view('gestion_banques_hyp'); + $this->load->view('footer'); + } + } + + public function active_bank() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $data = array( + 'id_bank_country' => $this->input->post('id_bank_country'), + 'id_network' => $this->input->post('id_network') + ); + + $query = $this->db->insert('networks_banks', $data); + + if ($query) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + } + + public function deactive_bank() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $data = array( + 'id_bank_country' => $this->input->post('id_bank_country'), + 'id_network' => $this->input->post('id_network') + ); + + $query = $this->db->delete('networks_banks', $data); + + if ($query) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + } } class Operation diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index a99103fa..d19b1028 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -515,4 +515,19 @@ $lang['id_identity_document'] = "Identity document number"; $lang['expiry_date_document'] = "Document expiration date"; $lang['user_image'] = "Profile picture"; $lang['users_found'] = 'users found'; +$lang['status_with_paying_network'] = "Status with the paying network"; +$lang['banks'] = 'Banks'; +$lang['bank'] = 'Bank'; +$lang['management_banks'] = "Management of banks"; +$lang['add_bank'] = "Add a bank"; +$lang['no_bank'] = "No bank"; +$lang['bank_added'] = "The bank has been added"; +$lang['bank_assigned'] = "The bank has been assigned"; +$lang['bank_modified'] = "The bank has been modified"; +$lang['bank_deleted'] = "The bank has been deleted"; +$lang['bank_activated'] = "The bank has been activated"; +$lang['bank_deactivated'] = "The bank has been deactivated"; +$lang['bank_deactivation'] = "Deactivation of the bank"; +$lang['modify_bank'] = "Modify the bank"; +$lang['assign_bank_to_country'] = "Assign a bank to a country"; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 1d249f5f..9487e363 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -527,4 +527,20 @@ $lang['id_identity_document'] = "Numero de la pièce d'identité"; $lang['expiry_date_document'] = "Date d'expiration du document"; $lang['user_image'] = "Photo de profil"; $lang['users_found'] = 'utilisateurs trouvés'; +$lang['status_with_paying_network'] = "Statut chez le réseau payeur"; +$lang['banks'] = 'Banques'; +$lang['bank'] = 'Banque'; +$lang['management_banks'] = "Gestion des banques"; +$lang['add_bank'] = "Ajouter une banque"; +$lang['no_bank'] = "Aucune banque"; +$lang['bank_added'] = "La banque a été ajoutée"; +$lang['bank_assigned'] = "La banque a été assignée"; +$lang['bank_modified'] = "La banque a été modifiée"; +$lang['bank_deleted'] = "La banque a été supprimée"; +$lang['bank_activated'] = "La banque a été activée"; +$lang['bank_deactivated'] = "La banque a été désactivée"; +$lang['bank_deactivation'] = "Désactivation de la banque"; +$lang['modify_bank'] = "Modifier la banque"; +$lang['assign_bank_to_country'] = "Assigner une banque à un pays"; + ?> diff --git a/application/models/Wallet_model.php b/application/models/Wallet_model.php index c9f28a4f..e5a5f046 100644 --- a/application/models/Wallet_model.php +++ b/application/models/Wallet_model.php @@ -861,4 +861,47 @@ INNER JOIN countries_currencies cc ON n.country_id= cc.id INNER JOIN configWalle $query = $this->db->query($sql , array($max_day_national,$max_week_national,$max_month_national,$max_day_international,$max_week_international,$max_month_international,$id_country)); return $query; } + + // Banques + public function getAllBanksCountries(){ + $query = $this->db->query("SELECT b.id, b.nom as bank_name , bc.adresse as bank_address , bc.status, c.name as country , c.id as country_id FROM banks_countries bc INNER JOIN banks b ON b.id = bc.id_bank INNER JOIN countries c ON c.id = bc.id_country"); + return $query->num_rows() > 0 ? $query : false ; + } + + public function getAllBanks(){ + $query = $this->db->query("SELECT * FROM banks"); + return $query->num_rows() > 0 ? $query : false ; + } + + public function checkIfBankAssignationExist($id_country,$id_bank){ + $query = $this->db->query("SELECT * FROM banks_countries WHERE id_country ='".$id_country."' AND id_bank='".$id_bank."'"); + return $query->num_rows() > 0 ? $query : false ; + } + + public function getBank($id_bank){ + $query = $this->db->query("SELECT * FROM banks WHERE id='".$id_bank."'"); + return $query->num_rows() > 0 ? $query : false ; + } + + public function updateBank($id_bank,$id_country, $name , $address){ + $sql = "UPDATE `banks` SET `nom` = ? WHERE (`id` = ?);"; + $this->db->query($sql , array($name,$id_bank)); + + $sql = "UPDATE `banks_countries` SET `adresse` = ? WHERE (`id_bank` = ? AND `id_country` = ?);"; + return $this->db->query($sql , array($address,$id_bank,$id_country)); + } + + public function deleteBankCountry($id_bank, $id_country){ + $sql = "DELETE FROM `banks_countries` WHERE `id_bank` = ? AND `id_country` = ?"; + $query = $this->db->query($sql, array($id_bank,$id_country)); + return $query; + } + + public function getBanksForNetwork($id_network){ + $sql = "SELECT bc.id, b.nom as bank_name , bc.adresse as bank_address, c.name as country , c.id as country_id , nb.id_network FROM networks n +CROSS JOIN banks_countries bc INNER JOIN banks b ON b.id = bc.id_bank INNER JOIN countries c ON c.id = bc.id_country +LEFT JOIn networks_banks nb ON nb.id_bank_country = bc.id AND nb.id_network = n.id WHERE bc.status = 1 AND n.id = ?"; + $query = $this->db->query($sql , array($id_network)); + return $query->num_rows() > 0 ? $query : false ; + } } diff --git a/application/views/gestion_banques_admin.php b/application/views/gestion_banques_admin.php new file mode 100755 index 00000000..e5d371b7 --- /dev/null +++ b/application/views/gestion_banques_admin.php @@ -0,0 +1,425 @@ + + +
+ +
+ +

+ lang->line('management_banks'); ?> + +

+ +
+ +

Erreur!

+ +
+ + +
+ +

Success!

+ +
+ + +
+ +
+
+
+
+
+

lang->line('banks'); ?>

+
+
+ + num_rows(); + $num = 0; + if ($numrows > 0) { + ?> + + + + + + + + + + + + + + + result() as $row) { + $num ++; + //$member_code = randomString1(10); + $libelle_status = $this->lang->line('Actif'); + if($row->status==0){ + $libelle_status = $this->lang->line('Inactif'); + } + echo " + + + + + "; + if($row->status==0){ + echo ""; + }else{ + echo ""; + } + echo " + + "; + } + ?> + +
lang->line('Pays'); ?>lang->line('Nom'); ?>lang->line('Adresse'); ?>lang->line('Statut'); ?>lang->line('Activer/Désactiver'); ?>lang->line('Modifier'); ?>lang->line('Supprimer'); ?>
$num$row->country$row->bank_name$row->bank_address$libelle_status + + + + + +
+ + lang->line('no_bank'); + } + }else { + echo $this->lang->line('no_bank'); + } + ?> +
+
+
+
+
+
+

lang->line('add_bank'); ?>

+
+
+
+
+ + +
+
+ +
+
+
+
+
+
+

lang->line('assign_bank_to_country'); ?>

+
+
+
+
+ + num_rows(); + if ($numrows > 0) { ?> + + lang->line("Aucun pays"); + } + ?> +
+
+ + num_rows(); + if ($numrows > 0) { ?> + + lang->line("no_bank"); + } + }else{ + echo $this->lang->line("no_bank"); + } + ?> +
+
+ +
+
+
+
+
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/views/gestion_banques_hyp.php b/application/views/gestion_banques_hyp.php new file mode 100755 index 00000000..6638b0f6 --- /dev/null +++ b/application/views/gestion_banques_hyp.php @@ -0,0 +1,234 @@ + + + +
+ +
+ +

+ lang->line('management_banks'); ?> +

+ +
+ +

Erreur!

+ +
+ + +
+ +

Success!

+ +
+ + +
+ +
+
+
+
+
+

lang->line('banks'); ?>

+
+
+ + num_rows(); + $num = 0; + if ($numrows > 0) { + ?> + + + + + + + + + + + + + + result() as $row) { + $num ++; + //$member_code = randomString1(10); + echo " + + + + "; + ?> + id_network){ + ?> + + + + + + + +id_network ? '?id='.$row->id_network : '')?>id_network) echo "disabled"?> +lang->line('Voir plus...'); ?> + + + + +
lang->line('Pays'); ?>lang->line('Nom'); ?>lang->line('Adresse'); ?>lang->line('Statut'); ?>lang->line('Activer/Désactiver'); ?>
$num$row->country$row->bank_name$row->bank_addresslang->line('Actif'); ?>lang->line('Inactif'); ?>
+ + lang->line('no_bank'); + } + }else { + echo $this->lang->line('no_bank'); + } + ?> +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/application/views/header_gestion.php b/application/views/header_gestion.php index be7cd173..8d64d125 100755 --- a/application/views/header_gestion.php +++ b/application/views/header_gestion.php @@ -175,7 +175,13 @@ echo "active"; } ?>"> - lang->line('regulations'); ?> + lang->line('regulations'); ?> + + + +
  • "> + + lang->line('banks'); ?>
  • diff --git a/application/views/header_hyp.php b/application/views/header_hyp.php index cd723768..5d03e5fa 100755 --- a/application/views/header_hyp.php +++ b/application/views/header_hyp.php @@ -202,6 +202,12 @@ + +
  • "> + + lang->line('banks'); ?> + +
  • "> diff --git a/application/views/historique_transactions_ilink.php b/application/views/historique_transactions_ilink.php index 7a71a6ac..b7242675 100755 --- a/application/views/historique_transactions_ilink.php +++ b/application/views/historique_transactions_ilink.php @@ -140,6 +140,7 @@ function toLocateDate($date , $timezone){ lang->line('customer_net_amount_init') ?> lang->line('customer_net_amount_final') ?> lang->line('commission_paying_network') ?> + lang->line('status_with_paying_network') ?> lang->line('final_currency') ?> lang->line('departure_country') ?> lang->line('country_of_destination') ?> @@ -183,11 +184,12 @@ function toLocateDate($date , $timezone){ $moneyNetFinal =Money::of(round($row->montant_net_final_country,2),$row->final_currency ? $row->final_currency : 'XAF',$context); echo " $row->id_transaction - " . strtoupper($row->acteur) . ' - ' . $row->operation . " + " . strtoupper($row->acteur) . ' - ' .($this->session->userdata('site_lang') === 'french' ? $row->operation_fr : $row->operation_en). " " . join(" ", str_split($row->numero_carte, 4)) . " " . $moneyNetInit->formatTo('fr_FR') . " " . $moneyNetFinal->formatTo('fr_FR') . " " . Money::of(round($row->part_reseau_payeur_final_country ? $row->part_reseau_payeur_final_country : 0, 2), $row->final_currency ? $row->final_currency : 'XAF', $context)->formatTo('fr_FR') . " + " . str_replace('_',' ',$row->status_reseau_payeur). " " . $row->final_currency . " ".$row->pays_init." ".$row->pays_final."