+ Add Nano credit : Credit Limit

This commit is contained in:
Djery-Tom 2020-08-06 07:26:28 +01:00
parent 43dae70858
commit 038f5cca88
9 changed files with 819 additions and 19 deletions

View File

@ -2058,6 +2058,55 @@ class Gestion extends CI_Controller
} }
} }
public function nano_credit()
{
if ($this->isLogged()) {
$data['active'] = "nano_credit";
$data['alert'] = "";
$data['game_pays'] = $this->user_model->getGameCountry();
$data['networks'] = $this->user_model->getAllIlinkWorldNetworks();
$this->load->view('header_gestion', $data);
$this->load->view('nano_credit/gestion_nano_credits');
$this->load->view('footer');
}
}
public function activate_nano_credit()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$id_network = $_POST['id_network'];
$this->user_model->insertCreditLimit(0, 0, '1', $id_network);
$res = true;
if ($res) {
echo json_encode("200");
} else {
echo json_encode("500");
}
}
}
}
public function delete_nano_credit()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$id_network = $_POST['id_network'];
$this->user_model->insertCreditLimit(0, 0, '0', $id_network);
$res = true;
if ($res) {
echo json_encode("200");
} else {
echo json_encode("500");
}
}
}
}
} }

View File

@ -1175,7 +1175,7 @@ class Hyperviseur_dash extends CI_Controller
$config_id = $_POST['config_id']; $config_id = $_POST['config_id'];
$rate = $_POST['rate']; $rate = $_POST['rate'];
$url = $_POST['url']; $url = $_POST['url'];
$res = $this->user_model->setSharingRate($network_id,$config_id,$rate,$url); $res = $this->user_model->setSharingRate($network_id, $config_id, $rate, $url);
if ($res) { if ($res) {
echo json_encode("200"); echo json_encode("200");
@ -1186,6 +1186,50 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
} }
public function nano_credit()
{
if ($this->isLogged()) {
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
$data['active'] = "nano_credit";
$data['alert'] = "";
$data['game_pays'] = $this->user_model->getGameCountry();
$data['network'] = $this->session->userdata('network');
$data['country'] = $this->session->userdata('current_pays');
$data['network_id'] = $this->session->userdata('network_id');
$data['firstname'] = $this->session->userdata('firstname');
$data['lastname'] = $this->session->userdata('lastname');
$data['currency_code'] = $this->session->userdata('currency_code');
$data['token'] = $this->session->userdata('token');
$data['email'] = $this->session->userdata('email');
$data['configWallet'] = $data['hasWallet']->first_row();
$data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays'));
$this->load->view('header_hyp', $data);
$this->load->view('nano_credit/gestion_nano_credit_hyp');
$this->load->view('footer');
}
}
public function saveCreditLimit()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$limit_min = $_POST['limit_min'];
$limit_max = $_POST['limit_max'];
$id_network = $_POST['id_network'];
$this->user_model->insertCreditLimit($limit_min, $limit_max, '1', $id_network);
$res = true;
if ($res) {
echo json_encode("200");
} else {
echo json_encode("500");
}
}
}
}
} }
class Operation class Operation

View File

@ -444,4 +444,16 @@ $lang['incoming_requests'] = 'Incoming requests';
$lang['outgoing_requests'] = 'Outgoing requests'; $lang['outgoing_requests'] = 'Outgoing requests';
$lang['incoming_credits_requests'] = 'Incoming credit requests'; $lang['incoming_credits_requests'] = 'Incoming credit requests';
$lang['outgoing_credits_requests'] = 'Outgoing credit requests'; $lang['outgoing_credits_requests'] = 'Outgoing credit requests';
$lang['nanocredit_management'] = 'Nanocredit management';
$lang['change_the_credit_limit'] = 'Change the credit limit';
$lang['minimum_credit_limit'] = 'Minimum credit limit';
$lang['maximum_credit_limit'] = 'Maximum credit limit';
$lang['credit_limit_rule'] = 'The maximum credit limit must be greater than the minimum limit';
$lang['update_credit_limit'] = 'Update credit limits';
$lang['activate_nano_credit'] = 'Activation of Nano credit';
$lang['ilink_world_networks'] = 'iLink World type networks';
$lang['credit_limit'] = 'Credit limit';
$lang['nano_credit_removal'] = 'Removal of nano credit';
$lang['set_credit_limit'] = 'Set the credit limit';
$lang['nano_credit_deleted'] = 'Nano credit deleted';
?> ?>

View File

