public static function getCoutOfUser($bdd) { $allUser = User::getAllUser($bdd); $couts = []; foreach ($allUser as $user) { $userNotes = Note::getNotesByUser($bdd, $user['id']); $uDevise = Devise::getDeviseById($bdd, $user['devise_id']); $totalNote = 0; foreach ($userNotes as $note) { $totalNote += Note::getMontantTotal($bdd, $note['id'], $uDevise->getTaux()); } $couts[] = ["username" => $user['login'], "total" => $totalNote]; } usort($couts, function ($a, $b) { if ($a['total'] == $b['total']) { return 0; } return $a['total'] < $b['total'] ? 1 : -1; }); return array_slice($couts, 0, 10); }
public function getNotes($bdd) { $note = new Note(); return $note->getNotesByUser($bdd, $this->id); }
//Statistiques //Statistiques case "statistique": include_once '/views/admin/statistique.php'; break; //Gestion des notes //Gestion des notes case "note": //on retourne la liste des notes en fonction du role de l'utilisateur if ($secu->isAdmin($bdd)) { $notes = Note::getAllNotes($bdd); } else { $listUser = User::getUsersByManagerId($bdd, $sessionUser->getId()); $notes = []; foreach ($listUser as $user) { $listNote = Note::getNotesByUser($bdd, $user["id"]); $notes = array_merge($notes, $listNote); } } $fraisNote = new Note(); $statut = new Statut(); $listStatut = $statut->getAll($bdd); $noteStatut = new Statut(); include_once '/views/admin/note.php'; break; //par defaut on a les statistiques //par defaut on a les statistiques default: include_once '/views/admin/index.php'; break; }
<input class = "formulaire formulairePrixTTC form-control champ-form" type="text" name="montant" placeholder="HT" value="<?php if(isset($_POST[$montan]) && !empty($_POST[$montan])){echo filter_input(INPUT_POST, $montan); } ?>"/> <select class = "formulaire formulairePrix form-control champ-form" name="devise_id"> <?php $reponseDevise = Devise::getAllDevise($bdd); while($donnee = $reponseDevise->fetch()) { ?> <option value="<?php echo $donnee['id'];?>" <?php if($sessionUser->getDevise() == $donnee['id']){echo "selected='selected'"; } ?>><?php echo $donnee['name'];?></option> <?php } ?> </select> </div> <select class = "formulaire deroulantFrais form-control champ-form deroulantId" name="note_id"> <?php $uid = $sessionUser->getId(); foreach ( (Note::getNotesByUser($bdd, $uid)) as $donnee ) { if ( 1 != $donnee['statut_id'] ) { continue; } ?> <option value="<?php echo $donnee['id'];?>" <?php if(isset($_POST[$noteid]) && !empty($_POST[$noteid]) && filter_input(INPUT_POST, $noteid) == $donnee['id']) {echo "selected.='selected'";} ?>><?php echo $donnee['name'];?></option> <?php } ?> </select> <select class = "formulaire deroulantFrais form-control champ-form deroulantId" name="categorie_id"> <?php $reponseCategorie = CategorieFrais::getAllCategorie($bdd); while($donnee = $reponseCategorie->fetch()) { ?> <option value ="<?php echo $donnee['id'];?>" <?php if(isset($_POST[$categori]) && !empty($_POST[$categori]) && filter_input(INPUT_POST, $categori) == $donnee['id']){echo "selected='selected'"; } ?>><?php echo $donnee['name'];?></option> <?php