dolibarr  18.0.0-alpha
company.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4  * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
5  * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
7  * Copyright (C) 2013-2014 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2013 Christophe Battarel <contact@altairis.fr>
9  * Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
10  * Copyright (C) 2015-2021 Frédéric France <frederic.france@netlogic.fr>
11  * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
12  * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
13  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program. If not, see <https://www.gnu.org/licenses/>.
27  * or see https://www.gnu.org/
28  */
29 
42 function societe_prepare_head(Societe $object)
43 {
44  global $db, $langs, $conf, $user;
45  global $hookmanager;
46 
47  $h = 0;
48  $head = array();
49 
50  $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id;
51  $head[$h][1] = $langs->trans("ThirdParty");
52  $head[$h][2] = 'card';
53  $h++;
54 
55  if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) {
56  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) {
57  //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
58  $nbContact = 0;
59  // Enable caching of thirdrparty count Contacts
60  require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
61  $cachekey = 'count_contacts_thirdparty_'.$object->id;
62  $dataretrieved = dol_getcache($cachekey);
63 
64  if (!is_null($dataretrieved)) {
65  $nbContact = $dataretrieved;
66  } else {
67  $sql = "SELECT COUNT(p.rowid) as nb";
68  $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
69  // Add table from hooks
70  $parameters = array('contacttab' => true);
71  $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
72  $sql .= $hookmanager->resPrint;
73  $sql .= " WHERE p.fk_soc = ".((int) $object->id);
74  // Add where from hooks
75  $parameters = array('contacttab' => true);
76  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
77  $sql .= $hookmanager->resPrint;
78  $resql = $db->query($sql);
79  if ($resql) {
80  $obj = $db->fetch_object($resql);
81  $nbContact = $obj->nb;
82  }
83 
84  dol_setcache($cachekey, $nbContact, 120); // If setting cache fails, this is not a problem, so we do not test result.
85  }
86 
87  $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id;
88  $head[$h][1] = $langs->trans('ContactsAddresses');
89  if ($nbContact > 0) {
90  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
91  }
92  $head[$h][2] = 'contact';
93  $h++;
94  }
95  } else {
96  $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id;
97  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
98  $head[$h][1] = $langs->trans("ContactsAddresses");
99  if ($nbContact > 0) {
100  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
101  }
102  $head[$h][2] = 'contact';
103  $h++;
104  }
105 
106  if ($object->client == 1 || $object->client == 2 || $object->client == 3) {
107  $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id;
108  $head[$h][1] = '';
109  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) {
110  $head[$h][1] .= $langs->trans("Prospect");
111  }
112  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) {
113  $head[$h][1] .= ' | ';
114  }
115  if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) {
116  $head[$h][1] .= $langs->trans("Customer");
117  }
118  $head[$h][2] = 'customer';
119  $h++;
120 
121  if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
122  $langs->load("products");
123  // price
124  $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id;
125  $head[$h][1] = $langs->trans("CustomerPrices");
126  $head[$h][2] = 'price';
127  $h++;
128  }
129  }
130  $supplier_module_enabled = 0;
131  if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
132  $supplier_module_enabled = 1;
133  }
134  if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
135  $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id;
136  $head[$h][1] = $langs->trans("Supplier");
137  $head[$h][2] = 'supplier';
138  $h++;
139  }
140 
141  if (isModEnabled('project') && (!empty($user->rights->projet->lire))) {
142  $nbProject = 0;
143  // Enable caching of thirdrparty count projects
144  require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
145  $cachekey = 'count_projects_thirdparty_'.$object->id;
146  $dataretrieved = dol_getcache($cachekey);
147 
148  if (!is_null($dataretrieved)) {
149  $nbProject = $dataretrieved;
150  } else {
151  $sql = "SELECT COUNT(n.rowid) as nb";
152  $sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
153  $sql .= " WHERE fk_soc = ".((int) $object->id);
154  $sql .= " AND entity IN (".getEntity('project').")";
155  $resql = $db->query($sql);
156  if ($resql) {
157  $obj = $db->fetch_object($resql);
158  $nbProject = $obj->nb;
159  } else {
160  dol_print_error($db);
161  }
162  dol_setcache($cachekey, $nbProject, 120); // If setting cache fails, this is not a problem, so we do not test result.
163  }
164  $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
165  $head[$h][1] = $langs->trans("Projects");
166  if ($nbProject > 0) {
167  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbProject.'</span>';
168  }
169  $head[$h][2] = 'project';
170  $h++;
171  }
172 
173  // Tab to link resources
174  if (isModEnabled('resource') && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) {
175  $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id;
176  $head[$h][1] = $langs->trans("Resources");
177  $head[$h][2] = 'resources';
178  $h++;
179  }
180 
181  // Related items
182  if ((isModEnabled('commande') || isModEnabled('propal') || isModEnabled('facture') || isModEnabled('ficheinter') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))
183  && empty($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB)) {
184  $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id;
185  $head[$h][1] = $langs->trans("Referers");
186  $head[$h][2] = 'consumption';
187  $h++;
188  }
189 
190  // Bank accounts
191  if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) {
192  $nbBankAccount = 0;
193  $foundonexternalonlinesystem = 0;
194  $langs->load("bills");
195 
196  $title = $langs->trans("PaymentModes");
197 
198  if (isModEnabled('stripe')) {
199  //$langs->load("stripe");
200  //$title = $langs->trans("BankAccountsAndGateways");
201 
202  $servicestatus = 0;
203  if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
204  $servicestatus = 1;
205  }
206 
207  include_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
208  $societeaccount = new SocieteAccount($db);
209  $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_...
210  if ($stripecu) {
211  $foundonexternalonlinesystem++;
212  }
213  }
214 
215  $sql = "SELECT COUNT(n.rowid) as nb";
216  $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n";
217  $sql .= " WHERE n.fk_soc = ".((int) $object->id);
218  if (!isModEnabled('stripe')) {
219  $sql .= " AND n.stripe_card_ref IS NULL";
220  } else {
221  $sql .= " AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".((int) $servicestatus)."))";
222  }
223 
224  $resql = $db->query($sql);
225  if ($resql) {
226  $obj = $db->fetch_object($resql);
227  $nbBankAccount = $obj->nb;
228  } else {
229  dol_print_error($db);
230  }
231 
232  //if (isModEnabled('stripe') && $nbBankAccount > 0) $nbBankAccount = '...'; // No way to know exact number
233 
234  $head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.urlencode($object->id);
235  $head[$h][1] = $title;
236  if ($foundonexternalonlinesystem) {
237  $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
238  } elseif ($nbBankAccount > 0) {
239  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbBankAccount.'</span>';
240  }
241  $head[$h][2] = 'rib';
242  $h++;
243  }
244 
245  if (isModEnabled('website') && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && ($user->hasRight('societe', 'lire'))) {
246  $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.urlencode($object->id);
247  $head[$h][1] = $langs->trans("WebSiteAccounts");
248  $nbNote = 0;
249  $sql = "SELECT COUNT(n.rowid) as nb";
250  $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n";
251  $sql .= " WHERE fk_soc = ".((int) $object->id).' AND fk_website > 0';
252  $resql = $db->query($sql);
253  if ($resql) {
254  $obj = $db->fetch_object($resql);
255  $nbNote = $obj->nb;
256  } else {
257  dol_print_error($db);
258  }
259  if ($nbNote > 0) {
260  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
261  }
262  $head[$h][2] = 'website';
263  $h++;
264  }
265 
266  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') {
267  if (!empty($user->rights->partnership->read)) {
268  $langs->load("partnership");
269  $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
270  $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?socid='.$object->id;
271  $head[$h][1] = $langs->trans("Partnerships");
272  $nbNote = 0;
273  $sql = "SELECT COUNT(n.rowid) as nb";
274  $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n";
275  $sql .= " WHERE fk_soc = ".((int) $object->id);
276  $resql = $db->query($sql);
277  if ($resql) {
278  $obj = $db->fetch_object($resql);
279  $nbNote = $obj->nb;
280  } else {
281  dol_print_error($db);
282  }
283  if ($nbNote > 0) {
284  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
285  }
286  $head[$h][2] = 'partnerships';
287  if ($nbPartnership > 0) {
288  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbPartnership.'</span>';
289  }
290  $h++;
291  }
292  }
293 
294  // Show more tabs from modules
295  // Entries must be declared in modules descriptor with line
296  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
297  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
298  complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'add', 'core');
299 
300  if ($user->socid == 0) {
301  // Notifications
302  if (isModEnabled('notification')) {
303  $nbNotif = 0;
304  // Enable caching of thirdparty count notifications
305  require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
306  $cachekey = 'count_notifications_thirdparty_'.$object->id;
307  $dataretrieved = dol_getcache($cachekey);
308  if (!is_null($dataretrieved)) {
309  $nbNotif = $dataretrieved;
310  } else {
311  $sql = "SELECT COUNT(n.rowid) as nb";
312  $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
313  $sql .= " WHERE fk_soc = ".((int) $object->id);
314  $resql = $db->query($sql);
315  if ($resql) {
316  $obj = $db->fetch_object($resql);
317  $nbNotif = $obj->nb;
318  } else {
319  dol_print_error($db);
320  }
321  dol_setcache($cachekey, $nbNotif, 120); // If setting cache fails, this is not a problem, so we do not test result.
322  }
323 
324  $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.urlencode($object->id);
325  $head[$h][1] = $langs->trans("Notifications");
326  if ($nbNotif > 0) {
327  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNotif.'</span>';
328  }
329  $head[$h][2] = 'notify';
330  $h++;
331  }
332 
333  // Notes
334  $nbNote = 0;
335  if (!empty($object->note_private)) {
336  $nbNote++;
337  }
338  if (!empty($object->note_public)) {
339  $nbNote++;
340  }
341  $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.urlencode($object->id);
342  $head[$h][1] = $langs->trans("Notes");
343  if ($nbNote > 0) {
344  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
345  }
346  $head[$h][2] = 'note';
347  $h++;
348 
349  // Attached files and Links
350  $totalAttached = 0;
351  // Enable caching of thirdrparty count attached files and links
352  require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
353  $cachekey = 'count_attached_thirdparty_'.$object->id;
354  $dataretrieved = dol_getcache($cachekey);
355  if (!is_null($dataretrieved)) {
356  $totalAttached = $dataretrieved;
357  } else {
358  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
359  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
360  $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
361  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
362  $nbLinks = Link::count($db, $object->element, $object->id);
363  $totalAttached = $nbFiles + $nbLinks;
364  dol_setcache($cachekey, $totalAttached, 120); // If setting cache fails, this is not a problem, so we do not test result.
365  }
366 
367  $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id;
368  $head[$h][1] = $langs->trans("Documents");
369  if (($totalAttached) > 0) {
370  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($totalAttached).'</span>';
371  }
372  $head[$h][2] = 'document';
373  $h++;
374  }
375 
376  $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
377  $head[$h][1] = $langs->trans("Events");
378  if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
379  $nbEvent = 0;
380  // Enable caching of thirdparty count actioncomm
381  require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
382  $cachekey = 'count_events_thirdparty_'.$object->id;
383  $dataretrieved = dol_getcache($cachekey);
384  if (!is_null($dataretrieved)) {
385  $nbEvent = $dataretrieved;
386  } else {
387  $sql = "SELECT COUNT(id) as nb";
388  $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
389  $sql .= " WHERE fk_soc = ".((int) $object->id);
390  $resql = $db->query($sql);
391  if ($resql) {
392  $obj = $db->fetch_object($resql);
393  $nbEvent = $obj->nb;
394  } else {
395  dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
396  }
397  dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
398  }
399 
400  $head[$h][1] .= '/';
401  $head[$h][1] .= $langs->trans("Agenda");
402  if ($nbEvent > 0) {
403  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
404  }
405  }
406  $head[$h][2] = 'agenda';
407  $h++;
408 
409  // Show more tabs from modules
410  // Entries must be declared in modules descriptor with line
411  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
412  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
413  complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'add', 'external');
414 
415  complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'remove');
416 
417  return $head;
418 }
419 
420 
427 function societe_prepare_head2($object)
428 {
429  global $langs, $conf, $user;
430  $h = 0;
431  $head = array();
432 
433  $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id;
434  $head[$h][1] = $langs->trans("ThirdParty");
435  $head[$h][2] = 'company';
436  $h++;
437 
438  $head[$h][0] = 'commerciaux.php?socid='.$object->id;
439  $head[$h][1] = $langs->trans("SalesRepresentative");
440  $head[$h][2] = 'salesrepresentative';
441  $h++;
442 
443  return $head;
444 }
445 
446 
447 
454 {
455  global $langs, $conf, $user, $db;
456 
457  $extrafields = new ExtraFields($db);
458  $extrafields->fetch_name_optionals_label('societe');
459  $extrafields->fetch_name_optionals_label('socpeople');
460 
461  $h = 0;
462  $head = array();
463 
464  $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe.php';
465  $head[$h][1] = $langs->trans("Miscellaneous");
466  $head[$h][2] = 'general';
467  $h++;
468 
469  // Show more tabs from modules
470  // Entries must be declared in modules descriptor with line
471  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
472  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
473  complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin');
474 
475  $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe_extrafields.php';
476  $head[$h][1] = $langs->trans("ExtraFieldsThirdParties");
477  $nbExtrafields = $extrafields->attributes['societe']['count'];
478  if ($nbExtrafields > 0) {
479  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
480  }
481  $head[$h][2] = 'attributes';
482  $h++;
483 
484  $head[$h][0] = DOL_URL_ROOT.'/societe/admin/contact_extrafields.php';
485  $head[$h][1] = $langs->trans("ExtraFieldsContacts");
486  $nbExtrafields = $extrafields->attributes['socpeople']['count'];
487  if ($nbExtrafields > 0) {
488  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
489  }
490  $head[$h][2] = 'attributes_contacts';
491  $h++;
492 
493  complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin', 'remove');
494 
495  return $head;
496 }
497 
498 
499 
515 function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '')
516 {
517  global $db, $langs;
518 
519  $result = '';
520 
521  // Check parameters
522  if (empty($searchkey) && empty($searchlabel)) {
523  if ($withcode === 'all') {
524  return array('id'=>'', 'code'=>'', 'label'=>'');
525  } else {
526  return '';
527  }
528  }
529  if (!is_object($dbtouse)) {
530  $dbtouse = $db;
531  }
532  if (!is_object($outputlangs)) {
533  $outputlangs = $langs;
534  }
535 
536  $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country";
537  if (is_numeric($searchkey)) {
538  $sql .= " WHERE rowid = ".((int) $searchkey);
539  } elseif (!empty($searchkey)) {
540  $sql .= " WHERE code = '".$db->escape($searchkey)."'";
541  } else {
542  $sql .= " WHERE label = '".$db->escape($searchlabel)."'";
543  }
544 
545  $resql = $dbtouse->query($sql);
546  if ($resql) {
547  $obj = $dbtouse->fetch_object($resql);
548  if ($obj) {
549  $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : '');
550  if (is_object($outputlangs)) {
551  $outputlangs->load("dict");
552  if ($entconv) {
553  $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label;
554  } else {
555  $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label;
556  }
557  }
558  if ($withcode == 1) {
559  $result = $label ? "$obj->code - $label" : "$obj->code";
560  } elseif ($withcode == 2) {
561  $result = $obj->code;
562  } elseif ($withcode == 3) {
563  $result = $obj->rowid;
564  } elseif ($withcode === 'all') {
565  $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label);
566  } else {
567  $result = $label;
568  }
569  } else {
570  $result = 'NotDefined';
571  }
572  $dbtouse->free($resql);
573  return $result;
574  } else {
575  dol_print_error($dbtouse, '');
576  }
577  return 'Error';
578 }
579 
595 function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1)
596 {
597  global $db, $langs;
598 
599  if (!is_object($dbtouse)) {
600  $dbtouse = $db;
601  }
602 
603  $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM";
604  $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c";
605  $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".((int) $id);
606  $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
607  $sql .= " ORDER BY c.code, d.code_departement";
608 
609  dol_syslog("Company.lib::getState", LOG_DEBUG);
610  $resql = $dbtouse->query($sql);
611  if ($resql) {
612  $obj = $dbtouse->fetch_object($resql);
613  if ($obj) {
614  $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : '');
615  if (is_object($outputlangs)) {
616  $outputlangs->load("dict");
617  if ($entconv) {
618  $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label;
619  } else {
620  $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label;
621  }
622  }
623 
624  if ($withcode == 1) {
625  if ($withregion == 1) {
626  return $label = $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
627  } else {
628  return $label = $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
629  }
630  } elseif ($withcode == 2) {
631  if ($withregion == 1) {
632  return $label = $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
633  } else {
634  return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
635  }
636  } elseif ($withcode === 'all') {
637  if ($withregion == 1) {
638  return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label, 'region_code'=>$obj->region_code, 'region'=>$obj->region_name);
639  } else {
640  return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label);
641  }
642  } else {
643  if ($withregion == 1) {
644  return $label = $obj->region_name.' - '.$label;
645  } else {
646  return $label;
647  }
648  }
649  } else {
650  return $langs->transnoentitiesnoconv("NotDefined");
651  }
652  } else {
653  dol_print_error($dbtouse, '');
654  }
655 
656  return '';
657 }
658 
667 function currency_name($code_iso, $withcode = '', $outputlangs = null)
668 {
669  global $langs, $db;
670 
671  if (empty($outputlangs)) {
672  $outputlangs = $langs;
673  }
674 
675  $outputlangs->load("dict");
676 
677  // If there is a translation, we can send immediatly the label
678  if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) {
679  return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso);
680  }
681 
682  // If no translation, we read table to get label by default
683  $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies";
684  $sql .= " WHERE code_iso='".$db->escape($code_iso)."'";
685 
686  $resql = $db->query($sql);
687  if ($resql) {
688  $num = $db->num_rows($resql);
689 
690  if ($num) {
691  $obj = $db->fetch_object($resql);
692  $label = ($obj->label != '-' ? $obj->label : '');
693  if ($withcode) {
694  return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label";
695  } else {
696  return $label;
697  }
698  } else {
699  return $code_iso;
700  }
701  }
702  return 'ErrorWhenReadingCurrencyLabel';
703 }
704 
711 function getFormeJuridiqueLabel($code)
712 {
713  global $db, $langs;
714 
715  if (!$code) {
716  return '';
717  }
718 
719  $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique";
720  $sql .= " WHERE code = '".$db->escape($code)."'";
721 
722  dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG);
723 
724  $resql = $db->query($sql);
725  if ($resql) {
726  $num = $db->num_rows($resql);
727  if ($num) {
728  $obj = $db->fetch_object($resql);
729 
730  $label = ($obj->libelle != '-' ? $obj->libelle : '');
731 
732  return $langs->trans($label);
733  } else {
734  return $langs->trans("NotDefined");
735  }
736  } else {
737  return 'Error '.$db->lasterror();
738  }
739 }
740 
741 
749 {
750  // List of all country codes that are in europe for european vat rules
751  // List found on https://ec.europa.eu/taxation_customs/territorial-status-eu-countries-and-certain-territories_en
752  global $conf, $db;
753  $country_code_in_EEC = array();
754 
755  if (!empty($conf->cache['country_code_in_EEC'])) {
756  // Use of cache to reduce number of database requests
757  $country_code_in_EEC = $conf->cache['country_code_in_EEC'];
758  } else {
759  $sql = "SELECT cc.code FROM ".MAIN_DB_PREFIX."c_country as cc";
760  $sql .= " WHERE cc.eec = 1";
761 
762  $resql = $db->query($sql);
763  if ($resql) {
764  $num = $db->num_rows($resql);
765  $i = 0;
766  while ($i < $num) {
767  $objp = $db->fetch_object($resql);
768  $country_code_in_EEC[] = $objp->code;
769  $i++;
770  }
771  } else {
772  dol_print_error($db);
773  }
774  $conf->cache['country_code_in_EEC'] = $country_code_in_EEC;
775  }
776  return $country_code_in_EEC;
777 }
778 
785 function isInEEC($object)
786 {
787  if (empty($object->country_code)) {
788  return false;
789  }
790 
791  $country_code_in_EEC = getCountriesInEEC(); // This make a database call but there is a cache done into $conf->cache['country_code_in_EEC']
792 
793  //print "dd".$object->country_code;
794  return in_array($object->country_code, $country_code_in_EEC);
795 }
796 
797 
810 function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '')
811 {
812  global $user, $action, $hookmanager;
813 
814  $i = -1;
815 
816  if (isModEnabled('project') && $user->hasRight('projet', 'lire')) {
817  $langs->load("projects");
818 
819  $newcardbutton = '';
820  if (isModEnabled('project') && $user->hasRight('projet', 'creer') && empty($nocreatelink)) {
821  $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage));
822  }
823 
824  print "\n";
825  print load_fiche_titre($langs->trans("ProjectsDedicatedToThisThirdParty"), $newcardbutton.$morehtmlright, '');
826 
827  print '<div class="div-table-responsive">'."\n";
828  print '<table class="noborder centpercent">';
829 
830  $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
831  $sql .= ", cls.code as opp_status_code";
832  $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
833  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
834  $sql .= " WHERE p.fk_soc = ".((int) $object->id);
835  $sql .= " AND p.entity IN (".getEntity('project').")";
836  $sql .= " ORDER BY p.dateo DESC";
837 
838  $result = $db->query($sql);
839  if ($result) {
840  $num = $db->num_rows($result);
841 
842  print '<tr class="liste_titre">';
843  print '<td>'.$langs->trans("Ref").'</td>';
844  print '<td>'.$langs->trans("Name").'</td>';
845  print '<td class="center">'.$langs->trans("DateStart").'</td>';
846  print '<td class="center">'.$langs->trans("DateEnd").'</td>';
847  print '<td class="right">'.$langs->trans("OpportunityAmountShort").'</td>';
848  print '<td class="center">'.$langs->trans("OpportunityStatusShort").'</td>';
849  print '<td class="right">'.$langs->trans("OpportunityProbabilityShort").'</td>';
850  print '<td class="right">'.$langs->trans("Status").'</td>';
851  print '</tr>';
852 
853  if ($num > 0) {
854  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
855 
856  $projecttmp = new Project($db);
857 
858  $i = 0;
859 
860  while ($i < $num) {
861  $obj = $db->fetch_object($result);
862  $projecttmp->fetch($obj->id);
863 
864  // To verify role of users
865  $userAccess = $projecttmp->restrictedProjectArea($user);
866 
867  if ($user->rights->projet->lire && $userAccess > 0) {
868  print '<tr class="oddeven">';
869 
870  // Ref
871  print '<td class="nowraponall">';
872  print $projecttmp->getNomUrl(1);
873  print '</td>';
874 
875  // Label
876  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">'.dol_escape_htmltag($obj->title).'</td>';
877  // Date start
878  print '<td class="center">'.dol_print_date($db->jdate($obj->do), "day").'</td>';
879  // Date end
880  print '<td class="center">'.dol_print_date($db->jdate($obj->de), "day").'</td>';
881  // Opp amount
882  print '<td class="right">';
883  if ($obj->opp_status_code) {
884  print price($obj->opp_amount, 1, '', 1, -1, -1, '');
885  }
886  print '</td>';
887  // Opp status
888  print '<td class="center">';
889  if ($obj->opp_status_code) {
890  print $langs->trans("OppStatus".$obj->opp_status_code);
891  }
892  print '</td>';
893  // Opp percent
894  print '<td class="right">';
895  if ($obj->opp_percent) {
896  print price($obj->opp_percent, 1, '', 1, 0).'%';
897  }
898  print '</td>';
899  // Status
900  print '<td class="right">'.$projecttmp->getLibStatut(5).'</td>';
901 
902  print '</tr>';
903  }
904  $i++;
905  }
906  } else {
907  print '<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
908  }
909  $db->free($result);
910  } else {
911  dol_print_error($db);
912  }
913 
914  $parameters = array('sql'=>$sql, 'function'=>'show_projects');
915  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
916  print $hookmanager->resPrint;
917 
918  print "</table>";
919  print '</div>';
920 
921  print "<br>\n";
922  }
923 
924  return $i;
925 }
926 
927 
939 function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserlogin = 0)
940 {
941  global $user, $conf, $extrafields, $hookmanager;
942  global $contextpage;
943 
944  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
945  $formcompany = new FormCompany($db);
946  $form = new Form($db);
947 
948  $optioncss = GETPOST('optioncss', 'alpha');
949  $sortfield = GETPOST('sortfield', 'aZ09comma');
950  $sortorder = GETPOST('sortorder', 'aZ09comma');
951  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
952 
953  $search_status = GETPOST("search_status", 'int');
954  if ($search_status == '') {
955  $search_status = 1; // always display active customer first
956  }
957 
958  $search_rowid = GETPOST("search_rowid", 'int');
959  $search_name = GETPOST("search_name", 'alpha');
960  $search_address = GETPOST("search_address", 'alpha');
961  $search_poste = GETPOST("search_poste", 'alpha');
962  $search_note_private = GETPOST('search_note_private', 'alphanohtml');
963  $search_roles = GETPOST("search_roles", 'array');
964  $search_birthday_dtstart = GETPOST("search_birthday_dtstart", 'alpha');
965  $search_birthday_dtend = GETPOST("search_birthday_dtend", 'alpha');
966 
967  if ($search_birthday_dtstart != '' || $search_birthday_dtend != '') {
968  $search_birthday_dtstart = dol_mktime(0, 0, 0, GETPOST('search_birthday_dtstartmonth', 'int'), GETPOST('search_birthday_dtstartday', 'int'), GETPOST('search_birthday_dtstartyear', 'int'));
969  $search_birthday_dtend = dol_mktime(23, 59, 59, GETPOST('search_birthday_dtendmonth', 'int'), GETPOST('search_birthday_dtendday', 'int'), GETPOST('search_birthday_dtendyear', 'int'));
970  }
971  $socialnetworks = getArrayOfSocialNetworks();
972 
973  $searchAddressPhoneDBFields = array(
974  //Address
975  't.address',
976  't.zip',
977  't.town',
978 
979  //Phone
980  't.phone',
981  't.phone_perso',
982  't.phone_mobile',
983 
984  //Fax
985  't.fax',
986 
987  //E-mail
988  't.email',
989  );
990  //Social media
991  // foreach ($socialnetworks as $key => $value) {
992  // if ($value['active']) {
993  // $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'";
994  // }
995  // }
996 
997  if (!$sortorder) {
998  $sortorder = "ASC";
999  }
1000  if (!$sortfield) {
1001  $sortfield = "t.lastname";
1002  }
1003 
1004  if (isModEnabled('clicktodial')) {
1005  $user->fetch_clicktodial(); // lecture des infos de clicktodial du user
1006  }
1007 
1008 
1009  $contactstatic = new Contact($db);
1010 
1011  $extrafields->fetch_name_optionals_label($contactstatic->table_element);
1012 
1013  $contactstatic->fields = array(
1014  'rowid' =>array('type'=>'integer', 'label'=>"TechnicalID", 'enabled'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0), 'visible'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0), 'position'=>1),
1015  'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
1016  'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>2, 'index'=>1, 'position'=>20),
1017  'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>3, 'index'=>1, 'position'=>30),
1018  'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'visible'=>3, 'position'=>35),
1019  'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>4, 'index'=>1, 'position'=>40),
1020  'birthday' =>array('type'=>'date', 'label'=>'Birthday', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 0, 'position'=>45),
1021  'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))),
1022  );
1023 
1024  // Definition of fields for list
1025  $arrayfields = array(
1026  't.rowid'=>array('label'=>"TechnicalID", 'checked'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0), 'enabled'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0), 'position'=>1),
1027  't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10),
1028  't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20),
1029  't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30),
1030  't.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position'=>35),
1031  'sc.role'=>array('label'=>"ContactByDefaultFor", 'checked'=>1, 'position'=>40),
1032  't.birthday'=>array('label'=>"Birthday", 'checked'=>0, 'position'=>45),
1033  't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'),
1034  );
1035  // Extra fields
1036  if (!empty($extrafields->attributes[$contactstatic->table_element]['label']) && is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) {
1037  foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) {
1038  if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) {
1039  $arrayfields["ef.".$key] = array(
1040  'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key],
1041  'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1),
1042  'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key],
1043  'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key]));
1044  }
1045  }
1046  }
1047 
1048  // Initialize array of search criterias
1049  $search = array();
1050  foreach ($arrayfields as $key => $val) {
1051  $queryName = 'search_'.substr($key, 2);
1052  if (GETPOST($queryName, 'alpha')) {
1053  $search[substr($key, 2)] = GETPOST($queryName, 'alpha');
1054  }
1055  }
1056  $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_');
1057 
1058  // Purge search criteria
1059  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
1060  $search_rowid = '';
1061  $search_status = '';
1062  $search_name = '';
1063  $search_roles = array();
1064  $search_address = '';
1065  $search_poste = '';
1066  $search_note_private = '';
1067  $search_birthday_dtstart = '';
1068  $search_birthday_dtend = '';
1069  $search = array();
1070  $search_array_options = array();
1071 
1072  foreach ($contactstatic->fields as $key => $val) {
1073  $search[$key] = '';
1074  }
1075  }
1076 
1077  $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position');
1078  $arrayfields = dol_sort_array($arrayfields, 'position');
1079 
1080  $newcardbutton = '';
1081  if ($user->hasRight('societe', 'contact', 'creer')) {
1082  $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress"));
1083  $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage));
1084  }
1085 
1086  print "\n";
1087 
1088  $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany"));
1089  print load_fiche_titre($title, $newcardbutton, '');
1090 
1091  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
1092  print '<input type="hidden" name="token" value="'.newToken().'">';
1093  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1094  print '<input type="hidden" name="socid" value="'.$object->id.'">';
1095  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1096  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1097  print '<input type="hidden" name="page" value="'.$page.'">';
1098 
1099  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1100  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
1101  //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
1102 
1103  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1104  print "\n".'<table class="tagtable liste">'."\n";
1105 
1106  $param = "socid=".urlencode($object->id);
1107  if ($search_rowid != '') {
1108  $param .= '&search_rowid='.urlencode($search_rowid);
1109  }
1110  if ($search_status != '') {
1111  $param .= '&search_status='.urlencode($search_status);
1112  }
1113  if (count($search_roles) > 0) {
1114  $param .= implode('&search_roles[]=', $search_roles);
1115  }
1116  if ($search_name != '') {
1117  $param .= '&search_name='.urlencode($search_name);
1118  }
1119  if ($search_poste != '') {
1120  $param .= '&search_poste='.urlencode($search_poste);
1121  }
1122  if ($search_address != '') {
1123  $param .= '&search_address='.urlencode($search_address);
1124  }
1125  if ($search_note_private != '') {
1126  $param .= '&search_note_private='.urlencode($search_note_private);
1127  }
1128  if ($search_birthday_dtstart != '') {
1129  $param .= '&search_birthday_dtstart='.urlencode($search_birthday_dtstart);
1130  }
1131  if ($search_birthday_dtend != '') {
1132  $param .= '&search_birthday_dtend='.urlencode($search_birthday_dtend);
1133  }
1134  if ($optioncss != '') {
1135  $param .= '&optioncss='.urlencode($optioncss);
1136  }
1137 
1138  // Add $param from extra fields
1139  $extrafieldsobjectkey = $contactstatic->table_element;
1140  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1141 
1142  $sql = "SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1143  $sql .= " t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo, t.fk_soc,";
1144  $sql .= " t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1145  $sql .= " t.note_private";
1146  $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
1147  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1148  $sql .= " WHERE t.fk_soc = ".((int) $object->id);
1149  $sql .= " AND ((t.fk_user_creat = ".((int) $user->id)." AND t.priv = 1) OR t.priv = 0)";
1150  if ($search_rowid) {
1151  $sql .= natural_search('t.rowid', $search_rowid);
1152  }
1153  if ($search_status != '' && $search_status != '-1') {
1154  $sql .= " AND t.statut = ".((int) $search_status);
1155  }
1156  if ($search_name) {
1157  $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name);
1158  }
1159  if ($search_poste) {
1160  $sql .= natural_search('t.poste', $search_poste);
1161  }
1162  if ($search_address) {
1163  $sql .= natural_search($searchAddressPhoneDBFields, $search_address);
1164  }
1165  if ($search_note_private) {
1166  $sql .= natural_search('t.note_private', $search_note_private);
1167  }
1168  if ($search_birthday_dtstart != '') {
1169  $sql .= " AND t.birthday >= '".$db->idate($search_birthday_dtstart)."'";
1170  }
1171  if ($search_birthday_dtend != '') {
1172  $sql .= " AND t.birthday <= '".$db->idate($search_birthday_dtend)."'";
1173  }
1174  if (count($search_roles) > 0) {
1175  $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".$db->sanitize(implode(',', $search_roles))."))";
1176  }
1177  // Add where from extra fields
1178  $extrafieldsobjectkey = $contactstatic->table_element;
1179  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
1180  // Add where from hooks
1181  $parameters = array('socid' => $object->id);
1182  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
1183  $sql .= $hookmanager->resPrint;
1184  if ($sortfield == "t.name") {
1185  $sql .= " ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1186  } else {
1187  $sql .= " ORDER BY $sortfield $sortorder";
1188  }
1189 
1190  dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1191  $result = $db->query($sql);
1192  if (!$result) {
1193  dol_print_error($db);
1194  }
1195 
1196  $num = $db->num_rows($result);
1197 
1198  // Fields title search
1199  // --------------------------------------------------------------------
1200  print '<tr class="liste_titre">';
1201  foreach ($contactstatic->fields as $key => $val) {
1202  $align = '';
1203  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1204  $align .= ($align ? ' ' : '').'center';
1205  }
1206  if (in_array($val['type'], array('timestamp'))) {
1207  $align .= ($align ? ' ' : '').'nowrap';
1208  }
1209  if ($key == 'status' || $key == 'statut') {
1210  $align .= ($align ? ' ' : '').'center';
1211  }
1212  if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) {
1213  print '<td class="liste_titre'.($align ? ' '.$align : '').'">';
1214  if (in_array($key, array('statut'))) {
1215  print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage');
1216  } elseif (in_array($key, array('role'))) {
1217  print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles, 'minwidth200 maxwidth300');
1218  } elseif (in_array($key, array('birthday'))) {
1219  print '<div class="nowrap">';
1220  print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart : '', "search_birthday_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1221  print '</div>';
1222  print '<div class="nowrap">';
1223  print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend : '', "search_birthday_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1224  print '</div>';
1225  } else {
1226  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.(!empty($search[$key]) ? dol_escape_htmltag($search[$key]) : '').'">';
1227  }
1228  print '</td>';
1229  }
1230  }
1231  if ($showuserlogin) {
1232  print '<td class="liste_titre"></td>';
1233  }
1234  // Extra fields
1235  $extrafieldsobjectkey = $contactstatic->table_element;
1236  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1237 
1238  // Fields from hook
1239  $parameters = array('arrayfields'=>$arrayfields);
1240  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook
1241  print $hookmanager->resPrint;
1242  // Action column
1243  print '<td class="liste_titre" align="right">';
1244  print $form->showFilterButtons();
1245  print '</td>';
1246  print '</tr>'."\n";
1247 
1248 
1249  // Fields title label
1250  // --------------------------------------------------------------------
1251  print '<tr class="liste_titre">';
1252  foreach ($contactstatic->fields as $key => $val) {
1253  $align = '';
1254  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1255  $align .= ($align ? ' ' : '').'center';
1256  }
1257  if (in_array($val['type'], array('timestamp'))) {
1258  $align .= ($align ? ' ' : '').'nowrap';
1259  }
1260  if ($key == 'status' || $key == 'statut') {
1261  $align .= ($align ? ' ' : '').'center';
1262  }
1263  if (!empty($arrayfields['t.'.$key]['checked'])) {
1264  print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
1265  }
1266  if ($key == 'role') {
1267  $align .= ($align ? ' ' : '').'left';
1268  }
1269  if (!empty($arrayfields['sc.'.$key]['checked'])) {
1270  print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], '', '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
1271  }
1272  }
1273  if ($showuserlogin) {
1274  print '<th class="wrapcolumntitle liste_titre">'.$langs->trans("DolibarrLogin").'</th>';
1275  }
1276  // Extra fields
1277  $extrafieldsobjectkey = $contactstatic->table_element;
1278  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1279  // Hook fields
1280  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1281  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
1282  print $hookmanager->resPrint;
1283  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
1284  print '</tr>'."\n";
1285 
1286  $i = -1;
1287 
1288  if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) {
1289  $i = 0;
1290 
1291  while ($i < $num) {
1292  $obj = $db->fetch_object($result);
1293 
1294  $contactstatic->id = $obj->rowid;
1295  $contactstatic->ref = $obj->rowid;
1296  $contactstatic->statut = $obj->statut;
1297  $contactstatic->lastname = $obj->lastname;
1298  $contactstatic->firstname = $obj->firstname;
1299  $contactstatic->civility_id = $obj->civility_id;
1300  $contactstatic->civility_code = $obj->civility_id;
1301  $contactstatic->poste = $obj->poste;
1302  $contactstatic->address = $obj->address;
1303  $contactstatic->zip = $obj->zip;
1304  $contactstatic->town = $obj->town;
1305  $contactstatic->phone_pro = $obj->phone_pro;
1306  $contactstatic->phone_mobile = $obj->phone_mobile;
1307  $contactstatic->phone_perso = $obj->phone_perso;
1308  $contactstatic->email = $obj->email;
1309  $contactstatic->socialnetworks = $obj->socialnetworks;
1310  $contactstatic->photo = $obj->photo;
1311  $contactstatic->fk_soc = $obj->fk_soc;
1312  $contactstatic->entity = $obj->entity;
1313 
1314  $country_code = getCountry($obj->country_id, 2);
1315  $contactstatic->country_code = $country_code;
1316 
1317  $contactstatic->setGenderFromCivility();
1318  $contactstatic->fetch_optionals();
1319 
1320  $resultRole = $contactstatic->fetchRoles();
1321  if ($resultRole < 0) {
1322  setEventMessages(null, $contactstatic->errors, 'errors');
1323  }
1324 
1325  if (is_array($contactstatic->array_options)) {
1326  foreach ($contactstatic->array_options as $key => $val) {
1327  $obj->$key = $val;
1328  }
1329  }
1330 
1331  print '<tr class="oddeven">';
1332 
1333  // ID
1334  if (!empty($arrayfields['t.rowid']['checked'])) {
1335  print '<td>';
1336  print $contactstatic->id;
1337  print '</td>';
1338  }
1339 
1340  // Photo - Name
1341  if (!empty($arrayfields['t.name']['checked'])) {
1342  print '<td>';
1343  print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1);
1344  print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage));
1345  print '</td>';
1346  }
1347 
1348  // Job position
1349  if (!empty($arrayfields['t.poste']['checked'])) {
1350  print '<td>';
1351  if ($obj->poste) {
1352  print $obj->poste;
1353  }
1354  print '</td>';
1355  }
1356 
1357  // Address - Phone - Email
1358  if (!empty($arrayfields['t.address']['checked'])) {
1359  print '<td>';
1360  print $contactstatic->getBannerAddress('contact', $object);
1361  print '</td>';
1362  }
1363 
1364  // Note private
1365  if (!empty($arrayfields['t.note_private']['checked'])) {
1366  print '<td>';
1367  if ($obj->note_private) {
1368  print dol_string_nohtmltag($obj->note_private);
1369  }
1370  print '</td>';
1371  }
1372 
1373  // Role
1374  if (!empty($arrayfields['sc.role']['checked'])) {
1375  print '<td>';
1376  print $formcompany->showRoles("roles", $contactstatic, 'view');
1377  print '</td>';
1378  }
1379 
1380  // Birthday
1381  if (!empty($arrayfields['t.birthday']['checked'])) {
1382  print '<td>';
1383  print dol_print_date($obj->birthday);
1384  print '</td>';
1385  }
1386 
1387  // Status
1388  if (!empty($arrayfields['t.statut']['checked'])) {
1389  print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
1390  }
1391 
1392  if ($showuserlogin) {
1393  print '<td>';
1394  $tmpuser= new User($db);
1395  $resfetch = $tmpuser->fetch(0, '', '', 0, -1, '', $contactstatic->id);
1396  if ($resfetch > 0) {
1397  print $tmpuser->getNomUrl(1, '', 0, 0, 24, 1);
1398  }
1399  print '</td>';
1400  }
1401 
1402  // Extra fields
1403  $extrafieldsobjectkey = $contactstatic->table_element;
1404  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1405 
1406  // Actions
1407  print '<td align="right">';
1408 
1409  // Add to agenda
1410  if (isModEnabled('agenda')&& $user->hasRight('agenda', 'myactions', 'create')) {
1411  print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">';
1412  print img_object($langs->trans("Event"), "action");
1413  print '</a> &nbsp; ';
1414  }
1415 
1416  // Edit
1417  if ($user->hasRight('societe', 'contact', 'creer')) {
1418  print '<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($backtopage).'">';
1419  print img_edit();
1420  print '</a>';
1421  }
1422 
1423  print '</td>';
1424 
1425  print "</tr>\n";
1426  $i++;
1427  }
1428 
1429  if ($num == 0) {
1430  $colspan = 1 + ($showuserlogin ? 1 : 0);
1431  foreach ($arrayfields as $key => $val) {
1432  if (!empty($val['checked'])) {
1433  $colspan++;
1434  }
1435  }
1436  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1437  }
1438  } else {
1439  $colspan = 1 + ($showuserlogin ? 1 : 0);
1440  foreach ($arrayfields as $key => $val) {
1441  if (!empty($val['checked'])) {
1442  $colspan++;
1443  }
1444  }
1445  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
1446  }
1447  print "\n</table>\n";
1448  print '</div>';
1449 
1450  print '</form>'."\n";
1451 
1452  return $i;
1453 }
1454 
1455 
1468 function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '')
1469 {
1470  global $user, $conf;
1471 
1472  $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo');
1473 
1474  if ($noprint) {
1475  return $out;
1476  } else {
1477  print $out;
1478  }
1479 }
1480 
1499 function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
1500 {
1501  global $user, $conf, $hookmanager;
1502  global $form;
1503  global $param, $massactionbutton;
1504 
1505  $start_year = GETPOST('dateevent_startyear', 'int');
1506  $start_month = GETPOST('dateevent_startmonth', 'int');
1507  $start_day = GETPOST('dateevent_startday', 'int');
1508  $end_year = GETPOST('dateevent_endyear', 'int');
1509  $end_month = GETPOST('dateevent_endmonth', 'int');
1510  $end_day = GETPOST('dateevent_endday', 'int');
1511  $tms_start = '';
1512  $tms_end = '';
1513 
1514  if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1515  $tms_start = dol_mktime(0, 0, 0, $start_month, $start_day, $start_year, 'tzuserrel');
1516  }
1517  if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1518  $tms_end = dol_mktime(23, 59, 59, $end_month, $end_day, $end_year, 'tzuserrel');
1519  }
1520  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
1521  $tms_start = '';
1522  $tms_end = '';
1523  }
1524  dol_include_once('/comm/action/class/actioncomm.class.php');
1525 
1526  // Check parameters
1527  if (!is_object($filterobj) && !is_object($objcon)) {
1528  dol_print_error('', 'BadParameter');
1529  }
1530 
1531  $out = '';
1532  $histo = array();
1533  $numaction = 0;
1534  $now = dol_now('tzuser');
1535 
1536  // Open DSI -- Fix order by -- Begin
1537  $sortfield_list = explode(',', $sortfield);
1538  $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent');
1539  $sortfield_new_list = array();
1540  foreach ($sortfield_list as $sortfield_value) {
1541  $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1542  }
1543  $sortfield_new = implode(',', $sortfield_new_list);
1544 
1545  $sql = '';
1546 
1547  if (isModEnabled('agenda')) {
1548  // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
1549  $hookmanager->initHooks(array('agendadao'));
1550 
1551  // Recherche histo sur actioncomm
1552  if (is_object($objcon) && $objcon->id > 0) {
1553  $sql = "SELECT DISTINCT a.id, a.label as label,";
1554  } else {
1555  $sql = "SELECT a.id, a.label as label,";
1556  }
1557  $sql .= " a.datep as dp,";
1558  $sql .= " a.datep2 as dp2,";
1559  $sql .= " a.percent as percent, 'action' as type,";
1560  $sql .= " a.fk_element, a.elementtype,";
1561  $sql .= " a.fk_contact,";
1562  $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,";
1563  $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
1564  if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) {
1565  $sql .= ", sp.lastname, sp.firstname";
1566  } elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {
1567  /* Nothing */
1568  } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') {
1569  /* Nothing */
1570  } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
1571  $sql .= ", m.lastname, m.firstname";
1572  } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
1573  $sql .= ", o.ref";
1574  } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
1575  $sql .= ", o.ref";
1576  } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
1577  $sql .= ", o.ref";
1578  } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') {
1579  $sql .= ", o.ref";
1580  } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') {
1581  $sql .= ", o.ref";
1582  } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && $filterobj->table_element && $filterobj->element) {
1583  if (!empty($filterobj->fields['ref'])) {
1584  $sql .= ", o.ref";
1585  } elseif (!empty($filterobj->fields['label'])) {
1586  $sql .= ", o.label";
1587  }
1588  }
1589 
1590  // Fields from hook
1591  $parameters = array('sql' => &$sql, 'filterobj' => $filterobj, 'objcon' => $objcon);
1592  $reshook = $hookmanager->executeHooks('showActionsDoneListSelect', $parameters); // Note that $action and $object may have been modified by hook
1593  if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1594 
1595  $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
1596  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
1597  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
1598 
1599  $force_filter_contact = false;
1600  if (is_object($objcon) && $objcon->id > 0) {
1601  $force_filter_contact = true;
1602  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm";
1603  $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".((int) $objcon->id);
1604  }
1605 
1606  // Fields from hook
1607  $parameters = array('sql' => &$sql, 'filterobj' => $filterobj, 'objcon' => $objcon);
1608  $reshook = $hookmanager->executeHooks('showActionsDoneListFrom', $parameters); // Note that $action and $object may have been modified by hook
1609  if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1610 
1611  if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) {
1612  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
1613  } elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {
1614  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er";
1615  $sql .= " ON er.resource_type = 'dolresource'";
1616  $sql .= " AND er.element_id = a.id";
1617  $sql .= " AND er.resource_id = ".((int) $filterobj->id);
1618  } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') {
1619  /* Nothing */
1620  } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
1621  $sql .= ", ".MAIN_DB_PREFIX."adherent as m";
1622  } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
1623  $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o";
1624  } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
1625  $sql .= ", ".MAIN_DB_PREFIX."product as o";
1626  } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
1627  $sql .= ", ".MAIN_DB_PREFIX."ticket as o";
1628  } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') {
1629  $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o";
1630  } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') {
1631  $sql .= ", ".MAIN_DB_PREFIX."contrat as o";
1632  } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && (!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref']) || $filterobj->fields['label'] && is_array($filterobj->fields['label'])) && $filterobj->table_element && $filterobj->element) {
1633  $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o";
1634  }
1635 
1636  $sql .= " WHERE a.entity IN (".getEntity('agenda').")";
1637  if ($force_filter_contact === false) {
1638  if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) {
1639  $sql .= " AND a.fk_soc = ".((int) $filterobj->id);
1640  } elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {
1641  /* Nothing */
1642  } elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) {
1643  $sql .= " AND a.fk_project = ".((int) $filterobj->id);
1644  } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
1645  $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
1646  if ($filterobj->id) {
1647  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1648  }
1649  } elseif (is_object($filterobj) && get_class($filterobj) == 'Commande') {
1650  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order'";
1651  if ($filterobj->id) {
1652  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1653  }
1654  } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
1655  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
1656  if ($filterobj->id) {
1657  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1658  }
1659  } elseif (is_object($filterobj) && get_class($filterobj) == 'Facture') {
1660  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
1661  if ($filterobj->id) {
1662  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1663  }
1664  } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
1665  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'";
1666  if ($filterobj->id) {
1667  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1668  }
1669  } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
1670  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
1671  if ($filterobj->id) {
1672  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1673  }
1674  } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') {
1675  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
1676  if ($filterobj->id) {
1677  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1678  }
1679  } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') {
1680  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
1681  if ($filterobj->id) {
1682  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1683  }
1684  } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && (!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref']) || $filterobj->fields['label'] && is_array($filterobj->fields['label'])) && $filterobj->table_element && $filterobj->element) {
1685  // Generic case
1686  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? "@".$module : "")."'";
1687  if ($filterobj->id) {
1688  $sql .= " AND a.fk_element = ".((int) $filterobj->id);
1689  }
1690  }
1691  }
1692 
1693  if (!empty($tms_start) && !empty($tms_end)) {
1694  $sql .= " AND ((a.datep BETWEEN '".$db->idate($tms_start)."' AND '".$db->idate($tms_end)."') OR (a.datep2 BETWEEN '".$db->idate($tms_start)."' AND '".$db->idate($tms_end)."'))";
1695  } elseif (empty($tms_start) && !empty($tms_end)) {
1696  $sql .= " AND ((a.datep <= '".$db->idate($tms_end)."') OR (a.datep2 <= '".$db->idate($tms_end)."'))";
1697  } elseif (!empty($tms_start) && empty($tms_end)) {
1698  $sql .= " AND ((a.datep >= '".$db->idate($tms_start)."') OR (a.datep2 >= '".$db->idate($tms_start)."'))";
1699  }
1700 
1701  if (is_array($actioncode) && !empty($actioncode)) {
1702  $sql .= ' AND (';
1703  foreach ($actioncode as $key => $code) {
1704  if ($key != 0) {
1705  $sql .= "OR (";
1706  }
1707  if (!empty($code)) {
1708  addEventTypeSQL($sql, $code);
1709  }
1710  if ($key != 0) {
1711  $sql .= ")";
1712  }
1713  }
1714  $sql .= ')';
1715  } elseif (!empty($actioncode)) {
1716  addEventTypeSQL($sql, $actioncode);
1717  }
1718 
1719  addOtherFilterSQL($sql, $donetodo, $now, $filters);
1720 
1721  // Fields from hook
1722  $parameters = array('sql' => &$sql, 'filterobj' => $filterobj, 'objcon' => $objcon, 'module' => $module);
1723  $reshook = $hookmanager->executeHooks('showActionsDoneListWhere', $parameters); // Note that $action and $object may have been modified by hook
1724  if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1725 
1726  if (is_array($actioncode)) {
1727  foreach ($actioncode as $code) {
1728  $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj);
1729  if (!empty($sql2)) {
1730  if (!empty($sql)) {
1731  $sql = $sql." UNION ".$sql2;
1732  } elseif (empty($sql)) {
1733  $sql = $sql2;
1734  }
1735  break;
1736  }
1737  }
1738  } else {
1739  $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj);
1740  if (!empty($sql) && !empty($sql2)) {
1741  $sql = $sql." UNION ".$sql2;
1742  } elseif (empty($sql) && !empty($sql2)) {
1743  $sql = $sql2;
1744  }
1745  }
1746  }
1747 
1748  //TODO Add limit in nb of results
1749  if ($sql) {
1750  $sql .= $db->order($sortfield_new, $sortorder);
1751 
1752  dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
1753 
1754  $resql = $db->query($sql);
1755  if ($resql) {
1756  $i = 0;
1757  $num = $db->num_rows($resql);
1758 
1759  while ($i < $num) {
1760  $obj = $db->fetch_object($resql);
1761 
1762  if ($obj->type == 'action') {
1763  $contactaction = new ActionComm($db);
1764  $contactaction->id = $obj->id;
1765  $result = $contactaction->fetchResources();
1766  if ($result < 0) {
1767  dol_print_error($db);
1768  setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors');
1769  }
1770 
1771  //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
1772  //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
1773  $tododone = '';
1774  if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
1775  $tododone = 'todo';
1776  }
1777 
1778  $histo[$numaction] = array(
1779  'type'=>$obj->type,
1780  'tododone'=>$tododone,
1781  'id'=>$obj->id,
1782  'datestart'=>$db->jdate($obj->dp),
1783  'dateend'=>$db->jdate($obj->dp2),
1784  'note'=>$obj->label,
1785  'percent'=>$obj->percent,
1786 
1787  'userid'=>$obj->user_id,
1788  'login'=>$obj->user_login,
1789  'userfirstname'=>$obj->user_firstname,
1790  'userlastname'=>$obj->user_lastname,
1791  'userphoto'=>$obj->user_photo,
1792 
1793  'contact_id'=>$obj->fk_contact,
1794  'socpeopleassigned' => $contactaction->socpeopleassigned,
1795  'lastname' => empty($obj->lastname) ? '' : $obj->lastname,
1796  'firstname' => empty($obj->firstname) ? '' : $obj->firstname,
1797  'fk_element'=>$obj->fk_element,
1798  'elementtype'=>$obj->elementtype,
1799  // Type of event
1800  'acode'=>$obj->acode,
1801  'alabel'=>$obj->alabel,
1802  'libelle'=>$obj->alabel, // deprecated
1803  'apicto'=>$obj->apicto
1804  );
1805  } else {
1806  $histo[$numaction] = array(
1807  'type'=>$obj->type,
1808  'tododone'=>'done',
1809  'id'=>$obj->id,
1810  'datestart'=>$db->jdate($obj->dp),
1811  'dateend'=>$db->jdate($obj->dp2),
1812  'note'=>$obj->label,
1813  'percent'=>$obj->percent,
1814  'acode'=>$obj->acode,
1815 
1816  'userid'=>$obj->user_id,
1817  'login'=>$obj->user_login,
1818  'userfirstname'=>$obj->user_firstname,
1819  'userlastname'=>$obj->user_lastname,
1820  'userphoto'=>$obj->user_photo
1821  );
1822  }
1823 
1824  $numaction++;
1825  $i++;
1826  }
1827  } else {
1828  dol_print_error($db);
1829  }
1830  }
1831 
1832  if (isModEnabled('agenda')|| (isModEnabled('mailing') && !empty($objcon->email))) {
1833  $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1834 
1835  require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
1836  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1837  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1838  require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
1839 
1840  $formactions = new FormActions($db);
1841 
1842  $actionstatic = new ActionComm($db);
1843  $userstatic = new User($db);
1844  $userlinkcache = array();
1845  $contactstatic = new Contact($db);
1846  $elementlinkcache = array();
1847 
1848  $out .= '<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
1849  $out .= '<input type="hidden" name="token" value="'.newToken().'">';
1850  if ($objcon && get_class($objcon) == 'Contact' &&
1851  (is_null($filterobj) || get_class($filterobj) == 'Societe')) {
1852  $out .= '<input type="hidden" name="id" value="'.$objcon->id.'" />';
1853  } else {
1854  $out .= '<input type="hidden" name="id" value="'.$filterobj->id.'" />';
1855  }
1856  if ($filterobj && get_class($filterobj) == 'Societe') {
1857  $out .= '<input type="hidden" name="socid" value="'.$filterobj->id.'" />';
1858  }
1859 
1860  $out .= "\n";
1861 
1862  $out .= '<div class="div-table-responsive-no-min">';
1863  $out .= '<table class="noborder centpercent">';
1864 
1865  $out .= '<tr class="liste_titre">';
1866  if ($donetodo) {
1867  $out .= '<td class="liste_titre"></td>';
1868  }
1869 
1870  $out .= '<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="'.(isset($filters['search_rowid']) ? $filters['search_rowid'] : '').'"></td>';
1871  $out .= '<td class="liste_titre"></td>';
1872  $out .= '<td class="liste_titre">';
1873  $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, (empty($conf->global->AGENDA_USE_MULTISELECT_TYPE) ? 0 : 1), 1, 'minwidth100 maxwidth150');
1874  $out .= '</td>';
1875  $out .= '<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters['search_agenda_label'].'"></td>';
1876  $out .= '<td class="liste_titre center">';
1877  $out .= $form->selectDateToDate($tms_start, $tms_end, 'dateevent', 1);
1878  $out .= '</td>';
1879  $out .= '<td class="liste_titre"></td>';
1880  $out .= '<td class="liste_titre"></td>';
1881  $out .= '<td class="liste_titre"></td>';
1882  // Action column
1883  $out .= '<td class="liste_titre" align="middle">';
1884  $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1885  $out .= $searchpicto;
1886  $out .= '</td>';
1887  $out .= '</tr>';
1888 
1889  $out .= '<tr class="liste_titre">';
1890  if ($donetodo) {
1891  $tmp = '';
1892  if (get_class($filterobj) == 'Societe') {
1893  $tmp .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.'&status=done">';
1894  }
1895  $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : '');
1896  $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : '');
1897  $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : '');
1898  //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort");
1899  if (get_class($filterobj) == 'Societe') {
1900  $tmp .= '</a>';
1901  }
1902  $out .= getTitleFieldOfList($tmp);
1903  }
1904  $out .= getTitleFieldOfList("Ref", 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder);
1905  $out .= getTitleFieldOfList("Owner");
1906  $out .= getTitleFieldOfList("Type");
1907  $out .= getTitleFieldOfList("Label", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
1908  $out .= getTitleFieldOfList("Date", 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, '', $sortfield, $sortorder, 'center ');
1909  $out .= getTitleFieldOfList("RelatedObjects", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
1910  $out .= getTitleFieldOfList("ActionOnContact", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'tdoverflowmax125 ', 0, '', 0);
1911  $out .= getTitleFieldOfList("Status", 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, '', $sortfield, $sortorder, 'center ');
1912  $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch ');
1913  $out .= '</tr>';
1914 
1915  require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
1916  $caction = new CActionComm($db);
1917  $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
1918 
1919  foreach ($histo as $key => $value) {
1920  $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
1921 
1922  $actionstatic->type_picto = $histo[$key]['apicto'];
1923  $actionstatic->type_code = $histo[$key]['acode'];
1924 
1925  $out .= '<tr class="oddeven">';
1926 
1927  // Done or todo
1928  if ($donetodo) {
1929  $out .= '<td class="nowrap">';
1930  $out .= '</td>';
1931  }
1932 
1933  // Ref
1934  $out .= '<td class="nowraponall">';
1935  if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
1936  $out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
1937  $out .= $histo[$key]['id'];
1938  $out .= '</a>';
1939  } else {
1940  $out .= $actionstatic->getNomUrl(1, -1);
1941  }
1942  $out .= '</td>';
1943 
1944  // Author of event
1945  $out .= '<td class="tdoverflowmax150">';
1946  //$userstatic->id=$histo[$key]['userid'];
1947  //$userstatic->login=$histo[$key]['login'];
1948  //$out.=$userstatic->getLoginUrl(1);
1949  if ($histo[$key]['userid'] > 0) {
1950  if (isset($userlinkcache[$histo[$key]['userid']])) {
1951  $link = $userlinkcache[$histo[$key]['userid']];
1952  } else {
1953  $userstatic->fetch($histo[$key]['userid']);
1954  $link = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
1955  $userlinkcache[$histo[$key]['userid']] = $link;
1956  }
1957  $out .= $link;
1958  }
1959  $out .= '</td>';
1960 
1961  // Type
1962  $labeltype = $actionstatic->type_code;
1963  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
1964  $labeltype = 'AC_OTH';
1965  }
1966  if (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
1967  $labeltype = $langs->trans("Message");
1968  } else {
1969  if (!empty($arraylist[$labeltype])) {
1970  $labeltype = $arraylist[$labeltype];
1971  }
1972  if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
1973  $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code
1974  }
1975  }
1976  $out .= '<td class="tdoverflowmax150" title="'.$labeltype.'">';
1977  $out .= $actionstatic->getTypePicto();
1978  $out .= $labeltype;
1979  $out .= '</td>';
1980 
1981  // Title/Label of event
1982  $out .= '<td class="tdoverflowmax300"';
1983  if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') {
1984  $transcode = $langs->trans("Action".$histo[$key]['acode']);
1985  $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']);
1986  //$actionstatic->libelle=$libelle;
1987  $libelle = $histo[$key]['note'];
1988  $actionstatic->id = $histo[$key]['id'];
1989  $out .= ' title="'.dol_escape_htmltag($libelle).'">';
1990  $out .= dol_trunc($libelle, 120);
1991  }
1992  if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
1993  $out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
1994  $transcode = $langs->trans("Action".$histo[$key]['acode']);
1995  $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
1996  $out .= ' title="'.dol_escape_htmltag($libelle).'">';
1997  $out .= dol_trunc($libelle, 120);
1998  }
1999  $out .= '</td>';
2000 
2001  // Date
2002  $out .= '<td class="center nowraponall">';
2003  $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel');
2004  if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) {
2005  $tmpa = dol_getdate($histo[$key]['datestart'], true);
2006  $tmpb = dol_getdate($histo[$key]['dateend'], true);
2007  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
2008  $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel');
2009  } else {
2010  $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel');
2011  }
2012  }
2013  $late = 0;
2014  if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) {
2015  $late = 1;
2016  }
2017  if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) {
2018  $late = 1;
2019  }
2020  if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) {
2021  $late = 1;
2022  }
2023  if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) {
2024  $late = 1;
2025  }
2026  if ($late) {
2027  $out .= img_warning($langs->trans("Late")).' ';
2028  }
2029  $out .= "</td>\n";
2030 
2031  // Title of event
2032  //$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
2033 
2034  // Linked object
2035  $out .= '<td class="nowraponall">';
2036  if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) {
2037  if (isset($elementlinkcache[$histo[$key]['elementtype']]) && isset($elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']])) {
2038  $link = $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']];
2039  } else {
2040  if (!isset($elementlinkcache[$histo[$key]['elementtype']])) {
2041  $elementlinkcache[$histo[$key]['elementtype']] = array();
2042  }
2043  $link = dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1);
2044  $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']] = $link;
2045  }
2046  $out .= $link;
2047  } else {
2048  $out .= '&nbsp;';
2049  }
2050  $out .= '</td>';
2051 
2052  // Contact(s) for action
2053  if (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) {
2054  $out .= '<td class="valignmiddle">';
2055  $contact = new Contact($db);
2056  foreach ($histo[$key]['socpeopleassigned'] as $cid => $cvalue) {
2057  $result = $contact->fetch($cid);
2058 
2059  if ($result < 0) {
2060  dol_print_error($db, $contact->error);
2061  }
2062 
2063  if ($result > 0) {
2064  $out .= $contact->getNomUrl(-3, '', 10, '', -1, 0, 'paddingright');
2065  if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
2066  if (!empty($contact->phone_pro)) {
2067  $out .= '('.dol_print_phone($contact->phone_pro).')';
2068  }
2069  }
2070  $out .= '<div class="paddingright"></div>';
2071  }
2072  }
2073  $out .= '</td>';
2074  } elseif (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) {
2075  $contactstatic->lastname = $histo[$key]['lastname'];
2076  $contactstatic->firstname = $histo[$key]['firstname'];
2077  $contactstatic->id = $histo[$key]['contact_id'];
2078  $contactstatic->photo = $histo[$key]['contact_photo'];
2079  $out .= '<td width="120">'.$contactstatic->getNomUrl(-1, '', 10).'</td>';
2080  } else {
2081  $out .= '<td>&nbsp;</td>';
2082  }
2083 
2084  // Status
2085  $out .= '<td class="nowrap center">'.$actionstatic->LibStatut($histo[$key]['percent'], 2, 0, $histo[$key]['datestart']).'</td>';
2086 
2087  // Actions
2088  $out .= '<td></td>';
2089 
2090  $out .= "</tr>\n";
2091  $i++;
2092  }
2093  if (empty($histo)) {
2094  $colspan = 9;
2095  $out .= '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2096  }
2097 
2098  $out .= "</table>\n";
2099  $out .= "</div>\n";
2100 
2101  $out .= '</form>';
2102  }
2103 
2104  if ($noprint) {
2105  return $out;
2106  } else {
2107  print $out;
2108  }
2109 }
2110 
2120 function show_subsidiaries($conf, $langs, $db, $object)
2121 {
2122  global $user;
2123 
2124  $i = -1;
2125 
2126  $sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas";
2127  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
2128  $sql .= " WHERE s.parent = ".((int) $object->id);
2129  $sql .= " AND s.entity IN (".getEntity('societe').")";
2130  $sql .= " ORDER BY s.nom";
2131 
2132  $result = $db->query($sql);
2133  $num = $db->num_rows($result);
2134 
2135  if ($num) {
2136  $socstatic = new Societe($db);
2137 
2138  print load_fiche_titre($langs->trans("Subsidiaries"), '', '');
2139 
2140  print "\n".'<div class="div-table-responsive-no-min">'."\n";
2141  print '<table class="noborder centpercent">'."\n";
2142 
2143  print '<tr class="liste_titre"><td>'.$langs->trans("Company").'</td>';
2144  print '<td>'.$langs->trans("Address").'</td><td>'.$langs->trans("Zip").'</td>';
2145  print '<td>'.$langs->trans("Town").'</td><td>'.$langs->trans("CustomerCode").'</td>';
2146  print "<td>&nbsp;</td>";
2147  print "</tr>";
2148 
2149  $i = 0;
2150 
2151  while ($i < $num) {
2152  $obj = $db->fetch_object($result);
2153 
2154  $socstatic->id = $obj->rowid;
2155  $socstatic->name = $obj->name;
2156  $socstatic->name_alias = $obj->name_alias;
2157  $socstatic->email = $obj->email;
2158  $socstatic->code_client = $obj->code_client;
2159  $socstatic->code_fournisseur = $obj->code_client;
2160  $socstatic->code_compta = $obj->code_compta;
2161  $socstatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
2162  $socstatic->email = $obj->email;
2163  $socstatic->canvas = $obj->canvas;
2164  $socstatic->client = $obj->client;
2165  $socstatic->fournisseur = $obj->fournisseur;
2166 
2167  print '<tr class="oddeven">';
2168 
2169  print '<td class="tdoverflowmax150">';
2170  print $socstatic->getNomUrl(1);
2171  print '</td>';
2172 
2173  print '<td class="tdoverflowmax400" title="'.dol_escape_htmltag($obj->address).'">'.dol_escape_htmltag($obj->address).'</td>';
2174  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).'">'.$obj->zip.'</td>';
2175  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->town).'">'.$obj->town.'</td>';
2176  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->code_client).'">'.$obj->code_client.'</td>';
2177 
2178  print '<td class="center">';
2179  print '<a class="editfielda" href="'.DOL_URL_ROOT.'/societe/card.php?socid='.((int) $obj->rowid).'&action=edit&token='.newToken().'">';
2180  print img_edit();
2181  print '</a></td>';
2182 
2183  print "</tr>\n";
2184  $i++;
2185  }
2186  print "\n</table>\n";
2187  print '</div>'."\n";
2188  }
2189 
2190  print "<br>\n";
2191 
2192  return $i;
2193 }
2202 function addEventTypeSQL(&$sql, $actioncode, $sqlANDOR = "AND")
2203 {
2204  global $conf, $db;
2205  // Condition on actioncode
2206 
2207  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
2208  if ($actioncode == 'AC_NON_AUTO') {
2209  $sql .= " $sqlANDOR c.type != 'systemauto'";
2210  } elseif ($actioncode == 'AC_ALL_AUTO') {
2211  $sql .= " $sqlANDOR c.type = 'systemauto'";
2212  } else {
2213  if ($actioncode == 'AC_OTH') {
2214  $sql .= " $sqlANDOR c.type != 'systemauto'";
2215  } elseif ($actioncode == 'AC_OTH_AUTO') {
2216  $sql .= " $sqlANDOR c.type = 'systemauto'";
2217  }
2218  }
2219  } else {
2220  if ($actioncode == 'AC_NON_AUTO') {
2221  $sql .= " $sqlANDOR c.type != 'systemauto'";
2222  } elseif ($actioncode == 'AC_ALL_AUTO') {
2223  $sql .= " $sqlANDOR c.type = 'systemauto'";
2224  } else {
2225  $sql .= " $sqlANDOR c.code = '".$db->escape($actioncode)."'";
2226  }
2227  }
2228 
2229  return $sql;
2230 }
2231 
2241 function addOtherFilterSQL(&$sql, $donetodo, $now, $filters)
2242 {
2243  global $db;
2244 
2245  if ($donetodo == 'todo') {
2246  $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
2247  } elseif ($donetodo == 'done') {
2248  $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
2249  }
2250  if (is_array($filters) && !empty($filters['search_agenda_label'])) {
2251  $sql .= natural_search('a.label', $filters['search_agenda_label']);
2252  }
2253  if (is_array($filters) && !empty($filters['search_rowid'])) {
2254  $sql .= natural_search('a.id', $filters['search_rowid'], 1);
2255  }
2256 
2257  return $sql;
2258 }
2259 
2268 function addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
2269 {
2270  global $db;
2271 
2272  // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing.
2273  if (isModEnabled('mailing') && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) {
2274  $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
2275  $sql2 .= ", null as fk_element, '' as elementtype, null as contact_id";
2276  $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
2277  $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action
2278  if (is_object($filterobj) && get_class($filterobj) == 'Societe') {
2279  $sql2 .= ", '' as lastname, '' as firstname";
2280  } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
2281  $sql2 .= ", '' as lastname, '' as firstname";
2282  } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
2283  $sql2 .= ", '' as ref";
2284  } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
2285  $sql2 .= ", '' as ref";
2286  } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
2287  $sql2 .= ", '' as ref";
2288  }
2289  $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u";
2290  $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email.
2291  $sql2 .= " AND mc.statut = 1";
2292  $sql2 .= " AND u.rowid = m.fk_user_valid";
2293  $sql2 .= " AND mc.fk_mailing=m.rowid";
2294 
2295  return $sql2;
2296  } else {
2297  return '';
2298  }
2299 }
2300 
2301 
2302 
2313 function htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null)
2314 {
2315  global $conf;
2316 
2317  $reg = array();
2318 
2319  // Juridical status
2320  $line1 = "";
2321  if ($fromcompany->forme_juridique_code) {
2322  $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
2323  }
2324  // Capital
2325  if ($fromcompany->capital) {
2326  $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
2327  }
2328  // Prof Id 1
2329  if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
2330  $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
2331  if (preg_match('/\((.*)\)/i', $field, $reg)) {
2332  $field = $reg[1];
2333  }
2334  $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
2335  }
2336  // Prof Id 2
2337  if ($fromcompany->idprof2) {
2338  $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
2339  if (preg_match('/\((.*)\)/i', $field, $reg)) {
2340  $field = $reg[1];
2341  }
2342  $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
2343  }
2344 
2345  // Second line of company infos
2346  $line2 = "";
2347  // Prof Id 3
2348  if ($fromcompany->idprof3) {
2349  $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
2350  if (preg_match('/\((.*)\)/i', $field, $reg)) {
2351  $field = $reg[1];
2352  }
2353  $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
2354  }
2355  // Prof Id 4
2356  if ($fromcompany->idprof4) {
2357  $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
2358  if (preg_match('/\((.*)\)/i', $field, $reg)) {
2359  $field = $reg[1];
2360  }
2361  $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
2362  }
2363  // IntraCommunautary VAT
2364  if ($fromcompany->tva_intra != '') {
2365  $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
2366  }
2367 
2368  print '<!-- htmlPrintOnlinePaymentFooter -->'."\n";
2369 
2370  print '<footer class="center paddingleft paddingright opacitymedium">'."\n";
2371  print '<br>';
2372  if ($addformmessage) {
2373  print '<!-- object = '.(empty($object) ? 'undefined' : $object->element).' -->';
2374  print '<br>';
2375 
2376  $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
2377  if (!empty($conf->global->$parammessageform)) {
2378  print $langs->transnoentities($conf->global->$parammessageform);
2379  } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) {
2380  print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
2381  }
2382 
2383  // Add other message if VAT exists
2384  if (!empty($object->total_vat) || !empty($object->total_tva)) {
2385  $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
2386  if (!empty($conf->global->$parammessageform)) {
2387  print $langs->transnoentities($conf->global->$parammessageform);
2388  } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) {
2389  print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
2390  }
2391  }
2392  }
2393 
2394  print '<span style="font-size: 10px;"><br><hr>'."\n";
2395  print $fromcompany->name.'<br>';
2396  print $line1;
2397  if (strlen($line1.$line2) > 50) {
2398  print '<br>';
2399  } else {
2400  print ' - ';
2401  }
2402  print $line2;
2403  print '</span>';
2404  print '</footer>'."\n";
2405 }
dol_getdate
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
Definition: functions.lib.php:2851
dol_setcache
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
Definition: memory.lib.php:68
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:50
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1534
dolGetElementUrl
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
Definition: functions2.lib.php:2119
dol_trunc
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
Definition: functions.lib.php:3985
Project
Class to manage projects.
Definition: project.class.php:36
ActionComm
Class to manage agenda events (actions)
Definition: actioncomm.class.php:38
dol_getcache
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
Definition: memory.lib.php:140
getTitleFieldOfList
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
Definition: functions.lib.php:5241
$sql
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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:745
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5400
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:551
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5031
dol_sort_array
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...
Definition: functions.lib.php:8801
SocieteAccount
Class for SocieteAccount.
Definition: societeaccount.class.php:35
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
htmlPrintOnlineFooter
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
Definition: company.lib.php:2313
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1072
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:62
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4708
show_actions_todo
show_actions_todo($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='')
Show html area with actions to do.
Definition: company.lib.php:1468
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4576
getArrayOfSocialNetworks
getArrayOfSocialNetworks()
Get array of social network dictionary.
Definition: functions.lib.php:3169
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2601
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
getState
getState($id, $withcode='', $dbtouse=0, $withregion=0, $outputlangs='', $entconv=1)
Return state translated from an id.
Definition: company.lib.php:595
show_subsidiaries
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
Definition: company.lib.php:2120
addOtherFilterSQL
addOtherFilterSQL(&$sql, $donetodo, $now, $filters)
Add Event Type SQL.
Definition: company.lib.php:2241
getCountriesInEEC
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
Definition: company.lib.php:748
$formactions
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Definition: agenda_other.php:182
CActionComm
Class to manage different types of events.
Definition: cactioncomm.class.php:29
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9465
currency_name
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
Definition: company.lib.php:667
dolGetButtonTitle
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.
Definition: functions.lib.php:11112
show_actions_done
show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
Definition: company.lib.php:1499
dol_string_nohtmltag
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Definition: functions.lib.php:6965
show_contacts
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
Definition: company.lib.php:939
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1669
setEventMessage
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
Definition: functions.lib.php:8523
Contact
Class to manage contact/addresses.
Definition: contact.class.php:41
show_projects
show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0, $morehtmlright='')
Show html area for list of projects.
Definition: company.lib.php:810
addMailingEventTypeSQL
addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
Add Mailing Event Type SQL.
Definition: company.lib.php:2268
getFormeJuridiqueLabel
getFormeJuridiqueLabel($code)
Return the name translated of juridical status.
Definition: company.lib.php:711
societe_prepare_head2
societe_prepare_head2($object)
Return array of tabs to used on page.
Definition: company.lib.php:427
societe_prepare_head
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11438
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:166
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:101
User
Class to manage Dolibarr users.
Definition: user.class.php:46
societe_admin_prepare_head
societe_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: company.lib.php:453
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:451
natural_search
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...
Definition: functions.lib.php:9872
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4398
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2982
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5750
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:515
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8552
dol_mktime
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...
Definition: functions.lib.php:2894
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:115
addEventTypeSQL
addEventTypeSQL(&$sql, $actioncode, $sqlANDOR="AND")
Add Event Type SQL.
Definition: company.lib.php:2202
isInEEC
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
Definition: company.lib.php:785