card.php 37 KB

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