dolibarr  13.0.2
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-2019 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  $h = 0;
46  $head = array();
47 
48  $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id;
49  $head[$h][1] = $langs->trans("ThirdParty");
50  $head[$h][2] = 'card';
51  $h++;
52 
53  if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) {
54  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) {
55  //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
56  $nbContact = 0; // TODO
57 
58  $sql = "SELECT COUNT(p.rowid) as nb";
59  $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
60  $sql .= " WHERE p.fk_soc = ".$object->id;
61  $resql = $db->query($sql);
62  if ($resql) {
63  $obj = $db->fetch_object($resql);
64  if ($obj) $nbContact = $obj->nb;
65  }
66 
67  $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id;
68  $head[$h][1] = $langs->trans('ContactsAddresses');
69  if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
70  $head[$h][2] = 'contact';
71  $h++;
72  }
73  } else {
74  $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id;
75  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
76  $head[$h][1] = $langs->trans("ContactsAddresses");
77  if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
78  $head[$h][2] = 'contact';
79  $h++;
80  }
81 
82  if ($object->client == 1 || $object->client == 2 || $object->client == 3) {
83  $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id;
84  $head[$h][1] = '';
85  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect");
86  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) $head[$h][1] .= ' | ';
87  if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) $head[$h][1] .= $langs->trans("Customer");
88  $head[$h][2] = 'customer';
89  $h++;
90 
91  if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
92  $langs->load("products");
93  // price
94  $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id;
95  $head[$h][1] = $langs->trans("CustomerPrices");
96  $head[$h][2] = 'price';
97  $h++;
98  }
99  }
100  $supplier_module_enabled = 0;
101  if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1;
102  if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
103  $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id;
104  $head[$h][1] = $langs->trans("Supplier");
105  $head[$h][2] = 'supplier';
106  $h++;
107  }
108 
109  if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
110  $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
111  $head[$h][1] = $langs->trans("Projects");
112  $nbNote = 0;
113  $sql = "SELECT COUNT(n.rowid) as nb";
114  $sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
115  $sql .= " WHERE fk_soc = ".$object->id;
116  $sql .= " AND entity IN (".getEntity('project').")";
117  $resql = $db->query($sql);
118  if ($resql) {
119  $num = $db->num_rows($resql);
120  $i = 0;
121  while ($i < $num) {
122  $obj = $db->fetch_object($resql);
123  $nbNote = $obj->nb;
124  $i++;
125  }
126  } else {
127  dol_print_error($db);
128  }
129  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
130  $head[$h][2] = 'project';
131  $h++;
132  }
133 
134  // Tab to link resources
135  if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) {
136  $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id;
137  $head[$h][1] = $langs->trans("Resources");
138  $head[$h][2] = 'resources';
139  $h++;
140  }
141 
142  if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
143  // Tab to accountancy
144  if (!empty($conf->accounting->enabled) && $object->client > 0) {
145  $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_customer.php?socid='.$object->id;
146  $head[$h][1] = $langs->trans("TabLetteringCustomer");
147  $head[$h][2] = 'lettering_customer';
148  $h++;
149  }
150 
151  // Tab to accountancy
152  if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) {
153  $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_supplier.php?socid='.$object->id;
154  $head[$h][1] = $langs->trans("TabLetteringSupplier");
155  $head[$h][2] = 'lettering_supplier';
156  $h++;
157  }
158  }
159 
160  // Related items
161  if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
162  && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) {
163  $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id;
164  $head[$h][1] = $langs->trans("Referers");
165  $head[$h][2] = 'consumption';
166  $h++;
167  }
168 
169  // Bank accounts
170  if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) {
171  $nbBankAccount = 0;
172  $foundonexternalonlinesystem = 0;
173  $langs->load("banks");
174 
175  //$title = $langs->trans("BankAccounts");
176  $title = $langs->trans("PaymentInformation");
177 
178  if (!empty($conf->stripe->enabled)) {
179  //$langs->load("stripe");
180  //$title = $langs->trans("BankAccountsAndGateways");
181 
182  $servicestatus = 0;
183  if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) $servicestatus = 1;
184 
185  include_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
186  $societeaccount = new SocieteAccount($db);
187  $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_...
188  if ($stripecu) $foundonexternalonlinesystem++;
189  }
190 
191  $sql = "SELECT COUNT(n.rowid) as nb";
192  $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n";
193  $sql .= " WHERE n.fk_soc = ".$object->id;
194  if (empty($conf->stripe->enabled)) {
195  $sql .= " AND n.stripe_card_ref IS NULL";
196  } else {
197  $sql .= " AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".$servicestatus."))";
198  }
199 
200  $resql = $db->query($sql);
201  if ($resql) {
202  $num = $db->num_rows($resql);
203  $i = 0;
204  while ($i < $num) {
205  $obj = $db->fetch_object($resql);
206  $nbBankAccount = $obj->nb;
207  $i++;
208  }
209  } else {
210  dol_print_error($db);
211  }
212 
213  //if (! empty($conf->stripe->enabled) && $nbBankAccount > 0) $nbBankAccount = '...'; // No way to know exact number
214 
215  $head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
216  $head[$h][1] = $title;
217  if ($foundonexternalonlinesystem) $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
218  elseif ($nbBankAccount > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbBankAccount.'</span>';
219  $head[$h][2] = 'rib';
220  $h++;
221  }
222 
223  if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) {
224  $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id;
225  $head[$h][1] = $langs->trans("WebSiteAccounts");
226  $nbNote = 0;
227  $sql = "SELECT COUNT(n.rowid) as nb";
228  $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n";
229  $sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0';
230  $resql = $db->query($sql);
231  if ($resql) {
232  $num = $db->num_rows($resql);
233  $i = 0;
234  while ($i < $num) {
235  $obj = $db->fetch_object($resql);
236  $nbNote = $obj->nb;
237  $i++;
238  }
239  } else {
240  dol_print_error($db);
241  }
242  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
243  $head[$h][2] = 'website';
244  $h++;
245  }
246 
247  // Show more tabs from modules
248  // Entries must be declared in modules descriptor with line
249  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
250  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
251  complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty');
252 
253  if ($user->socid == 0) {
254  // Notifications
255  if (!empty($conf->notification->enabled)) {
256  $nbNote = 0;
257  $sql = "SELECT COUNT(n.rowid) as nb";
258  $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
259  $sql .= " WHERE fk_soc = ".$object->id;
260  $resql = $db->query($sql);
261  if ($resql) {
262  $num = $db->num_rows($resql);
263  $i = 0;
264  while ($i < $num) {
265  $obj = $db->fetch_object($resql);
266  $nbNote = $obj->nb;
267  $i++;
268  }
269  } else {
270  dol_print_error($db);
271  }
272 
273  $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id;
274  $head[$h][1] = $langs->trans("Notifications");
275  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
276  $head[$h][2] = 'notify';
277  $h++;
278  }
279 
280  // Notes
281  $nbNote = 0;
282  if (!empty($object->note_private)) $nbNote++;
283  if (!empty($object->note_public)) $nbNote++;
284  $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id;
285  $head[$h][1] = $langs->trans("Notes");
286  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
287  $head[$h][2] = 'note';
288  $h++;
289 
290  // Attached files
291  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
292  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
293  $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
294  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
295  $nbLinks = Link::count($db, $object->element, $object->id);
296 
297  $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id;
298  $head[$h][1] = $langs->trans("Documents");
299  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
300  $head[$h][2] = 'document';
301  $h++;
302  }
303 
304  $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
305  $head[$h][1] .= $langs->trans("Events");
306  if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
307  $head[$h][1] .= '/';
308  $head[$h][1] .= $langs->trans("Agenda");
309  }
310  $head[$h][2] = 'agenda';
311  $h++;
312 
313  // Log
314  /*$head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id;
315  $head[$h][1] = $langs->trans("Info");
316  $head[$h][2] = 'info';
317  $h++;*/
318 
319  complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'remove');
320 
321  return $head;
322 }
323 
324 
331 function societe_prepare_head2($object)
332 {
333  global $langs, $conf, $user;
334  $h = 0;
335  $head = array();
336 
337  $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id;
338  $head[$h][1] = $langs->trans("ThirdParty");
339  $head[$h][2] = 'company';
340  $h++;
341 
342  $head[$h][0] = 'commerciaux.php?socid='.$object->id;
343  $head[$h][1] = $langs->trans("SalesRepresentative");
344  $head[$h][2] = 'salesrepresentative';
345  $h++;
346 
347  return $head;
348 }
349 
350 
351 
358 {
359  global $langs, $conf, $user;
360 
361  $h = 0;
362  $head = array();
363 
364  $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe.php';
365  $head[$h][1] = $langs->trans("Miscellaneous");
366  $head[$h][2] = 'general';
367  $h++;
368 
369  // Show more tabs from modules
370  // Entries must be declared in modules descriptor with line
371  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
372  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
373  complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin');
374 
375  $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe_extrafields.php';
376  $head[$h][1] = $langs->trans("ExtraFieldsThirdParties");
377  $head[$h][2] = 'attributes';
378  $h++;
379 
380  $head[$h][0] = DOL_URL_ROOT.'/societe/admin/contact_extrafields.php';
381  $head[$h][1] = $langs->trans("ExtraFieldsContacts");
382  $head[$h][2] = 'attributes_contacts';
383  $h++;
384 
385  complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin', 'remove');
386 
387  return $head;
388 }
389 
390 
391 
407 function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '')
408 {
409  global $db, $langs;
410 
411  $result = '';
412 
413  // Check parameters
414  if (empty($searchkey) && empty($searchlabel)) {
415  if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>'');
416  else return '';
417  }
418  if (!is_object($dbtouse)) $dbtouse = $db;
419  if (!is_object($outputlangs)) $outputlangs = $langs;
420 
421  $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country";
422  if (is_numeric($searchkey)) $sql .= " WHERE rowid=".$searchkey;
423  elseif (!empty($searchkey)) $sql .= " WHERE code='".$db->escape($searchkey)."'";
424  else $sql .= " WHERE label='".$db->escape($searchlabel)."'";
425 
426  $resql = $dbtouse->query($sql);
427  if ($resql) {
428  $obj = $dbtouse->fetch_object($resql);
429  if ($obj) {
430  $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : '');
431  if (is_object($outputlangs)) {
432  $outputlangs->load("dict");
433  if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label;
434  else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label;
435  }
436  if ($withcode == 1) $result = $label ? "$obj->code - $label" : "$obj->code";
437  elseif ($withcode == 2) $result = $obj->code;
438  elseif ($withcode == 3) $result = $obj->rowid;
439  elseif ($withcode === 'all') $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label);
440  else $result = $label;
441  } else {
442  $result = 'NotDefined';
443  }
444  $dbtouse->free($resql);
445  return $result;
446  } else dol_print_error($dbtouse, '');
447  return 'Error';
448 }
449 
465 function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1)
466 {
467  global $db, $langs;
468 
469  if (!is_object($dbtouse)) $dbtouse = $db;
470 
471  $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";
472  $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c";
473  $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id;
474  $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
475  $sql .= " ORDER BY c.code, d.code_departement";
476 
477  dol_syslog("Company.lib::getState", LOG_DEBUG);
478  $resql = $dbtouse->query($sql);
479  if ($resql) {
480  $obj = $dbtouse->fetch_object($resql);
481  if ($obj) {
482  $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : '');
483  if (is_object($outputlangs)) {
484  $outputlangs->load("dict");
485  if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label;
486  else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label;
487  }
488 
489  if ($withcode == 1) {
490  if ($withregion == 1) {
491  return $label = $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
492  } else {
493  return $label = $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
494  }
495  } elseif ($withcode == 2) {
496  if ($withregion == 1) {
497  return $label = $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
498  } else {
499  return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
500  }
501  } elseif ($withcode === 'all') {
502  if ($withregion == 1) {
503  return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label, 'region_code'=>$obj->region_code, 'region'=>$obj->region_name);
504  } else {
505  return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label);
506  }
507  } else {
508  if ($withregion == 1) {
509  return $label = $obj->region_name.' - '.$label;
510  } else {
511  return $label;
512  }
513  }
514  } else {
515  return $langs->transnoentitiesnoconv("NotDefined");
516  }
517  } else dol_print_error($dbtouse, '');
518 }
519 
528 function currency_name($code_iso, $withcode = '', $outputlangs = null)
529 {
530  global $langs, $db;
531 
532  if (empty($outputlangs)) $outputlangs = $langs;
533 
534  $outputlangs->load("dict");
535 
536  // If there is a translation, we can send immediatly the label
537  if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) {
538  return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso);
539  }
540 
541  // If no translation, we read table to get label by default
542  $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies";
543  $sql .= " WHERE code_iso='".$db->escape($code_iso)."'";
544 
545  $resql = $db->query($sql);
546  if ($resql) {
547  $num = $db->num_rows($resql);
548 
549  if ($num) {
550  $obj = $db->fetch_object($resql);
551  $label = ($obj->label != '-' ? $obj->label : '');
552  if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label";
553  else return $label;
554  } else {
555  return $code_iso;
556  }
557  }
558  return 'ErrorWhenReadingCurrencyLabel';
559 }
560 
567 function getFormeJuridiqueLabel($code)
568 {
569  global $db, $langs;
570 
571  if (!$code) return '';
572 
573  $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique";
574  $sql .= " WHERE code='".$db->escape($code)."'";
575 
576  dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG);
577  $resql = $db->query($sql);
578  if ($resql) {
579  $num = $db->num_rows($resql);
580 
581  if ($num) {
582  $obj = $db->fetch_object($resql);
583  $label = ($obj->libelle != '-' ? $obj->libelle : '');
584  return $label;
585  } else {
586  return $langs->trans("NotDefined");
587  }
588  }
589 }
590 
591 
599 {
600  global $conf;
601 
602  // List of all country codes that are in europe for european vat rules
603  // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9
604  $country_code_in_EEC = array(
605  'AT', // Austria
606  'BE', // Belgium
607  'BG', // Bulgaria
608  'CY', // Cyprus
609  'CZ', // Czech republic
610  'DE', // Germany
611  'DK', // Danemark
612  'EE', // Estonia
613  'ES', // Spain
614  'FI', // Finland
615  'FR', // France
616  'GB', // United Kingdom
617  'GR', // Greece
618  'HR', // Croatia
619  'NL', // Holland
620  'HU', // Hungary
621  'IE', // Ireland
622  'IM', // Isle of Man - Included in UK
623  'IT', // Italy
624  'LT', // Lithuania
625  'LU', // Luxembourg
626  'LV', // Latvia
627  'MC', // Monaco - Included in France
628  'MT', // Malta
629  //'NO', // Norway
630  'PL', // Poland
631  'PT', // Portugal
632  'RO', // Romania
633  'SE', // Sweden
634  'SK', // Slovakia
635  'SI', // Slovenia
636  'UK', // United Kingdom
637  //'CH', // Switzerland - No. Swizerland in not in EEC
638  );
639 
640  if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) {
641  // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK'
642  $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC);
643  }
644 
645  return $country_code_in_EEC;
646 }
647 
654 function isInEEC($object)
655 {
656  if (empty($object->country_code)) return false;
657 
658  $country_code_in_EEC = getCountriesInEEC();
659 
660  //print "dd".$this->country_code;
661  return in_array($object->country_code, $country_code_in_EEC);
662 }
663 
664 
677 function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '')
678 {
679  global $user;
680 
681  $i = -1;
682 
683  if (!empty($conf->projet->enabled) && $user->rights->projet->lire) {
684  $langs->load("projects");
685 
686  $newcardbutton = '';
687  if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) {
688  $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));
689  }
690 
691  print "\n";
692  print load_fiche_titre($langs->trans("ProjectsDedicatedToThisThirdParty"), $newcardbutton.$morehtmlright, '');
693  print '<div class="div-table-responsive">';
694  print "\n".'<table class="noborder" width=100%>';
695 
696  $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";
697  $sql .= ", cls.code as opp_status_code";
698  $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
699  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
700  $sql .= " WHERE p.fk_soc = ".$object->id;
701  $sql .= " AND p.entity IN (".getEntity('project').")";
702  $sql .= " ORDER BY p.dateo DESC";
703 
704  $result = $db->query($sql);
705  if ($result) {
706  $num = $db->num_rows($result);
707 
708  print '<tr class="liste_titre">';
709  print '<td>'.$langs->trans("Ref").'</td>';
710  print '<td>'.$langs->trans("Name").'</td>';
711  print '<td class="center">'.$langs->trans("DateStart").'</td>';
712  print '<td class="center">'.$langs->trans("DateEnd").'</td>';
713  print '<td class="right">'.$langs->trans("OpportunityAmountShort").'</td>';
714  print '<td class="center">'.$langs->trans("OpportunityStatusShort").'</td>';
715  print '<td class="right">'.$langs->trans("OpportunityProbabilityShort").'</td>';
716  print '<td class="right">'.$langs->trans("Status").'</td>';
717  print '</tr>';
718 
719  if ($num > 0) {
720  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
721 
722  $projecttmp = new Project($db);
723 
724  $i = 0;
725 
726  while ($i < $num) {
727  $obj = $db->fetch_object($result);
728  $projecttmp->fetch($obj->id);
729 
730  // To verify role of users
731  $userAccess = $projecttmp->restrictedProjectArea($user);
732 
733  if ($user->rights->projet->lire && $userAccess > 0) {
734  print '<tr class="oddeven">';
735 
736  // Ref
737  print '<td>';
738  print $projecttmp->getNomUrl(1);
739  print '</td>';
740 
741  // Label
742  print '<td>'.$obj->title.'</td>';
743  // Date start
744  print '<td class="center">'.dol_print_date($db->jdate($obj->do), "day").'</td>';
745  // Date end
746  print '<td class="center">'.dol_print_date($db->jdate($obj->de), "day").'</td>';
747  // Opp amount
748  print '<td class="right">';
749  if ($obj->opp_status_code) {
750  print price($obj->opp_amount, 1, '', 1, -1, -1, '');
751  }
752  print '</td>';
753  // Opp status
754  print '<td class="center">';
755  if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code);
756  print '</td>';
757  // Opp percent
758  print '<td class="right">';
759  if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%';
760  print '</td>';
761  // Status
762  print '<td class="right">'.$projecttmp->getLibStatut(5).'</td>';
763 
764  print '</tr>';
765  }
766  $i++;
767  }
768  } else {
769  print '<tr class="oddeven"><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
770  }
771  $db->free($result);
772  } else {
773  dol_print_error($db);
774  }
775  print "</table>";
776  print '</div>';
777 
778  print "<br>\n";
779  }
780 
781  return $i;
782 }
783 
784 
795 function show_contacts($conf, $langs, $db, $object, $backtopage = '')
796 {
797  global $user, $conf, $extrafields, $hookmanager;
798  global $contextpage;
799 
800  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
801  $formcompany = new FormCompany($db);
802  $form = new Form($db);
803 
804  $optioncss = GETPOST('optioncss', 'alpha');
805  $sortfield = GETPOST("sortfield", 'alpha');
806  $sortorder = GETPOST("sortorder", 'alpha');
807  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
808 
809  $search_status = GETPOST("search_status", 'int');
810  if ($search_status == '') $search_status = 1; // always display active customer first
811 
812  $search_name = GETPOST("search_name", 'alpha');
813  $search_address = GETPOST("search_address", 'alpha');
814  $search_poste = GETPOST("search_poste", 'alpha');
815  $search_roles = GETPOST("search_roles", 'array');
816 
817  $socialnetworks = getArrayOfSocialNetworks();
818 
819  $searchAddressPhoneDBFields = array(
820  //Address
821  't.address',
822  't.zip',
823  't.town',
824 
825  //Phone
826  't.phone',
827  't.phone_perso',
828  't.phone_mobile',
829 
830  //Fax
831  't.fax',
832 
833  //E-mail
834  't.email',
835  );
836  //Social media
837  foreach ($socialnetworks as $key => $value) {
838  if ($value['active']) {
839  $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'";
840  }
841  }
842 
843  if (!$sortorder) $sortorder = "ASC";
844  if (!$sortfield) $sortfield = "t.lastname";
845 
846  if (!empty($conf->clicktodial->enabled)) {
847  $user->fetch_clicktodial(); // lecture des infos de clicktodial du user
848  }
849 
850 
851  $contactstatic = new Contact($db);
852 
853  $extrafields->fetch_name_optionals_label($contactstatic->table_element);
854 
855  $contactstatic->fields = array(
856  'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
857  'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20),
858  'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30),
859  'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40),
860  '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))),
861  );
862 
863  // Definition of fields for list
864  $arrayfields = array(
865  't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'position'=>1),
866  't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10),
867  't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20),
868  '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),
869  'sc.role'=>array('label'=>"ContactByDefaultFor", 'checked'=>1, 'position'=>40),
870  't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'),
871  );
872  // Extra fields
873  if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) {
874  foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) {
875  if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) {
876  $arrayfields["ef.".$key] = array(
877  'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key],
878  'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1),
879  'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key],
880  'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key]));
881  }
882  }
883  }
884 
885  // Initialize array of search criterias
886  $search = array();
887  foreach ($arrayfields as $key => $val) {
888  $queryName = 'search_'.substr($key, 2);
889  if (GETPOST($queryName, 'alpha')) {
890  $search[substr($key, 2)] = GETPOST($queryName, 'alpha');
891  }
892  }
893  $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_');
894 
895  // Purge search criteria
896  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
897  $search_status = '';
898  $search_name = '';
899  $search_roles = array();
900  $search_address = '';
901  $search_poste = '';
902  $search = array();
903  $search_array_options = array();
904 
905  foreach ($contactstatic->fields as $key => $val) {
906  $search[$key] = '';
907  }
908  }
909 
910  $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position');
911  $arrayfields = dol_sort_array($arrayfields, 'position');
912 
913  $newcardbutton = '';
914  if ($user->rights->societe->contact->creer) {
915  $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress"));
916  $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage));
917  }
918 
919  print "\n";
920 
921  $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany"));
922  print load_fiche_titre($title, $newcardbutton, '');
923 
924  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
925  print '<input type="hidden" name="token" value="'.newToken().'">';
926  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
927  print '<input type="hidden" name="socid" value="'.$object->id.'">';
928  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
929  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
930  print '<input type="hidden" name="page" value="'.$page.'">';
931 
932  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
933  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
934  //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
935 
936  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
937  print "\n".'<table class="tagtable liste">'."\n";
938 
939  $param = "socid=".urlencode($object->id);
940  if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
941  if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles);
942  if ($search_name != '') $param .= '&search_name='.urlencode($search_name);
943  if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste);
944  if ($search_address != '') $param .= '&search_address='.urlencode($search_address);
945  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
946 
947  // Add $param from extra fields
948  $extrafieldsobjectkey = $contactstatic->table_element;
949  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
950 
951  $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,";
952  $sql .= " t.civility as civility_id, t.address, t.zip, t.town";
953  $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
954  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
955  $sql .= " WHERE t.fk_soc = ".$object->id;
956  if ($search_status != '' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status);
957  if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name);
958  if ($search_poste) $sql .= natural_search('t.poste', $search_poste);
959  if ($search_address) {
960  $sql .= natural_search($searchAddressPhoneDBFields, $search_address);
961  }
962  if (count($search_roles) > 0) {
963  $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))";
964  }
965  // Add where from extra fields
966  $extrafieldsobjectkey = $contactstatic->table_element;
967  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
968  if ($sortfield == "t.name") $sql .= " ORDER BY t.lastname $sortorder, t.firstname $sortorder";
969  else $sql .= " ORDER BY $sortfield $sortorder";
970 
971  dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
972  $result = $db->query($sql);
973  if (!$result) dol_print_error($db);
974 
975  $num = $db->num_rows($result);
976 
977  // Fields title search
978  // --------------------------------------------------------------------
979  print '<tr class="liste_titre">';
980  foreach ($contactstatic->fields as $key => $val) {
981  $align = '';
982  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center';
983  if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap';
984  if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center';
985  if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) {
986  print '<td class="liste_titre'.($align ? ' '.$align : '').'">';
987  if (in_array($key, array('statut'))) {
988  print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status);
989  } elseif (in_array($key, array('role'))) {
990  print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles);
991  } else {
992  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
993  }
994  print '</td>';
995  }
996  }
997  // Extra fields
998  $extrafieldsobjectkey = $contactstatic->table_element;
999  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1000 
1001  // Fields from hook
1002  $parameters = array('arrayfields'=>$arrayfields);
1003  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook
1004  print $hookmanager->resPrint;
1005  // Action column
1006  print '<td class="liste_titre" align="right">';
1007  print $form->showFilterButtons();
1008  print '</td>';
1009  print '</tr>'."\n";
1010 
1011 
1012  // Fields title label
1013  // --------------------------------------------------------------------
1014  print '<tr class="liste_titre">';
1015  foreach ($contactstatic->fields as $key => $val) {
1016  $align = '';
1017  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center';
1018  if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap';
1019  if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center';
1020  if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
1021  if ($key == 'role') $align .= ($align ? ' ' : '').'left';
1022  if (!empty($arrayfields['sc.'.$key]['checked'])) {
1023  print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], '', '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
1024  }
1025  }
1026  // Extra fields
1027  $extrafieldsobjectkey = $contactstatic->table_element;
1028  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1029  // Hook fields
1030  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1031  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
1032  print $hookmanager->resPrint;
1033  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
1034  print '</tr>'."\n";
1035 
1036  $i = -1;
1037 
1038  if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) {
1039  $i = 0;
1040 
1041  while ($i < $num) {
1042  $obj = $db->fetch_object($result);
1043 
1044  $contactstatic->id = $obj->rowid;
1045  $contactstatic->ref = $obj->ref;
1046  $contactstatic->statut = $obj->statut;
1047  $contactstatic->lastname = $obj->lastname;
1048  $contactstatic->firstname = $obj->firstname;
1049  $contactstatic->civility_id = $obj->civility_id;
1050  $contactstatic->civility_code = $obj->civility_id;
1051  $contactstatic->poste = $obj->poste;
1052  $contactstatic->address = $obj->address;
1053  $contactstatic->zip = $obj->zip;
1054  $contactstatic->town = $obj->town;
1055  $contactstatic->phone_pro = $obj->phone_pro;
1056  $contactstatic->phone_mobile = $obj->phone_mobile;
1057  $contactstatic->phone_perso = $obj->phone_perso;
1058  $contactstatic->email = $obj->email;
1059  $contactstatic->web = $obj->web;
1060  $contactstatic->socialnetworks = $obj->socialnetworks;
1061  $contactstatic->photo = $obj->photo;
1062 
1063  $country_code = getCountry($obj->country_id, 2);
1064  $contactstatic->country_code = $country_code;
1065 
1066  $contactstatic->setGenderFromCivility();
1067  $contactstatic->fetch_optionals();
1068 
1069  $resultRole = $contactstatic->fetchRoles();
1070  if ($resultRole < 0) {
1071  setEventMessages(null, $contactstatic->errors, 'errors');
1072  }
1073 
1074  if (is_array($contactstatic->array_options)) {
1075  foreach ($contactstatic->array_options as $key => $val) {
1076  $obj->$key = $val;
1077  }
1078  }
1079 
1080  print '<tr class="oddeven">';
1081 
1082  // ID
1083  if (!empty($arrayfields['t.rowid']['checked'])) {
1084  print '<td>';
1085  print $contactstatic->id;
1086  print '</td>';
1087  }
1088 
1089  // Photo - Name
1090  if (!empty($arrayfields['t.name']['checked'])) {
1091  print '<td>';
1092  print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1);
1093  print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage));
1094  print '</td>';
1095  }
1096 
1097  // Job position
1098  if (!empty($arrayfields['t.poste']['checked'])) {
1099  print '<td>';
1100  if ($obj->poste) print $obj->poste;
1101  print '</td>';
1102  }
1103 
1104  // Address - Phone - Email
1105  if (!empty($arrayfields['t.address']['checked'])) {
1106  print '<td>';
1107  print $contactstatic->getBannerAddress('contact', $object);
1108  print '</td>';
1109  }
1110 
1111  // Role
1112  if (!empty($arrayfields['sc.role']['checked'])) {
1113  print '<td>';
1114  print $formcompany->showRoles("roles", $contactstatic, 'view');
1115  print '</td>';
1116  }
1117 
1118  // Status
1119  if (!empty($arrayfields['t.statut']['checked'])) {
1120  print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
1121  }
1122 
1123  // Extra fields
1124  $extrafieldsobjectkey = $contactstatic->table_element;
1125  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1126 
1127  // Actions
1128  print '<td align="right">';
1129 
1130  // Add to agenda
1131  if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
1132  print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">';
1133  print img_object($langs->trans("Event"), "action");
1134  print '</a> &nbsp; ';
1135  }
1136 
1137  // Edit
1138  if ($user->rights->societe->contact->creer) {
1139  print '<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($backtopage).'">';
1140  print img_edit();
1141  print '</a>';
1142  }
1143 
1144  print '</td>';
1145 
1146  print "</tr>\n";
1147  $i++;
1148  }
1149  } else {
1150  $colspan = 1;
1151  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
1152  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
1153  }
1154  print "\n</table>\n";
1155  print '</div>';
1156 
1157  print '</form>'."\n";
1158 
1159  return $i;
1160 }
1161 
1162 
1175 function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '')
1176 {
1177  global $user, $conf;
1178 
1179  $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo');
1180 
1181  if ($noprint) return $out;
1182  else print $out;
1183 }
1184 
1203 function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
1204 {
1205  global $user, $conf;
1206  global $form;
1207 
1208  global $param, $massactionbutton;
1209  $start_year = GETPOST('dateevent_startyear', 'int');
1210  $start_month = GETPOST('dateevent_startmonth', 'int');
1211  $start_day = GETPOST('dateevent_startday', 'int');
1212  $end_year = GETPOST('dateevent_endyear', 'int');
1213  $end_month = GETPOST('dateevent_endmonth', 'int');
1214  $end_day = GETPOST('dateevent_endday', 'int');
1215  $tms_start = '';
1216  $tms_end = '';
1217 
1218  if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1219  $tms_start = dol_mktime(0, 0, 0, $start_month, $start_day, $start_year, 'tzuserrel');
1220  }
1221  if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1222  $tms_end = dol_mktime(23, 59, 59, $end_month, $end_day, $end_year, 'tzuserrel');
1223  }
1224  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
1225  $tms_start = '';
1226  $tms_end = '';
1227  }
1228  dol_include_once('/comm/action/class/actioncomm.class.php');
1229 
1230  // Check parameters
1231  if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter');
1232 
1233  $out = '';
1234  $histo = array();
1235  $numaction = 0;
1236  $now = dol_now('tzuser');
1237 
1238  // Open DSI -- Fix order by -- Begin
1239  $sortfield_list = explode(',', $sortfield);
1240  $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent');
1241  $sortfield_new_list = array();
1242  foreach ($sortfield_list as $sortfield_value) {
1243  $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1244  }
1245  $sortfield_new = implode(',', $sortfield_new_list);
1246 
1247  $sql = '';
1248 
1249  if (!empty($conf->agenda->enabled)) {
1250  // Recherche histo sur actioncomm
1251  if (is_object($objcon) && $objcon->id > 0) {
1252  $sql = "SELECT DISTINCT a.id, a.label as label,";
1253  } else {
1254  $sql = "SELECT a.id, a.label as label,";
1255  }
1256  $sql .= " a.datep as dp,";
1257  $sql .= " a.datep2 as dp2,";
1258  $sql .= " a.percent as percent, 'action' as type,";
1259  $sql .= " a.fk_element, a.elementtype,";
1260  $sql .= " a.fk_contact,";
1261  $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,";
1262  $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";
1263  if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= ", sp.lastname, sp.firstname";
1264  elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname";
1265  elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref";
1266  elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref";
1267  elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref";
1268  elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref";
1269  elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref";
1270  elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", o.ref";
1271 
1272  $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
1273  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
1274  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
1275 
1276  $force_filter_contact = false;
1277  if (is_object($objcon) && $objcon->id > 0) {
1278  $force_filter_contact = true;
1279  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm";
1280  $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id;
1281  }
1282 
1283  if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
1284  elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {
1285  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er";
1286  $sql .= " ON er.resource_type = 'dolresource'";
1287  $sql .= " AND er.element_id = a.id";
1288  $sql .= " AND er.resource_id = ".$filterobj->id;
1289  } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m";
1290  elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o";
1291  elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o";
1292  elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o";
1293  elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o";
1294  elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o";
1295  elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o";
1296 
1297  $sql .= " WHERE a.entity IN (".getEntity('agenda').")";
1298  if ($force_filter_contact === false) {
1299  if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id;
1300  elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ }
1301  elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id;
1302  elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
1303  $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
1304  if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
1305  } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
1306  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
1307  if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
1308  } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
1309  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'";
1310  if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
1311  } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
1312  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
1313  if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
1314  } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') {
1315  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
1316  if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
1317  } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') {
1318  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
1319  if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
1320  } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) {
1321  // Generic case
1322  $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'";
1323  if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
1324  }
1325  }
1326 
1327  if (!empty($tms_start) && !empty($tms_end)) {
1328  $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)."'))";
1329  }
1330  elseif (empty($tms_start) && !empty($tms_end)) {
1331  $sql .= " AND ((a.datep <= '".$db->idate($tms_end)."') OR (a.datep2 <= '".$db->idate($tms_end)."'))";
1332  }
1333  elseif (!empty($tms_start) && empty($tms_end)) {
1334  $sql .= " AND ((a.datep >= '".$db->idate($tms_start)."') OR (a.datep2 >= '".$db->idate($tms_start)."'))";
1335  }
1336 
1337  if (is_array($actioncode) && !empty($actioncode)) {
1338  $sql .= ' AND (';
1339  foreach ($actioncode as $key => $code) {
1340  if ($key != 0) $sql .= "OR (";
1341  if (!empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, "");
1342  if ($key != 0) $sql .= ")";
1343  }
1344  $sql .= ')';
1345  }
1346  elseif (!empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters);
1347 
1348  if (is_array($actioncode)) {
1349  foreach ($actioncode as $code) {
1350  $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj);
1351  if (!empty($sql2)) {
1352  if (!empty($sql)) $sql = $sql." UNION ".$sql2;
1353  elseif (empty($sql)) $sql = $sql2;
1354  break;
1355  }
1356  }
1357  }
1358  else {
1359  $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj);
1360  if (!empty($sql) && !empty($sql2)) {
1361  $sql = $sql." UNION ".$sql2;
1362  }
1363  elseif (empty($sql) && !empty($sql2)) {
1364  $sql = $sql2;
1365  }
1366  }
1367  }
1368 
1369  //TODO Add limit in nb of results
1370  if ($sql) {
1371  $sql .= $db->order($sortfield_new, $sortorder);
1372  dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
1373  $resql = $db->query($sql);
1374  if ($resql) {
1375  $i = 0;
1376  $num = $db->num_rows($resql);
1377 
1378  while ($i < $num) {
1379  $obj = $db->fetch_object($resql);
1380 
1381  if ($obj->type == 'action') {
1382  $contactaction = new ActionComm($db);
1383  $contactaction->id = $obj->id;
1384  $result = $contactaction->fetchResources();
1385  if ($result < 0) {
1386  dol_print_error($db);
1387  setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors');
1388  }
1389 
1390  //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
1391  //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
1392  $tododone = '';
1393  if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo';
1394 
1395  $histo[$numaction] = array(
1396  'type'=>$obj->type,
1397  'tododone'=>$tododone,
1398  'id'=>$obj->id,
1399  'datestart'=>$db->jdate($obj->dp),
1400  'dateend'=>$db->jdate($obj->dp2),
1401  'note'=>$obj->label,
1402  'percent'=>$obj->percent,
1403 
1404  'userid'=>$obj->user_id,
1405  'login'=>$obj->user_login,
1406  'userfirstname'=>$obj->user_firstname,
1407  'userlastname'=>$obj->user_lastname,
1408  'userphoto'=>$obj->user_photo,
1409 
1410  'contact_id'=>$obj->fk_contact,
1411  'socpeopleassigned' => $contactaction->socpeopleassigned,
1412  'lastname'=>$obj->lastname,
1413  'firstname'=>$obj->firstname,
1414  'fk_element'=>$obj->fk_element,
1415  'elementtype'=>$obj->elementtype,
1416  // Type of event
1417  'acode'=>$obj->acode,
1418  'alabel'=>$obj->alabel,
1419  'libelle'=>$obj->alabel, // deprecated
1420  'apicto'=>$obj->apicto
1421  );
1422  } else {
1423  $histo[$numaction] = array(
1424  'type'=>$obj->type,
1425  'tododone'=>'done',
1426  'id'=>$obj->id,
1427  'datestart'=>$db->jdate($obj->dp),
1428  'dateend'=>$db->jdate($obj->dp2),
1429  'note'=>$obj->label,
1430  'percent'=>$obj->percent,
1431  'acode'=>$obj->acode,
1432 
1433  'userid'=>$obj->user_id,
1434  'login'=>$obj->user_login,
1435  'userfirstname'=>$obj->user_firstname,
1436  'userlastname'=>$obj->user_lastname,
1437  'userphoto'=>$obj->user_photo
1438  );
1439  }
1440 
1441  $numaction++;
1442  $i++;
1443  }
1444  } else {
1445  dol_print_error($db);
1446  }
1447  }
1448 
1449  if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) {
1450  $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1451 
1452  require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
1453  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1454  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1455  require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
1456 
1457  $formactions = new FormActions($db);
1458 
1459  $actionstatic = new ActionComm($db);
1460  $userstatic = new User($db);
1461  $userlinkcache = array();
1462  $contactstatic = new Contact($db);
1463  $elementlinkcache = array();
1464 
1465  $out .= '<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
1466  $out .= '<input type="hidden" name="token" value="'.newToken().'">';
1467  if ($objcon && get_class($objcon) == 'Contact' &&
1468  (is_null($filterobj) || get_class($filterobj) == 'Societe')) {
1469  $out .= '<input type="hidden" name="id" value="'.$objcon->id.'" />';
1470  } else {
1471  $out .= '<input type="hidden" name="id" value="'.$filterobj->id.'" />';
1472  }
1473  if ($filterobj && get_class($filterobj) == 'Societe') $out .= '<input type="hidden" name="socid" value="'.$filterobj->id.'" />';
1474 
1475  $out .= "\n";
1476 
1477  $out .= '<div class="div-table-responsive-no-min">';
1478  $out .= '<table class="noborder centpercent">';
1479 
1480  $out .= '<tr class="liste_titre">';
1481  if ($donetodo) {
1482  $out .= '<td class="liste_titre"></td>';
1483  }
1484  $out .= '<td class="liste_titre"></td>';
1485  $out .= '<td class="liste_titre"></td>';
1486  $out .= '<td class="liste_titre">';
1487  $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);
1488  $out .= '</td>';
1489  $out .= '<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters['search_agenda_label'].'"></td>';
1490  $out .= '<td class="liste_titre center">';
1491  $out .= $form->selectDateToDate($tms_start, $tms_end, 'dateevent', 1);
1492  $out .= '</td>';
1493  $out .= '<td class="liste_titre"></td>';
1494  $out .= '<td class="liste_titre"></td>';
1495  $out .= '<td class="liste_titre"></td>';
1496  // Action column
1497  $out .= '<td class="liste_titre" align="middle">';
1498  $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
1499  $out .= $searchpicto;
1500  $out .= '</td>';
1501  $out .= '</tr>';
1502 
1503  $out .= '<tr class="liste_titre">';
1504  if ($donetodo) {
1505  $tmp = '';
1506  if (get_class($filterobj) == 'Societe') $tmp .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&socid='.$filterobj->id.'&status=done">';
1507  $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : '');
1508  $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : '');
1509  $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : '');
1510  //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort");
1511  if (get_class($filterobj) == 'Societe') $tmp .= '</a>';
1512  $out .= getTitleFieldOfList($tmp);
1513  }
1514  $out .= getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder);
1515  $out .= getTitleFieldOfList($langs->trans("Owner"));
1516  $out .= getTitleFieldOfList($langs->trans("Type"));
1517  $out .= getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
1518  $out .= getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder);
1519  $out .= getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
1520  $out .= getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
1521  $out .= getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder);
1522  $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch ');
1523  $out .= '</tr>';
1524 
1525  require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
1526  $caction = new CActionComm($db);
1527  $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
1528 
1529  foreach ($histo as $key => $value) {
1530  $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
1531 
1532  $actionstatic->type_picto = $histo[$key]['apicto'];
1533  $actionstatic->type_code = $histo[$key]['acode'];
1534 
1535  $out .= '<tr class="oddeven">';
1536 
1537  // Done or todo
1538  if ($donetodo) {
1539  $out .= '<td class="nowrap">';
1540  $out .= '</td>';
1541  }
1542 
1543  // Ref
1544  $out .= '<td class="nowraponall">';
1545  if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
1546  $out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
1547  $out .= $histo[$key]['id'];
1548  $out .= '</a>';
1549  } else {
1550  $out .= $actionstatic->getNomUrl(1, -1);
1551  }
1552  $out .= '</td>';
1553 
1554  // Author of event
1555  $out .= '<td class="tdoverflowmax200">';
1556  //$userstatic->id=$histo[$key]['userid'];
1557  //$userstatic->login=$histo[$key]['login'];
1558  //$out.=$userstatic->getLoginUrl(1);
1559  if ($histo[$key]['userid'] > 0) {
1560  if (isset($userlinkcache[$histo[$key]['userid']])) {
1561  $link = $userlinkcache[$histo[$key]['userid']];
1562  } else {
1563  $userstatic->fetch($histo[$key]['userid']);
1564  $link = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
1565  $userlinkcache[$histo[$key]['userid']] = $link;
1566  }
1567  $out .= $link;
1568  }
1569  $out .= '</td>';
1570 
1571  // Type
1572  $out .= '<td>';
1573  // TODO Code common with code into showactions
1574  $imgpicto = '';
1575  if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1576  if ($actionstatic->type_picto) {
1577  $imgpicto .= img_picto('', $actionstatic->type_picto);
1578  }
1579  else {
1580  if ($actionstatic->type_code == 'AC_RDV') $imgpicto .= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
1581  elseif ($actionstatic->type_code == 'AC_TEL') $imgpicto .= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
1582  elseif ($actionstatic->type_code == 'AC_FAX') $imgpicto .= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
1583  elseif ($actionstatic->type_code == 'AC_EMAIL' || $actionstatic->type_code == 'AC_EMAIL_IN') $imgpicto .= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
1584  elseif ($actionstatic->type_code == 'AC_INT') $imgpicto .= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
1585  elseif ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' ';
1586  elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $imgpicto .= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' ';
1587  }
1588  }
1589  $out .= $imgpicto;
1590  $labeltype = $actionstatic->type_code;
1591  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH';
1592  if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') {
1593  $labeltype = $langs->trans("Message");
1594  } else {
1595  if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
1596  if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code
1597  }
1598  $out .= dol_trunc($labeltype, 28);
1599  $out .= '</td>';
1600 
1601  // Title
1602  $out .= '<td>';
1603  if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') {
1604  $transcode = $langs->trans("Action".$histo[$key]['acode']);
1605  $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']);
1606  //$actionstatic->libelle=$libelle;
1607  $libelle = $histo[$key]['note'];
1608  $actionstatic->id = $histo[$key]['id'];
1609  $out .= dol_trunc($libelle, 120);
1610  }
1611  if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
1612  $out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
1613  $transcode = $langs->trans("Action".$histo[$key]['acode']);
1614  $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
1615  $out .= dol_trunc($libelle, 120);
1616  }
1617  $out .= '</td>';
1618 
1619  // Date
1620  $out .= '<td class="center nowrap">';
1621  $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel');
1622  if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) {
1623  $tmpa = dol_getdate($histo[$key]['datestart'], true);
1624  $tmpb = dol_getdate($histo[$key]['dateend'], true);
1625  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel');
1626  else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel');
1627  }
1628  $late = 0;
1629  if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1;
1630  if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1;
1631  if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late = 1;
1632  if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1;
1633  if ($late) $out .= img_warning($langs->trans("Late")).' ';
1634  $out .= "</td>\n";
1635 
1636  // Title of event
1637  //$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
1638 
1639  // Linked object
1640  $out .= '<td class="nowraponall">';
1641  if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) {
1642  if (isset($elementlinkcache[$histo[$key]['elementtype']]) && isset($elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']])) {
1643  $link = $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']];
1644  } else {
1645  if (!isset($elementlinkcache[$histo[$key]['elementtype']])) {
1646  $elementlinkcache[$histo[$key]['elementtype']] = array();
1647  }
1648  $link = dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1);
1649  $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']] = $link;
1650  }
1651  $out .= $link;
1652  } else {
1653  $out .= '&nbsp;';
1654  }
1655  $out .= '</td>';
1656 
1657  // Contact(s) for action
1658  if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) {
1659  $contactstatic->lastname = $histo[$key]['lastname'];
1660  $contactstatic->firstname = $histo[$key]['firstname'];
1661  $contactstatic->id = $histo[$key]['contact_id'];
1662  $out .= '<td width="120">'.$contactstatic->getNomUrl(1, '', 10).'</td>';
1663  } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) {
1664  $out .= '<td>';
1665  $contact = new Contact($db);
1666  foreach ($histo[$key]['socpeopleassigned'] as $cid => $value) {
1667  $result = $contact->fetch($cid);
1668 
1669  if ($result < 0)
1670  dol_print_error($db, $contact->error);
1671 
1672  if ($result > 0) {
1673  $out .= $contact->getNomUrl(1, '', 16);
1674  if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
1675  if (!empty($contact->phone_pro))
1676  $out .= '('.dol_print_phone($contact->phone_pro).')';
1677  }
1678  $out .= '<div class="paddingright"></div>';
1679  }
1680  }
1681  $out .= '</td>';
1682  } else {
1683  $out .= '<td>&nbsp;</td>';
1684  }
1685 
1686  // Status
1687  $out .= '<td class="nowrap center">'.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).'</td>';
1688 
1689  // Actions
1690  $out .= '<td></td>';
1691 
1692  $out .= "</tr>\n";
1693  $i++;
1694  }
1695  $out .= "</table>\n";
1696  $out .= "</div>\n";
1697 
1698  $out .= '</form>';
1699  }
1700 
1701  if ($noprint) return $out;
1702  else print $out;
1703 }
1704 
1714 function show_subsidiaries($conf, $langs, $db, $object)
1715 {
1716  global $user;
1717 
1718  $i = -1;
1719 
1720  $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";
1721  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
1722  $sql .= " WHERE s.parent = ".$object->id;
1723  $sql .= " AND s.entity IN (".getEntity('societe').")";
1724  $sql .= " ORDER BY s.nom";
1725 
1726  $result = $db->query($sql);
1727  $num = $db->num_rows($result);
1728 
1729  if ($num) {
1730  $socstatic = new Societe($db);
1731 
1732  print load_fiche_titre($langs->trans("Subsidiaries"), '', '');
1733  print "\n".'<table class="noborder centpercent">'."\n";
1734 
1735  print '<tr class="liste_titre"><td>'.$langs->trans("Company").'</td>';
1736  print '<td>'.$langs->trans("Address").'</td><td>'.$langs->trans("Zip").'</td>';
1737  print '<td>'.$langs->trans("Town").'</td><td>'.$langs->trans("CustomerCode").'</td>';
1738  print "<td>&nbsp;</td>";
1739  print "</tr>";
1740 
1741  $i = 0;
1742 
1743  while ($i < $num) {
1744  $obj = $db->fetch_object($result);
1745 
1746  $socstatic->id = $obj->rowid;
1747  $socstatic->name = $obj->name;
1748  $socstatic->name_alias = $obj->name_alias;
1749  $socstatic->email = $obj->email;
1750  $socstatic->code_client = $obj->code_client;
1751  $socstatic->code_fournisseur = $obj->code_client;
1752  $socstatic->code_compta = $obj->code_compta;
1753  $socstatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1754  $socstatic->email = $obj->email;
1755  $socstatic->canvas = $obj->canvas;
1756  $socstatic->client = $obj->client;
1757  $socstatic->fournisseur = $obj->fournisseur;
1758 
1759  print '<tr class="oddeven">';
1760 
1761  print '<td>';
1762  print $socstatic->getNomUrl(1);
1763  print '</td>';
1764 
1765  print '<td>'.$obj->address.'</td>';
1766  print '<td>'.$obj->zip.'</td>';
1767  print '<td>'.$obj->town.'</td>';
1768  print '<td>'.$obj->code_client.'</td>';
1769 
1770  print '<td class="center">';
1771  print '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$obj->rowid.'&amp;action=edit">';
1772  print img_edit();
1773  print '</a></td>';
1774 
1775  print "</tr>\n";
1776  $i++;
1777  }
1778  print "\n</table>\n";
1779  }
1780 
1781  print "<br>\n";
1782 
1783  return $i;
1784 }
1796 function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR = "AND")
1797 {
1798  global $conf, $db;
1799  // Condition on actioncode
1800 
1801  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1802  if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'";
1803  elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'";
1804  else {
1805  if ($actioncode == 'AC_OTH') $sql .= " $sqlANDOR c.type != 'systemauto'";
1806  elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'";
1807  }
1808  }
1809  else {
1810  if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'";
1811  elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'";
1812  else $sql .= " $sqlANDOR c.code = '".$db->escape($actioncode)."'";
1813  }
1814 
1815  if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
1816  elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
1817  if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']);
1818 
1819  return $sql;
1820 }
1821 
1830 function addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
1831 {
1832  global $conf, $langs, $db;
1833  // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing.
1834  if (!empty($conf->mailing->enabled) && !empty($objcon->email)
1835  && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) {
1836  $langs->load("mails");
1837 
1838  $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";
1839  $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id";
1840  $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
1841  $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
1842  if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname";
1843  elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname";
1844  elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref";
1845  elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref";
1846  elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref";
1847  $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u";
1848  $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email.
1849  $sql2 .= " AND mc.statut = 1";
1850  $sql2 .= " AND u.rowid = m.fk_user_valid";
1851  $sql2 .= " AND mc.fk_mailing=m.rowid";
1852  return $sql2;
1853  }
1854 }
Class to manage different types of events.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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.
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...
Class to manage building of HTML components.
Class to manage agenda events (actions)
Class to manage contact/addresses.
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.
getArrayOfSocialNetworks()
Get array of social network dictionary.
addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
Add Mailing Event Type SQL.
dol_now($mode= 'auto')
Return date for now.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
Class to manage Dolibarr users.
Definition: user.class.php:44
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
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).
show_contacts($conf, $langs, $db, $object, $backtopage= '')
Show html area for list of contacts.
Class for SocieteAccount.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
currency_name($code_iso, $withcode= '', $outputlangs=null)
Return label of currency or code+label.
Class to build HTML component for third parties management Only common components are here...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
getFormeJuridiqueLabel($code)
Retourne le nom traduit de la forme juridique.
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
societe_admin_prepare_head()
Return array head with list of tabs to view object informations.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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...
getState($id, $withcode= '', $dbtouse=0, $withregion=0, $outputlangs= '', $entconv=1)
Return state translated from an id.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
liste_contact($status=-1, $source= 'external', $list=0, $code= '')
Get array of all contacts for an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
societe_prepare_head2($object)
Return array of tabs to used on page.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR="AND")
Add Event Type SQL.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
show_projects($conf, $langs, $db, $object, $backtopage= '', $nocreatelink=0, $morehtmlright= '')
Show html area for list of projects.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon= '', $noprint=0, $actioncode= '')
Show html area with actions to do.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option= '')
Return link url to an object.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...