+ Update taux de partage

This commit is contained in:
Djery-Tom 2020-06-23 07:41:44 +01:00
parent 898621f3bf
commit 99316612d9
6 changed files with 391 additions and 23 deletions

View File

@ -1622,6 +1622,8 @@ class Gestion extends CI_Controller
$this->load->view('gestion_wallet');
elseif ($taux->type == 'ilink')
$this->load->view('gestion_wallet_ilink');
elseif ($taux->type == 'autre')
$this->load->view('gestion_wallet_autre');
$this->load->view('footer');
}
}
@ -1818,26 +1820,30 @@ class Gestion extends CI_Controller
// Asynchrous method
$network_id = $_POST['network_id'];
$pool = Pool::create();
$pool->add(function () use ($network_id) {
// Fetch all agents , hyperviseur , superviseur
$f_agents = $this->user_model->getAllAgentsForNetwork($network_id) ;
if ($f_agents){
foreach($f_agents->result() AS $row){
//Create wallet if it not exist
$res = $this->user_model->getWallet($row->agent_id);
if($res){
// Reinitialize the wallet
$type = $_POST['type'];
if($type != 'autre'){
$pool = Pool::create();
$pool->add(function () use ($network_id) {
// Fetch all agents , hyperviseur , superviseur
$f_agents = $this->user_model->getAllAgentsForNetwork($network_id) ;
if ($f_agents){
foreach($f_agents->result() AS $row){
//Create wallet if it not exist
$res = $this->user_model->getWallet($row->agent_id);
if($res){
// Reinitialize the wallet
// $this->user_model->reinitializeWallet($res->first_row()->wallet_id);
}else{
$this->user_model->addWallet($row->agent_id);
}else{
$this->user_model->addWallet($row->agent_id);
}
}
}
}
})->then(function () {
})->then(function () {
});
await($pool);
}
});
await($pool);
}
private function historique($network_id ,$startDate ,$endDate, $type)

View File

@ -987,7 +987,7 @@ class Hyperviseur_dash extends CI_Controller
if (isset($country)) {
$data['country_id'] = $country;
$data['country'] = $this->user_model->getCountry($country)->first_row();
$res = $this->user_model->getActiveNetworks($country);
$res = $this->user_model->getActiveNetworksByCountry($country);
$data['networks'] = [];
if($res){
$result = $res->result();
@ -1006,7 +1006,7 @@ class Hyperviseur_dash extends CI_Controller
$this->load->view('footer');
return;
}
$res = $this->user_model->getActiveCountries();
$res = $this->user_model->getWalletsCountries();
$data['countries'] = [];
if($res){
$result = $res->result();

View File

@ -2080,7 +2080,7 @@ class User_model extends CI_Model
// Wallet
public function getAllActivatedNetworks(){
$query = $this->db->query("SELECT networks.name AS network,networks.status AS status,networks.id,countries.name AS country,networks.country_id , configWallet.id_network FROM `networks`
$query = $this->db->query("SELECT networks.name AS network,networks.status AS status,networks.id,countries.name AS country,networks.country_id , configWallet.id_network , configWallet.type FROM `networks`
INNER JOIN countries ON networks.country_id=countries.id LEFT JOIN configWallet ON configWallet.id_network = networks.id WHERE status = 1");
if($query->num_rows()>0){
return $query;
@ -2476,4 +2476,14 @@ class User_model extends CI_Model
return false;
}
}
public function getActiveNetworksByCountry($country_id){
$query = $this->db->query("SELECT networks.name , networks.id , configWallet.type FROM `networks` INNER JOIN countries ON networks.country_id=countries.id
INNER JOIN configWallet ON configWallet.id_network = networks.id WHERE status = 1 AND countries.id = $country_id");
if($query->num_rows()>0){
return $query;
}else{
return false;
}
}
}

View File

@ -0,0 +1,349 @@
<link rel="stylesheet" href="<?php echo base_url('bower_components/jvectormap/jquery-jvectormap.css') ?>">
<link rel="stylesheet"
href="<?php echo base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
<link rel="stylesheet" href="<?php echo base_url('bower_components/bootstrap-daterangepicker/daterangepicker.css') ?>">
<link rel="stylesheet" href="<?php echo base_url('plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css') ?>">
<link rel="stylesheet"
href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<?php
function convertDate($date)
{
$month = null;
switch ($date) {
case "Jan":
$month = 1;
break;
case "Feb":
$month = 2;
break;
case "Mar":
$month = 3;
break;
case "Apr":
$month = 4;
break;
case "May":
$month = 5;
break;
case "Jun":
$month = 6;
break;
case "Jul":
$month = 7;
break;
case "Aug":
$month = 8;
break;
case "Sep":
$month = 9;
break;
case "Oct":
$month = 10;
break;
case "Nov":
$month = 11;
break;
case "Dec":
$month = 12;
break;
}
return $month;
}
$month = time();
$months[] = convertDate(date("M"));
$label_months [] = date("M") . " " . date("Y");
$years[] = date("Y");
for ($i = 1; $i <= 11; $i++) {
$month = strtotime('last month', $month);
$months [] = convertDate(date("M", $month));
$years[] = date("Y", $month);
$label_months [] = date("M", $month) . " " . date("Y", $month);
}
/**
** Retraits
**/
$date = date("Y");
$retraits_data[] = '';
$retraits_data = array();
for ($i = 1; $i <= 12; $i++) {
$retraits_query_mounth = $this->db->query("SELECT id FROM infos_transaction
WHERE network_id='" . $network_id . "'
AND MONTH(date_created) = '" . $months[$i - 1] . "'
AND YEAR(date_created) = '" . $years[$i - 1] . "'
AND type_transac='debit'");
$retraits_data[] = $retraits_query_mounth->num_rows();
}
$startDate = (new DateTime('01-' . $months[11] . '-' . $years[11]))->format('Y-m-d H:i:s');
$endDate = date_create_from_format('m/Y', $months[0] . '/' . $years[0])->format('Y-m-d H:i:s');
$retraits = $this->db->query("SELECT * FROM infos_transaction
WHERE network_id='" . $network_id . "'
AND date_created BETWEEN '" . $startDate . "' AND '" . $endDate . "'
AND type_transac='debit'");
/**
** Dépots
**/
$date = date("Y");
$depots_data[] = '';
$depots_data = array();
for ($i = 1; $i <= 12; $i++) {
$depots_query_mounth = $this->db->query("SELECT id FROM infos_transaction
WHERE network_id='" . $network_id . "'
AND MONTH(date_created) = '" . $months[$i - 1] . "'
AND YEAR(date_created) = '" . $years[$i - 1] . "'
AND type_transac='credit'");
$depots_data[] = $depots_query_mounth->num_rows();
}
$depots = $this->db->query("SELECT * FROM infos_transaction
WHERE network_id='" . $network_id . "'
AND date_created BETWEEN '" . $startDate . "' AND '" . $endDate . "'
AND type_transac='credit'");
if ($transactions != false) {
$transac = $transactions->num_rows();
$array_transac = array();
$num = 0;
if ($transac > 0) {
foreach ($transactions->result() as $row) {
$num++;
$array_transac[] = $row->type_transac;
}
$vals_transac = array_count_values($array_transac);
$pieChart = array();
foreach (array_keys($vals_transac) as $paramName) {
$color = dechex(rand(0x000000, 0xFFFFFF));
$trash = array("value" => $vals_transac[$paramName],
"color" => "#" . $color,
"highlight" => "#" . $color,
"label" => $paramName);
$pieChart[] = $trash;
}
}
} else {
$pieChart = array();
}
$fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL );
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?php echo $this->lang->line('Gestion des wallets'). ' '. $network .' - '.$country; ?>
</h1>
<?php
$site_url = base_url();
if ($alert == "ok") {
if (!$success == "ok") {
?>
<div class='alert alert-danger alert-dismissible col-xs-6'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
<h4><i class='icon fa fa-ban'></i> Erreur!</h4>
<?php echo $message; ?>
</div>
<?php
} else {
?>
<div class="alert alert-success alert-dismissible col-xs-6">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h4><i class="icon fa fa-check"></i> Success!</h4>
<?php echo $message; ?>
</div>
<?php
}
}
?>
</section>
<section class="content">
<div class="row centered">
<div class="col-lg-2 col-lg-offset-2 col-xs-6">
<div class="small-box bg-aqua-active">
<div class="inner">
<h3><?php echo $taux_u_w_cart; ?><sup style="font-size: 20px">%</sup></h3>
<p><?php echo $this->lang->line('rate_com_user_wallet_cart') ?> </p>
</div>
<div class="icon">
<i class="ion ion-android-arrow-up"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">
<?php echo $this->lang->line('Historique des 12 derniers mois'); ?></h3>
<div class="box-tools">
<a class="btn btn-primary" href="<?php echo current_url().($network_id ? '?id='.$network_id . '&history=transaction' : '')?>">
<?php echo $this->lang->line('transactions_historic'); ?>
</a>
<a class="btn btn-info" href="<?php echo current_url().($network_id ? '?id='.$network_id . '&history=recharge' : '')?>">
<?php echo $this->lang->line('recharge_historic'); ?>
</a>
</div>
</div>
<div class="box-body">
<div class="chart" id="chart">
<canvas id="barChart" style="height:230px"></canvas>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title">
<?php echo $this->lang->line("Parts dépots & retraits"); ?></h3>
</div>
<div class="box-body" id="chart2">
<canvas id="pieChart" style="height:250px"></canvas>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('Commission Hyperviseur') ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<table id="example1" class="table table-bordered table-hover">
<thead>
<tr>
<?php
echo "<th>".$this->lang->line('Nom')."</th>
<th>".$this->lang->line('Solde Principal')."</th>
<th>".$this->lang->line('Solde Commission')."</th>
<th>".$this->lang->line('Commission banque')."</th>
<th>".$this->lang->line('DEPOT'). 's'."</th>
<th>".$this->lang->line('RETRAIT').'s'."</th>";
?>
</tr>
</thead>
<tbody>
<?php
if ($walletHyper) {
$fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL );
echo "<tr>
<td>" . $walletHyper->first_row()->lastname . "</td>
<td>" . $fmt->format($walletHyper->first_row()->balance_princ) . "</td>
<td>" . $fmt->format($walletHyper->first_row()->balance_com) . "</td>
<td>" . $fmt->format($totalCommissionBanque) . "</td>";
echo "<td>" . $depots->num_rows() . "</td>
<td>" . $retraits->num_rows() . "</td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- jQuery 3 -->
<script src="<?php echo base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
<!-- Bootstrap 3.3.7 -->
<script src="<?php echo base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
<script src="<?php echo base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
<script src="<?php echo base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
<!-- Slimscroll -->
<script src="<?php echo base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
<!-- FastClick -->
<script src="<?php echo base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
<!-- AdminLTE App -->
<script src="<?php echo base_url('dist/js/adminlte.min.js') ?>"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?php echo base_url('dist/js/demo.js') ?>"></script>
<script src="<?php echo base_url('bower_components/moment/min/moment.min.js') ?>"></script>
<script src="<?php echo base_url('bower_components/bootstrap-daterangepicker/daterangepicker.js') ?>"></script>
<script
src="<?php echo base_url('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') ?>"></script>
<scriptf
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></scriptf>
<!-- ChartJS -->
<script src="<?php echo base_url('bower_components/chart.js/Chart.js') ?>"></script>
<script>
$(function () {
$('#example1').DataTable();
// $('#example1').DataTable({
// "aLengthMenu": [[5, 10, 15, -1], [5, 10, 5, "All"]],
// "iDisplayLength": 5
// });
// $('#example2').DataTable({
// 'paging' : true,
// 'lengthChange': false,
// 'searching' : false,
// 'ordering' : true,
// 'info' : true,
// 'autoWidth' : false
// })
})
</script>
<script>
var areaChartData = {
labels: <?php echo json_encode($label_months) ?>,
datasets: [
{
label: 'Electronics',
fillColor: 'rgba(255, 162, 0, 1)',
strokeColor: 'rgba(255, 162, 0, 1)',
pointColor: 'rgba(255, 162, 0, 1)',
pointStrokeColor: '#ffa200',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(220,220,220,1)',
data: <?php echo json_encode($depots_data) ?>
},
{
label: 'Digital Goods',
fillColor: 'rgba(0, 187, 255, 1)',
strokeColor: 'rgba(0, 187, 255, 1)',
pointColor: '#00bbff',
pointStrokeColor: 'rgba(0, 187, 255, 1)',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(0, 187, 255, 1)',
data: <?php echo json_encode($retraits_data) ?>
}
]
};
var Pie = '<?php echo json_encode($pieChart) ?>';
if (Pie === '[]') {
var select = document.getElementById('chart2');
$(select.children).hide();
$(select).append("<p>Aucune transaction</p>");
} else {
Pie = JSON.parse(Pie);
}
</script>
<!-- Page script -->
<script src="<?php echo base_url('dist/js/custom.js') ?>"></script>

View File

@ -59,6 +59,7 @@
<tr>
<th align='center'></th>
<th><?php echo $this->lang->line('Nom'); ?></th>
<th align='center'>Wallet</th>
<th align='center'> <?php echo $this->lang->line('share_rate')?></th>
<th align='center'> Action</th>
</tr>
@ -71,7 +72,8 @@
//$member_code = randomString1(10);
echo "<tr>
<td align='center'>$num</td>
<td >$row->name</td>";
<td>$row->name</td>
<td><span class='label label-success'>".strtoupper($row->type)."</span></td>";
?>
<?php
if ($row->rate != null ) {

View File

@ -77,7 +77,7 @@
<?php
if($row->id_network){
?>
<td><span class="label label-success"><?php echo $this->lang->line('Actif'); ?></span></td>
<td><span class="label label-success"><?= strtoupper($row->type) ?></span></td>
<td><button type="button" data-toggle="modal" data-target="#disableWallet" data-network-id="<?php echo $row->id ?>" class="btn btn-danger openModal"><?php echo $this->lang->line('Désactiver'); ?></button></td>
<?php
}else{
@ -139,7 +139,8 @@
<div class="login-box">
<div class="login-box-body">
<button type="button" class="btn btn-primary enableWallet" style="width: 100% ; margin-bottom: 15px" value="visa" data-dismiss="modal">VISA</button>
<button type="button" class="btn btn-primary enableWallet" value="ilink" style="width: 100%" data-dismiss="modal">ILINK WORLD</button>
<button type="button" class="btn btn-primary enableWallet" value="ilink" style="width: 100%; margin-bottom: 15px" data-dismiss="modal">ILINK WORLD</button>
<button type="button" class="btn btn-primary enableWallet" value="autre" style="width: 100%" data-dismiss="modal">AUTRE</button>
</div>
</div>
@ -228,7 +229,7 @@
url : '<?php echo base_url('index.php/Gestion/generateAllWallets')?>',
type : 'POST',
dataType : 'json',
data : {"network_id": network_id},
data : {"network_id": network_id , "type" : type},
async : true ,
timeout : 0,
success : function () {