Changeset 60667 in spip-zone
- Timestamp:
- Apr 26, 2012, 2:10:47 AM (9 years ago)
- Location:
- _plugins_/Association/Associaspip
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/Association/Associaspip/association_options.php
r60425 r60667 501 501 } 502 502 503 /* selecteur d'exercice comptable */ 504 function association_selectionner_exercice($exercice='', $url_action='') { 505 if ($url_action) { 506 $res = '<form method="get" action="'.$url_action.'"><div>'; 507 } else { 508 $res = ''; 509 } 510 $res .= '<select name ="exercice" onchange="form.submit()">'; 511 $res .= '<option value="0" '; 512 if (!$exercice) { 513 $res .= ' selected="selected"'; 514 } 515 $res .= '>'. _L("choisir l'exercice ?") .'</option>'; 516 $sql = sql_select('id_exercice, intitule', 'spip_asso_exercices','', 'intitule DESC'); 517 while ($val = sql_fetch($sql)) { 518 $res .= '<option value="'.$val['id_exercice'].'" '; 519 if ($exercice==$val['id_exercice']) { 520 $res .= ' selected="selected"'; 521 } 522 $res .= '>'.$val['intitule'].'</option>'; 523 } 524 $res .= '</select><noscript><input type="submit" value="'._T('asso:bouton_lister').'" /></noscript>'; 525 if ($url_action) { 526 $res .= '</div></form>'; 527 } 528 return $res; 529 } 530 531 /* selecteur d'exercice comptable */ 532 function association_selectionner_destination($destination='', $url_action='') { 533 if ($url_action) { 534 $res = '<form method="get" action="'.$url_action.'"><div>'; 535 } else { 536 $res = ''; 537 } 538 // $res .= '<select name ="destination[]" multiple="multiple" onchange="form.submit()">'; 539 $res .= '<select name ="destination" onchange="form.submit()">'; 540 $res .= '<option value="0" '; 541 // if ( !(array_search(0, $destinations)===FALSE) ) { 542 if (!$destination) { 543 $res .= ' selected="selected"'; 544 } 545 $res .= '>'. _T('asso:toutes_destinations') .'</option><option disabled="disabled">--------</option>'; 546 $intitule_destinations = array(); 547 $sql = sql_select('id_destination, intitule', 'spip_asso_destination','', 'intitule DESC'); 548 while ($val = sql_fetch($sql)) { 549 $res .= '<option value="'.$val['id_destination'].'" '; 550 // if (!(array_search($val['id_destination'], $destinations)===FALSE)) { 551 if ($destination==$val['id_destination']) { 552 $res .= ' selected="selected"'; 553 } 554 $res .= '>'.$val['intitule'].'</option>'; 555 $intitule_destinations[$val['id_destination']] = $val['intitule']; 556 } 557 $res .= '</select><noscript><input type="submit" value="'._T('asso:bouton_lister').'" /></noscript>'; 558 if ($url_action) { 559 $res .= '</div></form>'; 560 } 561 if ($GLOBALS['association_metas']['destinations']){ 562 return $res; 563 } else { 564 return FALSE; 565 } 566 } 567 503 568 function encadre($texte,$avant='[',$apres=']') 504 569 { -
_plugins_/Association/Associaspip/exec/bilan.php
r60578 r60667 34 34 if (!($ids_destination_bilan = _request('destination'))) 35 35 $ids_destination_bilan = array(0); 36 include_spip('inc/association_comptabilite'); 36 37 onglets_association('titre_onglet_comptes'); 37 38 // INTRO : rappel de l'exercicee affichee … … 77 78 $join = $sel = $where = $having = $order = ''; 78 79 } 80 $classes = array( 81 sql_quote($GLOBALS['association_metas']['classe_charges']), 82 sql_quote($GLOBALS['association_metas']['classe_produits']), 83 // sql_quote($GLOBALS['association_metas']['classe_contributions_volontaires']), 84 // sql_quote($GLOBALS['association_metas']['classe_banques']), 85 ); 79 86 // on boucle sur le tableau des destinations en refaisant le fetch a chaque iteration 80 87 foreach ($ids_destination_bilan as $id_destination) { … … 88 95 echo "\n<fieldset>"; 89 96 echo '<legend><strong>'. _T('asso:resultat_courant') . ' ' .$intitule_destination_bilan. '</strong></legend>'; 90 echo "<table width='100%' class='asso_tablo' id='asso_tablo_bilan_resultat'>\n"; 91 echo "<thead>\n<tr>"; 92 echo '<th colspan="2"> </th>'; 93 echo '<th width="50">'. _T('asso:bilan_recettes') .'</th>'; 94 echo '<th width="50">'. _T('asso:bilan_depenses') .'</th>'; 95 echo '<th width="50">'. _T('asso:bilan_solde').'</th>'; 96 echo "</tr>\n</thead><tbody>"; 97 if ($id_destination==0) { // on fait le bilan sur toutes les destinations (quand aucune de selectionnee ou que destination n'est pas on) 98 $query = sql_select( 99 "imputation, SUM(recette) AS recettes, SUM(depense) AS depenses $sel", 100 "spip_asso_comptes $join", 101 $where, $order, '', '', $having); 102 } else { // on fait le bilan d'une seule destination 103 $query = sql_select( 104 "imputation, 105 SUM(spip_asso_destination_op.recette) AS recettes, 106 SUM(spip_asso_destination_op.depense) AS depenses, 107 spip_asso_destination_op.id_destination $sel", 108 "spip_asso_comptes LEFT JOIN spip_asso_destination_op ON spip_asso_destination_op.id_compte=spip_asso_comptes.id_compte $join", 109 "spip_asso_destination_op.id_destination=$id_destination AND $where", 110 $order, '', '', $having); 111 } 112 while ($data = sql_fetch($query)) { 113 $recettes = $data['recettes']; 114 $depenses = $data['depenses']; 115 $solde = $recettes-$depenses; 116 echo '<tr>'; 117 echo '<td class="text">'. $data['code'] . '</td>'; 118 echo '<td class="text">'. $data['intitule'] .'</td>'; 119 echo '<td class="decimal">'.association_prixfr($recettes).'</td>'; 120 echo '<td class="decimal">'.association_prixfr($depenses).'</td>'; 121 echo '<td class="decimal">'.association_prixfr($solde).'</td>'; 122 echo "</tr>\n"; 123 $total_recettes += $recettes; 124 $total_depenses += $depenses; 125 $total_soldes += $solde; 126 } 127 echo "</tbody><tfoot>\n<tr>"; 128 echo '<th colspan="2">'. _T('asso:resultat_courant') .'</th>'; 129 echo '<th class="decimal">'. association_prixfr($total_recettes) .'</th>'; 130 echo '<th class="decimal">'. association_prixfr($total_depenses) .'</th>'; 131 echo '<th class="decimal">'. association_prixfr($total_soldes) .'</th>'; 132 echo "</tr>\n</tfoot>\n</table>\n"; 97 $solde = association_liste_totaux_comptes_classes($classes, 'cpte_resultat', 0, $exercice, $id_destination); 133 98 echo '</fieldset>'; 134 99 } … … 137 102 } 138 103 139 /* Dans la fonction suivante "bilan_encaisse($annee)"on dissocie la "lecture" et "l'affichage"104 /* Dans la fonction suivante on dissocie la "lecture" et "l'affichage" 140 105 * afin de pouvoir traiter et calculer des valeurs intermédiaires : 141 106 * 1 - on ne comptabilise pour le terme "encaisse" que les sommes dont le journal est 53xx ou 51xx … … 146 111 * y a desequilibre ! 147 112 */ 148 149 // TODO : le passage en exercice budgétaire - 1)date de fin de l'exercice 2)faire apparaitre l'avoir initial : qui est le solde à (debut -1) de l'exercice (report)150 151 113 function bilan_encaisse() 152 114 { -
_plugins_/Association/Associaspip/exec/compte_bilan.php
r60658 r60667 24 24 echo minipres(); 25 25 } else { 26 // initialisations 26 27 $plan = sql_countsel('spip_asso_plan','active=1'); 27 28 $id_exercice = intval(_request('exercice')); … … 29 30 /* on recupere l'id_exercice dont la date "fin" est "la plus grande" */ 30 31 $id_exercice = sql_getfetsel('id_exercice', 'spip_asso_exercices', '', '', 'fin DESC'); 31 if(!$id_exercice) 32 $id_exercice = 0; 33 } 32 } 33 $destination = intval(_request('destination')); 34 34 $exercice_data = sql_asso1ligne('exercice', $id_exercice); 35 include_spip('inc/association_comptabilite'); 36 // traitements 35 37 onglets_association('titre_onglet_comptes'); 36 38 // INTRO : rappel de l'exercicee affichee … … 40 42 // pas de sommes de synthes puisque tous les totaux sont dans la zone centrale ;- 41 43 // datation et raccourcis 42 icones_association(array('comptes', "exercice=$ exercice"), array(43 'encaisse_titre_general' => array('finances-24.png', 'encaisse', "exercice=$id_exercice" ),44 'cpte_resultat_titre_general' => array('finances-24.png', 'compte_resultat', "exercice=$id_exercice" ),45 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$id_exercice" ),44 icones_association(array('comptes', "exercice=$id_exercice"), array( 45 'encaisse_titre_general' => array('finances-24.png', 'encaisse', "exercice=$id_exercice".($destination?"&destination=$id_destination":'')), 46 'cpte_resultat_titre_general' => array('finances-24.png', 'compte_resultat', "exercice=$id_exercice".($destination?"&destination=$id_destination":'')), 47 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$id_exercice".($destination?"&destination=$id_destination":'')), 46 48 )); 47 49 // elements communs aux requetes … … 72 74 */ 73 75 debut_cadre_association('finances-24.jpg', 'cpte_bilan_titre_general', $exercice_data['intitule']); 74 include_spip('inc/association_comptabilite'); 76 echo "\n<table width='100%'><tr>"; 77 echo '<td width="50%" align="left">'. association_selectionner_exercice($id_exercice, generer_url_ecrire('compte_bilan',($id_destination?"destination=$id_destination":'')) ) .'</td>'; 78 echo '<td width="50%" align="right">'. association_selectionner_destination($id_destination, generer_url_ecrire('compte_bilan',($id_exercice?"exercice=$id_exercice":'')) ) .'</td>'; 79 echo '</tr></table>'; 75 80 // les autres classes a prendre en compte ici 76 81 $classes_bilan = array(); … … 86 91 } 87 92 // liste des actifs cumulees par comptes 88 $ dettes = association_liste_totaux_comptes_classes($classes_bilan, 'cpte_bilan', '-1', $id_exercice, 0);93 $actifs = association_liste_totaux_comptes_classes($classes_bilan, 'cpte_bilan', '-1', $id_exercice, $id_destination); 89 94 // liste des passifs cumulees par comptes 90 $pa trimoine = association_liste_totaux_comptes_classes($classes_bilan, 'cpte_bilan', '+1', $id_exercice, 0);95 $passifs = association_liste_totaux_comptes_classes($classes_bilan, 'cpte_bilan', '+1', $id_exercice, $id_destination); 91 96 // liste des bilans (actifs et passifs) par comptes 92 # $bilan = association_liste_totaux_comptes_classes($classes_bilan, 'cpte_bilan', '', $id_exercice, 0);97 # $bilan = association_liste_totaux_comptes_classes($classes_bilan, 'cpte_bilan', '', $id_exercice, $id_destination); 93 98 /* 94 99 if(autoriser('associer', 'export_compte_bilans') && $plan){ // on peut exporter : pdf, csv, xml, ... -
_plugins_/Association/Associaspip/exec/compte_resultat.php
r60658 r60667 24 24 echo minipres(); 25 25 } else { 26 // initialisations 26 27 $plan = sql_countsel('spip_asso_plan','active=1'); 27 28 $id_exercice = intval(_request('exercice')); … … 29 30 /* on recupere l'id_exercice dont la date "fin" est "la plus grande" */ 30 31 $id_exercice = sql_getfetsel('id_exercice', 'spip_asso_exercices', '', '', 'fin DESC'); 31 if(!$id_exercice) 32 $id_exercice = 0; 33 } 32 } 33 $id_destination = intval(_request('destination')); 34 34 $exercice_data = sql_asso1ligne('exercice', $id_exercice); 35 include_spip('inc/association_comptabilite'); 36 // traitements 35 37 onglets_association('titre_onglet_comptes'); 36 38 // INTRO : rappel de l'exercicee affichee … … 40 42 // pas de sommes de synthes puisque tous les totaux sont dans la zone centrale ;- 41 43 // datation et raccourcis 42 icones_association(array('comptes', "exercice=$ exercice"), array(43 'encaisse_titre_general' => array('finances-24.png', 'encaisse', "exercice=$ exercice"),44 'cpte_bilan_titre_general' => array('finances-24.png', 'compte_bilan', "exercice=$id_exercice" ),45 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$id_exercice" ),44 icones_association(array('comptes', "exercice=$id_exercice"), array( 45 'encaisse_titre_general' => array('finances-24.png', 'encaisse', "exercice=$id_exercice".($destination?"&destination=$id_destination":'')), 46 'cpte_bilan_titre_general' => array('finances-24.png', 'compte_bilan', "exercice=$id_exercice".($destination?"&destination=$id_destination":'')), 47 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$id_exercice".($destination?"&destination=$id_destination":'')), 46 48 )); 47 include_spip('inc/association_comptabilite');48 49 // elements communs aux requetes 49 50 if ($plan) { … … 70 71 } 71 72 debut_cadre_association('finances-24.jpg', 'cpte_resultat_titre_general', $exercice_data['intitule']); 73 echo "\n<table width='100%'><tr>"; 74 echo '<td width="50%" align="left">'. association_selectionner_exercice($id_exercice, generer_url_ecrire('compte_resultat',($id_destination?"destination=$id_destination":'')) ) .'</td>'; 75 echo '<td width="50%" align="right">'. association_selectionner_destination($id_destination, generer_url_ecrire('compte_resultat',($id_exercice?"exercice=$id_exercice":'')) ) .'</td>'; 76 echo '</tr></table>'; 72 77 // liste des charges cumulees par comptes 73 $ depenses = association_liste_totaux_comptes_classes($GLOBALS['association_metas']['classe_charges'], 'cpte_resultat', '-1', $id_exercice, 0);78 $charges = association_liste_totaux_comptes_classes($GLOBALS['association_metas']['classe_charges'], 'cpte_resultat', '-1', $id_exercice, $id_destination); 74 79 // liste des produits cumules par comptes 75 $ recettes = association_liste_totaux_comptes_classes($GLOBALS['association_metas']['classe_produits'], 'cpte_resultat', '+1', $id_exercice, 0);80 $produits = association_liste_totaux_comptes_classes($GLOBALS['association_metas']['classe_produits'], 'cpte_resultat', '+1', $id_exercice, $id_destination); 76 81 // resultat comptable courant 77 compte_resultat_benefice_perte($ recettes, $depenses);82 compte_resultat_benefice_perte($produits, $charges); 78 83 // liste des contributions volontaires (emplois et ressources) par comptes 79 association_liste_totaux_comptes_classes($GLOBALS['association_metas']['classe_contributions_volontaires'], 'cpte_benevolat', 0, $id_exercice, 0);84 $contributions = association_liste_totaux_comptes_classes($GLOBALS['association_metas']['classe_contributions_volontaires'], 'cpte_benevolat', 0, $id_exercice, $id_destination); 80 85 /* 81 86 if(autoriser('associer', 'export_compte_resultats') && $plan){ // on peut exporter : pdf, csv, xml, ... -
_plugins_/Association/Associaspip/exec/comptes.php
r60418 r60667 22 22 } else { 23 23 // initialisations 24 $ exercice = intval(_request('exercice'));25 if(!$ exercice){24 $id_exercice = intval(_request('exercice')); 25 if(!$id_exercice){ 26 26 /* on recupere l'id du dernier exercice */ 27 $exercice = sql_getfetsel('id_exercice','spip_asso_exercices','','','debut DESC'); 28 if(!$exercice) 29 $exercice = 0; 27 $id_exercice = sql_getfetsel('id_exercice','spip_asso_exercices','','','debut DESC'); 30 28 } 31 29 $vu = _request('vu'); … … 46 44 } 47 45 $debut = intval(_request('debut')); 48 $exercice_data = sql_asso1ligne('exercice', $ exercice);46 $exercice_data = sql_asso1ligne('exercice', $id_exercice); 49 47 // traitements 50 48 $where = 'imputation LIKE '. sql_quote($imputation); … … 53 51 onglets_association('titre_onglet_comptes'); 54 52 // INTRO : rappel de l'exercicee affichee 55 echo totauxinfos_intro($exercice_data['intitule'],'exercice',$ exercice);53 echo totauxinfos_intro($exercice_data['intitule'],'exercice',$id_exercice); 56 54 $journaux = sql_allfetsel('journal, intitule', 'spip_asso_comptes RIGHT JOIN spip_asso_plan ON journal=code', "date>='$exercice_data[debut]' AND date<='$exercice_data[fin]'", "intitule DESC"); // on se permet sql_allfetsel car il s'agit d'une association (mois d'une demie dizaine de comptes) et non d'un etablissement financier (des milliers de comptes clients) 57 55 // TOTAUX : operations de l'exercice par compte financier (indique rapidement les comptes financiers les plus utilises ou les modes de paiement preferes...) … … 82 80 // datation et raccourcis 83 81 icones_association(array(), array( 84 'encaisse_titre_general' => array('finances-24.png', 'encaisse', "exercice=$ exercice"),85 'cpte_resultat_titre_general' => array('finances-24.png', 'compte_resultat', "exercice=$ exercice"),86 'cpte_bilan_titre_general' => array('finances-24.png', 'compte_bilan', "exercice=$ exercice"),87 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$ exercice"),82 'encaisse_titre_general' => array('finances-24.png', 'encaisse', "exercice=$id_exercice"), 83 'cpte_resultat_titre_general' => array('finances-24.png', 'compte_resultat', "exercice=$id_exercice"), 84 'cpte_bilan_titre_general' => array('finances-24.png', 'compte_bilan', "exercice=$id_exercice"), 85 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$id_exercice"), 88 86 'ajouter_une_operation' => array('ajout-24.png', 'edit_compte'), 89 87 ) ); 90 88 debut_cadre_association('finances-24.png', 'informations_comptables'); 91 echo "\n<table width='100%'>"; 92 echo '<tr><td>'; 93 echo '<form method="post" action="'.generer_url_ecrire('comptes',"imputation=$imputation").'"><div>'; 94 echo '<select name ="exercice" onchange="form.submit()">'; 95 echo '<option value="0" '; 96 if (!$exercice) { 89 echo "\n<table width='100%'><tr>"; 90 echo '<td width="50%" align="left">'. association_selectionner_exercice($id_exercice, generer_url_ecrire('comptes',"imputation=$imputation") ) .'</td>'; 91 echo '<td width="50%" align="right">'; 92 echo '<form method="post" action="'.generer_url_ecrire('comptes', "exercice=$id_exercice").'"><div>'; 93 echo '<select name ="imputation" onchange="form.submit()">'; 94 echo '<option value="%" '; 95 if ($imputation=='%') { 97 96 echo ' selected="selected"'; 98 97 } 99 echo '>Choix Exercice ?</option>';100 $sql = sql_select('id_exercice, intitule', 'spip_asso_exercices','', "intitule DESC");101 while ($val = sql_fetch($sql)) {102 echo '<option value="'.$val['id_exercice'].'" ';103 if ($exercice==$val['id_exercice']) { echo ' selected="selected"'; }104 echo '>'.$val['intitule'].'</option>';105 }106 echo '</select><noscript><input type="submit" value="'._T('asso:bouton_lister').'" /></noscript></div></form></td>';107 echo '<td>';108 echo '<form method="post" action="'.generer_url_ecrire('comptes', "exercice=$exercice").'"><div>';109 echo '<select name ="imputation" class="fondl" onchange="form.submit()">';110 echo '<option value="%" ';111 if ($imputation=="%") { echo ' selected="selected"'; }112 98 echo '>Tous</option>'; 113 99 /* Remplir le select uniquement avec les comptes utilises */ … … 120 106 while ($plan = sql_fetch($sql)) { 121 107 echo '<option value="'.$plan['code'].'" '; 122 if ($imputation==$plan['code']) { echo ' selected="selected"'; } 108 if ($imputation==$plan['code']) { 109 echo ' selected="selected"'; 110 } 123 111 echo '>'.$plan['code'].' - '.$plan['intitule'].'</option>'; 124 112 } -
_plugins_/Association/Associaspip/exec/encaisse.php
r60658 r60667 22 22 echo minipres(); 23 23 } else { 24 // initialisations 24 25 $plan = sql_countsel('spip_asso_plan'); 25 $exercice = intval(_request('exercice')); 26 if(!$exercice){ // on recupere l'id_exercice dont la date "fin" est "la plus grande" 27 $exercice = sql_getfetsel('id_exercice','spip_asso_exercices','',''); 28 if(!$exercice) 29 $exercice = 0; 26 $id_exercice = intval(_request('exercice')); 27 if(!$id_exercice){ // on recupere l'id_exercice dont la date "fin" est "la plus grande" 28 $id_exercice = sql_getfetsel('id_exercice','spip_asso_exercices','',''); 30 29 } 30 // traitements 31 31 onglets_association('titre_onglet_comptes'); 32 32 // INTRO : rappel de l'exercicee affichee … … 38 38 } 39 39 // datation et raccourcis 40 icones_association(array('comptes', "exercice=$ exercice"), array(41 'cpte_resultat_titre_general' => array('finances-24.png', 'compte_resultat', "exercice=$ exercice"),42 'cpte_bilan_titre_general' => array('finances-24.png', 'compte_bilan', "exercice=$ exercice"),43 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$ exercice"),40 icones_association(array('comptes', "exercice=$id_exercice"), array( 41 'cpte_resultat_titre_general' => array('finances-24.png', 'compte_resultat', "exercice=$id_exercice"), 42 'cpte_bilan_titre_general' => array('finances-24.png', 'compte_bilan', "exercice=$id_exercice"), 43 # 'annexe_titre_general' => array('finances-24.png', 'annexe', "exercice=$id_exercice"), 44 44 )); 45 45 debut_cadre_association('finances-24.png', 'encaisse'); -
_plugins_/Association/Associaspip/inc/association_comptabilite.php
r60658 r60667 388 388 $annee = date('Y'); // on prende l'annee actuelle 389 389 } 390 $ destination = intval(_request('destination'));391 if( !$ destination ) { // pas de destination390 $id_destination = intval(_request('destination')); 391 if( !$id_destination ) { // pas de destination 392 392 } 393 393 return serialize(array($exercice, $destination) ); … … 416 416 # } elseif ( $classe==$GLOBALS['association_metas']['classe_banques'] ) { // encaisse 417 417 # $c_where = 'LEFT(a_c.imputation,1)<>'. sql_quote($GLOBALS['association_metas']['classe_contributions_volontaires']) .' AND a_c.date>=a_p.date_anterieure AND a_c.date<=NOW() '; 418 } else { // tout ?!?419 $c_where = ' ';418 } else { // tout depuis le debut ?!? 419 $c_where = 'a_c.date<=NOW()'; // il faut mettre un test valide car la chaine peut etre precedee de "AND "... limiter alors a aujourd'hui ? 420 420 } 421 421 $query = sql_select(
Note: See TracChangeset
for help on using the changeset viewer.