list.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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-2016 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 3 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 <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/adherents/subscription/list.php
  21. * \ingroup member
  22. * \brief list of subscription
  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/adherent_type.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  29. $langs->loadLangs(array("members", "companies"));
  30. $action = GETPOST('action', 'aZ09');
  31. $massaction = GETPOST('massaction', 'alpha');
  32. $confirm = GETPOST('confirm', 'alpha');
  33. $toselect = GETPOST('toselect', 'array');
  34. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'subscriptionlist'; // To manage different context of search
  35. $statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1);
  36. $search_ref = GETPOST('search_ref', 'alpha');
  37. $search_type = GETPOST('search_type', 'alpha');
  38. $search_lastname = GETPOST('search_lastname', 'alpha');
  39. $search_firstname = GETPOST('search_firstname', 'alpha');
  40. $search_login = GETPOST('search_login', 'alpha');
  41. $search_note = GETPOST('search_note', 'alpha');
  42. $search_account = GETPOST('search_account', 'int');
  43. $search_amount = GETPOST('search_amount', 'alpha');
  44. $optioncss = GETPOST('optioncss', 'alpha');
  45. $sall = '';
  46. $date_select = GETPOST("date_select", 'alpha');
  47. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  48. $sortfield = GETPOST('sortfield', 'aZ09comma');
  49. $sortorder = GETPOST('sortorder', 'aZ09comma');
  50. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  51. if (empty($page) || $page == -1) {
  52. $page = 0;
  53. } // If $page is not defined, or '' or -1
  54. $offset = $limit * $page;
  55. $pageprev = $page - 1;
  56. $pagenext = $page + 1;
  57. if (!$sortorder) {
  58. $sortorder = "DESC";
  59. }
  60. if (!$sortfield) {
  61. $sortfield = "c.dateadh";
  62. }
  63. $object = new Subscription($db);
  64. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  65. $hookmanager->initHooks(array('subscriptionlist'));
  66. $extrafields = new ExtraFields($db);
  67. // fetch optionals attributes and labels
  68. $extrafields->fetch_name_optionals_label($object->table_element);
  69. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  70. // List of fields to search into when doing a "search in all"
  71. $fieldstosearchall = array(
  72. );
  73. $arrayfields = array(
  74. 'd.ref'=>array('label'=>"Ref", 'checked'=>1),
  75. 'd.fk_type'=>array('label'=>"Type", 'checked'=>1),
  76. 'd.lastname'=>array('label'=>"Lastname", 'checked'=>1),
  77. 'd.firstname'=>array('label'=>"Firstname", 'checked'=>1),
  78. 'd.login'=>array('label'=>"Login", 'checked'=>1),
  79. 't.libelle'=>array('label'=>"Label", 'checked'=>1),
  80. 'd.bank'=>array('label'=>"BankAccount", 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled))),
  81. /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
  82. 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
  83. 'c.dateadh'=>array('label'=>"DateSubscription", 'checked'=>1, 'position'=>100),
  84. 'c.datef'=>array('label'=>"EndSubscription", 'checked'=>1, 'position'=>101),
  85. 'd.amount'=>array('label'=>"Amount", 'checked'=>1, 'position'=>102),
  86. 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
  87. 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  88. // 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
  89. );
  90. // Security check
  91. $result = restrictedArea($user, 'adherent', '', '', 'cotisation');
  92. /*
  93. * Actions
  94. */
  95. if (GETPOST('cancel', 'alpha')) {
  96. $action = 'list'; $massaction = '';
  97. }
  98. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
  99. $massaction = '';
  100. }
  101. $parameters = array('socid'=>isset($socid) ? $socid : null);
  102. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  103. if ($reshook < 0) {
  104. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  105. }
  106. if (empty($reshook)) {
  107. // Selection of new fields
  108. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  109. // Purge search criteria
  110. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  111. $search_type = "";
  112. $search_ref = "";
  113. $search_lastname = "";
  114. $search_firstname = "";
  115. $search_login = "";
  116. $search_note = "";
  117. $search_amount = "";
  118. $search_account = "";
  119. $toselect = '';
  120. $search_array_options = array();
  121. }
  122. }
  123. /*
  124. * View
  125. */
  126. $form = new Form($db);
  127. $subscription = new Subscription($db);
  128. $adherent = new Adherent($db);
  129. $accountstatic = new Account($db);
  130. $now = dol_now();
  131. // List of subscriptions
  132. $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut,";
  133. $sql .= " d.gender, d.email, d.morphy,";
  134. $sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
  135. $sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
  136. $sql .= " c.fk_bank as bank, c.note,";
  137. $sql .= " b.fk_account";
  138. $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
  139. $sql .= " JOIN ".MAIN_DB_PREFIX."subscription as c on d.rowid = c.fk_adherent";
  140. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
  141. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
  142. $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
  143. if (isset($date_select) && $date_select != '') {
  144. $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'";
  145. $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
  146. }
  147. if ($search_ref) {
  148. if (is_numeric($search_ref)) {
  149. $sql .= " AND c.rowid = ".((int) $search_ref);
  150. } else {
  151. $sql .= " AND 1 = 2"; // Always wrong
  152. }
  153. }
  154. if ($search_type) {
  155. $sql .= natural_search(array('c.fk_type'), $search_type);
  156. }
  157. if ($search_lastname) {
  158. $sql .= natural_search(array('d.lastname', 'd.societe'), $search_lastname);
  159. }
  160. if ($search_firstname) {
  161. $sql .= natural_search(array('d.firstname'), $search_firstname);
  162. }
  163. if ($search_login) {
  164. $sql .= natural_search('d.login', $search_login);
  165. }
  166. if ($search_note) {
  167. $sql .= natural_search('c.note', $search_note);
  168. }
  169. if ($search_account > 0) {
  170. $sql .= " AND b.fk_account = ".((int) $search_account);
  171. }
  172. if ($search_amount) {
  173. $sql .= natural_search('c.subscription', $search_amount, 1);
  174. }
  175. // Add where from extra fields
  176. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  177. // Add where from hooks
  178. $parameters = array();
  179. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  180. $sql .= $hookmanager->resPrint;
  181. $sql .= $db->order($sortfield, $sortorder);
  182. // Count total nb of records with no order and no limits
  183. $nbtotalofrecords = '';
  184. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  185. $resql = $db->query($sql);
  186. if ($resql) {
  187. $nbtotalofrecords = $db->num_rows($resql);
  188. } else {
  189. dol_print_error($db);
  190. }
  191. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  192. $page = 0;
  193. $offset = 0;
  194. }
  195. }
  196. // Add limit
  197. $sql .= $db->plimit($limit + 1, $offset);
  198. $result = $db->query($sql);
  199. if (!$result) {
  200. dol_print_error($db);
  201. exit;
  202. }
  203. $num = $db->num_rows($result);
  204. $arrayofselected = is_array($toselect) ? $toselect : array();
  205. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
  206. $obj = $db->fetch_object($resql);
  207. $id = $obj->rowid;
  208. header("Location: ".DOL_URL_ROOT.'/adherents/subscription/card.php?id='.$id);
  209. exit;
  210. }
  211. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
  212. llxHeader('', $langs->trans("ListOfSubscriptions"), $help_url);
  213. $i = 0;
  214. $title = $langs->trans("ListOfSubscriptions");
  215. if (!empty($date_select)) {
  216. $title .= ' ('.$langs->trans("Year").' '.$date_select.')';
  217. }
  218. $param = '';
  219. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  220. $param .= '&contextpage='.urlencode($contextpage);
  221. }
  222. if ($limit > 0 && $limit != $conf->liste_limit) {
  223. $param .= '&limit='.urlencode($limit);
  224. }
  225. if ($statut != '') {
  226. $param .= "&statut=".urlencode($statut);
  227. }
  228. if ($search_type) {
  229. $param .= "&search_type=".urlencode($search_type);
  230. }
  231. if ($date_select) {
  232. $param .= "&date_select=".urlencode($date_select);
  233. }
  234. if ($search_lastname) {
  235. $param .= "&search_lastname=".urlencode($search_lastname);
  236. }
  237. if ($search_login) {
  238. $param .= "&search_login=".urlencode($search_login);
  239. }
  240. if ($search_account) {
  241. $param .= "&search_account=".urlencode($search_account);
  242. }
  243. if ($search_amount) {
  244. $param .= "&search_amount=".urlencode($search_amount);
  245. }
  246. if ($optioncss != '') {
  247. $param .= '&optioncss='.urlencode($optioncss);
  248. }
  249. // Add $param from extra fields
  250. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  251. // List of mass actions available
  252. $arrayofmassactions = array(
  253. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  254. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  255. );
  256. //if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  257. if (in_array($massaction, array('presend', 'predelete'))) {
  258. $arrayofmassactions = array();
  259. }
  260. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  261. $newcardbutton = '';
  262. if ($user->rights->adherent->cotisation->creer) {
  263. $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1');
  264. }
  265. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  266. if ($optioncss != '') {
  267. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  268. }
  269. print '<input type="hidden" name="token" value="'.newToken().'">';
  270. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  271. print '<input type="hidden" name="action" value="list">';
  272. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  273. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  274. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  275. print '<input type="hidden" name="date_select" value="'.$date_select.'">';
  276. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  277. $topicmail = "Information";
  278. $modelmail = "subscription";
  279. $objecttmp = new Subscription($db);
  280. $trackid = 'sub'.$object->id;
  281. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  282. if ($sall) {
  283. foreach ($fieldstosearchall as $key => $val) {
  284. $fieldstosearchall[$key] = $langs->trans($val);
  285. }
  286. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  287. }
  288. $moreforfilter = '';
  289. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  290. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  291. if ($massactionbutton) {
  292. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  293. }
  294. print '<div class="div-table-responsive">';
  295. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  296. // Line for filters fields
  297. print '<tr class="liste_titre_filter">';
  298. // Line numbering
  299. if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
  300. print '<td class="liste_titre">&nbsp;</td>';
  301. }
  302. // Ref
  303. if (!empty($arrayfields['d.ref']['checked'])) {
  304. print '<td class="liste_titre left">';
  305. print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
  306. }
  307. // Type
  308. if (!empty($arrayfields['d.fk_type']['checked'])) {
  309. print '<td class="liste_titre left">';
  310. print '<input class="flat maxwidth50" type="text" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
  311. print'</td>';
  312. }
  313. if (!empty($arrayfields['d.lastname']['checked'])) {
  314. print '<td class="liste_titre left">';
  315. print '<input class="flat maxwidth75" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
  316. }
  317. if (!empty($arrayfields['d.firstname']['checked'])) {
  318. print '<td class="liste_titre left">';
  319. print '<input class="flat maxwidth75" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
  320. }
  321. if (!empty($arrayfields['d.login']['checked'])) {
  322. print '<td class="liste_titre left">';
  323. print '<input class="flat maxwidth75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
  324. }
  325. if (!empty($arrayfields['t.libelle']['checked'])) {
  326. print '<td class="liste_titre">';
  327. print '';
  328. print '</td>';
  329. }
  330. if (!empty($arrayfields['d.bank']['checked'])) {
  331. print '<td class="liste_titre">';
  332. $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150');
  333. print '</td>';
  334. }
  335. if (!empty($arrayfields['c.dateadh']['checked'])) {
  336. print '<td class="liste_titre">&nbsp;</td>';
  337. }
  338. if (!empty($arrayfields['c.datef']['checked'])) {
  339. print '<td class="liste_titre">&nbsp;</td>';
  340. }
  341. if (!empty($arrayfields['d.amount']['checked'])) {
  342. print '<td class="liste_titre right">';
  343. print '<input class="flat" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'" size="4">';
  344. print '</td>';
  345. }
  346. // Extra fields
  347. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  348. // Fields from hook
  349. $parameters = array('arrayfields'=>$arrayfields);
  350. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  351. print $hookmanager->resPrint;
  352. // Date creation
  353. if (!empty($arrayfields['c.datec']['checked'])) {
  354. print '<td class="liste_titre">';
  355. print '</td>';
  356. }
  357. // Date modification
  358. if (!empty($arrayfields['c.tms']['checked'])) {
  359. print '<td class="liste_titre">';
  360. print '</td>';
  361. }
  362. // Action column
  363. print '<td class="liste_titre right">';
  364. $searchpicto = $form->showFilterButtons();
  365. print $searchpicto;
  366. print '</td>';
  367. print "</tr>\n";
  368. print '<tr class="liste_titre">';
  369. if (!empty($arrayfields['d.ref']['checked'])) {
  370. print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
  371. }
  372. if (!empty($arrayfields['d.fk_type']['checked'])) {
  373. print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
  374. }
  375. if (!empty($arrayfields['d.lastname']['checked'])) {
  376. print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
  377. }
  378. if (!empty($arrayfields['d.firstname']['checked'])) {
  379. print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
  380. }
  381. if (!empty($arrayfields['d.login']['checked'])) {
  382. print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
  383. }
  384. if (!empty($arrayfields['t.libelle']['checked'])) {
  385. print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
  386. }
  387. if (!empty($arrayfields['d.bank']['checked'])) {
  388. print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
  389. }
  390. if (!empty($arrayfields['c.dateadh']['checked'])) {
  391. print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
  392. }
  393. if (!empty($arrayfields['c.datef']['checked'])) {
  394. print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
  395. }
  396. if (!empty($arrayfields['d.amount']['checked'])) {
  397. print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
  398. }
  399. // Extra fields
  400. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  401. // Hook fields
  402. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  403. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  404. print $hookmanager->resPrint;
  405. if (!empty($arrayfields['c.datec']['checked'])) {
  406. print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  407. }
  408. if (!empty($arrayfields['c.tms']['checked'])) {
  409. print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  410. }
  411. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  412. print "</tr>\n";
  413. $totalarray = array();
  414. $totalarray['nbfield'] = 0;
  415. while ($i < min($num, $limit)) {
  416. $obj = $db->fetch_object($result);
  417. $subscription->ref = $obj->crowid;
  418. $subscription->id = $obj->crowid;
  419. $subscription->dateh = $db->jdate($obj->dateadh);
  420. $subscription->datef = $db->jdate($obj->datef);
  421. $adherent->lastname = $obj->lastname;
  422. $adherent->firstname = $obj->firstname;
  423. $adherent->ref = $obj->rowid;
  424. $adherent->id = $obj->rowid;
  425. $adherent->statut = $obj->statut;
  426. $adherent->login = $obj->login;
  427. $adherent->photo = $obj->photo;
  428. $adherent->gender = $obj->gender;
  429. $adherent->morphy = $obj->morphy;
  430. $adherent->email = $obj->email;
  431. $adherent->typeid = $obj->fk_type;
  432. $adherent->datefin = $db->jdate($obj->datef);
  433. $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
  434. $adht = new AdherentType($db);
  435. $adht->fetch($typeid);
  436. $adherent->need_subscription = $adht->subscription;
  437. print '<tr class="oddeven">';
  438. // Ref
  439. if (!empty($arrayfields['d.ref']['checked'])) {
  440. print '<td>'.$subscription->getNomUrl(1).'</td>';
  441. if (!$i) {
  442. $totalarray['nbfield']++;
  443. }
  444. }
  445. // Type
  446. if (!empty($arrayfields['d.fk_type']['checked'])) {
  447. print '<td class="nowraponall">';
  448. if ($typeid > 0) {
  449. print $adht->getNomUrl(1);
  450. }
  451. print '</td>';
  452. if (!$i) {
  453. $totalarray['nbfield']++;
  454. }
  455. }
  456. // Lastname
  457. if (!empty($arrayfields['d.lastname']['checked'])) {
  458. print '<td class="tdoverflowmax150">'.$adherent->getNomUrl(-1, 0, 'card', 'lastname').'</td>';
  459. if (!$i) {
  460. $totalarray['nbfield']++;
  461. }
  462. }
  463. // Firstname
  464. if (!empty($arrayfields['d.firstname']['checked'])) {
  465. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->firstname).'">'.$adherent->firstname.'</td>';
  466. if (!$i) {
  467. $totalarray['nbfield']++;
  468. }
  469. }
  470. // Login
  471. if (!empty($arrayfields['d.login']['checked'])) {
  472. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->login).'">'.$adherent->login.'</td>';
  473. if (!$i) {
  474. $totalarray['nbfield']++;
  475. }
  476. }
  477. // Label
  478. if (!empty($arrayfields['t.libelle']['checked'])) {
  479. print '<td class="tdoverflowmax400" title="'.dol_escape_htmltag($obj->note).'">';
  480. print $obj->note;
  481. print '</td>';
  482. if (!$i) {
  483. $totalarray['nbfield']++;
  484. }
  485. }
  486. // Banque
  487. if (!empty($arrayfields['d.bank']['checked'])) {
  488. print '<td class="tdmaxoverflow150">';
  489. if ($obj->fk_account > 0) {
  490. $accountstatic->id = $obj->fk_account;
  491. $accountstatic->fetch($obj->fk_account);
  492. //$accountstatic->label=$obj->label;
  493. print $accountstatic->getNomUrl(1);
  494. }
  495. print "</td>\n";
  496. if (!$i) {
  497. $totalarray['nbfield']++;
  498. }
  499. }
  500. // Date start
  501. if (!empty($arrayfields['c.dateadh']['checked'])) {
  502. print '<td class="center">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
  503. if (!$i) {
  504. $totalarray['nbfield']++;
  505. }
  506. }
  507. // Date end
  508. if (!empty($arrayfields['c.datef']['checked'])) {
  509. print '<td class="center">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
  510. if (!$i) {
  511. $totalarray['nbfield']++;
  512. }
  513. }
  514. // Price
  515. if (!empty($arrayfields['d.amount']['checked'])) {
  516. print '<td class="right amount">'.price($obj->subscription).'</td>';
  517. if (!$i) {
  518. $totalarray['nbfield']++;
  519. }
  520. if (!$i) {
  521. $totalarray['pos'][$totalarray['nbfield']] = 'd.amount';
  522. }
  523. $totalarray['val']['d.amount'] += $obj->subscription;
  524. }
  525. // Extra fields
  526. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  527. // Fields from hook
  528. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  529. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  530. print $hookmanager->resPrint;
  531. // Date creation
  532. if (!empty($arrayfields['c.datec']['checked'])) {
  533. print '<td class="nowrap center">';
  534. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  535. print '</td>';
  536. if (!$i) {
  537. $totalarray['nbfield']++;
  538. }
  539. }
  540. // Date modification
  541. if (!empty($arrayfields['c.tms']['checked'])) {
  542. print '<td class="nowrap center">';
  543. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  544. print '</td>';
  545. if (!$i) {
  546. $totalarray['nbfield']++;
  547. }
  548. }
  549. // Action column
  550. print '<td class="center">';
  551. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  552. $selected = 0;
  553. if (in_array($obj->rowid, $arrayofselected)) {
  554. $selected = 1;
  555. }
  556. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  557. }
  558. print '</td>';
  559. if (!$i) {
  560. $totalarray['nbfield']++;
  561. }
  562. print "</tr>\n";
  563. $i++;
  564. }
  565. // Show total line
  566. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  567. // If no record found
  568. if ($num == 0) {
  569. $colspan = 1;
  570. foreach ($arrayfields as $key => $val) {
  571. if (!empty($val['checked'])) {
  572. $colspan++;
  573. }
  574. }
  575. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  576. }
  577. $db->free($resql);
  578. $parameters = array('sql' => $sql);
  579. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  580. print $hookmanager->resPrint;
  581. print "</table>";
  582. print '</div>';
  583. print '</form>';
  584. // End of page
  585. llxFooter();
  586. $db->close();