+ Sending notifications after cancellation of a credit request
This commit is contained in:
parent
b5357516d1
commit
eb17b9605f
|
@ -89,7 +89,7 @@ $autoload['drivers'] = array();
|
|||
|
|
||||
| $autoload['helper'] = array('url', 'file');
|
||||
*/
|
||||
$autoload['helper'] = array('url', 'file');
|
||||
$autoload['helper'] = array('url', 'file' , 'functions_helper');
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
|
||||
class AcceptedCreditRequests extends CI_Controller
|
||||
{
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Load member model
|
||||
$this->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,
|
||||
'<button id="cancelDemand" class="btn btn-danger" data-id-demand="'.$row->demande_id.'"'.$disabled .'>'. $this->lang->line('cancel') .'</button>');
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
if (!function_exists('duree')) {
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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."
|
||||
?>
|
||||
|
|
|
@ -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."
|
||||
?>
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class AcceptedCreditRequests_model extends CI_Model
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
// Set table name
|
||||
$this->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)]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -4,62 +4,6 @@
|
|||
|
||||
<div class="content-wrapper">
|
||||
|
||||
<?php
|
||||
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){
|
||||
$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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-6 col-xs-12">
|
||||
|
|
|
@ -4,63 +4,6 @@
|
|||
|
||||
<div class="content-wrapper">
|
||||
|
||||
<?php
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-6 col-xs-12">
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -5,87 +5,6 @@
|
|||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
|
||||
<div class="content-wrapper">
|
||||
|
||||
<?php
|
||||
|
||||
// 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');
|
||||
// $carbon->setTimezone($timezone);
|
||||
// return $carbon->toDateTimeString();
|
||||
// }
|
||||
// return $date;
|
||||
// }
|
||||
|
||||
?>
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
|
||||
|
@ -177,21 +96,11 @@
|
|||
</div>
|
||||
<div class="box-body" style="overflow-x:auto;">
|
||||
|
||||
<?php
|
||||
$result = $list;
|
||||
if ($result != false){
|
||||
|
||||
$numrows = $result->num_rows();
|
||||
$num = 0;
|
||||
if ($numrows > 0) {
|
||||
|
||||
?>
|
||||
|
||||
<table id="listeMembres1" class="table table-bordered table-striped table-modified">
|
||||
<thead>
|
||||
<?php
|
||||
echo "<tr class='label-primary'>
|
||||
|
||||
<th> ID </th>
|
||||
<th>" . $this->lang->line('Emetteur') . "</th>
|
||||
<th>" . $this->lang->line('receiver'). "</th>
|
||||
<th>" . $this->lang->line('Montant') . "</th>
|
||||
|
@ -204,46 +113,6 @@
|
|||
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
// output data of each row
|
||||
foreach ($result->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 "<tr>
|
||||
<td >".$origin."</td>
|
||||
<td >$destination</td>
|
||||
<td>". $fmt->format($row->montant)."</td>
|
||||
<td>" . $row->dateAjout . "</td>
|
||||
<td > " . $row->dateModif . "</td>
|
||||
<td>" . traitementTemps($row->temps, $row->dateAjout,$this) . "</td>"; ?>
|
||||
<td><?= getDelayOfTreatmentInSeconds($row->temps, $row->dateAjout)/60 ?></td>
|
||||
<td><button id="cancelDemand" class="btn btn-danger" data-id-demand="<?= $row->demande_id ?>" <?php if($row->canceled_by_hypervisor) echo "disabled" ?> ><?php echo $this->lang->line('cancel'); ?></button></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
|
||||
<?php
|
||||
} else {
|
||||
echo $this->lang->line('Aucune demande');
|
||||
}
|
||||
} else {
|
||||
echo $this->lang->line('Aucune demande');
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</table>
|
||||
|
||||
|
@ -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: "<?//=$this->lang->line('incoming_credits_requests_accepted')?>//"
|
||||
// },
|
||||
// {
|
||||
// extend: 'csvHtml5',
|
||||
// title: "<?//=$this->lang->line('incoming_credits_requests_accepted')?>//"
|
||||
// },
|
||||
// {
|
||||
// extend: 'pdfHtml5',
|
||||
// orientation: 'landscape',
|
||||
// pageSize: 'LEGAL',
|
||||
// title: "<?//=$this->lang->line('incoming_credits_requests_accepted')?>//"
|
||||
// }
|
||||
// ]
|
||||
//});
|
||||
|
||||
var table = $('#listeMembres1').DataTable({
|
||||
// Processing indicator
|
||||
"processing": true,
|
||||
"language": {
|
||||
"processing": "<?= $this->lang->line('loading') ?>"
|
||||
},
|
||||
// DataTables server-side processing mode
|
||||
"serverSide": true,
|
||||
// Initial no order.
|
||||
"order": [],
|
||||
// Load data from an Ajax source
|
||||
"ajax": {
|
||||
"url": "<?php echo base_url('pagination/AcceptedCreditRequests/getLists'); ?>",
|
||||
"data":{
|
||||
"startDate" : "<?= $startDate?>",
|
||||
"endDate" : "<?= $endDate?>",
|
||||
"id_network" : <?= $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: "<?=$this->lang->line('incoming_credits_requests_accepted')?>"
|
||||
"extend": 'excelHtml5',
|
||||
title: "<?= $this->lang->line('incoming_credits_requests_accepted') ?>",
|
||||
trim: false,
|
||||
"action": newexportaction
|
||||
},
|
||||
{
|
||||
extend: 'csvHtml5',
|
||||
title: "<?=$this->lang->line('incoming_credits_requests_accepted')?>"
|
||||
title: "<?= $this->lang->line('incoming_credits_requests_accepted') ?>",
|
||||
trim: false,
|
||||
"action": newexportaction
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'LEGAL',
|
||||
title: "<?=$this->lang->line('incoming_credits_requests_accepted')?>"
|
||||
}
|
||||
title: "<?= $this->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();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
|
@ -140,7 +84,7 @@
|
|||
<thead>
|
||||
<?php
|
||||
echo "<tr class='label-primary'>
|
||||
|
||||
<th> ID</th>
|
||||
<th>" . $this->lang->line('Emetteur') . "</th>
|
||||
<th>" . $this->lang->line('receiver'). "</th>
|
||||
<th>" . $this->lang->line('Montant') . "</th>
|
||||
|
@ -168,6 +112,7 @@
|
|||
}
|
||||
|
||||
echo "<tr>
|
||||
<td >".$row->demande_id."</td>
|
||||
<td >".$origin."</td>
|
||||
<td >$destination</td>
|
||||
<td>". $fmt->format($row->montant)."</td>
|
||||
|
@ -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),
|
||||
}
|
||||
],
|
||||
|
|
|
@ -188,6 +188,9 @@ use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
|
|||
var table = $('#transactions').DataTable({
|
||||
// Processing indicator
|
||||
"processing": true,
|
||||
"language": {
|
||||
"processing": "<?= $this->lang->line('loading') ?>"
|
||||
},
|
||||
// DataTables server-side processing mode
|
||||
"serverSide": true,
|
||||
// Initial no order.
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
"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"
|
||||
|
|
Loading…
Reference in New Issue