Skip to content

Commit

Permalink
Tri du résultat du merge des tables history et historyArch
Browse files Browse the repository at this point in the history
Ajout du tri par le datetime lors du merge des tables history et historyArch principalement pour l'affichage de graphique highcharts où les données doivent etre dans l'ordre chronologique.
  • Loading branch information
jpty committed May 22, 2020
1 parent 5c94c43 commit 7da6d6c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/class/history.class.php
Expand Up @@ -333,8 +333,15 @@ public static function all($_cmd_id, $_startTime = null, $_endTime = null,$_grou
$sql .= ' ORDER BY `datetime` ASC';
$result2 = DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, 'historyArch');

return array_merge($result2, $result1);
$result = array_merge($result2, $result1);
uasort($result, array('self','cmpHistory'));
return $result;
// return array_merge($result2, $result1);
}
// Fonction de comparaison des historiques par leur datetime
function cmpHistory($a, $b) {
return strcmp($a->datetime,$b->datetime);
}

public static function removes($_cmd_id, $_startTime = null, $_endTime = null) {
$values = array(
Expand Down Expand Up @@ -993,4 +1000,4 @@ public function setChanged($_changed) {
}

}


0 comments on commit 7da6d6c

Please sign in to comment.