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