From eb17b9605fc8a8071c0f3c17869d1292d4a69416 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Wed, 16 Dec 2020 06:55:04 +0100 Subject: [PATCH] + Sending notifications after cancellation of a credit request --- application/config/autoload.php | 2 +- application/config/database.php | 5 +- application/config/email.php | 2 +- application/controllers/Hyperviseur_dash.php | 68 ++++- .../pagination/AcceptedCreditRequests.php | 58 ++++ application/helpers/functions_helper.php | 90 ++++++ application/language/english/message_lang.php | 3 + application/language/french/message_lang.php | 3 + application/models/User_model.php | 10 - .../AcceptedCreditRequests_model.php | 98 +++++++ .../WalletIlinkTransaction_model.php | 4 +- application/views/demande.php | 56 ---- application/views/demande_adhesion.php | 57 ---- application/views/demande_credit.php | 67 ----- .../views/demande_credit_annulation.php | 258 ++++++++---------- .../historique_demande_credit_annulation.php | 63 +---- .../views/historique_transactions_ilink.php | 3 + composer.json | 6 +- 18 files changed, 447 insertions(+), 406 deletions(-) create mode 100755 application/controllers/pagination/AcceptedCreditRequests.php create mode 100644 application/helpers/functions_helper.php create mode 100644 application/models/pagination/AcceptedCreditRequests_model.php diff --git a/application/config/autoload.php b/application/config/autoload.php index 09e51264..703b37c9 100755 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -89,7 +89,7 @@ $autoload['drivers'] = array(); | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array('url', 'file'); +$autoload['helper'] = array('url', 'file' , 'functions_helper'); /* | ------------------------------------------------------------------- diff --git a/application/config/database.php b/application/config/database.php index 68ce7312..7ac94ffe 100755 --- a/application/config/database.php +++ b/application/config/database.php @@ -79,8 +79,9 @@ $db['default'] = array( 'username' => 'root', 'password' => 'vps@2017GA', 'database' => 'iLink_preprod', - 'wallet_service_url' => 'https://localhost:8081', - 'wallet_service_externe_url' => 'https://localhost:8085', + 'wallet_service_url' => 'http://localhost:8081', + 'wallet_service_externe_url' => 'http://localhost:8085', + 'notification_service_url' => 'http://localhost:8083', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/config/email.php b/application/config/email.php index cd090bae..28aa4b46 100755 --- a/application/config/email.php +++ b/application/config/email.php @@ -9,6 +9,6 @@ $config = array( 'smtp_crypto' => 'tls', //can be 'ssl' or 'tls' for example 'mailtype' => 'text', //plaintext 'text' mails or 'html' 'smtp_timeout' => '5', //in seconds - 'charset' => 'iso-8859-1', + 'charset' => 'utf8', 'wordwrap' => TRUE ); diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 10375c0a..3b853e96 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -199,8 +199,8 @@ class Hyperviseur_dash extends CI_Controller $debut = $this->input->get("d"); $fin = $this->input->get("f"); $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; - $data['debut'] = $debut ? date($format, strtotime($debut)) : null; - $data['fin'] = $fin ? date($format, strtotime($fin)) : null; + $data['debut'] = $data['startDate'] = $debut ? date($format, strtotime($debut)) : null; + $data['fin'] = $data['endDate'] =$fin ? date($format, strtotime($fin)) : null; $fin = Date('Y-m-d', strtotime($fin . "+1 day")); @@ -218,14 +218,12 @@ class Hyperviseur_dash extends CI_Controller $data['category'] = $this->session->userdata('category'); $data['network'] = $this->session->userdata('network'); $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['id_network'] = $this->session->userdata('network_id'); if($show == 'history'){ $data['list'] = $this->user_model->getAllCanceledCreditsDemands($debut, $fin, $this->session->userdata('network_id')); - }else{ - $data['list'] = $this->user_model->getAllAcceptedCreditsDemands($debut, $fin, $this->session->userdata('network_id')); $data['temp_moyen'] = $this->user_model->getTempsMoyenByNetwork($this->session->userdata('network_id')); - } $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); $data['hasWallet'] = $this->wallet_model->getConfigWallet($this->session->userdata('network_id')); @@ -243,9 +241,10 @@ class Hyperviseur_dash extends CI_Controller public function cancelCreditRequest(){ if ($this->isLogged()) { + $datetime = $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id')); $data = array( 'canceled_by_hypervisor' => 1 , - 'cancellation_date' => $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id')) + 'cancellation_date' => $datetime ); $id = $this->input->post('id_demand'); $query = $this->db->get_where('info_demandeCredits', ['demande_id' => $id]); @@ -266,11 +265,68 @@ class Hyperviseur_dash extends CI_Controller $this->db->where('id', $id); $query = $this->db->update('demandeCredits', $data); + try { + $message = line_with_arguments($this->lang->line('credit_request_canceled_by_hypervisor_message'), array($id,$demand->montant)); + //Send email + $this->load->library('email'); + $this->email->from('noreply@ilink-app.com', 'iLink World'); + $this->email->to(array($demand->email_agent,$demand->email_parrain)); + + $this->email->subject($this->lang->line('credit_request_canceled_by_hypervisor')); + $this->email->message($message); + $this->email->send() ; + + /* API URL */ + $url = $this->db->notification_service_url . '/onesignal/pushToAgent' ; + + /* Init cURL resource */ + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_POST, 1); + + /* set the content type json */ + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type:application/json', + 'Authorization: RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg' + )); + + $data = new \stdClass(); + $data->screen = "Historique"; + $data->data = new \stdClass(); + $data->data->id = $id; + + $body = new \stdClass(); + $body->agent_code = $demand->codeMembre; + $body->message = $message; + $body->data = $data; + $body->date = $datetime; + + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); + + /* set return type json */ + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + /* execute request */ + curl_exec($ch); + + $body->agent_code = $demand->codeParrain; + + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); + + curl_exec($ch); + /* close cURL resource */ + curl_close($ch); + + }catch (\Throwable $e){ + + } + if ($query) { echo json_encode("200"); } else { echo json_encode("500"); } + }else{ echo json_encode("404"); } diff --git a/application/controllers/pagination/AcceptedCreditRequests.php b/application/controllers/pagination/AcceptedCreditRequests.php new file mode 100755 index 00000000..0f7789cf --- /dev/null +++ b/application/controllers/pagination/AcceptedCreditRequests.php @@ -0,0 +1,58 @@ +load->model('pagination/AcceptedCreditRequests_model', 'acr_model'); + + } + + + function getLists() + { + $data = $row = array(); + + // Fetch member's records + $acrData = $this->acr_model->getRows($_POST); + + $i = $_POST['start']; + $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); + + foreach ($acrData as $row) { + + $origin = $row->agent." | ".$row->phone; + $destination = $row->name_parrain." | ".$row->phone_parrain; + if ($row->codeMembre == $this->session->userdata('member_code')) { + $origin = $this->lang->line('Vous'); + } + if ($row->codeParrain == $this->session->userdata('member_code')) { + $destination = $this->lang->line('Vous'); + } + + $disabled = $row->canceled_by_hypervisor ? "disabled" : ""; + + $data[] = array($row->demande_id, $origin, $destination, $fmt->format($row->montant), $row->dateAjout, $row->dateModif , + traitementTemps($row->temps, $row->dateAjout,$this), getDelayOfTreatmentInSeconds($row->temps, $row->dateAjout)/60, + ''); + } + + $output = array( + "draw" => $_POST['draw'], + "recordsTotal" => $this->acr_model->countAll($_POST), + "recordsFiltered" => $this->acr_model->countFiltered($_POST), + "data" => $data, + ); + + // Output to JSON format + echo json_encode($output); + } + +} diff --git a/application/helpers/functions_helper.php b/application/helpers/functions_helper.php new file mode 100644 index 00000000..5124ee8a --- /dev/null +++ b/application/helpers/functions_helper.php @@ -0,0 +1,90 @@ + 86400, + "h" => 3600, + "m" => 60, + "s" => 1); + $result = ""; + + foreach ($tabTemps as $uniteTemps => $nombreSecondesDansUnite) { + + $$uniteTemps = floor($time / $nombreSecondesDansUnite); + + $time = $time % $nombreSecondesDansUnite; + + if ($$uniteTemps > 0 || !empty($result)) { + + $result .= $$uniteTemps . " $uniteTemps "; + } + } + + return $result; + + } + +} + +if (!function_exists('dateDiff')) { + function dateDiff($date1, $date2, $class = null) + { + $diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative + $retour = array(); + + $tmp = $diff; + $second = $tmp % 60; + + $tmp = floor(($tmp - $second) / 60); + $minute = $tmp % 60; + + $tmp = floor(($tmp - $minute) / 60); + $heure = $tmp % 24; + + $tmp = floor(($tmp - $heure) / 24); + $jour = $tmp; + + return $class->lang->line('since') . ' ' . $jour . ' ' . $class->lang->line('days') . ' ' . $heure . ' ' . $class->lang->line('hours') . ' ' . $minute . ' ' . $class->lang->line('minutes') . ' ' . $second . ' ' . $class->lang->line('seconds'); + } +} + + +if (!function_exists('traitementTemps')) { + function traitementTemps($time, $dateAjout, $class = null) + { + if ($time == null) { + $now = time(); + $date2 = strtotime($dateAjout); + + return dateDiff($now, $date2, $class); + } else { + return duree($time); + } + } +} + + +if (!function_exists('getDelayOfTreatmentInSeconds')) { + function getDelayOfTreatmentInSeconds($time, $dateAjout) + { + if ($time == null) { + $now = time(); + $date2 = strtotime($dateAjout); + return abs($now - $date2); + } else { + return $time; + } + + } +} + +if ( ! function_exists('line_with_arguments')) +{ + function line_with_arguments($line, $args = array()) + { + return vsprintf($line, $args); +// return str_replace('%s', $swap, $line); + } +} + diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 251d1ad6..82758e0a 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -596,4 +596,7 @@ $lang['incoming_credits_requests_accepted'] = 'Incoming credit requests accepted $lang['history_canceled_credit_requests'] = "History of canceled credit requests"; $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." ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 69105598..a24ed269 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -608,4 +608,7 @@ $lang['incoming_credits_requests_accepted'] = 'Demandes de crédits entrantes ac $lang['history_canceled_credit_requests'] = "Historique des demandes de crédits annulées"; $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." ?> diff --git a/application/models/User_model.php b/application/models/User_model.php index 2ab9decd..f062b591 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -2574,16 +2574,6 @@ class User_model extends CI_Model return ($query->num_rows() > 0) ? $query : false; } - public function getAllAcceptedCreditsDemands($debut, $fin, $id_network) - { - - $query = $this->db->query("SELECT * - FROM info_demandeCredits AS d - WHERE d.id_network='" . $id_network . "' AND d.dateAjout BETWEEN '" . $debut . "' AND '" . $fin . "' AND statut = '1' - ORDER BY dateAjout"); - return ($query->num_rows() > 0) ? $query : false; - } - public function getAllCanceledCreditsDemands($debut, $fin, $id_network) { diff --git a/application/models/pagination/AcceptedCreditRequests_model.php b/application/models/pagination/AcceptedCreditRequests_model.php new file mode 100644 index 00000000..7cc58b1a --- /dev/null +++ b/application/models/pagination/AcceptedCreditRequests_model.php @@ -0,0 +1,98 @@ +table = 'info_demandeCredits'; + + // Set orderable column fields + $this->column_order = array('demande_id','agent','name_parrain' , 'montant', 'dateAjout', 'dateModif', 'phone' , 'phone_parrain'); + // Set searchable column fields + $this->column_search = array('demande_id', 'montant', 'dateAjout', 'dateModif','agent' , 'phone', 'name_parrain', 'phone_parrain'); + // Set default order + $this->order = array('dateAjout' => '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('id_network', $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('id_network', $postData['id_network']); + if (strlen($postData['startDate']) > 0 && strlen($postData['endDate']) > 0) { + $this->db->where('dateAjout >=', date('Y-m-d', strtotime($postData['startDate']))); + $this->db->where('dateAjout <', 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/models/pagination/WalletIlinkTransaction_model.php b/application/models/pagination/WalletIlinkTransaction_model.php index a55bd54c..f658753c 100644 --- a/application/models/pagination/WalletIlinkTransaction_model.php +++ b/application/models/pagination/WalletIlinkTransaction_model.php @@ -64,8 +64,8 @@ class WalletIlinkTransaction_model extends CI_Model $this->db->from($this->table); $this->db->where('network_emetteur', $postData['id_network']); if (strlen($postData['startDate']) > 0 && strlen($postData['endDate']) > 0) { - $this->db->where('date >=', date('Y-m-d h:i:s', strtotime($postData['startDate']))); - $this->db->where('date <=', date('Y-m-d h:i:s', strtotime($postData['endDate']))); + $this->db->where('date >=', date('Y-m-d', strtotime($postData['startDate']))); + $this->db->where('date <', date('Y-m-d', strtotime($postData['endDate']. "+1 day"))); } $i = 0; diff --git a/application/views/demande.php b/application/views/demande.php index 11a82c52..c0fe1ce2 100755 --- a/application/views/demande.php +++ b/application/views/demande.php @@ -4,62 +4,6 @@
- 86400, - "h" => 3600, - "m" => 60, - "s" => 1); - $result = ""; - - foreach($tabTemps as $uniteTemps => $nombreSecondesDansUnite) { - - $$uniteTemps = floor($time/$nombreSecondesDansUnite); - - $time = $time%$nombreSecondesDansUnite; - - if($$uniteTemps > 0 || !empty($result)){ - - $result .= $$uniteTemps." $uniteTemps "; - } - } - - return $result; - - } - - function dateDiff($date1, $date2){ - $diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative - $retour = array(); - - $tmp = $diff; - $second = $tmp % 60; - - $tmp = floor( ($tmp - $second) /60 ); - $minute = $tmp % 60; - - $tmp = floor( ($tmp - $minute)/60 ); - $heure = $tmp % 24; - - $tmp = floor( ($tmp - $heure) /24 ); - $jour = $tmp; - - return 'Depuis '.$jour.' jours '.$heure.' heures '.$minute.' minutes '.$second.' secondes'; - } - - function traitementTemps($time,$dateAjout){ - if($time==null){ - $now = time(); - $date2 = strtotime($dateAjout); - - return dateDiff($now, $date2); - } - else{ - return duree($time); - } - } - ?> -
diff --git a/application/views/demande_adhesion.php b/application/views/demande_adhesion.php index bb8fcde7..3a814d33 100755 --- a/application/views/demande_adhesion.php +++ b/application/views/demande_adhesion.php @@ -4,63 +4,6 @@
- 86400, - "h" => 3600, - "m" => 60, - "s" => 1); - $result = ""; - - foreach($tabTemps as $uniteTemps => $nombreSecondesDansUnite) { - - $$uniteTemps = floor($time/$nombreSecondesDansUnite); - - $time = $time%$nombreSecondesDansUnite; - - if($$uniteTemps > 0 || !empty($result)){ - - $result .= $$uniteTemps." $uniteTemps "; - } - } - - return $result; - - } - - function dateDiff($date1, $date2,$class = null){ - $diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative - $retour = array(); - - $tmp = $diff; - $second = $tmp % 60; - - $tmp = floor( ($tmp - $second) /60 ); - $minute = $tmp % 60; - - $tmp = floor( ($tmp - $minute)/60 ); - $heure = $tmp % 24; - - $tmp = floor( ($tmp - $heure) /24 ); - $jour = $tmp; - - return $class->lang->line('since').' ' . $jour . ' '.$class->lang->line('days').' ' . $heure . ' '.$class->lang->line('hours').' ' . $minute . ' '.$class->lang->line('minutes').' ' . $second . ' '.$class->lang->line('seconds'); - - } - - function traitementTemps($time,$dateAjout , $class = null){ - if($time==null){ - $now = time(); - $date2 = strtotime($dateAjout); - - return dateDiff($now, $date2, $class); - } - else{ - return duree($time); - } - } - ?> -
diff --git a/application/views/demande_credit.php b/application/views/demande_credit.php index 0bc1e021..a7b2c571 100755 --- a/application/views/demande_credit.php +++ b/application/views/demande_credit.php @@ -10,73 +10,6 @@ // use Carbon\Carbon; $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); - function duree($time) - { - $tabTemps = array("jours" => 86400, - "h" => 3600, - "m" => 60, - "s" => 1); - $result = ""; - - foreach ($tabTemps as $uniteTemps => $nombreSecondesDansUnite) { - - $$uniteTemps = floor($time / $nombreSecondesDansUnite); - - $time = $time % $nombreSecondesDansUnite; - - if ($$uniteTemps > 0 || !empty($result)) { - - $result .= $$uniteTemps . " $uniteTemps "; - } - } - - return $result; - - } - - function dateDiff($date1, $date2,$class = null) - { - $diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative - $retour = array(); - - $tmp = $diff; - $second = $tmp % 60; - - $tmp = floor(($tmp - $second) / 60); - $minute = $tmp % 60; - - $tmp = floor(($tmp - $minute) / 60); - $heure = $tmp % 24; - - $tmp = floor(($tmp - $heure) / 24); - $jour = $tmp; - - return $class->lang->line('since').' ' . $jour . ' '.$class->lang->line('days').' ' . $heure . ' '.$class->lang->line('hours').' ' . $minute . ' '.$class->lang->line('minutes').' ' . $second . ' '.$class->lang->line('seconds'); - } - - function traitementTemps($time, $dateAjout , $class = null) - { - if ($time == null) { - $now = time(); - $date2 = strtotime($dateAjout); - - return dateDiff($now, $date2,$class); - } else { - return duree($time); - } - } - - function getDelayOfTreatmentInSeconds($time, $dateAjout){ - if ($time == null) { - $now = time(); - $date2 = strtotime($dateAjout); - return abs($now - $date2); - }else{ - return $time ; - } - - } - // function toLocateDate($date , $timezone){ // if($date){ // $carbon = Carbon::createFromFormat('Y-m-d H:i:s', $date, 'UTC'); diff --git a/application/views/demande_credit_annulation.php b/application/views/demande_credit_annulation.php index 30266967..e6089fe7 100755 --- a/application/views/demande_credit_annulation.php +++ b/application/views/demande_credit_annulation.php @@ -5,87 +5,6 @@
- 86400, - "h" => 3600, - "m" => 60, - "s" => 1); - $result = ""; - - foreach ($tabTemps as $uniteTemps => $nombreSecondesDansUnite) { - - $$uniteTemps = floor($time / $nombreSecondesDansUnite); - - $time = $time % $nombreSecondesDansUnite; - - if ($$uniteTemps > 0 || !empty($result)) { - - $result .= $$uniteTemps . " $uniteTemps "; - } - } - - return $result; - - } - - function dateDiff($date1, $date2,$class = null) - { - $diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative - $retour = array(); - - $tmp = $diff; - $second = $tmp % 60; - - $tmp = floor(($tmp - $second) / 60); - $minute = $tmp % 60; - - $tmp = floor(($tmp - $minute) / 60); - $heure = $tmp % 24; - - $tmp = floor(($tmp - $heure) / 24); - $jour = $tmp; - - return $class->lang->line('since').' ' . $jour . ' '.$class->lang->line('days').' ' . $heure . ' '.$class->lang->line('hours').' ' . $minute . ' '.$class->lang->line('minutes').' ' . $second . ' '.$class->lang->line('seconds'); - } - - function traitementTemps($time, $dateAjout , $class = null) - { - if ($time == null) { - $now = time(); - $date2 = strtotime($dateAjout); - - return dateDiff($now, $date2,$class); - } else { - return duree($time); - } - } - - function getDelayOfTreatmentInSeconds($time, $dateAjout){ - if ($time == null) { - $now = time(); - $date2 = strtotime($dateAjout); - return abs($now - $date2); - }else{ - return $time ; - } - - } - -// function toLocateDate($date , $timezone){ -// if($date){ -// $carbon = Carbon::createFromFormat('Y-m-d H:i:s', $date, 'UTC'); -// $carbon->setTimezone($timezone); -// return $carbon->toDateTimeString(); -// } -// return $date; -// } - - ?>
@@ -177,21 +96,11 @@
- num_rows(); - $num = 0; - if ($numrows > 0) { - - ?> - - + @@ -204,46 +113,6 @@ ?> - - - result() as $row) { - $num++; - $origin = $row->agent." | ".$row->phone; - $destination = $row->name_parrain." | ".$row->phone_parrain; - if ($row->codeMembre == $this->session->userdata('member_code')) { - $origin = $this->lang->line('Vous'); - } - if ($row->codeParrain == $this->session->userdata('member_code')) { - $destination = $this->lang->line('Vous'); - } - - echo " - - - - - - "; ?> - - - - - - - - - lang->line('Aucune demande'); - } - } else { - echo $this->lang->line('Aucune demande'); - } - - - ?>
ID " . $this->lang->line('Emetteur') . " " . $this->lang->line('receiver'). " " . $this->lang->line('Montant') . "
".$origin."$destination". $fmt->format($row->montant)."" . $row->dateAjout . " " . $row->dateModif . "" . traitementTemps($row->temps, $row->dateAjout,$this) . "temps, $row->dateAjout)/60 ?>
@@ -293,14 +162,66 @@ const format = lang === 'french' ? 'fr' : 'en'; moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date - $('#listeMembres1').DataTable({ - "aaSorting": [[3, "desc"]], - "columnDefs": [{ - targets: [3, 4], - render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format), + //$('#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, + "language": { + "processing": "lang->line('loading') ?>" }, + // DataTables server-side processing mode + "serverSide": true, + // Initial no order. + "order": [], + // Load data from an Ajax source + "ajax": { + "url": "", + "data":{ + "startDate" : "", + "endDate" : "", + "id_network" : + }, + "type": "POST" + }, + "aaSorting": [[4, "desc"]], + "columnDefs": [{ + "targets": [4, 5], + // "orderable": false, + render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format) + }, + { "orderable": false, "targets": 8 }, { - "targets": [ 6 ], + "targets": [ 7 ], "visible": false } ], @@ -308,22 +229,73 @@ "buttons": [ 'pageLength', { - extend: 'excelHtml5', - title: "lang->line('incoming_credits_requests_accepted')?>" + "extend": 'excelHtml5', + title: "lang->line('incoming_credits_requests_accepted') ?>", + trim: false, + "action": newexportaction }, { extend: 'csvHtml5', - title: "lang->line('incoming_credits_requests_accepted')?>" + title: "lang->line('incoming_credits_requests_accepted') ?>", + trim: false, + "action": newexportaction }, { extend: 'pdfHtml5', orientation: 'landscape', pageSize: 'LEGAL', - title: "lang->line('incoming_credits_requests_accepted')?>" - } + title: "lang->line('incoming_credits_requests_accepted') ?>", + trim: false, + "action": newexportaction + }, + // 'colvis' ] }); + table.buttons().container() + .appendTo('#example_wrapper .col-sm-6:eq(0)'); + + function newexportaction(e, dt, button, config) { + var self = this; + var oldStart = dt.settings()[0]._iDisplayStart; + dt.one('preXhr', function (e, s, data) { + // Just this once, load all data from the server... + data.start = 0; + data.length = 2147483647; + dt.one('preDraw', function (e, settings) { + // Call the original action function + if (button[0].className.indexOf('buttons-copy') >= 0) { + $.fn.dataTable.ext.buttons.copyHtml5.action.call(self, e, dt, button, config); + } else if (button[0].className.indexOf('buttons-excel') >= 0) { + $.fn.dataTable.ext.buttons.excelHtml5.available(dt, config) ? + $.fn.dataTable.ext.buttons.excelHtml5.action.call(self, e, dt, button, config) : + $.fn.dataTable.ext.buttons.excelFlash.action.call(self, e, dt, button, config); + } else if (button[0].className.indexOf('buttons-csv') >= 0) { + $.fn.dataTable.ext.buttons.csvHtml5.available(dt, config) ? + $.fn.dataTable.ext.buttons.csvHtml5.action.call(self, e, dt, button, config) : + $.fn.dataTable.ext.buttons.csvFlash.action.call(self, e, dt, button, config); + } else if (button[0].className.indexOf('buttons-pdf') >= 0) { + $.fn.dataTable.ext.buttons.pdfHtml5.available(dt, config) ? + $.fn.dataTable.ext.buttons.pdfHtml5.action.call(self, e, dt, button, config) : + $.fn.dataTable.ext.buttons.pdfFlash.action.call(self, e, dt, button, config); + } else if (button[0].className.indexOf('buttons-print') >= 0) { + $.fn.dataTable.ext.buttons.print.action(e, dt, button, config); + } + dt.one('preXhr', function (e, s, data) { + // DataTables thinks the first item displayed is index 0, but we're not drawing that. + // Set the property to what it was before exporting. + settings._iDisplayStart = oldStart; + data.start = oldStart; + }); + // Reload the grid with the original page. Otherwise, API functions like table.cell(this) don't work properly. + setTimeout(dt.ajax.reload, 0); + // Prevent rendering of the full data to the DOM + return false; + }); + }); + // Requery the server with the new one-time export settings + dt.ajax.reload(); + } }); diff --git a/application/views/historique_demande_credit_annulation.php b/application/views/historique_demande_credit_annulation.php index 96c9aed1..8b11a33c 100755 --- a/application/views/historique_demande_credit_annulation.php +++ b/application/views/historique_demande_credit_annulation.php @@ -9,62 +9,6 @@ // use Carbon\Carbon; $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); - function duree($time) - { - $tabTemps = array("jours" => 86400, - "h" => 3600, - "m" => 60, - "s" => 1); - $result = ""; - - foreach ($tabTemps as $uniteTemps => $nombreSecondesDansUnite) { - - $$uniteTemps = floor($time / $nombreSecondesDansUnite); - - $time = $time % $nombreSecondesDansUnite; - - if ($$uniteTemps > 0 || !empty($result)) { - - $result .= $$uniteTemps . " $uniteTemps "; - } - } - - return $result; - - } - - function dateDiff($date1, $date2,$class = null) - { - $diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative - $retour = array(); - - $tmp = $diff; - $second = $tmp % 60; - - $tmp = floor(($tmp - $second) / 60); - $minute = $tmp % 60; - - $tmp = floor(($tmp - $minute) / 60); - $heure = $tmp % 24; - - $tmp = floor(($tmp - $heure) / 24); - $jour = $tmp; - - return $class->lang->line('since').' ' . $jour . ' '.$class->lang->line('days').' ' . $heure . ' '.$class->lang->line('hours').' ' . $minute . ' '.$class->lang->line('minutes').' ' . $second . ' '.$class->lang->line('seconds'); - } - - function traitementTemps($time, $dateAjout , $class = null) - { - if ($time == null) { - $now = time(); - $date2 = strtotime($dateAjout); - - return dateDiff($now, $date2,$class); - } else { - return duree($time); - } - } - ?>
@@ -140,7 +84,7 @@ - + ID " . $this->lang->line('Emetteur') . " " . $this->lang->line('receiver'). " " . $this->lang->line('Montant') . " @@ -168,6 +112,7 @@ } echo " + ".$row->demande_id." ".$origin." $destination ". $fmt->format($row->montant)." @@ -243,9 +188,9 @@ moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date $('#listeMembres1').DataTable({ - "aaSorting": [[6, "desc"]], + "aaSorting": [[7, "desc"]], "columnDefs": [{ - targets: [3, 4 ,6], + targets: [4, 5 ,7], render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format), } ], diff --git a/application/views/historique_transactions_ilink.php b/application/views/historique_transactions_ilink.php index 602b0873..1300b64d 100755 --- a/application/views/historique_transactions_ilink.php +++ b/application/views/historique_transactions_ilink.php @@ -188,6 +188,9 @@ use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration; var table = $('#transactions').DataTable({ // Processing indicator "processing": true, + "language": { + "processing": "lang->line('loading') ?>" + }, // DataTables server-side processing mode "serverSide": true, // Initial no order. diff --git a/composer.json b/composer.json index 08d64888..d4c0ed8e 100755 --- a/composer.json +++ b/composer.json @@ -15,8 +15,10 @@ "spatie/async": "^1.4", "nesbot/carbon": "^2.33", "brick/money": "^0.4.5", - "ext-intl": "*" - }, + "ext-intl": "*", + "ext-json": "*", + "ext-curl": "*" + }, "suggest": { "paragonie/random_compat": "Provides better randomness in PHP 5.x" },