77 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| class Class_gestionFiche
 | |
| {
 | |
|     private $pdo = null;
 | |
|     public $NB_LIGNES_PAGINATION = 12;
 | |
| 
 | |
|     public function __construct(PdoGsb $pDO)
 | |
|     {
 | |
|         $this->pdo = $pDO->getPdoGsb();
 | |
|     }
 | |
| 
 | |
|     public function getLesUtilisateurs(): array
 | |
|     {
 | |
|         $req = 'SELECT "uId", "uNom", "uPrenom" FROM utilisateur WHERE "uStatut"!=0 ORDER BY "uNom" ASC;';
 | |
|         $result = $this->pdo->prepare($req);
 | |
|         $result->execute();
 | |
| 
 | |
|         return $result->fetchAll();
 | |
|     }
 | |
| 
 | |
|     public function get_ListesFiches(string $idUtilisateur): array
 | |
|     {
 | |
|         $req = 'SELECT "rMois", "rEtat", "rNbJustificatifs", ROUND("rMontantValide", 2) as "rMontantValide", "eLibelle"
 | |
|         FROM remboursement
 | |
|         INNER JOIN etat ON etat."eId"=remboursement."rEtat"
 | |
|         WHERE "rVisiteur"= :userId
 | |
|         ORDER BY "rMois" DESC';
 | |
| 
 | |
|         $result = $this->pdo->prepare($req);
 | |
|         $result->bindParam("userId", $idUtilisateur);
 | |
|         $result->execute();
 | |
| 
 | |
|         return $result->fetchAll();
 | |
|     }
 | |
| 
 | |
|     public function dateComplete(string $date): string
 | |
|     {
 | |
|         return substr($date, 0, 4) . '-' . substr($date, 4);
 | |
|     }
 | |
| 
 | |
|     public function get_ficheAvalider(): array
 | |
|     {
 | |
|         $req = 'SELECT "rMois", "rVisiteur", "rEtat", ROUND("rMontantValide", 2) as "rMontantValide", "eLibelle", "uNom", "uPrenom"
 | |
|         from remboursement 
 | |
|         INNER JOIN utilisateur ON utilisateur."uId"=remboursement."rVisiteur"
 | |
|         INNER JOIN etat ON etat."eId"=remboursement."rEtat"
 | |
|         where "rEtat"=\'CL\'
 | |
|         ORDER BY "rMois" ASC';
 | |
|         $result = $this->pdo->prepare($req);
 | |
|         $result->execute();
 | |
| 
 | |
|         return $result->fetchAll();
 | |
|     }
 | |
| 
 | |
|     public function get_nbRemboursement(string $idUtilisateur): int
 | |
|     {
 | |
|         $req = 'SELECT COUNT(*) as "nbRemboursement" from remboursement WHERE "rVisiteur"= :userId;';
 | |
|         $result = $this->pdo->prepare($req);
 | |
|         $result->bindParam("userId", $idUtilisateur);
 | |
|         $result->execute();
 | |
|         $result = $result->fetch();
 | |
| 
 | |
|         return (int) $result['nbRemboursement'];
 | |
|     }
 | |
| 
 | |
|     public function get_nbPage(int $decalage): array
 | |
|     {
 | |
|         $req = 'SELECT * FROM remboursement ORDER BY "rDateModif" DESC LIMIT :nbLignes offset :decalage;';
 | |
|         $result = $this->pdo->prepare($req);
 | |
|         $result->bindParam('nbLigne', $this->NB_LIGNES_PAGINATION);
 | |
|         $result->bindParam('decalage', $decalage);
 | |
|         $result->execute();
 | |
| 
 | |
|         return $result->fetchAll(PDO::FETCH_ASSOC);
 | |
|     }
 | |
| } |