+ Add comission banque

This commit is contained in:
DJERY-TOM 2020-04-19 09:51:28 +01:00
parent 9d42162a2c
commit a44199c016
8 changed files with 107 additions and 34 deletions

View File

@ -1560,6 +1560,13 @@ class Gestion extends CI_Controller
$data['taux_bq_r'] = $taux->part_banque_retrait;
$data['frais_d'] = $taux->frais_min_banque_depot;
$data['transactions'] = $this->user_model->getTransactions($network_id);
$totalCommissionBanque = 0;
if($data['transactions']){
foreach ($data['transactions']->result() as $row) {
$totalCommissionBanque += $row->commission_banque;
}
}
$data['totalCommissionBanque'] = $totalCommissionBanque ;
} else {
$data["taux_client_r"] = "N/A";
@ -1571,6 +1578,7 @@ class Gestion extends CI_Controller
$data['taux_bq_d'] = "N/A";
$data['taux_bq_r'] = "N/A";
$data['frais_d'] = "N/A";
$data['totalCommissionBanque'] = "N/A";
$data["transactions"] = false;
}
@ -1620,6 +1628,8 @@ class Gestion extends CI_Controller
if($method == 'create')
{
$res = $this->user_model->addConfigWallet($network_id , $taux_client_r , $taux_client_d , $taux_ag_r ,$taux_ag_d , $taux_sup_r , $taux_sup_d, $taux_bq_r , $taux_bq_d , $frais_d);
if($res)
$this->generateAllWallets($network_id);
}
else if($method = 'update'){
@ -1666,11 +1676,11 @@ class Gestion extends CI_Controller
return true;
}
public function generateAllWallets(){
if($this->isLogged()) {
if (isset($_POST)) {
$network_id = $_POST['network_id'];
public function generateAllWallets($network_id){
// if($this->isLogged()) {
// if (isset($_POST)) {
//
// $network_id = $_POST['network_id'];
// Fetch all agents , hyperviseur , superviseur
$f_agents = $this->user_model->getAllAgentsForNetwork($network_id) ;
if ($f_agents){
@ -1686,8 +1696,8 @@ class Gestion extends CI_Controller
}
}
}
}
// }
// }
}

View File

@ -289,6 +289,14 @@ class Hyperviseur_dash extends CI_Controller
$agent_id = $this->session->userdata('agent_id');
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
//Create wallet if it not exist
$res = $this->user_model->getWallet($agent_id );
if($res == false){
if($data['hasWallet']){
$this->user_model->addWallet($agent_id );
}
}
$res = $this->user_model->getWallet($agent_id);
if ($res!=null){
$row = $res->first_row();
@ -298,6 +306,7 @@ class Hyperviseur_dash extends CI_Controller
//Fetch all transactions of any geolocated agent of the network
$data["transactions"] = array();
$totalCommissionBanque = 0;
if($agents_g){
foreach($agents_g->result() AS $row){
$wallet = $this->user_model->getWallet($row->agent_id);
@ -305,6 +314,7 @@ class Hyperviseur_dash extends CI_Controller
$transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id);
if($transactions){
foreach($transactions->result() AS $trans){
$totalCommissionBanque += $trans->commission_banque;
$trans->code_parrain = $row->code_parrain ; // Add code parrain to transaction
array_push( $data['transactions'], $trans);
}
@ -312,10 +322,11 @@ class Hyperviseur_dash extends CI_Controller
}
}
}
$data["totalCommissionBanque"] = $totalCommissionBanque;
}else{
$data["commission"] = "N/A";
$data["principal"] = "N/A";
$data["totalCommissionBanque"] = "N/A";
$data["transactions"] = false;
}

View File

