+ Fix demande.php for Hyperviseur and Superviseur

This commit is contained in:
DJERY-TOM 2020-04-28 23:23:15 +01:00
parent 09de7da955
commit dc2e5f68be
8 changed files with 244 additions and 162 deletions

View File

@ -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);
}
}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();

View File

@ -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);
}
$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'));

View File

@ -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');

View File

@ -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{

View File

@ -86,18 +86,19 @@
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="info-box">
<span id="change-periode" style="cursor: pointer;" class="info-box-icon bg-aqua"><i class="ion ion-android-arrow-right"></i></span>
<span class="info-box-icon bg-aqua"><i class="ion ion-android-time"></i></span>
<div class="info-box-content">
<?php
if($this->session->userdata('category') == "super"){
if(isset($nameOfcurentGeolocatedUser))
echo "<span class='info-box-number'>".$nameOfcurentGeolocatedUser."</span>";
}
?>
<span class="info-box-text">Période </span>
<span class="info-box-number">
<input style="background: #fff; cursor: pointer; padding: 1px 1px; border: 1px solid #ccc; width: 100%" type="text" name="daterange" value="01/01/2020 - 12/31/2020" />
<input id="picker" style="background: #fff; cursor: pointer; padding: 1px 1px; border: 1px solid #ccc; width: 100%" type="text" name="daterange" data-type="<?php echo $demand_type?>" data-category="<?php echo $this->session->userdata('category') ?>"
value="<?php echo ($debut!=null & $fin != null) ? $debut. ' - '.$fin : ''?>"
/>
</span>
</span>
</div>
@ -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("<?php echo base_url('index.php/Superviseur_dash/getDemandes')?>"+"?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;
});
});
$('#change-periode').click(function(){
var debut = startDate.format('YYYY-MM-DD');
var fin = endDate.format('YYYY-MM-DD');
var user_geo = GetURLParameter("u");
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("<?php echo base_url('index.php/Superviseur_dash/getDemandes')?>"+"?d="+debut+"&f="+fin+"&u="+user_geo);
}else if (type == 'adhesion'){
window.location.replace("<?php echo base_url('index.php/Superviseur_dash/getDemandesAd')?>"+"?d="+debut+"&f="+fin);
}
}else if (category == 'hyper'){
if(type == 'credit'){
window.location.replace("<?php echo base_url('index.php/Hyperviseur_dash/getDemandes')?>"+"?d="+debut+"&f="+fin+"&u="+user_geo);
}else if (type == 'adhesion'){
window.location.replace("<?php echo base_url('index.php/Hyperviseur_dash/getDemandesAd')?>"+"?d="+debut+"&f="+fin);
}
}
});
});
</script>

View File

@ -1,7 +1,6 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@ -203,43 +202,101 @@
<div class="modal fade" id="modal-default2">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?php echo base_url('index.php/Hyperviseur_dash/getDemandes')?>" method="post">
<form action="#" method="post" id="getDemandes">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><?php echo $this->lang->line('Superviseur'); ?></h4>
<h4 class="modal-title"><?php echo $this->lang->line('Utilisateurs_géolocalisés'); ?></h4>
</div>
<div class="modal-body">
<div class="form-group">
<?php
$result=$superviseurs;
$result=$superviseurs;;
$numrows=$result->num_rows();
if ($numrows > 0) { ?>
<select class="form-control input-lg" name="super" required>
<label for="selected-super">Superviseur</label>
<select class="form-control input-lg" name="geo_user" id="selected-super" required>
<?php foreach($result->result() as $row) {
echo "<option value='".$row->member_code."'>".$row->lastname." - ".$row->member_code."</option>";
} ?>
</select>
<?php }else{
echo "Aucun superviseur";
echo "Aucun utilisateur gééolocalisé";
}
?>
</div>
<div class="info-box-content">
<span class="info-box-text">Période </span>
<span class="info-box-number">
<div id="reportrange" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="fa fa-calendar"></i>&nbsp;
<span></span> <i class="fa fa-caret-down"></i>
</div>
</span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
<button type="submit" class="btn btn-primary"><?php echo $this->lang->line('Continuer'); ?></button>
<button type="button" id="send-getDemandes" class="btn btn-primary"><?php echo $this->lang->line('Continuer'); ?></button>
</div>
</form>
</div>
</div>
</div>
<!-- /.modal -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<script type="text/javascript">
var startDate;
var endDate;
$(function() {
var start = moment().subtract(29, 'days');
var end = moment();
startDate = start;
endDate = end;
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
startDate = start;
endDate = end;
}
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
}, cb);
cb(start, end);
});
$('#send-getDemandes').click(function(){
var debut = startDate.format('YYYY-MM-DD');
var fin = endDate.format('YYYY-MM-DD');
var user_geo = $('#selected-super').find(":selected").val();
window.location.replace("<?php echo base_url('index.php/Hyperviseur_dash/getDemandes')?>"+"?d="+debut+"&f="+fin+"&u="+user_geo);
});
</script>

View File

@ -117,11 +117,11 @@
<i class="fa fa-users"></i> <span><?php echo $this->lang->line('Demandes de crédits'); ?></span>
</a>
</li>
<!-- <li class="<?php // if($active=="demandesAd"){echo "active ";} ?>">
<a href="<?php // echo base_url('index.php/Superviseur_dash/getDemandesAd') ?>">
<li class="<?php if($active=="demandesAd"){echo "active ";} ?>">
<a href="<?php echo base_url('index.php/Superviseur_dash/getDemandesAd') ?>">
<i class="fa fa-users"></i> <span>Demandes d'adhésion</span>
</a>
</li>-->
</li>
<?php if($hasWallet){
?>
<li class="<?php if($active=="wallet"){echo "active";} ?>">

View File

@ -67,9 +67,10 @@
<h3 class="box-title">Historique des transactions</h3>
</div>
<div class="box-body">
<?php
$numrows = sizeof($transactions);
if($transactions){
$numrows = $transactions->num_rows();
$num = 0;
if ($numrows > 0) {
$fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL );
@ -92,7 +93,7 @@
<?php
foreach ($transactions as $row) {
foreach ($transactions->result() as $row) {
$num++;
$type = $row->type_transac == 'credit' ? 'DEPOT' : 'RETRAIT';
echo "<tr>
@ -114,7 +115,9 @@
} else {
echo $this->lang->line('Aucune transaction');
}
}else {
echo $this->lang->line('Aucune transaction');
}
?>
</table>
@ -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 = "<?php echo current_url()?>" + "?id=118&history=true" + "&d=" + debut + "&f=" + fin;
});