37require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
46require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
47if (isModEnabled(
'invoice')) {
48 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
51if (isModEnabled(
"propal")) {
52 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
54if (isModEnabled(
'order')) {
55 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
57if (isModEnabled(
"shipping")) {
58 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
60if (isModEnabled(
'contract')) {
61 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
63if (isModEnabled(
'member')) {
64 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
66if (isModEnabled(
'intervention')) {
67 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
69if (isModEnabled(
'accounting')) {
70 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
71 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
84$langs->loadLangs(array(
'companies',
'banks'));
86if (isModEnabled(
'contract')) {
87 $langs->load(
"contracts");
89if (isModEnabled(
'order')) {
90 $langs->load(
"orders");
92if (isModEnabled(
"shipping")) {
93 $langs->load(
"sendings");
95if (isModEnabled(
'invoice')) {
96 $langs->load(
"bills");
98if (isModEnabled(
'project')) {
99 $langs->load(
"projects");
101if (isModEnabled(
'intervention')) {
102 $langs->load(
"interventions");
104if (isModEnabled(
'notification')) {
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) {
168$parameters = array(
'id' => $id,
'socid' => $id);
169$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
174if (empty($reshook)) {
180 if ($action ==
'setcustomeraccountancycodegeneral') {
182 $object->accountancy_code_customer_general =
GETPOST(
"customeraccountancycodegeneral");
190 if ($action ==
'setcustomeraccountancycode' && $user->hasRight(
'societe',
'creer')) {
197 $action =
'editcustomeraccountancycode';
202 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
211 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
220 if ($action ==
'settransportmode' && $user->hasRight(
'societe',
'creer')) {
222 $result =
$object->setTransportMode(
GETPOST(
'transport_mode_id',
'alpha'));
229 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
238 if ($action ==
'setshippingmethod' && $user->hasRight(
'societe',
'creer')) {
247 if ($action ==
'setassujtva' && $user->hasRight(
'societe',
'creer')) {
257 if ($action ==
'setprospectlevel' && $user->hasRight(
'societe',
'creer')) {
259 $object->fk_prospectlevel =
GETPOST(
'prospect_level_id',
'alpha');
267 if ($action ==
'setstcomm' && $user->hasRight(
'societe',
'creer')) {
279 if ($action ==
'setoutstanding_limit' && $user->hasRight(
'societe',
'creer')) {
289 if ($action ==
'setorder_min_amount' && $user->hasRight(
'societe',
'creer')) {
299 if ($action ==
'set_salesrepresentatives' && $user->hasRight(
'societe',
'creer')) {
304 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
310 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
315 $result =
$object->insertExtraFields(
'COMPANY_MODIFY');
322 $action =
'edit_extras';
327 if ($action ==
'setwarehouse' && $user->hasRight(
'societe',
'creer')) {
337$contactstatic =
new Contact($db);
338$userstatic =
new User($db);
339$form =
new Form($db);
343$title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Customer');
345 $title =
$object->name.
" - ".$langs->trans(
'Customer');
348$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
355 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), -1,
'company');
357 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
359 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
361 print
'<div class="fichecenter"><div class="fichehalfleft">';
363 print
'<div class="underbanner clearboth"></div>';
364 print
'<table class="border centpercent tableforfield">';
367 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
373 print
'<tr><td>'.$langs->trans(
"Prefix").
'</td><td>';
379 $langs->load(
"compta");
382 print $langs->trans(
'CustomerCode').
'</td><td>';
384 $tmpcheck =
$object->check_codeclient();
385 if ($tmpcheck != 0 && $tmpcheck != -5) {
386 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
390 if (isModEnabled(
'accounting')) {
395 print $form->editfieldkey(
"CustomerAccountancyCodeGeneral",
'customeraccountancycodegeneral',
length_accountg(
$object->accountancy_code_customer_general),
$object, $user->hasRight(
'societe',
'creer'));
397 if ($action ==
'editcustomeraccountancycodegeneral' && $user->hasRight(
'societe',
'creer')) {
398 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_customer_general,
'customeraccountancycodegeneral', 0, 1,
'', 1);
400 if (
$object->accountancy_code_customer_general > 0) {
402 $accountingaccount->fetch(0,
$object->accountancy_code_customer_general, 1);
404 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
407 if (
$object->accountancy_code_customer_general > 0) {
410 $accountingAccountByDefault =
'<span class="opacitymedium">' . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')) .
'</span>';
411 print $accountingAccountByDefault;
419 print $form->editfieldkey(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client,
$object, $user->hasRight(
'societe',
'creer'));
421 print $form->editfieldval(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client,
$object, $user->hasRight(
'societe',
'creer'));
442 if ($mysoc->country_code ==
'ES') {
444 if ($mysoc->localtax1_assuj ==
"1") {
445 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
449 if ($mysoc->localtax1_assuj ==
"1") {
450 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
457 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
462 $langs->load(
'bills');
464 print
'<table width="100%" class="nobordernopadding"><tr><td>';
465 print $langs->trans(
'PaymentConditions');
467 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
468 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>';
470 print
'</tr></table>';
472 if ($action ==
'editconditions') {
473 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
475 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_id,
'none', 0,
'', 1,
$object->deposit_percent);
481 print
'<tr><td class="nowrap">';
482 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
483 print $langs->trans(
'PaymentMode');
485 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
486 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>';
488 print
'</tr></table>';
490 if ($action ==
'editmode') {
491 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
493 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_id,
'none');
498 if (isModEnabled(
"bank")) {
500 print
'<tr><td class="nowrap">';
501 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
502 print $langs->trans(
'PaymentBankAccount');
504 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
505 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>';
507 print
'</tr></table>';
509 if ($action ==
'editbankaccount') {
510 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'fk_account', 1);
512 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'none');
522 print
'<tr><td class="nowrap">';
523 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
524 print $langs->trans(
"CustomerRelativeDiscountShort");
525 print
'<td><td class="right">';
526 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
527 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>';
529 print
'</td></tr></table>';
530 print
'</td><td>'.($object->remise_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_percent.
'%</a>' :
'').
'</td>';
534 print
'<tr><td class="nowrap">';
535 print
'<table width="100%" class="nobordernopadding">';
536 print
'<tr><td class="nowrap">';
537 print $langs->trans(
"CustomerAbsoluteDiscountShort");
538 print
'<td><td class="right">';
539 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
540 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>';
542 print
'</td></tr></table>';
545 $amount_discount =
$object->getAvailableDiscounts();
546 if ($amount_discount < 0) {
549 if ($amount_discount > 0) {
550 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>';
557 $limit_field_type =
'';
560 print
'<tr class="nowrap">';
562 print $form->editfieldkey(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit,
$object, $user->hasRight(
'societe',
'creer'));
564 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
565 print $form->editfieldval(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit,
$object, $user->hasRight(
'societe',
'creer'), $limit_field_type, (
$object->outstanding_limit !=
'' ?
price(
$object->outstanding_limit) :
''));
572 print
'<!-- Minimum amount for orders -->'.
"\n";
573 print
'<tr class="nowrap">';
575 print $form->editfieldkey(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount,
$object, $user->hasRight(
'societe',
'creer'));
577 print $form->editfieldval(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount,
$object, $user->hasRight(
'societe',
'creer'), $limit_field_type, (
$object->order_min_amount !=
'' ?
price(
$object->order_min_amount) :
''));
586 print
'<tr><td class="nowrap">';
587 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
588 print $langs->trans(
"PriceLevel");
589 print
'<td><td class="right">';
590 if ($user->hasRight(
'societe',
'creer')) {
591 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/multiprix.php?id='.
$object->id.
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
593 print
'</td></tr></table>';
596 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
606 $langs->load(
'stocks');
607 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
609 print
'<tr class="nowrap">';
611 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, $user->hasRight(
'societe',
'creer'));
613 if ($action ==
'editwarehouse') {
614 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'fk_warehouse', 1);
616 if (
$object->fk_warehouse > 0) {
617 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
619 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'none');
627 print
'<tr><td class="nowrap">';
628 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
629 print $langs->trans(
'SendingMethod');
631 if (($action !=
'editshipping') && $user->hasRight(
'societe',
'creer')) {
632 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>';
634 print
'</tr></table>';
636 if ($action ==
'editshipping') {
637 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->shipping_method_id,
'shipping_method_id', 1);
639 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->shipping_method_id,
'none');
645 if (isModEnabled(
'intracommreport')) {
647 print
'<tr><td class="nowrap">';
648 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
649 print $langs->trans(
'IntracommReportTransportMode');
651 if (($action !=
'edittransportmode') && $user->hasRight(
'societe',
'creer')) {
652 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>';
654 print
'</tr></table>';
656 if ($action ==
'edittransportmode') {
657 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'transport_mode_id', 1);
659 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'none');
666 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
667 $langs->load(
"categories");
668 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
670 print $form->showCategories(
$object->id, Categorie::TYPE_CUSTOMER, 1);
675 $parameters = array(
'socid' =>
$object->id);
676 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
679 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
682 if (isModEnabled(
'member')) {
683 $langs->load(
"members");
684 $langs->load(
"users");
686 print
'<tr><td class="titlefield">'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
689 $result = $adh->fetch(0,
'',
$object->id);
691 $adh->ref = $adh->getFullName($langs);
692 print $adh->getNomUrl(-1);
694 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
702 print
'</div><div class="fichehalfright">';
706 print
'<div class="underbanner clearboth"></div>';
707 print
'<table class="border centpercent tableforfield">';
710 print
'<tr><td class="titlefield nowrap">';
711 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
712 print $langs->trans(
'ProspectLevel');
714 if ($action !=
'editlevel' && $user->hasRight(
'societe',
'creer')) {
715 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>';
717 print
'</tr></table>';
719 if ($action ==
'editlevel') {
720 $formcompany->form_prospect_level($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_prospectlevel,
'prospect_level_id', 1);
722 print
$object->getLibProspLevel();
728 $object->loadCacheOfProspStatus();
729 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.
$object->getLibProspCommStatut(4,
$object->cacheprospectstatus[
$object->stcomm_id][
'label']);
730 print
' ';
731 print
'<div class="floatright">';
732 foreach (
$object->cacheprospectstatus as $key => $val) {
733 $titlealt =
'default';
734 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
735 $titlealt = $val[
'label'];
737 if (
$object->stcomm_id != $val[
'id']) {
738 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>';
741 print
'</div></td></tr>';
746 print
'<div class="underbanner underbanner-before-box clearboth"></div><br>';
755 $boxstat .=
'<div class="box divboxtable box-halfright">';
756 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop boxtablenomarginbottom centpercent">';
757 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
759 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
761 $tmp =
$object->getOutstandingProposals();
762 $outstandingOpened = $tmp[
'opened'];
763 $outstandingTotal = $tmp[
'total_ht'];
764 $outstandingTotalIncTax = $tmp[
'total_ttc'];
765 $text = $langs->trans(
"OverAllProposals");
766 $link = DOL_URL_ROOT.
'/comm/propal/list.php?socid='.
$object->id;
769 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
771 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
772 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
773 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
774 $boxstat .=
'</div>';
780 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
782 $tmp =
$object->getOutstandingOrders();
783 $outstandingOpened = $tmp[
'opened'];
784 $outstandingTotal = $tmp[
'total_ht'];
785 $outstandingTotalIncTax = $tmp[
'total_ttc'];
786 $text = $langs->trans(
"OverAllOrders");
787 $link = DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->id;
790 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
792 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
793 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
794 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
795 $boxstat .=
'</div>';
801 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
803 $tmp =
$object->getOutstandingBills(
'customer', 0);
804 $outstandingOpened = $tmp[
'opened'];
805 $outstandingTotal = $tmp[
'total_ht'];
806 $outstandingTotalIncTax = $tmp[
'total_ttc'];
808 $text = $langs->trans(
"OverAllInvoices");
809 $link = DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->id;
812 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
814 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
815 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
816 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
817 $boxstat .=
'</div>';
824 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpened) {
825 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
827 $text = $langs->trans(
"CurrentOutstandingBill");
828 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
831 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
833 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
834 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
835 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
836 $boxstat .=
'</div>';
841 $tmp =
$object->getOutstandingBills(
'customer', 1);
842 $outstandingOpenedLate = $tmp[
'opened'];
843 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
845 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpenedLate) {
846 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
848 $text = $langs->trans(
"CurrentOutstandingBillLate");
849 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
852 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
854 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
855 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
856 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
857 $boxstat .=
'</div>';
864 $parameters = array();
865 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', $parameters,
$object, $action);
866 if (empty($reshook)) {
867 $boxstat .= $hookmanager->resPrint;
870 $boxstat .=
'</td></tr>';
871 $boxstat .=
'</table>';
872 $boxstat .=
'</div>';
880 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
881 $langs->load(
"propal");
883 $sql =
"SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_projet, p.fk_statut, p.total_ht";
884 $sql .=
", p.total_tva";
885 $sql .=
", p.total_ttc";
886 $sql .=
", p.ref, p.ref_client, p.remise";
887 $sql .=
", p.datep as dp, p.fin_validite as date_limit, p.entity";
888 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
889 $sql .=
" WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
890 $sql .=
" AND s.rowid = ".((int)
$object->id);
891 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
892 $sql .=
" ORDER BY p.datep DESC";
894 $resql = $db->query($sql);
896 $propal_static =
new Propal($db);
898 $num = $db->num_rows($resql);
900 print
'<div class="div-table-responsive-no-min">';
901 print
'<table class="noborder centpercent lastrecordtable">';
903 print
'<tr class="liste_titre">';
904 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>';
905 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>';
906 print
'</tr></table></td>';
911 while ($i < $num && $i < $MAXLIST) {
912 $objp = $db->fetch_object($resql);
914 print
'<tr class="oddeven">';
915 print
'<td class="nowraponall">';
916 $propal_static->id = $objp->propalid;
917 $propal_static->ref = $objp->ref;
918 $propal_static->ref_client = $objp->ref_client;
919 $propal_static->ref_customer = $objp->ref_client;
920 $propal_static->fk_project = $objp->fk_projet;
921 $propal_static->total_ht = $objp->total_ht;
922 $propal_static->total_tva = $objp->total_tva;
923 $propal_static->total_ttc = $objp->total_ttc;
924 print $propal_static->getNomUrl(1);
929 if (!empty($filedir)) {
932 if (is_array($file_list) && !empty($file_list)) {
936 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
937 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
942 '@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';
945 if (!empty($sortfield) && !empty($sortorder)) {
950 print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0);
952 print
'</td><td class="left">';
953 if ($propal_static->fk_project > 0) {
954 $project->fetch($propal_static->fk_project);
955 print $project->getNomUrl(1);
961 if (($db->jdate($objp->date_limit) < ($now -
$conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
962 print
" ".img_warning();
964 print
'</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
965 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
966 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).
'</td></tr>';
980 $orders2invoice =
null;
985 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
986 $sql =
"SELECT s.nom, s.rowid";
987 $sql .=
", c.rowid as cid, c.entity, c.fk_projet, c.total_ht";
988 $sql .=
", c.total_tva";
989 $sql .=
", c.total_ttc";
990 $sql .=
", c.ref, c.ref_client, c.fk_statut, c.facture";
991 $sql .=
", c.date_commande as dc";
992 $sql .=
", c.facture as billed";
993 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
994 $sql .=
" WHERE c.fk_soc = s.rowid ";
995 $sql .=
" AND s.rowid = ".((int)
$object->id);
996 $sql .=
" AND c.entity IN (".getEntity(
'commande').
')';
997 $sql .=
" ORDER BY c.date_commande DESC";
999 $resql = $db->query($sql);
1001 $commande_static =
new Commande($db);
1003 $num = $db->num_rows($resql);
1006 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
1007 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
1008 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
1009 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande as c';
1010 $sql2 .=
' WHERE c.fk_soc = s.rowid';
1011 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
1013 $sql2 .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
1015 $resql2 = $db->query($sql2);
1016 $orders2invoice = $db->num_rows($resql2);
1019 print
'<div class="div-table-responsive-no-min">';
1020 print
'<table class="noborder centpercent lastrecordtable">';
1022 print
'<tr class="liste_titre">';
1023 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>';
1024 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>';
1025 print
'</tr></table></td>';
1030 while ($i < $num && $i < $MAXLIST) {
1031 $objp = $db->fetch_object($resql);
1033 $commande_static->id = $objp->cid;
1034 $commande_static->ref = $objp->ref;
1035 $commande_static->ref_client = $objp->ref_client;
1036 $commande_static->fk_project = $objp->fk_projet;
1037 $commande_static->total_ht = $objp->total_ht;
1038 $commande_static->total_tva = $objp->total_tva;
1039 $commande_static->total_ttc = $objp->total_ttc;
1040 $commande_static->billed = $objp->billed;
1042 print
'<tr class="oddeven">';
1043 print
'<td class="nowraponall">';
1044 print $commande_static->getNomUrl(1);
1048 if (!empty($filedir)) {
1051 if (is_array($file_list) && !empty($file_list)) {
1055 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1056 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1061 '@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';
1064 if (!empty($sortfield) && !empty($sortorder)) {
1069 print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0, $param);
1071 print
'</td><td class="left">';
1072 if ($commande_static->fk_project > 0) {
1073 $project->fetch($commande_static->fk_project);
1074 print $project->getNomUrl(1);
1082 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
"</td>\n";
1083 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
1084 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).
'</td></tr>';
1101 if (isModEnabled(
"shipping") && $user->hasRight(
'expedition',
'lire')) {
1102 $sql =
'SELECT e.rowid as id';
1103 $sql .=
', e.ref, e.entity, e.fk_projet';
1104 $sql .=
', e.date_creation';
1105 $sql .=
', e.fk_statut as statut';
1107 $sql .=
', s.rowid as socid';
1108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"expedition as e";
1109 $sql .=
" WHERE e.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1110 $sql .=
" AND e.entity IN (".getEntity(
'expedition').
")";
1111 $sql .=
' GROUP BY e.rowid';
1112 $sql .=
', e.ref, e.entity, e.fk_projet';
1113 $sql .=
', e.date_creation';
1114 $sql .=
', e.fk_statut';
1116 $sql .=
', s.rowid';
1117 $sql .=
" ORDER BY e.date_creation DESC";
1119 $resql = $db->query($sql);
1123 $num = $db->num_rows($resql);
1125 print
'<div class="div-table-responsive-no-min">';
1126 print
'<table class="noborder centpercent lastrecordtable">';
1128 print
'<tr class="liste_titre">';
1129 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>';
1130 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>';
1131 print
'</tr></table></td>';
1136 while ($i < $num && $i < $MAXLIST) {
1137 $objp = $db->fetch_object($resql);
1139 $sendingstatic->id = $objp->id;
1140 $sendingstatic->ref = $objp->ref;
1141 $sendingstatic->fk_project = $objp->fk_projet;
1143 print
'<tr class="oddeven">';
1144 print
'<td class="nowraponall">';
1145 print $sendingstatic->getNomUrl(1);
1149 if (!empty($filedir)) {
1152 if (is_array($file_list) && !empty($file_list)) {
1156 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1157 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1162 '@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';
1165 if (!empty($sortfield) && !empty($sortorder)) {
1170 print $formfile->showPreview($file_list, $sendingstatic->table_element, $relativepath, 0, $param);
1172 print
'</td><td class="left">';
1173 if ($sendingstatic->fk_project > 0) {
1174 $project->fetch($sendingstatic->fk_project);
1175 print $project->getNomUrl(1);
1182 if ($objp->date_creation > 0) {
1183 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
1185 print
'<td class="right"><b>!!!</b></td>';
1188 print
'<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
1206 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1207 $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,";
1208 $sql .=
" c.last_main_doc, c.model_pdf";
1209 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
1210 $sql .=
" WHERE c.fk_soc = s.rowid ";
1211 $sql .=
" AND s.rowid = ".((int)
$object->id);
1212 $sql .=
" AND c.entity IN (".getEntity(
'contract').
")";
1213 $sql .=
" ORDER BY c.datec DESC";
1215 $resql = $db->query($sql);
1219 $num = $db->num_rows($resql);
1221 print
'<div class="div-table-responsive-no-min">';
1222 print
'<table class="noborder centpercent lastrecordtable">';
1224 print
'<tr class="liste_titre">';
1225 print
'<td colspan="6"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
"LastContracts", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
1226 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>';
1228 print
'</tr></table></td>';
1233 while ($i < $num && $i < $MAXLIST) {
1234 $objp = $db->fetch_object($resql);
1236 $contrat->id = $objp->id;
1237 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1238 $contrat->ref_customer = $objp->refcus;
1239 $contrat->ref_supplier = $objp->refsup;
1240 $contrat->fk_project = $objp->fk_projet;
1241 $contrat->statut = $objp->contract_status;
1242 $contrat->status = $objp->contract_status;
1243 $contrat->last_main_doc = $objp->last_main_doc;
1244 $contrat->model_pdf = $objp->model_pdf;
1245 $contrat->fetch_lines();
1248 foreach ($contrat->lines as $line) {
1249 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1250 if (((!empty($line->date_end) ? $line->date_end : 0) +
$conf->contrat->services->expires->warning_delay) < $now) {
1256 print
'<tr class="oddeven">';
1257 print
'<td class="nowraponall">';
1258 print $contrat->getNomUrl(1, 12);
1259 if (!empty($contrat->model_pdf)) {
1263 if (!empty($filedir)) {
1266 if (is_array($file_list) && !empty($file_list)) {
1270 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1271 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1276 '@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';
1279 if (!empty($sortfield) && !empty($sortorder)) {
1284 print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0);
1292 print
'</td><td class="tdoverflowmax100">';
1293 if ($contrat->fk_project > 0) {
1294 $project->fetch($contrat->fk_project);
1295 print $project->getNomUrl(1);
1298 print
'<td class="nowrap">';
1299 print
dol_trunc(strtolower(get_class(
$object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1302 print
'<td class="right" width="80px"><span title="'.$langs->trans(
"DateContract").
'">'.
dol_print_date($db->jdate($objp->dcon),
'day').
"</span></td>\n";
1303 print
'<td width="20"> </td>';
1304 print
'<td class="nowraponall right">';
1305 print $contrat->getLibStatut(4);
1324 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'lire')) {
1325 $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";
1326 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"fichinter as f";
1327 $sql .=
" WHERE f.fk_soc = s.rowid";
1328 $sql .=
" AND s.rowid = ".((int)
$object->id);
1329 $sql .=
" AND f.entity IN (".getEntity(
'intervention').
")";
1330 $sql .=
" ORDER BY f.tms DESC";
1332 $resql = $db->query($sql);
1336 $num = $db->num_rows($resql);
1338 print
'<div class="div-table-responsive-no-min">';
1339 print
'<table class="noborder centpercent lastrecordtable">';
1341 print
'<tr class="liste_titre">';
1342 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>';
1343 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>';
1344 print
'</tr></table></td>';
1349 while ($i < $num && $i < $MAXLIST) {
1350 $objp = $db->fetch_object($resql);
1352 $fichinter_static->id = $objp->id;
1353 $fichinter_static->ref = $objp->ref;
1354 $fichinter_static->statut = $objp->fk_statut;
1355 $fichinter_static->fk_project = $objp->fk_projet;
1357 print
'<tr class="oddeven">';
1358 print
'<td class="nowraponall">';
1359 print $fichinter_static->getNomUrl(1);
1363 if (!empty($filedir)) {
1366 if (is_array($file_list) && !empty($file_list)) {
1370 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1371 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1376 '@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';
1379 if (!empty($sortfield) && !empty($sortorder)) {
1384 print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0);
1386 print
'</td><td class="left">';
1387 if ($fichinter_static->fk_project > 0) {
1388 $project->fetch($fichinter_static->fk_project);
1389 print $project->getNomUrl(1);
1397 print
'<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).
'</td>'.
"\n";
1398 print
'<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).
'</td>'.
"\n";
1417 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1418 $sql =
'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1419 $sql .=
', f.total_ht';
1420 $sql .=
', f.total_tva';
1421 $sql .=
', f.total_ttc';
1422 $sql .=
', f.datec as dc';
1423 $sql .=
', f.date_last_gen, f.date_when';
1424 $sql .=
', f.frequency';
1425 $sql .=
', f.unit_frequency';
1426 $sql .=
', f.suspended as suspended';
1427 $sql .=
', s.nom, s.rowid as socid';
1428 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_rec as f";
1429 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1430 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1431 $sql .=
' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1432 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1433 $sql .=
' f.suspended, f.date_when,';
1434 $sql .=
' s.nom, s.rowid';
1435 $sql .=
" ORDER BY f.date_last_gen, f.datec DESC";
1437 $resql = $db->query($sql);
1441 $num = $db->num_rows($resql);
1443 print
'<div class="div-table-responsive-no-min">';
1444 print
'<table class="noborder centpercent lastrecordtable">';
1445 print
'<tr class="liste_titre">';
1450 print
'<td colspan="'.$colspan.
'">';
1451 print
'<table class="centpercent nobordernopadding"><tr>';
1452 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>';
1453 print
'</tr></table>';
1459 while ($i < $num && $i < $MAXLIST) {
1460 $objp = $db->fetch_object($resql);
1462 $invoicetemplate->id = $objp->id;
1463 $invoicetemplate->ref = $objp->ref;
1464 $invoicetemplate->fk_project = $objp->fk_projet;
1465 $invoicetemplate->suspended = $objp->suspended;
1466 $invoicetemplate->frequency = $objp->frequency;
1467 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1468 $invoicetemplate->total_ht = $objp->total_ht;
1469 $invoicetemplate->total_tva = $objp->total_tva;
1470 $invoicetemplate->total_ttc = $objp->total_ttc;
1471 $invoicetemplate->date_last_gen = $objp->date_last_gen;
1472 $invoicetemplate->date_when = $objp->date_when;
1474 print
'<tr class="oddeven">';
1475 print
'<td class="tdoverflowmax250">';
1476 print $invoicetemplate->getNomUrl(1);
1477 print
'</td><td class="left">';
1478 if ($invoicetemplate->fk_project > 0) {
1479 $project->fetch($invoicetemplate->fk_project);
1480 print $project->getNomUrl(1);
1484 if ($objp->frequency && $objp->date_last_gen > 0) {
1485 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
1487 if ($objp->dc > 0) {
1488 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
1490 print
'<td class="right"><b>!!!</b></td>';
1493 print
'<td class="right nowraponall">';
1494 print
price($objp->total_ht);
1498 print
'<td class="right nowraponall">';
1499 print
price($objp->total_ttc);
1503 print
'<td class="nowrap right" style="min-width: 60px">';
1504 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
1505 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1524 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1525 $sql =
'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1526 $sql .=
', f.total_ht';
1527 $sql .=
', f.total_tva';
1528 $sql .=
', f.total_ttc';
1529 $sql .=
', f.entity';
1530 $sql .=
', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status';
1531 $sql .=
', s.nom, s.rowid as socid';
1532 $sql .=
', SUM(pf.amount) as am';
1533 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
1534 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON f.rowid=pf.fk_facture';
1535 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1536 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1537 $sql .=
' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1538 $sql .=
' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1539 $sql .=
' s.nom, s.rowid';
1540 $sql .=
" ORDER BY f.datef DESC, f.datec DESC";
1542 $resql = $db->query($sql);
1544 $facturestatic =
new Facture($db);
1546 $num = $db->num_rows($resql);
1548 print
'<div class="div-table-responsive-no-min">';
1549 print
'<table class="noborder centpercent lastrecordtable">';
1550 print
'<tr class="liste_titre">';
1558 print
'<td colspan="'.$colspan.
'">';
1559 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>';
1560 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>';
1561 print
'</tr></table>';
1567 while ($i < $num && $i < $MAXLIST) {
1568 $objp = $db->fetch_object($resql);
1570 $facturestatic->id = $objp->facid;
1571 $facturestatic->ref = $objp->ref;
1572 $facturestatic->ref_client = $objp->ref_client;
1573 $facturestatic->fk_project = $objp->fk_projet;
1574 $facturestatic->type = $objp->type;
1575 $facturestatic->total_ht = $objp->total_ht;
1576 $facturestatic->total_tva = $objp->total_tva;
1577 $facturestatic->total_ttc = $objp->total_ttc;
1578 $facturestatic->statut = $objp->status;
1579 $facturestatic->status = $objp->status;
1580 $facturestatic->paye = $objp->paye;
1581 $facturestatic->alreadypaid = $objp->am;
1582 $facturestatic->totalpaid = $objp->am;
1583 $facturestatic->date = $db->jdate($objp->df);
1584 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1586 print
'<tr class="oddeven">';
1587 print
'<td class="nowraponall">';
1588 print $facturestatic->getNomUrl(1);
1592 if (!empty($filedir)) {
1595 if (is_array($file_list) && !empty($file_list)) {
1599 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1600 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1605 '@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';
1608 if (!empty($sortfield) && !empty($sortorder)) {
1613 print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0);
1615 print
'</td><td class="left">';
1616 if ($facturestatic->fk_project > 0) {
1617 $project->fetch($facturestatic->fk_project);
1618 print $project->getNomUrl(1);
1626 print
'<td class="left nowraponall">';
1627 print $objp->ref_client;
1630 if ($objp->df > 0) {
1631 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateInvoice')).
'">'.
dol_print_date($db->jdate($objp->df),
'day').
'</td>';
1633 print
'<td><b>!!!</b></td>';
1635 if ($objp->dl > 0) {
1636 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateMaxPayment')).
'">'.
dol_print_date($db->jdate($objp->dl),
'day').
'</td>';
1638 print
'<td><b>!!!</b></td>';
1641 print
'<td class="right nowraponall">';
1642 print
price($objp->total_ht);
1646 print
'<td class="right nowraponall">';
1647 print
price($objp->total_ttc);
1651 print
'<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).
'</td>';
1667 $parameters = array();
1668 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters,
$object, $action);
1672 print $hookmanager->resPrint;
1675 print
'</div></div>';
1676 print
'<div class="clearboth"></div>';
1684 print
'<div class="tabsAction">';
1686 $parameters = array();
1687 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1689 if (empty($reshook)) {
1691 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"ThirdPartyIsClosed").
'</a></div>';
1694 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer') &&
$object->status == 1) {
1695 $langs->load(
"propal");
1696 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>';
1699 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'creer') &&
$object->status == 1) {
1700 $langs->load(
"orders");
1701 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>';
1704 if ($user->hasRight(
'contrat',
'creer') &&
$object->status == 1) {
1705 $langs->load(
"contracts");
1706 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>';
1709 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer') &&
$object->status == 1) {
1710 $langs->load(
"interventions");
1711 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>';
1715 if ($user->socid == 0) {
1716 if (isModEnabled(
'deplacement') &&
$object->status == 1) {
1717 $langs->load(
"trips");
1718 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>';
1721 if (isModEnabled(
'invoice') &&
$object->status == 1) {
1722 if (!$user->hasRight(
'facture',
'creer')) {
1723 $langs->load(
"bills");
1724 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1726 $langs->loadLangs(array(
"orders",
"bills"));
1728 if (isModEnabled(
'order')) {
1730 if (!empty($orders2invoice) && $orders2invoice > 0) {
1731 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>';
1733 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1736 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1741 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>';
1743 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1751 if ($user->hasRight(
'agenda',
'myactions',
'create')) {
1752 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>';
1754 print
'<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddAction").
'</a></div>';
1776 $langs->load(
"errors");
1777 print $langs->trans(
'ErrorRecordNotFound');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
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.
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.
completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
Complete $filearray with data from database.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Show tabs of a record.
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.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
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.
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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'.
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($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.