@ -183,6 +183,14 @@ class Superviseur_dash extends CI_Controller
$agent_id = $this->session->userdata('agent_id');
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
//Create wallet if it not exist
$res = $this->user_model->getWallet($agent_id );
if($res == false){
if($data['hasWallet']){
$this->user_model->addWallet($agent_id );
}
}
$res = $this->user_model->getWallet($agent_id);
if ($res!=null){
$row = $res->first_row();
@ -193,6 +201,7 @@ class Superviseur_dash extends CI_Controller
//Fetch all transactions of any geolocated agent of the network
$data["transactions"] = array();
$totalCommissionBanque = 0;
if($agents_g){
foreach($agents_g->result() AS $row){
$wallet = $this->user_model->getWallet($row->agent_id);
@ -200,6 +209,7 @@ class Superviseur_dash extends CI_Controller
$transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id);
if($transactions){
foreach($transactions->result() AS $trans){
$totalCommissionBanque += $trans->commission_banque;
$trans->agent_id = $row->agent_id ; // Add agent id to transaction
array_push( $data['transactions'], $trans);
}
@ -207,10 +217,11 @@ class Superviseur_dash extends CI_Controller
}
}
}
$data["totalCommissionBanque"] = $totalCommissionBanque;
}else{
$data["commission"] = "N/A";
$data["principal"] = "N/A";
$data["totalCommissionBanque"] = "N/A";
$data["transactions"] = false;
}

View File

