card.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
  4. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2014 Jean Heimburger <jean@tiaris.info>
  8. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  9. * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  10. * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/fourn/card.php
  27. * \ingroup fournisseur, facture
  28. * \brief Page for supplier third party card (view, edit)
  29. */
  30. // Load Dolibarr environment
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  38. if (isModEnabled('adherent')) {
  39. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  40. }
  41. if (isModEnabled('categorie')) {
  42. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  43. }
  44. // Load translation files required by page
  45. $langs->loadLangs(array(
  46. 'companies',
  47. 'suppliers',
  48. 'products',
  49. 'bills',
  50. 'orders',
  51. 'commercial',
  52. ));
  53. $action = GETPOST('action', 'aZ09');
  54. $cancel = GETPOST('cancel', 'alpha');
  55. // Security check
  56. $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
  57. if ($user->socid) {
  58. $id = $user->socid;
  59. }
  60. $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid');
  61. $object = new Fournisseur($db);
  62. $extrafields = new ExtraFields($db);
  63. // fetch optionals attributes and labels
  64. $extrafields->fetch_name_optionals_label($object->table_element);
  65. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  66. $hookmanager->initHooks(array('thirdpartysupplier', 'globalcard'));
  67. // Security check
  68. $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
  69. if ($object->id > 0) {
  70. if (!($object->fournisseur > 0) || empty($user->rights->fournisseur->lire)) {
  71. accessforbidden();
  72. }
  73. }
  74. /*
  75. * Action
  76. */
  77. $parameters = array('id'=>$id);
  78. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  79. if ($reshook < 0) {
  80. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  81. }
  82. if (empty($reshook)) {
  83. if ($cancel) {
  84. $action = "";
  85. }
  86. if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) {
  87. $result = $object->fetch($id);
  88. $object->code_compta_fournisseur = GETPOST("supplieraccountancycode");
  89. $result = $object->update($object->id, $user, 1, 0, 1);
  90. if ($result < 0) {
  91. setEventMessages($object->error, $object->errors, 'errors');
  92. }
  93. }
  94. // Set payment terms of the settlement
  95. if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) {
  96. $object->fetch($id);
  97. $result = $object->setPaymentTerms(GETPOST('cond_reglement_supplier_id', 'int'));
  98. if ($result < 0) {
  99. dol_print_error($db, $object->error);
  100. }
  101. }
  102. // Payment mode
  103. if ($action == 'setmode' && $user->hasRight('societe', 'creer')) {
  104. $object->fetch($id);
  105. $result = $object->setPaymentMethods(GETPOST('mode_reglement_supplier_id', 'int'));
  106. if ($result < 0) {
  107. dol_print_error($db, $object->error);
  108. }
  109. }
  110. // Bank account
  111. if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) {
  112. $object->fetch($id);
  113. $result = $object->setBankAccount(GETPOST('fk_account', 'int'));
  114. if ($result < 0) {
  115. setEventMessages($object->error, $object->errors, 'errors');
  116. }
  117. }
  118. // update supplier order min amount
  119. if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) {
  120. $object->fetch($id);
  121. $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha'));
  122. $result = $object->update($object->id, $user);
  123. if ($result < 0) {
  124. setEventMessages($object->error, $object->errors, 'errors');
  125. }
  126. }
  127. if ($action == 'update_extras' && $user->hasRight('societe', 'creer')) {
  128. $object->fetch($id);
  129. $object->oldcopy = dol_clone($object);
  130. // Fill array 'array_options' with data from update form
  131. $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
  132. if ($ret < 0) {
  133. $error++;
  134. }
  135. if (!$error) {
  136. $result = $object->insertExtraFields('COMPANY_MODIFY');
  137. if ($result < 0) {
  138. setEventMessages($object->error, $object->errors, 'errors');
  139. $error++;
  140. }
  141. }
  142. if ($error) {
  143. $action = 'edit_extras';
  144. }
  145. }
  146. }
  147. /*
  148. * View
  149. */
  150. $contactstatic = new Contact($db);
  151. $form = new Form($db);
  152. if ($id > 0 && empty($object->id)) {
  153. // Load data of third party
  154. $res = $object->fetch($id);
  155. if ($object->id <= 0) {
  156. dol_print_error($db, $object->error);
  157. exit(-1);
  158. }
  159. }
  160. if ($object->id > 0) {
  161. $title = $langs->trans("ThirdParty")." - ".$langs->trans('Supplier');
  162. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  163. $title = $object->name." - ".$langs->trans('Supplier');
  164. }
  165. $help_url = '';
  166. llxHeader('', $title, $help_url);
  167. /*
  168. * Show tabs
  169. */
  170. $head = societe_prepare_head($object);
  171. print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company');
  172. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  173. dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
  174. print '<div class="fichecenter"><div class="fichehalfleft">';
  175. print '<div class="underbanner clearboth"></div>';
  176. print '<table class="border centpercent tableforfield">';
  177. // Type Prospect/Customer/Supplier
  178. print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
  179. print $object->getTypeUrl(1);
  180. print '</td></tr>';
  181. if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
  182. print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
  183. }
  184. if ($object->fournisseur) {
  185. print '<tr>';
  186. print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>';
  187. print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
  188. $tmpcheck = $object->check_codefournisseur();
  189. if ($tmpcheck != 0 && $tmpcheck != -5) {
  190. print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
  191. }
  192. print '</td>';
  193. print '</tr>';
  194. $langs->load('compta');
  195. print '<tr>';
  196. print '<td>';
  197. print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
  198. print '</td><td>';
  199. print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
  200. print '</td>';
  201. print '</tr>';
  202. }
  203. // Assujetti a TVA ou pas
  204. print '<tr>';
  205. print '<td class="titlefield">';
  206. print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling'));
  207. print '</td><td>';
  208. print yn($object->tva_assuj);
  209. print '</td>';
  210. print '</tr>';
  211. // Local Taxes
  212. if ($mysoc->useLocalTax(1)) {
  213. print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
  214. print yn($object->localtax1_assuj);
  215. print '</td></tr>';
  216. }
  217. if ($mysoc->useLocalTax(2)) {
  218. print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
  219. print yn($object->localtax2_assuj);
  220. print '</td></tr>';
  221. }
  222. // TVA Intra
  223. print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
  224. print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra));
  225. print '</td></tr>';
  226. // Default terms of the settlement
  227. $langs->load('bills');
  228. $form = new Form($db);
  229. print '<tr><td>';
  230. print '<table width="100%" class="nobordernopadding"><tr><td>';
  231. print $langs->trans('PaymentConditions');
  232. print '<td>';
  233. if (($action != 'editconditions') && $user->hasRight('societe', 'creer')) {
  234. 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>';
  235. }
  236. print '</tr></table>';
  237. print '</td><td>';
  238. if ($action == 'editconditions') {
  239. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', 1);
  240. } else {
  241. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'none');
  242. }
  243. print "</td>";
  244. print '</tr>';
  245. // Default payment mode
  246. print '<tr><td class="nowrap">';
  247. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  248. print $langs->trans('PaymentMode');
  249. print '<td>';
  250. if (($action != 'editmode') && $user->hasRight('societe', 'creer')) {
  251. 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>';
  252. }
  253. print '</tr></table>';
  254. print '</td><td>';
  255. if ($action == 'editmode') {
  256. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_supplier_id, 'mode_reglement_supplier_id', 'DBIT', 1, 1);
  257. } else {
  258. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_supplier_id, 'none');
  259. }
  260. print "</td>";
  261. print '</tr>';
  262. if (isModEnabled("banque")) {
  263. // Default bank account for payments
  264. print '<tr><td class="nowrap">';
  265. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  266. print $langs->trans('PaymentBankAccount');
  267. print '<td>';
  268. if (($action != 'editbankaccount') && $user->hasRight('societe', 'creer')) {
  269. 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>';
  270. }
  271. print '</tr></table>';
  272. print '</td><td>';
  273. if ($action == 'editbankaccount') {
  274. $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'fk_account', 1);
  275. } else {
  276. $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'none');
  277. }
  278. print "</td>";
  279. print '</tr>';
  280. }
  281. // Relative discounts (Discounts-Drawbacks-Rebates)
  282. print '<tr><td class="nowrap">';
  283. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  284. print $langs->trans("CustomerRelativeDiscountShort");
  285. print '<td><td class="right">';
  286. if ($user->hasRight('societe', 'creer') && !$user->socid > 0) {
  287. 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>';
  288. }
  289. print '</td></tr></table>';
  290. print '</td><td>'.($object->remise_supplier_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_supplier_percent.'%</a>' : '').'</td>';
  291. print '</tr>';
  292. // Absolute discounts (Discounts-Drawbacks-Rebates)
  293. print '<tr><td class="nowrap">';
  294. print '<table width="100%" class="nobordernopadding">';
  295. print '<tr><td class="nowrap">';
  296. print $langs->trans("CustomerAbsoluteDiscountShort");
  297. print '<td><td class="right">';
  298. if ($user->hasRight('societe', 'creer') && !$user->socid > 0) {
  299. 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>';
  300. }
  301. print '</td></tr></table>';
  302. print '</td>';
  303. print '<td>';
  304. $amount_discount = $object->getAvailableDiscounts('', '', 0, 1);
  305. if ($amount_discount < 0) {
  306. dol_print_error($db, $object->error);
  307. }
  308. if ($amount_discount > 0) {
  309. 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>';
  310. }
  311. //else print $langs->trans("DiscountNone");
  312. print '</td>';
  313. print '</tr>';
  314. if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
  315. print '<tr class="nowrap">';
  316. print '<td>';
  317. print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer);
  318. print '</td><td>';
  319. $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
  320. print $form->editfieldval("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : ''));
  321. print '</td>';
  322. print '</tr>';
  323. }
  324. // Categories
  325. if (isModEnabled('categorie')) {
  326. $langs->load("categories");
  327. print '<tr><td>'.$langs->trans("SuppliersCategoriesShort").'</td>';
  328. print '<td>';
  329. print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
  330. print "</td></tr>";
  331. }
  332. // Other attributes
  333. $parameters = array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
  334. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  335. // Module Adherent
  336. if (isModEnabled('adherent')) {
  337. $langs->load("members");
  338. $langs->load("users");
  339. print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
  340. print '<td>';
  341. $adh = new Adherent($db);
  342. $result = $adh->fetch('', '', $object->id);
  343. if ($result > 0) {
  344. $adh->ref = $adh->getFullName($langs);
  345. print $adh->getNomUrl(1);
  346. } else {
  347. print $langs->trans("ThirdpartyNotLinkedToMember");
  348. }
  349. print '</td>';
  350. print "</tr>\n";
  351. }
  352. print '</table>';
  353. print '</div><div class="fichehalfright">';
  354. $boxstat = '';
  355. // Nbre max d'elements des petites listes
  356. $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  357. print '<div class="underbanner underbanner-before-box clearboth"></div>';
  358. // Lien recap
  359. $boxstat .= '<div class="box box-halfright">';
  360. $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
  361. $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
  362. if (isModEnabled('supplier_proposal')) {
  363. // Box proposals
  364. $tmp = $object->getOutstandingProposals('supplier');
  365. $outstandingOpened = $tmp['opened'];
  366. $outstandingTotal = $tmp['total_ht'];
  367. $outstandingTotalIncTax = $tmp['total_ttc'];
  368. $text = $langs->trans("OverAllSupplierProposals");
  369. $link = DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id;
  370. $icon = 'bill';
  371. if ($link) {
  372. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  373. }
  374. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  375. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  376. $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
  377. $boxstat .= '</div>';
  378. if ($link) {
  379. $boxstat .= '</a>';
  380. }
  381. }
  382. if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
  383. // Box proposals
  384. $tmp = $object->getOutstandingOrders('supplier');
  385. $outstandingOpened = $tmp['opened'];
  386. $outstandingTotal = $tmp['total_ht'];
  387. $outstandingTotalIncTax = $tmp['total_ttc'];
  388. $text = $langs->trans("OverAllOrders");
  389. $link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id;
  390. $icon = 'bill';
  391. if ($link) {
  392. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  393. }
  394. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  395. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  396. $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
  397. $boxstat .= '</div>';
  398. if ($link) {
  399. $boxstat .= '</a>';
  400. }
  401. }
  402. if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) {
  403. $warn = '';
  404. $tmp = $object->getOutstandingBills('supplier');
  405. $outstandingOpened = $tmp['opened'];
  406. $outstandingTotal = $tmp['total_ht'];
  407. $outstandingTotalIncTax = $tmp['total_ttc'];
  408. $text = $langs->trans("OverAllInvoices");
  409. $link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id;
  410. $icon = 'bill';
  411. if ($link) {
  412. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  413. }
  414. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  415. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  416. $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
  417. $boxstat .= '</div>';
  418. if ($link) {
  419. $boxstat .= '</a>';
  420. }
  421. // Box outstanding bill
  422. $text = $langs->trans("CurrentOutstandingBill");
  423. $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
  424. $icon = 'bill';
  425. if ($link) {
  426. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  427. }
  428. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  429. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  430. $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
  431. $boxstat .= '</div>';
  432. if ($link) {
  433. $boxstat .= '</a>';
  434. }
  435. $tmp = $object->getOutstandingBills('supplier', 1);
  436. $outstandingOpenedLate = $tmp['opened'];
  437. if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
  438. $text = $langs->trans("CurrentOutstandingBillLate");
  439. $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
  440. $icon = 'bill';
  441. if ($link) {
  442. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  443. }
  444. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  445. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  446. $boxstat .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
  447. $boxstat .= '</div>';
  448. if ($link) {
  449. $boxstat .= '</a>';
  450. }
  451. }
  452. }
  453. $parameters = array();
  454. $reshook = $hookmanager->executeHooks('addMoreBoxStatsSupplier', $parameters, $object, $action);
  455. if (empty($reshook)) {
  456. $boxstat .= $hookmanager->resPrint;
  457. }
  458. $boxstat .= '</td></tr>';
  459. $boxstat .= '</table>';
  460. $boxstat .= '</div>';
  461. print $boxstat;
  462. $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  463. // Lien recap
  464. /*
  465. print '<table class="noborder centpercent">';
  466. print '<tr class="liste_titre">';
  467. print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
  468. print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id.'">'.$langs->trans("ShowSupplierPreview").'</a></td></tr></table></td>';
  469. print '</tr>';
  470. print '</table>';
  471. print '<br>';
  472. */
  473. /*
  474. * List of products
  475. */
  476. if (isModEnabled("product") || isModEnabled("service")) {
  477. $langs->load("products");
  478. //Query from product/liste.php
  479. $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity, p.tosell as status, p.tobuy as status_buy, p.tobatch as status_batch,';
  480. $sql .= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
  481. $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
  482. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product";
  483. $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
  484. $sql .= ' AND pfp.fk_soc = '.((int) $object->id);
  485. $sql .= $db->order('pfp.tms', 'desc');
  486. $sql .= $db->plimit($MAXLIST);
  487. $query = $db->query($sql);
  488. if (!$query) {
  489. dol_print_error($db);
  490. }
  491. $num = $db->num_rows($query);
  492. print '<div class="div-table-responsive-no-min">';
  493. print '<table class="noborder centpercent lastrecordtable">';
  494. print '<tr class="liste_titre'.(($num == 0) ? ' nobottom' : '').'">';
  495. print '<td colspan="3">'.$langs->trans("ProductsAndServices").'</td><td class="right">';
  496. print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllProductReferencesOfSupplier").'</span><span class="badge marginleftonlyshort">'.$object->nbOfProductRefs().'</span>';
  497. print '</a></td></tr>';
  498. $return = array();
  499. if ($num > 0) {
  500. $productstatic = new Product($db);
  501. while ($objp = $db->fetch_object($query)) {
  502. $productstatic->id = $objp->rowid;
  503. $productstatic->ref = $objp->ref;
  504. $productstatic->label = $objp->label;
  505. $productstatic->type = $objp->fk_product_type;
  506. $productstatic->entity = $objp->entity;
  507. $productstatic->status = $objp->status;
  508. $productstatic->status_buy = $objp->status_buy;
  509. $productstatic->status_batch = $objp->status_batch;
  510. print '<tr class="oddeven">';
  511. print '<td class="nowrap">';
  512. print $productstatic->getNomUrl(1);
  513. print '</td>';
  514. print '<td>';
  515. print dol_escape_htmltag($objp->supplier_ref);
  516. print '</td>';
  517. print '<td class="maxwidthonsmartphone">';
  518. print dol_trunc(dol_htmlentities($objp->label), 30);
  519. print '</td>';
  520. //print '<td class="right" class="nowrap">'.dol_print_date($objp->tms, 'day').'</td>';
  521. print '<td class="right">';
  522. //print (isset($objp->unitprice) ? price($objp->unitprice) : '');
  523. if (isset($objp->price)) {
  524. print '<span class="amount">'.price($objp->price).'</span>';
  525. if ($objp->quantity > 1) {
  526. print ' / ';
  527. print $objp->quantity;
  528. }
  529. }
  530. print '</td>';
  531. print '</tr>';
  532. }
  533. }
  534. print '</table>';
  535. print '</div>';
  536. }
  537. /*
  538. * Latest supplier proposal
  539. */
  540. $proposalstatic = new SupplierProposal($db);
  541. if (!empty($user->rights->supplier_proposal->lire)) {
  542. $langs->loadLangs(array("supplier_proposal"));
  543. $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
  544. $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p ";
  545. $sql .= " WHERE p.fk_soc = ".((int) $object->id);
  546. $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
  547. $sql .= " ORDER BY p.date_valid DESC";
  548. $sql .= $db->plimit($MAXLIST);
  549. $resql = $db->query($sql);
  550. if ($resql) {
  551. $i = 0;
  552. $num = $db->num_rows($resql);
  553. if ($num > 0) {
  554. print '<div class="div-table-responsive-no-min">';
  555. print '<table class="noborder centpercent lastrecordtable">';
  556. print '<tr class="liste_titre">';
  557. print '<td colspan="3">';
  558. print '<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
  559. print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllPriceRequests").'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
  560. print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/supplier_proposal/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
  561. print '</tr></table>';
  562. print '</td></tr>';
  563. }
  564. while ($i < $num && $i <= $MAXLIST) {
  565. $obj = $db->fetch_object($resql);
  566. print '<tr class="oddeven">';
  567. print '<td class="nowrap">';
  568. $proposalstatic->id = $obj->rowid;
  569. $proposalstatic->ref = $obj->ref;
  570. $proposalstatic->total_ht = $obj->total_ht;
  571. $proposalstatic->total_tva = $obj->total_tva;
  572. $proposalstatic->total_ttc = $obj->total_ttc;
  573. print $proposalstatic->getNomUrl(1);
  574. print '</td>';
  575. print '<td class="center" width="80">';
  576. if ($obj->dc) {
  577. print dol_print_date($db->jdate($obj->dc), 'day');
  578. } else {
  579. print "-";
  580. }
  581. print '</td>';
  582. print '<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).'</td>';
  583. print '</tr>';
  584. $i++;
  585. }
  586. $db->free($resql);
  587. if ($num > 0) {
  588. print "</table></div>";
  589. }
  590. } else {
  591. dol_print_error($db);
  592. }
  593. }
  594. /*
  595. * Latest supplier orders
  596. */
  597. $orderstatic = new CommandeFournisseur($db);
  598. if ($user->rights->fournisseur->commande->lire) {
  599. // TODO move to DAO class
  600. // Check if there are supplier orders billable
  601. $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
  602. $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
  603. $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
  604. $sql2 .= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c';
  605. $sql2 .= ' WHERE c.fk_soc = s.rowid';
  606. $sql2 .= " AND c.entity IN (".getEntity('commande_fournisseur').")";
  607. $sql2 .= ' AND s.rowid = '.((int) $object->id);
  608. // Show orders we can bill
  609. if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) {
  610. $sql2 .= " AND c.fk_statut IN (".$db->sanitize(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php
  611. } else {
  612. // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY
  613. $sql2 .= " AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")";
  614. }
  615. $sql2 .= " AND c.billed = 0";
  616. // Find order that are not already invoiced
  617. // just need to check received status because we have the billed status now
  618. //$sql2 .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')";
  619. $resql2 = $db->query($sql2);
  620. if ($resql2) {
  621. $orders2invoice = $db->num_rows($resql2);
  622. $db->free($resql2);
  623. } else {
  624. setEventMessages($db->lasterror(), null, 'errors');
  625. }
  626. // TODO move to DAO class
  627. $sql = "SELECT count(p.rowid) as total";
  628. $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
  629. $sql .= " WHERE p.fk_soc = ".((int) $object->id);
  630. $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
  631. $resql = $db->query($sql);
  632. if ($resql) {
  633. $object_count = $db->fetch_object($resql);
  634. $num = $object_count->total;
  635. }
  636. $sql = "SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
  637. $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
  638. $sql .= " WHERE p.fk_soc = ".((int) $object->id);
  639. $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
  640. $sql .= " ORDER BY p.date_commande DESC";
  641. $sql .= $db->plimit($MAXLIST);
  642. $resql = $db->query($sql);
  643. if ($resql) {
  644. $i = 0;
  645. if ($num > 0) {
  646. print '<div class="div-table-responsive-no-min">';
  647. print '<table class="noborder centpercent lastrecordtable">';
  648. print '<tr class="liste_titre">';
  649. print '<td colspan="4">';
  650. print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
  651. print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllOrders").'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
  652. print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
  653. print '</tr></table>';
  654. print '</td></tr>';
  655. }
  656. while ($i < $num && $i < $MAXLIST) {
  657. $obj = $db->fetch_object($resql);
  658. $orderstatic->id = $obj->rowid;
  659. $orderstatic->ref = $obj->ref;
  660. $orderstatic->total_ht = $obj->total_ht;
  661. $orderstatic->total_tva = $obj->total_tva;
  662. $orderstatic->total_ttc = $obj->total_ttc;
  663. $orderstatic->date = $db->jdate($obj->date);
  664. print '<tr class="oddeven">';
  665. print '<td class="nowraponall">';
  666. print $orderstatic->getNomUrl(1);
  667. print '</td>';
  668. print '<td class="center" width="80">';
  669. if ($obj->date) {
  670. print dol_print_date($orderstatic->date, 'day');
  671. }
  672. print '</td>';
  673. print '<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).'</span></td>';
  674. print '<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).'</td>';
  675. print '</tr>';
  676. $i++;
  677. }
  678. $db->free($resql);
  679. if ($num > 0) {
  680. print "</table></div>";
  681. }
  682. } else {
  683. dol_print_error($db);
  684. }
  685. }
  686. /*
  687. * Latest supplier invoices
  688. */
  689. $langs->load('bills');
  690. $facturestatic = new FactureFournisseur($db);
  691. if ($user->rights->fournisseur->facture->lire) {
  692. // TODO move to DAO class
  693. $sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc, f.paye,';
  694. $sql .= ' SUM(pf.amount) as am';
  695. $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
  696. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
  697. $sql .= ' WHERE f.fk_soc = '.((int) $object->id);
  698. $sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
  699. $sql .= ' GROUP BY f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef,f.total_ht,f.total_tva,f.total_ttc,f.paye';
  700. $sql .= ' ORDER BY f.datef DESC';
  701. $resql = $db->query($sql);
  702. if ($resql) {
  703. $i = 0;
  704. $num = $db->num_rows($resql);
  705. if ($num > 0) {
  706. print '<div class="div-table-responsive-no-min">';
  707. print '<table class="noborder centpercent lastrecordtable">';
  708. print '<tr class="liste_titre">';
  709. print '<td colspan="4">';
  710. print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
  711. print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans('AllBills').'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
  712. print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
  713. print '</tr></table>';
  714. print '</td></tr>';
  715. }
  716. while ($i < min($num, $MAXLIST)) {
  717. $obj = $db->fetch_object($resql);
  718. $facturestatic->id = $obj->rowid;
  719. $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
  720. $facturestatic->ref_supplier = $obj->ref_supplier;
  721. $facturestatic->libelle = $obj->label; // deprecated
  722. $facturestatic->label = $obj->label;
  723. $facturestatic->total_ht = $obj->total_ht;
  724. $facturestatic->total_tva = $obj->total_tva;
  725. $facturestatic->total_ttc = $obj->total_ttc;
  726. $facturestatic->date = $db->jdate($obj->df);
  727. print '<tr class="oddeven">';
  728. print '<td class="tdoverflowmax200">';
  729. print '<span class="nowraponall">'.$facturestatic->getNomUrl(1).'</span>';
  730. print $obj->ref_supplier ? ' - '.$obj->ref_supplier : '';
  731. print ($obj->label ? ' - ' : '').dol_trunc($obj->label, 14);
  732. print '</td>';
  733. print '<td class="center nowrap">'.dol_print_date($facturestatic->date, 'day').'</td>';
  734. print '<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).'</span></td>';
  735. print '<td class="right nowrap">';
  736. print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
  737. print '</td>';
  738. print '</tr>';
  739. $i++;
  740. }
  741. $db->free($resql);
  742. if ($num > 0) {
  743. print '</table></div>';
  744. }
  745. } else {
  746. dol_print_error($db);
  747. }
  748. }
  749. print '</div></div>';
  750. print '<div style="clear:both"></div>';
  751. print dol_get_fiche_end();
  752. /*
  753. * Action bar
  754. */
  755. print '<div class="tabsAction">';
  756. $parameters = array();
  757. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
  758. // modified by hook
  759. if (empty($reshook)) {
  760. if ($object->status != 1) {
  761. print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('ThirdPartyIsClosed'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
  762. }
  763. if (isModEnabled('supplier_proposal') && !empty($user->rights->supplier_proposal->creer)) {
  764. $langs->load("supplier_proposal");
  765. if ($object->status == 1) {
  766. print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&amp;socid='.$object->id, '');
  767. } else {
  768. print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierProposal'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
  769. }
  770. }
  771. if ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')) {
  772. $langs->load("orders");
  773. if ($object->status == 1) {
  774. print dolGetButtonAction('', $langs->trans('AddSupplierOrderShort'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;token='.newToken().'&amp;socid='.$object->id, '');
  775. } else {
  776. print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierOrderShort'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
  777. }
  778. }
  779. if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
  780. if (!empty($orders2invoice) && $orders2invoice > 0) {
  781. if ($object->status == 1) {
  782. // Company is open
  783. print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisSupplier'), 'default', DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'&amp;search_billed=0&amp;autoselectall=1', '');
  784. } else {
  785. print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
  786. }
  787. } else {
  788. print dolGetButtonAction($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
  789. }
  790. }
  791. if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
  792. $langs->load("bills");
  793. if ($object->status == 1) {
  794. print dolGetButtonAction('', $langs->trans('AddBill'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;socid='.$object->id, '');
  795. } else {
  796. print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddBill'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
  797. }
  798. }
  799. // Add action
  800. if (isModEnabled('agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
  801. if ($user->rights->agenda->myactions->create) {
  802. print dolGetButtonAction('', $langs->trans('AddAction'), 'default', DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;socid='.$object->id, '');
  803. } else {
  804. print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddAction'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
  805. }
  806. }
  807. }
  808. print '</div>';
  809. if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
  810. print '<br>';
  811. // List of contacts
  812. show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
  813. }
  814. if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {
  815. print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
  816. // List of todo actions
  817. show_actions_todo($conf, $langs, $db, $object);
  818. // List of done actions
  819. show_actions_done($conf, $langs, $db, $object);
  820. }
  821. } else {
  822. dol_print_error($db);
  823. }
  824. // End of page
  825. llxFooter();
  826. $db->close();