liste.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <?php
  2. /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2010 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/liste.php
  21. * \ingroup member
  22. * \brief Page to list all members of foundation
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
  26. require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
  28. $langs->load("members");
  29. $langs->load("companies");
  30. $sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
  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="ASC"; }
  39. if (! $sortfield) { $sortfield="d.nom"; }
  40. $filter=$_GET["filter"];
  41. $statut=isset($_GET["statut"])?$_GET["statut"]:'';
  42. if ($_REQUEST["button_removefilter"])
  43. {
  44. $_GET["search_nom"]="";
  45. $_REQUEST["search_nom"]="";
  46. $_GET["search_prenom"]="";
  47. $_REQUEST["search_prenom"]="";
  48. $_GET["type"]="";
  49. $_REQUEST["type"]="";
  50. $_GET["search_email"]="";
  51. $_REQUEST["search_email"]="";
  52. $_GET["search_categ"]="";
  53. $_REQUEST["search_categ"]="";
  54. $sall="";
  55. }
  56. // Load categ filters
  57. $search_categ = isset($_GET["search_categ"])?$_GET["search_categ"]:$_POST["search_categ"];
  58. /*
  59. * View
  60. */
  61. llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
  62. $form=new Form($db);
  63. $htmlother=new FormOther($db);
  64. $now=dol_now();
  65. $membertypestatic=new AdherentType($db);
  66. $sql = "SELECT d.rowid, d.login, d.prenom, d.nom, d.societe, ";
  67. $sql.= " d.datefin,";
  68. $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
  69. $sql.= " t.libelle as type, t.cotisation";
  70. $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
  71. if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_member as cf";
  72. $sql.= " WHERE d.fk_adherent_type = t.rowid ";
  73. if ($search_categ) $sql.= " AND d.rowid = cf.fk_member"; // Join for the needed table to filter by categ
  74. $sql.= " AND d.entity = ".$conf->entity;
  75. if ($sall)
  76. {
  77. $sql.=" AND (d.prenom like '%".$sall."%' OR d.nom like '%".$sall."%' OR d.societe like '%".$sall."%'";
  78. $sql.=" OR d.email like '%".$sall."%' OR d.login like '%".$sall."%' OR d.adresse like '%".$sall."%'";
  79. $sql.=" OR d.ville like '%".$sall."%' OR d.note like '%".$sall."%')";
  80. }
  81. if ($_REQUEST["type"] > 0)
  82. {
  83. $sql.=" AND t.rowid=".$_REQUEST["type"];
  84. }
  85. if (isset($_GET["statut"]))
  86. {
  87. $sql.=" AND d.statut in ($statut)"; // Peut valoir un nombre ou liste de nombre separes par virgules
  88. }
  89. if ( $_POST["action"] == 'search')
  90. {
  91. if (isset($_POST['search']) && $_POST['search'] != '')
  92. {
  93. $sql.= " AND (d.prenom LIKE '%".$_POST['search']."%' OR d.nom LIKE '%".$_POST['search']."%')";
  94. }
  95. }
  96. if ($_GET["search_nom"])
  97. {
  98. $sql.= " AND (d.prenom LIKE '%".$_GET["search_nom"]."%' OR d.nom LIKE '%".$_GET["search_nom"]."%')";
  99. }
  100. if ($_GET["search_login"])
  101. {
  102. $sql.= " AND d.login LIKE '%".$_GET["search_login"]."%'";
  103. }
  104. if ($_GET["search_email"])
  105. {
  106. $sql.= " AND (d.email LIKE '%".$_GET["search_email"]."%')";
  107. }
  108. if ($filter == 'uptodate')
  109. {
  110. $sql.=" AND datefin >= ".$db->idate($now);
  111. }
  112. if ($filter == 'outofdate')
  113. {
  114. $sql.=" AND datefin < ".$db->idate($now);
  115. }
  116. // Insert categ filter
  117. if ($search_categ)
  118. {
  119. $sql.= " AND cf.fk_categorie = ".$db->escape($search_categ);
  120. }
  121. // Count total nb of records with no order and no limits
  122. $nbtotalofrecords = 0;
  123. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  124. {
  125. $resql = $db->query($sql);
  126. if ($resql) $nbtotalofrecords = $db->num_rows($result);
  127. else dol_print_error($db);
  128. }
  129. // Add order and limit
  130. $sql.= $db->order($sortfield,$sortorder);
  131. $sql.= $db->plimit($conf->liste_limit+1, $offset);
  132. $resql = $db->query($sql);
  133. if ($resql)
  134. {
  135. $num = $db->num_rows($resql);
  136. $i = 0;
  137. $titre=$langs->trans("MembersList");
  138. if (isset($_GET["statut"]))
  139. {
  140. if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
  141. if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); }
  142. if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
  143. if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
  144. if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
  145. if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); }
  146. }
  147. elseif ($_POST["action"] == 'search')
  148. {
  149. $titre=$langs->trans("MembersListQualified");
  150. }
  151. if ($_REQUEST["type"] > 0)
  152. {
  153. $membertype=new AdherentType($db);
  154. $result=$membertype->fetch($_REQUEST["type"]);
  155. $titre.=" (".$membertype->libelle.")";
  156. }
  157. $param="";
  158. if (isset($_GET["statut"])) $param.="&statut=".$_GET["statut"];
  159. if (isset($_GET["search_nom"])) $param.="&search_nom=".$_GET["search_nom"];
  160. if (isset($_GET["search_login"])) $param.="&search_login=".$_GET["search_login"];
  161. if (isset($_GET["search_email"])) $param.="&search_email=".$_GET["search_email"];
  162. if (isset($_GET["filter"])) $param.="&filter=".$_GET["filter"];
  163. print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
  164. if ($sall)
  165. {
  166. print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
  167. }
  168. print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
  169. print "<table class=\"noborder\" width=\"100%\">";
  170. // Filter on categories
  171. $moreforfilter='';
  172. if ($conf->categorie->enabled)
  173. {
  174. $moreforfilter.=$langs->trans('Categories'). ': ';
  175. $moreforfilter.=$htmlother->select_categories(3,$search_categ,'search_categ');
  176. $moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
  177. }
  178. if ($moreforfilter)
  179. {
  180. print '<tr class="liste_titre">';
  181. print '<td class="liste_titre" colspan="8">';
  182. print $moreforfilter;
  183. print '</td></tr>';
  184. }
  185. print '<tr class="liste_titre">';
  186. print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),"liste.php","d.nom",$param,"","",$sortfield,$sortorder);
  187. print_liste_field_titre($langs->trans("Login"),"liste.php","d.login",$param,"","",$sortfield,$sortorder);
  188. print_liste_field_titre($langs->trans("Type"),"liste.php","t.libelle",$param,"","",$sortfield,$sortorder);
  189. print_liste_field_titre($langs->trans("Person"),"liste.php","d.morphy",$param,"","",$sortfield,$sortorder);
  190. print_liste_field_titre($langs->trans("EMail"),"liste.php","d.email",$param,"","",$sortfield,$sortorder);
  191. print_liste_field_titre($langs->trans("Status"),"liste.php","d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
  192. print_liste_field_titre($langs->trans("EndSubscription"),"liste.php","d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
  193. print_liste_field_titre($langs->trans("Action"),"liste.php","",$param,"",'width="60" align="center"',$sortfield,$sortorder);
  194. print "</tr>\n";
  195. // Lignes des champs de filtre
  196. print '<tr class="liste_titre">';
  197. print '<td class="liste_titre" align="left">';
  198. print '<input class="flat" type="text" name="search_nom" value="'.$_REQUEST["search_nom"].'" size="12"></td>';
  199. print '<td class="liste_titre" align="left">';
  200. print '<input class="flat" type="text" name="search_login" value="'.$_REQUEST["search_login"].'" size="7"></td>';
  201. print '<td class="liste_titre">';
  202. $listetype=$membertypestatic->liste_array();
  203. print $form->selectarray("type", $listetype, $_REQUEST["type"], 1, 0, 0, '', 0, 12);
  204. print '</td>';
  205. print '<td class="liste_titre">&nbsp;</td>';
  206. print '<td class="liste_titre" align="left">';
  207. print '<input class="flat" type="text" name="search_email" value="'.$_REQUEST["search_email"].'" size="12"></td>';
  208. print '<td class="liste_titre">&nbsp;</td>';
  209. print '<td align="right" colspan="2" class="liste_titre">';
  210. print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
  211. print '&nbsp; ';
  212. print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
  213. print '</td>';
  214. print "</tr>\n";
  215. print '</form>';
  216. $var=True;
  217. while ($i < $num && $i < $conf->liste_limit)
  218. {
  219. $objp = $db->fetch_object($resql);
  220. $datefin=$db->jdate($objp->datefin);
  221. $adh=new Adherent($db);
  222. // Nom
  223. $var=!$var;
  224. print "<tr $bc[$var]>";
  225. if ($objp->societe != '')
  226. {
  227. print "<td><a href=\"fiche.php?rowid=$objp->rowid\">".img_object($langs->trans("ShowMember"),"user").' '.$objp->prenom." ".dol_trunc($objp->nom,12)." / ".dol_trunc($objp->societe,12)."</a></td>\n";
  228. }
  229. else
  230. {
  231. print "<td><a href=\"fiche.php?rowid=$objp->rowid\">".img_object($langs->trans("ShowMember"),"user").' '.$objp->prenom." ".dol_trunc($objp->nom)."</a></td>\n";
  232. }
  233. // Login
  234. print "<td>".$objp->login."</td>\n";
  235. // Type
  236. print '<td nowrap="nowrap">';
  237. $membertypestatic->id=$objp->type_id;
  238. $membertypestatic->libelle=$objp->type;
  239. print $membertypestatic->getNomUrl(1,12);
  240. print '</td>';
  241. // Moral/Physique
  242. print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
  243. // EMail
  244. print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
  245. // Statut
  246. print '<td nowrap="nowrap">';
  247. print $adh->LibStatut($objp->statut,$objp->cotisation,$datefin,2);
  248. print "</td>";
  249. // End of subscription date
  250. if ($datefin)
  251. {
  252. print '<td align="center" nowrap="nowrap">';
  253. print dol_print_date($datefin,'day');
  254. if ($datefin < ($now - $conf->adherent->cotisation->warning_delay) && $objp->statut > 0) print " ".img_warning($langs->trans("SubscriptionLate"));
  255. print '</td>';
  256. }
  257. else
  258. {
  259. print '<td align="left" nowrap="nowrap">';
  260. if ($objp->cotisation == 'yes')
  261. {
  262. print $langs->trans("SubscriptionNotReceived");
  263. if ($objp->statut > 0) print " ".img_warning();
  264. }
  265. else
  266. {
  267. print '&nbsp;';
  268. }
  269. print '</td>';
  270. }
  271. // Actions
  272. print '<td align="center">';
  273. if ($user->rights->adherent->creer)
  274. {
  275. print "<a href=\"fiche.php?rowid=$objp->rowid&action=edit&return=liste.php\">".img_edit()."</a>";
  276. }
  277. print '&nbsp;';
  278. if ($user->rights->adherent->supprimer)
  279. {
  280. print "<a href=\"fiche.php?rowid=$objp->rowid&action=resign&return=liste.php\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
  281. }
  282. print "</td>";
  283. print "</tr>\n";
  284. $i++;
  285. }
  286. print "</table>\n";
  287. if ($num > $conf->liste_limit)
  288. {
  289. print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
  290. }
  291. }
  292. else
  293. {
  294. dol_print_error($db);
  295. }
  296. $db->close();
  297. llxFooter();
  298. ?>