cotisations.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/adherents/cotisations.php
  21. * \ingroup member
  22. * \brief Page de consultation et insertion d'une cotisation
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
  26. require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
  28. $langs->load("members");
  29. $filter=$_GET["filter"];
  30. $statut=isset($_GET["statut"])?$_GET["statut"]:1;
  31. $sortfield = GETPOST("sortfield",'alpha');
  32. $sortorder = GETPOST("sortorder",'alpha');
  33. $page = GETPOST("page",'int');
  34. if ($page == -1) { $page = 0 ; }
  35. $offset = $conf->liste_limit * $page ;
  36. $pageprev = $page - 1;
  37. $pagenext = $page + 1;
  38. if (! $sortorder) { $sortorder="DESC"; }
  39. if (! $sortfield) { $sortfield="c.dateadh"; }
  40. $msg='';
  41. $date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
  42. if (! $user->rights->adherent->cotisation->lire)
  43. accessforbidden();
  44. /*
  45. * Actions
  46. */
  47. /*
  48. * View
  49. */
  50. llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
  51. if ($msg) print $msg.'<br>';
  52. // Liste des cotisations
  53. $sql = "SELECT d.rowid, d.login, d.prenom, d.nom, d.societe,";
  54. $sql.= " c.rowid as crowid, c.cotisation,";
  55. $sql.= " c.dateadh,";
  56. $sql.= " c.datef,";
  57. $sql.= " c.fk_bank as bank, c.note,";
  58. $sql.= " b.fk_account";
  59. $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
  60. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
  61. $sql.= " WHERE d.rowid = c.fk_adherent";
  62. if (isset($date_select) && $date_select != '')
  63. {
  64. $sql.= " AND dateadh LIKE '$date_select%'";
  65. }
  66. $sql.= $db->order($sortfield,$sortorder);
  67. $sql.= $db->plimit($conf->liste_limit+1, $offset);
  68. $result = $db->query($sql);
  69. if ($result)
  70. {
  71. $num = $db->num_rows($result);
  72. $i = 0;
  73. $title=$langs->trans("ListOfSubscriptions");
  74. if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')';
  75. $param.="&amp;statut=$statut&amp;date_select=$date_select";
  76. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num);
  77. print '<table class="noborder" width="100%">';
  78. print '<tr class="liste_titre">';
  79. print_liste_field_titre($langs->trans("Ref"),"cotisations.php","c.rowid",$param,"","",$sortfield,$sortorder);
  80. print_liste_field_titre($langs->trans("Name"),"cotisations.php","d.nom",$param,"","",$sortfield,$sortorder);
  81. print_liste_field_titre($langs->trans("Login"),"cotisations.php","d.login",$param,"","",$sortfield,$sortorder);
  82. print_liste_field_titre($langs->trans("Label"),"cotisations.php","c.note",$param,"",'align="left"',$sortfield,$sortorder);
  83. if ($conf->banque->enabled)
  84. {
  85. print_liste_field_titre($langs->trans("Account"),"cotisations.php","b.fk_account",$pram,"","",$sortfield,$sortorder);
  86. }
  87. print_liste_field_titre($langs->trans("Date"),"cotisations.php","c.dateadh",$param,"",'align="center"',$sortfield,$sortorder);
  88. print_liste_field_titre($langs->trans("DateEnd"),"cotisations.php","c.datef",$param,"",'align="center"',$sortfield,$sortorder);
  89. print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation",$param,"",'align="right"',$sortfield,$sortorder);
  90. print "</tr>\n";
  91. // Static objects
  92. $cotisation=new Cotisation($db);
  93. $adherent=new Adherent($db);
  94. $accountstatic=new Account($db);
  95. $var=true;
  96. $total=0;
  97. while ($i < $num && $i < $conf->liste_limit)
  98. {
  99. $objp = $db->fetch_object($result);
  100. $total+=$objp->cotisation;
  101. $cotisation->ref=$objp->crowid;
  102. $cotisation->id=$objp->crowid;
  103. $adherent->ref=trim($objp->prenom.' '.$objp->nom);
  104. $adherent->id=$objp->rowid;
  105. $adherent->login=$objp->login;
  106. $var=!$var;
  107. if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $objp->cotisation)
  108. {
  109. print "<form method=\"post\" action=\"cotisations.php\">";
  110. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  111. }
  112. print "<tr $bc[$var]>";
  113. // Ref
  114. print '<td>'.$cotisation->getNomUrl(1).'</td>';
  115. // Nom
  116. print '<td>'.$adherent->getNomUrl(1).'</td>';
  117. // Login
  118. print '<td>'.$adherent->login.'</td>';
  119. // Libelle
  120. print '<td>';
  121. print dol_trunc($objp->note,32);
  122. print '</td>';
  123. // Banque
  124. if ($conf->banque->enabled)
  125. {
  126. if ($objp->fk_account)
  127. {
  128. $accountstatic->id=$objp->fk_account;
  129. $accountstatic->fetch($objp->fk_account);
  130. //$accountstatic->label=$objp->label;
  131. print '<td>'.$accountstatic->getNomUrl(1).'</td>';
  132. }
  133. else
  134. {
  135. print "<td>";
  136. if ($allowinsertbankafter && $objp->cotisation)
  137. {
  138. print '<input type="hidden" name="action" value="2bank">';
  139. print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">';
  140. $html = new Form($db);
  141. $html->select_comptes('','accountid',0,'',1);
  142. print '<br>';
  143. $html->select_types_paiements('','paymenttypeid');
  144. print '<input name="num_chq" type="text" class="flat" size="5">';
  145. }
  146. else
  147. {
  148. print '&nbsp;';
  149. }
  150. print "</td>\n";
  151. }
  152. }
  153. // Date start
  154. print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
  155. // Date end
  156. print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
  157. // Price
  158. print '<td align="right">'.price($objp->cotisation).'</td>';
  159. print "</tr>";
  160. if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $objp->cotisation)
  161. {
  162. print "</form>\n";
  163. }
  164. $i++;
  165. }
  166. // Total
  167. $var=!$var;
  168. print '<tr class="liste_total">';
  169. print "<td>".$langs->trans("Total")."</td>\n";
  170. print "<td align=\"right\">&nbsp;</td>\n";
  171. print "<td align=\"right\">&nbsp;</td>\n";
  172. print "<td align=\"right\">&nbsp;</td>\n";
  173. if ($conf->banque->enabled)
  174. {
  175. print '<td>&nbsp;</td>';
  176. }
  177. print '<td>&nbsp;</td>';
  178. print '<td>&nbsp;</td>';
  179. print "<td align=\"right\">".price($total)."</td>\n";
  180. print "</tr>\n";
  181. print "</table>";
  182. print "<br>\n";
  183. }
  184. else
  185. {
  186. dol_print_error($db);
  187. }
  188. $db->close();
  189. llxFooter();
  190. ?>