Mini Shell
<!doctype html>
<html lang="fr">
<head>
<?php
require_once("_include/meta.php");
require_once("_include/link.php");
require_once("_include/script.php");
require_once("_include/init.php");
if(!current_user_can('administrator') ) {
echo "Section réservée aux administrateurs du site uniquement. <a href='javascript:window.parent.location.href=\"/mcpv/index.php\"'>Revenir au site</a>";
exit();
}
?>
<script type="text/javascript">
$(document).ready(function() {
$('#btn-csv-prestataires').on('click',function() {
$('#popup').modal('show');
$.ajax({
type: 'post',
url: 'prestataire_csv.php',
data: null,
success: function(data) {
var bom = '\ufeff' + data; // Write BOM character sequence to fix UTF-8 in Excel
setTimeout(function() {
var link = document.getElementById("a-csv-download");
var csv = new Blob([bom], {type: 'text/csv'});
link.href = URL.createObjectURL(csv);
link.download = 'prestataires.csv';
$( "#btn-csv-download").click();
location.reload(true);
}, 3000);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
});
$('#btn-csv-avis').on('click',function() {
$('#popup').modal('show');
$.ajax({
type: 'post',
url: 'avis_csv.php',
data: null,
success: function(data) {
var bom = '\ufeff' + data; // Write BOM character sequence to fix UTF-8 in Excel
setTimeout(function() {
var link = document.getElementById("a-csv-download");
var csv = new Blob([bom], {type: 'text/csv'});
link.href = URL.createObjectURL(csv);
link.download = 'avis.csv';
$( "#btn-csv-download").click();
location.reload(true);
}, 3000);
$('#popup').modal('hide');
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
});
});
</script>
<title>Export données</title>
</head>
<body>
<h5 class="text-center my-5">Exporter données vers Excel</h5>
<div class="container-flex">
<div class="row">
<div class="col-4"></div>
<div class="col-2 text-center">
<button class="btn btn-sm btn-block btn-primary" id="btn-csv-prestataires" name="btn-csv-prestataires">
<i class="fa fa-user"></i><br /><span>Données prestataires</span></button>
</div>
<div class="col-2 text-center">
<button class="btn btn-sm btn-block btn-primary" id="btn-csv-avis" name="btn-csv-avis">
<i class="fa fa-thermometer"></i><br /><span>Avis prestataires</span></button>
</div>
<div class="col-4"></div>
</div>
</div>
<br/>
<!-- Page modale - Popup attente -->
<div class="modal fade" id="popup">
<div class="modal-dialog modal-dialog-centered modal-sm">
<div class="modal-content">
<div class="modal-header text-center">Exportation données</div>
<div id="modal-body" class="modal-body text-center">
Exportation en cours<br />
Veuillez patienter<br />
<p class="text-center">
<div class="spinner-border text-primary"></div>
</p>
</div>
<a href="javascript:void(0)" id="a-csv-download" style="display: none;">
<button class="btn btn-sm btn-primary" id="btn-csv-download"><i class="fa fa-download"></i>Télécharger</button>
</a>
</div>
</div>
</div>
</body>
</html>