+ Manage transmitting networks

This commit is contained in:
Djery-Tom 2020-10-29 20:07:19 +01:00
parent cac703c271
commit 74adfaf1fd
8 changed files with 230 additions and 154 deletions

View File

@ -1030,6 +1030,7 @@ class Hyperviseur_dash extends CI_Controller
$result = $res->result();
foreach ($result as $network){
$res = $this->wallet_model->getSharingRate($network->id , $data['idConfig']);
$res2 = $this->wallet_model->getTransmittingNetwork($network->id , $data['idConfig']);
if($res){
$network->rate = $res->first_row()->taux_partage;
$network->url = $res->first_row()->url;
@ -1037,6 +1038,7 @@ class Hyperviseur_dash extends CI_Controller
$network->rate = null;
$network->url = null;
}
$network->is_transmitting_network = $res2 ? true : false;
$data['networks'][] = $network;
}
}
@ -1051,11 +1053,11 @@ class Hyperviseur_dash extends CI_Controller
$result = $res->result();
foreach ($result as $country){
$res = $this->wallet_model->countPayingNetworks($country->id, $data['idConfig']);
if($res){
$country->total = $res->first_row()->total;
}else{
$country->total = null;
}
$res2 = $this->wallet_model->countTransmittiongNetworks($country->id, $data['idConfig']);
$country->total_paying = $res ? $res->first_row()->total : null ;
$country->total_transmitting = $res ? $res2->first_row()->total : null ;
$data['countries'][] = $country;
}
}
@ -1605,6 +1607,46 @@ class Hyperviseur_dash extends CI_Controller
}
}
}
public function active_transmitting_network()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$data = array(
'id_configWallet' => $this->input->post('config_id'),
'id_network' => $this->input->post('network_id')
);
$query = $this->db->insert('transmitting_networks', $data);
if ($query) {
echo json_encode("200");
} else {
echo json_encode("500");
}
}
}
}
public function deactive_transmitting_network()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$data = array(
'id_configWallet' => $this->input->post('config_id'),
'id_network' => $this->input->post('network_id')
);
$query = $this->db->delete('transmitting_networks', $data);
if ($query) {
echo json_encode("200");
} else {
echo json_encode("500");
}
}
}
}
}
class Operation

View File

@ -391,7 +391,7 @@ $lang['ilink_third_rule'] = 'The sum of the distribution of commission on cash d
$lang['ilink_fourth_rule'] = 'The sum of the distribution of commission on withdrawal operation in the card must be equal to 100%';
$lang['ilink_fifth_rule'] = 'The sum of the distribution of commission on withdrawal operation in the card for iLink user must be equal to 100%';
$lang['ilink_sixth_rule'] = 'The sum of the commission distributions on the operation of sending a wallet to the iLink user card must be equal to 100%';
$lang['edit_paying_networks'] = 'Configuration of paying networks';
$lang['edit_paying_and_transmitting_networks'] = 'Configuration of paying and issuing networks';
$lang['configure'] = 'Configure';
$lang['configure_share_rate'] = 'Configure the sharing rate';
$lang['share_rate'] = 'Sharing rate';
@ -530,4 +530,8 @@ $lang['bank_deactivated'] = "The bank has been deactivated";
$lang['bank_deactivation'] = "Deactivation of the bank";
$lang['modify_bank'] = "Modify the bank";
$lang['assign_bank_to_country'] = "Assign a bank to a country";
$lang['transmitting_networks'] = "Transmitting networks";
$lang['transmitter_network_activated'] = "Transmitter network activated";
$lang['transmitter_network_deactivated'] = "Transmitter network deactivated";
$lang['paying_networks'] = 'Paying networks';
?>

View File

