36 require 
'../main.inc.php';
 
   37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
 
   38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
 
   39 require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
 
   40 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
 
   41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
 
   42 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
 
   43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   45   require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
 
   46   require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
 
   49   require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
 
   52   require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
 
   55   require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
 
   58   require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
 
   61   require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
 
   64   require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
 
   68 $langs->loadLangs(array(
'companies', 
'banks'));
 
   71   $langs->load(
"contracts");
 
   74   $langs->load(
"orders");
 
   77   $langs->load(
"sendings");
 
   80   $langs->load(
"bills");
 
   83   $langs->load(
"projects");
 
   86   $langs->load(
"interventions");
 
   89   $langs->load(
"mails");
 
   92 $action = 
GETPOST(
'action', 
'aZ09');
 
   96 $limit = 
GETPOST(
'limit', 
'int') ? 
GETPOST(
'limit', 
'int') : $conf->liste_limit;
 
   97 $sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   98 $sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
  100 if (empty($page) || $page == -1) {
 
  103 $offset = $limit * $page;
 
  104 $pageprev = $page - 1;
 
  105 $pagenext = $page + 1;
 
  112 $cancel = 
GETPOST(
'cancel', 
'alpha');
 
  114 $object = 
new Client($db);
 
  119 $extrafields->fetch_name_optionals_label($object->table_element);
 
  122 $hookmanager->initHooks(array(
'thirdpartycomm', 
'globalcard'));
 
  126 if ($id > 0 && empty($object->id)) {
 
  128   $res = $object->fetch($id);
 
  129   if ($object->id < 0) {
 
  133 if ($object->id > 0) {
 
  134   if (!($object->client > 0) || !$user->hasRight(
'societe', 
'lire')) {
 
  140 if ($user->socid > 0) {
 
  143 $result = 
restrictedArea($user, 
'societe', $object->id, 
'&societe', 
'', 
'fk_soc', 
'rowid', 0);
 
  151 $reshook = $hookmanager->executeHooks(
'doActions', 
$parameters, $object, $action); 
 
  156 if (empty($reshook)) {
 
  162   if ($action == 
'setcustomeraccountancycode') {
 
  163     $result = $object->fetch($id);
 
  164     $object->code_compta_client = 
GETPOST(
"customeraccountancycode");
 
  165     $object->code_compta = $object->code_compta_client; 
 
  166     $result = $object->update($object->id, $user, 1, 1, 0);
 
  173   if ($action == 
'setconditions' && $user->rights->societe->creer) {
 
  175     $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id', 
'int'), 
GETPOST(
'cond_reglement_id_deposit_percent', 
'alpha'));
 
  182   if ($action == 
'setmode' && $user->rights->societe->creer) {
 
  184     $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id', 
'int'));
 
  191   if ($action == 
'settransportmode' && $user->rights->societe->creer) {
 
  193     $result = $object->setTransportMode(
GETPOST(
'transport_mode_id', 
'alpha'));
 
  200   if ($action == 
'setbankaccount' && $user->rights->societe->creer) {
 
  202     $result = $object->setBankAccount(
GETPOST(
'fk_account', 
'int'));
 
  209   if ($action == 
'setshippingmethod' && $user->rights->societe->creer) {
 
  211     $result = $object->setShippingMethod(
GETPOST(
'shipping_method_id', 
'int'));
 
  218   if ($action == 
'setassujtva' && $user->rights->societe->creer) {
 
  220     $object->tva_assuj = 
GETPOST(
'assujtva_value');
 
  221     $result = $object->update($object->id);
 
  228   if ($action == 
'setprospectlevel' && $user->rights->societe->creer) {
 
  230     $object->fk_prospectlevel = 
GETPOST(
'prospect_level_id', 
'alpha');
 
  231     $result = $object->update($object->id, $user);
 
  238   if ($action == 
'setstcomm') {
 
  241     $result = $object->update($object->id, $user);
 
  245       $result = $object->fetch($object->id);
 
  250   if ($action == 
'setoutstanding_limit') {
 
  252     $object->outstanding_limit = 
GETPOST(
'outstanding_limit');
 
  253     $result = $object->update($object->id, $user);
 
  260   if ($action == 
'setorder_min_amount') {
 
  262     $object->order_min_amount = 
price2num(
GETPOST(
'order_min_amount', 
'alpha'));
 
  263     $result = $object->update($object->id, $user);
 
  270   if ($action == 
'set_salesrepresentatives' && $user->rights->societe->creer) {
 
  272     $result = $object->setSalesRep(
GETPOST(
'commercial', 
'array'));
 
  275   if ($action == 
'update_extras') {
 
  281     $ret = $extrafields->setOptionalsFromPost(
null, $object, 
GETPOST(
'attribute', 
'restricthtml'));
 
  286       $result = $object->insertExtraFields(
'COMPANY_MODIFY');
 
  293       $action = 
'edit_extras';
 
  298   if ($action == 
'setwarehouse' && $user->rights->societe->creer) {
 
  299     $result = $object->setWarehouse(
GETPOST(
'fk_warehouse', 
'int'));
 
  308 $contactstatic = 
new Contact($db);
 
  309 $userstatic = 
new User($db);
 
  313 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Customer');
 
  314 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
 
  315   $title = $object->name.
" - ".$langs->trans(
'Customer');
 
  318 $help_url = 
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
 
  323 if ($object->id > 0) {
 
  326   print 
dol_get_fiche_head($head, 
'customer', $langs->trans(
"ThirdParty"), -1, 
'company');
 
  328   $linkback = 
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
 
  330   dol_banner_tab($object, 
'socid', $linkback, ($user->socid ? 0 : 1), 
'rowid', 
'nom');
 
  332   print 
'<div class="fichecenter"><div class="fichehalfleft">';
 
  334   print 
'<div class="underbanner clearboth"></div>';
 
  335   print 
'<table class="border centpercent tableforfield">';
 
  338   print 
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
 
  339   print $object->getTypeUrl(1);
 
  343   if (!empty($conf->global->SOCIETE_USEPREFIX)) {  
 
  344     print 
'<tr><td>'.$langs->trans(
"Prefix").
'</td><td>';
 
  345     print ($object->prefix_comm ? $object->prefix_comm : 
' ');
 
  349   if ($object->client) {
 
  350     $langs->load(
"compta");
 
  353     print $langs->trans(
'CustomerCode').
'</td><td>';
 
  355     $tmpcheck = $object->check_codeclient();
 
  356     if ($tmpcheck != 0 && $tmpcheck != -5) {
 
  357       print 
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
 
  363     print 
$form->editfieldkey(
"CustomerAccountancyCode", 
'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
 
  365     print 
$form->editfieldval(
"CustomerAccountancyCode", 
'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
 
  386   if ($mysoc->country_code == 
'ES') {
 
  388     if ($mysoc->localtax1_assuj == 
"1") {
 
  389       print 
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
 
  390       print 
yn($object->localtax1_assuj);
 
  393     if ($mysoc->localtax1_assuj == 
"1") {
 
  394       print 
'<tr><td class="nowrap">'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
 
  395       print 
yn($object->localtax2_assuj);
 
  401   print 
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
 
  406   $langs->load(
'bills');
 
  408   print 
'<table width="100%" class="nobordernopadding"><tr><td>';
 
  409   print $langs->trans(
'PaymentConditions');
 
  411   if (($action != 
'editconditions') && $user->rights->societe->creer) {
 
  412     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>';
 
  414   print 
'</tr></table>';
 
  416   if ($action == 
'editconditions') {
 
  417     $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_id, 
'cond_reglement_id', 1, 
'', 1, $object->deposit_percent);
 
  419     $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_id, 
'none', 0, 
'', 1, $object->deposit_percent);
 
  425   print 
'<tr><td class="nowrap">';
 
  426   print 
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 
  427   print $langs->trans(
'PaymentMode');
 
  429   if (($action != 
'editmode') && $user->rights->societe->creer) {
 
  430     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>';
 
  432   print 
'</tr></table>';
 
  434   if ($action == 
'editmode') {
 
  435     $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_id, 
'mode_reglement_id', 
'CRDT', 1, 1);
 
  437     $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_id, 
'none');
 
  444     print 
'<tr><td class="nowrap">';
 
  445     print 
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 
  446     print $langs->trans(
'PaymentBankAccount');
 
  448     if (($action != 
'editbankaccount') && $user->rights->societe->creer) {
 
  449       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>';
 
  451     print 
'</tr></table>';
 
  453     if ($action == 
'editbankaccount') {
 
  454       $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account, 
'fk_account', 1);
 
  456       $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account, 
'none');
 
  462   $isCustomer = ($object->client == 1 || $object->client == 3);
 
  466     print 
'<tr><td class="nowrap">';
 
  467     print 
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 
  468     print $langs->trans(
"CustomerRelativeDiscountShort");
 
  469     print 
'<td><td class="right">';
 
  470     if ($user->rights->societe->creer && !$user->socid > 0) {
 
  471       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>';
 
  473     print 
'</td></tr></table>';
 
  474     print 
'</td><td>'.($object->remise_percent ? 
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.$object->remise_percent.
'%</a>' : 
'').
'</td>';
 
  478     print 
'<tr><td class="nowrap">';
 
  479     print 
'<table width="100%" class="nobordernopadding">';
 
  480     print 
'<tr><td class="nowrap">';
 
  481     print $langs->trans(
"CustomerAbsoluteDiscountShort");
 
  482     print 
'<td><td class="right">';
 
  483     if ($user->rights->societe->creer && !$user->socid > 0) {
 
  484       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>';
 
  486     print 
'</td></tr></table>';
 
  489     $amount_discount = $object->getAvailableDiscounts();
 
  490     if ($amount_discount < 0) {
 
  493     if ($amount_discount > 0) {
 
  494       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>';
 
  502   if ($object->client) {
 
  503     print 
'<tr class="nowrap">';
 
  505     print 
$form->editfieldkey(
"OutstandingBill", 
'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer);
 
  507     $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 
'numeric' : 
'amount';
 
  508     print 
$form->editfieldval(
"OutstandingBill", 
'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit != 
'' ? 
price($object->outstanding_limit) : 
''));
 
  513   if ($object->client) {
 
  514     if (
isModEnabled(
'commande') && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
 
  515       print 
'<!-- Minimim amount for orders -->'.
"\n";
 
  516       print 
'<tr class="nowrap">';
 
  518       print 
$form->editfieldkey(
"OrderMinAmount", 
'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer);
 
  520       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) : 
''));
 
  528   if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
 
  529     print 
'<tr><td class="nowrap">';
 
  530     print 
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 
  531     print $langs->trans(
"PriceLevel");
 
  532     print 
'<td><td class="right">';
 
  533     if ($user->rights->societe->creer) {
 
  534       print 
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/multiprix.php?id='.$object->id.
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
 
  536     print 
'</td></tr></table>';
 
  538     print $object->price_level;
 
  539     $keyforlabel = 
'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
 
  540     if (!empty($conf->global->$keyforlabel)) {
 
  541       print 
' - '.$langs->trans($conf->global->$keyforlabel);
 
  548   if (
isModEnabled(
'stock') && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
 
  549     $langs->load(
'stocks');
 
  550     require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
 
  552     print 
'<tr class="nowrap">';
 
  554     print 
$form->editfieldkey(
"Warehouse", 
'warehouse', 
'', $object, $user->rights->societe->creer);
 
  556     if ($action == 
'editwarehouse') {
 
  557       $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse, 
'fk_warehouse', 1);
 
  559       if ($object->fk_warehouse > 0) {
 
  560         print 
img_picto(
'', 
'stock', 
'class="paddingrightonly"');
 
  562       $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse, 
'none');
 
  569   if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
 
  570     print 
'<tr><td class="nowrap">';
 
  571     print 
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 
  572     print $langs->trans(
'SendingMethod');
 
  574     if (($action != 
'editshipping') && $user->rights->societe->creer) {
 
  575       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>';
 
  577     print 
'</tr></table>';
 
  579     if ($action == 
'editshipping') {
 
  580       $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->shipping_method_id, 
'shipping_method_id', 1);
 
  582       $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->shipping_method_id, 
'none');
 
  590     print 
'<tr><td class="nowrap">';
 
  591     print 
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
 
  592     print $langs->trans(
'IntracommReportTransportMode');
 
  594     if (($action != 
'edittransportmode') && $user->rights->societe->creer) {
 
  595       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>';
 
  597     print 
'</tr></table>';
 
  599     if ($action == 
'edittransportmode') {
 
  600       $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id : 
''), 
'transport_mode_id', 1);
 
  602       $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id : 
''), 
'none');
 
  609   if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
 
  610     $langs->load(
"categories");
 
  611     print 
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
 
  613     print 
$form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
 
  619   include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
 
  622   include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
 
  626     $langs->load(
"members");
 
  627     $langs->load(
"users");
 
  629     print 
'<tr><td class="titlefield">'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
 
  632     $result = $adh->fetch(
'', 
'', $object->id);
 
  634       $adh->ref = $adh->getFullName($langs);
 
  635       print $adh->getNomUrl(-1);
 
  637       print 
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
 
  645   print 
'</div><div class="fichehalfright">';
 
  648   if ($object->client == 2 || $object->client == 3) {
 
  649     print 
'<div class="underbanner clearboth"></div>';
 
  650     print 
'<table class="border centpercent tableforfield">';
 
  653     print 
'<tr><td class="titlefield nowrap">';
 
  654     print 
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
 
  655     print $langs->trans(
'ProspectLevel');
 
  657     if ($action != 
'editlevel' && $user->rights->societe->creer) {
 
  658       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>';
 
  660     print 
'</tr></table>';
 
  662     if ($action == 
'editlevel') {
 
  663       $formcompany->form_prospect_level($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_prospectlevel, 
'prospect_level_id', 1);
 
  665       print $object->getLibProspLevel();
 
  671     $object->loadCacheOfProspStatus();
 
  672     print 
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id][
'label']);
 
  673     print 
'     ';
 
  674     print 
'<div class="floatright">';
 
  675     foreach ($object->cacheprospectstatus as $key => $val) {
 
  676       $titlealt = 
'default';
 
  677       if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO', 
'ST_NEVER', 
'ST_TODO', 
'ST_PEND', 
'ST_DONE'))) {
 
  678         $titlealt = $val[
'label'];
 
  680       if ($object->stcomm_id != $val[
'id']) {
 
  681         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>';
 
  684     print 
'</div></td></tr>';
 
  689     print 
'<div class="underbanner underbanner-before-box clearboth"></div><br>';
 
  695   $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
 
  698   $boxstat .= 
'<div class="box box-halfright">';
 
  699   $boxstat .= 
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop boxtablenomarginbottom centpercent">';
 
  700   $boxstat .= 
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
 
  702   if (
isModEnabled(
"propal") && $user->rights->propal->lire) {
 
  704     $tmp = $object->getOutstandingProposals();
 
  705     $outstandingOpened = $tmp[
'opened'];
 
  706     $outstandingTotal = $tmp[
'total_ht'];
 
  707     $outstandingTotalIncTax = $tmp[
'total_ttc'];
 
  708     $text = $langs->trans(
"OverAllProposals");
 
  709     $link = DOL_URL_ROOT.
'/comm/propal/list.php?socid='.$object->id;
 
  712       $boxstat .= 
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
 
  714     $boxstat .= 
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
 
  715     $boxstat .= 
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
 
  716     $boxstat .= 
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
 
  717     $boxstat .= 
'</div>';
 
  723   if (
isModEnabled(
'commande') && $user->rights->commande->lire) {
 
  725     $tmp = $object->getOutstandingOrders();
 
  726     $outstandingOpened = $tmp[
'opened'];
 
  727     $outstandingTotal = $tmp[
'total_ht'];
 
  728     $outstandingTotalIncTax = $tmp[
'total_ttc'];
 
  729     $text = $langs->trans(
"OverAllOrders");
 
  730     $link = DOL_URL_ROOT.
'/commande/list.php?socid='.$object->id;
 
  733       $boxstat .= 
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
 
  735     $boxstat .= 
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
 
  736     $boxstat .= 
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
 
  737     $boxstat .= 
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
 
  738     $boxstat .= 
'</div>';
 
  744   if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
 
  746     $tmp = $object->getOutstandingBills(
'customer', 0);
 
  747     $outstandingOpened = $tmp[
'opened'];
 
  748     $outstandingTotal = $tmp[
'total_ht'];
 
  749     $outstandingTotalIncTax = $tmp[
'total_ttc'];
 
  751     $text = $langs->trans(
"OverAllInvoices");
 
  752     $link = DOL_URL_ROOT.
'/compta/facture/list.php?socid='.$object->id;
 
  755       $boxstat .= 
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
 
  757     $boxstat .= 
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
 
  758     $boxstat .= 
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
 
  759     $boxstat .= 
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
 
  760     $boxstat .= 
'</div>';
 
  767     if ($object->outstanding_limit != 
'' && $object->outstanding_limit < $outstandingOpened) {
 
  768       $warn = 
' '.img_warning($langs->trans(
"OutstandingBillReached"));
 
  770     $text = $langs->trans(
"CurrentOutstandingBill");
 
  771     $link = DOL_URL_ROOT.
'/compta/recap-compta.php?socid='.$object->id;
 
  774       $boxstat .= 
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
 
  776     $boxstat .= 
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
 
  777     $boxstat .= 
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
 
  778     $boxstat .= 
'<span class="boxstatsindicator'.($outstandingOpened > 0 ? 
' amountremaintopay' : 
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
 
  779     $boxstat .= 
'</div>';
 
  784     $tmp = $object->getOutstandingBills(
'customer', 1);
 
  785     $outstandingOpenedLate = $tmp[
'opened'];
 
  786     if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
 
  788       if ($object->outstanding_limit != 
'' && $object->outstanding_limit < $outstandingOpenedLate) {
 
  789         $warn = 
' '.img_warning($langs->trans(
"OutstandingBillReached"));
 
  791       $text = $langs->trans(
"CurrentOutstandingBillLate");
 
  792       $link = DOL_URL_ROOT.
'/compta/recap-compta.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'.($outstandingOpenedLate > 0 ? 
' amountremaintopay' : 
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
 
  800       $boxstat .= 
'</div>';
 
  808   $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsCustomer', 
$parameters, $object, $action);
 
  809   if (empty($reshook)) {
 
  810     $boxstat .= $hookmanager->resPrint;
 
  813   $boxstat .= 
'</td></tr>';
 
  814   $boxstat .= 
'</table>';
 
  815   $boxstat .= 
'</div>';
 
  823   if (
isModEnabled(
"propal") && $user->rights->propal->lire) {
 
  824     $langs->load(
"propal");
 
  826     $sql = 
"SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
 
  827     $sql .= 
", p.total_tva";
 
  828     $sql .= 
", p.total_ttc";
 
  829     $sql .= 
", p.ref, p.ref_client, p.remise";
 
  830     $sql .= 
", p.datep as dp, p.fin_validite as date_limit, p.entity";
 
  831     $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
 
  832     $sql .= 
" WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
 
  833     $sql .= 
" AND s.rowid = ".((int) $object->id);
 
  834     $sql .= 
" AND p.entity IN (".getEntity(
'propal').
")";
 
  835     $sql .= 
" ORDER BY p.datep DESC";
 
  837     $resql = $db->query($sql);
 
  839       $propal_static = 
new Propal($db);
 
  841       $num = $db->num_rows(
$resql);
 
  843         print 
'<div class="div-table-responsive-no-min">';
 
  844         print 
'<table class="noborder centpercent lastrecordtable">';
 
  846         print 
'<tr class="liste_titre">';
 
  847         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>';
 
  848         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>';
 
  849         print 
'</tr></table></td>';
 
  854       while ($i < $num && $i < $MAXLIST) {
 
  855         $objp = $db->fetch_object(
$resql);
 
  857         print 
'<tr class="oddeven">';
 
  858         print 
'<td class="nowraponall">';
 
  859         $propal_static->id = $objp->propalid;
 
  860         $propal_static->ref = $objp->ref;
 
  861         $propal_static->ref_client = $objp->ref_client;
 
  862         $propal_static->total_ht = $objp->total_ht;
 
  863         $propal_static->total_tva = $objp->total_tva;
 
  864         $propal_static->total_ttc = $objp->total_ttc;
 
  865         print $propal_static->getNomUrl(1);
 
  870         if (!empty($filedir)) {
 
  871           $file_list = 
dol_dir_list($filedir, 
'files', 0, 
'', 
'(\.meta|_preview.*.*\.png)$', 
'date', SORT_DESC);
 
  873         if (is_array($file_list)) {
 
  877             $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT, 
'/').
'/', 
'', $filedir);
 
  878             $relativedir = preg_replace(
'/^[\\/]/', 
'', $relativedir);
 
  885             if (!empty($sortfield) && !empty($sortorder)) { 
 
  890           print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0);
 
  896         if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
 
  897           print 
" ".img_warning();
 
  899         print 
'</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp), 
'day').
"</td>\n";
 
  900         print 
'<td class="right" style="min-width: 60px">'.price($objp->total_ht).
'</td>';
 
  901         print 
'<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).
'</td></tr>';
 
  918   if (
isModEnabled(
'commande') && $user->rights->commande->lire) {
 
  921     $sql = 
"SELECT s.nom, s.rowid";
 
  922     $sql .= 
", c.rowid as cid, c.entity, c.total_ht";
 
  923     $sql .= 
", c.total_tva";
 
  924     $sql .= 
", c.total_ttc";
 
  925     $sql .= 
", c.ref, c.ref_client, c.fk_statut, c.facture";
 
  926     $sql .= 
", c.date_commande as dc";
 
  927     $sql .= 
", c.facture as billed";
 
  928     $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
 
  929     $sql .= 
" WHERE c.fk_soc = s.rowid ";
 
  930     $sql .= 
" AND s.rowid = ".((int) $object->id);
 
  931     $sql .= 
" AND c.entity IN (".getEntity(
'commande').
')';
 
  932     $sql .= 
" ORDER BY c.date_commande DESC";
 
  934     $resql = $db->query($sql);
 
  936       $commande_static = 
new Commande($db);
 
  938       $num = $db->num_rows(
$resql);
 
  941         $sql2 = 
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
 
  942         $sql2 .= 
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
 
  943         $sql2 .= 
' FROM '.MAIN_DB_PREFIX.
'societe as s';
 
  944         $sql2 .= 
', '.MAIN_DB_PREFIX.
'commande as c';
 
  945         $sql2 .= 
' WHERE c.fk_soc = s.rowid';
 
  946         $sql2 .= 
' AND s.rowid = '.((int) $object->id);
 
  948         $sql2 .= 
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
 
  950         $resql2 = $db->query($sql2);
 
  951         $orders2invoice = $db->num_rows($resql2);
 
  954         print 
'<div class="div-table-responsive-no-min">';
 
  955         print 
'<table class="noborder centpercent lastrecordtable">';
 
  957         print 
'<tr class="liste_titre">';
 
  958         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>';
 
  959         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>';
 
  960         print 
'</tr></table></td>';
 
  965       while ($i < $num && $i < $MAXLIST) {
 
  966         $objp = $db->fetch_object(
$resql);
 
  968         $commande_static->id = $objp->cid;
 
  969         $commande_static->ref = $objp->ref;
 
  970         $commande_static->ref_client = $objp->ref_client;
 
  971         $commande_static->total_ht = $objp->total_ht;
 
  972         $commande_static->total_tva = $objp->total_tva;
 
  973         $commande_static->total_ttc = $objp->total_ttc;
 
  974         $commande_static->billed = $objp->billed;
 
  976         print 
'<tr class="oddeven">';
 
  977         print 
'<td class="nowraponall">';
 
  978         print $commande_static->getNomUrl(1);
 
  980         $filedir = $conf->commande->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
 
  982         if (!empty($filedir)) {
 
  983           $file_list = 
dol_dir_list($filedir, 
'files', 0, 
'', 
'(\.meta|_preview.*.*\.png)$', 
'date', SORT_DESC);
 
  985         if (is_array($file_list)) {
 
  989             $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT, 
'/').
'/', 
'', $filedir);
 
  990             $relativedir = preg_replace(
'/^[\\/]/', 
'', $relativedir);
 
  997             if (!empty($sortfield) && !empty($sortorder)) { 
 
 1002           print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0, $param);
 
 1010         print 
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 
'day').
"</td>\n";
 
 1011         print 
'<td class="right" style="min-width: 60px">'.price($objp->total_ht).
'</td>';
 
 1012         print 
'<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).
'</td></tr>';
 
 1029   if (
isModEnabled(
"expedition") && $user->rights->expedition->lire) {
 
 1030     $sql = 
'SELECT e.rowid as id';
 
 1031     $sql .= 
', e.ref, e.entity';
 
 1032     $sql .= 
', e.date_creation';
 
 1033     $sql .= 
', e.fk_statut as statut';
 
 1035     $sql .= 
', s.rowid as socid';
 
 1036     $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"expedition as e";
 
 1037     $sql .= 
" WHERE e.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
 
 1038     $sql .= 
" AND e.entity IN (".getEntity(
'expedition').
")";
 
 1039     $sql .= 
' GROUP BY e.rowid';
 
 1040     $sql .= 
', e.ref, e.entity';
 
 1041     $sql .= 
', e.date_creation';
 
 1042     $sql .= 
', e.fk_statut';
 
 1044     $sql .= 
', s.rowid';
 
 1045     $sql .= 
" ORDER BY e.date_creation DESC";
 
 1047     $resql = $db->query($sql);
 
 1051       $num = $db->num_rows(
$resql);
 
 1053         print 
'<div class="div-table-responsive-no-min">';
 
 1054         print 
'<table class="noborder centpercent lastrecordtable">';
 
 1056         print 
'<tr class="liste_titre">';
 
 1057         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>';
 
 1058         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>';
 
 1059         print 
'</tr></table></td>';
 
 1064       while ($i < $num && $i < $MAXLIST) {
 
 1065         $objp = $db->fetch_object(
$resql);
 
 1067         $sendingstatic->id = $objp->id;
 
 1068         $sendingstatic->ref = $objp->ref;
 
 1070         print 
'<tr class="oddeven">';
 
 1071         print 
'<td class="nowraponall">';
 
 1072         print $sendingstatic->getNomUrl(1);
 
 1074         $filedir = $conf->expedition->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
 
 1076         if (!empty($filedir)) {
 
 1077           $file_list = 
dol_dir_list($filedir, 
'files', 0, 
'', 
'(\.meta|_preview.*.*\.png)$', 
'date', SORT_DESC);
 
 1079         if (is_array($file_list)) {
 
 1083             $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT, 
'/').
'/', 
'', $filedir);
 
 1084             $relativedir = preg_replace(
'/^[\\/]/', 
'', $relativedir);
 
 1091             if (!empty($sortfield) && !empty($sortorder)) { 
 
 1096           print $formfile->showPreview($file_list, $sendingstatic->element, $relativepath, 0, $param);
 
 1103         if ($objp->date_creation > 0) {
 
 1104           print 
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 
'day').
'</td>';
 
 1106           print 
'<td class="right"><b>!!!</b></td>';
 
 1109         print 
'<td class="nowrap right" width="100" >'.$sendingstatic->LibStatut($objp->statut, 5).
'</td>';
 
 1127   if (
isModEnabled(
'contrat') && $user->rights->contrat->lire) {
 
 1128     $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,";
 
 1129     $sql .= 
" c.last_main_doc, c.model_pdf";
 
 1130     $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
 
 1131     $sql .= 
" WHERE c.fk_soc = s.rowid ";
 
 1132     $sql .= 
" AND s.rowid = ".((int) $object->id);
 
 1133     $sql .= 
" AND c.entity IN (".getEntity(
'contract').
")";
 
 1134     $sql .= 
" ORDER BY c.datec DESC";
 
 1136     $resql = $db->query($sql);
 
 1140       $num = $db->num_rows(
$resql);
 
 1142         print 
'<div class="div-table-responsive-no-min">';
 
 1143         print 
'<table class="noborder centpercent lastrecordtable">';
 
 1145         print 
'<tr class="liste_titre">';
 
 1146         print 
'<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
"LastContracts", ($num <= $MAXLIST ? 
"" : $MAXLIST)).
'</td>';
 
 1147         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>';
 
 1149         print 
'</tr></table></td>';
 
 1154       while ($i < $num && $i < $MAXLIST) {
 
 1155         $objp = $db->fetch_object(
$resql);
 
 1157         $contrat->id = $objp->id;
 
 1158         $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
 
 1159         $contrat->ref_customer = $objp->refcus;
 
 1160         $contrat->ref_supplier = $objp->refsup;
 
 1161         $contrat->statut = $objp->contract_status;
 
 1162         $contrat->last_main_doc = $objp->last_main_doc;
 
 1163         $contrat->model_pdf = $objp->model_pdf;
 
 1164         $contrat->fetch_lines();
 
 1167         foreach ($contrat->lines as $line) {
 
 1168           if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
 
 1169             if (((!empty($line->date_end) ? $line->date_end : 0) + $conf->contrat->services->expires->warning_delay) < $now) {
 
 1175         print 
'<tr class="oddeven">';
 
 1176         print 
'<td class="nowraponall">';
 
 1177         print $contrat->getNomUrl(1, 12);
 
 1178         if (!empty($contrat->model_pdf)) {
 
 1180           $filedir = $conf->contrat->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
 
 1182           if (!empty($filedir)) {
 
 1183             $file_list = 
dol_dir_list($filedir, 
'files', 0, 
'', 
'(\.meta|_preview.*.*\.png)$', 
'date', SORT_DESC);
 
 1185           if (is_array($file_list)) {
 
 1189               $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT, 
'/').
'/', 
'', $filedir);
 
 1190               $relativedir = preg_replace(
'/^[\\/]/', 
'', $relativedir);
 
 1197               if (!empty($sortfield) && !empty($sortorder)) { 
 
 1202             print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0);
 
 1211         print 
'<td class="nowrap">'.dol_trunc($objp->refsup, 12).
"</td>\n";
 
 1213         print 
'<td class="right" width="80px"><span title="'.$langs->trans(
"DateContract").
'">'.
dol_print_date($db->jdate($objp->dcon), 
'day').
"</span></td>\n";
 
 1214         print 
'<td width="20"> </td>';
 
 1215         print 
'<td class="nowraponall right">';
 
 1216         print $contrat->getLibStatut(4);
 
 1235   if (
isModEnabled(
'ficheinter') && $user->rights->ficheinter->lire) {
 
 1236     $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";
 
 1237     $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"fichinter as f";
 
 1238     $sql .= 
" WHERE f.fk_soc = s.rowid";
 
 1239     $sql .= 
" AND s.rowid = ".((int) $object->id);
 
 1240     $sql .= 
" AND f.entity IN (".getEntity(
'intervention').
")";
 
 1241     $sql .= 
" ORDER BY f.tms DESC";
 
 1243     $resql = $db->query($sql);
 
 1247       $num = $db->num_rows(
$resql);
 
 1249         print 
'<div class="div-table-responsive-no-min">';
 
 1250         print 
'<table class="noborder centpercent lastrecordtable">';
 
 1252         print 
'<tr class="liste_titre">';
 
 1253         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>';
 
 1254         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>';
 
 1255         print 
'</tr></table></td>';
 
 1260       while ($i < $num && $i < $MAXLIST) {
 
 1261         $objp = $db->fetch_object(
$resql);
 
 1263         $fichinter_static->id = $objp->id;
 
 1264         $fichinter_static->ref = $objp->ref;
 
 1265         $fichinter_static->statut = $objp->fk_statut;
 
 1267         print 
'<tr class="oddeven">';
 
 1268         print 
'<td class="nowraponall">';
 
 1269         print $fichinter_static->getNomUrl(1);
 
 1271         $filedir = $conf->ficheinter->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
 
 1273         if (!empty($filedir)) {
 
 1274           $file_list = 
dol_dir_list($filedir, 
'files', 0, 
'', 
'(\.meta|_preview.*.*\.png)$', 
'date', SORT_DESC);
 
 1276         if (is_array($file_list)) {
 
 1280             $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT, 
'/').
'/', 
'', $filedir);
 
 1281             $relativedir = preg_replace(
'/^[\\/]/', 
'', $relativedir);
 
 1288             if (!empty($sortfield) && !empty($sortorder)) { 
 
 1293           print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0);
 
 1301         print 
'<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).
'</td>'.
"\n";
 
 1302         print 
'<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).
'</td>'.
"\n";
 
 1321   if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
 
 1322     $sql = 
'SELECT f.rowid as id, f.titre as ref';
 
 1323     $sql .= 
', f.total_ht';
 
 1324     $sql .= 
', f.total_tva';
 
 1325     $sql .= 
', f.total_ttc';
 
 1326     $sql .= 
', f.datec as dc';
 
 1327     $sql .= 
', f.date_last_gen, f.date_when';
 
 1328     $sql .= 
', f.frequency';
 
 1329     $sql .= 
', f.unit_frequency';
 
 1330     $sql .= 
', f.suspended as suspended';
 
 1331     $sql .= 
', s.nom, s.rowid as socid';
 
 1332     $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_rec as f";
 
 1333     $sql .= 
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
 
 1334     $sql .= 
" AND f.entity IN (".getEntity(
'invoice').
")";
 
 1335     $sql .= 
' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
 
 1336     $sql .= 
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
 
 1337     $sql .= 
' f.suspended, f.date_when,';
 
 1338     $sql .= 
' s.nom, s.rowid';
 
 1339     $sql .= 
" ORDER BY f.date_last_gen, f.datec DESC";
 
 1341     $resql = $db->query($sql);
 
 1345       $num = $db->num_rows(
$resql);
 
 1347         print 
'<div class="div-table-responsive-no-min">';
 
 1348         print 
'<table class="noborder centpercent lastrecordtable">';
 
 1350         print 
'<tr class="liste_titre">';
 
 1351         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>';
 
 1352         print 
'</tr></table></td>';
 
 1357       while ($i < $num && $i < $MAXLIST) {
 
 1358         $objp = $db->fetch_object(
$resql);
 
 1360         $invoicetemplate->id = $objp->id;
 
 1361         $invoicetemplate->ref = $objp->ref;
 
 1362         $invoicetemplate->suspended = $objp->suspended;
 
 1363         $invoicetemplate->frequency = $objp->frequency;
 
 1364         $invoicetemplate->unit_frequency = $objp->unit_frequency;
 
 1365         $invoicetemplate->total_ht = $objp->total_ht;
 
 1366         $invoicetemplate->total_tva = $objp->total_tva;
 
 1367         $invoicetemplate->total_ttc = $objp->total_ttc;
 
 1368         $invoicetemplate->date_last_gen = $objp->date_last_gen;
 
 1369         $invoicetemplate->date_when = $objp->date_when;
 
 1371         print 
'<tr class="oddeven">';
 
 1372         print 
'<td class="nowrap">';
 
 1373         print $invoicetemplate->getNomUrl(1);
 
 1376         if ($objp->frequency && $objp->date_last_gen > 0) {
 
 1377           print 
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 
'day').
'</td>';
 
 1379           if ($objp->dc > 0) {
 
 1380             print 
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 
'day').
'</td>';
 
 1382             print 
'<td class="right"><b>!!!</b></td>';
 
 1385         print 
'<td class="right" style="min-width: 60px">';
 
 1386         print 
price($objp->total_ht);
 
 1389         if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
 
 1390           print 
'<td class="right" style="min-width: 60px">';
 
 1391           print 
price($objp->total_ttc);
 
 1395         print 
'<td class="nowrap right" style="min-width: 60px">';
 
 1396         print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
 
 1397         print ($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
 
 1416   if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
 
 1417     $sql = 
'SELECT f.rowid as facid, f.ref, f.type';
 
 1418     $sql .= 
', f.total_ht';
 
 1419     $sql .= 
', f.total_tva';
 
 1420     $sql .= 
', f.total_ttc';
 
 1421     $sql .= 
', f.entity';
 
 1422     $sql .= 
', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status';
 
 1423     $sql .= 
', s.nom, s.rowid as socid';
 
 1424     $sql .= 
', SUM(pf.amount) as am';
 
 1425     $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
 
 1426     $sql .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON f.rowid=pf.fk_facture';
 
 1427     $sql .= 
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
 
 1428     $sql .= 
" AND f.entity IN (".getEntity(
'invoice').
")";
 
 1429     $sql .= 
' GROUP BY f.rowid, f.ref, f.type, f.total_ht, f.total_tva, f.total_ttc,';
 
 1430     $sql .= 
' f.entity, f.datef, f.datec, f.paye, f.fk_statut,';
 
 1431     $sql .= 
' s.nom, s.rowid';
 
 1432     $sql .= 
" ORDER BY f.datef DESC, f.datec DESC";
 
 1434     $resql = $db->query($sql);
 
 1436       $facturestatic = 
new Facture($db);
 
 1438       $num = $db->num_rows(
$resql);
 
 1440         print 
'<div class="div-table-responsive-no-min">';
 
 1441         print 
'<table class="noborder centpercent lastrecordtable">';
 
 1443         print 
'<tr class="liste_titre">';
 
 1444         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>';
 
 1445         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>';
 
 1446         print 
'</tr></table></td>';
 
 1451       while ($i < $num && $i < $MAXLIST) {
 
 1452         $objp = $db->fetch_object(
$resql);
 
 1454         $facturestatic->id = $objp->facid;
 
 1455         $facturestatic->ref = $objp->ref;
 
 1456         $facturestatic->type = $objp->type;
 
 1457         $facturestatic->total_ht = $objp->total_ht;
 
 1458         $facturestatic->total_tva = $objp->total_tva;
 
 1459         $facturestatic->total_ttc = $objp->total_ttc;
 
 1460         $facturestatic->statut = $objp->status;
 
 1462         print 
'<tr class="oddeven">';
 
 1463         print 
'<td class="nowraponall">';
 
 1464         print $facturestatic->getNomUrl(1);
 
 1466         $filedir = $conf->facture->multidir_output[$objp->entity].
'/'.
dol_sanitizeFileName($objp->ref);
 
 1468         if (!empty($filedir)) {
 
 1469           $file_list = 
dol_dir_list($filedir, 
'files', 0, 
'', 
'(\.meta|_preview.*.*\.png)$', 
'date', SORT_DESC);
 
 1471         if (is_array($file_list)) {
 
 1475             $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT, 
'/').
'/', 
'', $filedir);
 
 1476             $relativedir = preg_replace(
'/^[\\/]/', 
'', $relativedir);
 
 1483             if (!empty($sortfield) && !empty($sortorder)) { 
 
 1488           print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0);
 
 1495         if ($objp->df > 0) {
 
 1496           print 
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->df), 
'day').
'</td>';
 
 1498           print 
'<td class="right"><b>!!!</b></td>';
 
 1500         print 
'<td class="right" style="min-width: 60px">';
 
 1501         print 
price($objp->total_ht);
 
 1504         if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
 
 1505           print 
'<td class="right" style="min-width: 60px">';
 
 1506           print 
price($objp->total_ttc);
 
 1510         print 
'<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).
'</td>';
 
 1527   $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', 
$parameters, $object, $action);
 
 1531     print $hookmanager->resPrint;
 
 1534   print 
'</div></div>';
 
 1535   print 
'<div style="clear:both"></div>';
 
 1543   print 
'<div class="tabsAction">';
 
 1546   $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', 
$parameters, $object, $action); 
 
 1548   if (empty($reshook)) {
 
 1549     if ($object->status != 1) {
 
 1550       print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"ThirdPartyIsClosed").
'</a></div>';
 
 1553     if (
isModEnabled(
"propal") && $user->rights->propal->creer && $object->status == 1) {
 
 1554       $langs->load(
"propal");
 
 1555       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>';
 
 1558     if (
isModEnabled(
'commande') && $user->rights->commande->creer && $object->status == 1) {
 
 1559       $langs->load(
"orders");
 
 1560       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>';
 
 1563     if (!empty($user->rights->contrat->creer) && $object->status == 1) {
 
 1564       $langs->load(
"contracts");
 
 1565       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>';
 
 1568     if (
isModEnabled(
'ficheinter') && $user->rights->ficheinter->creer && $object->status == 1) {
 
 1569       $langs->load(
"fichinter");
 
 1570       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>';
 
 1574     if ($user->socid == 0) {
 
 1575       if (
isModEnabled(
'deplacement') && $object->status == 1) {
 
 1576         $langs->load(
"trips");
 
 1577         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>';
 
 1581         if (empty($user->rights->facture->creer)) {
 
 1582           print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
 
 1584           $langs->loadLangs(array(
"orders", 
"bills"));
 
 1587             if ($object->client != 0 && $object->client != 2) {
 
 1588               if (!empty($orders2invoice) && $orders2invoice > 0) {
 
 1589                 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>';
 
 1591                 print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NoOrdersToInvoice")).
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
 
 1594               print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
 
 1598           if ($object->client != 0 && $object->client != 2) {
 
 1599             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>';
 
 1601             print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyMustBeEditAsCustomer")).
'" href="#">'.$langs->trans(
"AddBill").
'</a></div>';
 
 1608     if (
isModEnabled(
'agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
 
 1609       if ($user->rights->agenda->myactions->create) {
 
 1610         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>';
 
 1612         print 
'<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddAction").
'</a></div>';
 
 1619   if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) {
 
 1621     show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
 
 1624   if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {
 
 1634   $langs->load(
"errors");
 
 1635   print $langs->trans(
'ErrorRecordNotFound');
 
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage members of a foundation.
Class to manage customers or prospects.
Class to manage customers orders.
Class to manage contracts.
Class to manage shipments.
Class to manage invoices.
Class to manage invoice templates.
Class to manage interventions.
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_todo($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='')
Show html area with actions to do.
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).
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_dir_list($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.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
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.
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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...
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 =...
img_action($titlealt, $numaction, $picto='')
Show logo action.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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.