@ -456,5 +456,16 @@ $lang['incoming_requests'] = 'Demandes entrantes';
$lang['outgoing_requests'] = 'Demandes sortantes'; $lang['outgoing_requests'] = 'Demandes sortantes';
$lang['incoming_credits_requests'] = 'Demandes de crédits entrantes'; $lang['incoming_credits_requests'] = 'Demandes de crédits entrantes';
$lang['outgoing_credits_requests'] = 'Demandes de crédits sortantes'; $lang['outgoing_credits_requests'] = 'Demandes de crédits sortantes';
$lang['nanocredit_management'] = 'Gestion du nano crédit';
$lang['change_the_credit_limit'] = 'Modifier la limite du crédit';
$lang['minimum_credit_limit'] = 'Limite de crédit minimale';
$lang['maximum_credit_limit'] = 'Limite de crédit maximale';
$lang['credit_limit_rule'] = 'La limite de crédit maximale doit être supérieure à la limite minimale';
$lang['update_credit_limit'] = 'Mise à jour des limites de crédits';
$lang['activate_nano_credit'] = 'Activation du Nano credit';
$lang['ilink_world_networks'] = 'Réseaux de type iLink World';
$lang['credit_limit'] = 'Limite de crédit';
$lang['nano_credit_removal'] = 'Suppression du nano crédit';
$lang['set_credit_limit'] = 'Définir la limite de crédit';
$lang['nano_credit_deleted'] = 'Nano crédit supprimé';
?> ?>

View File

@ -2664,4 +2664,23 @@ class User_model extends CI_Model
return false; return false;
} }
} }
// Nano credit
public function insertCreditLimit($limit_min, $limit_max, $has_nano_credit, $id_network)
{
$sql = "UPDATE `configWallet` SET `has_nano_credit` = ?, `limite_credit_min` = ? , `limite_credit_max` = ? WHERE (`id_network` = ? );";
return $this->db->query($sql, array($has_nano_credit, $limit_min, $limit_max, $id_network));
}
public function getAllIlinkWorldNetworks()
{
$query = $this->db->query("SELECT networks.name AS network,networks.status AS status,networks.id,cc.name AS country,networks.country_id , configWallet.id_network , configWallet.type,cc.currency_code,
configWallet.limite_credit_min , configWallet.limite_credit_max , configWallet.has_nano_credit FROM `networks`
INNER JOIN countries_currencies cc ON networks.country_id=cc.id LEFT JOIN configWallet ON configWallet.id_network = networks.id WHERE status = 1 AND configWallet.type = 'ilink'");
if ($query->num_rows() > 0) {
return $query;
} else {
return false;
}
}
} }

View File

@ -137,22 +137,35 @@
<i class="glyphicon glyphicon-tags"></i> <span><?php echo $this->lang->line('Publicité'); ?></span> <i class="glyphicon glyphicon-tags"></i> <span><?php echo $this->lang->line('Publicité'); ?></span>
</a> </a>
</li> </li>
<li class="<?php if($active=="game"){echo "active";} ?>"> <li class="<?php if ($active == "game") {
echo "active";
} ?>">
<a href="#" data-toggle="modal" data-target="#modal-default"> <a href="#" data-toggle="modal" data-target="#modal-default">
<i class="glyphicon glyphicon-phone"></i> <span><?php echo $this->lang->line('Game'); ?></span> <i class="glyphicon glyphicon-phone"></i> <span><?php echo $this->lang->line('Game'); ?></span>
</a> </a>
</li> </li>
<li class="<?php if($active=="wallet"){echo "active";} ?>"> <li class="<?php if ($active == "wallet") {
echo "active";
} ?>">
<a href="<?php echo base_url('index.php/Gestion/wallet') ?>"> <a href="<?php echo base_url('index.php/Gestion/wallet') ?>">
<i class="glyphicon glyphicon-credit-card"></i> <span>Wallet</span> <i class="glyphicon glyphicon-credit-card"></i> <span>Wallet</span>
</a> </a>
</li> </li>
<!-- <li class="--><?php ////if($active=="map"){echo "active";} ?><!--">--> <li class="<?php if ($active == "nano_credit") {
<!-- <a href="--><?php ////echo base_url('index.php/Gestion/map') ?><!--">--> echo "active";
<!-- <i class="glyphicon glyphicon-map-marker"></i> <span>Carte</span>--> } ?>">
<!-- </a>--> <a href="<?php echo base_url('index.php/Gestion/nano_credit') ?>">
<!-- </li>--> <i class="glyphicon glyphicon-credit-card"></i> <span>Nano credit</span>
<li class="<?php if($active=="currency"){echo "active";} ?>"> </a>
</li>
<!-- <li class="--><?php ////if($active=="map"){echo "active";} ?><!--">-->
<!-- <a href="--><?php ////echo base_url('index.php/Gestion/map') ?><!--">-->
<!-- <i class="glyphicon glyphicon-map-marker"></i> <span>Carte</span>-->
<!-- </a>-->
<!-- </li>-->
<li class="<?php if ($active == "currency") {
echo "active";
} ?>">
<a href="<?php echo base_url('index.php/Gestion/currency') ?>"> <a href="<?php echo base_url('index.php/Gestion/currency') ?>">
<i class="ion ion-cash"></i> <span><?php echo $this->lang->line('currency'); ?></span> <i class="ion ion-cash"></i> <span><?php echo $this->lang->line('currency'); ?></span>
</a> </a>