@ -403,7 +403,7 @@ $lang['ilink_third_rule'] = 'La somme des répartitions de commission sur opéra
$lang['ilink_fourth_rule'] = 'La somme des répartitions de commission sur opération de retrait dans la carte doit etre égale à 100 %';
$lang['ilink_fifth_rule'] = 'La somme des répartitions de commission sur opération de retrait dans la carte pour utilisateur iLink doit etre égale à 100 %';
$lang['ilink_sixth_rule'] = 'La somme des répartitions de commission sur opération d\'envoi de wallet vers la carte pour utilisateur iLink doit etre égale à 100 %';
$lang['edit_paying_networks'] = 'Configuration des réseaux payeurs';
$lang['edit_paying_and_transmitting_networks'] = 'Configuration des réseaux payeurs et emetteurs';
$lang['configure'] = 'Configurer';
$lang['configure_share_rate'] = 'Configurer le taux de partage';
$lang['share_rate'] = 'Taux de partage';
@ -542,5 +542,9 @@ $lang['bank_deactivated'] = "La banque a été désactivée";
$lang['bank_deactivation'] = "Désactivation de la banque";
$lang['modify_bank'] = "Modifier la banque";
$lang['assign_bank_to_country'] = "Assigner une banque à un pays";
$lang['transmitting_networks'] = "Réseaux émetteurs";
$lang['transmitter_network_activated'] = "Réseau emetteur activé";
$lang['transmitter_network_deactivated'] = "Réseau emetteur desactivé";
$lang['paying_networks'] = 'Réseaux payeurs';
?>

View File

@ -904,4 +904,23 @@ LEFT JOIn networks_banks nb ON nb.id_bank_country = bc.id AND nb.id_network = n.
$query = $this->db->query($sql , array($id_network));
return $query->num_rows() > 0 ? $query : false ;
}
// Reseaux emetteurs
public function getTransmittingNetwork($id_network ,$idConfig){
$sql = "SELECT * FROM `transmitting_networks` WHERE `id_network` = ? AND id_configWallet = ? ;";
$query = $this->db->query($sql , array($id_network,$idConfig));
return $query->num_rows() > 0 ? $query : false ;
}
public function countTransmittiongNetworks($id_country ,$idConfig){
$sql = "SELECT count(id) as total FROM `transmitting_networks` WHERE `id_network` IN (SELECT distinct n.id FROM countries c INNER JOIN
networks n ON n.country_id = c.id WHERE n.status = 1 AND c.id = ?
) AND id_configWallet = ? ;";
$query = $this->db->query($sql , array($id_country, $idConfig));
if($query->num_rows()>0){
return $query;
}else{
return false;
}
}
}

View File

