From dc2e5f68be52ec6a3d8f0d9e772751c2c2a19152 Mon Sep 17 00:00:00 2001 From: DJERY-TOM Date: Tue, 28 Apr 2020 23:23:15 +0100 Subject: [PATCH] + Fix demande.php for Hyperviseur and Superviseur --- application/controllers/Gestion.php | 36 +++--- application/controllers/Hyperviseur_dash.php | 33 ++--- application/controllers/Superviseur_dash.php | 22 +++- application/models/User_model.php | 32 +++-- application/views/demande.php | 53 ++++---- application/views/header_hyp.php | 121 +++++++++++++----- application/views/header_sup.php | 6 +- application/views/historique_transactions.php | 103 +++++++-------- 8 files changed, 244 insertions(+), 162 deletions(-) diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 9ef8f17b..fac37986 100644 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -1549,11 +1549,7 @@ class Gestion extends CI_Controller $network_id = $this->input->get('id'); if($this->input->get('history')){ - if($this->input->get('d') & $this->input->get('f')){ - $this->historique($network_id,$this->input->get('d'),$this->input->get('f')); - }else{ - $this->historique($network_id,null,null); - } + $this->historique($network_id,$this->input->get('d'),$this->input->get('f')); }else{ $taux = $this->user_model->getTaux($network_id); if ($taux != null) { @@ -1567,7 +1563,7 @@ class Gestion extends CI_Controller $data['taux_bq_d'] = $taux->part_banque_depot; $data['taux_bq_r'] = $taux->part_banque_retrait; $data['frais_d'] = $taux->frais_min_banque_depot; - $data['transactions'] = $this->user_model->getTransactions($network_id); + $data['transactions'] = $this->user_model->getTransactions(null,null,$network_id); $totalCommissionBanque = 0; if($data['transactions']){ foreach ($data['transactions']->result() as $row) { @@ -1718,22 +1714,22 @@ class Gestion extends CI_Controller private function historique($network_id ,$startDate ,$endDate) { - $transactions = array(); - $res= $this->user_model->getTransactions($network_id); - if($res) - $transactions = $res->result(); - - if($startDate!=null & $endDate != null){ - if ($transactions){ - $transactions = array_filter($transactions, function ($trans) use ($endDate ,$startDate){ - $date = strtotime($trans->date_created); - return $date >= strtotime($startDate) && $date <= strtotime($endDate) ; - }); - } - } $data['startDate'] = $startDate; $data['endDate'] = $endDate; - $data['transactions'] = $transactions; + $endDate = Date('Y-m-d', strtotime($endDate."+1 day")); + $data['transactions'] = $this->user_model->getTransactions($startDate , $endDate ,$network_id); +// if($res) +// $transactions = $res->result(); +// +// if($startDate!=null & $endDate != null){ +// if ($transactions){ +// $transactions = array_filter($transactions, function ($trans) use ($endDate ,$startDate){ +// $date = strtotime($trans->date_created); +// return $date >= strtotime($startDate) && $date <= strtotime($endDate) ; +// }); +// } +// } + $data['active'] = "wallet"; $data['alert'] = ""; $data['networks'] = $this->user_model->getAllActivatedNetworks(); diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 7d3ff909..b856c7fd 100644 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -187,29 +187,28 @@ class Hyperviseur_dash extends CI_Controller $data['message'] = "Login first!"; $this->load->view('login', $data); } else { - if($this->input->post('super') or $this->input->get("u") !== null) + if($this->input->get("u") !== null) { - $super = $this->input->post('super'); - $this->session->set_userdata("current_super_demande", $this->input->post('super')); - if($this->input->post('super') == null){ - $super = $this->input->get("u"); - $this->session->set_userdata("current_super_demande", $super); - } + $super = $this->input->get("u"); + $this->session->set_userdata("current_super_demande", $super); $debut =""; $fin = ""; if($this->input->get("d") !== null){ - $debut = $this->input->get("d"); $fin = $this->input->get("f"); }else{ - $fin = date('Y-m-d H:i:s'); - $debut = Date('Y-m-d H:i:s', strtotime("-3 days")); + $fin = date('Y-m-d'); + $debut = Date('Y-m-d', strtotime("-5 days")); } + $data['debut'] = $debut; + $data['fin'] = $fin; + $fin = Date('Y-m-d', strtotime($fin."+1 day")); $ville = $this->session->userdata('ville'); $data['active'] = "demandes"; $data['type'] = $this->lang->line('crédits'); + $data['demand_type'] = 'credit'; $data['alert'] = ""; $data['token'] = $this->session->userdata('token'); $data['email'] = $this->session->userdata('email'); @@ -262,7 +261,11 @@ class Hyperviseur_dash extends CI_Controller $this->load->view('login', $data); } else { $network = $this->session->userdata('network'); - + $debut = $this->input->get("d"); + $fin = $this->input->get("f"); + $data['debut'] = $debut; + $data['fin'] = $fin; + $data['demand_type'] = 'adhesion'; $data['active'] = "demandesAd"; $data['alert'] = ""; $data['token'] = $this->session->userdata('token'); @@ -274,10 +277,10 @@ class Hyperviseur_dash extends CI_Controller $data['adresse'] = $this->session->userdata('adresse'); $data['category'] = $this->session->userdata('category'); $data['network'] = $this->session->userdata('network'); - $data['tab_fastDemande'] = $this->user_model->getRangeASCDemandesAd($this->session->userdata('member_code')); - $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesAd($this->session->userdata('member_code')); - $data['temp_moyen'] = $this->user_model->getTempsMoyenAd($this->session->userdata('member_code')); - $data['list'] = $this->user_model->getDemandesAdForSuper($this->session->userdata('member_code')); + $data['tab_fastDemande'] = $this->user_model->getRangeASCDemandesAd($debut, $fin ,$this->session->userdata('member_code')); + $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesAd($debut, $fin ,$this->session->userdata('member_code')); + $data['temp_moyen'] = $this->user_model->getTempsMoyenAd($debut, $fin ,$this->session->userdata('member_code')); + $data['list'] = $this->user_model->getDemandesAdForSuper($debut, $fin , $this->session->userdata('member_code')); $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays')); $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); diff --git a/application/controllers/Superviseur_dash.php b/application/controllers/Superviseur_dash.php index 417fd3cb..f7ac0776 100644 --- a/application/controllers/Superviseur_dash.php +++ b/application/controllers/Superviseur_dash.php @@ -118,10 +118,14 @@ class Superviseur_dash extends CI_Controller $user_geo = $this->input->get("u"); $debut = $this->input->get("d"); $fin = $this->input->get("f"); + $data['debut'] = $debut; + $data['fin'] = $fin; + $fin = Date('Y-m-d', strtotime($fin."+1 day")); // Increment date because SQL BETWEEN $network = $this->session->userdata('network'); $data['active'] = "demandes"; $data['type'] = $this->lang->line('crédits'); + $data['demand_type'] = 'credit'; $data['alert'] = ""; $data['token'] = $this->session->userdata('token'); $data['email'] = $this->session->userdata('email'); @@ -165,9 +169,13 @@ class Superviseur_dash extends CI_Controller $this->load->view('login', $data); } else { $network = $this->session->userdata('network'); - + $debut = $this->input->get("d"); + $fin = $this->input->get("f"); + $data['debut'] = $debut; + $data['fin'] = $fin; $data['active'] = "demandesAd"; $data['alert'] = ""; + $data['demand_type'] = 'adhesion'; $data['token'] = $this->session->userdata('token'); $data['email'] = $this->session->userdata('email'); $data['firstname'] = $this->session->userdata('firstname'); @@ -177,12 +185,14 @@ class Superviseur_dash extends CI_Controller $data['adresse'] = $this->session->userdata('adresse'); $data['category'] = $this->session->userdata('category'); $data['network'] = $this->session->userdata('network'); - $data['tab_fastDemande'] = $this->user_model->getRangeASCDemandesAd($this->session->userdata('member_code')); - $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesAd($this->session->userdata('member_code')); + $data['tab_fastDemande'] = $this->user_model->getRangeASCDemandesAd($debut, $fin ,$this->session->userdata('member_code')); + $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesAd($debut, $fin ,$this->session->userdata('member_code')); $data['mydem'] = $this->user_model->getDemandesHyperForSuper($this->session->userdata('member_code')); - $data['temp_moyen'] = $this->user_model->getTempsMoyenAd($this->session->userdata('member_code')); - $data['list'] = $this->user_model->getDemandesAdForSuper($this->session->userdata('member_code')); - $data['type'] = 'adhésions'; + $data['temp_moyen'] = $this->user_model->getTempsMoyenAd($debut, $fin ,$this->session->userdata('member_code')); + $data['list'] = $this->user_model->getDemandesAdForSuper($debut, $fin ,$this->session->userdata('member_code')); + $data['type'] = $this->lang->line('Adhésion'); + $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); + $data['geolocated_user'] = $this->user_model->getSuperNameAndCodeForSup($this->session->userdata('member_code')); $this->load->view('header_sup', $data); $this->load->view('demande'); $this->load->view('footer'); diff --git a/application/models/User_model.php b/application/models/User_model.php index d2d94f16..0ddad7df 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -313,15 +313,15 @@ class User_model extends CI_Model } - public function getDemandesAdForSuper($member_code){ - + public function getDemandesAdForSuper($debut , $fin , $member_code){ + $chain = $debut ? "AND d.date_creation BETWEEN '".$debut."' AND '".$fin."'" : ""; $query = $this->db->query("SELECT *, (SELECT TIMESTAMPDIFF(SECOND,date_creation,date_modified) FROM demandeAdhesion AS req_im WHERE req_im.id=d.id_demande) AS temps FROM info_demandesAdhesion AS d - WHERE d.code_membre='".$member_code."' - ORDER BY date_creation"); + WHERE d.code_membre='".$member_code."'".$chain. + "ORDER BY date_creation"); if($query->num_rows()>0){ return $query; @@ -558,7 +558,7 @@ class User_model extends CI_Model } - public function getRangeASCDemandesAd($codeParrain){ + public function getRangeASCDemandesAd($debut , $fin , $codeParrain){ if($codeParrain=='all'){ $query = $this->db->query("SELECT d.phone AS emetteur, d.code_membre AS superviseur, d.categorie AS montant,d.date_creation AS dateA,d.date_modified AS dateM, @@ -570,14 +570,15 @@ class User_model extends CI_Model ORDER BY temps LIMIT 5"); }else{ + $chain = $debut ? "AND d.date_creation BETWEEN '".$debut."' AND '".$fin."'" : ""; $query = $this->db->query("SELECT d.phone AS emetteur, d.code_membre AS superviseur, d.date_creation AS dateA,d.date_modified AS dateM, (SELECT TIMESTAMPDIFF(SECOND,date_creation,date_modified) FROM demandeAdhesion AS req_im WHERE req_im.etat=1 AND req_im.id=d.id_demande) AS temps FROM info_demandesAdhesion AS d - WHERE etat=1 AND d.code_membre='".$codeParrain."' - ORDER BY temps + WHERE etat=1 AND d.code_membre='".$codeParrain."'". $chain + ."ORDER BY temps LIMIT 5"); } @@ -661,7 +662,7 @@ class User_model extends CI_Model } - public function getRangeDESCDemandesAd($codeParrain){ + public function getRangeDESCDemandesAd($debut, $fin , $codeParrain){ if($codeParrain=='all'){ $query = $this->db->query("SELECT d.phone AS emetteur, d.code AS superviseur, d.categorie AS montant,d.dateAjout AS dateA,d.dateModif AS dateM, @@ -673,14 +674,15 @@ class User_model extends CI_Model ORDER BY temps DESC LIMIT 5"); }else{ + $chain = $debut ? "AND d.date_creation BETWEEN '".$debut."' AND '".$fin."'" : ""; $query = $this->db->query("SELECT d.phone AS emetteur, d.code_membre AS superviseur, d.date_creation AS dateA,d.date_modified AS dateM, (SELECT TIMESTAMPDIFF(SECOND,date_creation,date_modified) FROM demandeAdhesion AS req_im WHERE req_im.etat=1 AND req_im.id=d.id_demande) AS temps FROM info_demandesAdhesion AS d - WHERE etat=1 AND d.code_membre='".$codeParrain."' - ORDER BY temps DESC + WHERE etat=1 AND d.code_membre='".$codeParrain."'".$chain. + "ORDER BY temps DESC LIMIT 5"); } @@ -744,12 +746,13 @@ class User_model extends CI_Model } - public function getTempsMoyenAd($codeParrain){ + public function getTempsMoyenAd($debut, $fin, $codeParrain){ if($codeParrain=='all'){ $query = $this->db->query("SELECT AVG(TIMESTAMPDIFF(SECOND,dateAjout,dateModif)) AS temps FROM demande_superviseur WHERE statut=1"); }else{ - $query = $this->db->query("SELECT AVG(TIMESTAMPDIFF(SECOND,date_creation,date_modified)) AS temps FROM info_demandesAdhesion WHERE etat=1 AND code_membre='".$codeParrain."'"); + $chain = $debut ? "AND date_creation BETWEEN '".$debut."' AND '".$fin."'" : ""; + $query = $this->db->query("SELECT AVG(TIMESTAMPDIFF(SECOND,date_creation,date_modified)) AS temps FROM info_demandesAdhesion WHERE etat=1 AND code_membre='".$codeParrain."'".$chain); } if($query->num_rows()>0){ @@ -1868,10 +1871,11 @@ class User_model extends CI_Model } } - public function getTransactions($id_network){ + public function getTransactions($debut , $fin , $id_network){ + $chain = $debut ? " AND date_created BETWEEN '".$debut."' AND '".$fin."'" : ""; $query = $this->db->query("SELECT * FROM infos_transaction - WHERE `network_id`=".$id_network); + WHERE `network_id`=".$id_network.$chain); if($query->num_rows()>0){ return $query; }else{ diff --git a/application/views/demande.php b/application/views/demande.php index 4732bef8..b0f0824b 100644 --- a/application/views/demande.php +++ b/application/views/demande.php @@ -86,18 +86,19 @@
- - +
session->userdata('category') == "super"){ - echo "".$nameOfcurentGeolocatedUser.""; + if(isset($nameOfcurentGeolocatedUser)) + echo "".$nameOfcurentGeolocatedUser.""; } ?> Période - - +
@@ -1438,27 +1439,35 @@ }); - $('#send-getDemandes').click(function(){ - var debut = startDate.format('YYYY-MM-DD'); - var fin = endDate.format('YYYY-MM-DD'); - var user_geo = $('#selected-geo-user').find(":selected").val(); - window.location.replace(""+"?d="+debut+"&f="+fin+"&u="+user_geo); - }); - $(function() { + const type = $('#picker').data('type'); + const category = $('#picker').data('category'); $('input[name="daterange"]').daterangepicker({ - opens: 'left' + opens: 'left', + autoUpdateInput: false, + locale: { + format: 'YYYY-MM-DD', + cancelLabel: 'Clear' + } }, function(start, end, label) { - startDate = start; - endDate = end; - }); - }); + const debut = start.format('YYYY-MM-DD'); + const fin = end.format('YYYY-MM-DD'); + const user_geo = GetURLParameter("u"); + if(category == 'super'){ + if(type == 'credit'){ + window.location.replace(""+"?d="+debut+"&f="+fin+"&u="+user_geo); + }else if (type == 'adhesion'){ + window.location.replace(""+"?d="+debut+"&f="+fin); + } + }else if (category == 'hyper'){ + if(type == 'credit'){ + window.location.replace(""+"?d="+debut+"&f="+fin+"&u="+user_geo); + }else if (type == 'adhesion'){ + window.location.replace(""+"?d="+debut+"&f="+fin); + } - $('#change-periode').click(function(){ - var debut = startDate.format('YYYY-MM-DD'); - var fin = endDate.format('YYYY-MM-DD'); - var user_geo = GetURLParameter("u"); - window.location.replace(""+"?d="+debut+"&f="+fin+"&u="+user_geo); + } + }); }); diff --git a/application/views/header_hyp.php b/application/views/header_hyp.php index d85330d7..fd5b34a1 100644 --- a/application/views/header_hyp.php +++ b/application/views/header_hyp.php @@ -1,7 +1,6 @@ - @@ -202,44 +201,102 @@ + + + + + + + diff --git a/application/views/header_sup.php b/application/views/header_sup.php index 3da7e495..610afb0b 100644 --- a/application/views/header_sup.php +++ b/application/views/header_sup.php @@ -117,11 +117,11 @@ lang->line('Demandes de crédits'); ?> - +
  • "> diff --git a/application/views/historique_transactions.php b/application/views/historique_transactions.php index dfe16186..a372e934 100755 --- a/application/views/historique_transactions.php +++ b/application/views/historique_transactions.php @@ -67,56 +67,59 @@

    Historique des transactions

  • - 0) { - $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); + + if($transactions){ + $numrows = $transactions->num_rows(); + $num = 0; + if ($numrows > 0) { + $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL ); + ?> + + + + + + + + + + + + + + + + + result() as $row) { + $num++; + $type = $row->type_transac == 'credit' ? 'DEPOT' : 'RETRAIT'; + echo " + + + + + + + + + "; + + } + ?> + + + lang->line('Aucune transaction'); + } + }else { + echo $this->lang->line('Aucune transaction'); + } ?> -
    ID Type MontantCommission de la banqueCommission de l'hyperviseurCommission du superviseurCommission de l'agentDate
    $row->id".strtoupper($type)."".$fmt->format($row->montant)."".$fmt->format( $row->commission_banque)."".$fmt->format( $row->commission_hyp)."".$fmt->format( $row->commission_sup)."".$fmt->format( $row->commission_ag)." $row->date_created
    - - - - - - - - - - - - - - - type_transac == 'credit' ? 'DEPOT' : 'RETRAIT'; - echo " - - - - - - - - - "; - - } - ?> - - - lang->line('Aucune transaction'); - } - - ?> -
    ID Type MontantCommission de la banqueCommission de l'hyperviseurCommission du superviseurCommission de l'agentDate
    $row->id".strtoupper($type)."".$fmt->format($row->montant)."".$fmt->format( $row->commission_banque)."".$fmt->format( $row->commission_hyp)."".$fmt->format( $row->commission_sup)."".$fmt->format( $row->commission_ag)." $row->date_created
    @@ -162,12 +165,12 @@ opens: 'left', autoUpdateInput: false, locale: { - format: 'DD-MM-YYYY', + format: 'YYYY-MM-DD', cancelLabel: 'Clear' } }, function (start, end, label) { - const debut = start.format('DD-MM-YYYY'); - const fin = end.format('DD-MM-YYYY'); + const debut = start.format('YYYY-MM-DD'); + const fin = end.format('YYYY-MM-DD'); window.location = "" + "?id=118&history=true" + "&d=" + debut + "&f=" + fin; });