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';
75$langs->loadLangs(array(
'companies',
'banks'));
77if (isModEnabled(
'contract')) {
78 $langs->load(
"contracts");
80if (isModEnabled(
'order')) {
81 $langs->load(
"orders");
83if (isModEnabled(
"shipping")) {
84 $langs->load(
"sendings");
86if (isModEnabled(
'invoice')) {
87 $langs->load(
"bills");
89if (isModEnabled(
'project')) {
90 $langs->load(
"projects");
92if (isModEnabled(
'intervention')) {
93 $langs->load(
"interventions");
95if (isModEnabled(
'notification')) {
96 $langs->load(
"mails");
99$action =
GETPOST(
'action',
'aZ09');
104$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
105$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
107if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
111$offset = $limit * $page;
112$pageprev = $page - 1;
113$pagenext = $page + 1;
120$cancel =
GETPOST(
'cancel',
'alpha');
127$extrafields->fetch_name_optionals_label(
$object->table_element);
130$hookmanager->initHooks(array(
'thirdpartycomm',
'globalcard'));
134if ($id > 0 && empty(
$object->id)) {
142 if (!(
$object->client > 0) || !$user->hasRight(
'societe',
'lire')) {
148if ($user->socid > 0) {
158$parameters = array(
'id' => $id,
'socid' => $id);
159$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
164if (empty($reshook)) {
170 if ($action ==
'setcustomeraccountancycodegeneral') {
172 $object->accountancy_code_customer_general =
GETPOST(
"customeraccountancycodegeneral");
180 if ($action ==
'setcustomeraccountancycode' && $user->hasRight(
'societe',
'creer')) {
187 $action =
'editcustomeraccountancycode';
192 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
201 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
210 if ($action ==
'settransportmode' && $user->hasRight(
'societe',
'creer')) {
212 $result =
$object->setTransportMode(
GETPOST(
'transport_mode_id',
'alpha'));
219 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
228 if ($action ==
'setshippingmethod' && $user->hasRight(
'societe',
'creer')) {
237 if ($action ==
'setassujtva' && $user->hasRight(
'societe',
'creer')) {
247 if ($action ==
'setprospectlevel' && $user->hasRight(
'societe',
'creer')) {
249 $object->fk_prospectlevel =
GETPOST(
'prospect_level_id',
'alpha');
257 if ($action ==
'setstcomm' && $user->hasRight(
'societe',
'creer')) {
269 if ($action ==
'setoutstanding_limit' && $user->hasRight(
'societe',
'creer')) {
279 if ($action ==
'setorder_min_amount' && $user->hasRight(
'societe',
'creer')) {
289 if ($action ==
'set_salesrepresentatives' && $user->hasRight(
'societe',
'creer')) {
294 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
300 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
305 $result =
$object->insertExtraFields(
'COMPANY_MODIFY');
312 $action =
'edit_extras';
317 if ($action ==
'setwarehouse' && $user->hasRight(
'societe',
'creer')) {
327$contactstatic =
new Contact($db);
328$userstatic =
new User($db);
329$form =
new Form($db);
333$title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Customer');
335 $title =
$object->name.
" - ".$langs->trans(
'Customer');
338$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
345 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), -1,
'company');
347 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
349 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
351 print
'<div class="fichecenter"><div class="fichehalfleft">';
353 print
'<div class="underbanner clearboth"></div>';
354 print
'<table class="border centpercent tableforfield">';
357 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
363 print
'<tr><td>'.$langs->trans(
"Prefix").
'</td><td>';
369 $langs->load(
"compta");
372 print $langs->trans(
'CustomerCode').
'</td><td>';
374 $tmpcheck =
$object->check_codeclient();
375 if ($tmpcheck != 0 && $tmpcheck != -5) {
376 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
380 if (isModEnabled(
'accounting')) {
385 print $form->editfieldkey(
"CustomerAccountancyCodeGeneral",
'customeraccountancycodegeneral',
length_accountg(
$object->accountancy_code_customer_general),
$object, $user->hasRight(
'societe',
'creer'));
387 if ($action ==
'editcustomeraccountancycodegeneral' && $user->hasRight(
'societe',
'creer')) {
388 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_customer_general,
'customeraccountancycodegeneral', 0, 1,
'', 1);
391 $accountingaccount->fetch(0,
$object->accountancy_code_customer_general, 1);
393 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
395 $accountingAccountByDefault =
" (" . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')) .
")";
396 print (
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER') ? $accountingAccountByDefault :
'');
402 print $form->editfieldkey(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client,
$object, $user->hasRight(
'societe',
'creer'));
404 print $form->editfieldval(
"CustomerAccountancyCode",
'customeraccountancycode',
$object->code_compta_client,
$object, $user->hasRight(
'societe',
'creer'));
425 if ($mysoc->country_code ==
'ES') {
427 if ($mysoc->localtax1_assuj ==
"1") {
428 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
432 if ($mysoc->localtax1_assuj ==
"1") {
433 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
440 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
445 $langs->load(
'bills');
447 print
'<table width="100%" class="nobordernopadding"><tr><td>';
448 print $langs->trans(
'PaymentConditions');
450 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
451 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>';
453 print
'</tr></table>';
455 if ($action ==
'editconditions') {
456 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
458 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_id,
'none', 0,
'', 1,
$object->deposit_percent);
464 print
'<tr><td class="nowrap">';
465 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
466 print $langs->trans(
'PaymentMode');
468 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
469 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>';
471 print
'</tr></table>';
473 if ($action ==
'editmode') {
474 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
476 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_id,
'none');
481 if (isModEnabled(
"bank")) {
483 print
'<tr><td class="nowrap">';
484 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
485 print $langs->trans(
'PaymentBankAccount');
487 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
488 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>';
490 print
'</tr></table>';
492 if ($action ==
'editbankaccount') {
493 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'fk_account', 1);
495 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'none');
505 print
'<tr><td class="nowrap">';
506 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
507 print $langs->trans(
"CustomerRelativeDiscountShort");
508 print
'<td><td class="right">';
509 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
510 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>';
512 print
'</td></tr></table>';
513 print
'</td><td>'.($object->remise_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_percent.
'%</a>' :
'').
'</td>';
517 print
'<tr><td class="nowrap">';
518 print
'<table width="100%" class="nobordernopadding">';
519 print
'<tr><td class="nowrap">';
520 print $langs->trans(
"CustomerAbsoluteDiscountShort");
521 print
'<td><td class="right">';
522 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
523 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>';
525 print
'</td></tr></table>';
528 $amount_discount =
$object->getAvailableDiscounts();
529 if ($amount_discount < 0) {
532 if ($amount_discount > 0) {
533 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>';
540 $limit_field_type =
'';
543 print
'<tr class="nowrap">';
545 print $form->editfieldkey(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit,
$object, $user->hasRight(
'societe',
'creer'));
547 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
548 print $form->editfieldval(
"OutstandingBill",
'outstanding_limit',
$object->outstanding_limit,
$object, $user->hasRight(
'societe',
'creer'), $limit_field_type, (
$object->outstanding_limit !=
'' ?
price(
$object->outstanding_limit) :
''));
555 print
'<!-- Minimum amount for orders -->'.
"\n";
556 print
'<tr class="nowrap">';
558 print $form->editfieldkey(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount,
$object, $user->hasRight(
'societe',
'creer'));
560 print $form->editfieldval(
"OrderMinAmount",
'order_min_amount',
$object->order_min_amount,
$object, $user->hasRight(
'societe',
'creer'), $limit_field_type, (
$object->order_min_amount !=
'' ?
price(
$object->order_min_amount) :
''));
569 print
'<tr><td class="nowrap">';
570 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
571 print $langs->trans(
"PriceLevel");
572 print
'<td><td class="right">';
573 if ($user->hasRight(
'societe',
'creer')) {
574 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/multiprix.php?id='.
$object->id.
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
576 print
'</td></tr></table>';
579 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
589 $langs->load(
'stocks');
590 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
592 print
'<tr class="nowrap">';
594 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, $user->hasRight(
'societe',
'creer'));
596 if ($action ==
'editwarehouse') {
597 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'fk_warehouse', 1);
599 if (
$object->fk_warehouse > 0) {
600 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
602 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'none');
610 print
'<tr><td class="nowrap">';
611 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
612 print $langs->trans(
'SendingMethod');
614 if (($action !=
'editshipping') && $user->hasRight(
'societe',
'creer')) {
615 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>';
617 print
'</tr></table>';
619 if ($action ==
'editshipping') {
620 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->shipping_method_id,
'shipping_method_id', 1);
622 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->shipping_method_id,
'none');
628 if (isModEnabled(
'intracommreport')) {
630 print
'<tr><td class="nowrap">';
631 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
632 print $langs->trans(
'IntracommReportTransportMode');
634 if (($action !=
'edittransportmode') && $user->hasRight(
'societe',
'creer')) {
635 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>';
637 print
'</tr></table>';
639 if ($action ==
'edittransportmode') {
640 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'transport_mode_id', 1);
642 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (!empty(
$object->transport_mode_id) ?
$object->transport_mode_id :
''),
'none');
649 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
650 $langs->load(
"categories");
651 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
653 print $form->showCategories(
$object->id, Categorie::TYPE_CUSTOMER, 1);
658 $parameters = array(
'socid' =>
$object->id);
659 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
662 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
665 if (isModEnabled(
'member')) {
666 $langs->load(
"members");
667 $langs->load(
"users");
669 print
'<tr><td class="titlefield">'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
672 $result = $adh->fetch(0,
'',
$object->id);
674 $adh->ref = $adh->getFullName($langs);
675 print $adh->getNomUrl(-1);
677 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
685 print
'</div><div class="fichehalfright">';
689 print
'<div class="underbanner clearboth"></div>';
690 print
'<table class="border centpercent tableforfield">';
693 print
'<tr><td class="titlefield nowrap">';
694 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
695 print $langs->trans(
'ProspectLevel');
697 if ($action !=
'editlevel' && $user->hasRight(
'societe',
'creer')) {
698 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>';
700 print
'</tr></table>';
702 if ($action ==
'editlevel') {
703 $formcompany->form_prospect_level($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_prospectlevel,
'prospect_level_id', 1);
705 print
$object->getLibProspLevel();
711 $object->loadCacheOfProspStatus();
712 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.
$object->getLibProspCommStatut(4,
$object->cacheprospectstatus[
$object->stcomm_id][
'label']);
713 print
' ';
714 print
'<div class="floatright">';
715 foreach (
$object->cacheprospectstatus as $key => $val) {
716 $titlealt =
'default';
717 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
718 $titlealt = $val[
'label'];
720 if (
$object->stcomm_id != $val[
'id']) {
721 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>';
724 print
'</div></td></tr>';
729 print
'<div class="underbanner underbanner-before-box clearboth"></div><br>';
738 $boxstat .=
'<div class="box divboxtable box-halfright">';
739 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop boxtablenomarginbottom centpercent">';
740 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
742 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
744 $tmp =
$object->getOutstandingProposals();
745 $outstandingOpened = $tmp[
'opened'];
746 $outstandingTotal = $tmp[
'total_ht'];
747 $outstandingTotalIncTax = $tmp[
'total_ttc'];
748 $text = $langs->trans(
"OverAllProposals");
749 $link = DOL_URL_ROOT.
'/comm/propal/list.php?socid='.
$object->id;
752 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
754 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
755 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
756 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
757 $boxstat .=
'</div>';
763 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
765 $tmp =
$object->getOutstandingOrders();
766 $outstandingOpened = $tmp[
'opened'];
767 $outstandingTotal = $tmp[
'total_ht'];
768 $outstandingTotalIncTax = $tmp[
'total_ttc'];
769 $text = $langs->trans(
"OverAllOrders");
770 $link = DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->id;
773 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
775 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
776 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
777 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
778 $boxstat .=
'</div>';
784 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
786 $tmp =
$object->getOutstandingBills(
'customer', 0);
787 $outstandingOpened = $tmp[
'opened'];
788 $outstandingTotal = $tmp[
'total_ht'];
789 $outstandingTotalIncTax = $tmp[
'total_ttc'];
791 $text = $langs->trans(
"OverAllInvoices");
792 $link = DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->id;
795 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
797 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
798 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
799 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
800 $boxstat .=
'</div>';
807 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpened) {
808 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
810 $text = $langs->trans(
"CurrentOutstandingBill");
811 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
814 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
816 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
817 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
818 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
819 $boxstat .=
'</div>';
824 $tmp =
$object->getOutstandingBills(
'customer', 1);
825 $outstandingOpenedLate = $tmp[
'opened'];
826 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
828 if (
$object->outstanding_limit !=
'' &&
$object->outstanding_limit < $outstandingOpenedLate) {
829 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
831 $text = $langs->trans(
"CurrentOutstandingBillLate");
832 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.
$object->id;
835 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
837 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
838 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
839 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
840 $boxstat .=
'</div>';
847 $parameters = array();
848 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', $parameters,
$object, $action);
849 if (empty($reshook)) {
850 $boxstat .= $hookmanager->resPrint;
853 $boxstat .=
'</td></tr>';
854 $boxstat .=
'</table>';
855 $boxstat .=
'</div>';
863 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
864 $langs->load(
"propal");
866 $sql =
"SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_projet, p.fk_statut, p.total_ht";
867 $sql .=
", p.total_tva";
868 $sql .=
", p.total_ttc";
869 $sql .=
", p.ref, p.ref_client, p.remise";
870 $sql .=
", p.datep as dp, p.fin_validite as date_limit, p.entity";
871 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
872 $sql .=
" WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
873 $sql .=
" AND s.rowid = ".((int)
$object->id);
874 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
875 $sql .=
" ORDER BY p.datep DESC";
877 $resql = $db->query($sql);
879 $propal_static =
new Propal($db);
881 $num = $db->num_rows($resql);
883 print
'<div class="div-table-responsive-no-min">';
884 print
'<table class="noborder centpercent lastrecordtable">';
886 print
'<tr class="liste_titre">';
887 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>';
888 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>';
889 print
'</tr></table></td>';
894 while ($i < $num && $i < $MAXLIST) {
895 $objp = $db->fetch_object($resql);
897 print
'<tr class="oddeven">';
898 print
'<td class="nowraponall">';
899 $propal_static->id = $objp->propalid;
900 $propal_static->ref = $objp->ref;
901 $propal_static->ref_client = $objp->ref_client;
902 $propal_static->ref_customer = $objp->ref_client;
903 $propal_static->fk_project = $objp->fk_projet;
904 $propal_static->total_ht = $objp->total_ht;
905 $propal_static->total_tva = $objp->total_tva;
906 $propal_static->total_ttc = $objp->total_ttc;
907 print $propal_static->getNomUrl(1);
912 if (!empty($filedir)) {
913 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
915 if (is_array($file_list)) {
919 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
920 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
927 if (!empty($sortfield) && !empty($sortorder)) {
932 print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0);
934 print
'</td><td class="left">';
935 if ($propal_static->fk_project > 0) {
936 $project->fetch($propal_static->fk_project);
937 print $project->getNomUrl(1);
943 if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
944 print
" ".img_warning();
946 print
'</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
947 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
948 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).
'</td></tr>';
962 $orders2invoice =
null;
967 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
968 $sql =
"SELECT s.nom, s.rowid";
969 $sql .=
", c.rowid as cid, c.entity, c.fk_projet, c.total_ht";
970 $sql .=
", c.total_tva";
971 $sql .=
", c.total_ttc";
972 $sql .=
", c.ref, c.ref_client, c.fk_statut, c.facture";
973 $sql .=
", c.date_commande as dc";
974 $sql .=
", c.facture as billed";
975 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
976 $sql .=
" WHERE c.fk_soc = s.rowid ";
977 $sql .=
" AND s.rowid = ".((int)
$object->id);
978 $sql .=
" AND c.entity IN (".getEntity(
'commande').
')';
979 $sql .=
" ORDER BY c.date_commande DESC";
981 $resql = $db->query($sql);
983 $commande_static =
new Commande($db);
985 $num = $db->num_rows($resql);
988 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
989 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
990 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
991 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande as c';
992 $sql2 .=
' WHERE c.fk_soc = s.rowid';
993 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
995 $sql2 .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
997 $resql2 = $db->query($sql2);
998 $orders2invoice = $db->num_rows($resql2);
1001 print
'<div class="div-table-responsive-no-min">';
1002 print
'<table class="noborder centpercent lastrecordtable">';
1004 print
'<tr class="liste_titre">';
1005 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>';
1006 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>';
1007 print
'</tr></table></td>';
1012 while ($i < $num && $i < $MAXLIST) {
1013 $objp = $db->fetch_object($resql);
1015 $commande_static->id = $objp->cid;
1016 $commande_static->ref = $objp->ref;
1017 $commande_static->ref_client = $objp->ref_client;
1018 $commande_static->fk_project = $objp->fk_projet;
1019 $commande_static->total_ht = $objp->total_ht;
1020 $commande_static->total_tva = $objp->total_tva;
1021 $commande_static->total_ttc = $objp->total_ttc;
1022 $commande_static->billed = $objp->billed;
1024 print
'<tr class="oddeven">';
1025 print
'<td class="nowraponall">';
1026 print $commande_static->getNomUrl(1);
1028 $filedir = $conf->commande->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1030 if (!empty($filedir)) {
1031 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1033 if (is_array($file_list)) {
1037 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1038 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1045 if (!empty($sortfield) && !empty($sortorder)) {
1050 print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0, $param);
1052 print
'</td><td class="left">';
1053 if ($commande_static->fk_project > 0) {
1054 $project->fetch($commande_static->fk_project);
1055 print $project->getNomUrl(1);
1063 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
"</td>\n";
1064 print
'<td class="right nowraponall">'.price($objp->total_ht).
'</td>';
1065 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).
'</td></tr>';
1082 if (isModEnabled(
"shipping") && $user->hasRight(
'expedition',
'lire')) {
1083 $sql =
'SELECT e.rowid as id';
1084 $sql .=
', e.ref, e.entity, e.fk_projet';
1085 $sql .=
', e.date_creation';
1086 $sql .=
', e.fk_statut as statut';
1088 $sql .=
', s.rowid as socid';
1089 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"expedition as e";
1090 $sql .=
" WHERE e.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1091 $sql .=
" AND e.entity IN (".getEntity(
'expedition').
")";
1092 $sql .=
' GROUP BY e.rowid';
1093 $sql .=
', e.ref, e.entity, e.fk_projet';
1094 $sql .=
', e.date_creation';
1095 $sql .=
', e.fk_statut';
1097 $sql .=
', s.rowid';
1098 $sql .=
" ORDER BY e.date_creation DESC";
1100 $resql = $db->query($sql);
1104 $num = $db->num_rows($resql);
1106 print
'<div class="div-table-responsive-no-min">';
1107 print
'<table class="noborder centpercent lastrecordtable">';
1109 print
'<tr class="liste_titre">';
1110 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>';
1111 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>';
1112 print
'</tr></table></td>';
1117 while ($i < $num && $i < $MAXLIST) {
1118 $objp = $db->fetch_object($resql);
1120 $sendingstatic->id = $objp->id;
1121 $sendingstatic->ref = $objp->ref;
1122 $sendingstatic->fk_project = $objp->fk_projet;
1124 print
'<tr class="oddeven">';
1125 print
'<td class="nowraponall">';
1126 print $sendingstatic->getNomUrl(1);
1128 $filedir = $conf->expedition->multidir_output[$objp->entity].
'/sending/'.
dol_sanitizeFileName($objp->ref);
1130 if (!empty($filedir)) {
1131 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1133 if (is_array($file_list)) {
1137 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1138 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1145 if (!empty($sortfield) && !empty($sortorder)) {
1150 print $formfile->showPreview($file_list, $sendingstatic->table_element, $relativepath, 0, $param);
1152 print
'</td><td class="left">';
1153 if ($sendingstatic->fk_project > 0) {
1154 $project->fetch($sendingstatic->fk_project);
1155 print $project->getNomUrl(1);
1162 if ($objp->date_creation > 0) {
1163 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
1165 print
'<td class="right"><b>!!!</b></td>';
1168 print
'<td class="nowrap right">'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
1186 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1187 $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,";
1188 $sql .=
" c.last_main_doc, c.model_pdf";
1189 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
1190 $sql .=
" WHERE c.fk_soc = s.rowid ";
1191 $sql .=
" AND s.rowid = ".((int)
$object->id);
1192 $sql .=
" AND c.entity IN (".getEntity(
'contract').
")";
1193 $sql .=
" ORDER BY c.datec DESC";
1195 $resql = $db->query($sql);
1199 $num = $db->num_rows($resql);
1201 print
'<div class="div-table-responsive-no-min">';
1202 print
'<table class="noborder centpercent lastrecordtable">';
1204 print
'<tr class="liste_titre">';
1205 print
'<td colspan="6"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
"LastContracts", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
1206 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>';
1208 print
'</tr></table></td>';
1213 while ($i < $num && $i < $MAXLIST) {
1214 $objp = $db->fetch_object($resql);
1216 $contrat->id = $objp->id;
1217 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1218 $contrat->ref_customer = $objp->refcus;
1219 $contrat->ref_supplier = $objp->refsup;
1220 $contrat->fk_project = $objp->fk_projet;
1221 $contrat->statut = $objp->contract_status;
1222 $contrat->status = $objp->contract_status;
1223 $contrat->last_main_doc = $objp->last_main_doc;
1224 $contrat->model_pdf = $objp->model_pdf;
1225 $contrat->fetch_lines();
1228 foreach ($contrat->lines as $line) {
1229 if ($contrat->status == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1230 if (((!empty($line->date_end) ? $line->date_end : 0) + $conf->contrat->services->expires->warning_delay) < $now) {
1236 print
'<tr class="oddeven">';
1237 print
'<td class="nowraponall">';
1238 print $contrat->getNomUrl(1, 12);
1239 if (!empty($contrat->model_pdf)) {
1241 $filedir = $conf->contrat->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1243 if (!empty($filedir)) {
1244 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1246 if (is_array($file_list)) {
1250 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1251 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1258 if (!empty($sortfield) && !empty($sortorder)) {
1263 print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0);
1271 print
'</td><td class="tdoverflowmax100">';
1272 if ($contrat->fk_project > 0) {
1273 $project->fetch($contrat->fk_project);
1274 print $project->getNomUrl(1);
1277 print
'<td class="nowrap">';
1278 print
dol_trunc(strtolower(get_class(
$object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);
1281 print
'<td class="right" width="80px"><span title="'.$langs->trans(
"DateContract").
'">'.
dol_print_date($db->jdate($objp->dcon),
'day').
"</span></td>\n";
1282 print
'<td width="20"> </td>';
1283 print
'<td class="nowraponall right">';
1284 print $contrat->getLibStatut(4);
1303 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'lire')) {
1304 $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";
1305 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"fichinter as f";
1306 $sql .=
" WHERE f.fk_soc = s.rowid";
1307 $sql .=
" AND s.rowid = ".((int)
$object->id);
1308 $sql .=
" AND f.entity IN (".getEntity(
'intervention').
")";
1309 $sql .=
" ORDER BY f.tms DESC";
1311 $resql = $db->query($sql);
1315 $num = $db->num_rows($resql);
1317 print
'<div class="div-table-responsive-no-min">';
1318 print
'<table class="noborder centpercent lastrecordtable">';
1320 print
'<tr class="liste_titre">';
1321 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>';
1322 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>';
1323 print
'</tr></table></td>';
1328 while ($i < $num && $i < $MAXLIST) {
1329 $objp = $db->fetch_object($resql);
1331 $fichinter_static->id = $objp->id;
1332 $fichinter_static->ref = $objp->ref;
1333 $fichinter_static->statut = $objp->fk_statut;
1334 $fichinter_static->fk_project = $objp->fk_projet;
1336 print
'<tr class="oddeven">';
1337 print
'<td class="nowraponall">';
1338 print $fichinter_static->getNomUrl(1);
1340 $filedir = $conf->ficheinter->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1342 if (!empty($filedir)) {
1343 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1345 if (is_array($file_list)) {
1349 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1350 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1357 if (!empty($sortfield) && !empty($sortorder)) {
1362 print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0);
1364 print
'</td><td class="left">';
1365 if ($fichinter_static->fk_project > 0) {
1366 $project->fetch($fichinter_static->fk_project);
1367 print $project->getNomUrl(1);
1375 print
'<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).
'</td>'.
"\n";
1376 print
'<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).
'</td>'.
"\n";
1395 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1396 $sql =
'SELECT f.rowid as id, f.titre as ref, f.fk_projet';
1397 $sql .=
', f.total_ht';
1398 $sql .=
', f.total_tva';
1399 $sql .=
', f.total_ttc';
1400 $sql .=
', f.datec as dc';
1401 $sql .=
', f.date_last_gen, f.date_when';
1402 $sql .=
', f.frequency';
1403 $sql .=
', f.unit_frequency';
1404 $sql .=
', f.suspended as suspended';
1405 $sql .=
', s.nom, s.rowid as socid';
1406 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_rec as f";
1407 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1408 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1409 $sql .=
' GROUP BY f.rowid, f.titre, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1410 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1411 $sql .=
' f.suspended, f.date_when,';
1412 $sql .=
' s.nom, s.rowid';
1413 $sql .=
" ORDER BY f.date_last_gen, f.datec DESC";
1415 $resql = $db->query($sql);
1419 $num = $db->num_rows($resql);
1421 print
'<div class="div-table-responsive-no-min">';
1422 print
'<table class="noborder centpercent lastrecordtable">';
1423 print
'<tr class="liste_titre">';
1428 print
'<td colspan="'.$colspan.
'">';
1429 print
'<table class="centpercent nobordernopadding"><tr>';
1430 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>';
1431 print
'</tr></table>';
1437 while ($i < $num && $i < $MAXLIST) {
1438 $objp = $db->fetch_object($resql);
1440 $invoicetemplate->id = $objp->id;
1441 $invoicetemplate->ref = $objp->ref;
1442 $invoicetemplate->fk_project = $objp->fk_projet;
1443 $invoicetemplate->suspended = $objp->suspended;
1444 $invoicetemplate->frequency = $objp->frequency;
1445 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1446 $invoicetemplate->total_ht = $objp->total_ht;
1447 $invoicetemplate->total_tva = $objp->total_tva;
1448 $invoicetemplate->total_ttc = $objp->total_ttc;
1449 $invoicetemplate->date_last_gen = $objp->date_last_gen;
1450 $invoicetemplate->date_when = $objp->date_when;
1452 print
'<tr class="oddeven">';
1453 print
'<td class="tdoverflowmax250">';
1454 print $invoicetemplate->getNomUrl(1);
1455 print
'</td><td class="left">';
1456 if ($invoicetemplate->fk_project > 0) {
1457 $project->fetch($invoicetemplate->fk_project);
1458 print $project->getNomUrl(1);
1462 if ($objp->frequency && $objp->date_last_gen > 0) {
1463 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
1465 if ($objp->dc > 0) {
1466 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
1468 print
'<td class="right"><b>!!!</b></td>';
1471 print
'<td class="right nowraponall">';
1472 print
price($objp->total_ht);
1476 print
'<td class="right nowraponall">';
1477 print
price($objp->total_ttc);
1481 print
'<td class="nowrap right" style="min-width: 60px">';
1482 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
1483 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1502 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1503 $sql =
'SELECT f.rowid as facid, f.ref, f.type, f.ref_client, f.fk_projet';
1504 $sql .=
', f.total_ht';
1505 $sql .=
', f.total_tva';
1506 $sql .=
', f.total_ttc';
1507 $sql .=
', f.entity';
1508 $sql .=
', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status';
1509 $sql .=
', s.nom, s.rowid as socid';
1510 $sql .=
', SUM(pf.amount) as am';
1511 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
1512 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON f.rowid=pf.fk_facture';
1513 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
1514 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1515 $sql .=
' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.fk_projet, f.total_ht, f.total_tva, f.total_ttc,';
1516 $sql .=
' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
1517 $sql .=
' s.nom, s.rowid';
1518 $sql .=
" ORDER BY f.datef DESC, f.datec DESC";
1520 $resql = $db->query($sql);
1522 $facturestatic =
new Facture($db);
1524 $num = $db->num_rows($resql);
1526 print
'<div class="div-table-responsive-no-min">';
1527 print
'<table class="noborder centpercent lastrecordtable">';
1528 print
'<tr class="liste_titre">';
1536 print
'<td colspan="'.$colspan.
'">';
1537 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>';
1538 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>';
1539 print
'</tr></table>';
1545 while ($i < $num && $i < $MAXLIST) {
1546 $objp = $db->fetch_object($resql);
1548 $facturestatic->id = $objp->facid;
1549 $facturestatic->ref = $objp->ref;
1550 $facturestatic->ref_client = $objp->ref_client;
1551 $facturestatic->fk_project = $objp->fk_projet;
1552 $facturestatic->type = $objp->type;
1553 $facturestatic->total_ht = $objp->total_ht;
1554 $facturestatic->total_tva = $objp->total_tva;
1555 $facturestatic->total_ttc = $objp->total_ttc;
1556 $facturestatic->statut = $objp->status;
1557 $facturestatic->status = $objp->status;
1558 $facturestatic->paye = $objp->paye;
1559 $facturestatic->alreadypaid = $objp->am;
1560 $facturestatic->totalpaid = $objp->am;
1561 $facturestatic->date = $db->jdate($objp->df);
1562 $facturestatic->date_lim_reglement = $db->jdate($objp->dl);
1564 print
'<tr class="oddeven">';
1565 print
'<td class="nowraponall">';
1566 print $facturestatic->getNomUrl(1);
1568 $filedir = $conf->facture->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1570 if (!empty($filedir)) {
1571 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1573 if (is_array($file_list)) {
1577 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1578 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1585 if (!empty($sortfield) && !empty($sortorder)) {
1590 print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0);
1592 print
'</td><td class="left">';
1593 if ($facturestatic->fk_project > 0) {
1594 $project->fetch($facturestatic->fk_project);
1595 print $project->getNomUrl(1);
1603 print
'<td class="left nowraponall">';
1604 print $objp->ref_client;
1607 if ($objp->df > 0) {
1608 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateInvoice')).
'">'.
dol_print_date($db->jdate($objp->df),
'day').
'</td>';
1610 print
'<td><b>!!!</b></td>';
1612 if ($objp->dl > 0) {
1613 print
'<td width="80px" title="'.dol_escape_htmltag($langs->trans(
'DateMaxPayment')).
'">'.
dol_print_date($db->jdate($objp->dl),
'day').
'</td>';
1615 print
'<td><b>!!!</b></td>';
1618 print
'<td class="right nowraponall">';
1619 print
price($objp->total_ht);
1623 print
'<td class="right nowraponall">';
1624 print
price($objp->total_ttc);
1628 print
'<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).
'</td>';
1644 $parameters = array();
1645 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters,
$object, $action);
1649 print $hookmanager->resPrint;
1652 print
'</div></div>';
1653 print
'<div class="clearboth"></div>';
1661 print
'<div class="tabsAction">';
1663 $parameters = array();
1664 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1666 if (empty($reshook)) {
1668 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"ThirdPartyIsClosed").
'</a></div>';
1671 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer') &&
$object->status == 1) {
1672 $langs->load(
"propal");
1673 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>';
1676 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'creer') &&
$object->status == 1) {
1677 $langs->load(
"orders");
1678 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>';
1681 if ($user->hasRight(
'contrat',
'creer') &&
$object->status == 1) {
1682 $langs->load(
"contracts");
1683 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>';
1686 if (isModEnabled(
'intervention') && $user->hasRight(
'ficheinter',
'creer') &&
$object->status == 1) {
1687 $langs->load(
"interventions");
1688 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>';
1692 if ($user->socid == 0) {
1693 if (isModEnabled(
'deplacement') &&
$object->status == 1) {
1694 $langs->load(
"trips");
1695 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>';
1698 if (isModEnabled(
'invoice') &&
$object->status == 1) {
1699 if (!$user->hasRight(
'facture',
'creer')) {
1700 $langs->load(
"bills");
1701 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1703 $langs->loadLangs(array(
"orders",
"bills"));
1705 if (isModEnabled(
'order')) {
1707 if (!empty($orders2invoice) && $orders2invoice > 0) {
1708 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>';
1710 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1713 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1718 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>';
1720 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1728 if ($user->hasRight(
'agenda',
'myactions',
'create')) {
1729 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>';
1731 print
'<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddAction").
'</a></div>';
1753 $langs->load(
"errors");
1754 print $langs->trans(
'ErrorRecordNotFound');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage customers or prospects.
Class to manage customers orders.
Class to manage invoices.
Class to manage invoice templates.
Class to manage projects.
Class to manage proposals.
Class to manage Dolibarr users.
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='')
Show html area with actions to do.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
Complete $filearray with data from database.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.