@ -8,7 +8,7 @@
<section class="content-header">
<h1>
<?php echo $this->lang->line('edit_paying_networks') . ' - ' . $country->name; ?>
<?php echo $this->lang->line('edit_paying_and_transmitting_networks') . ' - ' . $country->name; ?>
</h1>
<?php
$site_url = base_url();
@ -43,7 +43,7 @@
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('Réseaux activés'); ?></h3>
<h3 class="box-title"><?php echo $this->lang->line('paying_networks'); ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
@ -152,6 +152,77 @@
</div>
</div>
</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('transmitting_networks'); ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<?php
$sql2 = $networks;
if ($sql2 != false) {
$numrows = sizeof($sql2);
$num = 0;
if ($numrows > 0) {
?>
<table id="validated" class="table table-bordered table-striped">
<thead>
<tr>
<th align='center'></th>
<th><?= $this->lang->line('Nom'); ?></th>
<th align='center'>Wallet</th>
<th align='center'><?php echo $this->lang->line('Statut'); ?></th>
<th align='center'> Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($sql2 as $row) {
$num++;
//$member_code = randomString1(10);
echo "<tr>
<td align='center'>$num</td>
<td>$row->name</td>
<td><span class='label label-success'>" . strtoupper($row->type) . "</span></td>";
?>
<?php
if($row->is_transmitting_network){
?>
<td><span class="label label-success"><?= $this->lang->line('Actif'); ?></span></td>
<td><button type="button" data-network-id="<?php echo $row->id ?>"
data-config-id="<?= $idConfig ?>" data-num ="<?=$num?>" class="btn btn-danger openModal disableTransmitting"><?= $this->lang->line('Désactiver'); ?></button></td>
<?php
}else{
?>
<td><span class="label label-danger"><?= $this->lang->line('Inactif'); ?></span></td>
<td><button type="button" data-network-id="<?php echo $row->id ?>"
data-config-id="<?= $idConfig ?>" data-num ="<?=$num?>" class="btn btn-primary openModal enableTransmitting" ><?php echo $this->lang->line('Activer'); ?></button></td>
<?php
}
?>
<?php
}
?>
</tbody>
</table>
<?php
} else {
echo $this->lang->line('Aucun réseau');
}
} else {
echo $this->lang->line('Aucun réseau');
}
?>
</div>
</div>
</div>
</div>
</section>
</div>
@ -171,7 +242,6 @@
<!-- AdminLTE for demo purposes -->
<script src="<?php echo base_url('dist/js/demo.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script>
@ -230,4 +300,60 @@
});
$(document).on("click", ".enableTransmitting", function () {
$.ajax({
url : '<?php echo base_url('index.php/Hyperviseur_dash/active_transmitting_network')?>',
type : 'POST',
dataType : 'json',
data: {"network_id": network_id, "config_id": config_id},
success : function(data){
if(data=='200'){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('transmitter_network_activated')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
}else{
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
},
error : function(resultat, statut, error){
console.log(resultat+" "+error );
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
})
});
$(document).on("click", ".disableTransmitting", function () {
$.ajax({
url : '<?php echo base_url('index.php/Hyperviseur_dash/deactive_transmitting_network')?>',
type : 'POST',
dataType : 'json',
data: {"network_id": network_id, "config_id": config_id},
success : function(data){
if(data=='200'){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('transmitter_network_deactivated')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
}else{
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
},
error : function(resultat, statut, error){
console.log(resultat+" "+error );
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
})
});
</script>

View File

@ -6,7 +6,7 @@
<section class="content-header">
<h1>
<?php echo $this->lang->line('edit_paying_networks'); ?>
<?php echo $this->lang->line('edit_paying_and_transmitting_networks'); ?>
</h1>
<?php
$site_url = base_url();
@ -56,8 +56,9 @@
<thead>
<tr>
<th align='center'></th>
<th><?php echo $this->lang->line('Nom'); ?></th>
<th align='center'> Status </th>
<th><?= $this->lang->line('Nom'); ?></th>
<th align='center'><?= $this->lang->line('paying_networks'); ?> </th>
<th align='center'><?= $this->lang->line('transmitting_networks'); ?> </th>
<th align='center'> Action </th>
</tr>
</thead>
@ -71,9 +72,20 @@
<td >$row->name</td>";
?>
<?php
if($row->total > 0){
if($row->total_paying){
?>
<td><span class="label label-success" style="font-size: 1em;"><?= $row->total.' réseaux' ?></span></td>
<td><span class="label label-success" style="font-size: 1em;"><?= $row->total_paying.' '.$this->lang->line($row->total_paying > 1 ? 'Reseaux' : 'Reseau') ?></span></td>
<?php
}else{
?>
<td><span class="label label-danger" style="font-size: 1em;" ><?php echo $this->lang->line('no_network'); ?></span></td>
<?php
}
?>
<?php
if($row->total_transmitting){
?>
<td><span class="label label-success" style="font-size: 1em;"><?= $row->total_transmitting.' '.$this->lang->line($row->total_paying > 1 ? 'Reseaux' : 'Reseau') ?></span></td>
<?php
}else{
?>
@ -107,48 +119,6 @@
</div>
</div>
</div>
<div class="modal fade" id="disableWallet" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><?php echo $this->lang->line('Suppression du wallet'); ?></h3>
</div>
<div class="modal-body">
<h4> Etes vous certain de vouloir ?</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
<button type="button" class="btn btn-primary" id="deleteWallet" > <?php echo $this->lang->line('Valider'); ?></button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="enableWallet" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><?php echo $this->lang->line('choose_wallet_type'); ?></h3>
</div>
<div class="modal-body">
<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>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
</div>
</div>
</div>
</div>
<!-- <div class="alert alert-info alert-dismissible" aria-hidden="true">-->
<!-- <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>-->
<!-- <h4><i class="icon fa fa-info"></i>Info!</h4>-->
<!-- Data is Saved-->
<!-- </div>-->
</section>
</div>
@ -167,98 +137,9 @@
<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/toastr/toastr.js') ?>"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script>
$(function() {
$('#validated').DataTable();
})
</script>
<script>
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
var network_id = null;
$(document).on("click", ".openModal", function () {
network_id = $(this).data('network-id');
})
$(document).on("click", ".enableWallet", function () {
// const network_id = $(this).data('network-id');
const type = $(this).val();
$.ajax({
url : '<?php echo base_url('index.php/Gestion/config_wallet/create')?>',
type : 'POST',
dataType : 'json',
data: {"network_id": network_id , "type" : type},
success : function(data){
if(data=='200'){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('wallet_created')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
}else{
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
},
error : function(resultat, statut, error){
console.log(resultat+" "+error );
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
}).done(function () {
$.ajax({
url : '<?php echo base_url('index.php/Gestion/generateAllWallets')?>',
type : 'POST',
dataType : 'json',
data : {"network_id": network_id},
async : true ,
timeout : 0,
success : function () {
console.log("All wallets are generated");
}
});
});
});
$('#deleteWallet').click(function(){
$.ajax({
url : '<?php echo base_url('index.php/Gestion/delete_config_wallet')?>',
type : 'POST',
dataType : 'json',
data: {"network_id": network_id },
success : function(data, statut){
if(data=='200'){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('wallet_deleted')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" : location.reload();
}else{
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
},
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')?>");
}
});
});
</script>

View File

@ -93,8 +93,8 @@
</style>
<?php
use Brick\Money\Context\CustomContext;
use Brick\Money\Money;
$context = new \Brick\Money\Context\AutoContext();
function convertDate($date){
$month = null;
@ -313,7 +313,7 @@ $context = new \Brick\Money\Context\AutoContext();
<div class="col-lg-4">
<div class="margin">
<a href="<?php echo current_url().($network_id ? '?config=paying_networks' : '')?>" class="btn btn-success"
style="width: 100%"><?php echo $this->lang->line('edit_paying_networks') ?></a>
style="width: 100%"><?php echo $this->lang->line('edit_paying_and_transmitting_networks') ?></a>
</div>
</div>
</div>

View File

@ -275,9 +275,9 @@ function toLocateDate($date , $timezone){
const format = lang === 'french' ? 'fr' : 'en';
moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date
var table = $('#transactions').DataTable({
"aaSorting": [[18, "desc"]],
"aaSorting": [[19, "desc"]],
"columnDefs": [{
targets: 18,
targets: 19,
render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format)
}],
dom: 'Bfrtip',
@ -286,14 +286,14 @@ function toLocateDate($date , $timezone){
{
extend: 'excelHtml5',
title: "<?= $this->lang->line('Historique des transactions') ?>",
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
},
// exportOptions: {
// columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
// },
customizeData: function (data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// data.body[i][j] = '\u200C' + data.body[i][j];
if ([3, 4, 5, 9, 10, 11, 12, 13, 14].includes(j)) {
if ([3, 4, 5, 10, 11, 12, 13, 14,15].includes(j)) {
// Get the value and strip the non numeric characters
// var value = $(this).text();
value = data.body[i][j].replace(',', ".")