list.php 23 KB

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