backoffice/application/views/config_wallet_ilink_hyp/user_wallet_cash.php

546 lines
20 KiB
PHP
Raw Normal View History

<link rel="stylesheet"
href="<?= base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
<link rel="stylesheet" href="<?= base_url('bower_components/bootstrap-daterangepicker/daterangepicker.css') ?>">
<link rel="stylesheet"
href="<?= base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet" href="<?= base_url('bower_components/toastr/toastr.css') ?>">
<link rel="stylesheet" href="<?= base_url('bower_components/google-material-icons/google-material-icons.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>
<?= $this->lang->line('config_user').' - '.$this->lang->line('config_ilink_user_wallet_cash'); ?>
</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>
<?= $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>
<?= $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%"><?= $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"><?= $this->lang->line('rate_com_user_wallet_cash_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_cash != false) {
foreach ($plr_user_wallet_cash->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"><?= $this->lang->line('rate_com_user_wallet_cash_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_cash_national != false) {
foreach ($plr_user_wallet_cash_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><?= $this->lang->line('config_ilink_note') ?></h4>
</div>
<div class="row">
<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">&times;</span>
</button>
<h3 class="modal-title"><?= $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"><?= $this->lang->line('rate_com_user_wallet_cash_international'); ?></label>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new2"><i
class="fa fa-plus"></i> <?= $this->lang->line('new_level'); ?>
</button>
</div>
</div>
</div>
<table id="user_wallet_cash" class="table table-bordered">
<thead>
<tr>
<th>Min</th>
<th>Max</th>
<th><?= $this->lang->line('rate'); ?> (%)</th>
<th><?= $this->lang->line('ceiling')?></th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if ($plr_user_wallet_cash != false) {
foreach ($plr_user_wallet_cash->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 add2" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit2" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete2" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</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"><?= $this->lang->line('rate_com_user_wallet_cash_national'); ?></label>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new8"><i
class="fa fa-plus"></i> <?= $this->lang->line('new_level'); ?>
</button>
</div>
</div>
</div>
<table id="user_wallet_cash_national" class="table table-bordered">
<thead>
<tr>
<th>Min</th>
<th>Max</th>
<th><?= $this->lang->line('rate'); ?> (%)</th>
<th><?= $this->lang->line('ceiling')?></th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if ($plr_user_wallet_cash_national != false) {
foreach ($plr_user_wallet_cash_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 add8" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit8" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete8" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</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"><?= $this->lang->line('Fermer'); ?></button>
<button type="button" id="updateWallet" data-network-id="<?= $network_id ?>"
data-id-config="<?= $idConfig ?>"
class="btn btn-primary"><?= $this->lang->line('save'); ?></button>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- jQuery 3 -->
<script src="<?= base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
<!-- Bootstrap 3.3.7 -->
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
<script src="<?= base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
<script src="<?= base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
<!-- Slimscroll -->
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
<!-- FastClick -->
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
<!-- AdminLTE App -->
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?= base_url('dist/js/demo.js') ?>"></script>
<script src="<?= base_url('bower_components/moment/min/moment.min.js') ?>"></script>
<script src="<?= base_url('bower_components/bootstrap-daterangepicker/daterangepicker.js') ?>"></script>
<script src="<?= 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="<?= base_url('bower_components/chart.js/Chart.js') ?>"></script>
<script src="<?= base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="<?= 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_cash = [];
var plr_user_wallet_cash_national = [];
$('#user_wallet_cash 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_cash.push(arrayItem);
});
$('#user_wallet_cash_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_cash_national.push(arrayItem);
});
$.ajax({
url: '<?= base_url('Gestion/config_wallet/update')?>',
type: 'POST',
dataType: 'json',
data: {
"type": "ilink",
"config": "user_wallet_cash",
"network_id": network_id, "id_config": id_config,
"plr_user_wallet_cash": plr_user_wallet_cash,
"plr_user_wallet_cash_national": plr_user_wallet_cash_national
},
success: function (data) {
if (data == '200') {
Swal.fire({
icon: 'success',
title: "<?= $this->lang->line('wallet_update')?>",
text: "<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(() => {
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
} else {
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
}
});
} else {
$('#walletForm')[0].reportValidity();
}
});
</script>
<script type="text/javascript">
// Paliers scripts
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
// Table 2
var actions2 = $("#user_wallet_cash td:last-child").html();
// Append table with add row form on add new button click
$(".new2").click(function () {
if (!actions2) {
actions2 = '<a class="add add2" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>\n' +
' <a class="edit edit2" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete2" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#user_wallet_cash 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 step="any" class="form-control" name="taux" id="taux"></td>' +
'<td><input type="number" min="1" class="form-control" name="plafond" id="plafond"></td>' +
'<td> ' + actions2 + '</td>' +
'</tr>';
$("#user_wallet_cash").append(row);
$("#user_wallet_cash tbody tr").eq(index + 1).find(".add2, .edit2").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add2", 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(".add2, .edit2").toggle();
$(".new2").removeAttr("disabled");
}
});
// Edit row on edit button click
$(document).on("click", ".edit2", 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" step="any" 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(".add2, .edit2").toggle();
$(".new2").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete2", function () {
$(this).parents("tr").remove();
$(".new2").removeAttr("disabled");
});
// Table 8
var actions8 = $("#user_wallet_cash_national td:last-child").html();
// Append table with add row form on add new button click
$(".new8").click(function () {
if (!actions8) {
actions8 = '<a class="add add8" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE08B;</i></a>\n' +
' <a class="edit edit8" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete8" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE882;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#user_wallet_cash_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 step="any" class="form-control" name="taux" id="taux"></td>' +
'<td><input type="number" min="1" class="form-control" name="plafond" id="plafond"></td>' +
'<td> ' + actions8 + '</td>' +
'</tr>';
$("#user_wallet_cash_national").append(row);
$("#user_wallet_cash_national tbody tr").eq(index + 1).find(".add8, .edit8").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add8", 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(".add8, .edit8").toggle();
$(".new8").removeAttr("disabled");
}
});
// Edit row on edit button click
$(document).on("click", ".edit8", 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" step="any" 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(".add8, .edit8").toggle();
$(".new8").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete8", function () {
$(this).parents("tr").remove();
$(".new8").removeAttr("disabled");
});
});
</script>