executerRequete($sql, array($_SESSION['codeSociete'],$codeMoyenPaiement,$libelle)); return $moyenpaiements; } public function getMoyenpaiement($id) { $sql = 'SELECT * FROM moyenpaiement A WHERE (A.codeSociete=?) AND (A.id=?)'; $moyenpaiement = $this->executerRequete($sql, array($_SESSION['codeSociete'], $id)); if ($moyenpaiement->rowCount() > 0) return $moyenpaiement->fetch(); else throw new Exception("Aucun moyen de paiement ne correspond à cet id : '$id'"); } public function ajouter($codeSociete, $codeMoyenPaiement, $libelle, $codeTypePaiement, $numeroCompte) { $sql = 'INSERT INTO moyenpaiement (codeSociete, codeMoyenPaiement, libelle, codeTypePaiement, numeroCompte) VALUES (?, ?, ?, ?, ?)'; $this->executerRequete($sql, array($codeSociete, $codeMoyenPaiement, $libelle, $codeTypePaiement, $numeroCompte)); } public function modifier($id, $codeSociete, $codeMoyenPaiement, $libelle, $codeTypePaiement, $numeroCompte) { $sql = 'UPDATE moyenpaiement SET ccodeMoyenPaiement=?, libelle=?, codeTypePaiement=?, numeroCompte=? where (id=?)'; $this->executerRequete($sql, array($codeSociete, $codeMoyenPaiement, $libelle, $codeTypePaiement, $numeroCompte, $id)); } public function supprimer($id) { $sql = 'DELETE FROM moyenpaiement WHERE (id=?)'; $this->executerRequete($sql, array($id)); } public function existeligne($codeMoyenPaiement) { $sql = 'select id FROM moyenpaiement WHERE (codeSociete=?) and (codeMoyenPaiement=?)'; $resultat = $this->executerRequete($sql, array($_SESSION['codeSociete'],$codeMoyenPaiement)); return ($resultat->rowCount() > 0); } public function getListe($codeModePaiement) { $sql = 'SELECT codeMoyenPaiement AS code, moyenpaiement AS libelle FROM vw_moyenpaiement WHERE (codeSociete=?) AND (codeModePaiement=?) ORDER BY 2'; $liste = $this->executerRequete($sql, array($_SESSION['codeSociete'], $codeModePaiement)); return $liste->fetchAll(PDO::FETCH_ASSOC); } public function getNumeroCompte($codeModePaiement, $codeMoyenPaiement) { $sql = 'SELECT numeroCompte FROM vw_moyenpaiement WHERE (codeSociete=?) AND (codeModePaiement=?) AND (codeMoyenPaiement=?)'; $resultat = $this->executerRequete($sql, array($_SESSION['codeSociete'], $codeModePaiement, $codeMoyenPaiement)); $ligne = $resultat->fetch(); return $ligne['numeroCompte']; /* if($resultat->rowCount() > 0) { $ligne = $resultat->fetch(); return $ligne['numeroCompte']; } else { return ""; } */ } }