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