37require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
46require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
61 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
70 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
71 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');
136$extrafields->fetch_name_optionals_label(
$object->table_element);
139$hookmanager->initHooks(array(
'thirdpartycomm',
'globalcard'));
143if ($id > 0 && empty(
$object->id)) {
151 if (!(
$object->client > 0) || !$user->hasRight(
'societe',
'lire')) {
157if ($user->socid > 0) {
162$permissiontoadd = $user->hasRight(
'societe',
'creer');
163$permissiontoeditextra = $permissiontoadd;
164if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
166 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
175$parameters = array(
'id' => $id,
'socid' => $id);
176$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
181if (empty($reshook)) {
187 if ($action ==
'setcustomeraccountancycodegeneral' && $permissiontoadd) {
189 $object->accountancy_code_customer_general =
GETPOST(
"customeraccountancycodegeneral");
197 if ($action ==
'setcustomeraccountancycode' && $permissiontoadd) {
204 $action =
'editcustomeraccountancycode';
209 if ($action ==
'setconditions' && $permissiontoadd) {
218 if ($action ==
'setmode' && $permissiontoadd) {
227 if ($action ==
'settransportmode' && $permissiontoadd) {
236 if ($action ==
'setbankaccount' && $permissiontoadd) {
245 if ($action ==
'setshippingmethod' && $permissiontoadd) {
254 if ($action ==
'setassujtva' && $permissiontoadd) {
264 if ($action ==
'setprospectlevel' && $permissiontoadd) {
266 $object->fk_prospectlevel =
GETPOST(
'prospect_level_id',
'alpha');
274 if ($action ==
'setstcomm' && $permissiontoadd) {
286 if ($action ==
'setoutstanding_limit' && $permissiontoadd) {
296 if ($action ==
'setorder_min_amount' && $permissiontoadd) {
306 if ($action ==
'set_salesrepresentatives' && $permissiontoadd) {
311 if ($action ==
'update_extras' && $permissiontoeditextra) {
316 $attribute_name =
GETPOST(
'attribute',
'aZ09');
319 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
325 $result =
$object->updateExtraField($attribute_name,
'COMPANY_MODIFY');
333 $action =
'edit_extras';
338 if ($action ==
'setwarehouse' && $permissiontoadd) {
348$contactstatic =
new Contact($db);
349$userstatic =
new User($db);
350$form =
new Form($db);
354$title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Customer');
356 $title =
$object->name.
" - ".$langs->trans(
'Customer');
359$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
366 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), -1,
'company');
368 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
370 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
372 print
'<div class="fichecenter"><div class="fichehalfleft">';
374 print
'<div class="underbanner clearboth"></div>';
375 print
'<table class="border centpercent tableforfield">';
378 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
383 $langs->loadLangs(array(
"compta",
"accountancy"));
386 print $langs->trans(
'CustomerCode').
'</td><td>';
388 $tmpcheck =
$object->check_codeclient();
389 if ($tmpcheck != 0 && $tmpcheck != -5) {
390 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
399 print $form->editfieldkey(
"CustomerAccountancyCodeGeneral",
'customeraccountancycodegeneral',
length_accountg(
$object->accountancy_code_customer_general), $object, $permissiontoadd);
401 if ($action ==
'editcustomeraccountancycodegeneral' && $permissiontoadd) {
402 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_customer_general,
'customeraccountancycodegeneral', 0, 1,
'', 1);
404 if (
$object->accountancy_code_customer_general > 0) {
406 $accountingaccount->fetch(0,
$object->accountancy_code_customer_general, 1);
408 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
411 if (
$object->accountancy_code_customer_general > 0) {
414 $accountingAccountByDefault =
'<span class="opacitymedium">' . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')) .
'</span>';
415 print $accountingAccountByDefault;
424 print $form->editfieldkey(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client, $object, $permissiontoadd);
426 print $form->editfieldval(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client, $object, $permissiontoadd);
446 if (
$mysoc->country_code ==
'ES') {
448 if (
$mysoc->localtax1_assuj ==
"1") {
449 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td>';
453 if (
$mysoc->localtax1_assuj ==
"1") {
454 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td>';
461 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
466 $langs->load(
'bills');
468 print
'<table width="100%" class="nobordernopadding"><tr><td>';
469 print $langs->trans(
'PaymentConditions');
471 if (($action !=
'editconditions') && $permissiontoadd) {
472 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
474 print
'</tr></table>';
476 if ($action ==
'editconditions') {
477 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
479 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 0,
'', 1,
$object->deposit_percent);
485 print
'<tr><td class="nowrap">';
486 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
487 print $langs->trans(
'PaymentMode');
489 if (($action !=
'editmode') && $permissiontoadd) {
490 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
492 print
'</tr></table>';
494 if ($action ==
'editmode') {
495 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
497 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
504 print
'<tr><td class="nowrap">';
505 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
506 print $langs->trans(
'PaymentBankAccount');
508 if (($action !=
'editbankaccount') && $permissiontoadd) {
509 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
511 print
'</tr></table>';
513 if ($action ==
'editbankaccount') {
514 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
516 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'none');
526 print
'<tr><td class="nowrap">';
527 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
528 print $langs->trans(
"CustomerRelativeDiscountShort");
529 print
'<td><td class="right">';
530 if ($permissiontoadd && !$user->socid > 0) {
531 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create&token='.
newToken().
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
533 print
'</td></tr></table>';
534 print
'</td><td>'.($object->remise_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_percent.
'%</a>' :
'').
'</td>';
538 print
'<tr><td class="nowrap">';
539 print
'<table width="100%" class="nobordernopadding">';
540 print
'<tr><td class="nowrap">';
541 print $langs->trans(
"CustomerAbsoluteDiscountShort");
542 print
'<td><td class="right">';
543 if ($permissiontoadd && !$user->socid > 0) {
544 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create_remise&token='.
newToken().
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
546 print
'</td></tr></table>';
549 $amount_discount =
$object->getAvailableDiscounts();
550 if ($amount_discount < 0) {
553 if ($amount_discount > 0) {
554 print
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create&token='.
newToken().
'">'.
price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).
'</a>';
561 $limit_field_type =
'';
564 print
'<tr class="nowrap">';
566 print $form->editfieldkey(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit, $object, $permissiontoadd);
568 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
569 print $form->editfieldval(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit, $object, $permissiontoadd, $limit_field_type, (
$object->outstanding_limit !=
'' ?
price(
$object->outstanding_limit) :
''));
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->trans(
"CurrentOutstandingBill");
834 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
837 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
839 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
840 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
841 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
842 $boxstat .=
'</div>';
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->trans(
"CurrentOutstandingBillLate");
855 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
858 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
860 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
861 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
862 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
863 $boxstat .=
'</div>';
870 $parameters = array();
871 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', $parameters, $object, $action);
872 if (empty($reshook)) {
873 $boxstat .= $hookmanager->resPrint;
876 $boxstat .=
'</td></tr>';
877 $boxstat .=
'</table>';
878 $boxstat .=
'</div>';
886 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
887 $propal_static =
new Propal($db);
888 $langs->load(
"propal");
890 $sql =
"SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_projet, p.fk_statut, p.total_ht";
891 $sql .=
", p.total_tva";
892 $sql .=
", p.total_ttc";
893 $sql .=
", p.ref, p.ref_client, p.remise";
894 $sql .=
", p.datep as dp, p.fin_validite as date_limit, p.entity";
895 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
896 $sql .=
" WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
897 $sql .=
" AND s.rowid = ".((int)
$object->id);
898 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
899 $parameters = array();
900 $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propal_static);
901 $sql .= $hookmanager->resPrint;
902 $sql .=
" ORDER BY p.datep DESC";
904 $resql = $db->query($sql);
906 $num = $db->num_rows($resql);
908 print
'<div class="div-table-responsive-no-min">';
909 print
'<table class="noborder centpercent lastrecordtable">';
911 print
'<tr class="liste_titre">';
912 print
'<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
"LastPropals", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/comm/propal/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllPropals").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
913 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/comm/propal/stats/index.php?socid='.
$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
914 print
'</tr></table></td>';
919 while ($i < $num && $i < $MAXLIST) {
920 $objp = $db->fetch_object($resql);
922 print
'<tr class="oddeven">';
923 print
'<td class="nowraponall">';
924 $propal_static->id = $objp->propalid;
925 $propal_static->ref = $objp->ref;
926 $propal_static->ref_client = $objp->ref_client;
927 $propal_static->ref_customer = $objp->ref_client;
928 $propal_static->fk_project = $objp->fk_projet;
929 $propal_static->total_ht = $objp->total_ht;
930 $propal_static->total_tva = $objp->total_tva;
931 $propal_static->total_ttc = $objp->total_ttc;
932 print $propal_static->getNomUrl(1);
937 if (!empty($filedir)) {
940 if (is_array($file_list) && !empty($file_list)) {
944 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
945 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
950 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
953 if (!empty($sortfield) && !empty($sortorder)) {
958 print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0,
'entity=' . $objp->entity);
960 print
'</td><td class="tdoverflowmax125">';
961 if ($propal_static->fk_project > 0) {
962 $project->fetch($propal_static->fk_project);
963 print $project->getNomUrl(1);
969 if (($db->jdate($objp->date_limit) < ($now -
getWarningDelay(
'propal',
'cloture'))) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
970 print
" ".img_warning();
972 print
'</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
973 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
974 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).
'</td></tr>';
988 $orders2invoice =
null;
993 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
994 $commande_static =
new Commande($db);
995 $sql =
"SELECT s.nom, s.rowid";
996 $sql .=
", c.rowid as cid, c.entity, c.fk_projet, c.total_ht";
997 $sql .=
", c.total_tva";
998 $sql .=
", c.total_ttc";
999 $sql .=
", c.ref, c.ref_client, c.fk_statut, c.facture";
1000 $sql .=
", c.date_commande as dc";
1001 $sql .=
", c.facture as billed";
1002 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
1003 $sql .=
" WHERE c.fk_soc = s.rowid ";
1004 $sql .=
" AND s.rowid = ".((int)
$object->id);
1005 $sql .=
" AND c.entity IN (".getEntity(
'commande').
')';
1006 $parameters = array();
1007 $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $commande_static);
1008 $sql .= $hookmanager->resPrint;
1009 $sql .=
" ORDER BY c.date_commande DESC";
1011 $resql = $db->query($sql);
1013 $num = $db->num_rows($resql);
1016 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
1017 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
1018 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
1019 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande as c';
1020 $sql2 .=
' WHERE c.fk_soc = s.rowid';
1021 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
1023 $sql2 .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
1025 $resql2 = $db->query($sql2);
1026 $orders2invoice = $db->num_rows($resql2);
1029 print
'<div class="div-table-responsive-no-min">';
1030 print
'<table class="noborder centpercent lastrecordtable">';
1032 print
'<tr class="liste_titre">';
1033 print
'<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
"LastCustomerOrders", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllOrders").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1034 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/commande/stats/index.php?socid='.
$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
1035 print
'</tr></table></td>';
1040 while ($i < $num && $i < $MAXLIST) {
1041 $objp = $db->fetch_object($resql);
1043 $commande_static->id = $objp->cid;
1044 $commande_static->ref = $objp->ref;
1045 $commande_static->ref_client = $objp->ref_client;
1046 $commande_static->fk_project = $objp->fk_projet;
1047 $commande_static->total_ht = $objp->total_ht;
1048 $commande_static->total_tva = $objp->total_tva;
1049 $commande_static->total_ttc = $objp->total_ttc;
1050 $commande_static->billed = $objp->billed;
1052 print
'<tr class="oddeven">';
1053 print
'<td class="nowraponall">';
1054 print $commande_static->getNomUrl(1);
1056 $filedir = $conf->commande->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1058 if (!empty($filedir)) {
1061 if (is_array($file_list) && !empty($file_list)) {
1065 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1066 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1071 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1074 if (!empty($sortfield) && !empty($sortorder)) {
1079 print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0,
'entity=' . $objp->entity);
1081 print
'</td><td class="tdoverflowmax125">';
1082 if ($commande_static->fk_project > 0) {
1083 $project->fetch($commande_static->fk_project);
1084 print $project->getNomUrl(1);
1092 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
"</td>\n";
1093 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
1094 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).
'</td></tr>';
1111 if (
isModEnabled(
"shipping") && $user->hasRight(
'expedition',
'lire')) {
1114 $sql =
'SELECT e.rowid as id';
1115 $sql .=
', e.ref, e.entity, e.fk_projet';
1116 $sql .=
', e.date_creation';
1117 $sql .=
', e.fk_statut as statut';
1119 $sql .=
', s.rowid as socid';
1120 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"expedition as e";
1121 $sql .=
" WHERE e.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1122 $sql .=
" AND e.entity IN (".getEntity(
'expedition').
")";
1123 $sql .=
' GROUP BY e.rowid';
1124 $sql .=
', e.ref, e.entity, e.fk_projet';
1125 $sql .=
', e.date_creation';
1126 $sql .=
', e.fk_statut';
1128 $sql .=
', s.rowid';
1129 $sql .=
" ORDER BY e.date_creation DESC";
1131 $resql = $db->query($sql);
1135 $num = $db->num_rows($resql);
1137 print
'<div class="div-table-responsive-no-min">';
1138 print
'<table class="noborder centpercent lastrecordtable">';
1140 print
'<tr class="liste_titre">';
1141 print
'<td colspan="5"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans(
"LastSendings", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/expedition/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllSendings").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1142 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/expedition/stats/index.php?socid='.
$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
1143 print
'</tr></table></td>';
1148 while ($i < $num && $i < $MAXLIST) {
1149 $objp = $db->fetch_object($resql);
1151 $param =
'entity=' . ((int) $objp->entity);
1153 $sendingstatic->id = $objp->id;
1154 $sendingstatic->ref = $objp->ref;
1155 $sendingstatic->fk_project = $objp->fk_projet;
1157 print
'<tr class="oddeven">';
1158 print
'<td class="nowraponall">';
1159 print $sendingstatic->getNomUrl(1);
1161 $filedir = $conf->expedition->multidir_output[$objp->entity].
'/sending/'.
dol_sanitizeFileName($objp->ref);
1163 if (!empty($filedir)) {
1166 if (is_array($file_list) && !empty($file_list)) {
1170 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1171 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1176 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1179 if (!empty($sortfield) && !empty($sortorder)) {
1185 print $formfile->showPreview($file_list, $sendingstatic->element, $relativepath, 0, $param);
1187 print
'</td><td class="tdoverflowmax125">';
1188 if ($sendingstatic->fk_project > 0) {
1189 $project->fetch($sendingstatic->fk_project);
1190 print $project->getNomUrl(1);
1197 if ($objp->date_creation > 0) {
1198 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
1200 print
'<td class="right"><b>!!!</b></td>';
1203 print
'<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
1221 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1222 $sql =
"SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.fk_projet, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity,";
1223 $sql .=
" c.last_main_doc, c.model_pdf";
1224 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
1225 $sql .=
" WHERE c.fk_soc = s.rowid ";
1226 $sql .=
" AND s.rowid = ".((int)
$object->id);
1227 $sql .=
" AND c.entity IN (".getEntity(
'contract').
")";
1228 $sql .=
" ORDER BY c.datec DESC";
1230 $resql = $db->query($sql);
1234 $num = $db->num_rows($resql);
1236 print
'<div class="div-table-responsive-no-min">';
1237 print
'<table class="noborder centpercent lastrecordtable">';
1239 print
'<tr class="liste_titre">';
1240 print
'<td colspan="6"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans(
"LastContracts", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
1241 print
'<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/contrat/list.php?socid='.
$object->id.
'">'.$langs->trans(
"AllContracts").
'<span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1243 print
'</tr></table></td>';
1248 while ($i < $num && $i < $MAXLIST) {
1249 $objp = $db->fetch_object($resql);
1251 $contrat->id = $objp->id;
1252 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1253 $contrat->ref_customer = $objp->refcus;
1254 $contrat->ref_supplier = $objp->refsup;
1255 $contrat->fk_project = $objp->fk_projet;
1256 $contrat->statut = $objp->contract_status;
1257 $contrat->status = $objp->contract_status;
1258 $contrat->last_main_doc = $objp->last_main_doc;
1259 $contrat->model_pdf = $objp->model_pdf;
1260 $contrat->fetch_lines();
1263 foreach ($contrat->lines as $line) {
1264 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1265 if (((!empty($line->date_end) ? $line->date_end : 0) +
getWarningDelay(
'contract',
'service',
'expires')) < $now) {
1271 print
'<tr class="oddeven">';
1272 print
'<td class="nowraponall">';
1273 print $contrat->getNomUrl(1, 12);
1274 if (!empty($contrat->model_pdf)) {
1276 $filedir = $conf->contract->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1278 if (!empty($filedir)) {
1281 if (is_array($file_list) && !empty($file_list)) {
1285 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1286 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1291 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1294 if (!empty($sortfield) && !empty($sortorder)) {
1299 print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0,
'entity=' . $objp->entity);
1307 print
'</td><td class="tdoverflowmax125">';
1308 if ($contrat->fk_project > 0) {
1309 $project->fetch($contrat->fk_project);
1310 print $project->getNomUrl(1);
1313 print
'<td class="nowrap">';
1314 print
dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1317 print
'<td class="right" width="80px"><span title="'.$langs->trans(
"DateContract").
'">'.
dol_print_date($db->jdate($objp->dcon),
'day').
"</span></td>\n";
1318 print
'<td width="20"> </td>';
1319 print
'<td class="nowraponall right">';
1320 print $contrat->getLibStatut(4);
1339 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'lire')) {
1340 $sql =
"SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_projet, f.fk_statut, f.duree as duration, f.datei as startdate, f.entity";
1341 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"fichinter as f";
1342 $sql .=
" WHERE f.fk_soc = s.rowid";
1343 $sql .=
" AND s.rowid = ".((int)
$object->id);
1344 $sql .=
" AND f.entity IN (".getEntity(
'intervention').
")";
1345 $sql .=
" ORDER BY f.tms DESC";
1347 $resql = $db->query($sql);
1351 $num = $db->num_rows($resql);
1353 print
'<div class="div-table-responsive-no-min">';
1354 print
'<table class="noborder centpercent lastrecordtable">';
1356 print
'<tr class="liste_titre">';
1357 print
'<td colspan="4"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans(
"LastInterventions", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/fichinter/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllInterventions").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></td>';
1358 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/fichinter/stats/index.php?socid='.
$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
1359 print
'</tr></table></td>';
1364 while ($i < $num && $i < $MAXLIST) {
1365 $objp = $db->fetch_object($resql);
1367 $fichinter_static->id = $objp->id;
1368 $fichinter_static->ref = $objp->ref;
1369 $fichinter_static->statut = $objp->fk_statut;
1370 $fichinter_static->status = $objp->fk_statut;
1371 $fichinter_static->fk_project = $objp->fk_projet;
1373 print
'<tr class="oddeven">';
1374 print
'<td class="nowraponall">';
1375 print $fichinter_static->getNomUrl(1);
1377 $filedir = $conf->ficheinter->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1379 if (!empty($filedir)) {
1382 if (is_array($file_list) && !empty($file_list)) {
1386 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1387 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1392 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1395 if (!empty($sortfield) && !empty($sortorder)) {
1400 print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0,
'entity=' . $objp->entity);
1402 print
'</td><td class="tdoverflowmax125">';
1403 if ($fichinter_static->fk_project > 0) {
1404 $project->fetch($fichinter_static->fk_project);
1405 print $project->getNomUrl(1);
1413 print
'<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).
'</td>'.
"\n";
1414 print
'<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).
'</td>'.
"\n";
1433 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1434 $sql =
'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1435 $sql .=
', f.total_ht';
1436 $sql .=
', f.total_tva';
1437 $sql .=
', f.total_ttc';
1438 $sql .=
', f.datec as dc';
1439 $sql .=
', f.date_last_gen, f.date_when';
1440 $sql .=
', f.frequency';
1441 $sql .=
', f.unit_frequency';
1442 $sql .=
', f.suspended as suspended';
1443 $sql .=
', s.nom, s.rowid as socid';
1444 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_rec as f";
1445 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1446 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1447 $sql .=
' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1448 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1449 $sql .=
' f.suspended, f.date_when,';
1450 $sql .=
' s.nom, s.rowid';
1451 $sql .=
" ORDER BY f.date_last_gen, f.datec DESC";
1453 $resql = $db->query($sql);
1457 $num = $db->num_rows($resql);
1459 print
'<div class="div-table-responsive-no-min">';
1460 print
'<table class="noborder centpercent lastrecordtable">';
1461 print
'<tr class="liste_titre">';
1466 print
'<td colspan="'.$colspan.
'">';
1467 print
'<table class="centpercent nobordernopadding"><tr>';
1468 print
'<td>'.$langs->trans(
"LatestCustomerTemplateInvoices", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllCustomerTemplateInvoices").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1469 print
'</tr></table>';
1475 while ($i < $num && $i < $MAXLIST) {
1476 $objp = $db->fetch_object($resql);
1478 $invoicetemplate->id = $objp->id;
1479 $invoicetemplate->ref = $objp->ref;
1480 $invoicetemplate->fk_project = $objp->fk_projet;
1481 $invoicetemplate->suspended = $objp->suspended;
1482 $invoicetemplate->frequency = $objp->frequency;
1483 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1484 $invoicetemplate->total_ht = $objp->total_ht;
1485 $invoicetemplate->total_tva = $objp->total_tva;
1486 $invoicetemplate->total_ttc = $objp->total_ttc;
1487 $invoicetemplate->date_last_gen = $objp->date_last_gen;
1488 $invoicetemplate->date_when = $objp->date_when;
1490 print
'<tr class="oddeven">';
1491 print
'<td class="tdoverflowmax250">';
1492 print $invoicetemplate->getNomUrl(1);
1493 print
'</td><td class="tdoverflowmax125">';
1494 if ($invoicetemplate->fk_project > 0) {
1495 $project->fetch($invoicetemplate->fk_project);
1496 print $project->getNomUrl(1);
1500 if ($objp->frequency && $objp->date_last_gen > 0) {
1501 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
1503 if ($objp->dc > 0) {
1504 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
1506 print
'<td class="right"><b>!!!</b></td>';
1509 print
'<td class="right nowraponall">';
1510 print
price($objp->total_ht);
1514 print
'<td class="right nowraponall">';
1515 print
price($objp->total_ttc);
1519 print
'<td class="nowrap right" style="min-width: 60px">';
1520 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
1521 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1540 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1541 $sql =
'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1542 $sql .=
', f.total_ht';
1543 $sql .=
', f.total_tva';
1544 $sql .=
', f.total_ttc';
1545 $sql .=
', f.entity';
1546 $sql .=
', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status';
1547 $sql .=
', s.nom, s.rowid as socid';
1548 $sql .=
', SUM(pf.amount) as am';
1549 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
1550 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON f.rowid=pf.fk_facture';
1551 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1552 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1553 $sql .=
' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1554 $sql .=
' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1555 $sql .=
' s.nom, s.rowid';
1556 $sql .=
" ORDER BY f.datef DESC, f.datec DESC";
1558 $resql = $db->query($sql);
1560 $facturestatic =
new Facture($db);
1562 $num = $db->num_rows($resql);
1564 print
'<div class="div-table-responsive-no-min">';
1565 print
'<table class="noborder centpercent lastrecordtable">';
1566 print
'<tr class="liste_titre">';
1574 print
'<td colspan="'.$colspan.
'">';
1575 print
'<table class="centpercent nobordernopadding"><tr><td>'.$langs->trans(
"LastCustomersBills", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllBills").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1576 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/compta/facture/stats/index.php?socid='.
$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
1577 print
'</tr></table>';
1583 while ($i < $num && $i < $MAXLIST) {
1584 $objp = $db->fetch_object($resql);
1586 $facturestatic->id = $objp->facid;
1587 $facturestatic->ref = $objp->ref;
1588 $facturestatic->ref_client = $objp->ref_client;
1589 $facturestatic->fk_project = $objp->fk_projet;
1590 $facturestatic->type = $objp->type;
1591 $facturestatic->total_ht = $objp->total_ht;
1592 $facturestatic->total_tva = $objp->total_tva;
1593 $facturestatic->total_ttc = $objp->total_ttc;
1594 $facturestatic->statut = $objp->status;
1595 $facturestatic->status = $objp->status;
1596 $facturestatic->paye = $objp->paye;
1598 $facturestatic->alreadypaid = $objp->am;
1599 $facturestatic->totalpaid = $objp->am;
1601 $facturestatic->date = $db->jdate($objp->df);
1602 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1604 print
'<tr class="oddeven">';
1605 print
'<td class="nowraponall">';
1606 print $facturestatic->getNomUrl(1);
1608 $filedir = $conf->invoice->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1610 if (!empty($filedir)) {
1613 if (is_array($file_list) && !empty($file_list)) {
1617 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1618 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1623 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
1626 if (!empty($sortfield) && !empty($sortorder)) {
1631 print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0,
'entity=' . $objp->entity);
1633 print
'</td><td class="tdoverflowmax125">';
1634 if ($facturestatic->fk_project > 0) {
1635 $project->fetch($facturestatic->fk_project);
1636 print $project->getNomUrl(1);
1644 print
'<td class="nowraponall">';
1648 if ($objp->df > 0) {
1649 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateInvoice')).
'">'.
dol_print_date($db->jdate($objp->df),
'day').
'</td>';
1651 print
'<td><b>!!!</b></td>';
1653 if ($objp->dl > 0) {
1654 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateMaxPayment')).
'">'.
dol_print_date($db->jdate($objp->dl),
'day').
'</td>';
1656 print
'<td><b>!!!</b></td>';
1659 print
'<td class="right nowraponall">';
1660 print
price($objp->total_ht);
1664 print
'<td class="right nowraponall">';
1665 print
price($objp->total_ttc);
1669 print
'<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).
'</td>';
1685 $parameters = array();
1686 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
1690 print $hookmanager->resPrint;
1693 print
'</div></div>';
1694 print
'<div class="clearboth"></div>';
1702 print
'<div class="tabsAction">';
1704 $parameters = array();
1705 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1707 if (empty($reshook)) {
1709 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"ThirdPartyIsClosed").
'</a></div>';
1712 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer') &&
$object->status == 1) {
1713 $langs->load(
"propal");
1714 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/comm/propal/card.php?socid='.
$object->id.
'&action=create">'.$langs->trans(
"AddProp").
'</a></div>';
1717 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'creer') &&
$object->status == 1) {
1718 $langs->load(
"orders");
1719 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/commande/card.php?socid='.
$object->id.
'&action=create">'.$langs->trans(
"AddOrder").
'</a></div>';
1722 if ($user->hasRight(
'contrat',
'creer') &&
$object->status == 1) {
1723 $langs->load(
"contracts");
1724 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/contrat/card.php?socid='.
$object->id.
'&action=create">'.$langs->trans(
"AddContract").
'</a></div>';
1727 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer') &&
$object->status == 1) {
1728 $langs->load(
"interventions");
1729 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/fichinter/card.php?socid='.
$object->id.
'&action=create">'.$langs->trans(
"AddIntervention").
'</a></div>';
1734 $langs->load(
"trips");
1735 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/compta/deplacement/card.php?socid='.
$object->id.
'&action=create">'.$langs->trans(
"AddTrip").
'</a></div>';
1739 if (!$user->hasRight(
'facture',
'creer')) {
1740 $langs->load(
"bills");
1741 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1743 $langs->loadLangs(array(
"orders",
"bills"));
1746 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&socid='.
$object->id.
'">'.$langs->trans(
"AddBill").
'</a></div>';
1748 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1754 if ($user->hasRight(
'facture',
'creer')) {
1757 if (!empty($orders2invoice) && $orders2invoice > 0) {
1758 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->id.
'&search_billed=0&autoselectall=1">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1760 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1763 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1771 if ($user->hasRight(
'agenda',
'myactions',
'create')) {
1772 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.
$object->id.
'">'.$langs->trans(
"AddAction").
'</a></div>';
1774 print
'<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($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.
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)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.