dolibarr 23.0.3
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
6 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
8 * Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
10 * Copyright (C) 2021-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
12 * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
13 * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
14 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
36// Load Dolibarr environment
37require '../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
42require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
44require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
46require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
47if (isModEnabled('invoice')) {
48 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
49 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
50}
51if (isModEnabled("propal")) {
52 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
53}
54if (isModEnabled('order')) {
55 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
56}
57if (isModEnabled("shipping")) {
58 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
59}
60if (isModEnabled('contract')) {
61 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
62}
63if (isModEnabled('member')) {
64 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
65}
66if (isModEnabled('intervention')) {
67 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
68}
69if (isModEnabled('accounting')) {
70 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
71 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
72}
73
83// Load translation files required by the page
84$langs->loadLangs(array('companies', 'banks', 'commercial'));
85
86if (isModEnabled('contract')) {
87 $langs->load("contracts");
88}
89if (isModEnabled('order')) {
90 $langs->load("orders");
91}
92if (isModEnabled("shipping")) {
93 $langs->load("sendings");
94}
95if (isModEnabled('invoice')) {
96 $langs->load("bills");
97}
98if (isModEnabled('project')) {
99 $langs->load("projects");
100}
101if (isModEnabled('intervention')) {
102 $langs->load("interventions");
103}
104if (isModEnabled('notification')) {
105 $langs->load("mails");
106}
107
108$action = GETPOST('action', 'aZ09');
109
110$id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id'));
111
112$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
113$sortfield = GETPOST('sortfield', 'aZ09comma');
114$sortorder = GETPOST('sortorder', 'aZ09comma');
115$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
116if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
117 // If $page is not defined, or '' or -1 or if we click on clear filters
118 $page = 0;
119}
120$offset = $limit * $page;
121$pageprev = $page - 1;
122$pagenext = $page + 1;
123if (!$sortorder) {
124 $sortorder = "ASC";
125}
126if (!$sortfield) {
127 $sortfield = "nom";
128}
129$cancel = GETPOST('cancel', 'alpha');
130
131$object = new Client($db);
132$extrafields = new ExtraFields($db);
133$formfile = new FormFile($db);
134
135// fetch optionals attributes and labels
136$extrafields->fetch_name_optionals_label($object->table_element);
137
138// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
139$hookmanager->initHooks(array('thirdpartycomm', 'globalcard'));
140
141$now = dol_now();
142
143if ($id > 0 && empty($object->id)) {
144 // Load data of third party
145 $res = $object->fetch($id);
146 if ($object->id < 0) {
147 dol_print_error($db, $object->error, $object->errors);
148 }
149}
150if ($object->id > 0) {
151 if (!($object->client > 0) || !$user->hasRight('societe', 'lire')) {
153 }
154}
155
156// Security check
157if ($user->socid > 0) {
158 $id = $user->socid;
159}
160$result = restrictedArea($user, 'societe', $object->id, '&societe', '', 'fk_soc', 'rowid', 0);
161
162$permissiontoadd = $user->hasRight('societe', 'creer');
163$permissiontoeditextra = $permissiontoadd;
164if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
165 // For action 'update_extras', is there a specific permission set for the attribute to update
166 $permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
167}
168
169
170/*
171 * Actions
172 */
173$error = 0;
174
175$parameters = array('id' => $id, 'socid' => $id);
176$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
177if ($reshook < 0) {
178 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
179}
180
181if (empty($reshook)) {
182 if ($cancel) {
183 $action = "";
184 }
185
186 // set accountancy code
187 if ($action == 'setcustomeraccountancycodegeneral' && $permissiontoadd) {
188 $result = $object->fetch($id);
189 $object->accountancy_code_customer_general = GETPOST("customeraccountancycodegeneral");
190 $result = $object->update($object->id, $user, 1, 1, 0);
191 if ($result < 0) {
192 setEventMessages($object->error, $object->errors, 'errors');
193 }
194 }
195
196 // Set accountancy code
197 if ($action == 'setcustomeraccountancycode' && $permissiontoadd) {
198 $result = $object->fetch($id);
199 $object->code_compta_client = GETPOST("customeraccountancycode");
200 $object->code_compta = $object->code_compta_client; // For Backward compatibility
201 $result = $object->update($object->id, $user, 1, 1, 0);
202 if ($result < 0) {
203 setEventMessages($object->error, $object->errors, 'errors');
204 $action = 'editcustomeraccountancycode';
205 }
206 }
207
208 // Payment terms of the settlement
209 if ($action == 'setconditions' && $permissiontoadd) {
210 $object->fetch($id);
211 $result = $object->setPaymentTerms(GETPOSTINT('cond_reglement_id'), GETPOSTFLOAT('cond_reglement_id_deposit_percent'));
212 if ($result < 0) {
213 setEventMessages($object->error, $object->errors, 'errors');
214 }
215 }
216
217 // Payment mode
218 if ($action == 'setmode' && $permissiontoadd) {
219 $object->fetch($id);
220 $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_id'));
221 if ($result < 0) {
222 setEventMessages($object->error, $object->errors, 'errors');
223 }
224 }
225
226 // Transport mode
227 if ($action == 'settransportmode' && $permissiontoadd) {
228 $object->fetch($id);
229 $result = $object->setTransportMode(GETPOSTINT('transport_mode_id'));
230 if ($result < 0) {
231 setEventMessages($object->error, $object->errors, 'errors');
232 }
233 }
234
235 // Bank account
236 if ($action == 'setbankaccount' && $permissiontoadd) {
237 $object->fetch($id);
238 $result = $object->setBankAccount(GETPOSTINT('fk_account'));
239 if ($result < 0) {
240 setEventMessages($object->error, $object->errors, 'errors');
241 }
242 }
243
244 // customer preferred shipping method
245 if ($action == 'setshippingmethod' && $permissiontoadd) {
246 $object->fetch($id);
247 $result = $object->setShippingMethod(GETPOSTINT('shipping_method_id'));
248 if ($result < 0) {
249 setEventMessages($object->error, $object->errors, 'errors');
250 }
251 }
252
253 // assujetissement a la TVA
254 if ($action == 'setassujtva' && $permissiontoadd) {
255 $object->fetch($id);
256 $object->tva_assuj = GETPOSTINT('assujtva_value');
257 $result = $object->update($object->id, $user);
258 if ($result < 0) {
259 setEventMessages($object->error, $object->errors, 'errors');
260 }
261 }
262
263 // set prospect level
264 if ($action == 'setprospectlevel' && $permissiontoadd) {
265 $object->fetch($id);
266 $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha');
267 $result = $object->update($object->id, $user);
268 if ($result < 0) {
269 setEventMessages($object->error, $object->errors, 'errors');
270 }
271 }
272
273 // set communication status
274 if ($action == 'setstcomm' && $permissiontoadd) {
275 $object->fetch($id);
276 $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm');
277 $result = $object->update($object->id, $user);
278 if ($result < 0) {
279 setEventMessages($object->error, $object->errors, 'errors');
280 } else {
281 $result = $object->fetch($object->id);
282 }
283 }
284
285 // update outstandng limit
286 if ($action == 'setoutstanding_limit' && $permissiontoadd) {
287 $object->fetch($id);
288 $object->outstanding_limit = GETPOST('outstanding_limit');
289 $result = $object->update($object->id, $user);
290 if ($result < 0) {
291 setEventMessages($object->error, $object->errors, 'errors');
292 }
293 }
294
295 // update order min amount
296 if ($action == 'setorder_min_amount' && $permissiontoadd) {
297 $object->fetch($id);
298 $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha'));
299 $result = $object->update($object->id, $user);
300 if ($result < 0) {
301 setEventMessages($object->error, $object->errors, 'errors');
302 }
303 }
304
305 // Set sales representatives
306 if ($action == 'set_salesrepresentatives' && $permissiontoadd) {
307 $object->fetch($id);
308 $result = $object->setSalesRep(GETPOST('commercial', 'array'));
309 }
310
311 if ($action == 'update_extras' && $permissiontoeditextra) {
312 $object->fetch($id);
313
314 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
315
316 $attribute_name = GETPOST('attribute', 'aZ09');
317
318 // Fill array 'array_options' with data from update form
319 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
320 if ($ret < 0) {
321 $error++;
322 }
323
324 if (!$error) {
325 $result = $object->updateExtraField($attribute_name, 'COMPANY_MODIFY');
326 if ($result < 0) {
327 setEventMessages($object->error, $object->errors, 'errors');
328 $error++;
329 }
330 }
331
332 if ($error) {
333 $action = 'edit_extras';
334 }
335 }
336
337 // warehouse
338 if ($action == 'setwarehouse' && $permissiontoadd) {
339 $result = $object->setWarehouse(GETPOSTINT('fk_warehouse'));
340 }
341}
342
343
344/*
345 * View
346 */
347
348$contactstatic = new Contact($db);
349$userstatic = new User($db);
350$form = new Form($db);
351$formcompany = new FormCompany($db);
352$project = new Project($db);
353
354$title = $langs->trans("ThirdParty")." - ".$langs->trans('Customer');
355if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
356 $title = $object->name." - ".$langs->trans('Customer');
357}
358
359$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
360
361llxHeader('', $title, $help_url);
362
363if ($object->id > 0) {
364 $head = societe_prepare_head($object);
365
366 print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company');
367
368 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
369
370 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
371
372 print '<div class="fichecenter"><div class="fichehalfleft">';
373
374 print '<div class="underbanner clearboth"></div>';
375 print '<table class="border centpercent tableforfield">';
376
377 // Nature Prospect/Customer/Supplier
378 print '<tr><td class="titlefieldmiddle">'.$langs->trans('NatureOfThirdParty').'</td><td>';
379 print $object->getTypeUrl(1);
380 print '</td></tr>';
381
382 if ($object->client) {
383 $langs->loadLangs(array("compta", "accountancy"));
384
385 print '<tr><td>';
386 print $langs->trans('CustomerCode').'</td><td>';
388 $tmpcheck = $object->check_codeclient();
389 if ($tmpcheck != 0 && $tmpcheck != -5) {
390 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
391 }
392 print '</td></tr>';
393
394 if (isModEnabled('accounting')) {
395 $formaccounting = new FormAccounting($db);
396
397 print '<tr>';
398 print '<td>';
399 print $form->editfieldkey("CustomerAccountancyCodeGeneral", 'customeraccountancycodegeneral', length_accountg($object->accountancy_code_customer_general), $object, $permissiontoadd);
400 print '</td><td>';
401 if ($action == 'editcustomeraccountancycodegeneral' && $permissiontoadd) {
402 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_customer_general, 'customeraccountancycodegeneral', 0, 1, '', 1);
403 } else {
404 if ($object->accountancy_code_customer_general > 0) {
405 $accountingaccount = new AccountingAccount($db);
406 $accountingaccount->fetch(0, $object->accountancy_code_customer_general, 1);
407
408 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
409 }
410 if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) {
411 if ($object->accountancy_code_customer_general > 0) {
412 print ' - ';
413 }
414 $accountingAccountByDefault = '<span class="opacitymedium">' . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) . '</span>';
415 print $accountingAccountByDefault;
416 }
417 }
418 print '</td>';
419 print '</tr>';
420 }
421
422 print '<tr>';
423 print '<td>';
424 print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $permissiontoadd);
425 print '</td><td>';
426 print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $permissiontoadd);
427 print '</td>';
428 print '</tr>';
429 }
430
431 // This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier.
432 // We don't need them into customer profile.
433 // Except for spain and localtax where localtax depends on buyer and not seller
434
435 // VAT is used
436 /*
437 print '<tr>';
438 print '<td class="nowrap">';
439 print $form->textwithpicto($langs->trans('VATIsUsed'),$langs->trans('VATIsUsedWhenSelling'));
440 print '</td><td>';
441 print yn($object->tva_assuj);
442 print '</td>';
443 print '</tr>';
444 */
445
446 if ($mysoc->country_code == 'ES') {
447 // Local Taxes
448 if ($mysoc->localtax1_assuj == "1") {
449 print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
450 print yn($object->localtax1_assuj);
451 print '</td></tr>';
452 }
453 if ($mysoc->localtax1_assuj == "1") {
454 print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
455 print yn($object->localtax2_assuj);
456 print '</td></tr>';
457 }
458 }
459
460 // TVA Intra
461 print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
463 print '</td></tr>';
464
465 // default terms of the settlement
466 $langs->load('bills');
467 print '<tr><td>';
468 print '<table width="100%" class="nobordernopadding"><tr><td>';
469 print $langs->trans('PaymentConditions');
470 print '<td>';
471 if (($action != 'editconditions') && $permissiontoadd) {
472 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>';
473 }
474 print '</tr></table>';
475 print '</td><td>';
476 if ($action == 'editconditions') {
477 $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->cond_reglement_id, 'cond_reglement_id', 1, '', 1, $object->deposit_percent);
478 } else {
479 $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->cond_reglement_id, 'none', 0, '', 1, $object->deposit_percent);
480 }
481 print "</td>";
482 print '</tr>';
483
484 // Default payment mode
485 print '<tr><td class="nowrap">';
486 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
487 print $langs->trans('PaymentMode');
488 print '<td>';
489 if (($action != 'editmode') && $permissiontoadd) {
490 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
491 }
492 print '</tr></table>';
493 print '</td><td>';
494 if ($action == 'editmode') {
495 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1);
496 } else {
497 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_id, 'none');
498 }
499 print "</td>";
500 print '</tr>';
501
502 if (isModEnabled("bank")) {
503 // Default bank account for payments
504 print '<tr><td class="nowrap">';
505 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
506 print $langs->trans('PaymentBankAccount');
507 print '<td>';
508 if (($action != 'editbankaccount') && $permissiontoadd) {
509 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
510 }
511 print '</tr></table>';
512 print '</td><td>';
513 if ($action == 'editbankaccount') {
514 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'fk_account', 1);
515 } else {
516 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'none');
517 }
518 print "</td>";
519 print '</tr>';
520 }
521
522 $isCustomer = ($object->client == 1 || $object->client == 3);
523
524 // Relative discounts (Discounts-Drawbacks-Rebates)
525 if ($isCustomer) {
526 print '<tr><td class="nowrap">';
527 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
528 print $langs->trans("CustomerRelativeDiscountShort");
529 print '<td><td class="right">';
530 if ($permissiontoadd && !$user->socid > 0) {
531 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'&action=create&token='.newToken().'">'.img_edit($langs->trans("Modify")).'</a>';
532 }
533 print '</td></tr></table>';
534 print '</td><td>'.($object->remise_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>' : '').'</td>';
535 print '</tr>';
536
537 // Absolute discounts (Discounts-Drawbacks-Rebates)
538 print '<tr><td class="nowrap">';
539 print '<table width="100%" class="nobordernopadding">';
540 print '<tr><td class="nowrap">';
541 print $langs->trans("CustomerAbsoluteDiscountShort");
542 print '<td><td class="right">';
543 if ($permissiontoadd && !$user->socid > 0) {
544 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'&action=create_remise&token='.newToken().'">'.img_edit($langs->trans("Modify")).'</a>';
545 }
546 print '</td></tr></table>';
547 print '</td>';
548 print '<td>';
549 $amount_discount = $object->getAvailableDiscounts();
550 if ($amount_discount < 0) {
551 dol_print_error($db, $object->error);
552 }
553 if ($amount_discount > 0) {
554 print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'&action=create&token='.newToken().'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>';
555 }
556 //else print $langs->trans("DiscountNone");
557 print '</td>';
558 print '</tr>';
559 }
560
561 $limit_field_type = '';
562 // Max outstanding bill
563 if ($object->client) {
564 print '<tr class="nowrap">';
565 print '<td>';
566 print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $permissiontoadd);
567 print '</td><td>';
568 $limit_field_type = (getDolGlobalString('MAIN_USE_JQUERY_JEDITABLE')) ? 'numeric' : 'amount';
569 print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $permissiontoadd, $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
570 print '</td>';
571 print '</tr>';
572 }
573
574 if ($object->client) {
575 if (isModEnabled('order') && getDolGlobalString('ORDER_MANAGE_MIN_AMOUNT')) {
576 print '<!-- Minimum amount for orders -->'."\n";
577 print '<tr class="nowrap">';
578 print '<td>';
579 print $form->editfieldkey("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $permissiontoadd);
580 print '</td><td>';
581 print $form->editfieldval("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $permissiontoadd, $limit_field_type, ($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
582 print '</td>';
583 print '</tr>';
584 }
585 }
586
587
588 // Multiprice level
589 if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
590 print '<tr><td class="nowrap">';
591 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
592 print $langs->trans("PriceLevel");
593 print '<td><td class="right">';
594 if ($permissiontoadd) {
595 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
596 }
597 print '</td></tr></table>';
598 print '</td><td>';
599 print $object->price_level;
600 $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
601 if (getDolGlobalString($keyforlabel)) {
602 print ' - '.$langs->trans(getDolGlobalString($keyforlabel));
603 }
604 print "</td>";
605 print '</tr>';
606 }
607
608 // Warehouse
609 if (isModEnabled('stock') && getDolGlobalString('SOCIETE_ASK_FOR_WAREHOUSE')) {
610 $langs->load('stocks');
611 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
612 $formproduct = new FormProduct($db);
613 print '<tr class="nowrap">';
614 print '<td>';
615 print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $permissiontoadd);
616 print '</td><td>';
617 if ($action == 'editwarehouse') {
618 $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, (int) $object->fk_warehouse, 'fk_warehouse', 1);
619 } else {
620 if ($object->fk_warehouse > 0) {
621 print img_picto('', 'stock', 'class="paddingrightonly"');
622 }
623 $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, (int) $object->fk_warehouse, 'none');
624 }
625 print '</td>';
626 print '</tr>';
627 }
628
629 // Preferred shipping Method
630 if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD')) {
631 print '<tr><td class="nowrap">';
632 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
633 print $langs->trans('SendingMethod');
634 print '<td>';
635 if (($action != 'editshipping') && $permissiontoadd) {
636 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshipping&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
637 }
638 print '</tr></table>';
639 print '</td><td>';
640 if ($action == 'editshipping') {
641 $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->shipping_method_id, 'shipping_method_id', 1);
642 } else {
643 $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->shipping_method_id, 'none');
644 }
645 print "</td>";
646 print '</tr>';
647 }
648
649 if (isModEnabled('intracommreport')) {
650 $langs->load("intracommreport");
651
652 // Transport mode by default
653 print '<tr><td class="nowrap">';
654 print '<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
655 print $langs->trans('IntracommReportTransportMode');
656 print '<td>';
657 if (($action != 'edittransportmode') && $permissiontoadd) {
658 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edittransportmode&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
659 }
660 print '</tr></table>';
661 print '</td><td>';
662 if ($action == 'edittransportmode') {
663 $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id : ''), 'transport_mode_id', 1, 1);
664 } else {
665 $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id : ''), 'none');
666 }
667 print "</td>";
668 print '</tr>';
669 }
670
671 // Categories
672 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
673 $langs->load("categories");
674 print '<tr><td>'.$langs->trans("CustomersCategoriesShort").'</td>';
675 print '<td>';
676 print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
677 print "</td></tr>";
678 }
679
680 // Other attributes
681 $parameters = array('socid' => $object->id);
682 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
683
684 // Sales representative
685 include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
686
687 // Module Adherent
688 if (isModEnabled('member')) {
689 $langs->load("members");
690 $langs->load("users");
691
692 print '<tr><td class="titlefield">'.$langs->trans("LinkedToDolibarrMember").'</td>';
693 print '<td>';
694 $adh = new Adherent($db);
695 $result = $adh->fetch(0, '', $object->id);
696 if ($result > 0) {
697 $adh->ref = $adh->getFullName($langs);
698 print $adh->getNomUrl(-1);
699 } else {
700 print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
701 }
702 print '</td>';
703 print "</tr>\n";
704 }
705
706 print "</table>";
707
708 print '</div><div class="fichehalfright">';
709
710 // Prospection level and status
711 if ($object->client == 2 || $object->client == 3) {
712 print '<div class="underbanner clearboth"></div>';
713 print '<table class="border centpercent tableforfield">';
714
715 // Level of prospection
716 print '<tr><td class="titlefield nowrap">';
717 print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
718 print $langs->trans('ProspectLevel');
719 print '<td>';
720 if ($action != 'editlevel' && $permissiontoadd) {
721 print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editlevel&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
722 }
723 print '</tr></table>';
724 print '</td><td>';
725 if ($action == 'editlevel') {
726 $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id, (int) $object->fk_prospectlevel, 'prospect_level_id', 1);
727 } else {
728 print $object->getLibProspLevel();
729 }
730 print "</td>";
731 print '</tr>';
732
733 // Status of prospection
734 $object->loadCacheOfProspStatus();
735 print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
736 print ' &nbsp; &nbsp; ';
737 print '<div class="floatright">';
738 foreach ($object->cacheprospectstatus as $key => $val) {
739 $titlealt = 'default';
740 if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
741 $titlealt = $val['label'];
742 }
743 if ($object->stcomm_id != $val['id']) {
744 print '<a class="pictosubstatus reposition" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
745 }
746 }
747 print '</div></td></tr>';
748 print "</table>";
749
750 print '<br>';
751 } else {
752 print '<div class="underbanner underbanner-before-box clearboth"></div><br>';
753 }
754
755 $boxstat = '';
756
757 // Max nb of elements in lists
758 $MAXLIST = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
759
760 // Link summary/status board
761 $boxstat .= '<div class="box divboxtable box-halfright">';
762 $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop boxtablenomarginbottom centpercent">';
763 $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
764
765 if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
766 // Box proposals
767 $tmp = $object->getOutstandingProposals();
768 $outstandingOpened = $tmp['opened'];
769 $outstandingTotal = $tmp['total_ht'];
770 $outstandingTotalIncTax = $tmp['total_ttc'];
771 $text = $langs->trans("OverAllProposals");
772 $link = DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id;
773 $icon = 'bill';
774 if ($link) {
775 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
776 }
777 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
778 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
779 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
780 $boxstat .= '</div>';
781 if ($link) {
782 $boxstat .= '</a>';
783 }
784 }
785
786 if (isModEnabled('order') && $user->hasRight('commande', 'lire')) {
787 // Box orders
788 $tmp = $object->getOutstandingOrders();
789 $outstandingOpened = $tmp['opened'];
790 $outstandingTotal = $tmp['total_ht'];
791 $outstandingTotalIncTax = $tmp['total_ttc'];
792 $text = $langs->trans("OverAllOrders");
793 $link = DOL_URL_ROOT.'/commande/list.php?socid='.$object->id;
794 $icon = 'bill';
795 if ($link) {
796 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
797 }
798 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
799 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
800 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
801 $boxstat .= '</div>';
802 if ($link) {
803 $boxstat .= '</a>';
804 }
805 }
806
807 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
808 // Box invoices
809 $tmp = $object->getOutstandingBills('customer', 0);
810 $outstandingOpened = $tmp['opened'];
811 $outstandingTotal = $tmp['total_ht'];
812 $outstandingTotalIncTax = $tmp['total_ttc'];
813
814 $text = $langs->trans("OverAllInvoices");
815 $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id;
816 $icon = 'bill';
817 if ($link) {
818 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
819 }
820 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
821 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
822 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
823 $boxstat .= '</div>';
824 if ($link) {
825 $boxstat .= '</a>';
826 }
827
828 // Box outstanding bill
829 $warn = '';
830 if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) {
831 $warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
832 }
833 $text = $langs->trans("CurrentOutstandingBill");
834 $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
835 $icon = 'bill';
836 if ($link) {
837 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
838 }
839 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
840 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
841 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
842 $boxstat .= '</div>';
843 if ($link) {
844 $boxstat .= '</a>';
845 }
846
847 $tmp = $object->getOutstandingBills('customer', 1);
848 $outstandingOpenedLate = $tmp['opened'];
849 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
850 $warn = '';
851 if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpenedLate) {
852 $warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
853 }
854 $text = $langs->trans("CurrentOutstandingBillLate");
855 $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
856 $icon = 'bill';
857 if ($link) {
858 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
859 }
860 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
861 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
862 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
863 $boxstat .= '</div>';
864 if ($link) {
865 $boxstat .= '</a>';
866 }
867 }
868 }
869
870 $parameters = array();
871 $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action);
872 if (empty($reshook)) {
873 $boxstat .= $hookmanager->resPrint;
874 }
875
876 $boxstat .= '</td></tr>';
877 $boxstat .= '</table>';
878 $boxstat .= '</div>';
879
880 print $boxstat;
881
882
883 /*
884 * Latest proposals
885 */
886 if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
887 $propal_static = new Propal($db);
888 $langs->load("propal");
889
890 $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_projet, p.fk_statut, p.total_ht";
891 $sql .= ", p.total_tva";
892 $sql .= ", p.total_ttc";
893 $sql .= ", p.ref, p.ref_client, p.remise";
894 $sql .= ", p.datep as dp, p.fin_validite as date_limit, p.entity";
895 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
896 $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
897 $sql .= " AND s.rowid = ".((int) $object->id);
898 $sql .= " AND p.entity IN (".getEntity('propal').")";
899 $parameters = array();
900 $hookmanager->executeHooks('printFieldListWhere', $parameters, $propal_static); // Note that $action and $object may have been modified by hook
901 $sql .= $hookmanager->resPrint;
902 $sql .= " ORDER BY p.datep DESC";
903
904 $resql = $db->query($sql);
905 if ($resql) {
906 $num = $db->num_rows($resql);
907 if ($num > 0) {
908 print '<div class="div-table-responsive-no-min">';
909 print '<table class="noborder centpercent lastrecordtable">';
910
911 print '<tr class="liste_titre">';
912 print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllPropals").'</span><span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
913 print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
914 print '</tr></table></td>';
915 print '</tr>';
916 }
917
918 $i = 0;
919 while ($i < $num && $i < $MAXLIST) {
920 $objp = $db->fetch_object($resql);
921
922 print '<tr class="oddeven">';
923 print '<td class="nowraponall">';
924 $propal_static->id = $objp->propalid;
925 $propal_static->ref = $objp->ref;
926 $propal_static->ref_client = $objp->ref_client; // deprecated
927 $propal_static->ref_customer = $objp->ref_client;
928 $propal_static->fk_project = $objp->fk_projet;
929 $propal_static->total_ht = $objp->total_ht;
930 $propal_static->total_tva = $objp->total_tva;
931 $propal_static->total_ttc = $objp->total_ttc;
932 print $propal_static->getNomUrl(1);
933
934 // Preview
935 $filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
936 $file_list = null;
937 if (!empty($filedir)) {
938 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
939 }
940 if (is_array($file_list) && !empty($file_list)) {
941 // Defined relative dir to DOL_DATA_ROOT
942 $relativedir = '';
943 if ($filedir) {
944 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
945 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
946 }
947 // Get list of files stored into database for same relative directory
948 if ($relativedir) {
949 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
950 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
951
952 //var_dump($sortfield.' - '.$sortorder);
953 if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
954 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
955 }
956 }
957 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
958 print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0, 'entity=' . $objp->entity);
959 }
960 print '</td><td class="tdoverflowmax125">';
961 if ($propal_static->fk_project > 0) {
962 $project->fetch($propal_static->fk_project);
963 print $project->getNomUrl(1);
964 }
965 // $filename = dol_sanitizeFileName($objp->ref);
966 // $filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
967 // $urlsource = '/comm/propal/card.php?id='.$objp->cid;
968 // print $formfile->getDocumentsLink($propal_static->element, $filename, $filedir);
969 if (($db->jdate($objp->date_limit) < ($now - getWarningDelay('propal', 'cloture'))) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
970 print " ".img_warning();
971 }
972 print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
973 print '<td class="right nowraponall">'.price($objp->total_ht).'</td>';
974 print '<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).'</td></tr>';
975 $i++;
976 }
977 $db->free($resql);
978
979 if ($num > 0) {
980 print "</table>";
981 print '</div>';
982 }
983 } else {
984 dol_print_error($db);
985 }
986 }
987
988 $orders2invoice = null;
989 $param = "";
990 /*
991 * Latest orders
992 */
993 if (isModEnabled('order') && $user->hasRight('commande', 'lire')) {
994 $commande_static = new Commande($db);
995 $sql = "SELECT s.nom, s.rowid";
996 $sql .= ", c.rowid as cid, c.entity, c.fk_projet, c.total_ht";
997 $sql .= ", c.total_tva";
998 $sql .= ", c.total_ttc";
999 $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture";
1000 $sql .= ", c.date_commande as dc";
1001 $sql .= ", c.facture as billed";
1002 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
1003 $sql .= " WHERE c.fk_soc = s.rowid ";
1004 $sql .= " AND s.rowid = ".((int) $object->id);
1005 $sql .= " AND c.entity IN (".getEntity('commande').')';
1006 $parameters = array();
1007 $hookmanager->executeHooks('printFieldListWhere', $parameters, $commande_static); // Note that $action and $object may have been modified by hook
1008 $sql .= $hookmanager->resPrint;
1009 $sql .= " ORDER BY c.date_commande DESC";
1010
1011 $resql = $db->query($sql);
1012 if ($resql) {
1013 $num = $db->num_rows($resql);
1014 if ($num > 0) {
1015 // Check if there are orders billable
1016 $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
1017 $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
1018 $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
1019 $sql2 .= ', '.MAIN_DB_PREFIX.'commande as c';
1020 $sql2 .= ' WHERE c.fk_soc = s.rowid';
1021 $sql2 .= ' AND s.rowid = '.((int) $object->id);
1022 // Show orders with status validated, shipping started and delivered (well any order we can bill)
1023 $sql2 .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
1024
1025 $resql2 = $db->query($sql2);
1026 $orders2invoice = $db->num_rows($resql2);
1027 $db->free($resql2);
1028
1029 print '<div class="div-table-responsive-no-min">';
1030 print '<table class="noborder centpercent lastrecordtable">';
1031
1032 print '<tr class="liste_titre">';
1033 print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllOrders").'</span><span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
1034 print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
1035 print '</tr></table></td>';
1036 print '</tr>';
1037 }
1038
1039 $i = 0;
1040 while ($i < $num && $i < $MAXLIST) {
1041 $objp = $db->fetch_object($resql);
1042
1043 $commande_static->id = $objp->cid;
1044 $commande_static->ref = $objp->ref;
1045 $commande_static->ref_client = $objp->ref_client;
1046 $commande_static->fk_project = $objp->fk_projet;
1047 $commande_static->total_ht = $objp->total_ht;
1048 $commande_static->total_tva = $objp->total_tva;
1049 $commande_static->total_ttc = $objp->total_ttc;
1050 $commande_static->billed = $objp->billed;
1051
1052 print '<tr class="oddeven">';
1053 print '<td class="nowraponall">';
1054 print $commande_static->getNomUrl(1);
1055 // Preview
1056 $filedir = $conf->commande->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1057 $file_list = null;
1058 if (!empty($filedir)) {
1059 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1060 }
1061 if (is_array($file_list) && !empty($file_list)) {
1062 // Defined relative dir to DOL_DATA_ROOT
1063 $relativedir = '';
1064 if ($filedir) {
1065 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1066 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1067 }
1068 // Get list of files stored into database for same relative directory
1069 if ($relativedir) {
1070 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1071 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1072
1073 //var_dump($sortfield.' - '.$sortorder);
1074 if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
1075 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1076 }
1077 }
1078 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1079 print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0, 'entity=' . $objp->entity);
1080 }
1081 print '</td><td class="tdoverflowmax125">';
1082 if ($commande_static->fk_project > 0) {
1083 $project->fetch($commande_static->fk_project);
1084 print $project->getNomUrl(1);
1085 }
1086 // $filename = dol_sanitizeFileName($objp->ref);
1087 // $filedir = $conf->order->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1088 // $urlsource = '/commande/card.php?id='.$objp->cid;
1089 // print $formfile->getDocumentsLink($commande_static->element, $filename, $filedir);
1090 print '</td>';
1091
1092 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day')."</td>\n";
1093 print '<td class="right nowraponall">'.price($objp->total_ht).'</td>';
1094 print '<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>';
1095 $i++;
1096 }
1097 $db->free($resql);
1098
1099 if ($num > 0) {
1100 print "</table>";
1101 print '</div>';
1102 }
1103 } else {
1104 dol_print_error($db);
1105 }
1106 }
1107
1108 /*
1109 * Latest shipments
1110 */
1111 if (isModEnabled("shipping") && $user->hasRight('expedition', 'lire')) {
1112 $param = '';
1113
1114 $sql = 'SELECT e.rowid as id';
1115 $sql .= ', e.ref, e.entity, e.fk_projet';
1116 $sql .= ', e.date_creation';
1117 $sql .= ', e.fk_statut as statut';
1118 $sql .= ', s.nom';
1119 $sql .= ', s.rowid as socid';
1120 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
1121 $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1122 $sql .= " AND e.entity IN (".getEntity('expedition').")";
1123 $sql .= ' GROUP BY e.rowid';
1124 $sql .= ', e.ref, e.entity, e.fk_projet';
1125 $sql .= ', e.date_creation';
1126 $sql .= ', e.fk_statut';
1127 $sql .= ', s.nom';
1128 $sql .= ', s.rowid';
1129 $sql .= " ORDER BY e.date_creation DESC";
1130
1131 $resql = $db->query($sql);
1132 if ($resql) {
1133 $sendingstatic = new Expedition($db);
1134
1135 $num = $db->num_rows($resql);
1136 if ($num > 0) {
1137 print '<div class="div-table-responsive-no-min">';
1138 print '<table class="noborder centpercent lastrecordtable">';
1139
1140 print '<tr class="liste_titre">';
1141 print '<td colspan="5"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans("LastSendings", ($num < $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expedition/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllSendings").'</span><span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
1142 print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/expedition/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
1143 print '</tr></table></td>';
1144 print '</tr>';
1145 }
1146
1147 $i = 0;
1148 while ($i < $num && $i < $MAXLIST) {
1149 $objp = $db->fetch_object($resql);
1150
1151 $param = 'entity=' . ((int) $objp->entity);
1152
1153 $sendingstatic->id = $objp->id;
1154 $sendingstatic->ref = $objp->ref;
1155 $sendingstatic->fk_project = $objp->fk_projet;
1156
1157 print '<tr class="oddeven">';
1158 print '<td class="nowraponall">';
1159 print $sendingstatic->getNomUrl(1);
1160 // Preview
1161 $filedir = $conf->expedition->multidir_output[$objp->entity].'/sending/'.dol_sanitizeFileName($objp->ref);
1162 $file_list = null;
1163 if (!empty($filedir)) {
1164 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1165 }
1166 if (is_array($file_list) && !empty($file_list)) {
1167 // Defined relative dir to DOL_DATA_ROOT
1168 $relativedir = '';
1169 if ($filedir) {
1170 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1171 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1172 }
1173 // Get list of files stored into database for same relative directory
1174 if ($relativedir) {
1175 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1176 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1177
1178 //var_dump($sortfield.' - '.$sortorder);
1179 if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
1180 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1181 }
1182 }
1183 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1184
1185 print $formfile->showPreview($file_list, $sendingstatic->element, $relativepath, 0, $param);
1186 }
1187 print '</td><td class="tdoverflowmax125">';
1188 if ($sendingstatic->fk_project > 0) {
1189 $project->fetch($sendingstatic->fk_project);
1190 print $project->getNomUrl(1);
1191 }
1192 // $filename = dol_sanitizeFileName($objp->ref);
1193 // $filedir = $conf->expedition->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1194 // $urlsource = '/expedition/card.php?id='.$objp->cid;
1195 // print $formfile->getDocumentsLink($sendingstatic->element, $filename, $filedir);
1196 print '</td>';
1197 if ($objp->date_creation > 0) {
1198 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>';
1199 } else {
1200 print '<td class="right"><b>!!!</b></td>';
1201 }
1202
1203 print '<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).'</td>';
1204 print "</tr>\n";
1205 $i++;
1206 }
1207 $db->free($resql);
1208
1209 if ($num > 0) {
1210 print "</table>";
1211 print '</div>';
1212 }
1213 } else {
1214 dol_print_error($db);
1215 }
1216 }
1217
1218 /*
1219 * Latest contracts
1220 */
1221 if (isModEnabled('contract') && $user->hasRight('contrat', 'lire')) {
1222 $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.fk_projet, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity,";
1223 $sql .= " c.last_main_doc, c.model_pdf";
1224 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
1225 $sql .= " WHERE c.fk_soc = s.rowid ";
1226 $sql .= " AND s.rowid = ".((int) $object->id);
1227 $sql .= " AND c.entity IN (".getEntity('contract').")";
1228 $sql .= " ORDER BY c.datec DESC";
1229
1230 $resql = $db->query($sql);
1231 if ($resql) {
1232 $contrat = new Contrat($db);
1233
1234 $num = $db->num_rows($resql);
1235 if ($num > 0) {
1236 print '<div class="div-table-responsive-no-min">';
1237 print '<table class="noborder centpercent lastrecordtable">';
1238
1239 print '<tr class="liste_titre">';
1240 print '<td colspan="6"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
1241 print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
1242 //print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/contract/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
1243 print '</tr></table></td>';
1244 print '</tr>';
1245 }
1246
1247 $i = 0;
1248 while ($i < $num && $i < $MAXLIST) {
1249 $objp = $db->fetch_object($resql);
1250
1251 $contrat->id = $objp->id;
1252 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1253 $contrat->ref_customer = $objp->refcus;
1254 $contrat->ref_supplier = $objp->refsup;
1255 $contrat->fk_project = $objp->fk_projet;
1256 $contrat->statut = $objp->contract_status; // deprecated
1257 $contrat->status = $objp->contract_status;
1258 $contrat->last_main_doc = $objp->last_main_doc;
1259 $contrat->model_pdf = $objp->model_pdf;
1260 $contrat->fetch_lines();
1261
1262 $late = '';
1263 foreach ($contrat->lines as $line) {
1264 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1265 if (((!empty($line->date_end) ? $line->date_end : 0) + getWarningDelay('contract', 'service', 'expires')) < $now) {
1266 $late = img_warning($langs->trans("Late"));
1267 }
1268 }
1269 }
1270
1271 print '<tr class="oddeven">';
1272 print '<td class="nowraponall">';
1273 print $contrat->getNomUrl(1, 12);
1274 if (!empty($contrat->model_pdf)) {
1275 // Preview
1276 $filedir = $conf->contract->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1277 $file_list = null;
1278 if (!empty($filedir)) {
1279 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1280 }
1281 if (is_array($file_list) && !empty($file_list)) {
1282 // Defined relative dir to DOL_DATA_ROOT
1283 $relativedir = '';
1284 if ($filedir) {
1285 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1286 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1287 }
1288 // Get list of files stored into database for same relative directory
1289 if ($relativedir) {
1290 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1291 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1292
1293 //var_dump($sortfield.' - '.$sortorder);
1294 if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
1295 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1296 }
1297 }
1298 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1299 print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0, 'entity=' . $objp->entity);
1300 }
1301 }
1302 // $filename = dol_sanitizeFileName($objp->ref);
1303 // $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1304 // $urlsource = '/contrat/card.php?id='.$objp->cid;
1305 // print $formfile->getDocumentsLink($contrat->element, $filename, $filedir);
1306 print $late;
1307 print '</td><td class="tdoverflowmax125">';
1308 if ($contrat->fk_project > 0) {
1309 $project->fetch($contrat->fk_project);
1310 print $project->getNomUrl(1);
1311 }
1312 print "</td>\n";
1313 print '<td class="nowrap">';
1314 print dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1315 print "</td>\n";
1316 //print '<td class="right" width="80px"><span title="'.$langs->trans("DateCreation").'">'.dol_print_date($db->jdate($objp->dc), 'day')."</span></td>\n";
1317 print '<td class="right" width="80px"><span title="'.$langs->trans("DateContract").'">'.dol_print_date($db->jdate($objp->dcon), 'day')."</span></td>\n";
1318 print '<td width="20">&nbsp;</td>';
1319 print '<td class="nowraponall right">';
1320 print $contrat->getLibStatut(4);
1321 print "</td>\n";
1322 print '</tr>';
1323 $i++;
1324 }
1325 $db->free($resql);
1326
1327 if ($num > 0) {
1328 print "</table>";
1329 print '</div>';
1330 }
1331 } else {
1332 dol_print_error($db);
1333 }
1334 }
1335
1336 /*
1337 * Latest interventions
1338 */
1339 if (isModEnabled('intervention') && $user->hasRight('ficheinter', 'lire')) {
1340 $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_projet, f.fk_statut, f.duree as duration, f.datei as startdate, f.entity";
1341 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
1342 $sql .= " WHERE f.fk_soc = s.rowid";
1343 $sql .= " AND s.rowid = ".((int) $object->id);
1344 $sql .= " AND f.entity IN (".getEntity('intervention').")";
1345 $sql .= " ORDER BY f.tms DESC";
1346
1347 $resql = $db->query($sql);
1348 if ($resql) {
1349 $fichinter_static = new Fichinter($db);
1350
1351 $num = $db->num_rows($resql);
1352 if ($num > 0) {
1353 print '<div class="div-table-responsive-no-min">';
1354 print '<table class="noborder centpercent lastrecordtable">';
1355
1356 print '<tr class="liste_titre">';
1357 print '<td colspan="4"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllInterventions").'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
1358 print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/fichinter/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
1359 print '</tr></table></td>';
1360 print '</tr>';
1361 }
1362
1363 $i = 0;
1364 while ($i < $num && $i < $MAXLIST) {
1365 $objp = $db->fetch_object($resql);
1366
1367 $fichinter_static->id = $objp->id;
1368 $fichinter_static->ref = $objp->ref;
1369 $fichinter_static->statut = $objp->fk_statut; // deprecated
1370 $fichinter_static->status = $objp->fk_statut;
1371 $fichinter_static->fk_project = $objp->fk_projet;
1372
1373 print '<tr class="oddeven">';
1374 print '<td class="nowraponall">';
1375 print $fichinter_static->getNomUrl(1);
1376 // Preview
1377 $filedir = $conf->ficheinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1378 $file_list = null;
1379 if (!empty($filedir)) {
1380 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1381 }
1382 if (is_array($file_list) && !empty($file_list)) {
1383 // Defined relative dir to DOL_DATA_ROOT
1384 $relativedir = '';
1385 if ($filedir) {
1386 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1387 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1388 }
1389 // Get list of files stored into database for same relative directory
1390 if ($relativedir) {
1391 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1392 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1393
1394 //var_dump($sortfield.' - '.$sortorder);
1395 if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
1396 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1397 }
1398 }
1399 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1400 print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0, 'entity=' . $objp->entity);
1401 }
1402 print '</td><td class="tdoverflowmax125">';
1403 if ($fichinter_static->fk_project > 0) {
1404 $project->fetch($fichinter_static->fk_project);
1405 print $project->getNomUrl(1);
1406 }
1407 // $filename = dol_sanitizeFileName($objp->ref);
1408 // $filedir = getMultidirOutput($fichinter_static).'/'.dol_sanitizeFileName($objp->ref);
1409 // $urlsource = '/fichinter/card.php?id='.$objp->cid;
1410 // print $formfile->getDocumentsLink($fichinter_static->element, $filename, $filedir);
1411 print '</td>'."\n";
1412 //print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
1413 print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
1414 print '<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n";
1415 print '</tr>';
1416
1417 $i++;
1418 }
1419 $db->free($resql);
1420
1421 if ($num > 0) {
1422 print "</table>";
1423 print '</div>';
1424 }
1425 } else {
1426 dol_print_error($db);
1427 }
1428 }
1429
1430 /*
1431 * Latest invoices templates
1432 */
1433 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
1434 $sql = 'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1435 $sql .= ', f.total_ht';
1436 $sql .= ', f.total_tva';
1437 $sql .= ', f.total_ttc';
1438 $sql .= ', f.datec as dc';
1439 $sql .= ', f.date_last_gen, f.date_when';
1440 $sql .= ', f.frequency';
1441 $sql .= ', f.unit_frequency';
1442 $sql .= ', f.suspended as suspended';
1443 $sql .= ', s.nom, s.rowid as socid';
1444 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
1445 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1446 $sql .= " AND f.entity IN (".getEntity('invoice').")";
1447 $sql .= ' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1448 $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1449 $sql .= ' f.suspended, f.date_when,';
1450 $sql .= ' s.nom, s.rowid';
1451 $sql .= " ORDER BY f.date_last_gen, f.datec DESC";
1452
1453 $resql = $db->query($sql);
1454 if ($resql) {
1455 $invoicetemplate = new FactureRec($db);
1456
1457 $num = $db->num_rows($resql);
1458 if ($num > 0) {
1459 print '<div class="div-table-responsive-no-min">';
1460 print '<table class="noborder centpercent lastrecordtable">';
1461 print '<tr class="liste_titre">';
1462 $colspan = 5;
1463 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1464 $colspan++;
1465 }
1466 print '<td colspan="'.$colspan.'">';
1467 print '<table class="centpercent nobordernopadding"><tr>';
1468 print '<td>'.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllCustomerTemplateInvoices").'</span><span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
1469 print '</tr></table>';
1470 print '</td>';
1471 print '</tr>';
1472 }
1473
1474 $i = 0;
1475 while ($i < $num && $i < $MAXLIST) {
1476 $objp = $db->fetch_object($resql);
1477
1478 $invoicetemplate->id = $objp->id;
1479 $invoicetemplate->ref = $objp->ref;
1480 $invoicetemplate->fk_project = $objp->fk_projet;
1481 $invoicetemplate->suspended = $objp->suspended;
1482 $invoicetemplate->frequency = $objp->frequency;
1483 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1484 $invoicetemplate->total_ht = $objp->total_ht;
1485 $invoicetemplate->total_tva = $objp->total_tva;
1486 $invoicetemplate->total_ttc = $objp->total_ttc;
1487 $invoicetemplate->date_last_gen = $objp->date_last_gen;
1488 $invoicetemplate->date_when = $objp->date_when;
1489
1490 print '<tr class="oddeven">';
1491 print '<td class="tdoverflowmax250">';
1492 print $invoicetemplate->getNomUrl(1);
1493 print '</td><td class="tdoverflowmax125">';
1494 if ($invoicetemplate->fk_project > 0) {
1495 $project->fetch($invoicetemplate->fk_project);
1496 print $project->getNomUrl(1);
1497 }
1498 print '</td>';
1499
1500 if ($objp->frequency && $objp->date_last_gen > 0) {
1501 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
1502 } else {
1503 if ($objp->dc > 0) {
1504 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day').'</td>';
1505 } else {
1506 print '<td class="right"><b>!!!</b></td>';
1507 }
1508 }
1509 print '<td class="right nowraponall">';
1510 print price($objp->total_ht);
1511 print '</td>';
1512
1513 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1514 print '<td class="right nowraponall">';
1515 print price($objp->total_ttc);
1516 print '</td>';
1517 }
1518
1519 print '<td class="nowrap right" style="min-width: 60px">';
1520 print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - ';
1521 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1522 print '</td>';
1523 print "</tr>\n";
1524 $i++;
1525 }
1526 $db->free($resql);
1527
1528 if ($num > 0) {
1529 print "</table>";
1530 print '</div>';
1531 }
1532 } else {
1533 dol_print_error($db);
1534 }
1535 }
1536
1537 /*
1538 * Latest invoices
1539 */
1540 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
1541 $sql = 'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1542 $sql .= ', f.total_ht';
1543 $sql .= ', f.total_tva';
1544 $sql .= ', f.total_ttc';
1545 $sql .= ', f.entity';
1546 $sql .= ', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status';
1547 $sql .= ', s.nom, s.rowid as socid';
1548 $sql .= ', SUM(pf.amount) as am';
1549 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
1550 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
1551 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1552 $sql .= " AND f.entity IN (".getEntity('invoice').")";
1553 $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1554 $sql .= ' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1555 $sql .= ' s.nom, s.rowid';
1556 $sql .= " ORDER BY f.datef DESC, f.datec DESC";
1557
1558 $resql = $db->query($sql);
1559 if ($resql) {
1560 $facturestatic = new Facture($db);
1561
1562 $num = $db->num_rows($resql);
1563 if ($num > 0) {
1564 print '<div class="div-table-responsive-no-min">';
1565 print '<table class="noborder centpercent lastrecordtable">';
1566 print '<tr class="liste_titre">';
1567 $colspan = 6;
1568 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1569 $colspan++;
1570 }
1571 if (getDolGlobalString('MAIN_SHOW_REF_CUSTOMER_INVOICES')) {
1572 $colspan++;
1573 }
1574 print '<td colspan="'.$colspan.'">';
1575 print '<table class="centpercent nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllBills").'</span><span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
1576 print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
1577 print '</tr></table>';
1578 print '</td>';
1579 print '</tr>';
1580 }
1581
1582 $i = 0;
1583 while ($i < $num && $i < $MAXLIST) {
1584 $objp = $db->fetch_object($resql);
1585
1586 $facturestatic->id = $objp->facid;
1587 $facturestatic->ref = $objp->ref;
1588 $facturestatic->ref_client = $objp->ref_client;
1589 $facturestatic->fk_project = $objp->fk_projet;
1590 $facturestatic->type = $objp->type;
1591 $facturestatic->total_ht = $objp->total_ht;
1592 $facturestatic->total_tva = $objp->total_tva;
1593 $facturestatic->total_ttc = $objp->total_ttc;
1594 $facturestatic->statut = $objp->status; // deprecated
1595 $facturestatic->status = $objp->status;
1596 $facturestatic->paye = $objp->paye;
1597
1598 $facturestatic->alreadypaid = $objp->am;
1599 $facturestatic->totalpaid = $objp->am;
1600
1601 $facturestatic->date = $db->jdate($objp->df);
1602 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1603
1604 print '<tr class="oddeven">';
1605 print '<td class="nowraponall">';
1606 print $facturestatic->getNomUrl(1);
1607 // Preview
1608 $filedir = $conf->invoice->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1609 $file_list = null;
1610 if (!empty($filedir)) {
1611 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1612 }
1613 if (is_array($file_list) && !empty($file_list)) {
1614 // Defined relative dir to DOL_DATA_ROOT
1615 $relativedir = '';
1616 if ($filedir) {
1617 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1618 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1619 }
1620 // Get list of files stored into database for same relative directory
1621 if ($relativedir) {
1622 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1623 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1624
1625 //var_dump($sortfield.' - '.$sortorder);
1626 if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
1627 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1628 }
1629 }
1630 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1631 print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0, 'entity=' . $objp->entity);
1632 }
1633 print '</td><td class="tdoverflowmax125">';
1634 if ($facturestatic->fk_project > 0) {
1635 $project->fetch($facturestatic->fk_project);
1636 print $project->getNomUrl(1);
1637 }
1638 // $filename = dol_sanitizeFileName($objp->ref);
1639 // $filedir = $conf->facture->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1640 // $urlsource = '/compta/facture/card.php?id='.$objp->cid;
1641 //print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
1642 print '</td>';
1643 if (getDolGlobalString('MAIN_SHOW_REF_CUSTOMER_INVOICES')) {
1644 print '<td class="nowraponall">';
1645 print dolPrintHTML($objp->ref_client);
1646 print '</td>';
1647 }
1648 if ($objp->df > 0) {
1649 print '<td width="80px" title="'.dol_escape_htmltag($langs->trans('DateInvoice')).'">'.dol_print_date($db->jdate($objp->df), 'day').'</td>';
1650 } else {
1651 print '<td><b>!!!</b></td>';
1652 }
1653 if ($objp->dl > 0) {
1654 print '<td width="80px" title="'.dol_escape_htmltag($langs->trans('DateMaxPayment')).'">'.dol_print_date($db->jdate($objp->dl), 'day').'</td>';
1655 } else {
1656 print '<td><b>!!!</b></td>';
1657 }
1658
1659 print '<td class="right nowraponall">';
1660 print price($objp->total_ht);
1661 print '</td>';
1662
1663 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1664 print '<td class="right nowraponall">';
1665 print price($objp->total_ttc);
1666 print '</td>';
1667 }
1668
1669 print '<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).'</td>';
1670 print "</tr>\n";
1671 $i++;
1672 }
1673 $db->free($resql);
1674
1675 if ($num > 0) {
1676 print "</table>";
1677 print '</div>';
1678 }
1679 } else {
1680 dol_print_error($db);
1681 }
1682 }
1683
1684 // Allow external modules to add their own shortlist of recent objects
1685 $parameters = array();
1686 $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action);
1687 if ($reshook < 0) {
1688 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1689 } else {
1690 print $hookmanager->resPrint;
1691 }
1692
1693 print '</div></div>';
1694 print '<div class="clearboth"></div>';
1695
1696 print dol_get_fiche_end();
1697
1698
1699 /*
1700 * Action bar
1701 */
1702 print '<div class="tabsAction">';
1703
1704 $parameters = array();
1705 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1706
1707 if (empty($reshook)) {
1708 if ($object->status != 1) {
1709 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
1710 }
1711
1712 if (isModEnabled("propal") && $user->hasRight('propal', 'creer') && $object->status == 1) {
1713 $langs->load("propal");
1714 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?socid='.$object->id.'&action=create">'.$langs->trans("AddProp").'</a></div>';
1715 }
1716
1717 if (isModEnabled('order') && $user->hasRight('commande', 'creer') && $object->status == 1) {
1718 $langs->load("orders");
1719 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$object->id.'&action=create">'.$langs->trans("AddOrder").'</a></div>';
1720 }
1721
1722 if ($user->hasRight('contrat', 'creer') && $object->status == 1) {
1723 $langs->load("contracts");
1724 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$object->id.'&action=create">'.$langs->trans("AddContract").'</a></div>';
1725 }
1726
1727 if (isModEnabled('intervention') && $user->hasRight('ficheinter', 'creer') && $object->status == 1) {
1728 $langs->load("interventions");
1729 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&action=create">'.$langs->trans("AddIntervention").'</a></div>';
1730 }
1731
1732 // Add invoice
1733 if (isModEnabled('deplacement') && $object->status == 1) {
1734 $langs->load("trips");
1735 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&action=create">'.$langs->trans("AddTrip").'</a></div>';
1736 }
1737
1738 if (isModEnabled('invoice') && $object->status == 1) {
1739 if (!$user->hasRight('facture', 'creer')) {
1740 $langs->load("bills");
1741 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1742 } else {
1743 $langs->loadLangs(array("orders", "bills"));
1744
1745 if ($object->client != 0 && $object->client != 2) {
1746 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
1747 } else {
1748 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1749 }
1750 }
1751 }
1752
1753 if (isModEnabled('invoice') && $object->status == 1) {
1754 if ($user->hasRight('facture', 'creer')) {
1755 if (isModEnabled('order')) {
1756 if ($object->client != 0 && $object->client != 2) {
1757 if (!empty($orders2invoice) && $orders2invoice > 0) {
1758 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
1759 } else {
1760 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
1761 }
1762 } else {
1763 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
1764 }
1765 }
1766 }
1767 }
1768
1769 // Add action
1770 if (isModEnabled('agenda') && getDolGlobalString('MAIN_REPEATTASKONEACHTAB') && $object->status == 1) {
1771 if ($user->hasRight('agenda', 'myactions', 'create')) {
1772 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a></div>';
1773 } else {
1774 print '<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a></div>';
1775 }
1776 }
1777 }
1778
1779 print '</div>';
1780
1781 if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD')) {
1782 // List of contacts
1783 show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
1784 }
1785
1786 if (getDolGlobalString('MAIN_REPEATTASKONEACHTAB')) {
1787 print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
1788
1789 // List of todo actions
1790 show_actions_todo($conf, $langs, $db, $object);
1791
1792 // List of done actions
1793 show_actions_done($conf, $langs, $db, $object);
1794 }
1795} else {
1796 recordNotFound('', 0);
1797}
1798
1799// End of page
1800llxFooter();
1801$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage customers or prospects.
Class to manage customers orders.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage invoices.
Class to manage invoice templates.
Class to manage generation of HTML components for accounting management.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage projects.
Class to manage proposals.
Class to manage Dolibarr users.
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $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).
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='')
Show html area with actions to do.
global $mysoc
completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $object=null)
Complete $filearray with data from database.
dol_dir_list($utf8_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:64
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
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 the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.