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