backoffice/application/views/gestion_monnaie.php

274 lines
7.6 KiB
PHP
Raw Normal View History

2020-06-01 11:21:06 +00:00
<link rel="stylesheet"
2022-04-18 11:39:19 +00:00
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/toastr/toastr.css') ?>">
<link rel="stylesheet" href="<?= base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
2020-06-01 11:21:06 +00:00
<style type="text/css">
.table-wrapper {
width: 500px;
2020-06-01 11:21:06 +00:00
margin: 30px auto;
background: #fff;
padding: 20px;
box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
.table-title {
padding-bottom: 10px;
margin: 0 0 10px;
}
.table-title h2 {
margin: 6px 0 0;
font-size: 22px;
}
.table-title .add-new {
float: right;
height: 30px;
font-weight: bold;
font-size: 12px;
text-shadow: none;
min-width: 100px;
border-radius: 50px;
line-height: 13px;
}
.table-title .add-new i {
margin-right: 4px;
}
table.table {
table-layout: fixed;
}
table.table tr th, table.table tr td {
border-color: #e9e9e9;
}
table.table th i {
font-size: 13px;
margin: 0 5px;
cursor: pointer;
}
table.table th:last-child {
width: 100px;
}
table.table td a {
cursor: pointer;
display: inline-block;
margin: 0 5px;
min-width: 24px;
}
table.table td a.add {
color: #27C46B;
}
table.table td a.edit {
color: #FFC107;
}
table.table td a.delete {
color: #E34724;
}
table.table td i {
font-size: 19px;
}
table.table td a.add i {
font-size: 24px;
margin-right: -1px;
position: relative;
top: 3px;
}
table.table .form-control {
height: 32px;
line-height: 32px;
box-shadow: none;
border-radius: 2px;
}
/*table.table .form-control.error {*/
/* border-color: #f50000;*/
/*}*/
.error {
border-color: #f50000;
}
table.table td .add {
display: none;
}
</style>
<?php
use Brick\Money\CurrencyConverter;
use Brick\Money\ExchangeRateProvider\PDOProvider;
use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
use Brick\Math\RoundingMode;
use Brick\Money\Money;
// set to whatever your rates are relative to
$baseCurrency = 'USD';
// use your own credentials, or re-use your existing PDO connection
$pdo = new PDO('mysql:host='.$this->db->hostname.';dbname='.$this->db->database, $this->db->username, $this->db->password);
$configuration = new PDOProviderConfiguration();
$configuration->tableName = 'exchange_rate';
$configuration->exchangeRateColumnName = 'exchange_rate';
$configuration->targetCurrencyColumnName = 'target_currency';
$configuration->sourceCurrencyCode = $baseCurrency;
// this provider loads exchange rates from your database
$provider = new PDOProvider($pdo, $configuration);
// this provider calculates exchange rates relative to the base currency
$provider = new BaseCurrencyProvider($provider, $baseCurrency);
// this currency converter can now handle any currency pair
$converter = new CurrencyConverter($provider);
//$money = Money::of('1', 'USD');
//$mone2 = $converter->convert($money, 'XAF', RoundingMode::DOWN);
?>
2020-06-01 11:21:06 +00:00
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
2022-04-18 11:39:19 +00:00
<?= $this->lang->line('currency_management'). ' '. $network .' - '.$country; ?>
2020-06-01 11:21:06 +00:00
</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>
2022-04-18 11:39:19 +00:00
<?= $message; ?>
2020-06-01 11:21:06 +00:00
</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>
2022-04-18 11:39:19 +00:00
<?= $message; ?>
2020-06-01 11:21:06 +00:00
</div>
<?php
}
}
?>
</section>
<section class="content">
<div class="row centered">
<div class="col-lg-2 col-xs-6">
<div class="small-box bg-red-active">
<div class="inner">
2022-04-18 11:39:19 +00:00
<h4><strong> <?= $currency_code.' - '.$currency_name_fr; ?> </strong></h4>
<p><?= $this->lang->line('currency') ?></p>
2020-06-01 11:21:06 +00:00
</div>
</div>
</div>
</div>
<div class="row">
<div class="table-wrapper" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
2022-04-18 11:39:19 +00:00
<label class="col-form-label"><?= $this->lang->line('conversion_rate') ; ?></label>
</div>
</div>
</div>
<table id="taux_conversion" class="table table-bordered table-striped" >
<thead>
<tr>
2022-04-18 11:39:19 +00:00
<th width="60%"><?= $this->lang->line('currency') ; ?> </th>
<th><?= $this->lang->line('rate') ; ?> (%) </th>
</tr>
</thead>
<tbody>
<?php
if($currencies!=false){
foreach($currencies->result() as $row) {
$name = $this->session->userdata('site_lang') === 'french' ? $row->name_fr : $row->name_en;
echo "<tr>
<td>".$row->code.' - '.$name."</td>
<td>".round($provider->getExchangeRate($currency_code ,$row->code)->toFloat(),3)."</td>".'
</tr>';
}
}
?>
</tbody>
</table>
<button type="button" id="save" class="btn btn-primary btn-block" >
2022-04-18 11:39:19 +00:00
<b><?= $this->lang->line('update_rate'); ?></b>
</button>
2020-06-01 11:21:06 +00:00
</div>
</div>
</section>
</div>
2020-06-01 11:21:06 +00:00
<!-- jQuery 3 -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
2020-06-01 11:21:06 +00:00
<!-- Bootstrap 3.3.7 -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
2022-04-18 11:39:19 +00:00
<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>
2020-06-01 11:21:06 +00:00
<!-- Slimscroll -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
2020-06-01 11:21:06 +00:00
<!-- FastClick -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
2020-06-01 11:21:06 +00:00
<!-- AdminLTE App -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
2020-06-01 11:21:06 +00:00
<!-- AdminLTE for demo purposes -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('dist/js/demo.js') ?>"></script>
<script src="<?= 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>
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('dist/js/sweetalert2.js') ?>"></script>
2020-06-01 11:21:06 +00:00
<script>
$(function() {
$('#taux_conversion').DataTable();
})
</script>
2020-06-01 11:21:06 +00:00
<script>
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
$('#save').click(function () {
$.ajax({
2022-04-18 11:39:19 +00:00
url: '<?= base_url('Gestion/fetchExchangeRates')?>',
type: 'GET',
dataType: 'json',
success: function (data) {
if(data===200){
Swal.fire({
icon: 'success',
2022-04-18 11:39:19 +00:00
title: "<?= $this->lang->line('rates_update')?>",
text:"<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
}else{
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
}
},
2020-06-01 11:21:06 +00:00
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
2020-06-01 11:21:06 +00:00
}
});
});
</script>
2020-06-01 11:21:06 +00:00
<!-- Page script -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('dist/js/custom.js') ?>"></script>