1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * Associaspip, extension de SPIP pour gestion d'associations * |
---|
4 | * * |
---|
5 | * Copyright (c) 2007 Bernard Blazin & François de Montlivault (V1) * |
---|
6 | * Copyright (c) 2010-2011 Emmanuel Saint-James & Jeannot Lapin (V2) * |
---|
7 | * * |
---|
8 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
---|
9 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
---|
10 | \***************************************************************************/ |
---|
11 | |
---|
12 | |
---|
13 | if (!defined('_ECRIRE_INC_VERSION')) |
---|
14 | return; |
---|
15 | |
---|
16 | include_spip ('inc/navigation_modules'); |
---|
17 | include_spip('inc/association_comptabilite'); |
---|
18 | |
---|
19 | function exec_dons() |
---|
20 | { |
---|
21 | if (!autoriser('associer', 'dons')) { |
---|
22 | include_spip('inc/minipres'); |
---|
23 | echo minipres(); |
---|
24 | } else { |
---|
25 | $annee = intval(_request('annee')); |
---|
26 | if(!$annee){ |
---|
27 | $annee = date('Y'); |
---|
28 | } |
---|
29 | onglets_association('titre_onglet_dons'); |
---|
30 | // INTRO : nom du module et annee affichee |
---|
31 | echo totauxinfos_intro('','dons',$annee); |
---|
32 | // TOTAUX : nombre de dons selon leur nature |
---|
33 | $liste_libelles = array('pair'=>'dons_financier', 'prospect'=>'dons_en_nature', 'impair'=>'autres'); |
---|
34 | $liste_effectifs['pair'] = sql_countsel('spip_asso_dons', "argent<>0 AND colis='' AND DATE_FORMAT(date_don, '%Y')='$annee' "); |
---|
35 | $liste_effectifs['prospect'] = sql_countsel('spip_asso_dons', "argent=0 AND colis<>'' AND DATE_FORMAT(date_don, '%Y')='$annee' "); |
---|
36 | $liste_effectifs['impair'] = sql_countsel('spip_asso_dons', "DATE_FORMAT(date_don, '%Y')='$annee' ")-$liste_effectifs['pair']-$liste_effectifs['prospect']; |
---|
37 | echo totauxinfos_effectifs('dons', $liste_libelles, $liste_effectifs); |
---|
38 | // STATS sur les donnations de l'annee |
---|
39 | echo totauxinfos_stats('donnations', 'dons', array('dons_financier'=>'argent','don_en_nature'=>'valeur',), "DATE_FORMAT(date_don, '%Y')='$annee' "); |
---|
40 | // TOTAUX : montants des dons et remboursements financiers |
---|
41 | $dons_financiers = sql_getfetsel('SUM(argent) AS somme_recettes', 'spip_asso_dons', "argent AND DATE_FORMAT(date_don, '%Y')=$annee" ); |
---|
42 | $remboursements = sql_getfetsel('SUM(argent) AS somme_reversees', 'spip_asso_dons', "argent AND contrepartie AND DATE_FORMAT(date_don, '%Y')=$annee" ); |
---|
43 | echo totauxinfos_montants($annee, $dons_financiers, $remboursements); |
---|
44 | // datation et raccourcis |
---|
45 | icones_association(array(), array( |
---|
46 | 'ajouter_un_don' => array('ajout-24.png', 'edit_don'), |
---|
47 | )); |
---|
48 | debut_cadre_association('dons-24.gif', 'tous_les_dons'); |
---|
49 | // Filtres |
---|
50 | echo '<table width="100%" class="asso_tablo_filtre"><tr>'; |
---|
51 | echo '<td>'. association_selectionner_annee($annee, 'dons', 'don','dons') .'</td>'; |
---|
52 | echo '</tr></table>'; |
---|
53 | //TABLEAU |
---|
54 | echo "<table width='100%' class='asso_tablo' id='asso_tablo_dons'>\n"; |
---|
55 | echo "<thead>\n<tr>"; |
---|
56 | echo '<th>'. _T('asso:entete_id') .'</th>'; |
---|
57 | echo '<th>'. _T('asso:entete_date') .'</th>'; |
---|
58 | echo '<th>'. _T('asso:entete_nom') .'</th>'; |
---|
59 | echo '<th>'. _T('asso:argent') .'</th>'; |
---|
60 | echo '<th>'. _T('asso:colis') .'</th>'; |
---|
61 | echo '<th> </th>'; |
---|
62 | echo '<th colspan="2" class="actions">' . _T('asso:entete_actions') .'</th>'; |
---|
63 | echo "</tr>\n</thead><tbody>"; |
---|
64 | $association_imputation = charger_fonction('association_imputation', 'inc'); |
---|
65 | $critere1 = $association_imputation('pc_dons', 'a_c'); |
---|
66 | if ($critere1) |
---|
67 | $critere1 .= ' AND '; |
---|
68 | $critere2 = $association_imputation('pc_colis', 'a_c'); |
---|
69 | if ($critere2) |
---|
70 | $critere2 .= ($critere1?' OR ':' AND '); |
---|
71 | $query = sql_select('DISTINCT a_d.*', 'spip_asso_dons AS a_d LEFT JOIN spip_asso_comptes AS a_c ON a_c.id_journal=a_d.id_don', "$critere2$critere1 DATE_FORMAT(date_don, '%Y')=$annee", '', 'id_don' ) ; |
---|
72 | while ($data = sql_fetch($query)) { |
---|
73 | $id_don = $data['id_don']; |
---|
74 | echo '<tr class="'.(($data['argent'] && !$data['colis'])?'pair':(($data['argent'] && !$data['colis'])?'prospect':'impair')).'" id="'.$data['id_don'].'">'; |
---|
75 | echo '<td class="integer">'.$id_don.'</td>'; |
---|
76 | echo '<td class="date">'. association_datefr($data['date_don']) .'</td>'; |
---|
77 | echo '<td class="text">'. association_calculer_lien_nomid($data['bienfaiteur'],$data['id_adherent']) .'</td>'; |
---|
78 | echo '<td class="decimal">'. association_prixfr($data['argent']) .'</td>'; |
---|
79 | echo '<td class="text" colspan="'.($data['vu']?2:1).'">' |
---|
80 | .($data['vu'] ? '' :'<i>'._T('asso:valeur').': '.association_prixfr($data['valeur']).'</i><br />') |
---|
81 | .$data['colis'].'</td>'; |
---|
82 | echo ($data['vu'] |
---|
83 | ? ('<td class="text"> </td>') |
---|
84 | : ('<td class="text">'. propre($data['contrepartie']) .'</td>') |
---|
85 | ); |
---|
86 | echo '<td class="action">'. association_bouton('supprimer_le_don', 'suppr-12.gif', 'action_dons', "id=$id_don") .'</td>'; |
---|
87 | echo '<td class="action">' . association_bouton('mettre_a_jour_le_don', 'edit-12.gif', 'edit_don', "id=$id_don") .'</td>';; |
---|
88 | echo "</tr>\n"; |
---|
89 | } |
---|
90 | echo "</tbody>\n</table>\n"; |
---|
91 | fin_page_association(); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | ?> |
---|