dolibarr 24.0.0-beta
partnership_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
4 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
42require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
43require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
44require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array("partnership", "members", "other"));
48
49$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
50$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
51$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
52$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
53$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
54$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
56$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
57$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
58$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
59
60$id = GETPOSTINT('id');
61$socid = GETPOSTINT('socid');
62$memberid = GETPOSTINT('rowid');
63// Load variable for pagination
64$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
65$sortfield = GETPOST('sortfield', 'aZ09comma');
66$sortorder = GETPOST('sortorder', 'aZ09comma');
67$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
68if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
69 // If $page is not defined, or '' or -1 or if we click on clear filters
70 $page = 0;
71}
72$offset = $limit * $page;
73$pageprev = $page - 1;
74$pagenext = $page + 1;
75
76// Initialize technical objects
78
79$adherent = new Adherent($db);
80$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
81if ($socid > 0) {
82 $hookmanager->initHooks(array('thirdpartypartnership', 'globalcard'));
83} elseif ($memberid > 0) {
84 $hookmanager->initHooks(array('memberpartnership', 'globalcard'));
85} else {
86 $hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array
87}
88
89// Fetch optionals attributes and labels
90$extrafields->fetch_name_optionals_label($object->table_element);
91//$extrafields->fetch_name_optionals_label($object->table_element_line);
92
93$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
94
95$error = 0;
96
97$managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty');
98
99if ($sortfield == 'd.datefin') {
100 if ($managedfor != 'member' && !isModEnabled('member')) {
101 $sortfield = '';
102 }
103}
104
105// Add non object fields to fields for list
106$non_object_fields = array(
107 'town' => array('type' => 'varchar(128)', 'label' => 'Town', 'enabled' => 1, 'position' => 51, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1, 'searchall' => 1,),
108 'country' => array('type' => 'integer', 'label' => 'Country', 'enabled' => 1, 'position' => 52, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'searchall' => 1,),
109 // Field to add member when link is through thirdparty membership then member link
110 'fk_soc_member' => array('type' => 'custom', 'label' => 'Member', 'visible' => -1, 'enabled' => ($managedfor != 'member' && isModEnabled('member')), 'picto' => 'member', 'csslist' => 'tdoverflowmax125', 'position' => 54),
111 // Field to show when partnership linked to member or thirdparty
112 'fk_soc_dateend' => array('type' => 'custom', 'label' => 'DateEndSubscription', 'visible' => -1, 'enabled' => ($managedfor == 'member' || isModEnabled('member')), 'picto' => 'member', 'csslist' => 'center', 'position' => 55)
113);
114//$arrayfields['fk_soc_member'] = array('type' => 'varchar', 'label' => 'Member', 'checked' => -1, 'enabled' => 1, 'picto' => 'member', 'csslist' => 'tdoverflowmax125', 'position' => 51);
115//var_dump($arrayfields);
116
117
118// All fields in list
119$all_fields_list = array_merge($object->fields, $non_object_fields);
120
121// Default sort order (if not yet defined by previous GETPOST)
122if (!$sortfield) {
123 reset($all_fields_list); // Reset is required to avoid key() to return null.
124 $sortfield = "t.".key($all_fields_list); // Set here default search field. By default 1st field in definition.
125}
126if (!$sortorder) {
127 $sortorder = "ASC";
128}
129
130// Initialize array of search criteria
131$search_all = trim(GETPOST('search_all', 'alphanohtml'));
132$search = array();
133foreach ($all_fields_list as $key => $val) {
134 if (GETPOST('search_'.$key, 'alpha') !== '') {
135 $search[$key] = GETPOST('search_'.$key, 'alpha');
136 }
137 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
138 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
139 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
140 }
141}
142$search_filter = GETPOST("search_filter", 'alpha');
143$filter = GETPOST("filter", 'alpha');
144if ($filter) {
145 $search_filter = $filter; // For backward compatibility
146}
147
148// List of fields to search into when doing a "search in all"
149$fieldstosearchall = array();
150foreach ($non_object_fields as $key => $val) {
151 if (!empty($val['searchall'])) {
152 $fieldstosearchall['t.'.$key] = $val['label'];
153 }
154}
155
156// Definition of array of fields for columns from ->fields
157$tableprefix = 't';
158$arrayfields = array();
159foreach ($all_fields_list as $key => $val) {
160 // If $val['visible']==0, then we never show the field
161 if (!empty($val['visible'])) {
162 $visible = (int) dol_eval((string) $val['visible'], 1);
163 $arrayfields[$tableprefix.'.'.$key] = array(
164 'label' => $val['label'],
165 'checked' => (($visible < 0) ? '0' : '1'),
166 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
167 'position' => $val['position'],
168 'help' => isset($val['help']) ? $val['help'] : ''
169 );
170 }
171}
172// Extra fields
173include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
174
175$object->fields = dol_sort_array($object->fields, 'position');
176$arrayfields = dol_sort_array($arrayfields, 'position');
177$all_fields_list = dol_sort_array($all_fields_list, 'position');
178
179$permissiontoread = $user->hasRight('partnership', 'read');
180$permissiontoadd = $user->hasRight('partnership', 'write');
181$permissiontodelete = $user->hasRight('partnership', 'delete');
182
183// Security check - Protection if external user
184//if ($user->socid > 0) accessforbidden();
185//if ($user->socid > 0) $socid = $user->socid;
186//restrictedArea($user, 'partnership', $object->id);
187if (empty($conf->partnership->enabled)) {
189}
190if (empty($permissiontoread)) {
192}
193if ($object->id > 0 && !($object->fk_member > 0) && $managedfor == 'member') {
195}
196if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor == 'thirdparty') {
198}
199
200
201/*
202 * Actions
203 */
204
205if (GETPOST('cancel', 'alpha')) {
206 $action = 'list';
207 $massaction = '';
208}
209if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
210 $massaction = '';
211}
212
213$parameters = array('socid' => $socid);
214$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
215if ($reshook < 0) {
216 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
217}
218
219if (empty($reshook)) {
220 // Selection of new fields
221 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
222
223 // Purge search criteria
224 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
225 foreach ($all_fields_list as $key => $val) {
226 $search[$key] = '';
227 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
228 $search[$key.'_dtstart'] = '';
229 $search[$key.'_dtend'] = '';
230 }
231 }
232 $toselect = array();
233 $search_array_options = array();
234 }
235 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
236 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
237 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
238 }
239
240 // Mass actions
241 $objectclass = 'Partnership';
242 $objectlabel = 'Partnership';
243 $uploaddir = $conf->partnership->dir_output;
244 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
245
246 // Validate and approve
247 if (!$error && $massaction == 'approve' && $permissiontoadd) {
248 $objecttmp = new Partnership($db);
249
250 $db->begin();
251 $error = 0;
252 $result = 0;
253
254 foreach ($toselect as $checked) {
255 if ($objecttmp->fetch($checked)) {
256 if ($objecttmp->status == $objecttmp::STATUS_DRAFT) {
257 //$objecttmp->date = dol_now();
258 $result = $objecttmp->validate($user);
259 }
260
261 if ($result >= 0 && $objecttmp->status == $objecttmp::STATUS_VALIDATED) {
262 $result = $objecttmp->approve($user);
263 if ($result > 0) {
264 setEventMessages($langs->trans("PartnershipRefApproved", $objecttmp->ref), null);
265 } else {
266 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
267 $error++;
268 }
269 } else {
270 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
271 $error++;
272 }
273 }
274 }
275
276 if (!$error) {
277 $db->commit();
278 } else {
279 $db->rollback();
280 }
281 }
282
283 // Cancel partnership
284 if ($massaction == 'cancel' && $permissiontoadd) {
285 $db->begin();
286
287 $objecttmp = new $objectclass($db);
288 $nbok = 0;
289 foreach ($toselect as $toselectid) {
290 $result = $objecttmp->fetch($toselectid);
291 if ($result > 0) {
292 $result = $objecttmp->cancel($user, 0);
293 if ($result == 0) {
294 setEventMessages($langs->trans('StatusOfRefMustBe', $objecttmp->ref, $objecttmp->LibStatut($objecttmp::STATUS_APPROVED)), null, 'warnings');
295 $error++;
296 } elseif ($result <= 0) {
297 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
298 $error++;
299 break;
300 } else {
301 $nbok++;
302 }
303 } else {
304 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
305 $error++;
306 break;
307 }
308 }
309
310 if (!$error) {
311 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
312 $db->commit();
313 } else {
314 $db->rollback();
315 }
316 }
317}
318
319
320
321/*
322 * View
323 */
324
325$form = new Form($db);
326$companystatic = new Societe($db);
327
328$now = dol_now();
329
330//$help_url="EN:Module_Partnership|FR:Module_Partnership_FR|ES:Módulo_Partnership";
331$help_url = '';
332$title = $langs->trans("Partnerships");
333$morejs = array();
334$morecss = array();
335
336
337// Build and execute select
338// --------------------------------------------------------------------
339$sql = 'SELECT ';
340$sql .= $object->getFieldList('t');
341if ($managedfor == 'member') {
342 $sql .= ', d.rowid as memberid, d.lastname, d.firstname, d.datefin, d.fk_adherent_type, dty.subscription';
343}
344if ($managedfor == 'thirdparty' && isModEnabled('member')) {
345 $sql .= ', d.rowid as memberid, d.lastname, d.firstname, d.datefin, d.fk_adherent_type, dty.subscription';
346}
347// Add fields from extrafields
348if (!empty($extrafields->attributes[$object->table_element]['label'])) {
349 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
350 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
351 }
352}
353// Add fields from hooks
354$parameters = array();
355$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
356$sql .= $hookmanager->resPrint;
357$sql = preg_replace('/,\s*$/', '', $sql);
358
359$sqlfields = $sql; // $sql fields to remove for count total
360
361$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
362if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
363 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
364}
365if ($managedfor == 'member') {
366 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)";
367 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)";
368} else {
369 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = t.fk_soc)";
370 if ($managedfor == 'thirdparty' && isModEnabled('member')) {
371 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.fk_soc = s.rowid)";
372 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)";
373 }
374}
375
376// Add table from hooks
377$parameters = array();
378$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
379$sql .= $hookmanager->resPrint;
380if ($object->ismultientitymanaged == 1) {
381 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
382} else {
383 $sql .= " WHERE 1 = 1";
384}
385if ($managedfor == 'member') {
386 if ($memberid > 0) {
387 $sql .= " AND t.fk_member = ".((int) $memberid);
388 } else {
389 $sql .= " AND t.fk_member > 0";
390 }
391} else {
392 if ($socid > 0) {
393 $sql .= " AND t.fk_soc = ".((int) $socid);
394 } else {
395 $sql .= " AND t.fk_soc > 0";
396 }
397}
398foreach ($search as $key => $val) {
399 if (array_key_exists($key, $object->fields)) {
400 if ($key == 'status' && $search[$key] == -1) {
401 continue;
402 }
403 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
404 if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
405 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
406 $search[$key] = '';
407 }
408 $mode_search = 2;
409 }
410 if ($search[$key] != '') {
411 $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
412 }
413 } else {
414 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
415 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
416 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
417 if (preg_match('/_dtstart$/', $key)) {
418 $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
419 }
420 if (preg_match('/_dtend$/', $key)) {
421 $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
422 }
423 }
424 }
425 if ($key == 'country' && $search[$key] != '') {
426 if ($managedfor == 'member') {
427 $sql .= " AND d.country = '".$db->escape($val)."'";
428 } else {
429 $sql .= " AND s.fk_pays = '".$db->escape($val)."'";
430 }
431 }
432 if ($key == 'town' && $search[$key] != '') {
433 if ($managedfor == 'member') {
434 $sql .= natural_search("d.town", $val);
435 } else {
436 $sql .= natural_search("s.town", $val);
437 }
438 }
439 }
440}
441if ($managedfor == 'member' || ($managedfor == 'thirdparty' && isModEnabled('member'))) {
442 if ($search_filter == 'withoutsubscription') {
443 $sql .= " AND (d.datefin IS NULL)";
444 }
445 if ($search_filter == 'waitingsubscription') {
446 $sql .= " AND (d.datefin IS NULL AND t.subscription = '1')";
447 }
448 if ($search_filter == 'uptodate') {
449 $sql .= " AND (d.datefin >= '".$db->idate($now)."' OR dty.subscription = '0')";
450 }
451 if ($search_filter == 'outofdate') {
452 $sql .= " AND (d.datefin < '".$db->idate($now)."' AND dty.subscription = '1')";
453 }
454}
455if ($search_all) {
456 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
457}
458//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
459// Add where from extra fields
460include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
461// Add where from hooks
462$parameters = array();
463$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
464$sql .= $hookmanager->resPrint;
465
466/* If a group by is required
467$sql.= " GROUP BY ";
468foreach($object->fields as $key => $val) {
469 $sql .= "t.".$db->escape($key).", ";
470}
471// Add fields from extrafields
472if (!empty($extrafields->attributes[$object->table_element]['label'])) {
473 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
474 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
475 }
476}
477// Add where from hooks
478$parameters=array();
479$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object, $action); // Note that $action and $object may have been modified by hook
480$sql.=$hookmanager->resPrint;
481$sql=preg_replace('/,\s*$/','', $sql);
482*/
483
484// Count total nb of records
485$nbtotalofrecords = '';
486if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
487 /* The fast and low memory method to get and count full list converts the sql into a sql count */
488 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
489 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
490 $resql = $db->query($sqlforcount);
491 if ($resql) {
492 $objforcount = $db->fetch_object($resql);
493 $nbtotalofrecords = $objforcount->nbtotalofrecords;
494 } else {
496 }
497
498 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
499 $page = 0;
500 $offset = 0;
501 }
502 $db->free($resql);
503}
504
505// Complete request and execute it with limit
506$sql .= $db->order($sortfield, $sortorder);
507if ($limit) {
508 $sql .= $db->plimit($limit + 1, $offset);
509}
510
511$resql = $db->query($sql);
512if (!$resql) {
514 exit;
515}
516
517$num = $db->num_rows($resql);
518
519
520// Direct jump if only one record found
521if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
522 $obj = $db->fetch_object($resql);
523 $id = $obj->rowid;
524 header("Location: ".dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$id);
525 exit;
526}
527
528
529// Output page
530// --------------------------------------------------------------------
531
532llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-partnership page-list');
533
534if ($managedfor == "member") {
535 if ($memberid > 0 && $user->hasRight('adherent', 'lire')) {
536 $langs->load("members");
537
538 $adhstat = new Adherent($db);
539 $adht = new AdherentType($db);
540 $result = $adhstat->fetch($memberid);
541
542 $adht->fetch($adhstat->typeid);
543
544 $head = member_prepare_head($adhstat);
545
546 print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'user');
547
548 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
549
550 dol_banner_tab($object, 'rowid', $linkback);
551
552 print '<div class="fichecenter">';
553
554 print '<div class="underbanner clearboth"></div>';
555 print '<table class="border centpercent tableforfield">';
556
557 // Login
558 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
559 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
560 }
561
562 // Type
563 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
564
565 // Morphy
566 print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$adhstat->getmorphylib().'</td>';
567 print '</tr>';
568
569 // Company
570 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$adhstat->company.'</td></tr>';
571
572 // Civility
573 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$adhstat->getCivilityLabel().'&nbsp;</td>';
574 print '</tr>';
575
576 print '</table>';
577
578 print '</div>';
579
580 print dol_get_fiche_end();
581 }
582} elseif ($managedfor == "thirdparty") {
583 if ($socid && $user->hasRight('societe', 'lire')) {
584 $socstat = new Societe($db);
585 $res = $socstat->fetch($socid);
586 if ($res > 0) {
587 $tmpobject = $object;
588 $object = $socstat; // $object must be of type Societe when calling societe_prepare_head
589 $head = societe_prepare_head($socstat);
590 $object = $tmpobject;
591
592 print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'company');
593
594 dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
595
596 print '<div class="fichecenter">';
597
598 print '<div class="underbanner clearboth"></div>';
599 print '<table class="border centpercent tableforfield">';
600
601 // Type Prospect/Customer/Supplier
602 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
603 print $socstat->getTypeUrl(1);
604 print '</td></tr>';
605
606 // Customer code
607 if ($socstat->client && !empty($socstat->code_client)) {
608 print '<tr><td class="titlefield">';
609 print $langs->trans('CustomerCode').'</td><td>';
610 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
611 $tmpcheck = $socstat->check_codeclient();
612 if ($tmpcheck != 0 && $tmpcheck != -5) {
613 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
614 }
615 print '</td>';
616 print '</tr>';
617 }
618 // Supplier code
619 if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
620 print '<tr><td class="titlefield">';
621 print $langs->trans('SupplierCode').'</td><td>';
622 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
623 $tmpcheck = $socstat->check_codefournisseur();
624 if ($tmpcheck != 0 && $tmpcheck != -5) {
625 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
626 }
627 print '</td>';
628 print '</tr>';
629 }
630
631 print '</table>';
632 print '</div>';
633 print dol_get_fiche_end();
634
635 print '<br>';
636 }
637 }
638}
639
640$arrayofselected = is_array($toselect) ? $toselect : array();
641
642$param = '';
643if (!empty($mode)) {
644 $param .= '&mode='.urlencode($mode);
645}
646if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
647 $param .= '&contextpage='.urlencode($contextpage);
648}
649if ($limit > 0 && $limit != $conf->liste_limit) {
650 $param .= '&limit='.((int) $limit);
651}
652if ($optioncss != '') {
653 $param .= '&optioncss='.urlencode($optioncss);
654}
655if ($socid) {
656 $param .= '&socid='.urlencode((string) ($socid));
657}
658if ($memberid) {
659 $param .= '&rowid='.urlencode((string) ($memberid));
660}
661foreach ($search as $key => $val) {
662 if (is_array($search[$key])) {
663 foreach ($search[$key] as $skey) {
664 if ($skey != '') {
665 $param .= '&search_'.$key.'[]='.urlencode($skey);
666 }
667 }
668 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
669 $param .= '&search_'.$key.'month='.(GETPOSTINT('search_'.$key.'month'));
670 $param .= '&search_'.$key.'day='.(GETPOSTINT('search_'.$key.'day'));
671 $param .= '&search_'.$key.'year='.(GETPOSTINT('search_'.$key.'year'));
672 } elseif ($search[$key] != '') {
673 $param .= '&search_'.$key.'='.urlencode($search[$key]);
674 }
675}
676if ($search_filter && $search_filter != '-1') {
677 $param .= "&search_filter=".urlencode($search_filter);
678}
679// Add $param from extra fields
680include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
681// Add $param from hooks
682$parameters = array('param' => &$param);
683$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
684$param .= $hookmanager->resPrint;
685
686// List of mass actions available
687$arrayofmassactions = array(
688 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
689 'approve' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove"),
690 'cancel' => img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"),
691 //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"),
692 //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"),
693 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"),
694);
695if ($permissiontodelete) {
696 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
697}
698if (GETPOSTINT('nomassaction') || in_array($massaction, array('prevalidate', 'presend', 'predelete'))) {
699 $arrayofmassactions = array();
700}
701$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
702
703print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
704if ($optioncss != '') {
705 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
706}
707print '<input type="hidden" name="token" value="'.newToken().'">';
708print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
709print '<input type="hidden" name="action" value="list">';
710print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
711print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
712print '<input type="hidden" name="page" value="'.$page.'">';
713print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
714print '<input type="hidden" name="page_y" value="">';
715print '<input type="hidden" name="mode" value="'.$mode.'">';
716if ($socid) {
717 print '<input type="hidden" name="socid" value="'.$socid.'" >';
718} elseif ($memberid) {
719 print '<input type="hidden" name="rowid" value="'.$memberid.'" >';
720}
721
722
723$newcardbutton = '';
724$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'));
725$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'));
726$newcardbutton .= dolGetButtonTitleSeparator();
727$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/partnership/partnership_card.php', 1).'?action=create'.($socid > 0 ? '&fk_soc='.$socid : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($socid > 0 ? '?socid='.$socid : '')), '', $permissiontoadd);
728
729
730print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
731
732// Add code for pre mass action (confirmation or email presend form)
733$topicmail = "SendPartnershipRef";
734$modelmail = "partnership_send";
735$objecttmp = new Partnership($db);
736$trackid = 'pship'.$object->id;
737include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
738
739if ($search_all) {
740 $setupstring = '';
741 foreach ($fieldstosearchall as $key => $val) {
742 $fieldstosearchall[$key] = $langs->trans($val);
743 $setupstring .= $key."=".$val.";";
744 }
745 print '<!-- Search done like if PARTNERSHIP_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
746 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
747}
748
749$moreforfilter = '';
750/*$moreforfilter.='<div class="divsearchfield">';
751$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
752$moreforfilter.= '</div>';*/
753
754$parameters = array();
755$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
756if (empty($reshook)) {
757 $moreforfilter .= $hookmanager->resPrint;
758} else {
759 $moreforfilter = $hookmanager->resPrint;
760}
761
762if (!empty($moreforfilter)) {
763 print '<div class="liste_titre liste_titre_bydiv centpercent">';
764 print $moreforfilter;
765 print '</div>';
766}
767
768$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
769$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
770$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
771$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
772
773print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
774print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
775
776
777if ($managedfor == 'member') {
778 $arrayfields['t.fk_member']['checked'] = 1;
779} else {
780 $arrayfields['t.fk_soc']['checked'] = 1;
781}
782
783
784// Fields title search
785// --------------------------------------------------------------------
786print '<tr class="liste_titre_filter">';
787// Action column
788if ($conf->main_checkbox_left_column) {
789 print '<td class="liste_titre center maxwidthsearch">';
790 $searchpicto = $form->showFilterButtons('left');
791 print $searchpicto;
792 print '</td>';
793}
794foreach ($all_fields_list as $key => $val) {
795 $searchkey = empty($search[$key]) ? '' : $search[$key];
796 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
797 if ($key == 'status') {
798 $cssforfield .= ($cssforfield ? ' ' : '').'center';
799 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
800 $cssforfield .= ($cssforfield ? ' ' : '').'center';
801 } elseif (in_array($val['type'], array('timestamp'))) {
802 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
803 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
804 $cssforfield .= ($cssforfield ? ' ' : '').'right';
805 }
806 if (!empty($arrayfields['t.'.$key]['checked'])) {
807 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
808 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
809 if (empty($val['searchmulti'])) {
810 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
811 } else {
812 print $form->multiselectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 0, 0, 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
813 }
814 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
815 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
816 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
817 print '<div class="nowrap">';
818 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
819 print '</div>';
820 print '<div class="nowrap">';
821 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
822 print '</div>';
823 } elseif ($key == 'lang') {
824 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
825 $formadmin = new FormAdmin($db);
826 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
827 } elseif ($val['type'] === 'boolean') {
828 print $form->selectyesno('search_' . $key, $search[$key] ?? '', 1, false, 1);
829 } elseif ($key == 'country') {
830 print $form->select_country(in_array($key, $search) ? $search[$key] : 0, 'search_country', '', 0, 'minwidth100imp maxwidth100');
831 } elseif ($key == 'fk_soc_member') {
832 print '';
833 } elseif ($key == 'fk_soc_dateend') { // End of subscription date
834 $selectarray = array('-1' => '', 'withoutsubscription' => $langs->trans("WithoutSubscription"), 'uptodate' => $langs->trans("UpToDate"), 'outofdate' => $langs->trans("OutOfDate"));
835 print $form->selectarray('search_filter', $selectarray, $search_filter);
836 } else {
837 print '<input type="text" class="flat maxwidth'.(in_array($val['type'], array('integer', 'price')) ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
838 }
839 print '</td>';
840 }
841}
842// Extra fields
843include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
844
845// Fields from hook
846$parameters = array('arrayfields' => $arrayfields);
847$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
848print $hookmanager->resPrint;
849// Action column
850if (!$conf->main_checkbox_left_column) {
851 print '<td class="liste_titre maxwidthsearch">';
852 $searchpicto = $form->showFilterButtons();
853 print $searchpicto;
854 print '</td>';
855}
856print '</tr>'."\n";
857
858$totalarray = array();
859$totalarray['nbfield'] = 0;
860
861// Fields title label
862// --------------------------------------------------------------------
863print '<tr class="liste_titre">';
864if ($conf->main_checkbox_left_column) {
865 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
866 $totalarray['nbfield']++; // For the column action
867}
868foreach ($all_fields_list as $key => $val) {
869 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
870 if ($key == 'status') {
871 $cssforfield .= ($cssforfield ? ' ' : '').'center';
872 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
873 $cssforfield .= ($cssforfield ? ' ' : '').'center';
874 } elseif (in_array($val['type'], array('timestamp'))) {
875 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
876 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
877 $cssforfield .= ($cssforfield ? ' ' : '').'right';
878 }
879 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
880 if (!empty($arrayfields['t.'.$key]['checked'])) {
881 $tmpfield = 't.'.$key;
882 if ($key == 'fk_soc_member') {
883 $tmpfield = '';
884 } elseif ($key == 'fk_soc_dateend') { // End of subscription date
885 $tmpfield = 'd.datefin';
886 $cssforfield = 'center';
887 }
888 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], $tmpfield, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
889 $totalarray['nbfield']++;
890 }
891}
892// Extra fields
893include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
894// Hook fields
895$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
896$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
897print $hookmanager->resPrint;
898// Action column
899if (!$conf->main_checkbox_left_column) {
900 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
901 $totalarray['nbfield']++;
902}
903print '</tr>'."\n";
904
905
906// Detect if we need a fetch on each output line
907$needToFetchEachLine = 0;
908if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
909 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
910 if (!is_null($val) && preg_match('/\$object/', $val)) {
911 $needToFetchEachLine++; // There is at least one compute field that use $object
912 }
913 }
914}
915
916
917// Loop on record
918// --------------------------------------------------------------------
919$i = 0;
920$savnbfield = $totalarray['nbfield'];
921$totalarray = array();
922$totalarray['nbfield'] = 0;
923$imaxinloop = ($limit ? min($num, $limit) : $num);
924$textlate = '';
925while ($i < $imaxinloop) {
926 $obj = $db->fetch_object($resql);
927 if (empty($obj)) {
928 break; // Should not happen
929 }
930
931 // Store properties in $object
932 $object->setVarsFromFetchObj($obj);
933
934 $object->thirdparty = null;
935 if ($obj->fk_soc > 0) {
936 if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
937 $companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
938 } else {
939 $companyobj = new Societe($db);
940 $companyobj->fetch($obj->fk_soc);
941 $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
942 }
943
944 $object->thirdparty = $companyobj;
945 }
946
947 $adherent->id = 0;
948 if ($managedfor == 'member' && $obj->fk_member > 0) {
949 $result = $adherent->fetch($obj->fk_member);
950 }
951 if ($managedfor == 'thirdparty' && isModEnabled('member') && $obj->fk_soc) {
952 $result = $adherent->fetch(0, '', $obj->fk_soc);
953 }
954
955 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
956 if ($i == 0) {
957 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
958 print '<div class="box-flex-container kanban">';
959 }
960 // Output Kanban
961 $selected = -1;
962 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
963 $selected = 0;
964 if (in_array($object->id, $arrayofselected)) {
965 $selected = 1;
966 }
967 }
968 print $object->getKanbanView('', array('thirdparty' => $object->thirdparty, 'selected' => $selected));
969 if ($i == ($imaxinloop - 1)) {
970 print '</div>';
971 print '</td></tr>';
972 }
973 } else {
974 // Show line of result
975 $j = 0;
976 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
977 // Action column
978 if ($conf->main_checkbox_left_column) {
979 print '<td class="nowrap center">';
980 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
981 $selected = 0;
982 if (in_array($object->id, $arrayofselected)) {
983 $selected = 1;
984 }
985 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
986 }
987 print '</td>';
988 if (!$i) {
989 $totalarray['nbfield']++;
990 }
991 }
992 // Fields
993 foreach ($all_fields_list as $key => $val) {
994 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
995 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
996 $cssforfield .= ($cssforfield ? ' ' : '').'center';
997 } elseif ($key == 'status') {
998 $cssforfield .= ($cssforfield ? ' ' : '').'center';
999 }
1000
1001 if (in_array($val['type'], array('timestamp'))) {
1002 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
1003 } elseif ($key == 'ref') {
1004 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
1005 }
1006
1007 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) {
1008 $cssforfield .= ($cssforfield ? ' ' : '').'right';
1009 }
1010 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
1011
1012 if (!empty($arrayfields['t.'.$key]['checked'])) {
1013 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
1014 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key) && !in_array($key, array('ref'))) {
1015 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
1016 }
1017 print '>';
1018 if ($key == 'status') {
1019 print $object->getLibStatut(5);
1020 } elseif ($key == 'rowid') {
1021 print $object->showOutputField($val, $key, (string) $object->id, '');
1022 } elseif ($key == 'country') {
1023 if ($managedfor == 'member') {
1024 if (!empty($adherent->country_code)) {
1025 print $langs->trans("Country".$adherent->country_code);
1026 }
1027 } else {
1028 if (!empty($object->thirdparty->country_code)) {
1029 print $langs->trans("Country".$object->thirdparty->country_code);
1030 }
1031 }
1032 } elseif ($key == 'town') {
1033 if ($managedfor == 'member') {
1034 print $adherent->town;
1035 } else {
1036 print $object->thirdparty->town;
1037 }
1038 } elseif ($key == 'fk_soc_member' && $adherent->id > 0) { // @phpstan-ignore greater.alwaysFalse,booleanAnd.alwaysFalse
1039 print $adherent->getNomUrl(1);
1040 } elseif ($key == 'fk_soc_dateend') {
1041 if ($adherent->id > 0) { // @phpstan-ignore greater.alwaysFalse
1042 $datefin = $adherent->datefin;
1043 if ($datefin) {
1044 print dol_print_date($datefin, 'day');
1045 if ($adherent->hasDelay()) {
1046 $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->member->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->member->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')';
1047 print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
1048 }
1049 } else {
1050 if ($adherent->subscription == 'yes') {
1051 print $langs->trans("SubscriptionNotReceived");
1052 if ($adherent->status > 0) {
1053 print " ".img_warning();
1054 }
1055 } else {
1056 print '&nbsp;';
1057 }
1058 }
1059 }
1060 } else {
1061 print $object->showOutputField($val, $key, $object->$key, '');
1062 }
1063 print '</td>';
1064 if (!$i) {
1065 $totalarray['nbfield']++;
1066 }
1067 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
1068 if (!$i) {
1069 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
1070 }
1071 if (!isset($totalarray['val'])) {
1072 $totalarray['val'] = array();
1073 }
1074 if (!isset($totalarray['val']['t.'.$key])) {
1075 $totalarray['val']['t.'.$key] = 0;
1076 }
1077 $totalarray['val']['t.'.$key] += $object->$key;
1078 }
1079 }
1080 }
1081 // Extra fields
1082 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1083 // Fields from hook
1084 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1085 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1086 print $hookmanager->resPrint;
1087 // Action column
1088 if (!$conf->main_checkbox_left_column) {
1089 print '<td class="nowrap center">';
1090 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1091 $selected = 0;
1092 if (in_array($object->id, $arrayofselected)) {
1093 $selected = 1;
1094 }
1095 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1096 }
1097 print '</td>';
1098 if (!$i) {
1099 $totalarray['nbfield']++;
1100 }
1101 }
1102
1103 print '</tr>'."\n";
1104 }
1105
1106 $i++;
1107}
1108
1109// Show total line
1110include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1111
1112// If no record found
1113if ($num == 0) {
1114 $colspan = 1;
1115 foreach ($arrayfields as $key => $val) {
1116 if (!empty($val['checked'])) {
1117 $colspan++;
1118 }
1119 }
1120 if ($managedfor == 'member' || ($managedfor == 'thirdparty' && isModEnabled('member'))) {
1121 $colspan++; // End of subscription date
1122 }
1123 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1124}
1125
1126
1127$db->free($resql);
1128
1129$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1130$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1131print $hookmanager->resPrint;
1132
1133print '</table>'."\n";
1134print '</div>'."\n";
1135
1136print '</form>'."\n";
1137
1138if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1139 $hidegeneratedfilelistifempty = 1;
1140 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1141 $hidegeneratedfilelistifempty = 0;
1142 }
1143
1144 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1145 $formfile = new FormFile($db);
1146
1147 // Show list of available documents
1148 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1149 $urlsource .= str_replace('&amp;', '&', $param);
1150
1151 $filedir = $diroutputmassaction;
1152 $genallowed = $permissiontoread;
1153 $delallowed = $permissiontoadd;
1154
1155 print $formfile->showdocuments('massfilesarea_partnership', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1156}
1157
1158// End of page
1159llxFooter();
1160$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage members of a foundation.
Class to manage members type.
Class to generate html code for admin pages.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for Partnership.
Class to manage third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object information.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.