From ed3f6ec992cf6a08ac4e4f5f8f73cc0c5cbb09c1 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Wed, 1 Sep 2021 09:25:20 +0100 Subject: [PATCH] Add Analyis per supervisor in historique_transactions --- application/controllers/Hyperviseur_dash.php | 65 +++++- application/language/english/message_lang.php | 6 +- application/language/french/message_lang.php | 4 + application/models/User_model.php | 5 + .../pagination/WalletTransaction_model.php | 6 + application/views/historique_transactions.php | 189 +++++++++++++++++- 6 files changed, 262 insertions(+), 13 deletions(-) diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 47a83956..9cea6f0d 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -398,7 +398,7 @@ class Hyperviseur_dash extends CI_Controller if ($data['hasWallet']) { if ($this->input->get('history')) { - $this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->input->get('history')); + $this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->input->get('history'), $this->input->get('parrainId')); } elseif ($this->input->get('config')) { $this->config_wallet($this->input->get('config'), $this->input->get('country')); } elseif ($this->input->get('show')) { @@ -520,7 +520,7 @@ class Hyperviseur_dash extends CI_Controller return true; } - private function historique($network_id, $startDate, $endDate, $type) + private function historique($network_id, $startDate, $endDate, $type , $parrainId = null) { $data['configWallet'] = $this->wallet_model->getConfigWallet($network_id); $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; @@ -545,8 +545,11 @@ class Hyperviseur_dash extends CI_Controller $data['refunds'] = $this->wallet_model->getRefunds($startDate, $endDate, $network_id); else if ($type == 'commission_payments') $data['payments'] = $this->wallet_model->getCommissionPayments($startDate, $endDate, $network_id); - else + else{ $data['transactions'] = $this->wallet_model->getRecharges($startDate, $endDate, $network_id); + $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); + $data['parrain'] = isset($parrainId) ? $this->user_model->getAgentInfos($parrainId) : null ; + } $data['active'] = "wallet_wallet"; $data['alert'] = ""; @@ -561,6 +564,7 @@ class Hyperviseur_dash extends CI_Controller $data['country'] = $this->session->userdata('current_pays'); $data['category'] = $this->session->userdata('category'); $data['id_network'] = $network_id; + $data['parrain_id'] = $parrainId; $this->load->view('header_hyp', $data); if ($type == 'transaction') @@ -582,6 +586,61 @@ class Hyperviseur_dash extends CI_Controller $this->load->view('footer'); } + public function export(){ + if ($this->isLogged()) { + if (isset($_POST)) { + + $parrain_id = $this->input->post('parrain_id'); + $start = date('Y-m-d', strtotime($this->input->post('start'))); + $end = date('Y-m-d', strtotime($this->input->post('end'). "+1 day")); + + $config = $this->wallet_model->getConfigWallet($this->session->userdata('network_id'))->first_row(); + + $sql = "SELECT id, type_transac, numCarte, montant, 0 as bank_deposit , commission_banque, commission_hyp, commission_sup, commission_ag, + agent,parrain,date_created FROM infos_transaction WHERE deleted = 0 AND parrain_id = ? AND date_created >= ? AND date_created < ? ORDER BY agent ASC"; + $query = $this->db->query($sql, array($parrain_id,$start,$end)); + + $data = [['ID', 'Type' , $this->lang->line('cart_number'),$this->lang->line('customer_net_amount'),$this->lang->line('bank_deposit_amount'), + $this->lang->line('Commission de la banque'),$this->lang->line('Commission de l\'hyperviseur'),$this->lang->line('Commission du superviseur'), + $this->lang->line('Commission de l\'agent'),$this->lang->line('agent_name'),$this->lang->line('Superviseur'),'Date']]; + + $oldAgent = ''; + foreach ($query->result() as $r){ + if($oldAgent != $r->agent) + array_push($data,[]); + + $row = []; + + if($r->type_transac == 'credit'){ + if($r->montant < 0){ + $commission = (-$r->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot; + $net = $r->montant + $commission; + }else{ + $commission = ( $r->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot; + $net = $r->montant - $commission; + } + $r->bank_deposit = $r->montant * (1 - ($config->taux_com_client_depot / 100)); + }else{ + $net = $r->montant ; + } + $r->montant = $net; + $r->commission_banque = intval($r->commission_banque); + $r->numCarte = join(" ", str_split($r->numCarte, 4)); + + foreach ($r as $k => $val){ + if($k == 'type_transac'){ + array_push($row,$val =='credit' ? $this->lang->line('DEPOT') : $this->lang->line('RETRAIT')); + } else + array_push($row,$val); + } + array_push($data,$row); + $oldAgent = $r->agent; + } + echo json_encode($data); + } + } + } + public function delete_wallet_transaction(){ if ($this->isLogged()) { $datetime = $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id')); diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 889c657e..cd34795a 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -624,5 +624,9 @@ $lang['steps_map_loading'] = "Number of agents geolocated by steps on the map"; $lang['sms_notifications'] = "SMS notifications"; $lang['advertising'] = "Advertising"; $lang['registration_date'] = "Registration date"; -$lang['sponsor'] = 'Sponsor' +$lang['sponsor'] = 'Sponsor'; +$lang['analysis_by_supervisor'] ="Analysis by supervisor"; +$lang['press_here_to_see_selection'] = "Press here to see the selection"; +$lang['show_selection'] = "Show selection"; +$lang['cancel_selection'] = "Cancel selection"; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 695b0065..3853d05b 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -637,4 +637,8 @@ $lang['sms_notifications'] = "Notifications par SMS"; $lang['advertising'] = "Publicité"; $lang['registration_date'] = "Date d'inscription"; $lang['sponsor'] = 'Parrain'; +$lang['analysis_by_supervisor'] ="Analyse par superviseur"; +$lang['press_here_to_see_selection'] = "Appuyer ici pour voir la sélection"; +$lang['show_selection'] = "Afficher la selection"; +$lang['cancel_selection'] = "Annuler la selection"; ?> diff --git a/application/models/User_model.php b/application/models/User_model.php index b9689136..7e28b652 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -2644,4 +2644,9 @@ class User_model extends CI_Model $query = $this->db->query("SELECT na.phone from networks_agents na WHERE na.id <> '$id_network_agent' AND (na.phone ='$phone' OR na.transactionNumber ='$phoneTransaction')"); return $query->num_rows() ; } + + public function getAgentInfos($id_agent){ + $query = $this->db->query("SELECT * FROM agents WHERE id ='".$id_agent."'"); + return $query->num_rows()>0 ? $query->first_row() : false; + } } diff --git a/application/models/pagination/WalletTransaction_model.php b/application/models/pagination/WalletTransaction_model.php index f46e680d..b05206f7 100644 --- a/application/models/pagination/WalletTransaction_model.php +++ b/application/models/pagination/WalletTransaction_model.php @@ -38,6 +38,9 @@ class WalletTransaction_model extends CI_Model { $this->db->from($this->table); $this->db->where('network_id', $postData['id_network']); + if(!empty($postData['parrain_id'])){ + $this->db->where('parrain_id', $postData['parrain_id']); + } return $this->db->count_all_results(); } @@ -62,6 +65,9 @@ class WalletTransaction_model extends CI_Model $this->db->from($this->table); $this->db->where('deleted', 0); $this->db->where('network_id', $postData['id_network']); + if(!empty($postData['parrain_id'])){ + $this->db->where('parrain_id', $postData['parrain_id']); + } if (strlen($postData['startDate']) > 0 && strlen($postData['endDate']) > 0) { $this->db->where('date_created >=', date('Y-m-d', strtotime($postData['startDate']))); $this->db->where('date_created <', date('Y-m-d', strtotime($postData['endDate']. "+1 day"))); diff --git a/application/views/historique_transactions.php b/application/views/historique_transactions.php index 8c16527a..260b753f 100755 --- a/application/views/historique_transactions.php +++ b/application/views/historique_transactions.php @@ -5,12 +5,43 @@ + +

- lang->line('Gestion des wallets') ; echo ' '.$network.' - '.$country; ?> + lang->line('Gestion des wallets') ; echo ' '.$network.' - '.$country.(isset($parrain) ? ' :: POS de '.$parrain->lastname : ''); ?>

@@ -59,15 +90,64 @@
- + session->userdata('category') != 'super') { ?> +
+
+
+

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

+
+
+
+ +
+
+
+ num_rows(); + if ($numrows > 0) { ?> + + lang->line('Aucun agent'); + } + }else{ + echo $this->lang->line('Aucun agent'); + } + ?> +
+
+
+ +
+ +
+
+
+
+
+ +
-

lang->line('Historique des transactions') ?>

+

lang->line('Historique des transactions').(isset($parrain) ? ' :: POS de '.$parrain->lastname : '') ?>

session->userdata('category') != 'super') { ?>
+ + + lang->line('deleted_transactions'); ?> @@ -116,6 +196,13 @@
+ +
+
+ Loading +

Chargement

+
+
@@ -149,9 +236,22 @@ + + + +