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