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',
'commercial'));
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) {
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>';
384 print
'<tr><td>'.$langs->trans(
"Prefix").
'</td><td>';
390 $langs->loadLangs(array(
"compta",
"accountancy"));
393 print $langs->trans(
'CustomerCode').
'</td><td>';
395 $tmpcheck =
$object->check_codeclient();
396 if ($tmpcheck != 0 && $tmpcheck != -5) {
397 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
401 if (isModEnabled(
'accounting')) {
406 print $form->editfieldkey(
"CustomerAccountancyCodeGeneral",
'customeraccountancycodegeneral',
length_accountg(
$object->accountancy_code_customer_general),
$object, $permissiontoadd);
408 if ($action ==
'editcustomeraccountancycodegeneral' && $permissiontoadd) {
409 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_customer_general,
'customeraccountancycodegeneral', 0, 1,
'', 1);
411 if (
$object->accountancy_code_customer_general > 0) {
413 $accountingaccount->fetch(0,
$object->accountancy_code_customer_general, 1);
415 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
418 if (
$object->accountancy_code_customer_general > 0) {
421 $accountingAccountByDefault =
'<span class="opacitymedium">' . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')) .
'</span>';
422 print $accountingAccountByDefault;
431 print $form->editfieldkey(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client,
$object, $permissiontoadd);
433 print $form->editfieldval(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client,
$object, $permissiontoadd);
453 if ($mysoc->country_code ==
'ES') {
455 if ($mysoc->localtax1_assuj ==
"1") {
456 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
460 if ($mysoc->localtax1_assuj ==
"1") {
461 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
468 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
473 $langs->load(
'bills');
475 print
'<table width="100%" class="nobordernopadding"><tr><td>';
476 print $langs->trans(
'PaymentConditions');
478 if (($action !=
'editconditions') && $permissiontoadd) {
479 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>';
481 print
'</tr></table>';
483 if ($action ==
'editconditions') {
484 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
486 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 0,
'', 1,
$object->deposit_percent);
492 print
'<tr><td class="nowrap">';
493 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
494 print $langs->trans(
'PaymentMode');
496 if (($action !=
'editmode') && $permissiontoadd) {
497 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>';
499 print
'</tr></table>';
501 if ($action ==
'editmode') {
502 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
504 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
509 if (isModEnabled(
"bank")) {
511 print
'<tr><td class="nowrap">';
512 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
513 print $langs->trans(
'PaymentBankAccount');
515 if (($action !=
'editbankaccount') && $permissiontoadd) {
516 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>';
518 print
'</tr></table>';
520 if ($action ==
'editbankaccount') {
521 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
523 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'none');
533 print
'<tr><td class="nowrap">';
534 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
535 print $langs->trans(
"CustomerRelativeDiscountShort");
536 print
'<td><td class="right">';
537 if ($permissiontoadd && !$user->socid > 0) {
538 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>';
540 print
'</td></tr></table>';
541 print
'</td><td>'.($object->remise_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_percent.
'%</a>' :
'').
'</td>';
545 print
'<tr><td class="nowrap">';
546 print
'<table width="100%" class="nobordernopadding">';
547 print
'<tr><td class="nowrap">';
548 print $langs->trans(
"CustomerAbsoluteDiscountShort");
549 print
'<td><td class="right">';
550 if ($permissiontoadd && !$user->socid > 0) {
551 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>';
553 print
'</td></tr></table>';
556 $amount_discount =
$object->getAvailableDiscounts();
557 if ($amount_discount < 0) {
560 if ($amount_discount > 0) {
561 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>';
568 $limit_field_type =
'';
571 print
'<tr class="nowrap">';
573 print $form->editfieldkey(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit,
$object, $permissiontoadd);
575 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
576 print $form->editfieldval(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit,
$object, $permissiontoadd, $limit_field_type, (
$object->outstanding_limit !=
'' ?
price(
$object->outstanding_limit) :
''));
583 print
'<!-- Minimum amount for orders -->'.
"\n";
584 print
'<tr class="nowrap">';
586 print $form->editfieldkey(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount,
$object, $permissiontoadd);
588 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) :
''));
597 print
'<tr><td class="nowrap">';
598 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
599 print $langs->trans(
"PriceLevel");
600 print
'<td><td class="right">';
601 if ($permissiontoadd) {
602 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/multiprix.php?id='.
$object->id.
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
604 print
'</td></tr></table>';
607 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
617 $langs->load(
'stocks');
618 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
620 print
'<tr class="nowrap">';
622 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, $permissiontoadd);
624 if ($action ==
'editwarehouse') {
625 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'fk_warehouse', 1);
627 if (
$object->fk_warehouse > 0) {
628 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
630 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'none');
638 print
'<tr><td class="nowrap">';
639 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
640 print $langs->trans(
'SendingMethod');
642 if (($action !=
'editshipping') && $permissiontoadd) {
643 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>';
645 print
'</tr></table>';
647 if ($action ==
'editshipping') {
648 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
650 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->shipping_method_id,
'none');
656 if (isModEnabled(
'intracommreport')) {
657 $langs->load(
"intracommreport");
660 print
'<tr><td class="nowrap">';
661 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
662 print $langs->trans(
'IntracommReportTransportMode');
664 if (($action !=
'edittransportmode') && $permissiontoadd) {
665 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>';
667 print
'</tr></table>';
669 if ($action ==
'edittransportmode') {
670 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'transport_mode_id', 1, 1);
672 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'none');
679 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
680 $langs->load(
"categories");
681 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
683 print $form->showCategories(
$object->id, Categorie::TYPE_CUSTOMER, 1);
688 $parameters = array(
'socid' =>
$object->id);
689 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
692 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
695 if (isModEnabled(
'member')) {
696 $langs->load(
"members");
697 $langs->load(
"users");
699 print
'<tr><td class="titlefield">'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
702 $result = $adh->fetch(0,
'',
$object->id);
704 $adh->ref = $adh->getFullName($langs);
705 print $adh->getNomUrl(-1);
707 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
715 print
'</div><div class="fichehalfright">';
719 print
'<div class="underbanner clearboth"></div>';
720 print
'<table class="border centpercent tableforfield">';
723 print
'<tr><td class="titlefield nowrap">';
724 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
725 print $langs->trans(
'ProspectLevel');
727 if ($action !=
'editlevel' && $permissiontoadd) {
728 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>';
730 print
'</tr></table>';
732 if ($action ==
'editlevel') {
733 $formcompany->form_prospect_level($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
int)
$object->fk_prospectlevel,
'prospect_level_id', 1);
735 print
$object->getLibProspLevel();
741 $object->loadCacheOfProspStatus();
742 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.
$object->getLibProspCommStatut(4,
$object->cacheprospectstatus[
$object->stcomm_id][
'label']);
743 print
' ';
744 print
'<div class="floatright">';
745 foreach (
$object->cacheprospectstatus as $key => $val) {
746 $titlealt =
'default';
747 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
748 $titlealt = $val[
'label'];
750 if (
$object->stcomm_id != $val[
'id']) {
751 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>';
754 print
'</div></td></tr>';
759 print
'<div class="underbanner underbanner-before-box clearboth"></div><br>';
768 $boxstat .=
'<div class="box divboxtable box-halfright">';
769 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop boxtablenomarginbottom centpercent">';
770 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
772 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
774 $tmp =
$object->getOutstandingProposals();
775 $outstandingOpened = $tmp[
'opened'];
776 $outstandingTotal = $tmp[
'total_ht'];
777 $outstandingTotalIncTax = $tmp[
'total_ttc'];
778 $text = $langs->trans(
"OverAllProposals");
779 $link = DOL_URL_ROOT.
'/comm/propal/list.php?socid='.
$object->id;
782 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
784 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
785 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
786 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
787 $boxstat .=
'</div>';
793 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
795 $tmp =
$object->getOutstandingOrders();
796 $outstandingOpened = $tmp[
'opened'];
797 $outstandingTotal = $tmp[
'total_ht'];
798 $outstandingTotalIncTax = $tmp[
'total_ttc'];
799 $text = $langs->trans(
"OverAllOrders");
800 $link = DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->id;
803 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
805 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
806 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
807 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
808 $boxstat .=
'</div>';
814 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
816 $tmp =
$object->getOutstandingBills(
'customer', 0);
817 $outstandingOpened = $tmp[
'opened'];
818 $outstandingTotal = $tmp[
'total_ht'];
819 $outstandingTotalIncTax = $tmp[
'total_ttc'];
821 $text = $langs->trans(
"OverAllInvoices");
822 $link = DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->id;
825 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
827 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
828 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
829 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
830 $boxstat .=
'</div>';
837 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpened) {
838 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
840 $text = $langs->trans(
"CurrentOutstandingBill");
841 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
844 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
846 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
847 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
848 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
849 $boxstat .=
'</div>';
854 $tmp =
$object->getOutstandingBills(
'customer', 1);
855 $outstandingOpenedLate = $tmp[
'opened'];
856 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
858 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpenedLate) {
859 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
861 $text = $langs->trans(
"CurrentOutstandingBillLate");
862 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
865 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
867 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
868 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
869 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
870 $boxstat .=
'</div>';
877 $parameters = array();
878 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', $parameters,
$object, $action);
879 if (empty($reshook)) {
880 $boxstat .= $hookmanager->resPrint;
883 $boxstat .=
'</td></tr>';
884 $boxstat .=
'</table>';
885 $boxstat .=
'</div>';
893 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
894 $langs->load(
"propal");
896 $sql =
"SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_projet, p.fk_statut, p.total_ht";
897 $sql .=
", p.total_tva";
898 $sql .=
", p.total_ttc";
899 $sql .=
", p.ref, p.ref_client, p.remise";
900 $sql .=
", p.datep as dp, p.fin_validite as date_limit, p.entity";
901 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
902 $sql .=
" WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
903 $sql .=
" AND s.rowid = ".((int)
$object->id);
904 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
905 $sql .=
" ORDER BY p.datep DESC";
907 $resql = $db->query($sql);
909 $propal_static =
new Propal($db);
911 $num = $db->num_rows($resql);
913 print
'<div class="div-table-responsive-no-min">';
914 print
'<table class="noborder centpercent lastrecordtable">';
916 print
'<tr class="liste_titre">';
917 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>';
918 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>';
919 print
'</tr></table></td>';
924 while ($i < $num && $i < $MAXLIST) {
925 $objp = $db->fetch_object($resql);
927 print
'<tr class="oddeven">';
928 print
'<td class="nowraponall">';
929 $propal_static->id = $objp->propalid;
930 $propal_static->ref = $objp->ref;
931 $propal_static->ref_client = $objp->ref_client;
932 $propal_static->ref_customer = $objp->ref_client;
933 $propal_static->fk_project = $objp->fk_projet;
934 $propal_static->total_ht = $objp->total_ht;
935 $propal_static->total_tva = $objp->total_tva;
936 $propal_static->total_ttc = $objp->total_ttc;
937 print $propal_static->getNomUrl(1);
942 if (!empty($filedir)) {
945 if (is_array($file_list) && !empty($file_list)) {
949 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
950 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
955 '@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';
958 if (!empty($sortfield) && !empty($sortorder)) {
963 print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0,
'entity=' . $objp->entity);
965 print
'</td><td class="tdoverflowmax125">';
966 if ($propal_static->fk_project > 0) {
967 $project->fetch($propal_static->fk_project);
968 print $project->getNomUrl(1);
974 if (($db->jdate($objp->date_limit) < ($now -
$conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
975 print
" ".img_warning();
977 print
'</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
978 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
979 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).
'</td></tr>';
993 $orders2invoice =
null;
998 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
999 $sql =
"SELECT s.nom, s.rowid";
1000 $sql .=
", c.rowid as cid, c.entity, c.fk_projet, c.total_ht";
1001 $sql .=
", c.total_tva";
1002 $sql .=
", c.total_ttc";
1003 $sql .=
", c.ref, c.ref_client, c.fk_statut, c.facture";
1004 $sql .=
", c.date_commande as dc";
1005 $sql .=
", c.facture as billed";
1006 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
1007 $sql .=
" WHERE c.fk_soc = s.rowid ";
1008 $sql .=
" AND s.rowid = ".((int)
$object->id);
1009 $sql .=
" AND c.entity IN (".getEntity(
'commande').
')';
1010 $sql .=
" ORDER BY c.date_commande DESC";
1012 $resql = $db->query($sql);
1014 $commande_static =
new Commande($db);
1016 $num = $db->num_rows($resql);
1019 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
1020 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
1021 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
1022 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande as c';
1023 $sql2 .=
' WHERE c.fk_soc = s.rowid';
1024 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
1026 $sql2 .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
1028 $resql2 = $db->query($sql2);
1029 $orders2invoice = $db->num_rows($resql2);
1032 print
'<div class="div-table-responsive-no-min">';
1033 print
'<table class="noborder centpercent lastrecordtable">';
1035 print
'<tr class="liste_titre">';
1036 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>';
1037 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>';
1038 print
'</tr></table></td>';
1043 while ($i < $num && $i < $MAXLIST) {
1044 $objp = $db->fetch_object($resql);
1046 $commande_static->id = $objp->cid;
1047 $commande_static->ref = $objp->ref;
1048 $commande_static->ref_client = $objp->ref_client;
1049 $commande_static->fk_project = $objp->fk_projet;
1050 $commande_static->total_ht = $objp->total_ht;
1051 $commande_static->total_tva = $objp->total_tva;
1052 $commande_static->total_ttc = $objp->total_ttc;
1053 $commande_static->billed = $objp->billed;
1055 print
'<tr class="oddeven">';
1056 print
'<td class="nowraponall">';
1057 print $commande_static->getNomUrl(1);
1061 if (!empty($filedir)) {
1064 if (is_array($file_list) && !empty($file_list)) {
1068 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1069 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1074 '@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';
1077 if (!empty($sortfield) && !empty($sortorder)) {
1082 print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0,
'entity=' . $objp->entity);
1084 print
'</td><td class="tdoverflowmax125">';
1085 if ($commande_static->fk_project > 0) {
1086 $project->fetch($commande_static->fk_project);
1087 print $project->getNomUrl(1);
1095 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
"</td>\n";
1096 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
1097 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).
'</td></tr>';
1114 if (isModEnabled(
"shipping") && $user->hasRight(
'expedition',
'lire')) {
1117 $sql =
'SELECT e.rowid as id';
1118 $sql .=
', e.ref, e.entity, e.fk_projet';
1119 $sql .=
', e.date_creation';
1120 $sql .=
', e.fk_statut as statut';
1122 $sql .=
', s.rowid as socid';
1123 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"expedition as e";
1124 $sql .=
" WHERE e.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1125 $sql .=
" AND e.entity IN (".getEntity(
'expedition').
")";
1126 $sql .=
' GROUP BY e.rowid';
1127 $sql .=
', e.ref, e.entity, e.fk_projet';
1128 $sql .=
', e.date_creation';
1129 $sql .=
', e.fk_statut';
1131 $sql .=
', s.rowid';
1132 $sql .=
" ORDER BY e.date_creation DESC";
1134 $resql = $db->query($sql);
1138 $num = $db->num_rows($resql);
1140 print
'<div class="div-table-responsive-no-min">';
1141 print
'<table class="noborder centpercent lastrecordtable">';
1143 print
'<tr class="liste_titre">';
1144 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>';
1145 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>';
1146 print
'</tr></table></td>';
1151 while ($i < $num && $i < $MAXLIST) {
1152 $objp = $db->fetch_object($resql);
1154 $param =
'entity=' . ((int) $objp->entity);
1156 $sendingstatic->id = $objp->id;
1157 $sendingstatic->ref = $objp->ref;
1158 $sendingstatic->fk_project = $objp->fk_projet;
1160 print
'<tr class="oddeven">';
1161 print
'<td class="nowraponall">';
1162 print $sendingstatic->getNomUrl(1);
1166 if (!empty($filedir)) {
1169 if (is_array($file_list) && !empty($file_list)) {
1173 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1174 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1179 '@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';
1182 if (!empty($sortfield) && !empty($sortorder)) {
1188 print $formfile->showPreview($file_list, $sendingstatic->element, $relativepath, 0, $param);
1190 print
'</td><td class="tdoverflowmax125">';
1191 if ($sendingstatic->fk_project > 0) {
1192 $project->fetch($sendingstatic->fk_project);
1193 print $project->getNomUrl(1);
1200 if ($objp->date_creation > 0) {
1201 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
1203 print
'<td class="right"><b>!!!</b></td>';
1206 print
'<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
1224 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1225 $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,";
1226 $sql .=
" c.last_main_doc, c.model_pdf";
1227 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
1228 $sql .=
" WHERE c.fk_soc = s.rowid ";
1229 $sql .=
" AND s.rowid = ".((int)
$object->id);
1230 $sql .=
" AND c.entity IN (".getEntity(
'contract').
")";
1231 $sql .=
" ORDER BY c.datec DESC";
1233 $resql = $db->query($sql);
1237 $num = $db->num_rows($resql);
1239 print
'<div class="div-table-responsive-no-min">';
1240 print
'<table class="noborder centpercent lastrecordtable">';
1242 print
'<tr class="liste_titre">';
1243 print
'<td colspan="6"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans(
"LastContracts", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
1244 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>';
1246 print
'</tr></table></td>';
1251 while ($i < $num && $i < $MAXLIST) {
1252 $objp = $db->fetch_object($resql);
1254 $contrat->id = $objp->id;
1255 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1256 $contrat->ref_customer = $objp->refcus;
1257 $contrat->ref_supplier = $objp->refsup;
1258 $contrat->fk_project = $objp->fk_projet;
1259 $contrat->statut = $objp->contract_status;
1260 $contrat->status = $objp->contract_status;
1261 $contrat->last_main_doc = $objp->last_main_doc;
1262 $contrat->model_pdf = $objp->model_pdf;
1263 $contrat->fetch_lines();
1266 foreach ($contrat->lines as $line) {
1267 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1268 if (((!empty($line->date_end) ? $line->date_end : 0) +
$conf->contract->services->expires->warning_delay) < $now) {
1274 print
'<tr class="oddeven">';
1275 print
'<td class="nowraponall">';
1276 print $contrat->getNomUrl(1, 12);
1277 if (!empty($contrat->model_pdf)) {
1281 if (!empty($filedir)) {
1284 if (is_array($file_list) && !empty($file_list)) {
1288 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1289 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1294 '@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';
1297 if (!empty($sortfield) && !empty($sortorder)) {
1302 print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0,
'entity=' . $objp->entity);
1310 print
'</td><td class="tdoverflowmax125">';
1311 if ($contrat->fk_project > 0) {
1312 $project->fetch($contrat->fk_project);
1313 print $project->getNomUrl(1);
1316 print
'<td class="nowrap">';
1317 print
dol_trunc(strtolower(get_class(
$object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1320 print
'<td class="right" width="80px"><span title="'.$langs->trans(
"DateContract").
'">'.
dol_print_date($db->jdate($objp->dcon),
'day').
"</span></td>\n";
1321 print
'<td width="20"> </td>';
1322 print
'<td class="nowraponall right">';
1323 print $contrat->getLibStatut(4);
1342 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'lire')) {
1343 $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";
1344 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"fichinter as f";
1345 $sql .=
" WHERE f.fk_soc = s.rowid";
1346 $sql .=
" AND s.rowid = ".((int)
$object->id);
1347 $sql .=
" AND f.entity IN (".getEntity(
'intervention').
")";
1348 $sql .=
" ORDER BY f.tms DESC";
1350 $resql = $db->query($sql);
1354 $num = $db->num_rows($resql);
1356 print
'<div class="div-table-responsive-no-min">';
1357 print
'<table class="noborder centpercent lastrecordtable">';
1359 print
'<tr class="liste_titre">';
1360 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>';
1361 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>';
1362 print
'</tr></table></td>';
1367 while ($i < $num && $i < $MAXLIST) {
1368 $objp = $db->fetch_object($resql);
1370 $fichinter_static->id = $objp->id;
1371 $fichinter_static->ref = $objp->ref;
1372 $fichinter_static->statut = $objp->fk_statut;
1373 $fichinter_static->status = $objp->fk_statut;
1374 $fichinter_static->fk_project = $objp->fk_projet;
1376 print
'<tr class="oddeven">';
1377 print
'<td class="nowraponall">';
1378 print $fichinter_static->getNomUrl(1);
1382 if (!empty($filedir)) {
1385 if (is_array($file_list) && !empty($file_list)) {
1389 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1390 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1395 '@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';
1398 if (!empty($sortfield) && !empty($sortorder)) {
1403 print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0,
'entity=' . $objp->entity);
1405 print
'</td><td class="tdoverflowmax125">';
1406 if ($fichinter_static->fk_project > 0) {
1407 $project->fetch($fichinter_static->fk_project);
1408 print $project->getNomUrl(1);
1416 print
'<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).
'</td>'.
"\n";
1417 print
'<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).
'</td>'.
"\n";
1436 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1437 $sql =
'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1438 $sql .=
', f.total_ht';
1439 $sql .=
', f.total_tva';
1440 $sql .=
', f.total_ttc';
1441 $sql .=
', f.datec as dc';
1442 $sql .=
', f.date_last_gen, f.date_when';
1443 $sql .=
', f.frequency';
1444 $sql .=
', f.unit_frequency';
1445 $sql .=
', f.suspended as suspended';
1446 $sql .=
', s.nom, s.rowid as socid';
1447 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_rec as f";
1448 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1449 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1450 $sql .=
' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1451 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1452 $sql .=
' f.suspended, f.date_when,';
1453 $sql .=
' s.nom, s.rowid';
1454 $sql .=
" ORDER BY f.date_last_gen, f.datec DESC";
1456 $resql = $db->query($sql);
1460 $num = $db->num_rows($resql);
1462 print
'<div class="div-table-responsive-no-min">';
1463 print
'<table class="noborder centpercent lastrecordtable">';
1464 print
'<tr class="liste_titre">';
1469 print
'<td colspan="'.$colspan.
'">';
1470 print
'<table class="centpercent nobordernopadding"><tr>';
1471 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>';
1472 print
'</tr></table>';
1478 while ($i < $num && $i < $MAXLIST) {
1479 $objp = $db->fetch_object($resql);
1481 $invoicetemplate->id = $objp->id;
1482 $invoicetemplate->ref = $objp->ref;
1483 $invoicetemplate->fk_project = $objp->fk_projet;
1484 $invoicetemplate->suspended = $objp->suspended;
1485 $invoicetemplate->frequency = $objp->frequency;
1486 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1487 $invoicetemplate->total_ht = $objp->total_ht;
1488 $invoicetemplate->total_tva = $objp->total_tva;
1489 $invoicetemplate->total_ttc = $objp->total_ttc;
1490 $invoicetemplate->date_last_gen = $objp->date_last_gen;
1491 $invoicetemplate->date_when = $objp->date_when;
1493 print
'<tr class="oddeven">';
1494 print
'<td class="tdoverflowmax250">';
1495 print $invoicetemplate->getNomUrl(1);
1496 print
'</td><td class="tdoverflowmax125">';
1497 if ($invoicetemplate->fk_project > 0) {
1498 $project->fetch($invoicetemplate->fk_project);
1499 print $project->getNomUrl(1);
1503 if ($objp->frequency && $objp->date_last_gen > 0) {
1504 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
1506 if ($objp->dc > 0) {
1507 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
1509 print
'<td class="right"><b>!!!</b></td>';
1512 print
'<td class="right nowraponall">';
1513 print
price($objp->total_ht);
1517 print
'<td class="right nowraponall">';
1518 print
price($objp->total_ttc);
1522 print
'<td class="nowrap right" style="min-width: 60px">';
1523 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
1524 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1543 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1544 $sql =
'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1545 $sql .=
', f.total_ht';
1546 $sql .=
', f.total_tva';
1547 $sql .=
', f.total_ttc';
1548 $sql .=
', f.entity';
1549 $sql .=
', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status';
1550 $sql .=
', s.nom, s.rowid as socid';
1551 $sql .=
', SUM(pf.amount) as am';
1552 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
1553 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON f.rowid=pf.fk_facture';
1554 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1555 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1556 $sql .=
' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1557 $sql .=
' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1558 $sql .=
' s.nom, s.rowid';
1559 $sql .=
" ORDER BY f.datef DESC, f.datec DESC";
1561 $resql = $db->query($sql);
1563 $facturestatic =
new Facture($db);
1565 $num = $db->num_rows($resql);
1567 print
'<div class="div-table-responsive-no-min">';
1568 print
'<table class="noborder centpercent lastrecordtable">';
1569 print
'<tr class="liste_titre">';
1577 print
'<td colspan="'.$colspan.
'">';
1578 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>';
1579 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>';
1580 print
'</tr></table>';
1586 while ($i < $num && $i < $MAXLIST) {
1587 $objp = $db->fetch_object($resql);
1589 $facturestatic->id = $objp->facid;
1590 $facturestatic->ref = $objp->ref;
1591 $facturestatic->ref_client = $objp->ref_client;
1592 $facturestatic->fk_project = $objp->fk_projet;
1593 $facturestatic->type = $objp->type;
1594 $facturestatic->total_ht = $objp->total_ht;
1595 $facturestatic->total_tva = $objp->total_tva;
1596 $facturestatic->total_ttc = $objp->total_ttc;
1597 $facturestatic->statut = $objp->status;
1598 $facturestatic->status = $objp->status;
1599 $facturestatic->paye = $objp->paye;
1600 $facturestatic->alreadypaid = $objp->am;
1601 $facturestatic->totalpaid = $objp->am;
1602 $facturestatic->date = $db->jdate($objp->df);
1603 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1605 print
'<tr class="oddeven">';
1606 print
'<td class="nowraponall">';
1607 print $facturestatic->getNomUrl(1);
1611 if (!empty($filedir)) {
1614 if (is_array($file_list) && !empty($file_list)) {
1618 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1619 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1624 '@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';
1627 if (!empty($sortfield) && !empty($sortorder)) {
1632 print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0,
'entity=' . $objp->entity);
1634 print
'</td><td class="tdoverflowmax125">';
1635 if ($facturestatic->fk_project > 0) {
1636 $project->fetch($facturestatic->fk_project);
1637 print $project->getNomUrl(1);
1645 print
'<td class="nowraponall">';
1649 if ($objp->df > 0) {
1650 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateInvoice')).
'">'.
dol_print_date($db->jdate($objp->df),
'day').
'</td>';
1652 print
'<td><b>!!!</b></td>';
1654 if ($objp->dl > 0) {
1655 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateMaxPayment')).
'">'.
dol_print_date($db->jdate($objp->dl),
'day').
'</td>';
1657 print
'<td><b>!!!</b></td>';
1660 print
'<td class="right nowraponall">';
1661 print
price($objp->total_ht);
1665 print
'<td class="right nowraponall">';
1666 print
price($objp->total_ttc);
1670 print
'<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).
'</td>';
1686 $parameters = array();
1687 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters,
$object, $action);
1691 print $hookmanager->resPrint;
1694 print
'</div></div>';
1695 print
'<div class="clearboth"></div>';
1703 print
'<div class="tabsAction">';
1705 $parameters = array();
1706 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1708 if (empty($reshook)) {
1710 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"ThirdPartyIsClosed").
'</a></div>';
1713 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer') &&
$object->status == 1) {
1714 $langs->load(
"propal");
1715 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>';
1718 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'creer') &&
$object->status == 1) {
1719 $langs->load(
"orders");
1720 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>';
1723 if ($user->hasRight(
'contrat',
'creer') &&
$object->status == 1) {
1724 $langs->load(
"contracts");
1725 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>';
1728 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer') &&
$object->status == 1) {
1729 $langs->load(
"interventions");
1730 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 if (isModEnabled(
'deplacement') &&
$object->status == 1) {
1735 $langs->load(
"trips");
1736 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 (isModEnabled(
'invoice') &&
$object->status == 1) {
1740 if (!$user->hasRight(
'facture',
'creer')) {
1741 $langs->load(
"bills");
1742 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1744 $langs->loadLangs(array(
"orders",
"bills"));
1747 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>';
1749 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 (isModEnabled(
'invoice') &&
$object->status == 1) {
1755 if ($user->hasRight(
'facture',
'creer')) {
1756 if (isModEnabled(
'order')) {
1758 if (!empty($orders2invoice) && $orders2invoice > 0) {
1759 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>';
1761 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1764 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1772 if ($user->hasRight(
'agenda',
'myactions',
'create')) {
1773 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>';
1775 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( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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.
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_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.
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_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_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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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.