partnership_list.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053
  1. <?php
  2. /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file partnership_list.php
  20. * \ingroup partnership
  21. * \brief List page for partnership
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
  32. // for other modules
  33. //dol_include_once('/othermodule/class/otherobject.class.php');
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("partnership", "members", "other"));
  36. $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
  37. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  38. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  39. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  40. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  41. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  42. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  43. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  44. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  45. $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
  46. $id = GETPOST('id', 'int');
  47. $socid = GETPOST('socid', 'int');
  48. $memberid = GETPOST('rowid', 'int');
  49. // Load variable for pagination
  50. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  51. $sortfield = GETPOST('sortfield', 'aZ09comma');
  52. $sortorder = GETPOST('sortorder', 'aZ09comma');
  53. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  54. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  55. // If $page is not defined, or '' or -1 or if we click on clear filters
  56. $page = 0;
  57. }
  58. $offset = $limit * $page;
  59. $pageprev = $page - 1;
  60. $pagenext = $page + 1;
  61. // Initialize technical objects
  62. $object = new Partnership($db);
  63. $extrafields = new ExtraFields($db);
  64. $adherent = new Adherent($db);
  65. $diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
  66. if ($socid > 0) {
  67. $hookmanager->initHooks(array('thirdpartypartnership'));
  68. } elseif ($memberid > 0) {
  69. $hookmanager->initHooks(array('memberpartnership'));
  70. } else {
  71. $hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array
  72. }
  73. // Fetch optionals attributes and labels
  74. $extrafields->fetch_name_optionals_label($object->table_element);
  75. //$extrafields->fetch_name_optionals_label($object->table_element_line);
  76. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  77. $error = 0;
  78. $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty');
  79. if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = '';
  80. // Default sort order (if not yet defined by previous GETPOST)
  81. if (!$sortfield) {
  82. reset($object->fields); // Reset is required to avoid key() to return null.
  83. $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
  84. }
  85. if (!$sortorder) {
  86. $sortorder = "ASC";
  87. }
  88. // Initialize array of search criterias
  89. $search_all = GETPOST('search_all', 'alphanohtml');
  90. $search = array();
  91. foreach ($object->fields as $key => $val) {
  92. if (GETPOST('search_'.$key, 'alpha') !== '') {
  93. $search[$key] = GETPOST('search_'.$key, 'alpha');
  94. }
  95. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  96. $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
  97. $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
  98. }
  99. }
  100. $search_filter = GETPOST("search_filter", 'alpha');
  101. $filter = GETPOST("filter", 'alpha');
  102. if ($filter) {
  103. $search_filter = $filter; // For backward compatibility
  104. }
  105. // List of fields to search into when doing a "search in all"
  106. $fieldstosearchall = array();
  107. foreach ($object->fields as $key => $val) {
  108. if (!empty($val['searchall'])) {
  109. $fieldstosearchall['t.'.$key] = $val['label'];
  110. }
  111. }
  112. // Definition of array of fields for columns
  113. $arrayfields = array();
  114. foreach ($object->fields as $key => $val) {
  115. // If $val['visible']==0, then we never show the field
  116. if (!empty($val['visible'])) {
  117. $visible = (int) dol_eval($val['visible'], 1);
  118. $arrayfields['t.'.$key] = array(
  119. 'label'=>$val['label'],
  120. 'checked'=>(($visible < 0) ? 0 : 1),
  121. 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
  122. 'position'=>$val['position'],
  123. 'help'=> isset($val['help']) ? $val['help'] : ''
  124. );
  125. }
  126. }
  127. // Extra fields
  128. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  129. $object->fields = dol_sort_array($object->fields, 'position');
  130. $arrayfields = dol_sort_array($arrayfields, 'position');
  131. $permissiontoread = $user->rights->partnership->read;
  132. $permissiontoadd = $user->rights->partnership->write;
  133. $permissiontodelete = $user->rights->partnership->delete;
  134. // Security check - Protection if external user
  135. //if ($user->socid > 0) accessforbidden();
  136. //if ($user->socid > 0) $socid = $user->socid;
  137. //$result = restrictedArea($user, 'partnership', $object->id);
  138. if (empty($conf->partnership->enabled)) accessforbidden();
  139. if (empty($permissiontoread)) accessforbidden();
  140. if ($object->id > 0 && !($object->fk_member > 0) && $managedfor == 'member') accessforbidden();
  141. if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor == 'thirdparty') accessforbidden();
  142. /*
  143. * Actions
  144. */
  145. if (GETPOST('cancel', 'alpha')) {
  146. $action = 'list';
  147. $massaction = '';
  148. }
  149. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  150. $massaction = '';
  151. }
  152. $parameters = array();
  153. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  154. if ($reshook < 0) {
  155. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  156. }
  157. if (empty($reshook)) {
  158. // Selection of new fields
  159. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  160. // Purge search criteria
  161. 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
  162. foreach ($object->fields as $key => $val) {
  163. $search[$key] = '';
  164. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  165. $search[$key.'_dtstart'] = '';
  166. $search[$key.'_dtend'] = '';
  167. }
  168. }
  169. $toselect = array();
  170. $search_array_options = array();
  171. }
  172. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  173. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  174. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  175. }
  176. // Mass actions
  177. $objectclass = 'Partnership';
  178. $objectlabel = 'Partnership';
  179. $uploaddir = $conf->partnership->dir_output;
  180. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  181. // Validate and approve
  182. if (!$error && $massaction == 'approve' && $permissiontoadd) {
  183. $objecttmp = new Partnership($db);
  184. $db->begin();
  185. $error = 0;
  186. $result = 0;
  187. foreach ($toselect as $checked) {
  188. if ($objecttmp->fetch($checked)) {
  189. if ($objecttmp->status == $objecttmp::STATUS_DRAFT) {
  190. //$objecttmp->date = dol_now();
  191. $result = $objecttmp->validate($user);
  192. }
  193. if ($result >= 0 && $objecttmp->status == $objecttmp::STATUS_VALIDATED) {
  194. $result = $objecttmp->approve($user);
  195. if ($result > 0) {
  196. setEventMessages($langs->trans("PartnershipRefApproved", $objecttmp->ref), null);
  197. } else {
  198. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  199. $error++;
  200. }
  201. } else {
  202. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  203. $error++;
  204. }
  205. }
  206. }
  207. if (!$error) {
  208. $db->commit();
  209. } else {
  210. $db->rollback();
  211. }
  212. }
  213. // Cancel partnership
  214. if ($massaction == 'cancel' && $permissiontoadd) {
  215. $db->begin();
  216. $objecttmp = new $objectclass($db);
  217. $nbok = 0;
  218. foreach ($toselect as $toselectid) {
  219. $result = $objecttmp->fetch($toselectid);
  220. if ($result > 0) {
  221. $result = $objecttmp->cancel($user, 0);
  222. if ($result == 0) {
  223. setEventMessages($langs->trans('StatusOfRefMustBe', $objecttmp->ref, $objecttmp->LibStatut($objecttmp::STATUS_APPROVED)), null, 'warnings');
  224. $error++;
  225. } elseif ($result <= 0) {
  226. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  227. $error++;
  228. break;
  229. } else {
  230. $nbok++;
  231. }
  232. } else {
  233. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  234. $error++;
  235. break;
  236. }
  237. }
  238. if (!$error) {
  239. setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
  240. $db->commit();
  241. } else {
  242. $db->rollback();
  243. }
  244. }
  245. }
  246. /*
  247. * View
  248. */
  249. $form = new Form($db);
  250. $now = dol_now();
  251. //$help_url="EN:Module_Partnership|FR:Module_Partnership_FR|ES:Módulo_Partnership";
  252. $help_url = '';
  253. $title = $langs->trans("Partnerships");
  254. $morejs = array();
  255. $morecss = array();
  256. // Build and execute select
  257. // --------------------------------------------------------------------
  258. $sql = 'SELECT ';
  259. $sql .= $object->getFieldList('t');
  260. if ($managedfor == 'member') {
  261. $sql .= ', d.datefin, d.fk_adherent_type, dty.subscription';
  262. }
  263. // Add fields from extrafields
  264. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  265. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  266. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  267. }
  268. }
  269. // Add fields from hooks
  270. $parameters = array();
  271. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  272. $sql .= $hookmanager->resPrint;
  273. $sql = preg_replace('/,\s*$/', '', $sql);
  274. $sqlfields = $sql; // $sql fields to remove for count total
  275. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
  276. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  277. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
  278. }
  279. if ($managedfor == 'member') {
  280. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)";
  281. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)";
  282. }
  283. // Add table from hooks
  284. $parameters = array();
  285. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  286. $sql .= $hookmanager->resPrint;
  287. if ($object->ismultientitymanaged == 1) {
  288. $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
  289. } else {
  290. $sql .= " WHERE 1 = 1";
  291. }
  292. if ($managedfor == 'member') {
  293. if ($memberid > 0) {
  294. $sql .= " AND t.fk_member = ".((int) $memberid);
  295. } else {
  296. $sql .= " AND fk_member > 0";
  297. }
  298. } else {
  299. if ($socid > 0) {
  300. $sql .= " AND t.fk_soc = ".((int) $socid);
  301. } else {
  302. $sql .= " AND fk_soc > 0";
  303. }
  304. }
  305. foreach ($search as $key => $val) {
  306. if (array_key_exists($key, $object->fields)) {
  307. if ($key == 'status' && $search[$key] == -1) {
  308. continue;
  309. }
  310. $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
  311. if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
  312. if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
  313. $search[$key] = '';
  314. }
  315. $mode_search = 2;
  316. }
  317. if ($search[$key] != '') {
  318. $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
  319. }
  320. } else {
  321. if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
  322. $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
  323. if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
  324. if (preg_match('/_dtstart$/', $key)) {
  325. $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
  326. }
  327. if (preg_match('/_dtend$/', $key)) {
  328. $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
  329. }
  330. }
  331. }
  332. }
  333. }
  334. if ($managedfor == 'member') {
  335. if ($search_filter == 'withoutsubscription') {
  336. $sql .= " AND (d.datefin IS NULL)";
  337. }
  338. if ($search_filter == 'waitingsubscription') {
  339. $sql .= " AND (d.datefin IS NULL AND t.subscription = '1')";
  340. }
  341. if ($search_filter == 'uptodate') {
  342. $sql .= " AND (d.datefin >= '".$db->idate($now)."' OR dty.subscription = '0')";
  343. }
  344. if ($search_filter == 'outofdate') {
  345. $sql .= " AND (d.datefin < '".$db->idate($now)."' AND dty.subscription = '1')";
  346. }
  347. }
  348. if ($search_all) {
  349. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  350. }
  351. //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
  352. // Add where from extra fields
  353. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  354. // Add where from hooks
  355. $parameters = array();
  356. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  357. $sql .= $hookmanager->resPrint;
  358. /* If a group by is required
  359. $sql.= " GROUP BY ";
  360. foreach($object->fields as $key => $val) {
  361. $sql .= "t.".$db->escape($key).", ";
  362. }
  363. // Add fields from extrafields
  364. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  365. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  366. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
  367. }
  368. }
  369. // Add where from hooks
  370. $parameters=array();
  371. $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook
  372. $sql.=$hookmanager->resPrint;
  373. $sql=preg_replace('/,\s*$/','', $sql);
  374. */
  375. // Count total nb of records
  376. $nbtotalofrecords = '';
  377. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  378. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  379. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  380. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  381. $resql = $db->query($sqlforcount);
  382. if ($resql) {
  383. $objforcount = $db->fetch_object($resql);
  384. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  385. } else {
  386. dol_print_error($db);
  387. }
  388. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  389. $page = 0;
  390. $offset = 0;
  391. }
  392. $db->free($resql);
  393. }
  394. // Complete request and execute it with limit
  395. $sql .= $db->order($sortfield, $sortorder);
  396. if ($limit) {
  397. $sql .= $db->plimit($limit + 1, $offset);
  398. }
  399. $resql = $db->query($sql);
  400. if (!$resql) {
  401. dol_print_error($db);
  402. exit;
  403. }
  404. $num = $db->num_rows($resql);
  405. // Direct jump if only one record found
  406. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  407. $obj = $db->fetch_object($resql);
  408. $id = $obj->rowid;
  409. header("Location: ".dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$id);
  410. exit;
  411. }
  412. // Output page
  413. // --------------------------------------------------------------------
  414. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
  415. if ($managedfor == "member") {
  416. if ($memberid > 0 && $user->hasRight('adherent', 'lire')) {
  417. $langs->load("members");
  418. $adhstat = new Adherent($db);
  419. $adht = new AdherentType($db);
  420. $result = $adhstat->fetch($memberid);
  421. if (isModEnabled('notification')) {
  422. $langs->load("mails");
  423. }
  424. $adht->fetch($adhstat->typeid);
  425. $head = member_prepare_head($adhstat);
  426. print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'user');
  427. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  428. dol_banner_tab($object, 'rowid', $linkback);
  429. print '<div class="fichecenter">';
  430. print '<div class="underbanner clearboth"></div>';
  431. print '<table class="border centpercent tableforfield">';
  432. // Login
  433. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
  434. print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
  435. }
  436. // Type
  437. print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
  438. // Morphy
  439. print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$adhstat->getmorphylib().'</td>';
  440. print '</tr>';
  441. // Company
  442. print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$adhstat->company.'</td></tr>';
  443. // Civility
  444. print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$adhstat->getCivilityLabel().'&nbsp;</td>';
  445. print '</tr>';
  446. print '</table>';
  447. print '</div>';
  448. print dol_get_fiche_end();
  449. }
  450. } elseif ($managedfor == "thirdparty") {
  451. if ($socid && $user->hasRight('societe', 'lire')) {
  452. $socstat = new Societe($db);
  453. $res = $socstat->fetch($socid);
  454. if ($res > 0) {
  455. $tmpobject = $object;
  456. $object = $socstat; // $object must be of type Societe when calling societe_prepare_head
  457. $head = societe_prepare_head($socstat);
  458. $object = $tmpobject;
  459. print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'company');
  460. dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
  461. print '<div class="fichecenter">';
  462. print '<div class="underbanner clearboth"></div>';
  463. print '<table class="border centpercent tableforfield">';
  464. // Type Prospect/Customer/Supplier
  465. print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
  466. print $socstat->getTypeUrl(1);
  467. print '</td></tr>';
  468. // Customer code
  469. if ($socstat->client && !empty($socstat->code_client)) {
  470. print '<tr><td class="titlefield">';
  471. print $langs->trans('CustomerCode').'</td><td>';
  472. print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
  473. $tmpcheck = $socstat->check_codeclient();
  474. if ($tmpcheck != 0 && $tmpcheck != -5) {
  475. print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
  476. }
  477. print '</td>';
  478. print '</tr>';
  479. }
  480. // Supplier code
  481. if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
  482. print '<tr><td class="titlefield">';
  483. print $langs->trans('SupplierCode').'</td><td>';
  484. print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
  485. $tmpcheck = $socstat->check_codefournisseur();
  486. if ($tmpcheck != 0 && $tmpcheck != -5) {
  487. print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
  488. }
  489. print '</td>';
  490. print '</tr>';
  491. }
  492. print '</table>';
  493. print '</div>';
  494. print dol_get_fiche_end();
  495. }
  496. }
  497. }
  498. $arrayofselected = is_array($toselect) ? $toselect : array();
  499. $param = '';
  500. if (!empty($mode)) {
  501. $param .= '&mode='.urlencode($mode);
  502. }
  503. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  504. $param .= '&contextpage='.urlencode($contextpage);
  505. }
  506. if ($limit > 0 && $limit != $conf->liste_limit) {
  507. $param .= '&limit='.((int) $limit);
  508. }
  509. if ($socid) {
  510. $param .= '&socid='.urlencode($socid);
  511. }
  512. if ($memberid) {
  513. $param .= '&rowid='.urlencode($memberid);
  514. }
  515. foreach ($search as $key => $val) {
  516. if (is_array($search[$key])) {
  517. foreach ($search[$key] as $skey) {
  518. if ($skey != '') {
  519. $param .= '&search_'.$key.'[]='.urlencode($skey);
  520. }
  521. }
  522. } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
  523. $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
  524. $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
  525. $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
  526. } elseif ($search[$key] != '') {
  527. $param .= '&search_'.$key.'='.urlencode($search[$key]);
  528. }
  529. }
  530. if ($optioncss != '') {
  531. $param .= '&optioncss='.urlencode($optioncss);
  532. }
  533. if ($search_filter && $search_filter != '-1') {
  534. $param .= "&search_filter=".urlencode($search_filter);
  535. }
  536. // Add $param from extra fields
  537. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  538. // Add $param from hooks
  539. $parameters = array();
  540. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
  541. $param .= $hookmanager->resPrint;
  542. // List of mass actions available
  543. $arrayofmassactions = array(
  544. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  545. 'approve'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove"),
  546. 'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"),
  547. //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"),
  548. //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"),
  549. 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"),
  550. );
  551. if ($permissiontodelete) {
  552. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  553. }
  554. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('prevalidate', 'presend', 'predelete'))) {
  555. $arrayofmassactions = array();
  556. }
  557. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  558. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  559. if ($optioncss != '') {
  560. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  561. }
  562. print '<input type="hidden" name="token" value="'.newToken().'">';
  563. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  564. print '<input type="hidden" name="action" value="list">';
  565. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  566. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  567. print '<input type="hidden" name="page" value="'.$page.'">';
  568. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  569. print '<input type="hidden" name="page_y" value="">';
  570. print '<input type="hidden" name="mode" value="'.$mode.'">';
  571. if ($socid) {
  572. print '<input type="hidden" name="socid" value="'.$socid.'" >';
  573. } elseif ($memberid) {
  574. print '<input type="hidden" name="rowid" value="'.$memberid.'" >';
  575. }
  576. $newcardbutton = '';
  577. $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'));
  578. $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'));
  579. $newcardbutton .= dolGetButtonTitleSeparator();
  580. $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/partnership/partnership_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
  581. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  582. // Add code for pre mass action (confirmation or email presend form)
  583. $topicmail = "SendPartnershipRef";
  584. $modelmail = "partnership_send";
  585. $objecttmp = new Partnership($db);
  586. $trackid = 'pship'.$object->id;
  587. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  588. if ($search_all) {
  589. $setupstring = '';
  590. foreach ($fieldstosearchall as $key => $val) {
  591. $fieldstosearchall[$key] = $langs->trans($val);
  592. $setupstring .= $key."=".$val.";";
  593. }
  594. print '<!-- Search done like if PARTNERSHIP_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  595. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
  596. }
  597. $moreforfilter = '';
  598. /*$moreforfilter.='<div class="divsearchfield">';
  599. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  600. $moreforfilter.= '</div>';*/
  601. $parameters = array();
  602. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  603. if (empty($reshook)) {
  604. $moreforfilter .= $hookmanager->resPrint;
  605. } else {
  606. $moreforfilter = $hookmanager->resPrint;
  607. }
  608. if (!empty($moreforfilter)) {
  609. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  610. print $moreforfilter;
  611. $parameters = array('type'=>$type);
  612. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  613. print $hookmanager->resPrint;
  614. print '</div>';
  615. }
  616. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  617. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
  618. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  619. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  620. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  621. if ($managedfor == 'member') {
  622. $arrayfields['t.fk_member']['checked'] = 1;
  623. } else {
  624. $arrayfields['t.fk_soc']['checked'] = 1;
  625. }
  626. // Fields title search
  627. // --------------------------------------------------------------------
  628. print '<tr class="liste_titre_filter">';
  629. // Action column
  630. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  631. print '<td class="liste_titre maxwidthsearch">';
  632. $searchpicto = $form->showFilterButtons('left');
  633. print $searchpicto;
  634. print '</td>';
  635. }
  636. foreach ($object->fields as $key => $val) {
  637. $searchkey = empty($search[$key]) ? '' : $search[$key];
  638. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  639. if ($key == 'status') {
  640. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  641. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  642. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  643. } elseif (in_array($val['type'], array('timestamp'))) {
  644. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  645. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  646. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  647. }
  648. if (!empty($arrayfields['t.'.$key]['checked'])) {
  649. print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
  650. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  651. print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
  652. } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
  653. print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
  654. } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  655. print '<div class="nowrap">';
  656. print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  657. print '</div>';
  658. print '<div class="nowrap">';
  659. print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  660. print '</div>';
  661. } elseif ($key == 'lang') {
  662. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  663. $formadmin = new FormAdmin($db);
  664. print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
  665. } else {
  666. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  667. }
  668. print '</td>';
  669. }
  670. }
  671. // End of subscription date
  672. if ($managedfor == 'member') {
  673. print '<td class="liste_titre center">';
  674. $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
  675. print $form->selectarray('search_filter', $selectarray, $search_filter);
  676. print '</td>';
  677. }
  678. // Extra fields
  679. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  680. // Fields from hook
  681. $parameters = array('arrayfields'=>$arrayfields);
  682. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  683. print $hookmanager->resPrint;
  684. // Action column
  685. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  686. print '<td class="liste_titre maxwidthsearch">';
  687. $searchpicto = $form->showFilterButtons();
  688. print $searchpicto;
  689. print '</td>';
  690. }
  691. print '</tr>'."\n";
  692. $totalarray = array();
  693. $totalarray['nbfield'] = 0;
  694. // Fields title label
  695. // --------------------------------------------------------------------
  696. print '<tr class="liste_titre">';
  697. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  698. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  699. $totalarray['nbfield']++; // For the column action
  700. }
  701. foreach ($object->fields as $key => $val) {
  702. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  703. if ($key == 'status') {
  704. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  705. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  706. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  707. } elseif (in_array($val['type'], array('timestamp'))) {
  708. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  709. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  710. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  711. }
  712. $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
  713. if (!empty($arrayfields['t.'.$key]['checked'])) {
  714. print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
  715. $totalarray['nbfield']++;
  716. }
  717. }
  718. // End of subscription date
  719. if ($managedfor == 'member') {
  720. $key = 'datefin';
  721. $cssforfield = 'center';
  722. print getTitleFieldOfList('SubscriptionEndDate', 0, $_SERVER['PHP_SELF'], 'd.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
  723. }
  724. // Extra fields
  725. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  726. // Hook fields
  727. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  728. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  729. print $hookmanager->resPrint;
  730. // Action column
  731. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  732. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  733. $totalarray['nbfield']++; // For the column action
  734. }
  735. print '</tr>'."\n";
  736. // Detect if we need a fetch on each output line
  737. $needToFetchEachLine = 0;
  738. if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  739. foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  740. if ($val && preg_match('/\$object/', $val)) {
  741. $needToFetchEachLine++; // There is at least one compute field that use $object
  742. }
  743. }
  744. }
  745. // Loop on record
  746. // --------------------------------------------------------------------
  747. $i = 0;
  748. $savnbfield = $totalarray['nbfield'];
  749. $totalarray = array();
  750. $totalarray['nbfield'] = 0;
  751. $imaxinloop = ($limit ? min($num, $limit) : $num);
  752. while ($i < $imaxinloop) {
  753. $obj = $db->fetch_object($resql);
  754. if (empty($obj)) {
  755. break; // Should not happen
  756. }
  757. // Store properties in $object
  758. $object->setVarsFromFetchObj($obj);
  759. if ($mode == 'kanban') {
  760. if ($i == 0) {
  761. print '<tr><td colspan="'.$savnbfield.'">';
  762. print '<div class="box-flex-container kanban">';
  763. }
  764. // Output Kanban
  765. print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
  766. if ($i == ($imaxinloop - 1)) {
  767. print '</div>';
  768. print '</td></tr>';
  769. }
  770. } else {
  771. // Show here line of result
  772. $j = 0;
  773. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  774. // Action column
  775. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  776. print '<td class="nowrap center">';
  777. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  778. $selected = 0;
  779. if (in_array($object->id, $arrayofselected)) {
  780. $selected = 1;
  781. }
  782. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  783. }
  784. print '</td>';
  785. if (!$i) {
  786. $totalarray['nbfield']++;
  787. }
  788. }
  789. foreach ($object->fields as $key => $val) {
  790. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  791. if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  792. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  793. } elseif ($key == 'status') {
  794. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  795. }
  796. if (in_array($val['type'], array('timestamp'))) {
  797. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  798. } elseif ($key == 'ref') {
  799. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  800. }
  801. if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
  802. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  803. }
  804. //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
  805. if (!empty($arrayfields['t.'.$key]['checked'])) {
  806. print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
  807. if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
  808. print ' title="'.dol_escape_htmltag($object->$key).'"';
  809. }
  810. print '>';
  811. if ($key == 'status') {
  812. print $object->getLibStatut(5);
  813. } elseif ($key == 'rowid') {
  814. print $object->showOutputField($val, $key, $object->id, '');
  815. } else {
  816. print $object->showOutputField($val, $key, $object->$key, '');
  817. }
  818. print '</td>';
  819. if (!$i) {
  820. $totalarray['nbfield']++;
  821. }
  822. if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
  823. if (!$i) {
  824. $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
  825. }
  826. if (!isset($totalarray['val'])) {
  827. $totalarray['val'] = array();
  828. }
  829. if (!isset($totalarray['val']['t.'.$key])) {
  830. $totalarray['val']['t.'.$key] = 0;
  831. }
  832. $totalarray['val']['t.'.$key] += $object->$key;
  833. }
  834. }
  835. }
  836. // End of subscription date
  837. if ($managedfor == 'member') {
  838. print '<td class="nowrap center endofsubscriptiondate">';
  839. $result = $adherent->fetch($object->fk_member);
  840. if ($result) {
  841. $datefin = $adherent->datefin;
  842. if ($datefin) {
  843. print dol_print_date($datefin, 'day');
  844. if ($adherent->hasDelay()) {
  845. $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')';
  846. print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
  847. }
  848. } else {
  849. if ($adherent->subscription == 'yes') {
  850. print $langs->trans("SubscriptionNotReceived");
  851. if ($adherent->statut > 0) {
  852. print " ".img_warning();
  853. }
  854. } else {
  855. print '&nbsp;';
  856. }
  857. }
  858. }
  859. print '</td>';
  860. }
  861. // Extra fields
  862. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  863. // Fields from hook
  864. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  865. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  866. print $hookmanager->resPrint;
  867. // Action column
  868. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  869. print '<td class="nowrap center">';
  870. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  871. $selected = 0;
  872. if (in_array($object->id, $arrayofselected)) {
  873. $selected = 1;
  874. }
  875. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  876. }
  877. print '</td>';
  878. if (!$i) {
  879. $totalarray['nbfield']++;
  880. }
  881. }
  882. print '</tr>'."\n";
  883. }
  884. $i++;
  885. }
  886. if ($managedfor != 'member') {
  887. $totalarray['nbfield']++; // End of subscription date
  888. }
  889. // Show total line
  890. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  891. // If no record found
  892. if ($num == 0) {
  893. $colspan = 1;
  894. foreach ($arrayfields as $key => $val) {
  895. if (!empty($val['checked'])) {
  896. $colspan++;
  897. }
  898. }
  899. if ($managedfor != 'member') {
  900. $colspan++; // End of subscription date
  901. }
  902. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  903. }
  904. $db->free($resql);
  905. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  906. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  907. print $hookmanager->resPrint;
  908. print '</table>'."\n";
  909. print '</div>'."\n";
  910. print '</form>'."\n";
  911. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  912. $hidegeneratedfilelistifempty = 1;
  913. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  914. $hidegeneratedfilelistifempty = 0;
  915. }
  916. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  917. $formfile = new FormFile($db);
  918. // Show list of available documents
  919. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  920. $urlsource .= str_replace('&amp;', '&', $param);
  921. $filedir = $diroutputmassaction;
  922. $genallowed = $permissiontoread;
  923. $delallowed = $permissiontoadd;
  924. print $formfile->showdocuments('massfilesarea_partnership', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  925. }
  926. // End of page
  927. llxFooter();
  928. $db->close();