35 require
'../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
47 if (!empty($conf->propal->enabled)) {
48 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
50 if (!empty($conf->commande->enabled)) {
51 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
53 if (!empty($conf->expedition->enabled)) {
54 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
56 if (!empty($conf->contrat->enabled)) {
57 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
59 if (!empty($conf->adherent->enabled)) {
60 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
62 if (!empty($conf->ficheinter->enabled)) {
63 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
67 $langs->loadLangs(array(
'companies',
'banks'));
69 if (!empty($conf->contrat->enabled)) {
70 $langs->load(
"contracts");
72 if (!empty($conf->commande->enabled)) {
73 $langs->load(
"orders");
75 if (!empty($conf->expedition->enabled)) {
76 $langs->load(
"sendings");
79 $langs->load(
"bills");
81 if (!empty($conf->project->enabled)) {
82 $langs->load(
"projects");
84 if (!empty($conf->ficheinter->enabled)) {
85 $langs->load(
"interventions");
87 if (!empty($conf->notification->enabled)) {
88 $langs->load(
"mails");
91 $action =
GETPOST(
'action',
'aZ09');
95 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
96 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
97 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
99 if (empty($page) || $page == -1) {
102 $offset = $limit * $page;
103 $pageprev = $page - 1;
104 $pagenext = $page + 1;
111 $cancel =
GETPOST(
'cancel',
'alpha');
113 $object =
new Client($db);
118 $extrafields->fetch_name_optionals_label($object->table_element);
121 $hookmanager->initHooks(array(
'thirdpartycomm',
'globalcard'));
125 if ($id > 0 && empty($object->id)) {
127 $res = $object->fetch($id);
128 if ($object->id < 0) {
132 if ($object->id > 0) {
133 if (!($object->client > 0) || empty($user->rights->societe->lire)) {
139 if ($user->socid > 0) {
142 $result =
restrictedArea($user,
'societe', $object->id,
'&societe',
'',
'fk_soc',
'rowid', 0);
149 $parameters = array(
'id' => $id,
'socid' => $id);
150 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
155 if (empty($reshook)) {
161 if ($action ==
'setcustomeraccountancycode') {
162 $result = $object->fetch($id);
163 $object->code_compta_client =
GETPOST(
"customeraccountancycode");
164 $object->code_compta = $object->code_compta_client;
165 $result = $object->update($object->id, $user, 1, 1, 0);
172 if ($action ==
'setconditions' && $user->rights->societe->creer) {
174 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'),
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha'));
181 if ($action ==
'setmode' && $user->rights->societe->creer) {
183 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
190 if ($action ==
'settransportmode' && $user->rights->societe->creer) {
192 $result = $object->setTransportMode(
GETPOST(
'transport_mode_id',
'alpha'));
199 if ($action ==
'setbankaccount' && $user->rights->societe->creer) {
201 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
208 if ($action ==
'setshippingmethod' && $user->rights->societe->creer) {
210 $result = $object->setShippingMethod(
GETPOST(
'shipping_method_id',
'int'));
217 if ($action ==
'setassujtva' && $user->rights->societe->creer) {
219 $object->tva_assuj =
GETPOST(
'assujtva_value');
220 $result = $object->update($object->id);
227 if ($action ==
'setprospectlevel' && $user->rights->societe->creer) {
229 $object->fk_prospectlevel =
GETPOST(
'prospect_level_id',
'alpha');
230 $result = $object->update($object->id, $user);
237 if ($action ==
'setstcomm') {
240 $result = $object->update($object->id, $user);
244 $result = $object->fetch($object->id);
249 if ($action ==
'setoutstanding_limit') {
251 $object->outstanding_limit =
GETPOST(
'outstanding_limit');
252 $result = $object->update($object->id, $user);
259 if ($action ==
'setorder_min_amount') {
261 $object->order_min_amount =
price2num(
GETPOST(
'order_min_amount',
'alpha'));
262 $result = $object->update($object->id, $user);
269 if ($action ==
'set_salesrepresentatives' && $user->rights->societe->creer) {
271 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
274 if ($action ==
'update_extras') {
280 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
285 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
292 $action =
'edit_extras';
297 if ($action ==
'setwarehouse' && $user->rights->societe->creer) {
298 $result = $object->setWarehouse(
GETPOST(
'fk_warehouse',
'int'));
307 $contactstatic =
new Contact($db);
308 $userstatic =
new User($db);
312 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Customer');
313 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
314 $title = $object->name.
" - ".$langs->trans(
'Customer');
317 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
322 if ($object->id > 0) {
325 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), -1,
'company');
327 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
329 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
331 print
'<div class="fichecenter"><div class="fichehalfleft">';
333 print
'<div class="underbanner clearboth"></div>';
334 print
'<table class="border centpercent tableforfield">';
337 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
338 print $object->getTypeUrl(1);
342 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
343 print
'<tr><td>'.$langs->trans(
"Prefix").
'</td><td>';
344 print ($object->prefix_comm ? $object->prefix_comm :
' ');
348 if ($object->client) {
349 $langs->load(
"compta");
352 print $langs->trans(
'CustomerCode').
'</td><td>';
354 $tmpcheck = $object->check_codeclient();
355 if ($tmpcheck != 0 && $tmpcheck != -5) {
356 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
362 print
$form->editfieldkey(
"CustomerAccountancyCode",
'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
364 print
$form->editfieldval(
"CustomerAccountancyCode",
'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
385 if ($mysoc->country_code ==
'ES') {
387 if ($mysoc->localtax1_assuj ==
"1") {
388 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
389 print
yn($object->localtax1_assuj);
392 if ($mysoc->localtax1_assuj ==
"1") {
393 print
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
394 print
yn($object->localtax2_assuj);
400 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
405 $langs->load(
'bills');
407 print
'<table width="100%" class="nobordernopadding"><tr><td>';
408 print $langs->trans(
'PaymentConditions');
410 if (($action !=
'editconditions') && $user->rights->societe->creer) {
411 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>';
413 print
'</tr></table>';
415 if ($action ==
'editconditions') {
416 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1, $object->deposit_percent);
418 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_id,
'none', 0,
'', 1, $object->deposit_percent);
424 print
'<tr><td class="nowrap">';
425 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
426 print $langs->trans(
'PaymentMode');
428 if (($action !=
'editmode') && $user->rights->societe->creer) {
429 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>';
431 print
'</tr></table>';
433 if ($action ==
'editmode') {
434 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
436 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_id,
'none');
441 if (!empty($conf->banque->enabled)) {
443 print
'<tr><td class="nowrap">';
444 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
445 print $langs->trans(
'PaymentBankAccount');
447 if (($action !=
'editbankaccount') && $user->rights->societe->creer) {
448 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>';
450 print
'</tr></table>';
452 if ($action ==
'editbankaccount') {
453 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'fk_account', 1);
455 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'none');
461 $isCustomer = ($object->client == 1 || $object->client == 3);
465 print
'<tr><td class="nowrap">';
466 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
467 print $langs->trans(
"CustomerRelativeDiscountShort");
468 print
'<td><td class="right">';
469 if ($user->rights->societe->creer && !$user->socid > 0) {
470 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>';
472 print
'</td></tr></table>';
473 print
'</td><td>'.($object->remise_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.$object->remise_percent.
'%</a>' :
'').
'</td>';
477 print
'<tr><td class="nowrap">';
478 print
'<table width="100%" class="nobordernopadding">';
479 print
'<tr><td class="nowrap">';
480 print $langs->trans(
"CustomerAbsoluteDiscountShort");
481 print
'<td><td class="right">';
482 if ($user->rights->societe->creer && !$user->socid > 0) {
483 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$object->id).
'&action=create&token='.
newToken().
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
485 print
'</td></tr></table>';
488 $amount_discount = $object->getAvailableDiscounts();
489 if ($amount_discount < 0) {
492 if ($amount_discount > 0) {
493 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>';
501 if ($object->client) {
502 print
'<tr class="nowrap">';
504 print
$form->editfieldkey(
"OutstandingBill",
'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer);
506 $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ?
'numeric' :
'amount';
507 print
$form->editfieldval(
"OutstandingBill",
'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit !=
'' ?
price($object->outstanding_limit) :
''));
512 if ($object->client) {
513 if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
514 print
'<!-- Minimim amount for orders -->'.
"\n";
515 print
'<tr class="nowrap">';
517 print
$form->editfieldkey(
"OrderMinAmount",
'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer);
519 print
$form->editfieldval(
"OrderMinAmount",
'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->order_min_amount !=
'' ?
price($object->order_min_amount) :
''));
527 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
528 print
'<tr><td class="nowrap">';
529 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
530 print $langs->trans(
"PriceLevel");
531 print
'<td><td class="right">';
532 if ($user->rights->societe->creer) {
533 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/multiprix.php?id='.$object->id.
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
535 print
'</td></tr></table>';
537 print $object->price_level;
538 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
539 if (!empty($conf->global->$keyforlabel)) {
540 print
' - '.$langs->trans($conf->global->$keyforlabel);
547 if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
548 $langs->load(
'stocks');
549 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
551 print
'<tr class="nowrap">';
553 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->rights->societe->creer);
555 if ($action ==
'editwarehouse') {
556 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'fk_warehouse', 1);
558 if ($object->fk_warehouse > 0) {
559 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
561 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'none');
568 if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
569 print
'<tr><td class="nowrap">';
570 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
571 print $langs->trans(
'SendingMethod');
573 if (($action !=
'editshipping') && $user->rights->societe->creer) {
574 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>';
576 print
'</tr></table>';
578 if ($action ==
'editshipping') {
579 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->shipping_method_id,
'shipping_method_id', 1);
581 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->shipping_method_id,
'none');
587 if (!empty($conf->intracommreport->enabled)) {
589 print
'<tr><td class="nowrap">';
590 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
591 print $langs->trans(
'IntracommReportTransportMode');
593 if (($action !=
'edittransportmode') && $user->rights->societe->creer) {
594 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>';
596 print
'</tr></table>';
598 if ($action ==
'edittransportmode') {
599 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id :
''),
'transport_mode_id', 1);
601 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id :
''),
'none');
608 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
609 $langs->load(
"categories");
610 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
612 print
$form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
617 $parameters = array(
'socid'=>$object->id);
618 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
621 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
624 if (!empty($conf->adherent->enabled)) {
625 $langs->load(
"members");
626 $langs->load(
"users");
628 print
'<tr><td class="titlefield">'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
631 $result = $adh->fetch(
'',
'', $object->id);
633 $adh->ref = $adh->getFullName($langs);
634 print $adh->getNomUrl(-1);
636 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
645 if ($object->client == 2 || $object->client == 3) {
648 print
'<div class="underbanner clearboth"></div>';
649 print
'<table class="border centpercent tableforfield">';
652 print
'<tr><td class="titlefield nowrap">';
653 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
654 print $langs->trans(
'ProspectLevel');
656 if ($action !=
'editlevel' && $user->rights->societe->creer) {
657 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>';
659 print
'</tr></table>';
661 if ($action ==
'editlevel') {
662 $formcompany->form_prospect_level($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_prospectlevel,
'prospect_level_id', 1);
664 print $object->getLibProspLevel();
670 $object->loadCacheOfProspStatus();
671 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id][
'label']);
672 print
' ';
673 print
'<div class="floatright">';
674 foreach ($object->cacheprospectstatus as $key => $val) {
675 $titlealt =
'default';
676 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
677 $titlealt = $val[
'label'];
679 if ($object->stcomm_id != $val[
'id']) {
680 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>';
683 print
'</div></td></tr>';
687 print
'</div><div class="fichehalfright">';
688 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
693 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
696 $boxstat .=
'<div class="box box-halfright">';
697 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
698 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
700 if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
702 $tmp = $object->getOutstandingProposals();
703 $outstandingOpened = $tmp[
'opened'];
704 $outstandingTotal = $tmp[
'total_ht'];
705 $outstandingTotalIncTax = $tmp[
'total_ttc'];
706 $text = $langs->trans(
"OverAllProposals");
707 $link = DOL_URL_ROOT.
'/comm/propal/list.php?socid='.$object->id;
710 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
712 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
713 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
714 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
715 $boxstat .=
'</div>';
721 if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
723 $tmp = $object->getOutstandingOrders();
724 $outstandingOpened = $tmp[
'opened'];
725 $outstandingTotal = $tmp[
'total_ht'];
726 $outstandingTotalIncTax = $tmp[
'total_ttc'];
727 $text = $langs->trans(
"OverAllOrders");
728 $link = DOL_URL_ROOT.
'/commande/list.php?socid='.$object->id;
731 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
733 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
734 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
735 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
736 $boxstat .=
'</div>';
742 if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
744 $tmp = $object->getOutstandingBills(
'customer', 0);
745 $outstandingOpened = $tmp[
'opened'];
746 $outstandingTotal = $tmp[
'total_ht'];
747 $outstandingTotalIncTax = $tmp[
'total_ttc'];
749 $text = $langs->trans(
"OverAllInvoices");
750 $link = DOL_URL_ROOT.
'/compta/facture/list.php?socid='.$object->id;
753 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
755 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
756 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
757 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
758 $boxstat .=
'</div>';
765 if ($object->outstanding_limit !=
'' && $object->outstanding_limit < $outstandingOpened) {
766 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
768 $text = $langs->trans(
"CurrentOutstandingBill");
769 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.$object->id;
772 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
774 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
775 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
776 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
777 $boxstat .=
'</div>';
782 $tmp = $object->getOutstandingBills(
'customer', 1);
783 $outstandingOpenedLate = $tmp[
'opened'];
784 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
786 if ($object->outstanding_limit !=
'' && $object->outstanding_limit < $outstandingOpenedLate) {
787 $warn =
' '.img_warning($langs->trans(
"OutstandingBillReached"));
789 $text = $langs->trans(
"CurrentOutstandingBillLate");
790 $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.$object->id;
793 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
795 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
796 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
797 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
798 $boxstat .=
'</div>';
805 $parameters = array();
806 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', $parameters, $object, $action);
807 if (empty($reshook)) {
808 $boxstat .= $hookmanager->resPrint;
811 $boxstat .=
'</td></tr>';
812 $boxstat .=
'</table>';
813 $boxstat .=
'</div>';
821 if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
822 $langs->load(
"propal");
824 $sql =
"SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
825 $sql .=
", p.total_tva";
826 $sql .=
", p.total_ttc";
827 $sql .=
", p.ref, p.ref_client, p.remise";
828 $sql .=
", p.datep as dp, p.fin_validite as date_limit, p.entity";
829 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
830 $sql .=
" WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
831 $sql .=
" AND s.rowid = ".((int) $object->id);
832 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
833 $sql .=
" ORDER BY p.datep DESC";
835 $resql = $db->query($sql);
837 $propal_static =
new Propal($db);
839 $num = $db->num_rows(
$resql);
841 print
'<div class="div-table-responsive-no-min">';
842 print
'<table class="noborder centpercent lastrecordtable">';
844 print
'<tr class="liste_titre">';
845 print
'<td colspan="4"><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.
'">'.$langs->trans(
"AllPropals").
'<span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
846 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>';
847 print
'</tr></table></td>';
852 while ($i < $num && $i < $MAXLIST) {
853 $objp = $db->fetch_object(
$resql);
855 print
'<tr class="oddeven">';
856 print
'<td class="nowraponall">';
857 $propal_static->id = $objp->propalid;
858 $propal_static->ref = $objp->ref;
859 $propal_static->ref_client = $objp->ref_client;
860 $propal_static->total_ht = $objp->total_ht;
861 $propal_static->total_tva = $objp->total_tva;
862 $propal_static->total_ttc = $objp->total_ttc;
863 print $propal_static->getNomUrl(1);
868 if (!empty($filedir)) {
869 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
871 if (is_array($file_list)) {
875 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
876 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
883 if (!empty($sortfield) && !empty($sortorder)) {
888 print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0);
894 if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
895 print
" ".img_warning();
897 print
'</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
898 print
'<td class="right" style="min-width: 60px">'.price($objp->total_ht).
'</td>';
899 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).
'</td></tr>';
916 if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
919 $sql =
"SELECT s.nom, s.rowid";
920 $sql .=
", c.rowid as cid, c.entity, c.total_ht";
921 $sql .=
", c.total_tva";
922 $sql .=
", c.total_ttc";
923 $sql .=
", c.ref, c.ref_client, c.fk_statut, c.facture";
924 $sql .=
", c.date_commande as dc";
925 $sql .=
", c.facture as billed";
926 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
927 $sql .=
" WHERE c.fk_soc = s.rowid ";
928 $sql .=
" AND s.rowid = ".((int) $object->id);
929 $sql .=
" AND c.entity IN (".getEntity(
'commande').
')';
930 $sql .=
" ORDER BY c.date_commande DESC";
932 $resql = $db->query($sql);
934 $commande_static =
new Commande($db);
936 $num = $db->num_rows(
$resql);
939 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
940 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
941 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
942 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande as c';
943 $sql2 .=
' WHERE c.fk_soc = s.rowid';
944 $sql2 .=
' AND s.rowid = '.((int) $object->id);
946 $sql2 .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
948 $resql2 = $db->query($sql2);
949 $orders2invoice = $db->num_rows($resql2);
952 print
'<div class="div-table-responsive-no-min">';
953 print
'<table class="noborder centpercent lastrecordtable">';
955 print
'<tr class="liste_titre">';
956 print
'<td colspan="4"><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.
'">'.$langs->trans(
"AllOrders").
'<span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
957 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>';
958 print
'</tr></table></td>';
963 while ($i < $num && $i < $MAXLIST) {
964 $objp = $db->fetch_object(
$resql);
966 $commande_static->id = $objp->cid;
967 $commande_static->ref = $objp->ref;
968 $commande_static->ref_client = $objp->ref_client;
969 $commande_static->total_ht = $objp->total_ht;
970 $commande_static->total_tva = $objp->total_tva;
971 $commande_static->total_ttc = $objp->total_ttc;
972 $commande_static->billed = $objp->billed;
974 print
'<tr class="oddeven">';
975 print
'<td class="nowraponall">';
976 print $commande_static->getNomUrl(1);
978 $filedir = $conf->commande->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
980 if (!empty($filedir)) {
981 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
983 if (is_array($file_list)) {
987 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
988 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
995 if (!empty($sortfield) && !empty($sortorder)) {
1000 print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0, $param);
1008 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
"</td>\n";
1009 print
'<td class="right" style="min-width: 60px">'.price($objp->total_ht).
'</td>';
1010 print
'<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).
'</td></tr>';
1027 if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
1028 $sql =
'SELECT e.rowid as id';
1029 $sql .=
', e.ref, e.entity';
1030 $sql .=
', e.date_creation';
1031 $sql .=
', e.fk_statut as statut';
1033 $sql .=
', s.rowid as socid';
1034 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"expedition as e";
1035 $sql .=
" WHERE e.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1036 $sql .=
" AND e.entity IN (".getEntity(
'expedition').
")";
1037 $sql .=
' GROUP BY e.rowid';
1038 $sql .=
', e.ref, e.entity';
1039 $sql .=
', e.date_creation';
1040 $sql .=
', e.fk_statut';
1042 $sql .=
', s.rowid';
1043 $sql .=
" ORDER BY e.date_creation DESC";
1045 $resql = $db->query($sql);
1049 $num = $db->num_rows(
$resql);
1051 print
'<div class="div-table-responsive-no-min">';
1052 print
'<table class="noborder centpercent lastrecordtable">';
1054 print
'<tr class="liste_titre">';
1055 print
'<td colspan="4"><table width="100%" class="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.
'">'.$langs->trans(
"AllSendings").
'<span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1056 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>';
1057 print
'</tr></table></td>';
1062 while ($i < $num && $i < $MAXLIST) {
1063 $objp = $db->fetch_object(
$resql);
1065 $sendingstatic->id = $objp->id;
1066 $sendingstatic->ref = $objp->ref;
1068 print
'<tr class="oddeven">';
1069 print
'<td class="nowraponall">';
1070 print $sendingstatic->getNomUrl(1);
1072 $filedir = $conf->expedition->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1074 if (!empty($filedir)) {
1075 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1077 if (is_array($file_list)) {
1081 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1082 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1089 if (!empty($sortfield) && !empty($sortorder)) {
1094 print $formfile->showPreview($file_list, $sendingstatic->element, $relativepath, 0, $param);
1101 if ($objp->date_creation > 0) {
1102 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
1104 print
'<td class="right"><b>!!!</b></td>';
1107 print
'<td class="nowrap right" width="100" >'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
1125 if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
1126 $sql =
"SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, 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,";
1127 $sql .=
" c.last_main_doc, c.model_pdf";
1128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
1129 $sql .=
" WHERE c.fk_soc = s.rowid ";
1130 $sql .=
" AND s.rowid = ".((int) $object->id);
1131 $sql .=
" AND c.entity IN (".getEntity(
'contract').
")";
1132 $sql .=
" ORDER BY c.datec DESC";
1134 $resql = $db->query($sql);
1138 $num = $db->num_rows(
$resql);
1140 print
'<div class="div-table-responsive-no-min">';
1141 print
'<table class="noborder centpercent lastrecordtable">';
1143 print
'<tr class="liste_titre">';
1144 print
'<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
"LastContracts", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
1145 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>';
1147 print
'</tr></table></td>';
1152 while ($i < $num && $i < $MAXLIST) {
1153 $objp = $db->fetch_object(
$resql);
1155 $contrat->id = $objp->id;
1156 $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
1157 $contrat->ref_customer = $objp->refcus;
1158 $contrat->ref_supplier = $objp->refsup;
1159 $contrat->statut = $objp->contract_status;
1160 $contrat->last_main_doc = $objp->last_main_doc;
1161 $contrat->model_pdf = $objp->model_pdf;
1162 $contrat->fetch_lines();
1165 foreach ($contrat->lines as $line) {
1166 if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
1167 if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) {
1173 print
'<tr class="oddeven">';
1174 print
'<td class="nowraponall">';
1175 print $contrat->getNomUrl(1, 12);
1176 if (!empty($contrat->model_pdf)) {
1178 $filedir = $conf->contrat->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1180 if (!empty($filedir)) {
1181 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1183 if (is_array($file_list)) {
1187 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1188 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1195 if (!empty($sortfield) && !empty($sortorder)) {
1200 print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0);
1209 print
'<td class="nowrap">'.dol_trunc($objp->refsup, 12).
"</td>\n";
1211 print
'<td class="right" width="80px"><span title="'.$langs->trans(
"DateContract").
'">'.
dol_print_date($db->jdate($objp->dcon),
'day').
"</span></td>\n";
1212 print
'<td width="20"> </td>';
1213 print
'<td class="nowraponall right">';
1214 print $contrat->getLibStatut(4);
1233 if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) {
1234 $sql =
"SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate, f.entity";
1235 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"fichinter as f";
1236 $sql .=
" WHERE f.fk_soc = s.rowid";
1237 $sql .=
" AND s.rowid = ".((int) $object->id);
1238 $sql .=
" AND f.entity IN (".getEntity(
'intervention').
")";
1239 $sql .=
" ORDER BY f.tms DESC";
1241 $resql = $db->query($sql);
1245 $num = $db->num_rows(
$resql);
1247 print
'<div class="div-table-responsive-no-min">';
1248 print
'<table class="noborder centpercent lastrecordtable">';
1250 print
'<tr class="liste_titre">';
1251 print
'<td colspan="3"><table width="100%" class="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.
'">'.$langs->trans(
"AllInterventions").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td>';
1252 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>';
1253 print
'</tr></table></td>';
1258 while ($i < $num && $i < $MAXLIST) {
1259 $objp = $db->fetch_object(
$resql);
1261 $fichinter_static->id = $objp->id;
1262 $fichinter_static->ref = $objp->ref;
1263 $fichinter_static->statut = $objp->fk_statut;
1265 print
'<tr class="oddeven">';
1266 print
'<td class="nowraponall">';
1267 print $fichinter_static->getNomUrl(1);
1269 $filedir = $conf->ficheinter->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1271 if (!empty($filedir)) {
1272 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1274 if (is_array($file_list)) {
1278 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1279 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1286 if (!empty($sortfield) && !empty($sortorder)) {
1291 print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0);
1299 print
'<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).
'</td>'.
"\n";
1300 print
'<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).
'</td>'.
"\n";
1319 if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
1320 $sql =
'SELECT f.rowid as id, f.titre as ref';
1321 $sql .=
', f.total_ht';
1322 $sql .=
', f.total_tva';
1323 $sql .=
', f.total_ttc';
1324 $sql .=
', f.datec as dc';
1325 $sql .=
', f.date_last_gen, f.date_when';
1326 $sql .=
', f.frequency';
1327 $sql .=
', f.unit_frequency';
1328 $sql .=
', f.suspended as suspended';
1329 $sql .=
', s.nom, s.rowid as socid';
1330 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_rec as f";
1331 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1332 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1333 $sql .=
' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
1334 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
1335 $sql .=
' f.suspended, f.date_when,';
1336 $sql .=
' s.nom, s.rowid';
1337 $sql .=
" ORDER BY f.date_last_gen, f.datec DESC";
1339 $resql = $db->query($sql);
1343 $num = $db->num_rows(
$resql);
1345 print
'<div class="div-table-responsive-no-min">';
1346 print
'<table class="noborder centpercent lastrecordtable">';
1348 print
'<tr class="liste_titre">';
1349 print
'<td colspan="4"><table width="100%" class="nobordernopadding"><tr><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.
'">'.$langs->trans(
"AllCustomerTemplateInvoices").
'<span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1350 print
'</tr></table></td>';
1355 while ($i < $num && $i < $MAXLIST) {
1356 $objp = $db->fetch_object(
$resql);
1358 $invoicetemplate->id = $objp->id;
1359 $invoicetemplate->ref = $objp->ref;
1360 $invoicetemplate->suspended = $objp->suspended;
1361 $invoicetemplate->frequency = $objp->frequency;
1362 $invoicetemplate->unit_frequency = $objp->unit_frequency;
1363 $invoicetemplate->total_ht = $objp->total_ht;
1364 $invoicetemplate->total_tva = $objp->total_tva;
1365 $invoicetemplate->total_ttc = $objp->total_ttc;
1366 $invoicetemplate->date_last_gen = $objp->date_last_gen;
1367 $invoicetemplate->date_when = $objp->date_when;
1369 print
'<tr class="oddeven">';
1370 print
'<td class="nowrap">';
1371 print $invoicetemplate->getNomUrl(1);
1374 if ($objp->frequency && $objp->date_last_gen > 0) {
1375 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
1377 if ($objp->dc > 0) {
1378 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
1380 print
'<td class="right"><b>!!!</b></td>';
1383 print
'<td class="right" style="min-width: 60px">';
1384 print
price($objp->total_ht);
1387 if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
1388 print
'<td class="right" style="min-width: 60px">';
1389 print
price($objp->total_ttc);
1393 print
'<td class="nowrap right" style="min-width: 60px">';
1394 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
1395 print ($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
1414 if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
1415 $sql =
'SELECT f.rowid as facid, f.ref, f.type';
1416 $sql .=
', f.total_ht';
1417 $sql .=
', f.total_tva';
1418 $sql .=
', f.total_ttc';
1419 $sql .=
', f.entity';
1420 $sql .=
', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status';
1421 $sql .=
', s.nom, s.rowid as socid';
1422 $sql .=
', SUM(pf.amount) as am';
1423 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
1424 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON f.rowid=pf.fk_facture';
1425 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
1426 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
1427 $sql .=
' GROUP BY f.rowid, f.ref, f.type, f.total_ht, f.total_tva, f.total_ttc,';
1428 $sql .=
' f.entity, f.datef, f.datec, f.paye, f.fk_statut,';
1429 $sql .=
' s.nom, s.rowid';
1430 $sql .=
" ORDER BY f.datef DESC, f.datec DESC";
1432 $resql = $db->query($sql);
1434 $facturestatic =
new Facture($db);
1436 $num = $db->num_rows(
$resql);
1438 print
'<div class="div-table-responsive-no-min">';
1439 print
'<table class="noborder centpercent lastrecordtable">';
1441 print
'<tr class="liste_titre">';
1442 print
'<td colspan="5"><table width="100%" class="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.
'">'.$langs->trans(
"AllBills").
'<span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
1443 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>';
1444 print
'</tr></table></td>';
1449 while ($i < $num && $i < $MAXLIST) {
1450 $objp = $db->fetch_object(
$resql);
1452 $facturestatic->id = $objp->facid;
1453 $facturestatic->ref = $objp->ref;
1454 $facturestatic->type = $objp->type;
1455 $facturestatic->total_ht = $objp->total_ht;
1456 $facturestatic->total_tva = $objp->total_tva;
1457 $facturestatic->total_ttc = $objp->total_ttc;
1458 $facturestatic->statut = $objp->status;
1460 print
'<tr class="oddeven">';
1461 print
'<td class="nowraponall">';
1462 print $facturestatic->getNomUrl(1);
1464 $filedir = $conf->facture->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
1466 if (!empty($filedir)) {
1467 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
1469 if (is_array($file_list)) {
1473 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
1474 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1481 if (!empty($sortfield) && !empty($sortorder)) {
1486 print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0);
1493 if ($objp->df > 0) {
1494 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->df),
'day').
'</td>';
1496 print
'<td class="right"><b>!!!</b></td>';
1498 print
'<td class="right" style="min-width: 60px">';
1499 print
price($objp->total_ht);
1502 if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
1503 print
'<td class="right" style="min-width: 60px">';
1504 print
price($objp->total_ttc);
1508 print
'<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).
'</td>';
1524 $parameters = array();
1525 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
1529 print $hookmanager->resPrint;
1532 print
'</div></div>';
1533 print
'<div style="clear:both"></div>';
1541 print
'<div class="tabsAction">';
1543 $parameters = array();
1544 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1546 if (empty($reshook)) {
1547 if ($object->status != 1) {
1548 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"ThirdPartyIsClosed").
'</a></div>';
1551 if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) {
1552 $langs->load(
"propal");
1553 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>';
1556 if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) {
1557 $langs->load(
"orders");
1558 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>';
1561 if (!empty($user->rights->contrat->creer) && $object->status == 1) {
1562 $langs->load(
"contracts");
1563 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>';
1566 if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) {
1567 $langs->load(
"fichinter");
1568 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>';
1572 if ($user->socid == 0) {
1573 if (!empty($conf->deplacement->enabled) && $object->status == 1) {
1574 $langs->load(
"trips");
1575 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>';
1579 if (empty($user->rights->facture->creer)) {
1580 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1582 $langs->loadLangs(array(
"orders",
"bills"));
1584 if (!empty($conf->commande->enabled)) {
1585 if ($object->client != 0 && $object->client != 2) {
1586 if (!empty($orders2invoice) && $orders2invoice > 0) {
1587 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>';
1589 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
1592 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1596 if ($object->client != 0 && $object->client != 2) {
1597 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>';
1599 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
1606 if (
isModEnabled(
'agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
1607 if ($user->rights->agenda->myactions->create) {
1608 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>';
1610 print
'<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddAction").
'</a></div>';
1617 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) {
1619 show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
1622 if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {
1632 $langs->load(
"errors");
1633 print $langs->trans(
'ErrorRecordNotFound');
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
show_contacts($conf, $langs, $db, $object, $backtopage= '', $showuserlogin=0)
Show html area for list of contacts.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow= '')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
Complete $filearray with data from database.
Class to manage interventions.
dol_now($mode= 'auto')
Return date for now.
Class to manage invoice templates.
Class to manage Dolibarr users.
Class to manage customers or prospects.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage contracts.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
show_actions_done($conf, $langs, $db, $filterobj, $objcon= '', $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).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
img_action($titlealt, $numaction, $picto= '')
Show logo action.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage shipments.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage customers orders.
Class to manage members of a foundation.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage invoices.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon= '', $noprint=0, $actioncode= '')
Show html area with actions to do.
Class to manage proposals.