bonjours a tous.
en fait je suis sur un site qui doit nous donner le taux d'occupation d'un technicien.
voici mon code qui marche nickel. cependant je doit renseigner les dates avant que canvas me donne les résultats voulu sur une periode et moi je veux que cela se fasse sur une date min(par exemple la date la plus ancienne de ma base de donnée ) a aujourd'hui. S'il vous plait aider moi. voici mon code:
<?php
$req = $DB->query("SELECT COUNT(idTech) as nbrTech FROM technicien ");
while ( $data = $req->fetch(PDO::FETCH_OBJ)) {
$nbrTechn=$data->nbrTech;
}
$req = $DB->query("SELECT COUNT(idClt) as nbrClt FROM client ");
while ( $data = $req->fetch(PDO::FETCH_OBJ)) {
$nbrClient=$data->nbrClt;
}
$req = $DB->query("SELECT COUNT(idListe) as nbrSpe FROM listespec ");
while ( $data = $req->fetch(PDO::FETCH_OBJ)) {
$nbrSpec=$data->nbrSpe;
}
?>
<div class="row"><br/>
<div class="col-lg-4 col-md-4">
<!-- small box -->
<div class="small-box bg-info">
<div class="inner">
<h3><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"><?php echo $nbrTechn; ?></font></font></h3>
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Techniciens</font></font></p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
<a href="?page=techn" class="small-box-footer"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Plus d'informations </font></font><i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<!-- ./col -->
<div class="col-lg-4 col-md-4">
<!-- small box -->
<div class="small-box bg-warning">
<div class="inner">
<h3><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"><?php echo $nbrClient; ?></font></font></h3>
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Clients</font></font></p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="?page=clie" class="small-box-footer"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Plus d'informations </font></font><i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-4 col-md-4">
<!-- small box -->
<div class="small-box bg-danger">
<div class="inner">
<h3><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"><?php echo $nbrSpec; ?></font></font></h3>
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Specialites</font></font></p>
</div>
<div class="icon">
<i class="ion ion-pie-graph"></i>
</div>
<a href="?page=speciali" class="small-box-footer"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Plus d'informations </font></font><i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
</div>
<!--diagramme-->
<?php
if (isset($_POST['date1'])){
include('etats/table.php');
}
?>
<form method="post" name="formMat" id="formMat" onsubmit="">
<div class="">
<div class="form-group col-md-1">
<label>De</label>
</div>
<div class="form-group col-md-3">
<input name="date1" type="date" class="form-control" id="exampleInputPassword1" placeholder="" required="required" value="">
</div>
<div class="form-group col-md-1">
<label>à</label>
</div>
<div class="form-group col-md-3">
<input name="date2" type="date" class="form-control" id="exampleInputPassword1" placeholder="" required="required" value="">
</div>
<div>
<button class="button" id="search"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
<div class="row">
<script src="js/canvasjs.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
</div>
<div class="row">
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Statistiques: Taux d'occupation des techniciens"
},
data: [
{
// Change type to "doughnut", "line", "splineArea", etc.
type: "column",
dataPoints: [
<?php
$req = $DB->query("SELECT *,SEC_TO_TIME(SUM(TIME_TO_SEC(heureFinInterv)-TIME_TO_SEC(heureDebInterv))) as hh, SUM(TIME_TO_SEC(heureFinInterv)-TIME_TO_SEC(heureDebInterv)) as hs FROM intervention a, client b, technicien c WHERE b.idClt=a.idClt AND c.idTech=a.idTech AND dateInterv BETWEEN '".$_POST['date1']."' AND '".$_POST['date2']."' group by NomTech order by NomTech");$i=0;
while ( $data=$req->fetch(PDO::FETCH_OBJ)){
$h=$data->hh;
$hst=$data->hs;
$ht=$hst/3600;
$taux=round(($ht*100)/$Htotal,2);
?>
{ label: "<?php echo $data->NomTech; ?>", y: <?php echo $taux; ?> },
<?php } ?>
]
}
]
});
chart.render();
}
</script>
</div>
<div id="chartContainer" style="height: 400px; width: 100%;">
en fait je suis sur un site qui doit nous donner le taux d'occupation d'un technicien.
voici mon code qui marche nickel. cependant je doit renseigner les dates avant que canvas me donne les résultats voulu sur une periode et moi je veux que cela se fasse sur une date min(par exemple la date la plus ancienne de ma base de donnée ) a aujourd'hui. S'il vous plait aider moi. voici mon code:
<?php
$req = $DB->query("SELECT COUNT(idTech) as nbrTech FROM technicien ");
while ( $data = $req->fetch(PDO::FETCH_OBJ)) {
$nbrTechn=$data->nbrTech;
}
$req = $DB->query("SELECT COUNT(idClt) as nbrClt FROM client ");
while ( $data = $req->fetch(PDO::FETCH_OBJ)) {
$nbrClient=$data->nbrClt;
}
$req = $DB->query("SELECT COUNT(idListe) as nbrSpe FROM listespec ");
while ( $data = $req->fetch(PDO::FETCH_OBJ)) {
$nbrSpec=$data->nbrSpe;
}
?>
<div class="row"><br/>
<div class="col-lg-4 col-md-4">
<!-- small box -->
<div class="small-box bg-info">
<div class="inner">
<h3><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"><?php echo $nbrTechn; ?></font></font></h3>
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Techniciens</font></font></p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
<a href="?page=techn" class="small-box-footer"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Plus d'informations </font></font><i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<!-- ./col -->
<div class="col-lg-4 col-md-4">
<!-- small box -->
<div class="small-box bg-warning">
<div class="inner">
<h3><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"><?php echo $nbrClient; ?></font></font></h3>
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Clients</font></font></p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="?page=clie" class="small-box-footer"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Plus d'informations </font></font><i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-4 col-md-4">
<!-- small box -->
<div class="small-box bg-danger">
<div class="inner">
<h3><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"><?php echo $nbrSpec; ?></font></font></h3>
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Specialites</font></font></p>
</div>
<div class="icon">
<i class="ion ion-pie-graph"></i>
</div>
<a href="?page=speciali" class="small-box-footer"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Plus d'informations </font></font><i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
</div>
<!--diagramme-->
<?php
if (isset($_POST['date1'])){
include('etats/table.php');
}
?>
<form method="post" name="formMat" id="formMat" onsubmit="">
<div class="">
<div class="form-group col-md-1">
<label>De</label>
</div>
<div class="form-group col-md-3">
<input name="date1" type="date" class="form-control" id="exampleInputPassword1" placeholder="" required="required" value="">
</div>
<div class="form-group col-md-1">
<label>à</label>
</div>
<div class="form-group col-md-3">
<input name="date2" type="date" class="form-control" id="exampleInputPassword1" placeholder="" required="required" value="">
</div>
<div>
<button class="button" id="search"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
<div class="row">
<script src="js/canvasjs.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
</div>
<div class="row">
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Statistiques: Taux d'occupation des techniciens"
},
data: [
{
// Change type to "doughnut", "line", "splineArea", etc.
type: "column",
dataPoints: [
<?php
$req = $DB->query("SELECT *,SEC_TO_TIME(SUM(TIME_TO_SEC(heureFinInterv)-TIME_TO_SEC(heureDebInterv))) as hh, SUM(TIME_TO_SEC(heureFinInterv)-TIME_TO_SEC(heureDebInterv)) as hs FROM intervention a, client b, technicien c WHERE b.idClt=a.idClt AND c.idTech=a.idTech AND dateInterv BETWEEN '".$_POST['date1']."' AND '".$_POST['date2']."' group by NomTech order by NomTech");$i=0;
while ( $data=$req->fetch(PDO::FETCH_OBJ)){
$h=$data->hh;
$hst=$data->hs;
$ht=$hst/3600;
$taux=round(($ht*100)/$Htotal,2);
?>
{ label: "<?php echo $data->NomTech; ?>", y: <?php echo $taux; ?> },
<?php } ?>
]
}
]
});
chart.render();
}
</script>
</div>
<div id="chartContainer" style="height: 400px; width: 100%;">