1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| <div id="statistiquesclients" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<div class="row">
<div class="form-group col-md-4 col-md-offset-4">
<select id="client_stat1" class="form-control mx-sm-3 mb-2" onchange="statclient_1(this.value)">
<?php
$client = $bdd->prepare('SELECT DISTINCT client_societe, client_id, client_ville
FROM client
WHERE client_contact = :client_contact
ORDER BY client_societe ASC');
$client->execute([
':client_contact' => $_SESSION['Contact_id']
]);
echo "<option></option>";
while ($data = $client->fetch(PDO::FETCH_ASSOC)) {
echo "<option value=\"{$data['client_id']}\">
{$data['client_societe']} | {$data['client_ville']}
</option>";
}
$client->closeCursor();
?>
</select>
</div><br />
</div>
<?php
$req1 = "SELECT SUM(facture_montant) as count FROM facture WHERE UPPER(facture_client) = :statclient1 GROUP BY MONTH(facture_date) ORDER BY facture_date";
$stat = $bdd->prepare($req1);
$stat->bindValue('statclient1',strtoupper(trim($_POST['statclient1'])),PDO::PARAM_STR);
$stat->execute();
$sum = $stat->fetchAll(PDO::FETCH_ASSOC);
$sum = json_encode(array_column($sum, 'count'),JSON_NUMERIC_CHECK);
$req2 = "SELECT DATE_FORMAT(facture_date, '%Y-%m') as count FROM facture WHERE UPPER(facture_client) = :statclient1 GROUP BY MONTH(facture_date) ORDER BY facture_date";
$stat2 = $bdd->prepare($req2);
$stat2->bindValue('statclient1',strtoupper(trim($_POST['statclient1'])),PDO::PARAM_STR);
$stat2->execute();
$date = $stat2->fetchAll(PDO::FETCH_ASSOC);
$date = json_encode(array_column($date, 'count'),JSON_NUMERIC_CHECK); ?>
<div id="client_stat1_request"></div>
<div id="statclient"></div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary btn-lg" data-dismiss="modal" style="margin-right:45%; margin-left:45%;">Fermer</button>
</div>
</div>
</div>
</div>
<script>
function statclient_1(statclient1) {
$.ajax({
method: "POST",
url: "modal_header/Editions/statistiquesclients.php",
data: { statclient1 : statclient1 }
})
.done(function( retour_html ) {
$("#client_stat1_request").html( retour_html );
})
.fail(function() {
alert( "error statclient_1()" );
});
}
$(function () {
var data_sum = <?php echo $sum; ?>;
var data_date = <?php echo $date; ?>;
$('#statclient').highcharts({
rangeSelector: {
selected: 1
},
title: {
text: 'Résultat de votre client Le Corse'
},
subtitle: {
text: 'contact.fr'
},
xAxis: {
categories : data_date
},
yAxis: {
title: {
text: 'Chiffre d\'affaire'
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
series: [{
type: 'column',
name: 'Resultat',
data: data_sum
}]
})
});
</script> |
Partager