Add Analyis per supervisor in historique_transactions
This commit is contained in:
parent
16b4d9738d
commit
ed3f6ec992
|
@ -398,7 +398,7 @@ class Hyperviseur_dash extends CI_Controller
|
|||
if ($data['hasWallet']) {
|
||||
|
||||
if ($this->input->get('history')) {
|
||||
$this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->input->get('history'));
|
||||
$this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->input->get('history'), $this->input->get('parrainId'));
|
||||
} elseif ($this->input->get('config')) {
|
||||
$this->config_wallet($this->input->get('config'), $this->input->get('country'));
|
||||
} elseif ($this->input->get('show')) {
|
||||
|
@ -520,7 +520,7 @@ class Hyperviseur_dash extends CI_Controller
|
|||
return true;
|
||||
}
|
||||
|
||||
private function historique($network_id, $startDate, $endDate, $type)
|
||||
private function historique($network_id, $startDate, $endDate, $type , $parrainId = null)
|
||||
{
|
||||
$data['configWallet'] = $this->wallet_model->getConfigWallet($network_id);
|
||||
$format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d';
|
||||
|
@ -545,8 +545,11 @@ class Hyperviseur_dash extends CI_Controller
|
|||
$data['refunds'] = $this->wallet_model->getRefunds($startDate, $endDate, $network_id);
|
||||
else if ($type == 'commission_payments')
|
||||
$data['payments'] = $this->wallet_model->getCommissionPayments($startDate, $endDate, $network_id);
|
||||
else
|
||||
else{
|
||||
$data['transactions'] = $this->wallet_model->getRecharges($startDate, $endDate, $network_id);
|
||||
$data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code'));
|
||||
$data['parrain'] = isset($parrainId) ? $this->user_model->getAgentInfos($parrainId) : null ;
|
||||
}
|
||||
|
||||
$data['active'] = "wallet_wallet";
|
||||
$data['alert'] = "";
|
||||
|
@ -561,6 +564,7 @@ class Hyperviseur_dash extends CI_Controller
|
|||
$data['country'] = $this->session->userdata('current_pays');
|
||||
$data['category'] = $this->session->userdata('category');
|
||||
$data['id_network'] = $network_id;
|
||||
$data['parrain_id'] = $parrainId;
|
||||
|
||||
$this->load->view('header_hyp', $data);
|
||||
if ($type == 'transaction')
|
||||
|
@ -582,6 +586,61 @@ class Hyperviseur_dash extends CI_Controller
|
|||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
public function export(){
|
||||
if ($this->isLogged()) {
|
||||
if (isset($_POST)) {
|
||||
|
||||
$parrain_id = $this->input->post('parrain_id');
|
||||
$start = date('Y-m-d', strtotime($this->input->post('start')));
|
||||
$end = date('Y-m-d', strtotime($this->input->post('end'). "+1 day"));
|
||||
|
||||
$config = $this->wallet_model->getConfigWallet($this->session->userdata('network_id'))->first_row();
|
||||
|
||||
$sql = "SELECT id, type_transac, numCarte, montant, 0 as bank_deposit , commission_banque, commission_hyp, commission_sup, commission_ag,
|
||||
agent,parrain,date_created FROM infos_transaction WHERE deleted = 0 AND parrain_id = ? AND date_created >= ? AND date_created < ? ORDER BY agent ASC";
|
||||
$query = $this->db->query($sql, array($parrain_id,$start,$end));
|
||||
|
||||
$data = [['ID', 'Type' , $this->lang->line('cart_number'),$this->lang->line('customer_net_amount'),$this->lang->line('bank_deposit_amount'),
|
||||
$this->lang->line('Commission de la banque'),$this->lang->line('Commission de l\'hyperviseur'),$this->lang->line('Commission du superviseur'),
|
||||
$this->lang->line('Commission de l\'agent'),$this->lang->line('agent_name'),$this->lang->line('Superviseur'),'Date']];
|
||||
|
||||
$oldAgent = '';
|
||||
foreach ($query->result() as $r){
|
||||
if($oldAgent != $r->agent)
|
||||
array_push($data,[]);
|
||||
|
||||
$row = [];
|
||||
|
||||
if($r->type_transac == 'credit'){
|
||||
if($r->montant < 0){
|
||||
$commission = (-$r->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot;
|
||||
$net = $r->montant + $commission;
|
||||
}else{
|
||||
$commission = ( $r->montant * $config->taux_com_client_depot / 100 ) + $config->frais_min_banque_depot;
|
||||
$net = $r->montant - $commission;
|
||||
}
|
||||
$r->bank_deposit = $r->montant * (1 - ($config->taux_com_client_depot / 100));
|
||||
}else{
|
||||
$net = $r->montant ;
|
||||
}
|
||||
$r->montant = $net;
|
||||
$r->commission_banque = intval($r->commission_banque);
|
||||
$r->numCarte = join(" ", str_split($r->numCarte, 4));
|
||||
|
||||
foreach ($r as $k => $val){
|
||||
if($k == 'type_transac'){
|
||||
array_push($row,$val =='credit' ? $this->lang->line('DEPOT') : $this->lang->line('RETRAIT'));
|
||||
} else
|
||||
array_push($row,$val);
|
||||
}
|
||||
array_push($data,$row);
|
||||
$oldAgent = $r->agent;
|
||||
}
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_wallet_transaction(){
|
||||
if ($this->isLogged()) {
|
||||
$datetime = $this->user_model->getCurrentTimeByNetworkID($this->session->userdata('network_id'));
|
||||
|
|
|
@ -624,5 +624,9 @@ $lang['steps_map_loading'] = "Number of agents geolocated by steps on the map";
|
|||
$lang['sms_notifications'] = "SMS notifications";
|
||||
$lang['advertising'] = "Advertising";
|
||||
$lang['registration_date'] = "Registration date";
|
||||
$lang['sponsor'] = 'Sponsor'
|
||||
$lang['sponsor'] = 'Sponsor';
|
||||
$lang['analysis_by_supervisor'] ="Analysis by supervisor";
|
||||
$lang['press_here_to_see_selection'] = "Press here to see the selection";
|
||||
$lang['show_selection'] = "Show selection";
|
||||
$lang['cancel_selection'] = "Cancel selection";
|
||||
?>
|
||||
|
|
|
@ -637,4 +637,8 @@ $lang['sms_notifications'] = "Notifications par SMS";
|
|||
$lang['advertising'] = "Publicité";
|
||||
$lang['registration_date'] = "Date d'inscription";
|
||||
$lang['sponsor'] = 'Parrain';
|
||||
$lang['analysis_by_supervisor'] ="Analyse par superviseur";
|
||||
$lang['press_here_to_see_selection'] = "Appuyer ici pour voir la sélection";
|
||||
$lang['show_selection'] = "Afficher la selection";
|
||||
$lang['cancel_selection'] = "Annuler la selection";
|
||||
?>
|
||||
|
|
|
@ -2644,4 +2644,9 @@ class User_model extends CI_Model
|
|||
$query = $this->db->query("SELECT na.phone from networks_agents na WHERE na.id <> '$id_network_agent' AND (na.phone ='$phone' OR na.transactionNumber ='$phoneTransaction')");
|
||||
return $query->num_rows() ;
|
||||
}
|
||||
|
||||
public function getAgentInfos($id_agent){
|
||||
$query = $this->db->query("SELECT * FROM agents WHERE id ='".$id_agent."'");
|
||||
return $query->num_rows()>0 ? $query->first_row() : false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ class WalletTransaction_model extends CI_Model
|
|||
{
|
||||
$this->db->from($this->table);
|
||||
$this->db->where('network_id', $postData['id_network']);
|
||||
if(!empty($postData['parrain_id'])){
|
||||
$this->db->where('parrain_id', $postData['parrain_id']);
|
||||
}
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
|
@ -62,6 +65,9 @@ class WalletTransaction_model extends CI_Model
|
|||
$this->db->from($this->table);
|
||||
$this->db->where('deleted', 0);
|
||||
$this->db->where('network_id', $postData['id_network']);
|
||||
if(!empty($postData['parrain_id'])){
|
||||
$this->db->where('parrain_id', $postData['parrain_id']);
|
||||
}
|
||||
if (strlen($postData['startDate']) > 0 && strlen($postData['endDate']) > 0) {
|
||||
$this->db->where('date_created >=', date('Y-m-d', strtotime($postData['startDate'])));
|
||||
$this->db->where('date_created <', date('Y-m-d', strtotime($postData['endDate']. "+1 day")));
|
||||
|
|
|
@ -5,12 +5,43 @@
|
|||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
|
||||
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
|
||||
|
||||
<style>
|
||||
|
||||
/* Turn off scrollbar when body element has the loading class */
|
||||
body.loading {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Make spinner image visible when body element has the loading class */
|
||||
body.loading #loader {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#loader {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.img-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
/*width: 65%;*/
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
|
||||
<h1>
|
||||
<?php echo isset($category) ? 'Wallet' : $this->lang->line('Gestion des wallets') ; echo ' '.$network.' - '.$country; ?>
|
||||
<?php echo isset($category) ? 'Wallet' : $this->lang->line('Gestion des wallets') ; echo ' '.$network.' - '.$country.(isset($parrain) ? ' :: POS de '.$parrain->lastname : ''); ?>
|
||||
<!-- <input type="button" class="btn btn-primary pull-right" id="Bactiver"-->
|
||||
<!-- value="Activer/Désactiver le(s) réseau(x)" />-->
|
||||
</h1>
|
||||
|
@ -59,15 +90,64 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($this->session->userdata('category') != 'super') { ?>
|
||||
<div class="col-md-8">
|
||||
<div class="box box-danger">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><?php echo $this->lang->line('analysis_by_supervisor'); ?></h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<form name="form_login" action="<?php echo base_url('Hyperviseur_dash/wallet') ?>" method="GET">
|
||||
<input type="hidden" name="history" value="transaction">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="form-group" id="grp-agent">
|
||||
<?php
|
||||
if($superviseurs!=false){
|
||||
$numrows=$superviseurs->num_rows();
|
||||
if ($numrows > 0) { ?>
|
||||
<select class="form-control input-lg" name="parrainId" required>
|
||||
<?php foreach($superviseurs->result() as $row) {
|
||||
echo "<option value='".$row->agent_id."' ".($row->agent_id == $parrain_id ? 'selected' : '').">".$row->lastname."</option>";
|
||||
} ?>
|
||||
</select>
|
||||
<?php }else{
|
||||
echo $this->lang->line('Aucun agent');
|
||||
}
|
||||
}else{
|
||||
echo $this->lang->line('Aucun agent');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
<button class="btn btn-block btn-primary" type='submit'> <?= $this->lang->line('show_selection'); ?></button>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
<?php if(isset($parrain_id)): ?>
|
||||
<a class="btn btn-block btn-danger" href="<?= current_url().'?history=transaction'?>"><?= $this->lang->line('cancel_selection'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?php echo $this->lang->line('Historique des transactions') ?></h3>
|
||||
<h3 class="box-title"><?= $this->lang->line('Historique des transactions').(isset($parrain) ? ' :: POS de '.$parrain->lastname : '') ?></h3>
|
||||
<?php if ($this->session->userdata('category') != 'super') { ?>
|
||||
<div class="box-tools">
|
||||
<?php if(isset($parrain_id)): ?>
|
||||
<button id="export-grouping" class="btn btn-info">
|
||||
Exporter par groupe
|
||||
</button>
|
||||
<?php endif;?>
|
||||
<a class="btn btn-success" href="<?php echo current_url().'?history=deleted_transactions'?>">
|
||||
<?php echo $this->lang->line('deleted_transactions'); ?>
|
||||
</a>
|
||||
|
@ -116,6 +196,13 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="loader" class="center-div loader">
|
||||
<div class="center-div">
|
||||
<img style="text-align: center" class="img-center" src="<?php echo base_url('dist/img/loading.gif') ?>" alt="Loading" height="50" width="50">
|
||||
<p style="text-align: center">Chargement</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
@ -149,9 +236,22 @@
|
|||
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.colVis.min.js"></script>
|
||||
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
|
||||
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
|
||||
<script src="<?php echo base_url('bower_components/js-xlsx/dist/xlsx.full.min.js') ?>"></script>
|
||||
<script src="<?php echo base_url('bower_components/file-saver/dist/FileSaver.js') ?>"></script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
// Add remove loading class on body element based on Ajax request status
|
||||
$(document).on({
|
||||
ajaxStart: function () {
|
||||
$("body").addClass("loading");
|
||||
},
|
||||
ajaxStop: function () {
|
||||
$("body").removeClass("loading");
|
||||
}
|
||||
});
|
||||
|
||||
$(function () {
|
||||
const lang = $('#picker').data('lang');
|
||||
const format = lang === 'french' ? 'fr' : 'en';
|
||||
|
@ -173,7 +273,8 @@
|
|||
"data":{
|
||||
"startDate" : "<?= $startDate?>",
|
||||
"endDate" : "<?= $endDate?>",
|
||||
"id_network" : <?= $id_network ?>
|
||||
"id_network" : <?= $id_network ?>,
|
||||
"parrain_id": "<?= $parrain_id ?>"
|
||||
},
|
||||
"type": "POST"
|
||||
},
|
||||
|
@ -191,7 +292,7 @@
|
|||
'pageLength',
|
||||
{
|
||||
"extend": 'excelHtml5',
|
||||
title: "<?= $this->lang->line('Historique des transactions') ?>",
|
||||
title: "<?= $this->lang->line('Historique des transactions').(isset($parrain) ? ' _ POS de '.$parrain->lastname : '')?>",
|
||||
customizeData: function (data) {
|
||||
for (var i = 0; i < data.body.length; i++) {
|
||||
for (var j = 0; j < data.body[i].length; j++) {
|
||||
|
@ -210,7 +311,7 @@
|
|||
},
|
||||
{
|
||||
extend: 'csvHtml5',
|
||||
title: "<?= $this->lang->line('Historique des transactions') ?>",
|
||||
title: "<?= $this->lang->line('Historique des transactions').(isset($parrain) ? ' _ POS de '.$parrain->lastname : '')?>",
|
||||
customizeData: function (data) {
|
||||
for (var i = 0; i < data.body.length; i++) {
|
||||
for (var j = 0; j < data.body[i].length; j++) {
|
||||
|
@ -231,7 +332,7 @@
|
|||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'LEGAL',
|
||||
title: "<?= $this->lang->line('Historique des transactions') ?>",
|
||||
title: "<?= $this->lang->line('Historique des transactions').(isset($parrain) ? ' _ POS de '.$parrain->lastname : '')?>",
|
||||
trim: false,
|
||||
"action": newexportaction
|
||||
},
|
||||
|
@ -286,6 +387,76 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
$("#export-grouping").click(function(){
|
||||
let start = "<?= $startDate?>"
|
||||
let end = "<?=$endDate?>"
|
||||
let parrain_id = "<?=$parrain_id?>"
|
||||
|
||||
let button = $(this);
|
||||
button.prop("disabled",true);
|
||||
$.ajax({
|
||||
url : '<?php echo base_url('/Hyperviseur_dash/export')?>',
|
||||
type : 'POST',
|
||||
dataType : 'json',
|
||||
data: {"parrain_id": parrain_id , start : start , end : end },
|
||||
async:true,
|
||||
success : function(data){
|
||||
|
||||
console.log('data',data)
|
||||
|
||||
// Empty workbook object
|
||||
var wb = XLSX.utils.book_new();
|
||||
var title = "<?= $this->lang->line('Historique des transactions').(isset($parrain) ? ' _ POS de '.$parrain->lastname : '')?>"+" _ "+start+" - "+end
|
||||
wb.Props = {
|
||||
Title: title,
|
||||
Subject: title,
|
||||
Author: "iLink World",
|
||||
CreatedDate: new Date()
|
||||
};
|
||||
|
||||
wb.SheetNames.push("sheet");
|
||||
|
||||
//Data
|
||||
var ws_data = data ; //[['hello' , 'world']]; //a row with 2 columns
|
||||
// Create the sheet from this array by using aoa_to_sheet()
|
||||
var ws = XLSX.utils.aoa_to_sheet(ws_data);
|
||||
// Assign the sheet object to the workbook Sheets array.
|
||||
wb.Sheets["sheet"] = ws;
|
||||
|
||||
/* cell width */
|
||||
var wscols = [];
|
||||
let cell;
|
||||
for (let i = 0; i < ws_data.length; i++) {
|
||||
wscols.push({ wch: 20 }); // wch = character
|
||||
}
|
||||
|
||||
ws['!cols'] = wscols;
|
||||
|
||||
var wbout = XLSX.write(wb, {bookType:'xlsx', type: 'binary'});
|
||||
function s2ab(s) {
|
||||
var buf = new ArrayBuffer(s.length); //convert s to arrayBuffer
|
||||
var view = new Uint8Array(buf); //create uint8array as viewer
|
||||
for (var i=0; i<s.length; i++) view[i] = s.charCodeAt(i) & 0xFF; //convert to octet
|
||||
return buf;
|
||||
}
|
||||
|
||||
saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), title+'.xlsx');
|
||||
},
|
||||
error : function(resultat, statut, erreur){
|
||||
console.log(resultat+" "+erreur);
|
||||
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
|
||||
},
|
||||
complete: function (){
|
||||
button.prop("disabled",false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var startDate;
|
||||
var endDate;
|
||||
|
@ -305,7 +476,7 @@
|
|||
const debut = start.format('YYYY-MM-DD');
|
||||
const fin = end.format('YYYY-MM-DD');
|
||||
if(category)
|
||||
window.location = "<?php echo current_url()?>" + "?history=transaction" + "&d=" + debut + "&f=" + fin;
|
||||
window.location = "<?php echo current_url()?>" + "?history=transaction" + "<?= isset($parrain_id) ? '&parrainId='.$parrain_id : '' ?>" + "&d=" + debut + "&f=" + fin;
|
||||
else
|
||||
window.location = "<?php echo current_url()?>" + "?id="+id_network+"&history=transaction" + "&d=" + debut + "&f=" + fin;
|
||||
|
||||
|
@ -315,7 +486,7 @@
|
|||
//do something, like clearing an input
|
||||
$('#daterange').val('');
|
||||
if(category)
|
||||
window.location = "<?php echo current_url()?>" + "?history=transaction";
|
||||
window.location = "<?php echo current_url()?>" + "?history=transaction"+ "<?= isset($parrain_id) ? '&parrainId='.$parrain_id : '' ?>";
|
||||
else
|
||||
window.location = "<?php echo current_url()?>" + "?id="+id_network+"&history=transaction";
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue