From 75f13c8af0aef26078c918846fff99641c4deddd Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Thu, 17 Dec 2020 09:28:53 +0100 Subject: [PATCH] + Deleting wallet transactions --- application/controllers/Gestion.php | 8 +- application/controllers/Hyperviseur_dash.php | 32 +- .../pagination/WalletTransaction.php | 78 +++++ application/language/english/message_lang.php | 7 +- application/language/french/message_lang.php | 7 +- application/models/User_model.php | 12 + application/models/Wallet_model.php | 13 - .../pagination/WalletTransaction_model.php | 100 ++++++ .../views/demande_credit_annulation.php | 31 -- application/views/historique_transactions.php | 232 +++++++++---- .../views/historique_transactions_deleted.php | 311 ++++++++++++++++++ .../views/historique_transactions_ilink.php | 3 +- 12 files changed, 708 insertions(+), 126 deletions(-) create mode 100755 application/controllers/pagination/WalletTransaction.php create mode 100644 application/models/pagination/WalletTransaction_model.php create mode 100755 application/views/historique_transactions_deleted.php diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 720c3b06..5b2adb82 100755 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -1903,11 +1903,7 @@ class Gestion extends CI_Controller $data['startDate'] = $startDate ? date($format, strtotime($startDate)) : null ; $data['endDate'] = $endDate ?date($format, strtotime($endDate)): null ; $endDate = Date('Y-m-d', strtotime($endDate."+1 day")); - if ($type == 'transaction') - $data['transactions'] = $this->user_model->getTransactions($startDate, $endDate, $network_id); - else if ($type == 'transaction_ilink') - $data['transactions'] = $this->wallet_model->getIlinkTransactions($startDate, $endDate, $network_id); - else + if ($type == 'recharge') $data['transactions'] = $this->wallet_model->getRecharges($startDate, $endDate, $network_id); $data['active'] = "wallet"; @@ -1926,6 +1922,8 @@ class Gestion extends CI_Controller $this->load->view('header_gestion', $data); if ($type == 'transaction') $this->load->view('historique_transactions'); + else if ($type == 'deleted_transactions') + $this->load->view('historique_transactions_deleted'); else if ($type == 'transaction_ilink') $this->load->view('historique_transactions_ilink'); else diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 3b853e96..61867889 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -527,14 +527,13 @@ class Hyperviseur_dash extends CI_Controller $data['startDate'] = $startDate ? date($format, strtotime($startDate)) : null; $data['endDate'] = $endDate ? date($format, strtotime($endDate)) : null; $endDate = Date('Y-m-d', strtotime($endDate . "+1 day")); - if ($type == 'transaction') - $data['transactions'] = $this->user_model->getTransactions($startDate, $endDate, $network_id); - else if ($type == 'transaction_ilink') { + if ($type == 'transaction_ilink') { $networkDetails = $this->user_model->getNetworkDetails($network_id); $data['currency_name_fr'] = $networkDetails->first_row()->currency_name_fr; $data['currency_name_en'] = $networkDetails->first_row()->currency_name_en; -// $data['transactions'] = $this->wallet_model->getIlinkTransactions($startDate, $endDate, $network_id); - } else if ($type == 'commission_transfer') + }else if ($type == 'deleted_transactions') + $data['transactions'] = $this->user_model->getDeletedTransactions($startDate, $endDate, $this->session->userdata('network_id')); + else if ($type == 'commission_transfer') $data['transactions'] = $this->wallet_model->getCommissionTransfers($startDate, $endDate, $this->session->userdata('member_code')); else if ($type == 'balance_statement') $data['wallets'] = $this->user_model->getInfosWalletAgentForHyper($this->session->userdata('network_id')); @@ -562,6 +561,8 @@ class Hyperviseur_dash extends CI_Controller $this->load->view('historique_transactions'); else if ($type == 'transaction_ilink') $this->load->view('historique_transactions_ilink'); + else if ($type == 'deleted_transactions') + $this->load->view('historique_transactions_deleted'); else if ($type == 'commission_transfer') $this->load->view('historique_transferts_commission'); else if ($type == 'balance_statement') @@ -573,6 +574,27 @@ class Hyperviseur_dash extends CI_Controller $this->load->view('footer'); } + public function delete_wallet_transaction(){ + if ($this->isLogged()) { + $datetime = $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id')); + $id = $this->input->post('id_transaction'); + + $data = array( + 'deleted' => 1 , + 'deleted_at' => $datetime + ); + + $this->db->where('id',$id); + $query = $this->db->update('wallet_transaction',$data); + + if ($query) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + public function walletPassword() { if ($this->isLogged()) { diff --git a/application/controllers/pagination/WalletTransaction.php b/application/controllers/pagination/WalletTransaction.php new file mode 100755 index 00000000..77fb5318 --- /dev/null +++ b/application/controllers/pagination/WalletTransaction.php @@ -0,0 +1,78 @@ +load->model('pagination/WalletTransaction_model', 'wt_model'); + $this->load->model('wallet_model'); + + + } + + + function getLists() + { + $data = $row = array(); + + // Fetch member's records + $wtData = $this->wt_model->getRows($_POST); + + $i = $_POST['start']; + $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); + $config = $this->wallet_model->getConfigWallet($_POST['id_network'])->first_row(); + foreach ($wtData as $row) { + + $type = $row->type_transac == 'credit' ? $this->lang->line('DEPOT') : $this->lang->line('RETRAIT'); + + $banque = 0; + if($row->type_transac == 'credit'){ + if($row->montant < 0){ + $commission = (-$row->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot; + $net = $row->montant + $commission; + }else{ + $commission = ( $row->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot; + $net = $row->montant - $commission; + } + $banque = $row->montant * (1 - ($config->taux_com_client_depot / 100)); + }else{ + $net = $row->montant ; + } + + $disabled = $row->canceled ? "disabled" : ""; + $disabled1 = $row->deleted ? "disabled" : ""; + + $data[] = array($row->id,strtoupper($type), join(" ", str_split($row->numCarte, 4)), $fmt->format($net), ($row->type_transac == 'credit' ? $fmt->format($banque) : ""), + $fmt->format( $row->commission_banque), $fmt->format( $row->commission_hyp), $fmt->format( $row->commission_sup), $fmt->format( $row->commission_ag), $row->agent , $row->date_created, + ' + '); + } + + $output = array( + "draw" => $_POST['draw'], + "recordsTotal" => $this->wt_model->countAll($_POST), + "recordsFiltered" => $this->wt_model->countFiltered($_POST), + "data" => $data, + ); + + // Output to JSON format + echo json_encode($output); + } + +} diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 82758e0a..80915d18 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -598,5 +598,10 @@ $lang['cancellation_date'] = "Cancellation date"; $lang['receiver'] = "Receiver"; $lang['loading'] = "Loading ..."; $lang['credit_request_canceled_by_hypervisor'] = "Credit request canceled by hypervisor"; -$lang['credit_request_canceled_by_hypervisor_message'] = "Credit request number %s of %s has been canceled." +$lang['credit_request_canceled_by_hypervisor_message'] = "Credit request number %s of %s has been canceled."; +$lang['transaction_deleted'] = "Transaction deleted"; +$lang['delete_transaction'] = "Delete a transaction"; +$lang['are_you_sure'] = "Are you sure what you are doing?"; +$lang['deleted_transactions'] = "Deleted Transactions"; +$lang['deletion_date'] = "Date of deletion"; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index a24ed269..b0f9733e 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -610,5 +610,10 @@ $lang['cancellation_date'] = "Date d'annulation"; $lang['receiver'] = "Destinataire"; $lang['loading'] = "Chargement en cours ..."; $lang['credit_request_canceled_by_hypervisor'] = "Demande de crédit annulée par l'hyperviseur"; -$lang['credit_request_canceled_by_hypervisor_message'] = "La demande de credit numéro %s de %s a été annulée." +$lang['credit_request_canceled_by_hypervisor_message'] = "La demande de credit numéro %s de %s a été annulée."; +$lang['transaction_deleted'] = "Transaction supprimée"; +$lang['delete_transaction'] = "Supprimer une transaction"; +$lang['are_you_sure'] = "Êtes vous sûr de ce que vous faites ?"; +$lang['deleted_transactions'] = "Transactions supprimées"; +$lang['deletion_date'] = "Date de suppression"; ?> diff --git a/application/models/User_model.php b/application/models/User_model.php index f062b591..1b1ecf7c 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -1854,6 +1854,18 @@ class User_model extends CI_Model } } + public function getDeletedTransactions($debut , $fin , $id_network){ + $chain = $debut ? " AND deleted_at BETWEEN '".$debut."' AND '".$fin."'" : ""; + $query = $this->db->query("SELECT * + FROM infos_transaction + WHERE deleted = 1 AND `network_id`=".$id_network.$chain); + if($query->num_rows()>0){ + return $query; + }else{ + return false; + } + } + public function getTransactionsSup($debut , $fin , $codeMembre){ $chain = $debut ? " AND date_created BETWEEN '".$debut."' AND '".$fin."'" : ""; $query = $this->db->query("SELECT * diff --git a/application/models/Wallet_model.php b/application/models/Wallet_model.php index c13facb4..05536eb5 100644 --- a/application/models/Wallet_model.php +++ b/application/models/Wallet_model.php @@ -727,19 +727,6 @@ class Wallet_model extends CI_Model } } - public function getIlinkTransactions($debut , $fin , $id_network){ - $chain = $debut ? " AND date BETWEEN '" . $debut . "' AND '" . $fin . "'" : ""; - $query = $this->db->query("SELECT * - FROM infos_ilink_transaction - WHERE `network_emetteur`=" . $id_network . $chain); - //var_dump($query->result_array()); - if ($query->num_rows() > 0) { - return $query; - } else { - return false; - } - } - public function getNetworkIlinTransactions($id_network){ $query = $this->db->query("SELECT * FROM infos_ilink_transaction diff --git a/application/models/pagination/WalletTransaction_model.php b/application/models/pagination/WalletTransaction_model.php new file mode 100644 index 00000000..f46e680d --- /dev/null +++ b/application/models/pagination/WalletTransaction_model.php @@ -0,0 +1,100 @@ +table = 'infos_transaction'; + // Set orderable column fields + $this->column_order = array('id', 'type_transac', 'numCarte', 'montant', 'commission_banque', 'commission_hyp', 'commission_sup', 'commission_ag', + 'agent','date_created', null); + // Set searchable column fields + $this->column_search = array('id', 'type_transac', 'numCarte', 'montant', 'commission_banque', 'commission_hyp', 'commission_sup', 'commission_ag', + 'agent','date_created'); + // Set default order + $this->order = array('date_created' => 'desc'); + } + + /* + * Fetch members data from the database + * @param $_POST filter data based on the posted parameters + */ + public function getRows($postData) + { + $this->_get_datatables_query($postData); + if ($postData['length'] != -1) { + $this->db->limit($postData['length'], $postData['start']); + } + $query = $this->db->get(); + return $query->result(); + } + + /* + * Count all records + */ + public function countAll($postData) + { + $this->db->from($this->table); + $this->db->where('network_id', $postData['id_network']); + return $this->db->count_all_results(); + } + + /* + * Count records based on the filter params + * @param $_POST filter data based on the posted parameters + */ + public function countFiltered($postData) + { + $this->_get_datatables_query($postData); + $query = $this->db->get(); + return $query->num_rows(); + } + + /* + * Perform the SQL queries needed for an server-side processing requested + * @param $_POST filter data based on the posted parameters + */ + private function _get_datatables_query($postData) + { + + $this->db->from($this->table); + $this->db->where('deleted', 0); + $this->db->where('network_id', $postData['id_network']); + 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"))); + } + + $i = 0; + // loop searchable columns + foreach ($this->column_search as $item) { + // if datatable send POST for search + if ($postData['search']['value']) { + // first loop + if ($i === 0) { + // open bracket + $this->db->group_start(); + $this->db->like($item, $postData['search']['value']); + } else { + $this->db->or_like($item, $postData['search']['value']); + } + + // last loop + if (count($this->column_search) - 1 == $i) { + // close bracket + $this->db->group_end(); + } + } + $i++; + } + + if (isset($postData['order'])) { + $this->db->order_by($this->column_order[$postData['order']['0']['column']], $postData['order']['0']['dir']); + } else if (isset($this->order)) { + $order = $this->order; + $this->db->order_by(key($order), $order[key($order)]); + } + } +} diff --git a/application/views/demande_credit_annulation.php b/application/views/demande_credit_annulation.php index e6089fe7..b9bfe1c4 100755 --- a/application/views/demande_credit_annulation.php +++ b/application/views/demande_credit_annulation.php @@ -162,37 +162,6 @@ const format = lang === 'french' ? 'fr' : 'en'; moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date - //$('#listeMembres1').DataTable({ - // "aaSorting": [[4, "desc"]], - // "columnDefs": [{ - // targets: [4, 5], - // render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format), - // }, - // { - // "targets": [ 7 ], - // "visible": false - // } - // ], - // dom: 'Bfrtip', - // "buttons": [ - // 'pageLength', - // { - // extend: 'excelHtml5', - // title: "lang->line('incoming_credits_requests_accepted')?>//" - // }, - // { - // extend: 'csvHtml5', - // title: "lang->line('incoming_credits_requests_accepted')?>//" - // }, - // { - // extend: 'pdfHtml5', - // orientation: 'landscape', - // pageSize: 'LEGAL', - // title: "lang->line('incoming_credits_requests_accepted')?>//" - // } - // ] - //}); - var table = $('#listeMembres1').DataTable({ // Processing indicator "processing": true, diff --git a/application/views/historique_transactions.php b/application/views/historique_transactions.php index 539bc631..1a9afa12 100755 --- a/application/views/historique_transactions.php +++ b/application/views/historique_transactions.php @@ -2,6 +2,7 @@ +
@@ -65,16 +66,15 @@

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

+ session->userdata('category') != 'super') { ?> + +
- num_rows(); - $num = 0; - if ($numrows > 0) { - $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); - ?> - @@ -94,66 +94,23 @@ - - - first_row(); - foreach ($transactions->result() as $row) { - $num++; - $type = $row->type_transac == 'credit' ? $this->lang->line('DEPOT') : $this->lang->line('RETRAIT'); - - $net = 0; - $banque = 0; - if($row->type_transac == 'credit'){ - if($row->montant < 0){ - $commission = (-$row->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot; - $net = $row->montant + $commission; - }else{ - $commission = ( $row->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot; - $net = $row->montant - $commission; - } - $banque = $row->montant * (1 - ($config->taux_com_client_depot / 100)); - }else{ - $net = $row->montant ; - } - echo " - - - - - - - - - - - "; - ?> - session->userdata('category') != 'super') { ?> - - - - - - - - lang->line('Aucune transaction'); - } - }else { - echo $this->lang->line('Aucune transaction'); - } - ?> -
$row->id".strtoupper($type)."".join(" ", str_split($row->numCarte, 4))."".$fmt->format($net)."".($row->type_transac == 'credit' ? $fmt->format($banque) : "")."".$fmt->format( $row->commission_banque)."".$fmt->format( $row->commission_hyp)."".$fmt->format( $row->commission_sup)."".$fmt->format( $row->commission_ag)."".$row->agent."".$row->date_created." - -
- +
+
+
+ +