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';
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';
61 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
70 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
73 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
76 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
79 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
80 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
84$langs->loadLangs(array(
'companies',
'banks',
'commercial'));
87 $langs->load(
"contracts");
90 $langs->load(
"orders");
93 $langs->load(
"sendings");
96 $langs->load(
"bills");
99 $langs->load(
"projects");
102 $langs->load(
"interventions");
105 $langs->load(
"mails");
108$action =
GETPOST(
'action',
'aZ09');
113$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
114$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
116if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
120$offset = $limit * $page;
121$pageprev = $page - 1;
122$pagenext = $page + 1;
129$cancel =
GETPOST(
'cancel',
'alpha');
135$extrafields->fetch_name_optionals_label(
$object->table_element);
138$hookmanager->initHooks(array(
'thirdpartycomm',
'globalcard'));
142if ($id > 0 && empty(
$object->id)) {
150 if (!(
$object->client > 0) || !$user->hasRight(
'societe',
'lire')) {
156if ($user->socid > 0) {
161$permissiontoadd = $user->hasRight(
'societe',
'creer');
162$permissiontoeditextra = $permissiontoadd;
163if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
165 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
174$parameters = array(
'id' => $id,
'socid' => $id);
175$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
177 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
180if (empty($reshook)) {
186 if ($action ==
'setcustomeraccountancycodegeneral' && $permissiontoadd) {
188 $object->accountancy_code_customer_general =
GETPOST(
"customeraccountancycodegeneral");
196 if ($action ==
'setcustomeraccountancycode' && $permissiontoadd) {
203 $action =
'editcustomeraccountancycode';
208 if ($action ==
'setconditions' && $permissiontoadd) {
217 if ($action ==
'setmode' && $permissiontoadd) {
226 if ($action ==
'settransportmode' && $permissiontoadd) {
235 if ($action ==
'setbankaccount' && $permissiontoadd) {
244 if ($action ==
'setshippingmethod' && $permissiontoadd) {
253 if ($action ==
'setassujtva' && $permissiontoadd) {
263 if ($action ==
'setprospectlevel' && $permissiontoadd) {
265 $object->fk_prospectlevel =
GETPOST(
'prospect_level_id',
'alpha');
273 if ($action ==
'setstcomm' && $permissiontoadd) {
285 if ($action ==
'setoutstanding_limit' && $permissiontoadd) {
295 if ($action ==
'setorder_min_amount' && $permissiontoadd) {
305 if ($action ==
'set_salesrepresentatives' && $permissiontoadd) {
310 if ($action ==
'update_extras' && $permissiontoeditextra) {
315 $attribute_name =
GETPOST(
'attribute',
'aZ09');
318 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
324 $result =
$object->updateExtraField($attribute_name,
'COMPANY_MODIFY');
332 $action =
'edit_extras';
337 if ($action ==
'setwarehouse' && $permissiontoadd) {
347$contactstatic =
new Contact($db);
348$userstatic =
new User($db);
349$form =
new Form($db);
353$title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Customer');
355 $title =
$object->name.
" - ".$langs->trans(
'Customer');
358$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
365 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), -1,
'company');
367 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
369 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
371 print
'<div class="fichecenter"><div class="fichehalfleft">';
373 print
'<div class="underbanner clearboth"></div>';
374 print
'<table class="border centpercent tableforfield">';
377 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
382 $langs->loadLangs(array(
"compta",
"accountancy"));
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>';
398 print $form->editfieldkey(
"CustomerAccountancyCodeGeneral",
'customeraccountancycodegeneral',
length_accountg(
$object->accountancy_code_customer_general), $object, $permissiontoadd);
400 if ($action ==
'editcustomeraccountancycodegeneral' && $permissiontoadd) {
401 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_customer_general,
'customeraccountancycodegeneral', 0, 1,
'', 1);
403 if (
$object->accountancy_code_customer_general > 0) {
405 $accountingaccount->fetch(0,
$object->accountancy_code_customer_general, 1);
407 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
410 if (
$object->accountancy_code_customer_general > 0) {
413 $accountingAccountByDefault =
'<span class="opacitymedium">' . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')) .
'</span>';
414 print $accountingAccountByDefault;
423 print $form->editfieldkey(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client, $object, $permissiontoadd);
425 print $form->editfieldval(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client, $object, $permissiontoadd);
445 if (
$mysoc->country_code ==
'ES') {
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);
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);
460 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
465 $langs->load(
'bills');
467 print
'<table width="100%" class="nobordernopadding"><tr><td>';
468 print $langs->trans(
'PaymentConditions');
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>';
473 print
'</tr></table>';
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);
478 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 0,
'', 1,
$object->deposit_percent);
484 print
'<tr><td class="nowrap">';
485 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
486 print $langs->trans(
'PaymentMode');
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>';
491 print
'</tr></table>';
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);
496 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
503 print
'<tr><td class="nowrap">';
504 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
505 print $langs->trans(
'PaymentBankAccount');
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>';
510 print
'</tr></table>';
512 if ($action ==
'editbankaccount') {
513 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
515 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'none');
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>';
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>';
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>';
545 print
'</td></tr></table>';
548 $amount_discount =
$object->getAvailableDiscounts();
549 if ($amount_discount < 0) {
550 dol_print_error($db,
$object->error);
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>';
560 $limit_field_type =
'';
563 print
'<tr class="nowrap">';
565 print $form->editfieldkey(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit, $object, $permissiontoadd);
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) :
''));
576 print
'<!-- Minimum amount for orders -->'.
"\n";
577 print
'<tr class="nowrap">';
579 print $form->editfieldkey(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount, $object, $permissiontoadd);
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) :
''));
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>';
597 print
'</td></tr></table>';
600 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
610 $langs->load(
'stocks');
611 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
613 print
'<tr class="nowrap">';
615 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $permissiontoadd);
617 if ($action ==
'editwarehouse') {
618 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
int)
$object->fk_warehouse,
'fk_warehouse', 1);
620 if (
$object->fk_warehouse > 0) {
621 print img_picto(
'',
'stock',
'class="paddingrightonly"');
623 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
int)
$object->fk_warehouse,
'none');
631 print
'<tr><td class="nowrap">';
632 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
633 print $langs->trans(
'SendingMethod');
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>';
638 print
'</tr></table>';
640 if ($action ==
'editshipping') {
641 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
643 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->shipping_method_id,
'none');
650 $langs->load(
"intracommreport");
653 print
'<tr><td class="nowrap">';
654 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
655 print $langs->trans(
'IntracommReportTransportMode');
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>';
660 print
'</tr></table>';
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);
665 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'none');
672 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
673 $langs->load(
"categories");
674 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
676 print $form->showCategories(
$object->id, Categorie::TYPE_CUSTOMER, 1);
681 $parameters = array(
'socid' =>
$object->id);
682 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
685 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
689 $langs->load(
"members");
690 $langs->load(
"users");
692 print
'<tr><td class="titlefield">'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
695 $result = $adh->fetch(0,
'',
$object->id);
697 $adh->ref = $adh->getFullName($langs);
698 print $adh->getNomUrl(-1);
700 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
708 print
'</div><div class="fichehalfright">';
712 print
'<div class="underbanner clearboth"></div>';
713 print
'<table class="border centpercent tableforfield">';
716 print
'<tr><td class="titlefield nowrap">';
717 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
718 print $langs->trans(
'ProspectLevel');
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>';
723 print
'</tr></table>';
725 if ($action ==
'editlevel') {
726 $formcompany->form_prospect_level($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
int)
$object->fk_prospectlevel,
'prospect_level_id', 1);
728 print
$object->getLibProspLevel();
734 $object->loadCacheOfProspStatus();
735 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.
$object->getLibProspCommStatut(4,
$object->cacheprospectstatus[
$object->stcomm_id][
'label']);
736 print
' ';
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'];
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>';
747 print
'</div></td></tr>';
752 print
'<div class="underbanner underbanner-before-box clearboth"></div><br>';
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">';
765 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
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;
775 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
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>';
786 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
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;
796 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
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>';
807 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
809 $tmp =
$object->getOutstandingBills(
'customer', 0);
810 $outstandingOpened = $tmp[
'opened'];
811 $outstandingTotal = $tmp[
'total_ht'];
812 $outstandingTotalIncTax = $tmp[
'total_ttc'];
814 $text = $langs->trans(
"OverAllInvoices");
815 $link = DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->id;
818 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
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>';
830 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpened) {
831 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
833 $text = $langs->transnoentitiesnoconv(
"CurrentOutstandingBill");
835 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
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>';
844 $boxstat .= $boxstattmp;
847 $tmp =
$object->getOutstandingBills(
'customer', 1);
848 $outstandingOpenedLate = $tmp[
'opened'];
849 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
851 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpenedLate) {
852 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
854 $text = $langs->transnoentitiesnoconv(
"CurrentOutstandingBillLate");
856 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
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>';
865 $boxstat .= $boxstattmp;
871 if (
isModEnabled(
'margin') && $user->hasRight(
'margin',
'liretous')) {
874 $sql .=
" sum(d.total_ht) as selling_price,";
875 $sql .=
" sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,";
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";
887 $sql .=
" AND d.buy_price_ht <> 0";
892 $resql = $db->query($sql);
894 $obj = $db->fetch_object($resql);
896 $marginTotal = $obj->marge;
900 $text = $langs->transnoentitiesnoconv(
"Margins");
902 $link = DOL_URL_ROOT.
'/margin/tabs/thirdpartyMargins.php?socid='.
$object->id;
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>';
911 $boxstat .= $boxstattmp;
916 $parameters = array();
917 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', $parameters, $object, $action);
918 if (empty($reshook)) {
919 $boxstat .= $hookmanager->resPrint;
922 $boxstat .=
'</td></tr>';
923 $boxstat .=
'</table>';
924 $boxstat .=
'</div>';
933 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
934 $propal_static =
new Propal($db);
935 $langs->load(
"propal");
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);
948 $sql .= $hookmanager->resPrint;
949 $sql .=
" ORDER BY p.datep DESC";
951 $resql = $db->query($sql);
953 $num = $db->num_rows($resql);
955 print
'<div class="div-table-responsive-no-min">';
956 print
'<table class="noborder centpercent lastrecordtable">';
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>';
966 while ($i < $num && $i < $MAXLIST) {
967 $objp = $db->fetch_object($resql);
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;
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);
984 if (!empty($filedir)) {
987 if (is_array($file_list) && !empty($file_list)) {
991 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
992 $relativedir = preg_replace(
'/^[\\/]/',
'', $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';
1000 if (!empty($sortfield) && !empty($sortorder)) {
1005 print $formfile->showPreview($file_list[0], $propal_static->element, $relativepath, 0,
'entity=' . $objp->entity);
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);
1016 if (($db->jdate($objp->date_limit) < ($now -
getWarningDelay(
'propal',
'cloture'))) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
1017 print
" ".img_warning();
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>';
1031 dol_print_error($db);
1035 $orders2invoice =
null;
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);
1056 $sql .= $hookmanager->resPrint;
1057 $sql .=
" ORDER BY c.date_commande DESC";
1059 $resql = $db->query($sql);
1061 $num = $db->num_rows($resql);
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);
1071 $sql2 .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
1073 $resql2 = $db->query($sql2);
1074 $orders2invoice = $db->num_rows($resql2);
1077 print
'<div class="div-table-responsive-no-min">';
1078 print
'<table class="noborder centpercent lastrecordtable">';
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>';
1088 while ($i < $num && $i < $MAXLIST) {
1089 $objp = $db->fetch_object($resql);
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;
1100 print
'<tr class="oddeven">';
1101 print
'<td class="nowraponall">';
1102 print $commande_static->getNomUrl(1);
1106 if (!empty($filedir)) {
1109 if (is_array($file_list) && !empty($file_list)) {
1113 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1114 $relativedir = preg_replace(
'/^[\\/]/',
'', $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';
1122 if (!empty($sortfield) && !empty($sortorder)) {
1127 print $formfile->showPreview($file_list[0], $commande_static->element, $relativepath, 0,
'entity=' . $objp->entity);
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);
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>';
1152 dol_print_error($db);
1159 if (
isModEnabled(
"shipping") && $user->hasRight(
'expedition',
'lire')) {
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';
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';
1176 $sql .=
', s.rowid';
1177 $sql .=
" ORDER BY e.date_creation DESC";
1179 $resql = $db->query($sql);
1183 $num = $db->num_rows($resql);
1185 print
'<div class="div-table-responsive-no-min">';
1186 print
'<table class="noborder centpercent lastrecordtable">';
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>';
1196 while ($i < $num && $i < $MAXLIST) {
1197 $objp = $db->fetch_object($resql);
1199 $param =
'entity=' . ((int) $objp->entity);
1201 $sendingstatic->id = $objp->id;
1202 $sendingstatic->ref = $objp->ref;
1203 $sendingstatic->fk_project = $objp->fk_projet;
1205 print
'<tr class="oddeven">';
1206 print
'<td class="nowraponall">';
1207 print $sendingstatic->getNomUrl(1);
1211 if (!empty($filedir)) {
1214 if (is_array($file_list) && !empty($file_list)) {
1218 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1219 $relativedir = preg_replace(
'/^[\\/]/',
'', $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';
1227 if (!empty($sortfield) && !empty($sortorder)) {
1233 print $formfile->showPreview($file_list[0], $sendingstatic->element, $relativepath, 0, $param);
1235 print
'</td><td class="tdoverflowmax125">';
1236 if ($sendingstatic->fk_project > 0) {
1237 $project->fetch($sendingstatic->fk_project);
1238 print $project->getNomUrl(1);
1245 if ($objp->date_creation > 0) {
1246 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
1248 print
'<td class="right"><b>!!!</b></td>';
1251 print
'<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
1262 dol_print_error($db);
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";
1279 $resql = $db->query($sql);
1283 $num = $db->num_rows($resql);
1285 print
'<div class="div-table-responsive-no-min">';
1286 print
'<table class="noborder centpercent lastrecordtable">';
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>';
1292 print
'</tr></table></td>';
1297 while ($i < $num && $i < $MAXLIST) {
1298 $objp = $db->fetch_object($resql);
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;
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();
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"));
1320 print
'<tr class="oddeven">';
1321 print
'<td class="nowraponall">';
1322 print $contrat->getNomUrl(1, 12);
1323 if (!empty($contrat->model_pdf)) {
1327 if (!empty($filedir)) {
1330 if (is_array($file_list) && !empty($file_list)) {
1334 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1335 $relativedir = preg_replace(
'/^[\\/]/',
'', $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';
1343 if (!empty($sortfield) && !empty($sortorder)) {
1348 print $formfile->showPreview($file_list[0], $contrat->element, $relativepath, 0,
'entity=' . $objp->entity);
1356 print
'</td><td class="tdoverflowmax125">';
1357 if ($contrat->fk_project > 0) {
1358 $project->fetch($contrat->fk_project);
1359 print $project->getNomUrl(1);
1362 print
'<td class="nowrap">';
1363 print
dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
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"> </td>';
1368 print
'<td class="nowraponall right">';
1369 print $contrat->getLibStatut(4);
1381 dol_print_error($db);
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";
1396 $resql = $db->query($sql);
1400 $num = $db->num_rows($resql);
1402 print
'<div class="div-table-responsive-no-min">';
1403 print
'<table class="noborder centpercent lastrecordtable">';
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>';
1413 while ($i < $num && $i < $MAXLIST) {
1414 $objp = $db->fetch_object($resql);
1416 $fichinter_static->id = $objp->id;
1417 $fichinter_static->ref = $objp->ref;
1418 $fichinter_static->statut = $objp->fk_statut;
1419 $fichinter_static->status = $objp->fk_statut;
1420 $fichinter_static->fk_project = $objp->fk_projet;
1422 print
'<tr class="oddeven">';
1423 print
'<td class="nowraponall">';
1424 print $fichinter_static->getNomUrl(1);
1428 if (!empty($filedir)) {
1431 if (is_array($file_list) && !empty($file_list)) {
1435 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1436 $relativedir = preg_replace(
'/^[\\/]/',
'', $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';
1444 if (!empty($sortfield) && !empty($sortorder)) {
1449 print $formfile->showPreview($file_list[0], $fichinter_static->element, $relativepath, 0,
'entity=' . $objp->entity);
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);
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";
1475 dol_print_error($db);
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";
1502 $resql = $db->query($sql);
1506 $num = $db->num_rows($resql);
1508 print
'<div class="div-table-responsive-no-min">';
1509 print
'<table class="noborder centpercent lastrecordtable">';
1510 print
'<tr class="liste_titre">';
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>';
1524 while ($i < $num && $i < $MAXLIST) {
1525 $objp = $db->fetch_object($resql);
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);
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);
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>';
1552 if ($objp->dc > 0) {
1553 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
1555 print
'<td class="right"><b>!!!</b></td>';
1558 print
'<td class="right nowraponall">';
1559 print
price($objp->total_ht);
1563 print
'<td class="right nowraponall">';
1564 print
price($objp->total_ttc);
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));
1582 dol_print_error($db);
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";
1607 $resql = $db->query($sql);
1609 $facturestatic =
new Facture($db);
1611 $num = $db->num_rows($resql);
1613 print
'<div class="div-table-responsive-no-min">';
1614 print
'<table class="noborder centpercent lastrecordtable">';
1615 print
'<tr class="liste_titre">';
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>';
1632 while ($i < $num && $i < $MAXLIST) {
1633 $objp = $db->fetch_object($resql);
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;
1644 $facturestatic->status = $objp->status;
1645 $facturestatic->dispute_status = $objp->dispute_status;
1646 $facturestatic->paye = $objp->paye;
1648 $facturestatic->alreadypaid = $objp->am;
1649 $facturestatic->totalpaid = $objp->am;
1651 $facturestatic->date = $db->jdate($objp->df);
1652 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1654 print
'<tr class="oddeven">';
1655 print
'<td class="nowraponall">';
1656 print $facturestatic->getNomUrl(1);
1660 if (!empty($filedir)) {
1663 if (is_array($file_list) && !empty($file_list)) {
1667 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1668 $relativedir = preg_replace(
'/^[\\/]/',
'', $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';
1676 if (!empty($sortfield) && !empty($sortorder)) {
1681 print $formfile->showPreview($file_list[0], $facturestatic->element, $relativepath, 0,
'entity=' . $objp->entity);
1683 print
'</td><td class="tdoverflowmax125">';
1684 if ($facturestatic->fk_project > 0) {
1685 $project->fetch($facturestatic->fk_project);
1686 print $project->getNomUrl(1);
1694 print
'<td class="nowraponall">';
1695 print dolPrintHTML($objp->ref_client);
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>';
1701 print
'<td><b>!!!</b></td>';
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>';
1706 print
'<td><b>!!!</b></td>';
1709 print
'<td class="right nowraponall">';
1710 print
price($objp->total_ht);
1714 print
'<td class="right nowraponall">';
1715 print
price($objp->total_ttc);
1719 print
'<td class="nowrap right" style="min-width: 60px">'.$facturestatic->getLibStatut(5, $objp->am).
'</td>';
1730 dol_print_error($db);
1735 $parameters = array();
1736 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
1738 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1740 print $hookmanager->resPrint;
1743 print
'</div></div>';
1744 print
'<div class="clearboth"></div>';
1752 print
'<div class="tabsAction">';
1754 $parameters = array();
1755 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1757 if (empty($reshook)) {
1758 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer')) {
1759 $langs->load(
"propal");
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>';
1763 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddProp").
'</a></div>';
1767 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'creer')) {
1768 $langs->load(
"orders");
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>';
1772 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddOrder").
'</a></div>';
1776 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'creer')) {
1777 $langs->load(
"contracts");
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>';
1781 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddContract").
'</a></div>';
1785 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer')) {
1786 $langs->load(
"interventions");
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>';
1790 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddIntervention").
'</a></div>';
1795 if (!$user->hasRight(
'facture',
'creer')) {
1796 $langs->load(
"bills");
1798 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1800 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1803 $langs->loadLangs(array(
"orders",
"bills"));
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>';
1809 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1812 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1817 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
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>';
1823 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1826 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
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>';
1836 print
'<div class="inline-block divButAction"><a class="butAction" title="'.dolPrintHTMLForAttribute($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddAction").
'</a></div>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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 invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage invoice templates.
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.
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.
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.
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.
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)
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.