@ -1849,7 +1849,7 @@ class User_model extends CI_Model
}
public function getTransactions($id_network){
$query = $this->db->query("SELECT id,type_transac
$query = $this->db->query("SELECT id,type_transac , commission_banque
FROM infos_transaction
WHERE `network_id`=".$id_network);
if($query->num_rows()>0){

View File

@ -304,6 +304,9 @@ if ($transactions != false) {
<div class="box-header with-border">
<h3 class="box-title">Retraits et dépots des 12 derniers
mois<?php //echo $this->lang->line('Souscription des 12 derniers mois'); ?></h3>
<div class="box-tools">
<a class="btn btn-primary" href=""> Historique </a>
</div>
</div>
<div class="box-body">
<div class="chart" id="chart">
@ -336,6 +339,7 @@ if ($transactions != false) {
<th>Nom</th>
<th>Solde Princ.</th>
<th>Solde Com.</th>
<th>Com. Banque</th>
<th>Dépots</th>
<th>Retraits</th>
</tr>
@ -346,7 +350,8 @@ if ($transactions != false) {
echo "<tr>
<td>" . $walletHyper->first_row()->lastname . "</td>
<td>" . $walletHyper->first_row()->balance_princ . "</td>
<td>" . $walletHyper->first_row()->balance_com . "</td>";
<td>" . $walletHyper->first_row()->balance_com . "</td>
<td>" . $totalCommissionBanque . "</td>";
echo "<td>" . $depots->num_rows() . "</td>
<td>" . $retraits->num_rows() . "</td>

View File

@ -81,7 +81,8 @@
$retraits = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){
$date = strtotime($trans->date);
return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ;
// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ;
return $trans->type == 'debit' ;
});
/**
@ -101,7 +102,8 @@
}
$depots = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){
$date = strtotime($trans->date);
return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ;
// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ;
return $trans->type == 'credit' ;
});
if($transactions!=false){
@ -179,7 +181,6 @@
<div class="icon">
<i class="ion ion-cash"></i>
</div>
<!-- <a href="#" data-toggle="modal" data-target="#modal-update" data-type="taux_client_r" class="small-box-footer openModal">Modifier <i class="fa fa-arrow-circle-right"></i></a>-->
</div>
</div>
@ -193,7 +194,18 @@
<div class="icon">
<i class="ion ion-cash"></i>
</div>
<!-- <a href="#" data-toggle="modal" data-target="#modal-update" data-type="taux_client_r" class="small-box-footer openModal">Modifier <i class="fa fa-arrow-circle-right"></i></a>-->
</div>
</div>
<div class="col-lg-4 col-xs-6">
<div class="small-box bg-yellow">
<div class="inner">
<h3><?php echo $totalCommissionBanque; ?><sup style="font-size: 20px">FCFA</sup></h3>
<p>Total commission de la banque</p>
</div>
<div class="icon">
<i class="ion ion-cash"></i>
</div>
</div>
</div>
@ -232,6 +244,7 @@
<th>Nom</th>
<th>Solde Princ.</th>
<th>Solde Com.</th>
<th>Com. Banque</th>
<th>Dépots</th>
<th>Retraits</th>
</tr>
@ -260,17 +273,21 @@
<td>".$com."</td>";
$nb_depots = 0;
$nb_retraits = 0;
$commission_banque = 0;
foreach($depots as $depot){
if($depot->code_parrain == $row->member_code) {
$nb_depots ++;
$commission_banque+= $depot->commission_banque;
}
}
foreach($retraits as $retrait){
if($retrait->code_parrain == $row->member_code) {
$nb_retraits ++;
$commission_banque+= $retrait->commission_banque;
}
}
echo "<td>".$nb_depots."</td>
echo "<td>".$commission_banque."</td>
<td>".$nb_depots."</td>
<td>".$nb_retraits."</td>
</tr>";
}

View File

@ -81,7 +81,9 @@
$retraits = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){
$date = strtotime($trans->date);
return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ;
// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'debit' ;
return $trans->type == 'debit' ;
});
/**
@ -101,7 +103,9 @@
}
$depots = array_filter($transactions, function ($trans) use ($i, $endDate ,$startDate){
$date = strtotime($trans->date);
return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ;
// return $date >= strtotime($startDate) && $date <= strtotime($endDate) && $trans->type == 'credit' ;
return $trans->type == 'credit' ;
});
if($transactions!=false){
@ -178,7 +182,6 @@
<div class="icon">
<i class="ion ion-cash"></i>
</div>
<!-- <a href="#" data-toggle="modal" data-target="#modal-update" data-type="taux_client_r" class="small-box-footer openModal">Modifier <i class="fa fa-arrow-circle-right"></i></a>-->
</div>
</div>
@ -191,7 +194,18 @@
<div class="icon">
<i class="ion ion-cash"></i>
</div>
<!-- <a href="#" data-toggle="modal" data-target="#modal-update" data-type="taux_client_r" class="small-box-footer openModal">Modifier <i class="fa fa-arrow-circle-right"></i></a>-->
</div>
</div>
<div class="col-lg-4 col-xs-6">
<div class="small-box bg-yellow">
<div class="inner">
<h3><?php echo $totalCommissionBanque; ?><sup style="font-size: 20px">FCFA</sup></h3>
<p>Total commission de la banque</p>
</div>
<div class="icon">
<i class="ion ion-cash"></i>
</div>
</div>
</div>
@ -230,6 +244,7 @@
<th>Nom</th>
<th>Solde Princ.</th>
<th>Solde Com.</th>
<th>Com. Banque</th>
<th>Dépots</th>
<th>Retraits</th>
</tr>
@ -258,17 +273,21 @@
<td>".$com."</td>";
$nb_depots = 0;
$nb_retraits = 0;
$commission_banque = 0;
foreach($depots as $depot){
if($depot->agent_id == $row->agent_id) {
$nb_depots ++;
$commission_banque+= $depot->commission_banque;
}
}
foreach($retraits as $retrait){
if($retrait->agent_id == $row->agent_id) {
$nb_retraits ++;
$commission_banque+= $retrait->commission_banque;
}
}
echo "<td>".$nb_depots."</td>
echo "<td>".$commission_banque."</td>
<td>".$nb_depots."</td>
<td>".$nb_retraits."</td>
</tr>";
}

View File

@ -281,17 +281,17 @@
console.log(resultat+" "+error );
}
}).done(function () {
$.ajax({
url : '<?php echo base_url('index.php/Gestion/generateAllWallets')?>',
type : 'POST',
dataType : 'json',
data : {"network_id": network_id},
timeout : 0,
async : true ,
success : function () {
console.log("All wallets are generated");
}
});
//$.ajax({
// url : '<?php //echo base_url('index.php/Gestion/generateAllWallets')?>//',
// type : 'POST',
// dataType : 'json',
// data : {"network_id": network_id},
// timeout : 0,
// async : true ,
// success : function () {
// console.log("All wallets are generated");
// }
//});
});
}