View File

@ -164,9 +164,19 @@
</a> </a>
</li> </li>
<?php if($hasWallet->first_row()->type == 'ilink'){ ?> <?php if($hasWallet->first_row()->type == 'ilink'){ ?>
<li class="<?php if($active=="calculator"){echo "active";} ?>"> <li class="<?php if ($active == "nano_credit") {
echo "active";
} ?>">
<a href="<?php echo base_url('index.php/Hyperviseur_dash/nano_credit') ?>">
<i class="glyphicon glyphicon-credit-card"></i> <span>Nano credit</span>
</a>
</li>
<li class="<?php if ($active == "calculator") {
echo "active";
} ?>">
<a href="<?php echo base_url('index.php/Hyperviseur_dash/calculator') ?>"> <a href="<?php echo base_url('index.php/Hyperviseur_dash/calculator') ?>">
<i class="glyphicon glyphicon-adjust"></i> <span><?php echo $this->lang->line('calculator'); ?></span> <i class="glyphicon glyphicon-adjust"></i>
<span><?php echo $this->lang->line('calculator'); ?></span>
</a> </a>
</li> </li>
<?php }?> <?php }?>

View File

@ -0,0 +1,385 @@
<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') ?>">
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round|Open+Sans">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<?php
use Brick\Money\Context\CustomContext;
use Brick\Money\Money;
$context = new \Brick\Money\Context\AutoContext();
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;
}
$fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Nano crédit <?php echo $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">
<div class="col-lg-4 col-xs-6">
<div class="small-box bg-green-active">
<div class="inner">
<h3><?php echo Money::of(round($configWallet->limite_credit_min, 2), $currency_code, $context)->formatTo('fr_FR') ?></h3>
<p><?php echo $this->lang->line('minimum_credit_limit') ?></p>
</div>
<div class="icon">
<i class="ion ion-cash"></i>
</div>
</div>
</div>
<div class="col-lg-4 col-xs-6">
<div class="small-box bg-red-active">
<div class="inner">
<h3><?php echo Money::of(round($configWallet->limite_credit_max, 2), $currency_code, $context)->formatTo('fr_FR'); ?></h3>
<p><?php echo $this->lang->line('maximum_credit_limit') ?></p>
</div>
<div class="icon">
<i class="ion ion-cash"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="margin">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-limit"
style="width: 100%"><?php echo $this->lang->line('change_the_credit_limit') ?></button>
</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('Commissions Superviseurs') ?><!--</h3>-->
<!-- <div class="box-tools">-->
<!-- <a class="btn btn-primary" href="-->
<?php //echo current_url().($network_id ? '?history=commission_transfer' : '')?><!--">-->
<!-- --><?php //echo $this->lang->line('commission_transfer_historic'); ?>
<!-- </a>-->
<!-- <a class="btn btn-success" href="-->
<?php //echo current_url().($network_id ? '?history=balance_statement' : '')?><!--">-->
<!-- --><?php //echo $this->lang->line('balance_statement'); ?>
<!-- </a>-->
<!-- </div>-->
<!-- </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($superviseurs!=false){
// foreach($superviseurs->result() as $row) {
// $wallet = null;
// foreach ($agentWalletInfos->result() as $value) {
// if ($value->agent_id == $row->agent_id) {
// $wallet = $value;
// break;
// }
// }
// $com = 0;
// $princ = 0;
// if($wallet) {
// $com = $wallet->balance_com;
// $princ = $wallet->balance_princ;
// }
// echo "<tr>
// <td>".$row->lastname."</td>
// <td>".Money::of(round($princ,2), $this->session->userdata('currency_code'),$context)->formatTo('fr_FR')."</td>
// <td>".Money::of(round($com,2), $this->session->userdata('currency_code'),$context)->formatTo('fr_FR')."</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>".Money::of(round($commission_banque,2), $this->session->userdata('currency_code'),$context)->formatTo('fr_FR')."</td>
// <td>".$nb_depots."</td>
// <td>".$nb_retraits."</td>
// </tr>";
// }
//
// }
// ?>
<!-- </tbody>-->
<!-- </table>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<div class="modal fade" id="modal-limit">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h3 class="modal-title"><?php echo $this->lang->line('set_credit_limit'); ?></h3>
</div>
<div class="modal-body">
<form id="limitForm">
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="limit_min"
class="col-form-label"><?php echo $this->lang->line('minimum_credit_limit'); ?></label>
<input type="number" min="0" step=".01" required class="form-control"
id="limit_min" name="limit_min"
value="<?= $configWallet->limite_credit_min ?>">
</div>
<div class="form-group">
<label for="limit_max"
class="col-form-label"><?php echo $this->lang->line('maximum_credit_limit'); ?></label>
<input type="number" min="0" step=".01" required class="form-control"
name="limit_max" id="limit_max"
value="<?= $configWallet->limite_credit_max ?>">
</div>
</div>
</div>
</form>
</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="button" id="saveLimit" data-network-id="<?= $network_id ?>"
class="btn btn-primary"><?php echo $this->lang->line('Continuer'); ?></button>
</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>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<!-- ChartJS -->
<script src="<?php echo base_url('bower_components/chart.js/Chart.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script src="https://cdn.jsdelivr.net/npm/autonumeric@4.5.4"></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>
<script>
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
$('#saveLimit').click(function () {
const limit_min = parseFloat($('#limit_min').val());
const limit_max = parseFloat($('#limit_max').val());
const network_id = $(this).data('network-id');
if (limit_max > limit_min) {
if ($('#limitForm')[0].checkValidity()) {
$.ajax({
url: '<?php echo base_url('index.php/Hyperviseur_dash/saveCreditLimit')?>',
type: 'POST',
dataType: 'json',
data: {
"limit_min": limit_min,
"limit_max": limit_max,
"id_network": network_id,
},
success: function (data) {
if (data == '200') {
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('activate_nano_credit')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(() => {
location.reload();
});
} 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')?>");
}
});
} else {
$('#limitForm')[0].reportValidity();
}
} else {
toastr.error("<?php echo $this->lang->line('credit_limit_rule')?>", "<?php echo $this->lang->line('request_error')?>");
}
});
</script>
<!-- Page script -->
<script src="<?php echo base_url('dist/js/custom.js') ?>"></script>

View File

@ -0,0 +1,257 @@
<link rel="stylesheet"
href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?php echo $this->lang->line('nanocredit_management'); ?>
</h1>
<?php
use Brick\Money\Money;
$context = new \Brick\Money\Context\AutoContext();
$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">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('ilink_world_networks'); ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<?php
$sql2 = $networks;
if ($sql2 != false) {
$numrows = $sql2->num_rows();
$num = 0;
if ($numrows > 0) {
?>
<table id="validated" class="table table-bordered table-striped">
<thead>
<tr>
<th align='center'></th>
<th><?php echo $this->lang->line('Reseau'); ?></th>
<th><?php echo $this->lang->line('Pays'); ?></th>
<th align='center'><?php echo $this->lang->line('credit_limit'); ?></th>
<th align='center'>Nano credit</th>
<th align='center'> Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($sql2->result() as $row) {
$num++;
//$member_code = randomString1(10);
echo "<tr>
<td align='center'>$num</td>
<td >$row->network</td>
<td>$row->country</td>";
?>
<?php
if ($row->has_nano_credit) {
?>
<td>
[ <?= Money::of(round($row->limite_credit_min, 2), $row->currency_code, $context)->formatTo('fr_FR') ?>
--
<?= Money::of(round($row->limite_credit_max, 2), $row->currency_code, $context)->formatTo('fr_FR') ?>
]
</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 {
?>
<td>
<span class="label label-danger"><?php echo $this->lang->line('Inactif'); ?></span>
</td>
<td>
<button type="button" data-network-id="<?php echo $row->id ?>"
class="btn btn-primary activateNanoCredit"><?php echo $this->lang->line('Activer'); ?></button>
</td>
<?php
}
?>
<td>
<a href="<?php echo current_url() . ($row->id_network ? '?id=' . $row->id_network : '') ?>"
class="btn btn-primary btn-block" <?php if (!$row->has_nano_credit) echo "disabled" ?> >
<b><?php echo $this->lang->line('Voir plus...'); ?></b>
</a>
</td>
<?php
}
?>
</tbody>
</table>
<?php
} else {
echo $this->lang->line('Aucun réseau');
}
} else {
echo $this->lang->line('Aucun réseau');
}
?>
</div>
</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('nano_credit_removal'); ?></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="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>
<!-- 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/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');
})
$('.activateNanoCredit').click(function () {
const id_network = $(this).data('network-id');
$.ajax({
url: '<?php echo base_url('index.php/Gestion/activate_nano_credit')?>',
type: 'POST',
dataType: 'json',
data: {"id_network": id_network},
success: function (data, statut) {
if (data == '200') {
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('activate_nano_credit')?>",
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')?>");
}
});
});
$('#deleteWallet').click(function () {
$.ajax({
url: '<?php echo base_url('index.php/Gestion/delete_nano_credit')?>',
type: 'POST',
dataType: 'json',
data: {"id_network": network_id},
success: function (data, statut) {
if (data == '200') {
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('nano_credit_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>