diff --git a/lib/Personne.php b/lib/Personne.php index 118aca1..2f695f6 100644 --- a/lib/Personne.php +++ b/lib/Personne.php @@ -35,7 +35,6 @@ class Personne /** * return copie d'une personne - */ public function clone() { return new Personne( @@ -46,6 +45,7 @@ class Personne $this->ville, $this->courriel); } + */ /** * ajouter un versement diff --git a/lib/Utils.php b/lib/Utils.php index f6bed5b..e29e92a 100644 --- a/lib/Utils.php +++ b/lib/Utils.php @@ -39,6 +39,37 @@ class Utils return $db->get($sql); } + /** + * @return versements correspondants à l'année donnée + * @param $annee + * @param array $champsNom : liste non vide des champs de nom/prénom + */ + public static function getVersementsPersonnes($annee, $champsNom) + { + $db = DB::getInstance(); + $tri = Utils::combinerTri($champsNom); + $sql = sprintf( + 'SELECT + membres.id as idUser, + acc_transactions_lines.credit as versement, + acc_transactions.date + FROM acc_transactions_users + INNER JOIN membres on acc_transactions_users.id_user = membres.id + INNER JOIN acc_transactions on acc_transactions_users.id_transaction = acc_transactions.id + INNER JOIN services_users on acc_transactions_users.id_service_user = services_users.id + INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id + WHERE + (strftime(%s, acc_transactions.date) = "%d" + AND + acc_transactions_lines.credit > 0) + ORDER by %s, acc_transactions.date', + '"%Y"', + $annee, + $tri + ); + return $db->get($sql); + } + /** * @return versements correspondants à l'année et aux tarifs donnés * @param $annee @@ -76,6 +107,42 @@ class Utils return $db->get($sql); } + /** + * @return versements correspondants à l'année et aux comptes donnés + * @param $annee + * @param array $comptes + * @param array $champsNom : liste non vide des champs de nom/prénom + */ + public static function getVersementsComptes($annee, $comptes, $champsNom) + { + $db = DB::getInstance(); + $tri = Utils::combinerTri($champsNom); + $sql = sprintf( + 'SELECT + acc_accounts.code as compte, + membres.id as idUser, + acc_transactions_lines.credit as versement, + acc_transactions.date + FROM acc_transactions_users + INNER JOIN membres on acc_transactions_users.id_user = membres.id + INNER JOIN acc_transactions on acc_transactions_users.id_transaction = acc_transactions.id + INNER JOIN services_users on acc_transactions_users.id_service_user = services_users.id + INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id + WHERE + (strftime(%s, acc_transactions.date) = "%d" + AND + acc_accounts.%s + AND + acc_transactions_lines.credit > 0) + ORDER by acc_accounts.code, %s, acc_transactions.date', + '"%Y"', + $annee, + $db->where('code', $comptes), + $tri + ); + return $db->get($sql); + } + /** * Versements totaux par personne pour une année donnée * @param année diff --git a/templates/_nav.tpl b/templates/_nav.tpl index 6ab82c4..140e031 100644 --- a/templates/_nav.tpl +++ b/templates/_nav.tpl @@ -5,7 +5,7 @@