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