list.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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-2023 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", "banks"));
  31. $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
  32. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  33. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  34. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  35. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  36. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  37. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  38. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  39. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  40. $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
  41. $statut = (GETPOSTISSET("statut") ? GETPOST("statut", "alpha") : 1);
  42. $search_ref = GETPOST('search_ref', 'alpha');
  43. $search_type = GETPOST('search_type', 'alpha');
  44. $search_lastname = GETPOST('search_lastname', 'alpha');
  45. $search_firstname = GETPOST('search_firstname', 'alpha');
  46. $search_login = GETPOST('search_login', 'alpha');
  47. $search_note = GETPOST('search_note', 'alpha');
  48. $search_account = GETPOST('search_account', 'int');
  49. $search_amount = GETPOST('search_amount', 'alpha');
  50. $search_all = '';
  51. $date_select = GETPOST("date_select", 'alpha');
  52. // Load variable for pagination
  53. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  54. $sortfield = GETPOST('sortfield', 'aZ09comma');
  55. $sortorder = GETPOST('sortorder', 'aZ09comma');
  56. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  57. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  58. // If $page is not defined, or '' or -1 or if we click on clear filters
  59. $page = 0;
  60. }
  61. $offset = $limit * $page;
  62. $pageprev = $page - 1;
  63. $pagenext = $page + 1;
  64. if (!$sortorder) {
  65. $sortorder = "DESC";
  66. }
  67. if (!$sortfield) {
  68. $sortfield = "c.dateadh";
  69. }
  70. // Initialize technical objects
  71. $object = new Subscription($db);
  72. $extrafields = new ExtraFields($db);
  73. $hookmanager->initHooks(array('subscriptionlist'));
  74. // Fetch optionals attributes and labels
  75. $extrafields->fetch_name_optionals_label($object->table_element);
  76. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  77. // List of fields to search into when doing a "search in all"
  78. $fieldstosearchall = array(
  79. );
  80. $arrayfields = array(
  81. 'd.ref'=>array('label'=>"Ref", 'checked'=>1),
  82. 'd.fk_type'=>array('label'=>"Type", 'checked'=>1),
  83. 'd.lastname'=>array('label'=>"Lastname", 'checked'=>1),
  84. 'd.firstname'=>array('label'=>"Firstname", 'checked'=>1),
  85. 'd.login'=>array('label'=>"Login", 'checked'=>1),
  86. 't.libelle'=>array('label'=>"Label", 'checked'=>1),
  87. 'd.bank'=>array('label'=>"BankAccount", 'checked'=>1, 'enabled'=>(isModEnabled('banque'))),
  88. /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
  89. 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
  90. 'c.dateadh'=>array('label'=>"DateSubscription", 'checked'=>1, 'position'=>100),
  91. 'c.datef'=>array('label'=>"EndSubscription", 'checked'=>1, 'position'=>101),
  92. 'd.amount'=>array('label'=>"Amount", 'checked'=>1, 'position'=>102),
  93. 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
  94. 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  95. // 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
  96. );
  97. // Security check
  98. $result = restrictedArea($user, 'adherent', '', '', 'cotisation');
  99. $permissiontodelete = $user->hasRight('adherent', 'cotisation', 'creer');
  100. /*
  101. * Actions
  102. */
  103. if (GETPOST('cancel', 'alpha')) {
  104. $action = 'list';
  105. $massaction = '';
  106. }
  107. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  108. $massaction = '';
  109. }
  110. $parameters = array('socid'=>isset($socid) ? $socid : null);
  111. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  112. if ($reshook < 0) {
  113. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  114. }
  115. if (empty($reshook)) {
  116. // Selection of new fields
  117. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  118. // Purge search criteria
  119. 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
  120. $search_type = "";
  121. $search_ref = "";
  122. $search_lastname = "";
  123. $search_firstname = "";
  124. $search_login = "";
  125. $search_note = "";
  126. $search_amount = "";
  127. $search_account = "";
  128. $toselect = array();
  129. $search_array_options = array();
  130. }
  131. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  132. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  133. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  134. }
  135. // Mass actions
  136. $objectclass = 'Subscription';
  137. $objectlabel = 'Subscription';
  138. $uploaddir = $conf->adherent->dir_output;
  139. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  140. }
  141. /*
  142. * View
  143. */
  144. $form = new Form($db);
  145. $subscription = new Subscription($db);
  146. $adherent = new Adherent($db);
  147. $accountstatic = new Account($db);
  148. $now = dol_now();
  149. // List of subscriptions
  150. $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut as status,";
  151. $sql .= " d.gender, d.email, d.morphy,";
  152. $sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
  153. $sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
  154. $sql .= " c.fk_bank as bank, c.note as note_private,";
  155. $sql .= " b.fk_account";
  156. // Add fields from extrafields
  157. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  158. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  159. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  160. }
  161. }
  162. // Add fields from hooks
  163. $parameters = array();
  164. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  165. $sql .= $hookmanager->resPrint;
  166. $sql = preg_replace('/,\s*$/', '', $sql);
  167. $sqlfields = $sql; // $sql fields to remove for count total
  168. $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
  169. $sql .= " JOIN ".MAIN_DB_PREFIX."subscription as c on d.rowid = c.fk_adherent";
  170. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
  171. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
  172. $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
  173. if (isset($date_select) && $date_select != '') {
  174. $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'";
  175. $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
  176. }
  177. if ($search_ref) {
  178. if (is_numeric($search_ref)) {
  179. $sql .= " AND c.rowid = ".((int) $search_ref);
  180. } else {
  181. $sql .= " AND 1 = 2"; // Always wrong
  182. }
  183. }
  184. if ($search_type) {
  185. $sql .= natural_search(array('c.fk_type'), $search_type);
  186. }
  187. if ($search_lastname) {
  188. $sql .= natural_search(array('d.lastname', 'd.societe'), $search_lastname);
  189. }
  190. if ($search_firstname) {
  191. $sql .= natural_search(array('d.firstname'), $search_firstname);
  192. }
  193. if ($search_login) {
  194. $sql .= natural_search('d.login', $search_login);
  195. }
  196. if ($search_note) {
  197. $sql .= natural_search('c.note', $search_note);
  198. }
  199. if ($search_account > 0) {
  200. $sql .= " AND b.fk_account = ".((int) $search_account);
  201. }
  202. if ($search_amount) {
  203. $sql .= natural_search('c.subscription', $search_amount, 1);
  204. }
  205. if ($search_all) {
  206. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  207. }
  208. // Add where from extra fields
  209. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  210. // Add where from hooks
  211. $parameters = array();
  212. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  213. $sql .= $hookmanager->resPrint;
  214. // Count total nb of records
  215. $nbtotalofrecords = '';
  216. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  217. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  218. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  219. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  220. $resql = $db->query($sqlforcount);
  221. if ($resql) {
  222. $objforcount = $db->fetch_object($resql);
  223. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  224. } else {
  225. dol_print_error($db);
  226. }
  227. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  228. $page = 0;
  229. $offset = 0;
  230. }
  231. $db->free($resql);
  232. }
  233. // Complete request and execute it with limit
  234. $sql .= $db->order($sortfield, $sortorder);
  235. if ($limit) {
  236. $sql .= $db->plimit($limit + 1, $offset);
  237. }
  238. $resql = $db->query($sql);
  239. if (!$resql) {
  240. dol_print_error($db);
  241. exit;
  242. }
  243. $num = $db->num_rows($resql);
  244. // Direct jump if only one record found
  245. if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
  246. $obj = $db->fetch_object($resql);
  247. $id = $obj->rowid;
  248. header("Location: ".DOL_URL_ROOT.'/adherents/subscription/card.php?id='.$id);
  249. exit;
  250. }
  251. // Output page
  252. // --------------------------------------------------------------------
  253. $title = $langs->trans("Subscriptions");
  254. if (!empty($date_select)) {
  255. $title .= ' ('.$langs->trans("Year").' '.$date_select.')';
  256. }
  257. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
  258. llxHeader('', $title, $help_url);
  259. $arrayofselected = is_array($toselect) ? $toselect : array();
  260. $param = '';
  261. if (!empty($mode)) {
  262. $param .='&mode='.urlencode($mode);
  263. }
  264. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  265. $param .= '&contextpage='.urlencode($contextpage);
  266. }
  267. if ($limit > 0 && $limit != $conf->liste_limit) {
  268. $param .= '&limit='.((int) $limit);
  269. }
  270. if ($statut != '') {
  271. $param .= "&statut=".urlencode($statut);
  272. }
  273. if ($search_type) {
  274. $param .= "&search_type=".urlencode($search_type);
  275. }
  276. if ($date_select) {
  277. $param .= "&date_select=".urlencode($date_select);
  278. }
  279. if ($search_lastname) {
  280. $param .= "&search_lastname=".urlencode($search_lastname);
  281. }
  282. if ($search_login) {
  283. $param .= "&search_login=".urlencode($search_login);
  284. }
  285. if ($search_account) {
  286. $param .= "&search_account=".urlencode($search_account);
  287. }
  288. if ($search_amount) {
  289. $param .= "&search_amount=".urlencode($search_amount);
  290. }
  291. if ($optioncss != '') {
  292. $param .= '&optioncss='.urlencode($optioncss);
  293. }
  294. // Add $param from extra fields
  295. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  296. // Add $param from hooks
  297. $parameters = array();
  298. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  299. $param .= $hookmanager->resPrint;
  300. // List of mass actions available
  301. $arrayofmassactions = array(
  302. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  303. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  304. );
  305. if (!empty($permissiontodelete)) {
  306. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  307. }
  308. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  309. $arrayofmassactions = array();
  310. }
  311. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  312. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  313. if ($optioncss != '') {
  314. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  315. }
  316. print '<input type="hidden" name="token" value="'.newToken().'">';
  317. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  318. print '<input type="hidden" name="action" value="list">';
  319. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  320. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  321. print '<input type="hidden" name="page" value="'.$page.'">';
  322. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  323. print '<input type="hidden" name="date_select" value="'.$date_select.'">';
  324. print '<input type="hidden" name="page_y" value="">';
  325. print '<input type="hidden" name="mode" value="'.$mode.'">';
  326. $newcardbutton = '';
  327. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  328. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  329. if ($user->hasRight('adherent', 'cotisation', 'creer')) {
  330. $newcardbutton .= dolGetButtonTitleSeparator();
  331. $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1');
  332. }
  333. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  334. $topicmail = "Information";
  335. $modelmail = "subscription";
  336. $objecttmp = new Subscription($db);
  337. $trackid = 'sub'.$object->id;
  338. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  339. if ($search_all) {
  340. $setupstring = '';
  341. foreach ($fieldstosearchall as $key => $val) {
  342. $fieldstosearchall[$key] = $langs->trans($val);
  343. $setupstring .= $key."=".$val.";";
  344. }
  345. print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  346. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
  347. }
  348. $moreforfilter = '';
  349. /*$moreforfilter.='<div class="divsearchfield">';
  350. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  351. $moreforfilter.= '</div>';*/
  352. $parameters = array();
  353. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  354. if (empty($reshook)) {
  355. $moreforfilter .= $hookmanager->resPrint;
  356. } else {
  357. $moreforfilter = $hookmanager->resPrint;
  358. }
  359. if (!empty($moreforfilter)) {
  360. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  361. print $moreforfilter;
  362. $parameters = array();
  363. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  364. print $hookmanager->resPrint;
  365. print '</div>';
  366. }
  367. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  368. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  369. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  370. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  371. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  372. // Fields title search
  373. // --------------------------------------------------------------------
  374. print '<tr class="liste_titre_filter">';
  375. // Action column
  376. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  377. print '<td class="liste_titre center maxwidthsearch">';
  378. $searchpicto = $form->showFilterButtons('left');
  379. print $searchpicto;
  380. print '</td>';
  381. }
  382. // Line numbering
  383. if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) {
  384. print '<td class="liste_titre">&nbsp;</td>';
  385. }
  386. // Ref
  387. if (!empty($arrayfields['d.ref']['checked'])) {
  388. print '<td class="liste_titre left">';
  389. print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
  390. }
  391. // Type
  392. if (!empty($arrayfields['d.fk_type']['checked'])) {
  393. print '<td class="liste_titre left">';
  394. print '<input class="flat maxwidth50" type="text" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
  395. print'</td>';
  396. }
  397. if (!empty($arrayfields['d.lastname']['checked'])) {
  398. print '<td class="liste_titre left">';
  399. print '<input class="flat maxwidth75" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
  400. }
  401. if (!empty($arrayfields['d.firstname']['checked'])) {
  402. print '<td class="liste_titre left">';
  403. print '<input class="flat maxwidth75" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
  404. }
  405. if (!empty($arrayfields['d.login']['checked'])) {
  406. print '<td class="liste_titre left">';
  407. print '<input class="flat maxwidth75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
  408. }
  409. if (!empty($arrayfields['t.libelle']['checked'])) {
  410. print '<td class="liste_titre">';
  411. print '';
  412. print '</td>';
  413. }
  414. if (!empty($arrayfields['d.bank']['checked'])) {
  415. print '<td class="liste_titre">';
  416. $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth100');
  417. print '</td>';
  418. }
  419. if (!empty($arrayfields['c.dateadh']['checked'])) {
  420. print '<td class="liste_titre">&nbsp;</td>';
  421. }
  422. if (!empty($arrayfields['c.datef']['checked'])) {
  423. print '<td class="liste_titre">&nbsp;</td>';
  424. }
  425. if (!empty($arrayfields['d.amount']['checked'])) {
  426. print '<td class="liste_titre right">';
  427. print '<input class="flat" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'" size="4">';
  428. print '</td>';
  429. }
  430. // Extra fields
  431. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  432. // Fields from hook
  433. $parameters = array('arrayfields'=>$arrayfields);
  434. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  435. print $hookmanager->resPrint;
  436. // Date creation
  437. if (!empty($arrayfields['c.datec']['checked'])) {
  438. print '<td class="liste_titre">';
  439. print '</td>';
  440. }
  441. // Date modification
  442. if (!empty($arrayfields['c.tms']['checked'])) {
  443. print '<td class="liste_titre">';
  444. print '</td>';
  445. }
  446. // Action column
  447. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  448. print '<td class="liste_titre center maxwidthsearch">';
  449. $searchpicto = $form->showFilterButtons();
  450. print $searchpicto;
  451. print '</td>';
  452. }
  453. print '</tr>'."\n";
  454. $totalarray = array();
  455. $totalarray['nbfield'] = 0;
  456. // Fields title label
  457. // --------------------------------------------------------------------
  458. print '<tr class="liste_titre">';
  459. // Action column
  460. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  461. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  462. $totalarray['nbfield']++;
  463. }
  464. if (!empty($arrayfields['d.ref']['checked'])) {
  465. print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
  466. $totalarray['nbfield']++;
  467. }
  468. if (!empty($arrayfields['d.fk_type']['checked'])) {
  469. print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
  470. $totalarray['nbfield']++;
  471. }
  472. if (!empty($arrayfields['d.lastname']['checked'])) {
  473. print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
  474. $totalarray['nbfield']++;
  475. }
  476. if (!empty($arrayfields['d.firstname']['checked'])) {
  477. print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
  478. $totalarray['nbfield']++;
  479. }
  480. if (!empty($arrayfields['d.login']['checked'])) {
  481. print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
  482. $totalarray['nbfield']++;
  483. }
  484. if (!empty($arrayfields['t.libelle']['checked'])) {
  485. print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
  486. $totalarray['nbfield']++;
  487. }
  488. if (!empty($arrayfields['d.bank']['checked'])) {
  489. print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
  490. $totalarray['nbfield']++;
  491. }
  492. if (!empty($arrayfields['c.dateadh']['checked'])) {
  493. print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
  494. $totalarray['nbfield']++;
  495. }
  496. if (!empty($arrayfields['c.datef']['checked'])) {
  497. print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
  498. $totalarray['nbfield']++;
  499. }
  500. if (!empty($arrayfields['d.amount']['checked'])) {
  501. print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
  502. $totalarray['nbfield']++;
  503. }
  504. // Extra fields
  505. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  506. // Hook fields
  507. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  508. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  509. print $hookmanager->resPrint;
  510. if (!empty($arrayfields['c.datec']['checked'])) {
  511. print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  512. }
  513. if (!empty($arrayfields['c.tms']['checked'])) {
  514. print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  515. }
  516. // Action column
  517. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  518. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  519. $totalarray['nbfield']++;
  520. }
  521. print '</tr>'."\n";
  522. // Loop on record
  523. // --------------------------------------------------------------------
  524. $i = 0;
  525. $savnbfield = $totalarray['nbfield'];
  526. $totalarray = array();
  527. $totalarray['nbfield'] = 0;
  528. $imaxinloop = ($limit ? min($num, $limit) : $num);
  529. while ($i < $imaxinloop) {
  530. $obj = $db->fetch_object($resql);
  531. if (empty($obj)) {
  532. break; // Should not happen
  533. }
  534. $subscription->ref = $obj->crowid;
  535. $subscription->id = $obj->crowid;
  536. $subscription->dateh = $db->jdate($obj->dateadh);
  537. $subscription->datef = $db->jdate($obj->datef);
  538. $subscription->amount = $obj->subscription;
  539. $subscription->fk_adherent = $obj->rowid;
  540. $adherent->lastname = $obj->lastname;
  541. $adherent->firstname = $obj->firstname;
  542. $adherent->ref = $obj->rowid;
  543. $adherent->id = $obj->rowid;
  544. $adherent->statut = $obj->status;
  545. $adherent->status = $obj->status;
  546. $adherent->login = $obj->login;
  547. $adherent->photo = $obj->photo;
  548. $adherent->gender = $obj->gender;
  549. $adherent->morphy = $obj->morphy;
  550. $adherent->email = $obj->email;
  551. $adherent->typeid = $obj->fk_type;
  552. $adherent->datefin = $db->jdate($obj->datef);
  553. $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
  554. $adht = new AdherentType($db);
  555. $adht->fetch($typeid);
  556. $adherent->need_subscription = $adht->subscription;
  557. if ($mode == 'kanban') {
  558. if ($i == 0) {
  559. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  560. print '<div class="box-flex-container kanban">';
  561. }
  562. // Output Kanban
  563. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  564. $selected = 0;
  565. if (in_array($object->id, $arrayofselected)) {
  566. $selected = 1;
  567. }
  568. }
  569. //fetch informations needs on this mode
  570. if ($obj->fk_account > 0) {
  571. $accountstatic->id = $obj->fk_account;
  572. $accountstatic->fetch($obj->fk_account);
  573. }
  574. // Output Kanban
  575. print $subscription->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected), 'adherent_type' => $adht, 'member' => $adherent, 'bank'=>($obj->fk_account > 0 ? $accountstatic : null)));
  576. if ($i == ($imaxinloop - 1)) {
  577. print '</div>';
  578. print '</td></tr>';
  579. }
  580. } else {
  581. // Show here line of result
  582. $j = 0;
  583. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  584. // Action column
  585. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  586. print '<td class="nowrap center">';
  587. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  588. $selected = 0;
  589. if (in_array($obj->crowid, $arrayofselected)) {
  590. $selected = 1;
  591. }
  592. print '<input id="cb'.$obj->crowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->crowid.'"'.($selected ? ' checked="checked"' : '').'>';
  593. }
  594. print '</td>';
  595. if (!$i) {
  596. $totalarray['nbfield']++;
  597. }
  598. }
  599. // Ref
  600. if (!empty($arrayfields['d.ref']['checked'])) {
  601. print '<td class="nowraponall">'.$subscription->getNomUrl(1).'</td>';
  602. if (!$i) {
  603. $totalarray['nbfield']++;
  604. }
  605. }
  606. // Type
  607. if (!empty($arrayfields['d.fk_type']['checked'])) {
  608. print '<td class="tdoverflowmax100">';
  609. if ($typeid > 0) {
  610. print $adht->getNomUrl(1);
  611. }
  612. print '</td>';
  613. if (!$i) {
  614. $totalarray['nbfield']++;
  615. }
  616. }
  617. // Lastname
  618. if (!empty($arrayfields['d.lastname']['checked'])) {
  619. print '<td class="tdoverflowmax125">'.$adherent->getNomUrl(-1, 0, 'card', 'lastname').'</td>';
  620. if (!$i) {
  621. $totalarray['nbfield']++;
  622. }
  623. }
  624. // Firstname
  625. if (!empty($arrayfields['d.firstname']['checked'])) {
  626. print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($adherent->firstname).'">'.dol_escape_htmltag($adherent->firstname).'</td>';
  627. if (!$i) {
  628. $totalarray['nbfield']++;
  629. }
  630. }
  631. // Login
  632. if (!empty($arrayfields['d.login']['checked'])) {
  633. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->login).'">'.dol_escape_htmltag($adherent->login).'</td>';
  634. if (!$i) {
  635. $totalarray['nbfield']++;
  636. }
  637. }
  638. // Label
  639. if (!empty($arrayfields['t.libelle']['checked'])) {
  640. print '<td class="tdoverflowmax400" title="'.dol_escape_htmltag($obj->note_private).'">';
  641. print dol_escape_htmltag(dolGetFirstLineOfText($obj->note_private));
  642. print '</td>';
  643. if (!$i) {
  644. $totalarray['nbfield']++;
  645. }
  646. }
  647. // Banque
  648. if (!empty($arrayfields['d.bank']['checked'])) {
  649. print '<td class="tdmaxoverflow100">';
  650. if ($obj->fk_account > 0) {
  651. $accountstatic->id = $obj->fk_account;
  652. $accountstatic->fetch($obj->fk_account);
  653. //$accountstatic->label=$obj->label;
  654. print $accountstatic->getNomUrl(1);
  655. }
  656. print "</td>\n";
  657. if (!$i) {
  658. $totalarray['nbfield']++;
  659. }
  660. }
  661. // Date start
  662. if (!empty($arrayfields['c.dateadh']['checked'])) {
  663. print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
  664. if (!$i) {
  665. $totalarray['nbfield']++;
  666. }
  667. }
  668. // Date end
  669. if (!empty($arrayfields['c.datef']['checked'])) {
  670. print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
  671. if (!$i) {
  672. $totalarray['nbfield']++;
  673. }
  674. }
  675. // Price
  676. if (!empty($arrayfields['d.amount']['checked'])) {
  677. print '<td class="right amount">'.price($obj->subscription).'</td>';
  678. if (!$i) {
  679. $totalarray['nbfield']++;
  680. }
  681. if (!$i) {
  682. $totalarray['pos'][$totalarray['nbfield']] = 'd.amount';
  683. }
  684. if (empty($totalarray['val']['d.amount'])) {
  685. $totalarray['val']['d.amount'] = $obj->subscription;
  686. } else {
  687. $totalarray['val']['d.amount'] += $obj->subscription;
  688. }
  689. }
  690. // Extra fields
  691. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  692. // Fields from hook
  693. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  694. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  695. print $hookmanager->resPrint;
  696. // Date creation
  697. if (!empty($arrayfields['c.datec']['checked'])) {
  698. print '<td class="nowrap center">';
  699. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  700. print '</td>';
  701. if (!$i) {
  702. $totalarray['nbfield']++;
  703. }
  704. }
  705. // Date modification
  706. if (!empty($arrayfields['c.tms']['checked'])) {
  707. print '<td class="nowrap center">';
  708. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  709. print '</td>';
  710. if (!$i) {
  711. $totalarray['nbfield']++;
  712. }
  713. }
  714. // Action column
  715. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  716. print '<td class="nowrap center">';
  717. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  718. $selected = 0;
  719. if (in_array($obj->crowid, $arrayofselected)) {
  720. $selected = 1;
  721. }
  722. print '<input id="cb'.$obj->crowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->crowid.'"'.($selected ? ' checked="checked"' : '').'>';
  723. }
  724. print '</td>';
  725. if (!$i) {
  726. $totalarray['nbfield']++;
  727. }
  728. }
  729. print '</tr>'."\n";
  730. }
  731. $i++;
  732. }
  733. // Show total line
  734. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  735. // If no record found
  736. if ($num == 0) {
  737. $colspan = 1;
  738. foreach ($arrayfields as $key => $val) {
  739. if (!empty($val['checked'])) {
  740. $colspan++;
  741. }
  742. }
  743. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  744. }
  745. $db->free($resql);
  746. $parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql);
  747. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  748. print $hookmanager->resPrint;
  749. print '</table>'."\n";
  750. print '</div>'."\n";
  751. print '</form>'."\n";
  752. // End of page
  753. llxFooter();
  754. $db->close();