backoffice/application/views/historique_demande_credit_a...

337 lines
11 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- DataTables -->
<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" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
<div class="content-wrapper">
<?php
// use Carbon\Carbon;
$fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL );
function duree($time)
{
$tabTemps = array("jours" => 86400,
"h" => 3600,
"m" => 60,
"s" => 1);
$result = "";
foreach ($tabTemps as $uniteTemps => $nombreSecondesDansUnite) {
$$uniteTemps = floor($time / $nombreSecondesDansUnite);
$time = $time % $nombreSecondesDansUnite;
if ($$uniteTemps > 0 || !empty($result)) {
$result .= $$uniteTemps . " $uniteTemps ";
}
}
return $result;
}
function dateDiff($date1, $date2,$class = null)
{
$diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative
$retour = array();
$tmp = $diff;
$second = $tmp % 60;
$tmp = floor(($tmp - $second) / 60);
$minute = $tmp % 60;
$tmp = floor(($tmp - $minute) / 60);
$heure = $tmp % 24;
$tmp = floor(($tmp - $heure) / 24);
$jour = $tmp;
return $class->lang->line('since').' ' . $jour . ' '.$class->lang->line('days').' ' . $heure . ' '.$class->lang->line('hours').' ' . $minute . ' '.$class->lang->line('minutes').' ' . $second . ' '.$class->lang->line('seconds');
}
function traitementTemps($time, $dateAjout , $class = null)
{
if ($time == null) {
$now = time();
$date2 = strtotime($dateAjout);
return dateDiff($now, $date2,$class);
} else {
return duree($time);
}
}
?>
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?php echo $this->lang->line('history_canceled_credit_requests'); ?>
</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-md-4 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-aqua"><i class="ion ion-android-time"></i></span>
<div class="info-box-content">
<span class="info-box-text"> <?php echo $this->lang->line('Période') ?> </span>
<span class="info-box-number">
<input id="picker"
style="background: #fff; cursor: pointer; padding: 1px 1px; border: 1px solid #ccc; width: 100%"
type="text" name="daterange"
data-lang="<?php echo $this->session->userdata('site_lang') ?>"
data-type="<?php echo $demand_type ?>"
data-category="<?php echo $this->session->userdata('category') ?>"
value="<?php echo ($debut != null & $fin != null) ? $debut . ' - ' . $fin : '' ?>"
/>
</span>
<span> Format : <?php echo $this->session->userdata('site_lang') === 'french' ? 'Jour - Mois - Année ' : 'Year - Month - Day' ?> </span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-body" style="overflow-x:auto;">
<?php
$result = $list;
if ($result != false){
$numrows = $result->num_rows();
$num = 0;
if ($numrows > 0) {
?>
<table id="listeMembres1" class="table table-bordered table-striped table-modified">
<thead>
<?php
echo "<tr class='label-primary'>
<th>" . $this->lang->line('Emetteur') . "</th>
<th>" . $this->lang->line('receiver'). "</th>
<th>" . $this->lang->line('Montant') . "</th>
<th>" . $this->lang->line('Date de la demande') . "</th>
<th>" . $this->lang->line('Date de traitement') . "</th>
<th>" . $this->lang->line('Délai de traitement') . "</th>
<th>" . $this->lang->line('cancellation_date') . "</th>
</tr>";
?>
</thead>
<tbody>
<?php
// output data of each row
foreach ($result->result() as $row) {
$num++;
$origin = $row->agent." | ".$row->phone;
$destination = $row->name_parrain." | ".$row->phone_parrain;
if ($row->codeMembre == $this->session->userdata('member_code')) {
$origin = $this->lang->line('Vous');
}
if ($row->codeParrain == $this->session->userdata('member_code')) {
$destination = $this->lang->line('Vous');
}
echo "<tr>
<td >".$origin."</td>
<td >$destination</td>
<td>". $fmt->format($row->montant)."</td>
<td>" . $row->dateAjout . "</td>
<td > " . $row->dateModif . "</td>
<td>" . traitementTemps($row->temps, $row->dateAjout,$this) . "</td>
<td>" . $row->cancellation_date. "</td>
"; ?>
</tr>
<?php } ?>
</tbody>
<?php
} else {
echo $this->lang->line('Aucune demande');
}
} else {
echo $this->lang->line('Aucune demande');
}
?>
</table>
</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>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment-with-locales.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script>
$(function () {
const lang = $('#picker').data('lang');
const format = lang === 'french' ? 'fr' : 'en';
moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date
$('#listeMembres1').DataTable({
"aaSorting": [[6, "desc"]],
"columnDefs": [{
targets: [3, 4 ,6],
render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format),
}
],
dom: 'Bfrtip',
"buttons": [
'pageLength',
{
extend: 'excelHtml5',
title: "<?=$this->lang->line('history_canceled_credit_requests')?>"
},
{
extend: 'csvHtml5',
title: "<?=$this->lang->line('history_canceled_credit_requests')?>"
},
{
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
title: "<?=$this->lang->line('history_canceled_credit_requests')?>"
}
]
});
});
</script>
<script type="text/javascript">
var startDate;
var endDate;
$(function () {
const lang = $('#picker').data('lang');
$('input[name="daterange"]').daterangepicker({
opens: 'left',
autoUpdateInput: false,
locale: {
format: lang === 'french' ? 'DD-MM-YYYY' : 'YYYY-MM-DD',
cancelLabel: 'Clear'
}
}, function (start, end, label) {
const debut = start.format('YYYY-MM-DD');
const fin = end.format('YYYY-MM-DD');
window.location.replace("<?php echo base_url('index.php/Hyperviseur_dash/demandsCancellation?show=history')?>" + "&d=" + debut + "&f=" + fin);
});
$('input[name="daterange"]').on('cancel.daterangepicker', function (ev, picker) {
//do something, like clearing an input
$('#daterange').val('');
window.location = "<?php echo current_url()?>";
});
});
</script>
<script>
$(document).on("click", "#cancelDemand", function () {
const id_demand = $(this).data('id-demand');
$.ajax({
url: '<?php echo base_url('index.php/Hyperviseur_dash/cancelCreditRequest')?>',
type: 'POST',
dataType: 'json',
data: {"id_demand": id_demand},
async: true,
success: function (data) {
if (data == '200') {
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('canceled_credit_request')?>",
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>