diff --git a/lib/Personne.php b/lib/Personne.php index 14a40d7..ab34dbf 100644 --- a/lib/Personne.php +++ b/lib/Personne.php @@ -10,8 +10,8 @@ class Personne public $id; public $nomPrenom; public $adresse; - public $ville; public $codePostal; + public $ville; public $courriel; public $versements; // tableau des versements totaux par activité/tarif @@ -19,32 +19,54 @@ class Personne $id, $nomPrenom, $adresse, - $ville, $codePostal, - $courriel + $ville, + $courriel = "" ) { $this->id = $id; $this->nomPrenom = $nomPrenom; $this->adresse = $adresse; - $this->ville = $ville; $this->codePostal = $codePostal; + $this->ville = $ville; $this->courriel = $courriel; $this->versements = array(); } - /* - * ajouter un versement pour une activité et un tarif donnés + /** + * return copie d'une personne + * @param $p + */ + public static function copier($p) + { + return new Personne( + $p->id, + $p->nomPrenom, + $p->adresse, + $p->codePostal, + $p->ville, + $p->courriel); + } + + + /** + * ajouter un versement + * @param $idActivite + * @param $idTarif + * @param $montant + * @param $tauxReduction */ public function ajouterVersement( $idActivite, $idTarif, - $montant + $montant, + $tauxReduction ) { $this->versements[] = new Versement( $idActivite, $idTarif, - $montant + $montant, + $tauxReduction ); } } diff --git a/lib/RecusPDF.php b/lib/RecusPDF.php index bc4d70e..9891cc2 100644 --- a/lib/RecusPDF.php +++ b/lib/RecusPDF.php @@ -135,8 +135,8 @@ class RecusPDF extends tFPDF $nom, $lesMontants, $adresse, - $ville, - $code_postal) + $code_postal, + $ville) { $this->AddPage(); @@ -164,9 +164,9 @@ class RecusPDF extends tFPDF "Le bénéficiaire reconnaît avoir reçu au titre des dons et versements ouvrant droit à réduction d'impôt :", 'LTR', 1); - foreach ($lesMontants as $montant) + foreach ($lesMontants as $taux => $montant) { - $this->imprimer_montant(" - la somme de ", $montant, "aide aux personnes en difficulté"); + $this->imprimer_montant(" - la somme de ", $montant, Utils::getLigneReduction($taux)); } $this->Cell(0, 3, "", 'LR', 1); $this->imprimer_description('Date des versements : ', diff --git a/lib/Utils.php b/lib/Utils.php index d392ac7..0d0bfb2 100644 --- a/lib/Utils.php +++ b/lib/Utils.php @@ -7,10 +7,161 @@ use KD2\ZipWriter; class Utils { + // ------------------------------------------------------------ + // test nouvelle organisation + /** + * @return tarifs demandés + * @param array $tarifs + */ + public static function getTarifs($tarifs) + { + $db = DB::getInstance(); + $sql = sprintf( + 'SELECT id, id_service as idActivite, label, description, amount as montant + FROM services_fees + WHERE services_fees.%s', + $db->where('id', $tarifs)); + return $db->get($sql); + } + + /** + * @return activités correspondant aux tarifs demandés + * @param array $tarifs + */ + public static function getActivites($tarifs) + { + $db = DB::getInstance(); + $sql = sprintf( + 'SELECT services.id, services.label, services.description + FROM services + LEFT JOIN services_fees ON services_fees.id_service = services.id + WHERE services_fees.%s + GROUP BY services.id', + $db->where('id', $tarifs)); + return $db->get($sql); + } + + /** + * @return versements correspondants à l'année et aux tarifs donnés + * @param $annee + * @param array $tarifs + */ + public static function getVersementsTarifs($annee, $tarifs) + { + $db = DB::getInstance(); + $sql = sprintf( + 'SELECT + services_fees.id as idTarif, + 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 services_fees on services_users.id_fee = services_fees.id + INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id + WHERE + (strftime(%s, acc_transactions.date) = "%d" + AND + services_fees.%s + AND + acc_transactions_lines.credit > 0) + ORDER by services_fees.id, membres.nom, acc_transactions.date', + '"%Y"', + $annee, + $db->where('id', $tarifs)); + return $db->get($sql); + } + + /** + * Versements totaux par personne pour une année donnée + * @param année + */ + public static function getVersementsTotaux($annee) + { + $sql = + "SELECT + membres.id as idUser, + sum(acc_transactions_lines.credit) AS versement + FROM + acc_transactions_users, + membres, + acc_transactions + INNER JOIN acc_transactions_lines + ON acc_transactions_lines.id_transaction = acc_transactions.id + WHERE ( + strftime('%Y', acc_transactions.date) = ? + AND + acc_transactions_lines.credit > 0 + AND + acc_transactions_users.id_transaction = acc_transactions.id + AND + acc_transactions_users.id_user = membres.id + ) + GROUP by acc_transactions_users.id_user + ORDER by membres.nom COLLATE U_NOCASE; + "; + return DB::getInstance()->get($sql, $annee); + } + + /** + * @return personnes ayant versé des dons pour une année donnée + * @param $annee + */ + public static function getDonateurs($annee) + { + $sql = + "SELECT + membres.id as idUser, + membres.nom as nom, + membres.adresse as adresse, + membres.code_postal as codePostal, + membres.ville as ville + FROM + acc_transactions_users, + membres, + acc_transactions + INNER JOIN acc_transactions_lines + ON acc_transactions_lines.id_transaction = acc_transactions.id + WHERE ( + strftime('%Y', acc_transactions.date) = ? + AND + acc_transactions_lines.credit > 0 + AND + acc_transactions_users.id_transaction = acc_transactions.id + AND + acc_transactions_users.id_user = membres.id + ) + GROUP by membres.id + ORDER by membres.nom COLLATE U_NOCASE; + "; + return DB::getInstance()->get($sql, $annee); + } + + public static function getLignesReduction($lesTaux) + { + foreach ($lesTaux as $elem) + { + $ligne = "taux " . $elem->taux . ", ligne " . $elem->ligne; + if ($elem->remarque != "") { + $ligne .= ", " . $elem->remarque; + } + $lignes[$elem->taux] = $ligne; + } + return $lignes; + } + public static function getLigneReduction($taux) + { + return $_SESSION['ligneReduction'][$taux]; + } + + // ------------------------------------------------------------ + /** * @return liste des activités */ - public static function getActivites() + public static function getToutesActivites() { return DB::getInstance()->get( "SELECT @@ -26,7 +177,7 @@ class Utils * @return liste des tarifs d'une activité * @param $activite : identifiant de l'activité */ - public static function getTarifs($activite) + public static function getTarifsActivite($activite) { return DB::getInstance()->get( "SELECT @@ -163,10 +314,10 @@ class Utils } /** - * liste du total de versements par personne pour une année donnée + * Versements totaux par personne pour une année donnée * @param année */ - public static function getVersementsTotaux($annee) { + public static function getVersementsTotaux_old($annee) { $sql = "SELECT acc_transactions_users.id_user as idUser, @@ -191,7 +342,7 @@ class Utils acc_transactions_users.id_user = membres.id ) GROUP by acc_transactions_users.id_user - ORDER by membres.nom COLLATE NOCASE; + ORDER by membres.nom COLLATE U_NOCASE; "; return DB::getInstance()->get($sql, $annee); } @@ -239,7 +390,7 @@ class Utils * @param tableau des versements par personne */ static function genererRecus() { - + } /** diff --git a/lib/Versement.php b/lib/Versement.php index c5d0145..3ac3f07 100644 --- a/lib/Versement.php +++ b/lib/Versement.php @@ -7,14 +7,18 @@ class Versement public $idActivite; public $idTarif; public $montant; + public $tauxReduction; public function __construct( $idActivite, $idTarif, - $montant - ) { + $montant, + $tauxReduction + ) + { $this->idActivite = $idActivite; $this->idTarif = $idTarif; $this->montant = $montant; + $this->tauxReduction = $tauxReduction; } } diff --git a/templates/index.tpl b/templates/index.tpl index 77c1c06..92a8be0 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -2,7 +2,7 @@ {include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="index"}

Choisir l'année fiscale

-
+
{* Choisir l'année fiscale *} + + + {/foreach} +
+ +
@@ -107,7 +120,7 @@ {literal}