dolibarr 25.0.0-alpha
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// Add hook to complete $arrayfield
175$parameters = array('arrayfields' => &$arrayfields);
176$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
177
178$object->fields = dol_sort_array($object->fields, 'position');
179$arrayfields = dol_sort_array($arrayfields, 'position');
180$all_fields_list = dol_sort_array($all_fields_list, 'position');
181
182$permissiontoread = $user->hasRight('partnership', 'read');
183$permissiontoadd = $user->hasRight('partnership', 'write');
184$permissiontodelete = $user->hasRight('partnership', 'delete');
185
186// Security check - Protection if external user
187//if ($user->socid > 0) accessforbidden();
188//if ($user->socid > 0) $socid = $user->socid;
189//restrictedArea($user, 'partnership', $object->id);
190if (empty($conf->partnership->enabled)) {
192}
193if (empty($permissiontoread)) {
195}
196if ($object->id > 0 && !($object->fk_member > 0) && $managedfor == 'member') {
198}
199if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor == 'thirdparty') {
201}
202
203
204/*
205 * Actions
206 */
207
208if (GETPOST('cancel', 'alpha')) {
209 $action = 'list';
210 $massaction = '';
211}
212if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
213 $massaction = '';
214}
215
216$parameters = array('socid' => $socid);
217$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
218if ($reshook < 0) {
219 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
220}
221
222if (empty($reshook)) {
223 // Selection of new fields
224 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
225
226 // Purge search criteria
227 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
228 foreach ($all_fields_list as $key => $val) {
229 $search[$key] = '';
230 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
231 $search[$key.'_dtstart'] = '';
232 $search[$key.'_dtend'] = '';
233 }
234 }
235 $toselect = array();
236 $search_array_options = array();
237 }
238 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
239 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
240 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
241 }
242
243 // Mass actions
244 $objectclass = 'Partnership';
245 $objectlabel = 'Partnership';
246 $uploaddir = $conf->partnership->dir_output;
247 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
248
249 // Validate and approve
250 if (!$error && $massaction == 'approve' && $permissiontoadd) {
251 $objecttmp = new Partnership($db);
252
253 $db->begin();
254 $error = 0;
255 $result = 0;
256
257 foreach ($toselect as $checked) {
258 if ($objecttmp->fetch($checked)) {
259 if ($objecttmp->status == $objecttmp::STATUS_DRAFT) {
260 //$objecttmp->date = dol_now();
261 $result = $objecttmp->validate($user);
262 }
263
264 if ($result >= 0 && $objecttmp->status == $objecttmp::STATUS_VALIDATED) {
265 $result = $objecttmp->approve($user);
266 if ($result > 0) {
267 setEventMessages($langs->trans("PartnershipRefApproved", $objecttmp->ref), null);
268 } else {
269 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
270 $error++;
271 }
272 } else {
273 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
274 $error++;
275 }
276 }
277 }
278
279 if (!$error) {
280 $db->commit();
281 } else {
282 $db->rollback();
283 }
284 }
285
286 // Cancel partnership
287 if ($massaction == 'cancel' && $permissiontoadd) {
288 $db->begin();
289
290 $objecttmp = new $objectclass($db);
291 $nbok = 0;
292 foreach ($toselect as $toselectid) {
293 $result = $objecttmp->fetch($toselectid);
294 if ($result > 0) {
295 $result = $objecttmp->cancel($user, 0);
296 if ($result == 0) {
297 setEventMessages($langs->trans('StatusOfRefMustBe', $objecttmp->ref, $objecttmp->LibStatut($objecttmp::STATUS_APPROVED)), null, 'warnings');
298 $error++;
299 } elseif ($result <= 0) {
300 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
301 $error++;
302 break;
303 } else {
304 $nbok++;
305 }
306 } else {
307 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
308 $error++;
309 break;
310 }
311 }
312
313 if (!$error) {
314 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
315 $db->commit();
316 } else {
317 $db->rollback();
318 }
319 }
320}
321
322
323
324/*
325 * View
326 */
327
328$form = new Form($db);
329$companystatic = new Societe($db);
330
331$now = dol_now();
332
333//$help_url="EN:Module_Partnership|FR:Module_Partnership_FR|ES:Módulo_Partnership";
334$help_url = '';
335$title = $langs->trans("Partnerships");
336$morejs = array();
337$morecss = array();
338
339
340// Build and execute select
341// --------------------------------------------------------------------
342$sql = 'SELECT ';
343$sql .= $object->getFieldList('t');
344if ($managedfor == 'member') {
345 $sql .= ', d.rowid as memberid, d.lastname, d.firstname, d.datefin, d.fk_adherent_type, dty.subscription';
346}
347if ($managedfor == 'thirdparty' && isModEnabled('member')) {
348 $sql .= ', d.rowid as memberid, d.lastname, d.firstname, d.datefin, d.fk_adherent_type, dty.subscription';
349}
350// Add fields from extrafields
351if (!empty($extrafields->attributes[$object->table_element]['label'])) {
352 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
353 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
354 }
355}
356// Add fields from hooks
357$parameters = array();
358$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
359$sql .= $hookmanager->resPrint;
360$sql = preg_replace('/,\s*$/', '', $sql);
361
362$sqlfields = $sql; // $sql fields to remove for count total
363
364$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
365if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
366 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
367}
368if ($managedfor == 'member') {
369 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)";
370 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)";
371} else {
372 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = t.fk_soc)";
373 if ($managedfor == 'thirdparty' && isModEnabled('member')) {
374 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.fk_soc = s.rowid)";
375 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)";
376 }
377}
378
379// Add table from hooks
380$parameters = array();
381$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
382$sql .= $hookmanager->resPrint;
383if ($object->ismultientitymanaged == 1) {
384 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
385} else {
386 $sql .= " WHERE 1 = 1";
387}
388if ($managedfor == 'member') {
389 if ($memberid > 0) {
390 $sql .= " AND t.fk_member = ".((int) $memberid);
391 } else {
392 $sql .= " AND t.fk_member > 0";
393 }
394} else {
395 if ($socid > 0) {
396 $sql .= " AND t.fk_soc = ".((int) $socid);
397 } else {
398 $sql .= " AND t.fk_soc > 0";
399 }
400}
401foreach ($search as $key => $val) {
402 if (array_key_exists($key, $object->fields)) {
403 if ($key == 'status' && $search[$key] == -1) {
404 continue;
405 }
406 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
407 if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
408 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
409 $search[$key] = '';
410 }
411 $mode_search = 2;
412 }
413 if ($search[$key] != '') {
414 $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
415 }
416 } else {
417 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
418 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
419 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
420 if (preg_match('/_dtstart$/', $key)) {
421 $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'";
422 }
423 if (preg_match('/_dtend$/', $key)) {
424 $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'";
425 }
426 }
427 }
428 if ($key == 'country' && $search[$key] != '') {
429 if ($managedfor == 'member') {
430 $sql .= " AND d.country = '".$db->escape($val)."'";
431 } else {
432 $sql .= " AND s.fk_pays = '".$db->escape($val)."'";
433 }
434 }
435 if ($key == 'town' && $search[$key] != '') {
436 if ($managedfor == 'member') {
437 $sql .= natural_search("d.town", $val);
438 } else {
439 $sql .= natural_search("s.town", $val);
440 }
441 }
442 }
443}
444if ($managedfor == 'member' || ($managedfor == 'thirdparty' && isModEnabled('member'))) {
445 if ($search_filter == 'withoutsubscription') {
446 $sql .= " AND (d.datefin IS NULL)";
447 }
448 if ($search_filter == 'waitingsubscription') {
449 $sql .= " AND (d.datefin IS NULL AND t.subscription = '1')";
450 }
451 if ($search_filter == 'uptodate') {
452 $sql .= " AND (d.datefin >= '".$db->idate($now)."' OR dty.subscription = '0')";
453 }
454 if ($search_filter == 'outofdate') {
455 $sql .= " AND (d.datefin < '".$db->idate($now)."' AND dty.subscription = '1')";
456 }
457}
458if ($search_all) {
459 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
460}
461//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
462// Add where from extra fields
463include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
464// Add where from hooks
465$parameters = array();
466$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
467$sql .= $hookmanager->resPrint;
468
469/* If a group by is required
470$sql.= " GROUP BY ";
471foreach($object->fields as $key => $val) {
472 $sql .= "t.".$db->escape($key).", ";
473}
474// Add fields from extrafields
475if (!empty($extrafields->attributes[$object->table_element]['label'])) {
476 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
477 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
478 }
479}
480// Add where from hooks
481$parameters=array();
482$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object, $action); // Note that $action and $object may have been modified by hook
483$sql.=$hookmanager->resPrint;
484$sql=preg_replace('/,\s*$/','', $sql);
485*/
486
487// Count total nb of records
488$nbtotalofrecords = '';
489if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
490 /* The fast and low memory method to get and count full list converts the sql into a sql count */
491 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
492 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
493 $resql = $db->query($sqlforcount);
494 if ($resql) {
495 $objforcount = $db->fetch_object($resql);
496 $nbtotalofrecords = $objforcount->nbtotalofrecords;
497 } else {
499 }
500
501 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
502 $page = 0;
503 $offset = 0;
504 }
505 $db->free($resql);
506}
507
508// Complete request and execute it with limit
509$sql .= $db->order($sortfield, $sortorder);
510if ($limit) {
511 $sql .= $db->plimit($limit + 1, $offset);
512}
513
514$resql = $db->query($sql);
515if (!$resql) {
517 exit;
518}
519
520$num = $db->num_rows($resql);
521
522
523// Direct jump if only one record found
524if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
525 $obj = $db->fetch_object($resql);
526 $id = $obj->rowid;
527 header("Location: ".dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$id);
528 exit;
529}
530
531
532// Output page
533// --------------------------------------------------------------------
534
535llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-partnership page-list');
536
537if ($managedfor == "member") {
538 if ($memberid > 0 && $user->hasRight('adherent', 'lire')) {
539 $langs->load("members");
540
541 $adhstat = new Adherent($db);
542 $adht = new AdherentType($db);
543 $result = $adhstat->fetch($memberid);
544
545 $adht->fetch($adhstat->typeid);
546
547 $head = member_prepare_head($adhstat);
548
549 print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'user');
550
551 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
552
553 dol_banner_tab($object, 'rowid', $linkback);
554
555 print '<div class="fichecenter">';
556
557 print '<div class="underbanner clearboth"></div>';
558 print '<table class="border centpercent tableforfield">';
559
560 // Login
561 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
562 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
563 }
564
565 // Type
566 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
567
568 // Morphy
569 print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$adhstat->getmorphylib().'</td>';
570 print '</tr>';
571
572 // Company
573 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$adhstat->company.'</td></tr>';
574
575 // Civility
576 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$adhstat->getCivilityLabel().'&nbsp;</td>';
577 print '</tr>';
578
579 print '</table>';
580
581 print '</div>';
582
583 print dol_get_fiche_end();
584 }
585} elseif ($managedfor == "thirdparty") {
586 if ($socid && $user->hasRight('societe', 'lire')) {
587 $socstat = new Societe($db);
588 $res = $socstat->fetch($socid);
589 if ($res > 0) {
590 $tmpobject = $object;
591 $object = $socstat; // $object must be of type Societe when calling societe_prepare_head
592 $head = societe_prepare_head($socstat);
593 $object = $tmpobject;
594
595 print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'company');
596
597 dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
598
599 print '<div class="fichecenter">';
600
601 print '<div class="underbanner clearboth"></div>';
602 print '<table class="border centpercent tableforfield">';
603
604 // Type Prospect/Customer/Supplier
605 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
606 print $socstat->getTypeUrl(1);
607 print '</td></tr>';
608
609 // Customer code
610 if ($socstat->client && !empty($socstat->code_client)) {
611 print '<tr><td class="titlefield">';
612 print $langs->trans('CustomerCode').'</td><td>';
613 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
614 $tmpcheck = $socstat->check_codeclient();
615 if ($tmpcheck != 0 && $tmpcheck != -5) {
616 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
617 }
618 print '</td>';
619 print '</tr>';
620 }
621 // Supplier code
622 if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
623 print '<tr><td class="titlefield">';
624 print $langs->trans('SupplierCode').'</td><td>';
625 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
626 $tmpcheck = $socstat->check_codefournisseur();
627 if ($tmpcheck != 0 && $tmpcheck != -5) {
628 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
629 }
630 print '</td>';
631 print '</tr>';
632 }
633
634 print '</table>';
635 print '</div>';
636 print dol_get_fiche_end();
637
638 print '<br>';
639 }
640 }
641}
642
643$arrayofselected = is_array($toselect) ? $toselect : array();
644
645$param = '';
646if (!empty($mode)) {
647 $param .= '&mode='.urlencode($mode);
648}
649if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
650 $param .= '&contextpage='.urlencode($contextpage);
651}
652if ($limit > 0 && $limit != $conf->liste_limit) {
653 $param .= '&limit='.((int) $limit);
654}
655if ($optioncss != '') {
656 $param .= '&optioncss='.urlencode($optioncss);
657}
658if ($socid) {
659 $param .= '&socid='.urlencode((string) ($socid));
660}
661if ($memberid) {
662 $param .= '&rowid='.urlencode((string) ($memberid));
663}
664foreach ($search as $key => $val) {
665 if (is_array($search[$key])) {
666 foreach ($search[$key] as $skey) {
667 if ($skey != '') {
668 $param .= '&search_'.$key.'[]='.urlencode($skey);
669 }
670 }
671 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
672 $param .= '&search_'.$key.'month='.(GETPOSTINT('search_'.$key.'month'));
673 $param .= '&search_'.$key.'day='.(GETPOSTINT('search_'.$key.'day'));
674 $param .= '&search_'.$key.'year='.(GETPOSTINT('search_'.$key.'year'));
675 } elseif ($search[$key] != '') {
676 $param .= '&search_'.$key.'='.urlencode($search[$key]);
677 }
678}
679if ($search_filter && $search_filter != '-1') {
680 $param .= "&search_filter=".urlencode($search_filter);
681}
682// Add $param from extra fields
683include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
684// Add $param from hooks
685$parameters = array('param' => &$param);
686$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
687$param .= $hookmanager->resPrint;
688
689// List of mass actions available
690$arrayofmassactions = array(
691 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
692 'approve' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove"),
693 'cancel' => img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"),
694 //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"),
695 //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"),
696 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"),
697);
698if ($permissiontodelete) {
699 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
700}
701if (GETPOSTINT('nomassaction') || in_array($massaction, array('prevalidate', 'presend', 'predelete'))) {
702 $arrayofmassactions = array();
703}
704$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
705
706print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
707if ($optioncss != '') {
708 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
709}
710print '<input type="hidden" name="token" value="'.newToken().'">';
711print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
712print '<input type="hidden" name="action" value="list">';
713print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
714print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
715print '<input type="hidden" name="page" value="'.$page.'">';
716print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
717print '<input type="hidden" name="page_y" value="">';
718print '<input type="hidden" name="mode" value="'.$mode.'">';
719if ($socid) {
720 print '<input type="hidden" name="socid" value="'.$socid.'" >';
721} elseif ($memberid) {
722 print '<input type="hidden" name="rowid" value="'.$memberid.'" >';
723}
724
725
726$newcardbutton = '';
727$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'));
728$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'));
729$newcardbutton .= dolGetButtonTitleSeparator();
730$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);
731
732
733print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
734
735// Add code for pre mass action (confirmation or email presend form)
736$topicmail = "SendPartnershipRef";
737$modelmail = "partnership_send";
738$objecttmp = new Partnership($db);
739$trackid = 'pship'.$object->id;
740include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
741
742if ($search_all) {
743 $setupstring = '';
744 foreach ($fieldstosearchall as $key => $val) {
745 $fieldstosearchall[$key] = $langs->trans($val);
746 $setupstring .= $key."=".$val.";";
747 }
748 print '<!-- Search done like if PARTNERSHIP_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
749 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
750}
751
752$moreforfilter = '';
753/*$moreforfilter.='<div class="divsearchfield">';
754$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
755$moreforfilter.= '</div>';*/
756
757$parameters = array();
758$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
759if (empty($reshook)) {
760 $moreforfilter .= $hookmanager->resPrint;
761} else {
762 $moreforfilter = $hookmanager->resPrint;
763}
764
765if (!empty($moreforfilter)) {
766 print '<div class="liste_titre liste_titre_bydiv centpercent">';
767 print $moreforfilter;
768 print '</div>';
769}
770
771$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
772$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
773$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
774$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
775
776print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
777print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
778
779
780if ($managedfor == 'member') {
781 $arrayfields['t.fk_member']['checked'] = 1;
782} else {
783 $arrayfields['t.fk_soc']['checked'] = 1;
784}
785
786
787// Fields title search
788// --------------------------------------------------------------------
789print '<tr class="liste_titre_filter">';
790// Action column
791if ($conf->main_checkbox_left_column) {
792 print '<td class="liste_titre center maxwidthsearch">';
793 $searchpicto = $form->showFilterButtons('left');
794 print $searchpicto;
795 print '</td>';
796}
797foreach ($all_fields_list as $key => $val) {
798 $searchkey = empty($search[$key]) ? '' : $search[$key];
799 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
800 if ($key == 'status') {
801 $cssforfield .= ($cssforfield ? ' ' : '').'center';
802 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
803 $cssforfield .= ($cssforfield ? ' ' : '').'center';
804 } elseif (in_array($val['type'], array('timestamp'))) {
805 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
806 } 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'])) {
807 $cssforfield .= ($cssforfield ? ' ' : '').'right';
808 }
809 if (!empty($arrayfields['t.'.$key]['checked'])) {
810 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
811 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
812 if (empty($val['searchmulti'])) {
813 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);
814 } else {
815 print $form->multiselectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 0, 0, 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
816 }
817 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
818 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
819 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
820 print '<div class="nowrap">';
821 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
822 print '</div>';
823 print '<div class="nowrap">';
824 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
825 print '</div>';
826 } elseif ($key == 'lang') {
827 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
828 $formadmin = new FormAdmin($db);
829 print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
830 } elseif ($val['type'] === 'boolean') {
831 print $form->selectyesno('search_' . $key, $search[$key] ?? '', 1, false, 1);
832 } elseif ($key == 'country') {
833 print $form->select_country(in_array($key, $search) ? $search[$key] : 0, 'search_country', '', 0, 'minwidth100imp maxwidth100');
834 } elseif ($key == 'fk_soc_member') {
835 print '';
836 } elseif ($key == 'fk_soc_dateend') { // End of subscription date
837 $selectarray = array('-1' => '', 'withoutsubscription' => $langs->trans("WithoutSubscription"), 'uptodate' => $langs->trans("UpToDate"), 'outofdate' => $langs->trans("OutOfDate"));
838 print $form->selectarray('search_filter', $selectarray, $search_filter);
839 } else {
840 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] : '').'">';
841 }
842 print '</td>';
843 }
844}
845// Extra fields
846include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
847
848// Fields from hook
849$parameters = array('arrayfields' => $arrayfields);
850$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
851print $hookmanager->resPrint;
852// Action column
853if (!$conf->main_checkbox_left_column) {
854 print '<td class="liste_titre maxwidthsearch">';
855 $searchpicto = $form->showFilterButtons();
856 print $searchpicto;
857 print '</td>';
858}
859print '</tr>'."\n";
860
861$totalarray = array();
862$totalarray['nbfield'] = 0;
863
864// Fields title label
865// --------------------------------------------------------------------
866print '<tr class="liste_titre">';
867if ($conf->main_checkbox_left_column) {
868 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
869 $totalarray['nbfield']++; // For the column action
870}
871foreach ($all_fields_list as $key => $val) {
872 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
873 if ($key == 'status') {
874 $cssforfield .= ($cssforfield ? ' ' : '').'center';
875 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
876 $cssforfield .= ($cssforfield ? ' ' : '').'center';
877 } elseif (in_array($val['type'], array('timestamp'))) {
878 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
879 } 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'])) {
880 $cssforfield .= ($cssforfield ? ' ' : '').'right';
881 }
882 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
883 if (!empty($arrayfields['t.'.$key]['checked'])) {
884 $tmpfield = 't.'.$key;
885 if ($key == 'fk_soc_member') {
886 $tmpfield = '';
887 } elseif ($key == 'fk_soc_dateend') { // End of subscription date
888 $tmpfield = 'd.datefin';
889 $cssforfield = 'center';
890 }
891 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";
892 $totalarray['nbfield']++;
893 }
894}
895// Extra fields
896include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
897// Hook fields
898$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
899$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
900print $hookmanager->resPrint;
901// Action column
902if (!$conf->main_checkbox_left_column) {
903 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
904 $totalarray['nbfield']++;
905}
906print '</tr>'."\n";
907
908
909// Detect if we need a fetch on each output line
910$needToFetchEachLine = 0;
911if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
912 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
913 if (!is_null($val) && preg_match('/\$object/', $val)) {
914 $needToFetchEachLine++; // There is at least one compute field that use $object
915 }
916 }
917}
918
919
920// Loop on record
921// --------------------------------------------------------------------
922$i = 0;
923$savnbfield = $totalarray['nbfield'];
924$totalarray = array();
925$totalarray['nbfield'] = 0;
926$imaxinloop = ($limit ? min($num, $limit) : $num);
927$textlate = '';
928while ($i < $imaxinloop) {
929 $obj = $db->fetch_object($resql);
930 if (empty($obj)) {
931 break; // Should not happen
932 }
933
934 // Store properties in $object
935 $object->setVarsFromFetchObj($obj);
936
937 $object->thirdparty = null;
938 if ($obj->fk_soc > 0) {
939 if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
940 $companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
941 } else {
942 $companyobj = new Societe($db);
943 $companyobj->fetch($obj->fk_soc);
944 $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
945 }
946
947 $object->thirdparty = $companyobj;
948 }
949
950 $adherent->id = 0;
951 if ($managedfor == 'member' && $obj->fk_member > 0) {
952 $result = $adherent->fetch($obj->fk_member);
953 }
954 if ($managedfor == 'thirdparty' && isModEnabled('member') && $obj->fk_soc) {
955 $result = $adherent->fetch(0, '', $obj->fk_soc);
956 }
957
958 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
959 if ($i == 0) {
960 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
961 print '<div class="box-flex-container kanban">';
962 }
963 // Output Kanban
964 $selected = -1;
965 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
966 $selected = 0;
967 if (in_array($object->id, $arrayofselected)) {
968 $selected = 1;
969 }
970 }
971 print $object->getKanbanView('', array('thirdparty' => $object->thirdparty, 'selected' => $selected));
972 if ($i == ($imaxinloop - 1)) {
973 print '</div>';
974 print '</td></tr>';
975 }
976 } else {
977 // Show line of result
978 $j = 0;
979 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
980 // Action column
981 if ($conf->main_checkbox_left_column) {
982 print '<td class="nowrap center">';
983 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
984 $selected = 0;
985 if (in_array($object->id, $arrayofselected)) {
986 $selected = 1;
987 }
988 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
989 }
990 print '</td>';
991 if (!$i) {
992 $totalarray['nbfield']++;
993 }
994 }
995 // Fields
996 foreach ($all_fields_list as $key => $val) {
997 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
998 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
999 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1000 } elseif ($key == 'status') {
1001 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1002 }
1003
1004 if (in_array($val['type'], array('timestamp'))) {
1005 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
1006 } elseif ($key == 'ref') {
1007 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
1008 }
1009
1010 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'])) {
1011 $cssforfield .= ($cssforfield ? ' ' : '').'right';
1012 }
1013 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
1014
1015 if (!empty($arrayfields['t.'.$key]['checked'])) {
1016 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
1017 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key) && !in_array($key, array('ref'))) {
1018 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
1019 }
1020 print '>';
1021 if ($key == 'status') {
1022 print $object->getLibStatut(5);
1023 } elseif ($key == 'rowid') {
1024 print $object->showOutputField($val, $key, (string) $object->id, '');
1025 } elseif ($key == 'country') {
1026 if ($managedfor == 'member') {
1027 if (!empty($adherent->country_code)) {
1028 print $langs->trans("Country".$adherent->country_code);
1029 }
1030 } else {
1031 if (!empty($object->thirdparty->country_code)) {
1032 print $langs->trans("Country".$object->thirdparty->country_code);
1033 }
1034 }
1035 } elseif ($key == 'town') {
1036 if ($managedfor == 'member') {
1037 print $adherent->town;
1038 } else {
1039 print $object->thirdparty->town;
1040 }
1041 } elseif ($key == 'fk_soc_member' && $adherent->id > 0) { // @phpstan-ignore greater.alwaysFalse,booleanAnd.alwaysFalse
1042 print $adherent->getNomUrl(1);
1043 } elseif ($key == 'fk_soc_dateend') {
1044 if ($adherent->id > 0) { // @phpstan-ignore greater.alwaysFalse
1045 $datefin = $adherent->datefin;
1046 if ($datefin) {
1047 print dol_print_date($datefin, 'day');
1048 if ($adherent->hasDelay()) {
1049 $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").')';
1050 print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
1051 }
1052 } else {
1053 if ($adherent->subscription == 'yes') {
1054 print $langs->trans("SubscriptionNotReceived");
1055 if ($adherent->status > 0) {
1056 print " ".img_warning();
1057 }
1058 } else {
1059 print '&nbsp;';
1060 }
1061 }
1062 }
1063 } else {
1064 print $object->showOutputField($val, $key, $object->$key, '');
1065 }
1066 print '</td>';
1067 if (!$i) {
1068 $totalarray['nbfield']++;
1069 }
1070 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
1071 if (!$i) {
1072 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
1073 }
1074 if (!isset($totalarray['val'])) {
1075 $totalarray['val'] = array();
1076 }
1077 if (!isset($totalarray['val']['t.'.$key])) {
1078 $totalarray['val']['t.'.$key] = 0;
1079 }
1080 $totalarray['val']['t.'.$key] += $object->$key;
1081 }
1082 }
1083 }
1084 // Extra fields
1085 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1086 // Fields from hook
1087 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1088 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1089 print $hookmanager->resPrint;
1090 // Action column
1091 if (!$conf->main_checkbox_left_column) {
1092 print '<td class="nowrap center">';
1093 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1094 $selected = 0;
1095 if (in_array($object->id, $arrayofselected)) {
1096 $selected = 1;
1097 }
1098 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1099 }
1100 print '</td>';
1101 if (!$i) {
1102 $totalarray['nbfield']++;
1103 }
1104 }
1105
1106 print '</tr>'."\n";
1107 }
1108
1109 $i++;
1110}
1111
1112// Show total line
1113include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1114
1115// If no record found
1116if ($num == 0) {
1117 $colspan = 1;
1118 foreach ($arrayfields as $key => $val) {
1119 if (!empty($val['checked'])) {
1120 $colspan++;
1121 }
1122 }
1123 if ($managedfor == 'member' || ($managedfor == 'thirdparty' && isModEnabled('member'))) {
1124 $colspan++; // End of subscription date
1125 }
1126 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1127}
1128
1129
1130$db->free($resql);
1131
1132$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1133$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1134print $hookmanager->resPrint;
1135
1136print '</table>'."\n";
1137print '</div>'."\n";
1138
1139print '</form>'."\n";
1140
1141if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1142 $hidegeneratedfilelistifempty = 1;
1143 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1144 $hidegeneratedfilelistifempty = 0;
1145 }
1146
1147 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1148 $formfile = new FormFile($db);
1149
1150 // Show list of available documents
1151 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1152 $urlsource .= str_replace('&amp;', '&', $param);
1153
1154 $filedir = $diroutputmassaction;
1155 $genallowed = $permissiontoread;
1156 $delallowed = $permissiontoadd;
1157
1158 print $formfile->showdocuments('massfilesarea_partnership', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1159}
1160
1161// End of page
1162llxFooter();
1163$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:501
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...
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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)
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.
Definition html.lib.php:519
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
Definition html.lib.php:172
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
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.