dolibarr 25.0.0-alpha
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>';
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>';
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->transnoentitiesnoconv("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->transnoentitiesnoconv("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('popupoutstandinglate', $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 {
1031 dol_print_error($db);
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 {
1152 dol_print_error($db);
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 {
1262 dol_print_error($db);
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.fk_contract_type = 0";
1276 $sql .= " AND c.entity IN (".getEntity('contract').")";
1277 $sql .= " ORDER BY c.datec DESC";
1278
1279 $resql = $db->query($sql);
1280 if ($resql) {
1281 $contrat = new Contrat($db);
1282
1283 $num = $db->num_rows($resql);
1284 if ($num > 0) {
1285 print '<div class="div-table-responsive-no-min">';
1286 print '<table class="noborder centpercent lastrecordtable">';
1287
1288 print '<tr class="liste_titre">';
1289 print '<td colspan="6"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
1290 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>';
1291 //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>';
1292 print '</tr></table></td>';
1293 print '</tr>';
1294 }
1295
1296 $i = 0;
1297 while ($i < $num && $i < $MAXLIST) {
1298 $objp = $db->fetch_object($resql);
1299
1300 $contrat->id = $objp->id;
1301 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1302 $contrat->ref_customer = $objp->refcus;
1303 $contrat->ref_supplier = $objp->refsup;
1304 $contrat->fk_project = $objp->fk_projet;
1305 $contrat->statut = $objp->contract_status; // deprecated
1306 $contrat->status = $objp->contract_status;
1307 $contrat->last_main_doc = $objp->last_main_doc;
1308 $contrat->model_pdf = $objp->model_pdf;
1309 $contrat->fetch_lines();
1310
1311 $late = '';
1312 foreach ($contrat->lines as $line) {
1313 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1314 if (((!empty($line->date_end) ? $line->date_end : 0) + getWarningDelay('contract', 'service', 'expires')) < $now) {
1315 $late = img_warning($langs->trans("Late"));
1316 }
1317 }
1318 }
1319
1320 print '<tr class="oddeven">';
1321 print '<td class="nowraponall">';
1322 print $contrat->getNomUrl(1, 12);
1323 if (!empty($contrat->model_pdf)) {
1324 // Preview
1325 $filedir = $conf->contract->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1326 $file_list = null;
1327 if (!empty($filedir)) {
1328 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1329 }
1330 if (is_array($file_list) && !empty($file_list)) {
1331 // Defined relative dir to DOL_DATA_ROOT
1332 $relativedir = '';
1333 if ($filedir) {
1334 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1335 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1336 }
1337 // Get list of files stored into database for same relative directory
1338 if ($relativedir) {
1339 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1340 '@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';
1341
1342 //var_dump($sortfield.' - '.$sortorder);
1343 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)
1344 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1345 }
1346 }
1347 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1348 print $formfile->showPreview($file_list[0], $contrat->element, $relativepath, 0, 'entity=' . $objp->entity);
1349 }
1350 }
1351 // $filename = dol_sanitizeFileName($objp->ref);
1352 // $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1353 // $urlsource = '/contrat/card.php?id='.$objp->cid;
1354 // print $formfile->getDocumentsLink($contrat->element, $filename, $filedir);
1355 print $late;
1356 print '</td><td class="tdoverflowmax125">';
1357 if ($contrat->fk_project > 0) {
1358 $project->fetch($contrat->fk_project);
1359 print $project->getNomUrl(1);
1360 }
1361 print "</td>\n";
1362 print '<td class="nowrap">';
1363 print dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1364 print "</td>\n";
1365 //print '<td class="right" width="80px"><span title="'.$langs->trans("DateCreation").'">'.dol_print_date($db->jdate($objp->dc), 'day')."</span></td>\n";
1366 print '<td class="right" width="80px"><span title="'.$langs->trans("DateContract").'">'.dol_print_date($db->jdate($objp->dcon), 'day')."</span></td>\n";
1367 print '<td width="20">&nbsp;</td>';
1368 print '<td class="nowraponall right">';
1369 print $contrat->getLibStatut(4);
1370 print "</td>\n";
1371 print '</tr>';
1372 $i++;
1373 }
1374 $db->free($resql);
1375
1376 if ($num > 0) {
1377 print "</table>";
1378 print '</div>';
1379 }
1380 } else {
1381 dol_print_error($db);
1382 }
1383 }
1384
1385 /*
1386 * Latest interventions
1387 */
1388 if (isModEnabled('intervention') && $user->hasRight('ficheinter', 'lire')) {
1389 $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";
1390 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
1391 $sql .= " WHERE f.fk_soc = s.rowid";
1392 $sql .= " AND s.rowid = ".((int) $object->id);
1393 $sql .= " AND f.entity IN (".getEntity('intervention').")";
1394 $sql .= " ORDER BY f.tms DESC";
1395
1396 $resql = $db->query($sql);
1397 if ($resql) {
1398 $fichinter_static = new Fichinter($db);
1399
1400 $num = $db->num_rows($resql);
1401 if ($num > 0) {
1402 print '<div class="div-table-responsive-no-min">';
1403 print '<table class="noborder centpercent lastrecordtable">';
1404
1405 print '<tr class="liste_titre">';
1406 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>';
1407 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>';
1408 print '</tr></table></td>';
1409 print '</tr>';
1410 }
1411
1412 $i = 0;
1413 while ($i < $num && $i < $MAXLIST) {
1414 $objp = $db->fetch_object($resql);
1415
1416 $fichinter_static->id = $objp->id;
1417 $fichinter_static->ref = $objp->ref;
1418 $fichinter_static->statut = $objp->fk_statut; // deprecated
1419 $fichinter_static->status = $objp->fk_statut;
1420 $fichinter_static->fk_project = $objp->fk_projet;
1421
1422 print '<tr class="oddeven">';
1423 print '<td class="nowraponall">';
1424 print $fichinter_static->getNomUrl(1);
1425 // Preview
1426 $filedir = $conf->ficheinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1427 $file_list = null;
1428 if (!empty($filedir)) {
1429 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1430 }
1431 if (is_array($file_list) && !empty($file_list)) {
1432 // Defined relative dir to DOL_DATA_ROOT
1433 $relativedir = '';
1434 if ($filedir) {
1435 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1436 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1437 }
1438 // Get list of files stored into database for same relative directory
1439 if ($relativedir) {
1440 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1441 '@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';
1442
1443 //var_dump($sortfield.' - '.$sortorder);
1444 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)
1445 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1446 }
1447 }
1448 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1449 print $formfile->showPreview($file_list[0], $fichinter_static->element, $relativepath, 0, 'entity=' . $objp->entity);
1450 }
1451 print '</td><td class="tdoverflowmax125">';
1452 if ($fichinter_static->fk_project > 0) {
1453 $project->fetch($fichinter_static->fk_project);
1454 print $project->getNomUrl(1);
1455 }
1456 // $filename = dol_sanitizeFileName($objp->ref);
1457 // $filedir = getMultidirOutput($fichinter_static).'/'.dol_sanitizeFileName($objp->ref);
1458 // $urlsource = '/fichinter/card.php?id='.$objp->cid;
1459 // print $formfile->getDocumentsLink($fichinter_static->element, $filename, $filedir);
1460 print '</td>'."\n";
1461 //print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
1462 print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
1463 print '<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n";
1464 print '</tr>';
1465
1466 $i++;
1467 }
1468 $db->free($resql);
1469
1470 if ($num > 0) {
1471 print "</table>";
1472 print '</div>';
1473 }
1474 } else {
1475 dol_print_error($db);
1476 }
1477 }
1478
1479 /*
1480 * Latest invoices templates
1481 */
1482 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
1483 $sql = 'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1484 $sql .= ', f.total_ht';
1485 $sql .= ', f.total_tva';
1486 $sql .= ', f.total_ttc';
1487 $sql .= ', f.datec as dc';
1488 $sql .= ', f.date_last_gen, f.date_when';
1489 $sql .= ', f.frequency';
1490 $sql .= ', f.unit_frequency';
1491 $sql .= ', f.suspended as suspended';
1492 $sql .= ', s.nom, s.rowid as socid';
1493 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
1494 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1495 $sql .= " AND f.entity IN (".getEntity('invoice').")";
1496 $sql .= ' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1497 $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1498 $sql .= ' f.suspended, f.date_when,';
1499 $sql .= ' s.nom, s.rowid';
1500 $sql .= " ORDER BY f.date_last_gen, f.datec DESC";
1501
1502 $resql = $db->query($sql);
1503 if ($resql) {
1504 $invoicetemplate = new FactureRec($db);
1505
1506 $num = $db->num_rows($resql);
1507 if ($num > 0) {
1508 print '<div class="div-table-responsive-no-min">';
1509 print '<table class="noborder centpercent lastrecordtable">';
1510 print '<tr class="liste_titre">';
1511 $colspan = 5;
1512 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1513 $colspan++;
1514 }
1515 print '<td colspan="'.$colspan.'">';
1516 print '<table class="centpercent nobordernopadding"><tr>';
1517 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>';
1518 print '</tr></table>';
1519 print '</td>';
1520 print '</tr>';
1521 }
1522
1523 $i = 0;
1524 while ($i < $num && $i < $MAXLIST) {
1525 $objp = $db->fetch_object($resql);
1526
1527 $invoicetemplate->id = $objp->id;
1528 $invoicetemplate->ref = $objp->ref;
1529 $invoicetemplate->fk_project = $objp->fk_projet;
1530 $invoicetemplate->suspended = $objp->suspended;
1531 $invoicetemplate->frequency = $objp->frequency;
1532 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1533 $invoicetemplate->total_ht = $objp->total_ht;
1534 $invoicetemplate->total_tva = $objp->total_tva;
1535 $invoicetemplate->total_ttc = $objp->total_ttc;
1536 $invoicetemplate->date_last_gen = $db->jdate($objp->date_last_gen);
1537 $invoicetemplate->date_when = $db->jdate($objp->date_when);
1538
1539 print '<tr class="oddeven">';
1540 print '<td class="tdoverflowmax250">';
1541 print $invoicetemplate->getNomUrl(1);
1542 print '</td><td class="tdoverflowmax125">';
1543 if ($invoicetemplate->fk_project > 0) {
1544 $project->fetch($invoicetemplate->fk_project);
1545 print $project->getNomUrl(1);
1546 }
1547 print '</td>';
1548
1549 if ($objp->frequency && $objp->date_last_gen > 0) {
1550 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
1551 } else {
1552 if ($objp->dc > 0) {
1553 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day').'</td>';
1554 } else {
1555 print '<td class="right"><b>!!!</b></td>';
1556 }
1557 }
1558 print '<td class="right nowraponall">';
1559 print price($objp->total_ht);
1560 print '</td>';
1561
1562 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1563 print '<td class="right nowraponall">';
1564 print price($objp->total_ttc);
1565 print '</td>';
1566 }
1567
1568 print '<td class="nowrap right" style="min-width: 60px">';
1569 print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - ';
1570 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1571 print '</td>';
1572 print "</tr>\n";
1573 $i++;
1574 }
1575 $db->free($resql);
1576
1577 if ($num > 0) {
1578 print "</table>";
1579 print '</div>';
1580 }
1581 } else {
1582 dol_print_error($db);
1583 }
1584 }
1585
1586 /*
1587 * Latest invoices
1588 */
1589 if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
1590 $sql = 'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1591 $sql .= ', f.total_ht';
1592 $sql .= ', f.total_tva';
1593 $sql .= ', f.total_ttc';
1594 $sql .= ', f.entity';
1595 $sql .= ', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status, f.dispute_status';
1596 $sql .= ', s.nom, s.rowid as socid';
1597 $sql .= ', SUM(pf.amount) as am';
1598 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
1599 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
1600 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1601 $sql .= " AND f.entity IN (".getEntity('invoice').")";
1602 $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1603 $sql .= ' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1604 $sql .= ' s.nom, s.rowid';
1605 $sql .= " ORDER BY f.datef DESC, f.datec DESC";
1606
1607 $resql = $db->query($sql);
1608 if ($resql) {
1609 $facturestatic = new Facture($db);
1610
1611 $num = $db->num_rows($resql);
1612 if ($num > 0) {
1613 print '<div class="div-table-responsive-no-min">';
1614 print '<table class="noborder centpercent lastrecordtable">';
1615 print '<tr class="liste_titre">';
1616 $colspan = 6;
1617 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1618 $colspan++;
1619 }
1620 if (getDolGlobalString('MAIN_SHOW_REF_CUSTOMER_INVOICES')) {
1621 $colspan++;
1622 }
1623 print '<td colspan="'.$colspan.'">';
1624 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>';
1625 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>';
1626 print '</tr></table>';
1627 print '</td>';
1628 print '</tr>';
1629 }
1630
1631 $i = 0;
1632 while ($i < $num && $i < $MAXLIST) {
1633 $objp = $db->fetch_object($resql);
1634
1635 $facturestatic->id = $objp->facid;
1636 $facturestatic->ref = $objp->ref;
1637 $facturestatic->ref_client = $objp->ref_client;
1638 $facturestatic->fk_project = $objp->fk_projet;
1639 $facturestatic->type = $objp->type;
1640 $facturestatic->total_ht = $objp->total_ht;
1641 $facturestatic->total_tva = $objp->total_tva;
1642 $facturestatic->total_ttc = $objp->total_ttc;
1643 $facturestatic->statut = $objp->status; // deprecated
1644 $facturestatic->status = $objp->status;
1645 $facturestatic->dispute_status = $objp->dispute_status;
1646 $facturestatic->paye = $objp->paye;
1647
1648 $facturestatic->alreadypaid = $objp->am;
1649 $facturestatic->totalpaid = $objp->am;
1650
1651 $facturestatic->date = $db->jdate($objp->df);
1652 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1653
1654 print '<tr class="oddeven">';
1655 print '<td class="nowraponall">';
1656 print $facturestatic->getNomUrl(1);
1657 // Preview
1658 $filedir = $conf->invoice->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1659 $file_list = null;
1660 if (!empty($filedir)) {
1661 $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
1662 }
1663 if (is_array($file_list) && !empty($file_list)) {
1664 // Defined relative dir to DOL_DATA_ROOT
1665 $relativedir = '';
1666 if ($filedir) {
1667 $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
1668 $relativedir = preg_replace('/^[\\/]/', '', $relativedir);
1669 }
1670 // Get list of files stored into database for same relative directory
1671 if ($relativedir) {
1672 completeFileArrayWithDatabaseInfo($file_list, $relativedir);
1673 '@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';
1674
1675 //var_dump($sortfield.' - '.$sortorder);
1676 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)
1677 $file_list = dol_sort_array($file_list, $sortfield, $sortorder);
1678 }
1679 }
1680 $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
1681 print $formfile->showPreview($file_list[0], $facturestatic->element, $relativepath, 0, 'entity=' . $objp->entity);
1682 }
1683 print '</td><td class="tdoverflowmax125">';
1684 if ($facturestatic->fk_project > 0) {
1685 $project->fetch($facturestatic->fk_project);
1686 print $project->getNomUrl(1);
1687 }
1688 // $filename = dol_sanitizeFileName($objp->ref);
1689 // $filedir = $conf->facture->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
1690 // $urlsource = '/compta/facture/card.php?id='.$objp->cid;
1691 //print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
1692 print '</td>';
1693 if (getDolGlobalString('MAIN_SHOW_REF_CUSTOMER_INVOICES')) {
1694 print '<td class="nowraponall">';
1695 print dolPrintHTML($objp->ref_client);
1696 print '</td>';
1697 }
1698 if ($objp->df > 0) {
1699 print '<td width="80px" title="'.dol_escape_htmltag($langs->trans('DateInvoice')).'">'.dol_print_date($db->jdate($objp->df), 'day').'</td>';
1700 } else {
1701 print '<td><b>!!!</b></td>';
1702 }
1703 if ($objp->dl > 0) {
1704 print '<td width="80px" title="'.dol_escape_htmltag($langs->trans('DateMaxPayment')).'">'.dol_print_date($db->jdate($objp->dl), 'day').'</td>';
1705 } else {
1706 print '<td><b>!!!</b></td>';
1707 }
1708
1709 print '<td class="right nowraponall">';
1710 print price($objp->total_ht);
1711 print '</td>';
1712
1713 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
1714 print '<td class="right nowraponall">';
1715 print price($objp->total_ttc);
1716 print '</td>';
1717 }
1718
1719 print '<td class="nowrap right" style="min-width: 60px">'.$facturestatic->getLibStatut(5, $objp->am).'</td>';
1720 print "</tr>\n";
1721 $i++;
1722 }
1723 $db->free($resql);
1724
1725 if ($num > 0) {
1726 print "</table>";
1727 print '</div>';
1728 }
1729 } else {
1730 dol_print_error($db);
1731 }
1732 }
1733
1734 // Allow external modules to add their own shortlist of recent objects
1735 $parameters = array();
1736 $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action);
1737 if ($reshook < 0) {
1738 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1739 } else {
1740 print $hookmanager->resPrint;
1741 }
1742
1743 print '</div></div>';
1744 print '<div class="clearboth"></div>';
1745
1746 print dol_get_fiche_end();
1747
1748
1749 /*
1750 * Action bar
1751 */
1752 print '<div class="tabsAction">';
1753
1754 $parameters = array();
1755 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1756
1757 if (empty($reshook)) {
1758 if (isModEnabled("propal") && $user->hasRight('propal', 'creer')) {
1759 $langs->load("propal");
1760 if ($object->status == 1) {
1761 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>';
1762 } else {
1763 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddProp").'</a></div>';
1764 }
1765 }
1766
1767 if (isModEnabled('order') && $user->hasRight('commande', 'creer')) {
1768 $langs->load("orders");
1769 if ($object->status == 1) {
1770 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>';
1771 } else {
1772 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddOrder").'</a></div>';
1773 }
1774 }
1775
1776 if (isModEnabled('contract') && $user->hasRight('contrat', 'creer')) {
1777 $langs->load("contracts");
1778 if ($object->status == 1) {
1779 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>';
1780 } else {
1781 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddContract").'</a></div>';
1782 }
1783 }
1784
1785 if (isModEnabled('intervention') && $user->hasRight('ficheinter', 'creer')) {
1786 $langs->load("interventions");
1787 if ($object->status == 1) {
1788 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>';
1789 } else {
1790 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddIntervention").'</a></div>';
1791 }
1792 }
1793
1794 if (isModEnabled('invoice')) {
1795 if (!$user->hasRight('facture', 'creer')) {
1796 $langs->load("bills");
1797 if ($object->status == 1) {
1798 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1799 } else {
1800 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1801 }
1802 } else {
1803 $langs->loadLangs(array("orders", "bills"));
1804
1805 if ($object->client != 0 && $object->client != 2) {
1806 if ($object->status == 1) {
1807 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>';
1808 } else {
1809 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1810 }
1811 } else {
1812 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
1813 }
1814 }
1815 }
1816
1817 if (isModEnabled('invoice') && $user->hasRight('facture', 'creer')) {
1818 if (isModEnabled('order') && $object->status == 1) {
1819 if ($object->client != 0 && $object->client != 2) {
1820 if (!empty($orders2invoice) && $orders2invoice > 0) {
1821 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>';
1822 } else {
1823 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
1824 }
1825 } else {
1826 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
1827 }
1828 }
1829 }
1830
1831 // Add action
1832 if (isModEnabled('agenda') && getDolGlobalString('MAIN_REPEATTASKONEACHTAB') && $object->status == 1) {
1833 if ($user->hasRight('agenda', 'myactions', 'create')) {
1834 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>';
1835 } else {
1836 print '<div class="inline-block divButAction"><a class="butAction" title="'.dolPrintHTMLForAttribute($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a></div>';
1837 }
1838 }
1839 }
1840
1841 print '</div>';
1842
1843 if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD')) {
1844 // List of contacts
1845 show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
1846 }
1847
1848 if (getDolGlobalString('MAIN_REPEATTASKONEACHTAB')) {
1849 print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
1850
1851 // List of todo actions
1852 show_actions_todo($conf, $langs, $db, $object);
1853
1854 // List of done actions
1855 show_actions_done($conf, $langs, $db, $object);
1856 }
1857} else {
1858 recordNotFound('', 0);
1859}
1860
1861// End of page
1862llxFooter();
1863$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:
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:65
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
Definition html.lib.php:540
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.
Definition html.lib.php:435
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:181
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.