542 lines
20 KiB
PHP
Executable File
542 lines
20 KiB
PHP
Executable File
<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('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">
|
||
<link rel="stylesheet" href="<?= base_url('dist/css/custom/levels-table.css') ?>">
|
||
<?php
|
||
|
||
use Brick\Money\Context\CustomContext;
|
||
use Brick\Money\Money;
|
||
|
||
$context = new \Brick\Money\Context\AutoContext();
|
||
$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('config_user').' - '.$this->lang->line('config_ilink_user_wallet_wallet'); ?>
|
||
</h1>
|
||
<?php
|
||
|
||
|
||
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">×</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-12">
|
||
<div class="margin">
|
||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-update"
|
||
style="width: 100%"><?php echo $this->lang->line('Modifier la configuration') ?></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row centered">
|
||
<div class="col-lg-6 col-xs-12">
|
||
<div class="box">
|
||
<div class="box-header">
|
||
<h3 class="box-title"><?php echo $this->lang->line('rate_com_user_wallet_wallet_international'); ?></h3>
|
||
</div>
|
||
<!-- /.box-header -->
|
||
<div class="box-body table-responsive" style="overflow-x:auto;">
|
||
<table class="table table-hover">
|
||
<tbody>
|
||
<tr>
|
||
<th>Min</th>
|
||
<th>Max</th>
|
||
<th>Taux (%)</th>
|
||
<th><?= $this->lang->line('ceiling')?></th>
|
||
</tr>
|
||
<?php
|
||
if ($plr_user_wallet_wallet != false) {
|
||
foreach ($plr_user_wallet_wallet->result() as $row) {
|
||
echo "<tr>
|
||
<td>" . $fmt->format($row->min) . "</td>
|
||
<td>" . $fmt->format($row->max) . "</td>
|
||
<td>" . $row->taux . "</td>
|
||
<td>" . (isset($row->plafond) ? floatval($row->plafond) : '') . "</td>" . '
|
||
</tr>';
|
||
}
|
||
}
|
||
?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<!-- /.box-body -->
|
||
</div>
|
||
</div>
|
||
<div class="col-lg-6 col-xs-12">
|
||
<div class="box">
|
||
<div class="box-header">
|
||
<h3 class="box-title"><?php echo $this->lang->line('rate_com_user_wallet_wallet_national'); ?></h3>
|
||
</div>
|
||
<!-- /.box-header -->
|
||
<div class="box-body table-responsive" style="overflow-x:auto;">
|
||
<table class="table table-hover">
|
||
<tbody>
|
||
<tr>
|
||
<th>Min</th>
|
||
<th>Max</th>
|
||
<th>Taux (%)</th>
|
||
<th><?= $this->lang->line('ceiling')?></th>
|
||
</tr>
|
||
<?php
|
||
if ($plr_user_wallet_wallet_national != false) {
|
||
foreach ($plr_user_wallet_wallet_national->result() as $row) {
|
||
echo "<tr>
|
||
<td>" . $fmt->format($row->min) . "</td>
|
||
<td>" . $fmt->format($row->max) . "</td>
|
||
<td>" . $row->taux . "</td>
|
||
<td>" . (isset($row->plafond) ? floatval($row->plafond) : '') . "</td>" . '
|
||
</tr>';
|
||
}
|
||
}
|
||
?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<!-- /.box-body -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="callout callout-info">
|
||
<p>Note</p>
|
||
<h4><?php echo $this->lang->line('config_ilink_note') ?></h4>
|
||
</div>
|
||
<div class="modal fade" id="modal-update">
|
||
<div class="modal-dialog" style="max-width: 1200px; width: 100%;">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span>
|
||
</button>
|
||
<h3 class="modal-title"><?php echo $this->lang->line('Configuration du wallet'); ?></h3>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form id="walletForm">
|
||
<div class="row">
|
||
<div class="col-lg-6">
|
||
<div class="form-group" style="overflow-x:auto;">
|
||
<div class="table-title">
|
||
<div class="row">
|
||
<div class="col-sm-8">
|
||
<label for="nom"
|
||
class="col-form-label"><?php echo $this->lang->line('rate_com_user_wallet_wallet_international'); ?></label>
|
||
</div>
|
||
<div class="col-sm-4">
|
||
<button type="button" class="btn btn-info add-new new1"><i
|
||
class="fa fa-plus"></i> <?php echo $this->lang->line('new_level'); ?>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<table id="user_wallet_wallet" class="table table-bordered">
|
||
<thead>
|
||
<tr>
|
||
<th>Min</th>
|
||
<th>Max</th>
|
||
<th><?php echo $this->lang->line('rate'); ?> (%)</th>
|
||
<th><?= $this->lang->line('ceiling')?></th>
|
||
<th>Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php
|
||
if ($plr_user_wallet_wallet != false) {
|
||
foreach ($plr_user_wallet_wallet->result() as $row) {
|
||
echo "<tr>
|
||
<td>" . $row->min . "</td>
|
||
<td>" . $row->max . "</td>
|
||
<td>" . $row->taux . "</td>
|
||
<td>" . (isset($row->plafond) ? floatval($row->plafond) : '') . "</td>" . '
|
||
<td>
|
||
<a class="add add1" title="Add" data-toggle="tooltip"><i class="material-icons"></i></a>
|
||
<a class="edit edit1" title="Edit" data-toggle="tooltip"><i class="material-icons"></i></a>
|
||
<a class="delete delete1" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a>
|
||
</td>
|
||
</tr>';
|
||
}
|
||
}
|
||
?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="col-lg-6">
|
||
<div class="form-group" style="overflow-x:auto;">
|
||
<div class="table-title">
|
||
<div class="row">
|
||
<div class="col-sm-8">
|
||
<label for="nom"
|
||
class="col-form-label"><?php echo $this->lang->line('rate_com_user_wallet_wallet_national'); ?></label>
|
||
</div>
|
||
<div class="col-sm-4">
|
||
<button type="button" class="btn btn-info add-new new7"><i
|
||
class="fa fa-plus"></i> <?php echo $this->lang->line('new_level'); ?>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<table id="user_wallet_wallet_national" class="table table-bordered">
|
||
<thead>
|
||
<tr>
|
||
<th>Min</th>
|
||
<th>Max</th>
|
||
<th><?php echo $this->lang->line('rate'); ?> (%)</th>
|
||
<th><?= $this->lang->line('ceiling')?></th>
|
||
<th>Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php
|
||
if ($plr_user_wallet_wallet_national != false) {
|
||
foreach ($plr_user_wallet_wallet_national->result() as $row) {
|
||
echo "<tr>
|
||
<td>" . $row->min . "</td>
|
||
<td>" . $row->max . "</td>
|
||
<td>" . $row->taux . "</td>
|
||
<td>" . (isset($row->plafond) ? floatval($row->plafond) : '') . "</td>" . '
|
||
<td>
|
||
<a class="add add7" title="Add" data-toggle="tooltip"><i class="material-icons"></i></a>
|
||
<a class="edit edit7" title="Edit" data-toggle="tooltip"><i class="material-icons"></i></a>
|
||
<a class="delete delete7" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a>
|
||
</td>
|
||
</tr>';
|
||
}
|
||
}
|
||
?>
|
||
</tbody>
|
||
</table>
|
||
</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="updateWallet" data-network-id="<?= $network_id ?>"
|
||
data-id-config="<?= $idConfig ?>"
|
||
class="btn btn-primary"><?php echo $this->lang->line('save'); ?></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>
|
||
toastr.options.closeButton = true;
|
||
toastr.options.closeMethod = 'fadeOut';
|
||
toastr.options.closeDuration = 5000;
|
||
toastr.options.closeEasing = 'swing';
|
||
|
||
$('#updateWallet').click(function () {
|
||
const network_id = $(this).data('network-id');
|
||
const id_config = $(this).data('id-config');
|
||
if ($('#walletForm')[0].checkValidity()) {
|
||
|
||
// Paliers
|
||
var plr_user_wallet_wallet = [];
|
||
|
||
var plr_user_wallet_wallet_national = [];
|
||
|
||
$('#user_wallet_wallet tr').has('td').each(function () {
|
||
var arrayItem = {};
|
||
$('td', $(this)).each(function (index, item) {
|
||
if (index < 4){
|
||
let val = parseFloat($(item).html())
|
||
arrayItem[index] = !isNaN(val) ? val : null;
|
||
}
|
||
});
|
||
plr_user_wallet_wallet.push(arrayItem);
|
||
});
|
||
|
||
|
||
$('#user_wallet_wallet_national tr').has('td').each(function () {
|
||
var arrayItem = {};
|
||
$('td', $(this)).each(function (index, item) {
|
||
if (index < 4){
|
||
let val = parseFloat($(item).html())
|
||
arrayItem[index] = !isNaN(val) ? val : null;
|
||
}
|
||
});
|
||
plr_user_wallet_wallet_national.push(arrayItem);
|
||
});
|
||
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('Gestion/config_wallet/update')?>',
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
data: {
|
||
"type": "ilink",
|
||
"config":"user_wallet_wallet",
|
||
"network_id": network_id, "id_config": id_config,
|
||
"plr_user_wallet_wallet": plr_user_wallet_wallet,
|
||
"plr_user_wallet_wallet_national": plr_user_wallet_wallet_national,
|
||
},
|
||
success: function (data) {
|
||
if (data == '200') {
|
||
Swal.fire({
|
||
icon: 'success',
|
||
title: "<?php echo $this->lang->line('wallet_update')?>",
|
||
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')?>");
|
||
}
|
||
});
|
||
|
||
|
||
} else {
|
||
$('#walletForm')[0].reportValidity();
|
||
}
|
||
});
|
||
</script>
|
||
<script type="text/javascript">
|
||
// Paliers scripts
|
||
$(document).ready(function () {
|
||
$('[data-toggle="tooltip"]').tooltip();
|
||
var actions1 = $("#user_wallet_wallet td:last-child").html();
|
||
// Append table with add row form on add new button click
|
||
$(".new1").click(function () {
|
||
if (!actions1) {
|
||
actions1 = '<a class="add add1" title="Add" data-toggle="tooltip"><i class="material-icons"></i></a>\n' +
|
||
' <a class="edit edit1" title="Edit" data-toggle="tooltip"><i class="material-icons"></i></a>\n' +
|
||
' <a class="delete delete1" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a>';
|
||
}
|
||
$(this).attr("disabled", "disabled");
|
||
var index = $("#user_wallet_wallet tbody tr:last-child").index();
|
||
var row = '<tr>' +
|
||
'<td><input type="number" required min="0" class="form-control" name="min" id="min"></td>' +
|
||
'<td><input type="number" required class="form-control" name="max" id="max"></td>' +
|
||
'<td><input type="number" required class="form-control" min="0" name="taux" id="taux"></td>' +
|
||
'<td><input type="number" min="1" class="form-control" name="plafond" id="plafond"></td>' +
|
||
'<td> ' + actions1 + '</td>' +
|
||
'</tr>';
|
||
$("#user_wallet_wallet").append(row);
|
||
$("#user_wallet_wallet tbody tr").eq(index + 1).find(".add, .edit").toggle();
|
||
$('[data-toggle="tooltip"]').tooltip();
|
||
});
|
||
// Add row on add button click
|
||
$(document).on("click", ".add1", function () {
|
||
var empty = false;
|
||
var input = $(this).parents("tr").find('input[type="number"]');
|
||
var min = parseFloat($(this).parents("tr").find('input[id="min"]').first().val());
|
||
var max = parseFloat($(this).parents("tr").find('input[id="max"]').first().val());
|
||
|
||
input.each(function () {
|
||
if ($(this).attr('id') == 'min') {
|
||
if (min >= max) {
|
||
$(this).addClass("error");
|
||
$(this)[0].reportValidity();
|
||
empty = true;
|
||
} else {
|
||
$(this).removeClass("error");
|
||
}
|
||
} else if ($(this).attr('id') == 'max') {
|
||
if (max <= min) {
|
||
$(this).addClass("error");
|
||
$(this)[0].reportValidity();
|
||
empty = true;
|
||
} else {
|
||
$(this).removeClass("error");
|
||
}
|
||
} else {
|
||
if (!$(this)[0].checkValidity()) {
|
||
$(this).addClass("error");
|
||
$(this)[0].reportValidity();
|
||
empty = true;
|
||
} else {
|
||
$(this).removeClass("error");
|
||
}
|
||
}
|
||
});
|
||
$(this).parents("tr").find(".error").first().focus();
|
||
if (!empty) {
|
||
input.each(function () {
|
||
$(this).parent("td").html($(this).val());
|
||
});
|
||
$(this).parents("tr").find(".add, .edit").toggle();
|
||
$(".new1").removeAttr("disabled");
|
||
}
|
||
});
|
||
// Edit row on edit button click
|
||
$(document).on("click", ".edit1", function () {
|
||
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
|
||
if (index == 0)
|
||
$(this).html('<input type="number" required class="form-control" min="0" id="min" value="' + $(this).text() + '">');
|
||
if (index == 1)
|
||
$(this).html('<input type="number" required class="form-control" id="max" value="' + $(this).text() + '">');
|
||
if (index == 2)
|
||
$(this).html('<input type="number" required class="form-control" min="0" value="' + $(this).text() + '">');
|
||
if (index == 3)
|
||
$(this).html('<input type="number" class="form-control" min="1" value="' + $(this).text() + '">');
|
||
});
|
||
$(this).parents("tr").find(".add, .edit").toggle();
|
||
$(".new1").attr("disabled", "disabled");
|
||
});
|
||
// Delete row on delete button click
|
||
$(document).on("click", ".delete1", function () {
|
||
$(this).parents("tr").remove();
|
||
$(".new1").removeAttr("disabled");
|
||
});
|
||
|
||
|
||
// Paliers nationaux
|
||
|
||
// Table 7
|
||
var actions7 = $("#user_wallet_wallet_national td:last-child").html();
|
||
// Append table with add row form on add new button click
|
||
$(".new7").click(function () {
|
||
if (!actions7) {
|
||
actions7 = '<a class="add add7" title="Add" data-toggle="tooltip"><i class="material-icons"></i></a>\n' +
|
||
' <a class="edit edit7" title="Edit" data-toggle="tooltip"><i class="material-icons"></i></a>\n' +
|
||
' <a class="delete delete7" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a>';
|
||
}
|
||
$(this).attr("disabled", "disabled");
|
||
var index = $("#user_wallet_wallet_national tbody tr:last-child").index();
|
||
var row = '<tr>' +
|
||
'<td><input type="number" required min="0" class="form-control" name="min" id="min"></td>' +
|
||
'<td><input type="number" required class="form-control" name="max" id="max"></td>' +
|
||
'<td><input type="number" required class="form-control" name="taux" id="taux"></td>' +
|
||
'<td><input type="number" min="1" class="form-control" name="plafond" id="plafond"></td>' +
|
||
'<td> ' + actions7 + '</td>' +
|
||
'</tr>';
|
||
$("#user_wallet_wallet_national").append(row);
|
||
$("#user_wallet_wallet_national tbody tr").eq(index + 1).find(".add, .edit").toggle();
|
||
$('[data-toggle="tooltip"]').tooltip();
|
||
});
|
||
// Add row on add button click
|
||
$(document).on("click", ".add7", function () {
|
||
var empty = false;
|
||
var input = $(this).parents("tr").find('input[type="number"]');
|
||
var min = parseFloat($(this).parents("tr").find('input[id="min"]').first().val());
|
||
var max = parseFloat($(this).parents("tr").find('input[id="max"]').first().val());
|
||
|
||
input.each(function () {
|
||
if ($(this).attr('id') == 'min') {
|
||
if (min >= max) {
|
||
$(this).addClass("error");
|
||
$(this)[0].reportValidity();
|
||
empty = true;
|
||
} else {
|
||
$(this).removeClass("error");
|
||
}
|
||
} else if ($(this).attr('id') == 'max') {
|
||
if (max <= min) {
|
||
$(this).addClass("error");
|
||
$(this)[0].reportValidity();
|
||
empty = true;
|
||
} else {
|
||
$(this).removeClass("error");
|
||
}
|
||
} else {
|
||
if (!$(this)[0].checkValidity()) {
|
||
$(this).addClass("error");
|
||
$(this)[0].reportValidity();
|
||
empty = true;
|
||
} else {
|
||
$(this).removeClass("error");
|
||
}
|
||
}
|
||
});
|
||
$(this).parents("tr").find(".error").first().focus();
|
||
if (!empty) {
|
||
input.each(function () {
|
||
$(this).parent("td").html($(this).val());
|
||
});
|
||
$(this).parents("tr").find(".add, .edit").toggle();
|
||
$(".new7").removeAttr("disabled");
|
||
}
|
||
});
|
||
// Edit row on edit button click
|
||
$(document).on("click", ".edit7", function () {
|
||
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
|
||
if (index == 0)
|
||
$(this).html('<input type="number" required class="form-control" min="0" id="min" value="' + $(this).text() + '">');
|
||
if (index == 1)
|
||
$(this).html('<input type="number" required class="form-control" id="max" value="' + $(this).text() + '">');
|
||
if (index == 2)
|
||
$(this).html('<input type="number" required class="form-control" min="0" value="' + $(this).text() + '">');
|
||
if (index == 3)
|
||
$(this).html('<input type="number" class="form-control" min="1" value="' + $(this).text() + '">');
|
||
});
|
||
$(this).parents("tr").find(".add, .edit").toggle();
|
||
$(".new7").attr("disabled", "disabled");
|
||
});
|
||
// Delete row on delete button click
|
||
$(document).on("click", ".delete7", function () {
|
||
$(this).parents("tr").remove();
|
||
$(".new7").removeAttr("disabled");
|
||
});
|
||
});
|
||
</script>
|