37require
'../main.inc.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
61 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
70 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
73 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
76 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
79 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
80 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
84$langs->loadLangs(array(
'companies',
'banks',
'commercial'));
87 $langs->load(
"contracts");
90 $langs->load(
"orders");
93 $langs->load(
"sendings");
96 $langs->load(
"bills");
99 $langs->load(
"projects");
102 $langs->load(
"interventions");
105 $langs->load(
"mails");
108$action =
GETPOST(
'action',
'aZ09');
113$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
114$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
116if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
120$offset = $limit * $page;
121$pageprev = $page - 1;
122$pagenext = $page + 1;
129$cancel =
GETPOST(
'cancel',
'alpha');
135$extrafields->fetch_name_optionals_label(
$object->table_element);
138$hookmanager->initHooks(array(
'thirdpartycomm',
'globalcard'));
142if ($id > 0 && empty(
$object->id)) {
150 if (!(
$object->client > 0) || !$user->hasRight(
'societe',
'lire')) {
156if ($user->socid > 0) {
161$permissiontoadd = $user->hasRight(
'societe',
'creer');
162$permissiontoeditextra = $permissiontoadd;
163if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
165 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
174$parameters = array(
'id' => $id,
'socid' => $id);
175$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
177 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
180if (empty($reshook)) {
186 if ($action ==
'setcustomeraccountancycodegeneral' && $permissiontoadd) {
188 $object->accountancy_code_customer_general =
GETPOST(
"customeraccountancycodegeneral");
196 if ($action ==
'setcustomeraccountancycode' && $permissiontoadd) {
203 $action =
'editcustomeraccountancycode';
208 if ($action ==
'setconditions' && $permissiontoadd) {
217 if ($action ==
'setmode' && $permissiontoadd) {
226 if ($action ==
'settransportmode' && $permissiontoadd) {
235 if ($action ==
'setbankaccount' && $permissiontoadd) {
244 if ($action ==
'setshippingmethod' && $permissiontoadd) {
253 if ($action ==
'setassujtva' && $permissiontoadd) {
263 if ($action ==
'setprospectlevel' && $permissiontoadd) {
265 $object->fk_prospectlevel =
GETPOST(
'prospect_level_id',
'alpha');
273 if ($action ==
'setstcomm' && $permissiontoadd) {
285 if ($action ==
'setoutstanding_limit' && $permissiontoadd) {
295 if ($action ==
'setorder_min_amount' && $permissiontoadd) {
305 if ($action ==
'set_salesrepresentatives' && $permissiontoadd) {
310 if ($action ==
'update_extras' && $permissiontoeditextra) {
315 $attribute_name =
GETPOST(
'attribute',
'aZ09');
318 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
324 $result =
$object->updateExtraField($attribute_name,
'COMPANY_MODIFY');
332 $action =
'edit_extras';
337 if ($action ==
'setwarehouse' && $permissiontoadd) {
347$contactstatic =
new Contact($db);
348$userstatic =
new User($db);
349$form =
new Form($db);
353$title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Customer');
355 $title =
$object->name.
" - ".$langs->trans(
'Customer');
358$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
365 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), -1,
'company');
367 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
369 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
371 print
'<div class="fichecenter"><div class="fichehalfleft">';
373 print
'<div class="underbanner clearboth"></div>';
374 print
'<table class="border centpercent tableforfield">';
377 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
382 $langs->loadLangs(array(
"compta",
"accountancy"));
385 print $langs->trans(
'CustomerCode').
'</td><td>';
387 $tmpcheck =
$object->check_codeclient();
388 if ($tmpcheck != 0 && $tmpcheck != -5) {
389 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
398 print $form->editfieldkey(
"CustomerAccountancyCodeGeneral",
'customeraccountancycodegeneral',
length_accountg(
$object->accountancy_code_customer_general), $object, $permissiontoadd);
400 if ($action ==
'editcustomeraccountancycodegeneral' && $permissiontoadd) {
401 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_customer_general,
'customeraccountancycodegeneral', 0, 1,
'', 1);
403 if (
$object->accountancy_code_customer_general > 0) {
405 $accountingaccount->fetch(0,
$object->accountancy_code_customer_general, 1);
407 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
410 if (
$object->accountancy_code_customer_general > 0) {
413 $accountingAccountByDefault =
'<span class="opacitymedium">' . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')) .
'</span>';
414 print $accountingAccountByDefault;
423 print $form->editfieldkey(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client, $object, $permissiontoadd);
425 print $form->editfieldval(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client, $object, $permissiontoadd);
445 if (
$mysoc->country_code ==
'ES') {
447 if (
$mysoc->localtax1_assuj ==
"1") {
448 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td>';
449 print yn(
$object->localtax1_assuj);
452 if (
$mysoc->localtax1_assuj ==
"1") {
453 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td>';
454 print yn(
$object->localtax2_assuj);
460 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
465 $langs->load(
'bills');
467 print
'<table width="100%" class="nobordernopadding"><tr><td>';
468 print $langs->trans(
'PaymentConditions');
470 if (($action !=
'editconditions') && $permissiontoadd) {
471 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.
newToken().
'&socid='.
$object->id.
'">'.img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
473 print
'</tr></table>';
475 if ($action ==
'editconditions') {
476 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
478 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 0,
'', 1,
$object->deposit_percent);
484 print
'<tr><td class="nowrap">';
485 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
486 print $langs->trans(
'PaymentMode');
488 if (($action !=
'editmode') && $permissiontoadd) {
489 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&socid='.
$object->id.
'">'.img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
491 print
'</tr></table>';
493 if ($action ==
'editmode') {
494 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
496 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
503 print
'<tr><td class="nowrap">';
504 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
505 print $langs->trans(
'PaymentBankAccount');
507 if (($action !=
'editbankaccount') && $permissiontoadd) {
508 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.
newToken().
'&socid='.
$object->id.
'">'.img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
510 print
'</tr></table>';
512 if ($action ==
'editbankaccount') {
513 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
515 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'none');
525 print
'<tr><td class="nowrap">';
526 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
527 print $langs->trans(
"CustomerRelativeDiscountShort");
528 print
'<td><td class="right">';
529 if ($permissiontoadd && !$user->socid > 0) {
530 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create&token='.
newToken().
'">'.img_edit($langs->trans(
"Modify")).
'</a>';
532 print
'</td></tr></table>';
533 print
'</td><td>'.($object->remise_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_percent.
'%</a>' :
'').
'</td>';
537 print
'<tr><td class="nowrap">';
538 print
'<table width="100%" class="nobordernopadding">';
539 print
'<tr><td class="nowrap">';
540 print $langs->trans(
"CustomerAbsoluteDiscountShort");
541 print
'<td><td class="right">';
542 if ($permissiontoadd && !$user->socid > 0) {
543 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create_remise&token='.
newToken().
'">'.img_edit($langs->trans(
"Modify")).
'</a>';
545 print
'</td></tr></table>';
548 $amount_discount =
$object->getAvailableDiscounts();
549 if ($amount_discount < 0) {
550 dol_print_error($db,
$object->error);
552 if ($amount_discount > 0) {
553 print
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create&token='.
newToken().
'">'.
price($amount_discount, 1, $langs, 1, -1, -1,
$conf->currency).
'</a>';
560 $limit_field_type =
'';
563 print
'<tr class="nowrap">';
565 print $form->editfieldkey(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit, $object, $permissiontoadd);
568 $limit_field_type =
'amount';
569 print $form->editfieldval(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit, $object, $permissiontoadd, $limit_field_type, (
$object->outstanding_limit !=
'' ?
price(
$object->outstanding_limit) :
''));
576 print
'<!-- Minimum amount for orders -->'.
"\n";
577 print
'<tr class="nowrap">';
579 print $form->editfieldkey(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount, $object, $permissiontoadd);
581 print $form->editfieldval(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount, $object, $permissiontoadd, $limit_field_type, (
$object->order_min_amount !=
'' ?
price(
$object->order_min_amount) :
''));
590 print
'<tr><td class="nowrap">';
591 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
592 print $langs->trans(
"PriceLevel");
593 print
'<td><td class="right">';
594 if ($permissiontoadd) {
595 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/multiprix.php?id='.
$object->id.
'">'.img_edit($langs->trans(
"Modify")).
'</a>';
597 print
'</td></tr></table>';
600 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
610 $langs->load(
'stocks');
611 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
613 print
'<tr class="nowrap">';
615 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $permissiontoadd);
617 if ($action ==
'editwarehouse') {
618 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
int)
$object->fk_warehouse,
'fk_warehouse', 1);
620 if (
$object->fk_warehouse > 0) {
621 print img_picto(
'',
'stock',
'class="paddingrightonly"');
623 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
int)
$object->fk_warehouse,
'none');
631 print
'<tr><td class="nowrap">';
632 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
633 print $langs->trans(
'SendingMethod');
635 if (($action !=
'editshipping') && $permissiontoadd) {
636 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editshipping&token='.
newToken().
'&socid='.
$object->id.
'">'.img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
638 print
'</tr></table>';
640 if ($action ==
'editshipping') {
641 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
643 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->shipping_method_id,
'none');
650 $langs->load(
"intracommreport");
653 print
'<tr><td class="nowrap">';
654 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
655 print $langs->trans(
'IntracommReportTransportMode');
657 if (($action !=
'edittransportmode') && $permissiontoadd) {
658 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&socid='.
$object->id.
'">'.img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
660 print
'</tr></table>';
662 if ($action ==
'edittransportmode') {
663 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'transport_mode_id', 1, 1);
665 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'none');
672 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
673 $langs->load(
"categories");
674 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
676 print $form->showCategories(
$object->id, Categorie::TYPE_CUSTOMER, 1);
681 $parameters = array(
'socid' =>
$object->id);
682 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
685 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
689 $langs->load(
"members");
690 $langs->load(
"users");
692 print
'<tr><td class="titlefield">'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
695 $result = $adh->fetch(0,
'',
$object->id);
697 $adh->ref = $adh->getFullName($langs);
698 print $adh->getNomUrl(-1);
700 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
708 print
'</div><div class="fichehalfright">';
712 print
'<div class="underbanner clearboth"></div>';
713 print
'<table class="border centpercent tableforfield">';
716 print
'<tr><td class="titlefield nowrap">';
717 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
718 print $langs->trans(
'ProspectLevel');
720 if ($action !=
'editlevel' && $permissiontoadd) {
721 print
'<td class="right"><a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlevel&token='.
newToken().
'&socid='.
$object->id.
'">'.img_edit($langs->trans(
'Modify'), 1).
'</a></td>';
723 print
'</tr></table>';
725 if ($action ==
'editlevel') {
726 $formcompany->form_prospect_level($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
int)
$object->fk_prospectlevel,
'prospect_level_id', 1);
728 print
$object->getLibProspLevel();
734 $object->loadCacheOfProspStatus();
735 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.
$object->getLibProspCommStatut(4,
$object->cacheprospectstatus[
$object->stcomm_id][
'label']);
736 print
' ';
737 print
'<div class="floatright">';
738 foreach (
$object->cacheprospectstatus as $key => $val) {
739 $titlealt =
'default';
740 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
741 $titlealt = $val[
'label'];
743 if (
$object->stcomm_id != $val[
'id']) {
744 print
'<a class="pictosubstatus reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&stcomm='.$val[
'code'].
'&action=setstcomm&token='.
newToken().
'">'.
img_action($titlealt, $val[
'code'], $val[
'picto']).
'</a>';
747 print
'</div></td></tr>';
752 print
'<div class="underbanner underbanner-before-box clearboth"></div><br>';
761 $boxstat .=
'<div class="box divboxtable box-halfright">';
762 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop boxtablenomarginbottom centpercent">';
763 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
765 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
767 $tmp =
$object->getOutstandingProposals();
768 $outstandingOpened = $tmp[
'opened'];
769 $outstandingTotal = $tmp[
'total_ht'];
770 $outstandingTotalIncTax = $tmp[
'total_ttc'];
771 $text = $langs->trans(
"OverAllProposals");
772 $link = DOL_URL_ROOT.
'/comm/propal/list.php?socid='.
$object->id;
775 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
777 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
778 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
779 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
780 $boxstat .=
'</div>';
786 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
788 $tmp =
$object->getOutstandingOrders();
789 $outstandingOpened = $tmp[
'opened'];
790 $outstandingTotal = $tmp[
'total_ht'];
791 $outstandingTotalIncTax = $tmp[
'total_ttc'];
792 $text = $langs->trans(
"OverAllOrders");
793 $link = DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->id;
796 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
798 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
799 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
800 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
801 $boxstat .=
'</div>';
807 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
809 $tmp =
$object->getOutstandingBills(
'customer', 0);
810 $outstandingOpened = $tmp[
'opened'];
811 $outstandingTotal = $tmp[
'total_ht'];
812 $outstandingTotalIncTax = $tmp[
'total_ttc'];
814 $text = $langs->trans(
"OverAllInvoices");
815 $link = DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->id;
818 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
820 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
821 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
822 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
823 $boxstat .=
'</div>';
830 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpened) {
831 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
833 $text = $langs->transnoentitiesnoconv(
"CurrentOutstandingBill");
835 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
837 $boxstattmp =
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
838 $boxstattmp .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
839 $boxstattmp .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
840 $boxstattmp .=
'</div>';
844 $boxstat .= $boxstattmp;
847 $tmp =
$object->getOutstandingBills(
'customer', 1);
848 $outstandingOpenedLate = $tmp[
'opened'];
849 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
851 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpenedLate) {
852 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
854 $text = $langs->transnoentitiesnoconv(
"CurrentOutstandingBillLate");
856 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
858 $boxstattmp =
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
859 $boxstattmp .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
860 $boxstattmp .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
861 $boxstattmp .=
'</div>';
865 $boxstat .= $boxstattmp;
871 if (
isModEnabled(
'margin') && $user->hasRight(
'margin',
'liretous')) {
874 $sql .=
" sum(d.total_ht) as selling_price,";
875 $sql .=
" sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,";
876 $sql .=
" sum(d.total_ht - (".$db->ifsql(
'f.type = '.
Facture::TYPE_CREDIT_NOTE,
'-1',
'1').
" * (d.buy_price_ht * d.qty * (d.situation_percent / 100)))) as marge";
877 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
878 $sql .=
" ".MAIN_DB_PREFIX.
"facturedet as d";
879 $sql .=
" WHERE f.fk_soc = ".((int) $id);
880 $sql .=
" AND f.fk_statut > 0";
881 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
882 $sql .=
" AND d.fk_facture = f.rowid";
883 $sql .=
" AND d.buy_price_ht IS NOT NULL";
887 $sql .=
" AND d.buy_price_ht <> 0";
892 $resql = $db->query($sql);
894 $obj = $db->fetch_object($resql);
896 $marginTotal = $obj->marge;
900 $text = $langs->transnoentitiesnoconv(
"Margins");
902 $link = DOL_URL_ROOT.
'/margin/tabs/thirdpartyMargins.php?socid='.
$object->id;
904 $boxstattmp =
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
905 $boxstattmp .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
906 $boxstattmp .=
'<span class="boxstatsindicator">'.price($marginTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
907 $boxstattmp .=
'</div>';
911 $boxstat .= $boxstattmp;
916 $parameters = array();
917 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', $parameters, $object, $action);
918 if (empty($reshook)) {
919 $boxstat .= $hookmanager->resPrint;
922 $boxstat .=
'</td></tr>';
923 $boxstat .=
'</table>';
924 $boxstat .=
'</div>';
933 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
934 $propal_static =
new Propal($db);
935 $langs->load(
"propal");
937 $sql =
"SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_projet, p.fk_statut, p.total_ht";
938 $sql .=
", p.total_tva";
939 $sql .=
", p.total_ttc";
940 $sql .=
", p.ref, p.ref_client, p.remise";
941 $sql .=
", p.datep as dp, p.fin_validite as date_limit, p.entity, p.last_main_doc";
942 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
943 $sql .=
" WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
944 $sql .=
" AND s.rowid = ".((int)
$object->id);
945 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
946 $parameters = array();
947 $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propal_static);
948 $sql .= $hookmanager->resPrint;
949 $sql .=
" ORDER BY p.datep DESC";
951 $resql = $db->query($sql);
953 $num = $db->num_rows($resql);
955 print
'<div class="div-table-responsive-no-min">';
956 print
'<table class="noborder centpercent lastrecordtable">';
958 print
'<tr class="liste_titre">';
959 print
'<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
"LastPropals", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/comm/propal/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllPropals").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
960 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/comm/propal/stats/index.php?socid='.
$object->id.
'">'.img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
961 print
'</tr></table></td>';
966 while ($i < $num && $i < $MAXLIST) {
967 $objp = $db->fetch_object($resql);
969 print
'<tr class="oddeven">';
970 print
'<td class="nowraponall">';
971 $propal_static->id = $objp->propalid;
972 $propal_static->ref = $objp->ref;
973 $propal_static->ref_client = $objp->ref_client;
974 $propal_static->ref_customer = $objp->ref_client;
975 $propal_static->fk_project = $objp->fk_projet;
976 $propal_static->total_ht = $objp->total_ht;
977 $propal_static->total_tva = $objp->total_tva;
978 $propal_static->total_ttc = $objp->total_ttc;
979 $propal_static->last_main_doc = $objp->last_main_doc;
980 $propal_static->entity = $objp->entity;
981 print $propal_static->getNomUrl(1);
984 print $propal_static->showLastFilePreview();
985 print
'</td><td class="tdoverflowmax125">';
986 if ($propal_static->fk_project > 0) {
987 $project->fetch((
int) $propal_static->fk_project);
988 print $project->getNomUrl(1);
994 if (($db->jdate($objp->date_limit) < ($now -
getWarningDelay(
'propal',
'cloture'))) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
995 print
" ".img_warning();
997 print
'</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
998 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
999 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).
'</td></tr>';
1009 dol_print_error($db);
1013 $orders2invoice =
null;
1019 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1020 $commande_static =
new Commande($db);
1021 $sql =
"SELECT s.nom, s.rowid";
1022 $sql .=
", c.rowid as cid, c.entity, c.last_main_doc, c.fk_projet, c.total_ht";
1023 $sql .=
", c.total_tva";
1024 $sql .=
", c.total_ttc";
1025 $sql .=
", c.ref, c.ref_client, c.fk_statut, c.facture";
1026 $sql .=
", c.date_commande as dc";
1027 $sql .=
", c.facture as billed";
1028 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
1029 $sql .=
" WHERE c.fk_soc = s.rowid ";
1030 $sql .=
" AND s.rowid = ".((int)
$object->id);
1031 $sql .=
" AND c.entity IN (".getEntity(
'commande').
')';
1032 $parameters = array();
1033 $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $commande_static);
1034 $sql .= $hookmanager->resPrint;
1035 $sql .=
" ORDER BY c.date_commande DESC";
1037 $resql = $db->query($sql);
1039 $num = $db->num_rows($resql);
1042 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
1043 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
1044 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
1045 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande as c';
1046 $sql2 .=
' WHERE c.fk_soc = s.rowid';
1047 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
1049 $sql2 .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
1051 $resql2 = $db->query($sql2);
1052 $orders2invoice = $db->num_rows($resql2);
1055 print
'<div class="div-table-responsive-no-min">';
1056 print
'<table class="noborder centpercent lastrecordtable">';
1058 print
'<tr class="liste_titre">';
1059 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>';
1060 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>';
1061 print
'</tr></table></td>';
1066 while ($i < $num && $i < $MAXLIST) {
1067 $objp = $db->fetch_object($resql);
1069 $commande_static->id = $objp->cid;
1070 $commande_static->ref = $objp->ref;
1071 $commande_static->ref_client = $objp->ref_client;
1072 $commande_static->fk_project = $objp->fk_projet;
1073 $commande_static->total_ht = $objp->total_ht;
1074 $commande_static->total_tva = $objp->total_tva;
1075 $commande_static->total_ttc = $objp->total_ttc;
1076 $commande_static->billed = $objp->billed;
1077 $commande_static->last_main_doc = $objp->last_main_doc;
1078 $commande_static->entity = $objp->entity;
1080 print
'<tr class="oddeven">';
1081 print
'<td class="nowraponall">';
1082 print $commande_static->getNomUrl(1);
1084 print $commande_static->showLastFilePreview();
1085 print
'</td><td class="tdoverflowmax125">';
1086 if ($commande_static->fk_project > 0) {
1087 $project->fetch((
int) $commande_static->fk_project);
1088 print $project->getNomUrl(1);
1096 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
"</td>\n";
1097 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
1098 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).
'</td></tr>';
1108 dol_print_error($db);
1115 if (
isModEnabled(
"shipping") && $user->hasRight(
'expedition',
'lire')) {
1118 $sql =
'SELECT e.rowid as id';
1119 $sql .=
', e.ref, e.entity, e.last_main_doc, e.fk_projet';
1120 $sql .=
', e.date_creation';
1121 $sql .=
', e.fk_statut as statut';
1123 $sql .=
', s.rowid as socid';
1124 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"expedition as e";
1125 $sql .=
" WHERE e.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1126 $sql .=
" AND e.entity IN (".getEntity(
'expedition').
")";
1127 $sql .=
' GROUP BY e.rowid';
1128 $sql .=
', e.ref, e.entity, e.fk_projet';
1129 $sql .=
', e.date_creation';
1130 $sql .=
', e.fk_statut';
1132 $sql .=
', s.rowid';
1133 $sql .=
" ORDER BY e.date_creation DESC";
1135 $resql = $db->query($sql);
1139 $num = $db->num_rows($resql);
1141 print
'<div class="div-table-responsive-no-min">';
1142 print
'<table class="noborder centpercent lastrecordtable">';
1144 print
'<tr class="liste_titre">';
1145 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>';
1146 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>';
1147 print
'</tr></table></td>';
1152 while ($i < $num && $i < $MAXLIST) {
1153 $objp = $db->fetch_object($resql);
1155 $param =
'entity=' . ((int) $objp->entity);
1157 $sendingstatic->id = $objp->id;
1158 $sendingstatic->ref = $objp->ref;
1159 $sendingstatic->fk_project = $objp->fk_projet;
1160 $sendingstatic->last_main_doc = $objp->last_main_doc;
1161 $sendingstatic->entity = $objp->entity;
1163 print
'<tr class="oddeven">';
1164 print
'<td class="nowraponall">';
1165 print $sendingstatic->getNomUrl(1);
1167 print $sendingstatic->showLastFilePreview();
1168 print
'</td><td class="tdoverflowmax125">';
1169 if ($sendingstatic->fk_project > 0) {
1170 $project->fetch((
int) $sendingstatic->fk_project);
1171 print $project->getNomUrl(1);
1178 if ($objp->date_creation > 0) {
1179 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
1181 print
'<td class="right"><b>!!!</b></td>';
1184 print
'<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
1195 dol_print_error($db);
1202 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1203 $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,";
1204 $sql .=
" c.last_main_doc, c.model_pdf";
1205 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
1206 $sql .=
" WHERE c.fk_soc = s.rowid ";
1207 $sql .=
" AND s.rowid = ".((int)
$object->id);
1208 $sql .=
" AND c.fk_contract_type = 0";
1209 $sql .=
" AND c.entity IN (".getEntity(
'contract').
")";
1210 $sql .=
" ORDER BY c.datec DESC";
1212 $resql = $db->query($sql);
1216 $num = $db->num_rows($resql);
1218 print
'<div class="div-table-responsive-no-min">';
1219 print
'<table class="noborder centpercent lastrecordtable">';
1221 print
'<tr class="liste_titre">';
1222 print
'<td colspan="6"><table class="centpercent nobordernopadding"><tr><td>'.$langs->trans(
"LastContracts", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
1223 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>';
1225 print
'</tr></table></td>';
1230 while ($i < $num && $i < $MAXLIST) {
1231 $objp = $db->fetch_object($resql);
1233 $contrat->id = $objp->id;
1234 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1235 $contrat->ref_customer = $objp->refcus;
1236 $contrat->ref_supplier = $objp->refsup;
1237 $contrat->fk_project = $objp->fk_projet;
1238 $contrat->statut = $objp->contract_status;
1239 $contrat->status = $objp->contract_status;
1240 $contrat->last_main_doc = $objp->last_main_doc;
1241 $contrat->model_pdf = $objp->model_pdf;
1242 $contrat->entity = $objp->entity;
1243 $contrat->fetch_lines();
1246 foreach ($contrat->lines as $line) {
1247 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1248 if (((!empty($line->date_end) ? $line->date_end : 0) +
getWarningDelay(
'contract',
'service',
'expires')) < $now) {
1249 $late = img_warning($langs->trans(
"Late"));
1254 print
'<tr class="oddeven">';
1255 print
'<td class="nowraponall">';
1256 print $contrat->getNomUrl(1, 12);
1257 if (!empty($contrat->model_pdf)) {
1259 print $contrat->showLastFilePreview();
1266 print
'</td><td class="tdoverflowmax125">';
1267 if ($contrat->fk_project > 0) {
1268 $project->fetch((
int) $contrat->fk_project);
1269 print $project->getNomUrl(1);
1272 print
'<td class="nowrap">';
1273 print
dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1276 print
'<td class="right" width="80px"><span title="'.$langs->trans(
"DateContract").
'">'.
dol_print_date($db->jdate($objp->dcon),
'day').
"</span></td>\n";
1277 print
'<td width="20"> </td>';
1278 print
'<td class="nowraponall right">';
1279 print $contrat->getLibStatut(4);
1291 dol_print_error($db);
1298 if (
isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'lire')) {
1299 $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, f.last_main_doc";
1300 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"fichinter as f";
1301 $sql .=
" WHERE f.fk_soc = s.rowid";
1302 $sql .=
" AND s.rowid = ".((int)
$object->id);
1303 $sql .=
" AND f.entity IN (".getEntity(
'intervention').
")";
1304 $sql .=
" ORDER BY f.tms DESC";
1306 $resql = $db->query($sql);
1310 $num = $db->num_rows($resql);
1312 print
'<div class="div-table-responsive-no-min">';
1313 print
'<table class="noborder centpercent lastrecordtable">';
1315 print
'<tr class="liste_titre">';
1316 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>';
1317 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>';
1318 print
'</tr></table></td>';
1323 while ($i < $num && $i < $MAXLIST) {
1324 $objp = $db->fetch_object($resql);
1326 $fichinter_static->id = $objp->id;
1327 $fichinter_static->ref = $objp->ref;
1328 $fichinter_static->statut = $objp->fk_statut;
1329 $fichinter_static->status = $objp->fk_statut;
1330 $fichinter_static->fk_project = $objp->fk_projet;
1331 $fichinter_static->last_main_doc = $objp->last_main_doc;
1332 $fichinter_static->entity = $objp->entity;
1334 print
'<tr class="oddeven">';
1335 print
'<td class="nowraponall">';
1336 print $fichinter_static->getNomUrl(1);
1338 print $fichinter_static->showLastFilePreview();
1339 print
'</td><td class="tdoverflowmax125">';
1340 if ($fichinter_static->fk_project > 0) {
1341 $project->fetch($fichinter_static->fk_project);
1342 print $project->getNomUrl(1);
1350 print
'<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).
'</td>'.
"\n";
1351 print
'<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).
'</td>'.
"\n";
1363 dol_print_error($db);
1370 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1371 $sql =
'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1372 $sql .=
', f.total_ht';
1373 $sql .=
', f.total_tva';
1374 $sql .=
', f.total_ttc';
1375 $sql .=
', f.datec as dc';
1376 $sql .=
', f.date_last_gen, f.date_when';
1377 $sql .=
', f.frequency';
1378 $sql .=
', f.unit_frequency';
1379 $sql .=
', f.suspended as suspended';
1380 $sql .=
', s.nom, s.rowid as socid';
1381 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_rec as f";
1382 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1383 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1384 $sql .=
' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1385 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1386 $sql .=
' f.suspended, f.date_when,';
1387 $sql .=
' s.nom, s.rowid';
1388 $sql .=
" ORDER BY f.date_last_gen, f.datec DESC";
1390 $resql = $db->query($sql);
1394 $num = $db->num_rows($resql);
1396 print
'<div class="div-table-responsive-no-min">';
1397 print
'<table class="noborder centpercent lastrecordtable">';
1398 print
'<tr class="liste_titre">';
1403 print
'<td colspan="'.$colspan.
'">';
1404 print
'<table class="centpercent nobordernopadding"><tr>';
1405 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>';
1406 print
'</tr></table>';
1412 while ($i < $num && $i < $MAXLIST) {
1413 $objp = $db->fetch_object($resql);
1415 $invoicetemplate->id = $objp->id;
1416 $invoicetemplate->ref = $objp->ref;
1417 $invoicetemplate->fk_project = $objp->fk_projet;
1418 $invoicetemplate->suspended = $objp->suspended;
1419 $invoicetemplate->frequency = $objp->frequency;
1420 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1421 $invoicetemplate->total_ht = $objp->total_ht;
1422 $invoicetemplate->total_tva = $objp->total_tva;
1423 $invoicetemplate->total_ttc = $objp->total_ttc;
1424 $invoicetemplate->date_last_gen = $db->jdate($objp->date_last_gen);
1425 $invoicetemplate->date_when = $db->jdate($objp->date_when);
1427 print
'<tr class="oddeven">';
1428 print
'<td class="tdoverflowmax250">';
1429 print $invoicetemplate->getNomUrl(1);
1430 print
'</td><td class="tdoverflowmax125">';
1431 if ($invoicetemplate->fk_project > 0) {
1432 $project->fetch((
int) $invoicetemplate->fk_project);
1433 print $project->getNomUrl(1);
1437 if ($objp->frequency && $objp->date_last_gen > 0) {
1438 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
1440 if ($objp->dc > 0) {
1441 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
1443 print
'<td class="right"><b>!!!</b></td>';
1446 print
'<td class="right nowraponall">';
1447 print
price($objp->total_ht);
1451 print
'<td class="right nowraponall">';
1452 print
price($objp->total_ttc);
1456 print
'<td class="nowrap right" style="min-width: 60px">';
1457 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
1458 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1470 dol_print_error($db);
1477 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1478 $sql =
'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1479 $sql .=
', f.total_ht';
1480 $sql .=
', f.total_tva';
1481 $sql .=
', f.total_ttc';
1482 $sql .=
', f.entity, f.last_main_doc';
1483 $sql .=
', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status, f.dispute_status';
1484 $sql .=
', s.nom, s.rowid as socid';
1485 $sql .=
', SUM(pf.amount) as am';
1486 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
1487 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON f.rowid=pf.fk_facture';
1488 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1489 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1490 $sql .=
' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1491 $sql .=
' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1492 $sql .=
' s.nom, s.rowid';
1493 $sql .=
" ORDER BY f.datef DESC, f.datec DESC";
1495 $resql = $db->query($sql);
1497 $facturestatic =
new Facture($db);
1499 $num = $db->num_rows($resql);
1501 print
'<div class="div-table-responsive-no-min">';
1502 print
'<table class="noborder centpercent lastrecordtable">';
1503 print
'<tr class="liste_titre">';
1511 print
'<td colspan="'.$colspan.
'">';
1512 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>';
1513 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>';
1514 print
'</tr></table>';
1520 while ($i < $num && $i < $MAXLIST) {
1521 $objp = $db->fetch_object($resql);
1523 $facturestatic->id = $objp->facid;
1524 $facturestatic->ref = $objp->ref;
1525 $facturestatic->ref_client = $objp->ref_client;
1526 $facturestatic->fk_project = $objp->fk_projet;
1527 $facturestatic->type = $objp->type;
1528 $facturestatic->total_ht = $objp->total_ht;
1529 $facturestatic->total_tva = $objp->total_tva;
1530 $facturestatic->total_ttc = $objp->total_ttc;
1531 $facturestatic->statut = $objp->status;
1532 $facturestatic->status = $objp->status;
1533 $facturestatic->dispute_status = $objp->dispute_status;
1534 $facturestatic->paye = $objp->paye;
1536 $facturestatic->alreadypaid = $objp->am;
1537 $facturestatic->totalpaid = $objp->am;
1539 $facturestatic->date = $db->jdate($objp->df);
1540 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1542 $facturestatic->last_main_doc = $objp->last_main_doc;
1543 $facturestatic->entity = $objp->entity;
1545 print
'<tr class="oddeven">';
1546 print
'<td class="nowraponall">';
1547 print $facturestatic->getNomUrl(1);
1549 print $facturestatic->showLastFilePreview();
1550 print
'</td><td class="tdoverflowmax125">';
1551 if ($facturestatic->fk_project > 0) {
1552 $project->fetch((
int) $facturestatic->fk_project);
1553 print $project->getNomUrl(1);
1561 print
'<td class="nowraponall">';
1562 print dolPrintHTML($objp->ref_client);
1565 if ($objp->df > 0) {
1566 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateInvoice')).
'">'.
dol_print_date($db->jdate($objp->df),
'day').
'</td>';
1568 print
'<td><b>!!!</b></td>';
1570 if ($objp->dl > 0) {
1571 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateMaxPayment')).
'">'.
dol_print_date($db->jdate($objp->dl),
'day').
'</td>';
1573 print
'<td><b>!!!</b></td>';
1576 print
'<td class="right nowraponall">';
1577 print
price($objp->total_ht);
1581 print
'<td class="right nowraponall">';
1582 print
price($objp->total_ttc);
1586 print
'<td class="nowrap right" style="min-width: 60px">'.$facturestatic->getLibStatut(5, $objp->am).
'</td>';
1597 dol_print_error($db);
1602 $parameters = array();
1603 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
1605 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1607 print $hookmanager->resPrint;
1610 print
'</div></div>';
1611 print
'<div class="clearboth"></div>';
1619 print
'<div class="tabsAction">';
1621 $parameters = array();
1622 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1624 if (empty($reshook)) {
1625 $langs->loadLangs(array(
"products",
"compta"));
1628 $thirdpartyclosedtitle = (
$object->status == 1 ?
'' : $langs->trans(
"ThirdPartyIsClosed"));
1631 $backtopageforcancel = $_SERVER[
'PHP_SELF'].
'?socid='.
$object->id;
1633 $arrayforbutaction = array();
1636 $arrayforbutaction[] = array(
1639 'perm' => (
$object->status == 1 && $user->hasRight(
'propal',
'creer')),
1640 'label' =>
'AddProp',
1641 'url' =>
'/comm/propal/card.php?socid='.$object->id.
'&action=create&backtopageforcancel='.urlencode($backtopageforcancel),
1642 'attr' => ($thirdpartyclosedtitle ? array(
'title' => $thirdpartyclosedtitle) : array()),
1643 'params' => ($thirdpartyclosedtitle ? array(
'attr' => array(
'title' => $thirdpartyclosedtitle)) : array())
1647 $arrayforbutaction[] = array(
1650 'perm' => (
$object->status == 1 && $user->hasRight(
'commande',
'creer')),
1651 'label' =>
'AddOrder',
1652 'url' =>
'/commande/card.php?socid='.$object->id.
'&action=create&backtopageforcancel='.urlencode($backtopageforcancel),
1653 'attr' => ($thirdpartyclosedtitle ? array(
'title' => $thirdpartyclosedtitle) : array()),
1654 'params' => ($thirdpartyclosedtitle ? array(
'attr' => array(
'title' => $thirdpartyclosedtitle)) : array())
1658 $arrayforbutaction[] = array(
1659 'lang' =>
'contracts',
1661 'perm' => (
$object->status == 1 && $user->hasRight(
'contrat',
'creer')),
1662 'label' =>
'AddContract',
1663 'url' =>
'/contrat/card.php?socid='.$object->id.
'&action=create&backtopageforcancel='.urlencode($backtopageforcancel),
1664 'attr' => ($thirdpartyclosedtitle ? array(
'title' => $thirdpartyclosedtitle) : array()),
1665 'params' => ($thirdpartyclosedtitle ? array(
'attr' => array(
'title' => $thirdpartyclosedtitle)) : array())
1669 $arrayforbutaction[] = array(
1670 'lang' =>
'interventions',
1672 'perm' => (
$object->status == 1 && $user->hasRight(
'ficheinter',
'creer')),
1673 'label' =>
'AddIntervention',
1674 'url' =>
'/fichinter/card.php?socid='.$object->id.
'&action=create&backtopageforcancel='.urlencode($backtopageforcancel),
1675 'attr' => ($thirdpartyclosedtitle ? array(
'title' => $thirdpartyclosedtitle) : array()),
1676 'params' => ($thirdpartyclosedtitle ? array(
'attr' => array(
'title' => $thirdpartyclosedtitle)) : array())
1680 $billbuttontitle = $thirdpartyclosedtitle;
1681 if (empty($billbuttontitle) && (
$object->client == 0 ||
$object->client == 2)) {
1683 $billbuttontitle = $langs->trans(
"ThirdPartyMustBeEditAsCustomer");
1685 $arrayforbutaction[] = array(
1688 'perm' => (
$object->status == 1 &&
$object->client != 0 &&
$object->client != 2 && $user->hasRight(
'facture',
'creer')),
1689 'label' =>
'AddBill',
1690 'url' =>
'/compta/facture/card.php?action=create&socid='.$object->id.
'&backtopageforcancel='.urlencode($backtopageforcancel),
1691 'attr' => ($billbuttontitle ? array(
'title' => $billbuttontitle) : array()),
1692 'params' => ($billbuttontitle ? array(
'attr' => array(
'title' => $billbuttontitle)) : array())
1696 $permissiontocreateatleastone = 0;
1697 foreach ($arrayforbutaction as $butaction) {
1698 if (!empty($butaction[
'perm'])) {
1699 $permissiontocreateatleastone = 1;
1705 if (!empty($arrayforbutaction)) {
1706 $createbuttontitle =
'';
1707 $createbuttonright = 1;
1709 $createbuttontitle = $langs->trans(
"ThirdPartyIsClosed");
1710 $createbuttonright = 0;
1711 } elseif (empty($permissiontocreateatleastone)) {
1712 $createbuttontitle = $langs->trans(
"NotAllowed");
1713 $createbuttonright = 0;
1716 print dolGetButtonAction($createbuttontitle, $langs->trans(
"Create"),
'default', $arrayforbutaction,
'', $createbuttonright, array(
'areDropdownButtons' => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_THIRDPARTY")));
1719 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
1722 if (!empty($orders2invoice) && $orders2invoice > 0) {
1723 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>';
1725 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1728 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dolPrintHTMLForAttribute($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1735 if ($user->hasRight(
'agenda',
'myactions',
'create')) {
1736 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>';
1738 print
'<div class="inline-block divButAction"><a class="butAction" title="'.dolPrintHTMLForAttribute($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddAction").
'</a></div>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage customers or prospects.
Class to manage customers orders.
Class to manage invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage invoice templates.
Class to manage projects.
Class to manage proposals.
Class to manage Dolibarr users.
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='')
Show html area with actions to do.
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.