dolibarr 24.0.0-beta
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-2026 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-2026 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';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
51require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
52require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
53require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
54require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
55require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
56if (isModEnabled('invoice')) {
57 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
58 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
59}
60if (isModEnabled("propal")) {
61 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
62}
63if (isModEnabled('order')) {
64 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
65}
66if (isModEnabled("shipping")) {
67 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
68}
69if (isModEnabled('contract')) {
70 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
71}
72if (isModEnabled('member')) {
73 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
74}
75if (isModEnabled('intervention')) {
76 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
77}
78if (isModEnabled('accounting')) {
79 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
80 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
81}
82
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$formfile = new FormFile($db);
133
134// fetch optionals attributes and labels
135$extrafields->fetch_name_optionals_label($object->table_element);
136
137// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
138$hookmanager->initHooks(array('thirdpartycomm', 'globalcard'));
139
140$now = dol_now();
141
142if ($id > 0 && empty($object->id)) {
143 // Load data of third party
144 $res = $object->fetch($id);
145 if ($object->id < 0) {
146 dol_print_error($db, $object->error, $object->errors);
147 }
148}
149if ($object->id > 0) {
150 if (!($object->client > 0) || !$user->hasRight('societe', 'lire')) {
152 }
153}
154
155// Security check
156if ($user->socid > 0) {
157 $id = $user->socid;
158}
159$result = restrictedArea($user, 'societe', $object->id, '&societe', '', 'fk_soc', 'rowid', 0);
160
161$permissiontoadd = $user->hasRight('societe', 'creer');
162$permissiontoeditextra = $permissiontoadd;
163if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
164 // For action 'update_extras', is there a specific permission set for the attribute to update
165 $permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
166}
167
168
169/*
170 * Actions
171 */
172$error = 0;
173
174$parameters = array('id' => $id, 'socid' => $id);
175$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
176if ($reshook < 0) {
177 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
178}
179
180if (empty($reshook)) {
181 if ($cancel) {
182 $action = "";
183 }
184
185 // set accountancy code
186 if ($action == 'setcustomeraccountancycodegeneral' && $permissiontoadd) {
187 $result = $object->fetch($id);
188 $object->accountancy_code_customer_general = GETPOST("customeraccountancycodegeneral");
189 $result = $object->update($object->id, $user, 1, 1, 0);
190 if ($result < 0) {
191 setEventMessages($object->error, $object->errors, 'errors');
192 }
193 }
194
195 // Set accountancy code
196 if ($action == 'setcustomeraccountancycode' && $permissiontoadd) {
197 $result = $object->fetch($id);
198 $object->code_compta_client = GETPOST("customeraccountancycode");
199 $object->code_compta = $object->code_compta_client; // For Backward compatibility
200 $result = $object->update($object->id, $user, 1, 1, 0);
201 if ($result < 0) {
202 setEventMessages($object->error, $object->errors, 'errors');
203 $action = 'editcustomeraccountancycode';
204 }
205 }
206
207 // Payment terms of the settlement
208 if ($action == 'setconditions' && $permissiontoadd) {
209 $object->fetch($id);
210 $result = $object->setPaymentTerms(GETPOSTINT('cond_reglement_id'), GETPOSTFLOAT('cond_reglement_id_deposit_percent'));
211 if ($result < 0) {
212 setEventMessages($object->error, $object->errors, 'errors');
213 }
214 }
215
216 // Payment mode
217 if ($action == 'setmode' && $permissiontoadd) {
218 $object->fetch($id);
219 $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_id'));
220 if ($result < 0) {
221 setEventMessages($object->error, $object->errors, 'errors');
222 }
223 }
224
225 // Transport mode
226 if ($action == 'settransportmode' && $permissiontoadd) {
227 $object->fetch($id);
228 $result = $object->setTransportMode(GETPOSTINT('transport_mode_id'));
229 if ($result < 0) {
230 setEventMessages($object->error, $object->errors, 'errors');
231 }
232 }
233
234 // Bank account
235 if ($action == 'setbankaccount' && $permissiontoadd) {
236 $object->fetch($id);
237 $result = $object->setBankAccount(GETPOSTINT('fk_account'));
238 if ($result < 0) {
239 setEventMessages($object->error, $object->errors, 'errors');
240 }
241 }
242
243 // customer preferred shipping method
244 if ($action == 'setshippingmethod' && $permissiontoadd) {
245 $object->fetch($id);
246 $result = $object->setShippingMethod(GETPOSTINT('shipping_method_id'));
247 if ($result < 0) {
248 setEventMessages($object->error, $object->errors, 'errors');
249 }
250 }
251
252 // assujetissement a la TVA
253 if ($action == 'setassujtva' && $permissiontoadd) {
254 $object->fetch($id);
255 $object->tva_assuj = GETPOSTINT('assujtva_value');
256 $result = $object->update($object->id, $user);
257 if ($result < 0) {
258 setEventMessages($object->error, $object->errors, 'errors');
259 }
260 }
261
262 // set prospect level
263 if ($action == 'setprospectlevel' && $permissiontoadd) {
264 $object->fetch($id);
265 $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha');
266 $result = $object->update($object->id, $user);
267 if ($result < 0) {
268 setEventMessages($object->error, $object->errors, 'errors');
269 }
270 }
271
272 // set communication status
273 if ($action == 'setstcomm' && $permissiontoadd) {
274 $object->fetch($id);
275 $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm');
276 $result = $object->update($object->id, $user);
277 if ($result < 0) {
278 setEventMessages($object->error, $object->errors, 'errors');
279 } else {
280 $result = $object->fetch($object->id);
281 }
282 }
283
284 // update outstandng limit
285 if ($action == 'setoutstanding_limit' && $permissiontoadd) {
286 $object->fetch($id);
287 $object->outstanding_limit = GETPOST('outstanding_limit');
288 $result = $object->update($object->id, $user);
289 if ($result < 0) {
290 setEventMessages($object->error, $object->errors, 'errors');
291 }
292 }
293
294 // update order min amount
295 if ($action == 'setorder_min_amount' && $permissiontoadd) {
296 $object->fetch($id);
297 $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha'));
298 $result = $object->update($object->id, $user);
299 if ($result < 0) {
300 setEventMessages($object->error, $object->errors, 'errors');
301 }
302 }
303
304 // Set sales representatives
305 if ($action == 'set_salesrepresentatives' && $permissiontoadd) {
306 $object->fetch($id);
307 $result = $object->setSalesRep(GETPOST('commercial', 'array'));
308 }
309
310 if ($action == 'update_extras' && $permissiontoeditextra) {
311 $object->fetch($id);
312
313 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
314
315 $attribute_name = GETPOST('attribute', 'aZ09');
316
317 // Fill array 'array_options' with data from update form
318 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
319 if ($ret < 0) {
320 $error++;
321 }
322
323 if (!$error) {
324 $result = $object->updateExtraField($attribute_name, 'COMPANY_MODIFY');
325 if ($result < 0) {
326 setEventMessages($object->error, $object->errors, 'errors');
327 $error++;
328 }
329 }
330
331 if ($error) {
332 $action = 'edit_extras';
333 }
334 }
335
336 // warehouse
337 if ($action == 'setwarehouse' && $permissiontoadd) {
338 $result = $object->setWarehouse(GETPOSTINT('fk_warehouse'));
339 }
340}
341
342
343/*
344 * View
345 */
346
347$contactstatic = new Contact($db);
348$userstatic = new User($db);
349$form = new Form($db);
350$formcompany = new FormCompany($db);
351$project = new Project($db);
352
353$title = $langs->trans("ThirdParty")." - ".$langs->trans('Customer');
354if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
355 $title = $object->name." - ".$langs->trans('Customer');
356}
357
358$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
359
360llxHeader('', $title, $help_url);
361
362if ($object->id > 0) {
363 $head = societe_prepare_head($object);
364
365 print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company');
366
367 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
368
369 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
370
371 print '<div class="fichecenter"><div class="fichehalfleft">';
372
373 print '<div class="underbanner clearboth"></div>';
374 print '<table class="border centpercent tableforfield">';
375
376 // Nature Prospect/Customer/Supplier
377 print '<tr><td class="titlefieldmiddle">'.$langs->trans('NatureOfThirdParty').'</td><td>';
378 print $object->getTypeUrl(1);
379 print '</td></tr>';
380
381 if ($object->client) {
382 $langs->loadLangs(array("compta", "accountancy"));
383
384 print '<tr><td>';
385 print $langs->trans('CustomerCode').'</td><td>';
386 print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
387 $tmpcheck = $object->check_codeclient();
388 if ($tmpcheck != 0 && $tmpcheck != -5) {
389 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
390 }
391 print '</td></tr>';
392
393 if (isModEnabled('accounting')) {
394 $formaccounting = new FormAccounting($db);
395
396 print '<tr>';
397 print '<td>';
398 print $form->editfieldkey("CustomerAccountancyCodeGeneral", 'customeraccountancycodegeneral', length_accountg($object->accountancy_code_customer_general), $object, $permissiontoadd);
399 print '</td><td>';
400 if ($action == 'editcustomeraccountancycodegeneral' && $permissiontoadd) {
401 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_customer_general, 'customeraccountancycodegeneral', 0, 1, '', 1);
402 } else {
403 if ($object->accountancy_code_customer_general > 0) {
404 $accountingaccount = new AccountingAccount($db);
405 $accountingaccount->fetch(0, $object->accountancy_code_customer_general, 1);
406
407 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
408 }
409 if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) {
410 if ($object->accountancy_code_customer_general > 0) {
411 print ' - ';
412 }
413 $accountingAccountByDefault = '<span class="opacitymedium">' . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) . '</span>';
414 print $accountingAccountByDefault;
415 }
416 }
417 print '</td>';
418 print '</tr>';
419 }
420
421 print '<tr>';
422 print '<td>';
423 print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $permissiontoadd);
424 print '</td><td>';
425 print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $permissiontoadd);
426 print '</td>';
427 print '</tr>';
428 }
429
430 // 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.
431 // We don't need them into customer profile.
432 // Except for spain and localtax where localtax depends on buyer and not seller
433
434 // VAT is used
435 /*
436 print '<tr>';
437 print '<td class="nowrap">';
438 print $form->textwithpicto($langs->trans('VATIsUsed'),$langs->trans('VATIsUsedWhenSelling'));
439 print '</td><td>';
440 print yn($object->tva_assuj);
441 print '</td>';
442 print '</tr>';
443 */
444
445 if ($mysoc->country_code == 'ES') {
446 // Local Taxes
447 if ($mysoc->localtax1_assuj == "1") {
448 print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
449 print yn($object->localtax1_assuj);
450 print '</td></tr>';
451 }
452 if ($mysoc->localtax1_assuj == "1") {
453 print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
454 print yn($object->localtax2_assuj);
455 print '</td></tr>';
456 }
457 }
458
459 // TVA Intra
460 print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
461 print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra));
462 print '</td></tr>';
463
464 // default terms of the settlement
465 $langs->load('bills');
466 print '<tr><td>';
467 print '<table width="100%" class="nobordernopadding"><tr><td>';
468 print $langs->trans('PaymentConditions');
469 print '<td>';
470 if (($action != 'editconditions') && $permissiontoadd) {
471 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>';
472 }
473 print '</tr></table>';
474 print '</td><td>';
475 if ($action == 'editconditions') {
476 $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->cond_reglement_id, 'cond_reglement_id', 1, '', 1, $object->deposit_percent);
477 } else {
478 $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->cond_reglement_id, 'none', 0, '', 1, $object->deposit_percent);
479 }
480 print "</td>";
481 print '</tr>';
482
483 // Default payment mode
484 print '<tr><td class="nowrap">';
485 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
486 print $langs->trans('PaymentMode');
487 print '<td>';
488 if (($action != 'editmode') && $permissiontoadd) {
489 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>';
490 }
491 print '</tr></table>';
492 print '</td><td>';
493 if ($action == 'editmode') {
494 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1);
495 } else {
496 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_id, 'none');
497 }
498 print "</td>";
499 print '</tr>';
500
501 if (isModEnabled("bank")) {
502 // Default bank account for payments
503 print '<tr><td class="nowrap">';
504 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
505 print $langs->trans('PaymentBankAccount');
506 print '<td>';
507 if (($action != 'editbankaccount') && $permissiontoadd) {
508 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>';
509 }
510 print '</tr></table>';
511 print '</td><td>';
512 if ($action == 'editbankaccount') {
513 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'fk_account', 1);
514 } else {
515 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'none');
516 }
517 print "</td>";
518 print '</tr>';
519 }
520
521 $isCustomer = ($object->client == 1 || $object->client == 3);
522
523 // Relative discounts (Discounts-Drawbacks-Rebates)
524 if ($isCustomer) {
525 print '<tr><td class="nowrap">';
526 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
527 print $langs->trans("CustomerRelativeDiscountShort");
528 print '<td><td class="right">';
529 if ($permissiontoadd && !$user->socid > 0) {
530 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>';
531 }
532 print '</td></tr></table>';
533 print '</td><td>'.($object->remise_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>' : '').'</td>';
534 print '</tr>';
535
536 // Absolute discounts (Discounts-Drawbacks-Rebates)
537 print '<tr><td class="nowrap">';
538 print '<table width="100%" class="nobordernopadding">';
539 print '<tr><td class="nowrap">';
540 print $langs->trans("CustomerAbsoluteDiscountShort");
541 print '<td><td class="right">';
542 if ($permissiontoadd && !$user->socid > 0) {
543 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>';
544 }
545 print '</td></tr></table>';
546 print '</td>';
547 print '<td>';
548 $amount_discount = $object->getAvailableDiscounts();
549 if ($amount_discount < 0) {
550 dol_print_error($db, $object->error);
551 }
552 if ($amount_discount > 0) {
553 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>';
554 }
555 //else print $langs->trans("DiscountNone");
556 print '</td>';
557 print '</tr>';
558 }
559
560 $limit_field_type = '';
561 // Max outstanding bill
562 if ($object->client) {
563 print '<tr class="nowrap">';
564 print '<td>';
565 print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $permissiontoadd);
566 print '</td><td>';
567 //$limit_field_type = (getDolGlobalString('MAIN_USE_EDIT_IN_PLACE')) ? 'numeric' : 'amount'; // TODO deprecated ?
568 $limit_field_type = '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
835 $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
836 $icon = 'bill';
837 $boxstattmp = '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
838 $boxstattmp .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
839 $boxstattmp .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
840 $boxstattmp .= '</div>';
841 if ($link) {
842 $boxstat .= dolButtonToOpenUrlInDialogPopup('popupoutstanding', $text, $boxstattmp, '/compta/recap-compta.php?socid='.$object->id, '', '');
843 } else {
844 $boxstat .= $boxstattmp;
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
856 $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
857 $icon = 'bill';
858 $boxstattmp = '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
859 $boxstattmp .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
860 $boxstattmp .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
861 $boxstattmp .= '</div>';
862 if ($link) {
863 $boxstat .= dolButtonToOpenUrlInDialogPopup('popupoutstanding', $text, $boxstattmp, '/compta/recap-compta.php?socid='.$object->id, '', '');
864 } else {
865 $boxstat .= $boxstattmp;
866 }
867 }
868 }
869
870 // Margins
871 if (isModEnabled('margin') && $user->hasRight('margin', 'liretous')) {
872 // Box margin
873 $sql = "SELECT ";
874 $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive
875 $sql .= " sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // always positive
876 $sql .= " sum(d.total_ht - (".$db->ifsql('f.type = '.Facture::TYPE_CREDIT_NOTE, '-1', '1')." * (d.buy_price_ht * d.qty * (d.situation_percent / 100)))) as marge";
877 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
878 $sql .= " ".MAIN_DB_PREFIX."facturedet as d";
879 $sql .= " WHERE f.fk_soc = ".((int) $id);
880 $sql .= " AND f.fk_statut > 0";
881 $sql .= " AND f.entity IN (".getEntity('invoice').")";
882 $sql .= " AND d.fk_facture = f.rowid";
883 $sql .= " AND d.buy_price_ht IS NOT NULL";
884 // We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report.
885 // We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredictable.
886 if (getDolGlobalInt('ForceBuyingPriceIfNull') == 2) {
887 $sql .= " AND d.buy_price_ht <> 0";
888 }
889
890 $marginTotal = 0;
891
892 $resql = $db->query($sql);
893 if ($resql) {
894 $obj = $db->fetch_object($resql);
895 if ($obj) {
896 $marginTotal = $obj->marge;
897 }
898 }
899
900 $text = $langs->transnoentitiesnoconv("Margins");
901
902 $link = DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$object->id;
903 $icon = 'margin';
904 $boxstattmp = '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
905 $boxstattmp .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
906 $boxstattmp .= '<span class="boxstatsindicator">'.price($marginTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
907 $boxstattmp .= '</div>';
908 if ($link) {
909 $boxstat .= dolButtonToOpenUrlInDialogPopup('popupmargin', $text, $boxstattmp, '/margin/tabs/thirdpartyMargins.php?socid='.$object->id, '', '');
910 } else {
911 $boxstat .= $boxstattmp;
912 }
913 }
914
915
916 $parameters = array();
917 $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action);
918 if (empty($reshook)) {
919 $boxstat .= $hookmanager->resPrint;
920 }
921
922 $boxstat .= '</td></tr>';
923 $boxstat .= '</table>';
924 $boxstat .= '</div>';
925
926 print $boxstat;
927
928
929
930 /*
931 * Latest proposals
932 */
933 if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
934 $propal_static = new Propal($db);
935 $langs->load("propal");
936
937 $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_projet, p.fk_statut, p.total_ht";
938 $sql .= ", p.total_tva";
939 $sql .= ", p.total_ttc";
940 $sql .= ", p.ref, p.ref_client, p.remise";
941 $sql .= ", p.datep as dp, p.fin_validite as date_limit, p.entity";
942 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
943 $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
944 $sql .= " AND s.rowid = ".((int) $object->id);
945 $sql .= " AND p.entity IN (".getEntity('propal').")";
946 $parameters = array();
947 $hookmanager->executeHooks('printFieldListWhere', $parameters, $propal_static); // Note that $action and $object may have been modified by hook
948 $sql .= $hookmanager->resPrint;
949 $sql .= " ORDER BY p.datep DESC";
950
951 $resql = $db->query($sql);
952 if ($resql) {
953 $num = $db->num_rows($resql);
954 if ($num > 0) {
955 print '<div class="div-table-responsive-no-min">';
956 print '<table class="noborder centpercent lastrecordtable">';
957
958 print '<tr class="liste_titre">';
959 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>';
960 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>';
961 print '</tr></table></td>';
962 print '</tr>';
963 }
964
965 $i = 0;
966 while ($i < $num && $i < $MAXLIST) {
967 $objp = $db->fetch_object($resql);
968
969 print '<tr class="oddeven">';
970 print '<td class="nowraponall">';
971 $propal_static->id = $objp->propalid;
972 $propal_static->ref = $objp->ref;
973 $propal_static->ref_client = $objp->ref_client; // deprecated
974 $propal_static->ref_customer = $objp->ref_client;
975 $propal_static->fk_project = $objp->fk_projet;
976 $propal_static->total_ht = $objp->total_ht;
977 $propal_static->total_tva = $objp->total_tva;
978 $propal_static->total_ttc = $objp->total_ttc;
979 print $propal_static->getNomUrl(1);
980
981 // Preview
982 $filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
983 $file_list = null;
984 if (!empty($filedir)) {
985 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
986 }
987 if (is_array($file_list) && !empty($file_list)) {
988 // Defined relative dir to DOL_DATA_ROOT
989 $relativedir = '';
990 if ($filedir) {
991 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
992 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
993 }
994 // Get list of files stored into database for same relative directory
995 if ($relativedir) {
996 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
997 '@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';
998
999 //var_dump($sortfield.' - '.$sortorder);
1000 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)
1001 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1002 }
1003 }
1004 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1005 print $formfile->showPreview($file_list[0], $propal_static->element, $relativepath, 0, 'entity=' . $objp->entity);
1006 }
1007 print '</td><td class="tdoverflowmax125">';
1008 if ($propal_static->fk_project > 0) {
1009 $project->fetch($propal_static->fk_project);
1010 print $project->getNomUrl(1);
1011 }
1012 // $filename = dol_sanitizeFileName($objp->ref);
1013 // $filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1014 // $urlsource = '/comm/propal/card.php?id='.$objp->cid;
1015 // print $formfile->getDocumentsLink($propal_static->element, $filename, $filedir);
1016 if (($db->jdate($objp->date_limit) < ($now - getWarningDelay('propal', 'cloture'))) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
1017 print " ".img_warning();
1018 }
1019 print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
1020 print '<td class="right nowraponall">'.price($objp->total_ht).'</td>';
1021 print '<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).'</td></tr>';
1022 $i++;
1023 }
1024 $db->free($resql);
1025
1026 if ($num > 0) {
1027 print "</table>";
1028 print '</div>';
1029 }
1030 } else {
1032 }
1033 }
1034
1035 $orders2invoice = null;
1036 $param = "";
1037
1038 /*
1039 * Latest orders
1040 */
1041 if (isModEnabled('order') && $user->hasRight('commande', 'lire')) {
1042 $commande_static = new Commande($db);
1043 $sql = "SELECT s.nom, s.rowid";
1044 $sql .= ", c.rowid as cid, c.entity, c.fk_projet, c.total_ht";
1045 $sql .= ", c.total_tva";
1046 $sql .= ", c.total_ttc";
1047 $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture";
1048 $sql .= ", c.date_commande as dc";
1049 $sql .= ", c.facture as billed";
1050 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
1051 $sql .= " WHERE c.fk_soc = s.rowid ";
1052 $sql .= " AND s.rowid = ".((int) $object->id);
1053 $sql .= " AND c.entity IN (".getEntity('commande').')';
1054 $parameters = array();
1055 $hookmanager->executeHooks('printFieldListWhere', $parameters, $commande_static); // Note that $action and $object may have been modified by hook
1056 $sql .= $hookmanager->resPrint;
1057 $sql .= " ORDER BY c.date_commande DESC";
1058
1059 $resql = $db->query($sql);
1060 if ($resql) {
1061 $num = $db->num_rows($resql);
1062 if ($num > 0) {
1063 // Check if there are orders billable
1064 $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
1065 $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
1066 $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
1067 $sql2 .= ', '.MAIN_DB_PREFIX.'commande as c';
1068 $sql2 .= ' WHERE c.fk_soc = s.rowid';
1069 $sql2 .= ' AND s.rowid = '.((int) $object->id);
1070 // Show orders with status validated, shipping started and delivered (well any order we can bill)
1071 $sql2 .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
1072
1073 $resql2 = $db->query($sql2);
1074 $orders2invoice = $db->num_rows($resql2);
1075 $db->free($resql2);
1076
1077 print '<div class="div-table-responsive-no-min">';
1078 print '<table class="noborder centpercent lastrecordtable">';
1079
1080 print '<tr class="liste_titre">';
1081 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>';
1082 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>';
1083 print '</tr></table></td>';
1084 print '</tr>';
1085 }
1086
1087 $i = 0;
1088 while ($i < $num && $i < $MAXLIST) {
1089 $objp = $db->fetch_object($resql);
1090
1091 $commande_static->id = $objp->cid;
1092 $commande_static->ref = $objp->ref;
1093 $commande_static->ref_client = $objp->ref_client;
1094 $commande_static->fk_project = $objp->fk_projet;
1095 $commande_static->total_ht = $objp->total_ht;
1096 $commande_static->total_tva = $objp->total_tva;
1097 $commande_static->total_ttc = $objp->total_ttc;
1098 $commande_static->billed = $objp->billed;
1099
1100 print '<tr class="oddeven">';
1101 print '<td class="nowraponall">';
1102 print $commande_static->getNomUrl(1);
1103 // Preview
1104 $filedir = $conf->commande->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1105 $file_list = null;
1106 if (!empty($filedir)) {
1107 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1108 }
1109 if (is_array($file_list) && !empty($file_list)) {
1110 // Defined relative dir to DOL_DATA_ROOT
1111 $relativedir = '';
1112 if ($filedir) {
1113 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1114 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1115 }
1116 // Get list of files stored into database for same relative directory
1117 if ($relativedir) {
1118 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1119 '@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';
1120
1121 //var_dump($sortfield.' - '.$sortorder);
1122 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)
1123 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1124 }
1125 }
1126 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1127 print $formfile->showPreview($file_list[0], $commande_static->element, $relativepath, 0, 'entity=' . $objp->entity);
1128 }
1129 print '</td><td class="tdoverflowmax125">';
1130 if ($commande_static->fk_project > 0) {
1131 $project->fetch($commande_static->fk_project);
1132 print $project->getNomUrl(1);
1133 }
1134 // $filename = dol_sanitizeFileName($objp->ref);
1135 // $filedir = $conf->order->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1136 // $urlsource = '/commande/card.php?id='.$objp->cid;
1137 // print $formfile->getDocumentsLink($commande_static->element, $filename, $filedir);
1138 print '</td>';
1139
1140 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day')."</td>\n";
1141 print '<td class="right nowraponall">'.price($objp->total_ht).'</td>';
1142 print '<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>';
1143 $i++;
1144 }
1145 $db->free($resql);
1146
1147 if ($num > 0) {
1148 print "</table>";
1149 print '</div>';
1150 }
1151 } else {
1153 }
1154 }
1155
1156 /*
1157 * Latest shipments
1158 */
1159 if (isModEnabled("shipping") && $user->hasRight('expedition', 'lire')) {
1160 $param = '';
1161
1162 $sql = 'SELECT e.rowid as id';
1163 $sql .= ', e.ref, e.entity, e.fk_projet';
1164 $sql .= ', e.date_creation';
1165 $sql .= ', e.fk_statut as statut';
1166 $sql .= ', s.nom';
1167 $sql .= ', s.rowid as socid';
1168 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
1169 $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1170 $sql .= " AND e.entity IN (".getEntity('expedition').")";
1171 $sql .= ' GROUP BY e.rowid';
1172 $sql .= ', e.ref, e.entity, e.fk_projet';
1173 $sql .= ', e.date_creation';
1174 $sql .= ', e.fk_statut';
1175 $sql .= ', s.nom';
1176 $sql .= ', s.rowid';
1177 $sql .= " ORDER BY e.date_creation DESC";
1178
1179 $resql = $db->query($sql);
1180 if ($resql) {
1181 $sendingstatic = new Expedition($db);
1182
1183 $num = $db->num_rows($resql);
1184 if ($num > 0) {
1185 print '<div class="div-table-responsive-no-min">';
1186 print '<table class="noborder centpercent lastrecordtable">';
1187
1188 print '<tr class="liste_titre">';
1189 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>';
1190 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>';
1191 print '</tr></table></td>';
1192 print '</tr>';
1193 }
1194
1195 $i = 0;
1196 while ($i < $num && $i < $MAXLIST) {
1197 $objp = $db->fetch_object($resql);
1198
1199 $param = 'entity=' . ((int) $objp->entity);
1200
1201 $sendingstatic->id = $objp->id;
1202 $sendingstatic->ref = $objp->ref;
1203 $sendingstatic->fk_project = $objp->fk_projet;
1204
1205 print '<tr class="oddeven">';
1206 print '<td class="nowraponall">';
1207 print $sendingstatic->getNomUrl(1);
1208 // Preview
1209 $filedir = $conf->expedition->multidir_output[$objp->entity].'/sending/'.dol_sanitizeFileName($objp->ref);
1210 $file_list = null;
1211 if (!empty($filedir)) {
1212 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1213 }
1214 if (is_array($file_list) && !empty($file_list)) {
1215 // Defined relative dir to DOL_DATA_ROOT
1216 $relativedir = '';
1217 if ($filedir) {
1218 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1219 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1220 }
1221 // Get list of files stored into database for same relative directory
1222 if ($relativedir) {
1223 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1224 '@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';
1225
1226 //var_dump($sortfield.' - '.$sortorder);
1227 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)
1228 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1229 }
1230 }
1231 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1232
1233 print $formfile->showPreview($file_list[0], $sendingstatic->element, $relativepath, 0, $param);
1234 }
1235 print '</td><td class="tdoverflowmax125">';
1236 if ($sendingstatic->fk_project > 0) {
1237 $project->fetch($sendingstatic->fk_project);
1238 print $project->getNomUrl(1);
1239 }
1240 // $filename = dol_sanitizeFileName($objp->ref);
1241 // $filedir = $conf->expedition->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1242 // $urlsource = '/expedition/card.php?id='.$objp->cid;
1243 // print $formfile->getDocumentsLink($sendingstatic->element, $filename, $filedir);
1244 print '</td>';
1245 if ($objp->date_creation > 0) {
1246 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>';
1247 } else {
1248 print '<td class="right"><b>!!!</b></td>';
1249 }
1250
1251 print '<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).'</td>';
1252 print "</tr>\n";
1253 $i++;
1254 }
1255 $db->free($resql);
1256
1257 if ($num > 0) {
1258 print "</table>";
1259 print '</div>';
1260 }
1261 } else {
1263 }
1264 }
1265
1266 /*
1267 * Latest contracts
1268 */
1269 if (isModEnabled('contract') && $user->hasRight('contrat', 'lire')) {
1270 $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,";
1271 $sql .= " c.last_main_doc, c.model_pdf";
1272 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
1273 $sql .= " WHERE c.fk_soc = s.rowid ";
1274 $sql .= " AND s.rowid = ".((int) $object->id);
1275 $sql .= " AND c.entity IN (".getEntity('contract').")";
1276 $sql .= " ORDER BY c.datec DESC";
1277
1278 $resql = $db->query($sql);
1279 if ($resql) {
1280 $contrat = new Contrat($db);
1281
1282 $num = $db->num_rows($resql);
1283 if ($num > 0) {
1284 print '<div class="div-table-responsive-no-min">';
1285 print '<table class="noborder centpercent lastrecordtable">';
1286
1287 print '<tr class="liste_titre">';
1288 print '<td colspan="6"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
1289 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>';
1290 //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>';
1291 print '</tr></table></td>';
1292 print '</tr>';
1293 }
1294
1295 $i = 0;
1296 while ($i < $num && $i < $MAXLIST) {
1297 $objp = $db->fetch_object($resql);
1298
1299 $contrat->id = $objp->id;
1300 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1301 $contrat->ref_customer = $objp->refcus;
1302 $contrat->ref_supplier = $objp->refsup;
1303 $contrat->fk_project = $objp->fk_projet;
1304 $contrat->statut = $objp->contract_status; // deprecated
1305 $contrat->status = $objp->contract_status;
1306 $contrat->last_main_doc = $objp->last_main_doc;
1307 $contrat->model_pdf = $objp->model_pdf;
1308 $contrat->fetch_lines();
1309
1310 $late = '';
1311 foreach ($contrat->lines as $line) {
1312 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1313 if (((!empty($line->date_end) ? $line->date_end : 0) + getWarningDelay('contract', 'service', 'expires')) < $now) {
1314 $late = img_warning($langs->trans("Late"));
1315 }
1316 }
1317 }
1318
1319 print '<tr class="oddeven">';
1320 print '<td class="nowraponall">';
1321 print $contrat->getNomUrl(1, 12);
1322 if (!empty($contrat->model_pdf)) {
1323 // Preview
1324 $filedir = $conf->contract->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1325 $file_list = null;
1326 if (!empty($filedir)) {
1327 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1328 }
1329 if (is_array($file_list) && !empty($file_list)) {
1330 // Defined relative dir to DOL_DATA_ROOT
1331 $relativedir = '';
1332 if ($filedir) {
1333 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1334 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1335 }
1336 // Get list of files stored into database for same relative directory
1337 if ($relativedir) {
1338 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1339 '@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';
1340
1341 //var_dump($sortfield.' - '.$sortorder);
1342 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)
1343 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1344 }
1345 }
1346 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1347 print $formfile->showPreview($file_list[0], $contrat->element, $relativepath, 0, 'entity=' . $objp->entity);
1348 }
1349 }
1350 // $filename = dol_sanitizeFileName($objp->ref);
1351 // $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1352 // $urlsource = '/contrat/card.php?id='.$objp->cid;
1353 // print $formfile->getDocumentsLink($contrat->element, $filename, $filedir);
1354 print $late;
1355 print '</td><td class="tdoverflowmax125">';
1356 if ($contrat->fk_project > 0) {
1357 $project->fetch($contrat->fk_project);
1358 print $project->getNomUrl(1);
1359 }
1360 print "</td>\n";
1361 print '<td class="nowrap">';
1362 print dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1363 print "</td>\n";
1364 //print '<td class="right" width="80px"><span title="'.$langs->trans("DateCreation").'">'.dol_print_date($db->jdate($objp->dc), 'day')."</span></td>\n";
1365 print '<td class="right" width="80px"><span title="'.$langs->trans("DateContract").'">'.dol_print_date($db->jdate($objp->dcon), 'day')."</span></td>\n";
1366 print '<td width="20">&nbsp;</td>';
1367 print '<td class="nowraponall right">';
1368 print $contrat->getLibStatut(4);
1369 print "</td>\n";
1370 print '</tr>';
1371 $i++;
1372 }
1373 $db->free($resql);
1374
1375 if ($num > 0) {
1376 print "</table>";
1377 print '</div>';
1378 }
1379 } else {
1381 }
1382 }
1383
1384 /*
1385 * Latest interventions
1386 */
1387 if (isModEnabled('intervention') && $user->hasRight('ficheinter', 'lire')) {
1388 $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";
1389 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
1390 $sql .= " WHERE f.fk_soc = s.rowid";
1391 $sql .= " AND s.rowid = ".((int) $object->id);
1392 $sql .= " AND f.entity IN (".getEntity('intervention').")";
1393 $sql .= " ORDER BY f.tms DESC";
1394
1395 $resql = $db->query($sql);
1396 if ($resql) {
1397 $fichinter_static = new Fichinter($db);
1398
1399 $num = $db->num_rows($resql);
1400 if ($num > 0) {
1401 print '<div class="div-table-responsive-no-min">';
1402 print '<table class="noborder centpercent lastrecordtable">';
1403
1404 print '<tr class="liste_titre">';
1405 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>';
1406 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>';
1407 print '</tr></table></td>';
1408 print '</tr>';
1409 }
1410
1411 $i = 0;
1412 while ($i < $num && $i < $MAXLIST) {
1413 $objp = $db->fetch_object($resql);
1414
1415 $fichinter_static->id = $objp->id;
1416 $fichinter_static->ref = $objp->ref;
1417 $fichinter_static->statut = $objp->fk_statut; // deprecated
1418 $fichinter_static->status = $objp->fk_statut;
1419 $fichinter_static->fk_project = $objp->fk_projet;
1420
1421 print '<tr class="oddeven">';
1422 print '<td class="nowraponall">';
1423 print $fichinter_static->getNomUrl(1);
1424 // Preview
1425 $filedir = $conf->ficheinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1426 $file_list = null;
1427 if (!empty($filedir)) {
1428 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1429 }
1430 if (is_array($file_list) && !empty($file_list)) {
1431 // Defined relative dir to DOL_DATA_ROOT
1432 $relativedir = '';
1433 if ($filedir) {
1434 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1435 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1436 }
1437 // Get list of files stored into database for same relative directory
1438 if ($relativedir) {
1439 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1440 '@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';
1441
1442 //var_dump($sortfield.' - '.$sortorder);
1443 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)
1444 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1445 }
1446 }
1447 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1448 print $formfile->showPreview($file_list[0], $fichinter_static->element, $relativepath, 0, 'entity=' . $objp->entity);
1449 }
1450 print '</td><td class="tdoverflowmax125">';
1451 if ($fichinter_static->fk_project > 0) {
1452 $project->fetch($fichinter_static->fk_project);
1453 print $project->getNomUrl(1);
1454 }
1455 // $filename = dol_sanitizeFileName($objp->ref);
1456 // $filedir = getMultidirOutput($fichinter_static).'/'.dol_sanitizeFileName($objp->ref);
1457 // $urlsource = '/fichinter/card.php?id='.$objp->cid;
1458 // print $formfile->getDocumentsLink($fichinter_static->element, $filename, $filedir);
1459 print '</td>'."\n";
1460 //print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
1461 print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
1462 print '<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n";
1463 print '</tr>';
1464
1465 $i++;
1466 }
1467 $db->free($resql);
1468
1469 if ($num > 0) {
1470 print "</table>";
1471 print '</div>';
1472 }
1473 } else {
1475 }
1476 }
1477
1478 /*
1479 * Latest invoices templates
1480 */
1481 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
1482 $sql = 'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1483 $sql .= ', f.total_ht';
1484 $sql .= ', f.total_tva';
1485 $sql .= ', f.total_ttc';
1486 $sql .= ', f.datec as dc';
1487 $sql .= ', f.date_last_gen, f.date_when';
1488 $sql .= ', f.frequency';
1489 $sql .= ', f.unit_frequency';
1490 $sql .= ', f.suspended as suspended';
1491 $sql .= ', s.nom, s.rowid as socid';
1492 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
1493 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1494 $sql .= " AND f.entity IN (".getEntity('invoice').")";
1495 $sql .= ' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1496 $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1497 $sql .= ' f.suspended, f.date_when,';
1498 $sql .= ' s.nom, s.rowid';
1499 $sql .= " ORDER BY f.date_last_gen, f.datec DESC";
1500
1501 $resql = $db->query($sql);
1502 if ($resql) {
1503 $invoicetemplate = new FactureRec($db);
1504
1505 $num = $db->num_rows($resql);
1506 if ($num > 0) {
1507 print '<div class="div-table-responsive-no-min">';
1508 print '<table class="noborder centpercent lastrecordtable">';
1509 print '<tr class="liste_titre">';
1510 $colspan = 5;
1511 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1512 $colspan++;
1513 }
1514 print '<td colspan="'.$colspan.'">';
1515 print '<table class="centpercent nobordernopadding"><tr>';
1516 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>';
1517 print '</tr></table>';
1518 print '</td>';
1519 print '</tr>';
1520 }
1521
1522 $i = 0;
1523 while ($i < $num && $i < $MAXLIST) {
1524 $objp = $db->fetch_object($resql);
1525
1526 $invoicetemplate->id = $objp->id;
1527 $invoicetemplate->ref = $objp->ref;
1528 $invoicetemplate->fk_project = $objp->fk_projet;
1529 $invoicetemplate->suspended = $objp->suspended;
1530 $invoicetemplate->frequency = $objp->frequency;
1531 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1532 $invoicetemplate->total_ht = $objp->total_ht;
1533 $invoicetemplate->total_tva = $objp->total_tva;
1534 $invoicetemplate->total_ttc = $objp->total_ttc;
1535 $invoicetemplate->date_last_gen = $objp->date_last_gen;
1536 $invoicetemplate->date_when = $objp->date_when;
1537
1538 print '<tr class="oddeven">';
1539 print '<td class="tdoverflowmax250">';
1540 print $invoicetemplate->getNomUrl(1);
1541 print '</td><td class="tdoverflowmax125">';
1542 if ($invoicetemplate->fk_project > 0) {
1543 $project->fetch($invoicetemplate->fk_project);
1544 print $project->getNomUrl(1);
1545 }
1546 print '</td>';
1547
1548 if ($objp->frequency && $objp->date_last_gen > 0) {
1549 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
1550 } else {
1551 if ($objp->dc > 0) {
1552 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day').'</td>';
1553 } else {
1554 print '<td class="right"><b>!!!</b></td>';
1555 }
1556 }
1557 print '<td class="right nowraponall">';
1558 print price($objp->total_ht);
1559 print '</td>';
1560
1561 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1562 print '<td class="right nowraponall">';
1563 print price($objp->total_ttc);
1564 print '</td>';
1565 }
1566
1567 print '<td class="nowrap right" style="min-width: 60px">';
1568 print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - ';
1569 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1570 print '</td>';
1571 print "</tr>\n";
1572 $i++;
1573 }
1574 $db->free($resql);
1575
1576 if ($num > 0) {
1577 print "</table>";
1578 print '</div>';
1579 }
1580 } else {
1582 }
1583 }
1584
1585 /*
1586 * Latest invoices
1587 */
1588 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
1589 $sql = 'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1590 $sql .= ', f.total_ht';
1591 $sql .= ', f.total_tva';
1592 $sql .= ', f.total_ttc';
1593 $sql .= ', f.entity';
1594 $sql .= ', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status';
1595 $sql .= ', s.nom, s.rowid as socid';
1596 $sql .= ', SUM(pf.amount) as am';
1597 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
1598 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
1599 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1600 $sql .= " AND f.entity IN (".getEntity('invoice').")";
1601 $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1602 $sql .= ' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1603 $sql .= ' s.nom, s.rowid';
1604 $sql .= " ORDER BY f.datef DESC, f.datec DESC";
1605
1606 $resql = $db->query($sql);
1607 if ($resql) {
1608 $facturestatic = new Facture($db);
1609
1610 $num = $db->num_rows($resql);
1611 if ($num > 0) {
1612 print '<div class="div-table-responsive-no-min">';
1613 print '<table class="noborder centpercent lastrecordtable">';
1614 print '<tr class="liste_titre">';
1615 $colspan = 6;
1616 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1617 $colspan++;
1618 }
1619 if (getDolGlobalString('MAIN_SHOW_REF_CUSTOMER_INVOICES')) {
1620 $colspan++;
1621 }
1622 print '<td colspan="'.$colspan.'">';
1623 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>';
1624 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>';
1625 print '</tr></table>';
1626 print '</td>';
1627 print '</tr>';
1628 }
1629
1630 $i = 0;
1631 while ($i < $num && $i < $MAXLIST) {
1632 $objp = $db->fetch_object($resql);
1633
1634 $facturestatic->id = $objp->facid;
1635 $facturestatic->ref = $objp->ref;
1636 $facturestatic->ref_client = $objp->ref_client;
1637 $facturestatic->fk_project = $objp->fk_projet;
1638 $facturestatic->type = $objp->type;
1639 $facturestatic->total_ht = $objp->total_ht;
1640 $facturestatic->total_tva = $objp->total_tva;
1641 $facturestatic->total_ttc = $objp->total_ttc;
1642 $facturestatic->statut = $objp->status; // deprecated
1643 $facturestatic->status = $objp->status;
1644 $facturestatic->paye = $objp->paye;
1645
1646 $facturestatic->alreadypaid = $objp->am;
1647 $facturestatic->totalpaid = $objp->am;
1648
1649 $facturestatic->date = $db->jdate($objp->df);
1650 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1651
1652 print '<tr class="oddeven">';
1653 print '<td class="nowraponall">';
1654 print $facturestatic->getNomUrl(1);
1655 // Preview
1656 $filedir = $conf->invoice->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1657 $file_list = null;
1658 if (!empty($filedir)) {
1659 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1660 }
1661 if (is_array($file_list) && !empty($file_list)) {
1662 // Defined relative dir to DOL_DATA_ROOT
1663 $relativedir = '';
1664 if ($filedir) {
1665 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1666 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1667 }
1668 // Get list of files stored into database for same relative directory
1669 if ($relativedir) {
1670 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1671 '@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';
1672
1673 //var_dump($sortfield.' - '.$sortorder);
1674 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)
1675 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1676 }
1677 }
1678 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1679 print $formfile->showPreview($file_list[0], $facturestatic->element, $relativepath, 0, 'entity=' . $objp->entity);
1680 }
1681 print '</td><td class="tdoverflowmax125">';
1682 if ($facturestatic->fk_project > 0) {
1683 $project->fetch($facturestatic->fk_project);
1684 print $project->getNomUrl(1);
1685 }
1686 // $filename = dol_sanitizeFileName($objp->ref);
1687 // $filedir = $conf->facture->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1688 // $urlsource = '/compta/facture/card.php?id='.$objp->cid;
1689 //print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
1690 print '</td>';
1691 if (getDolGlobalString('MAIN_SHOW_REF_CUSTOMER_INVOICES')) {
1692 print '<td class="nowraponall">';
1693 print dolPrintHTML($objp->ref_client);
1694 print '</td>';
1695 }
1696 if ($objp->df > 0) {
1697 print '<td width="80px" title="'.dol_escape_htmltag($langs->trans('DateInvoice')).'">'.dol_print_date($db->jdate($objp->df), 'day').'</td>';
1698 } else {
1699 print '<td><b>!!!</b></td>';
1700 }
1701 if ($objp->dl > 0) {
1702 print '<td width="80px" title="'.dol_escape_htmltag($langs->trans('DateMaxPayment')).'">'.dol_print_date($db->jdate($objp->dl), 'day').'</td>';
1703 } else {
1704 print '<td><b>!!!</b></td>';
1705 }
1706
1707 print '<td class="right nowraponall">';
1708 print price($objp->total_ht);
1709 print '</td>';
1710
1711 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1712 print '<td class="right nowraponall">';
1713 print price($objp->total_ttc);
1714 print '</td>';
1715 }
1716
1717 print '<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).'</td>';
1718 print "</tr>\n";
1719 $i++;
1720 }
1721 $db->free($resql);
1722
1723 if ($num > 0) {
1724 print "</table>";
1725 print '</div>';
1726 }
1727 } else {
1729 }
1730 }
1731
1732 // Allow external modules to add their own shortlist of recent objects
1733 $parameters = array();
1734 $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action);
1735 if ($reshook < 0) {
1736 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1737 } else {
1738 print $hookmanager->resPrint;
1739 }
1740
1741 print '</div></div>';
1742 print '<div class="clearboth"></div>';
1743
1744 print dol_get_fiche_end();
1745
1746
1747 /*
1748 * Action bar
1749 */
1750 print '<div class="tabsAction">';
1751
1752 $parameters = array();
1753 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1754
1755 if (empty($reshook)) {
1756 if ($object->status != 1) {
1757 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
1758 }
1759
1760 if (isModEnabled("propal") && $user->hasRight('propal', 'creer') && $object->status == 1) {
1761 $langs->load("propal");
1762 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>';
1763 }
1764
1765 if (isModEnabled('order') && $user->hasRight('commande', 'creer') && $object->status == 1) {
1766 $langs->load("orders");
1767 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>';
1768 }
1769
1770 if ($user->hasRight('contrat', 'creer') && $object->status == 1) {
1771 $langs->load("contracts");
1772 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>';
1773 }
1774
1775 if (isModEnabled('intervention') && $user->hasRight('ficheinter', 'creer') && $object->status == 1) {
1776 $langs->load("interventions");
1777 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>';
1778 }
1779
1780 if (isModEnabled('invoice') && $object->status == 1) {
1781 if (!$user->hasRight('facture', 'creer')) {
1782 $langs->load("bills");
1783 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1784 } else {
1785 $langs->loadLangs(array("orders", "bills"));
1786
1787 if ($object->client != 0 && $object->client != 2) {
1788 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>';
1789 } else {
1790 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1791 }
1792 }
1793 }
1794
1795 if (isModEnabled('invoice') && $object->status == 1) {
1796 if ($user->hasRight('facture', 'creer')) {
1797 if (isModEnabled('order')) {
1798 if ($object->client != 0 && $object->client != 2) {
1799 if (!empty($orders2invoice) && $orders2invoice > 0) {
1800 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>';
1801 } else {
1802 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
1803 }
1804 } else {
1805 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
1806 }
1807 }
1808 }
1809 }
1810
1811 // Add action
1812 if (isModEnabled('agenda') && getDolGlobalString('MAIN_REPEATTASKONEACHTAB') && $object->status == 1) {
1813 if ($user->hasRight('agenda', 'myactions', 'create')) {
1814 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>';
1815 } else {
1816 print '<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a></div>';
1817 }
1818 }
1819 }
1820
1821 print '</div>';
1822
1823 if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD')) {
1824 // List of contacts
1825 show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
1826 }
1827
1828 if (getDolGlobalString('MAIN_REPEATTASKONEACHTAB')) {
1829 print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
1830
1831 // List of todo actions
1832 show_actions_todo($conf, $langs, $db, $object);
1833
1834 // List of done actions
1835 show_actions_done($conf, $langs, $db, $object);
1836 }
1837} else {
1838 recordNotFound('', 0);
1839}
1840
1841// End of page
1842llxFooter();
1843$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 invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
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, $subtabs='')
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
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.
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.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
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...
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.