card.php 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  6. * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
  7. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  8. * Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
  9. * Copyright (C) 2013 Alexandre Spangaro <aspangaro@open-dsi.fr>
  10. * Copyright (C) 2015-2021 Frédéric France <frederic.france@netlogic.fr>
  11. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  12. * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  26. */
  27. /**
  28. * \file htdocs/comm/card.php
  29. * \ingroup commercial compta
  30. * \brief Page to show customer card of a third party
  31. */
  32. require '../main.inc.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  39. if (!empty($conf->facture->enabled)) {
  40. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  41. }
  42. if (!empty($conf->facture->enabled)) {
  43. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
  44. }
  45. if (!empty($conf->propal->enabled)) {
  46. require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  47. }
  48. if (!empty($conf->commande->enabled)) {
  49. require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  50. }
  51. if (!empty($conf->expedition->enabled)) {
  52. require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
  53. }
  54. if (!empty($conf->contrat->enabled)) {
  55. require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  56. }
  57. if (!empty($conf->adherent->enabled)) {
  58. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  59. }
  60. if (!empty($conf->ficheinter->enabled)) {
  61. require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
  62. }
  63. // Load translation files required by the page
  64. $langs->loadLangs(array('companies', 'banks'));
  65. if (!empty($conf->contrat->enabled)) {
  66. $langs->load("contracts");
  67. }
  68. if (!empty($conf->commande->enabled)) {
  69. $langs->load("orders");
  70. }
  71. if (!empty($conf->expedition->enabled)) {
  72. $langs->load("sendings");
  73. }
  74. if (!empty($conf->facture->enabled)) {
  75. $langs->load("bills");
  76. }
  77. if (!empty($conf->projet->enabled)) {
  78. $langs->load("projects");
  79. }
  80. if (!empty($conf->ficheinter->enabled)) {
  81. $langs->load("interventions");
  82. }
  83. if (!empty($conf->notification->enabled)) {
  84. $langs->load("mails");
  85. }
  86. $action = GETPOST('action', 'aZ09');
  87. $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
  88. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  89. $sortfield = GETPOST('sortfield', 'aZ09comma');
  90. $sortorder = GETPOST('sortorder', 'aZ09comma');
  91. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  92. if (empty($page) || $page == -1) {
  93. $page = 0;
  94. } // If $page is not defined, or '' or -1
  95. $offset = $limit * $page;
  96. $pageprev = $page - 1;
  97. $pagenext = $page + 1;
  98. if (!$sortorder) {
  99. $sortorder = "ASC";
  100. }
  101. if (!$sortfield) {
  102. $sortfield = "nom";
  103. }
  104. $cancel = GETPOST('cancel', 'alpha');
  105. $object = new Client($db);
  106. $extrafields = new ExtraFields($db);
  107. // fetch optionals attributes and labels
  108. $extrafields->fetch_name_optionals_label($object->table_element);
  109. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  110. $hookmanager->initHooks(array('thirdpartycomm', 'globalcard'));
  111. $now = dol_now();
  112. if ($id > 0 && empty($object->id)) {
  113. // Load data of third party
  114. $res = $object->fetch($id);
  115. if ($object->id < 0) {
  116. dol_print_error($db, $object->error, $object->errors);
  117. }
  118. }
  119. if ($object->id > 0) {
  120. if (!($object->client > 0) || empty($user->rights->societe->lire)) {
  121. accessforbidden();
  122. }
  123. }
  124. // Security check
  125. if ($user->socid > 0) {
  126. $id = $user->socid;
  127. }
  128. $result = restrictedArea($user, 'societe', $object->id, '&societe', '', 'fk_soc', 'rowid', 0);
  129. /*
  130. * Actions
  131. */
  132. $parameters = array('id' => $id, 'socid' => $id);
  133. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
  134. if ($reshook < 0) {
  135. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  136. }
  137. if (empty($reshook)) {
  138. if ($cancel) {
  139. $action = "";
  140. }
  141. // set accountancy code
  142. if ($action == 'setcustomeraccountancycode') {
  143. $result = $object->fetch($id);
  144. $object->code_compta = GETPOST("customeraccountancycode");
  145. $result = $object->update($object->id, $user, 1, 1, 0);
  146. if ($result < 0) {
  147. setEventMessages($object->error, $object->errors, 'errors');
  148. }
  149. }
  150. // terms of the settlement
  151. if ($action == 'setconditions' && $user->rights->societe->creer) {
  152. $object->fetch($id);
  153. $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
  154. if ($result < 0) {
  155. setEventMessages($object->error, $object->errors, 'errors');
  156. }
  157. }
  158. // mode de reglement
  159. if ($action == 'setmode' && $user->rights->societe->creer) {
  160. $object->fetch($id);
  161. $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
  162. if ($result < 0) {
  163. setEventMessages($object->error, $object->errors, 'errors');
  164. }
  165. }
  166. // transport mode
  167. if ($action == 'settransportmode' && $user->rights->societe->creer) {
  168. $object->fetch($id);
  169. $result = $object->setTransportMode(GETPOST('transport_mode_id', 'alpha'));
  170. if ($result < 0) {
  171. setEventMessages($object->error, $object->errors, 'errors');
  172. }
  173. }
  174. // Bank account
  175. if ($action == 'setbankaccount' && $user->rights->societe->creer) {
  176. $object->fetch($id);
  177. $result = $object->setBankAccount(GETPOST('fk_account', 'int'));
  178. if ($result < 0) {
  179. setEventMessages($object->error, $object->errors, 'errors');
  180. }
  181. }
  182. // customer preferred shipping method
  183. if ($action == 'setshippingmethod' && $user->rights->societe->creer) {
  184. $object->fetch($id);
  185. $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
  186. if ($result < 0) {
  187. setEventMessages($object->error, $object->errors, 'errors');
  188. }
  189. }
  190. // assujetissement a la TVA
  191. if ($action == 'setassujtva' && $user->rights->societe->creer) {
  192. $object->fetch($id);
  193. $object->tva_assuj = $_POST['assujtva_value'];
  194. $result = $object->update($object->id);
  195. if ($result < 0) {
  196. setEventMessages($object->error, $object->errors, 'errors');
  197. }
  198. }
  199. // set prospect level
  200. if ($action == 'setprospectlevel' && $user->rights->societe->creer) {
  201. $object->fetch($id);
  202. $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha');
  203. $result = $object->update($object->id, $user);
  204. if ($result < 0) {
  205. setEventMessages($object->error, $object->errors, 'errors');
  206. }
  207. }
  208. // set communication status
  209. if ($action == 'setstcomm') {
  210. $object->fetch($id);
  211. $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm');
  212. $result = $object->update($object->id, $user);
  213. if ($result < 0) {
  214. setEventMessages($object->error, $object->errors, 'errors');
  215. } else {
  216. $result = $object->fetch($object->id);
  217. }
  218. }
  219. // update outstandng limit
  220. if ($action == 'setoutstanding_limit') {
  221. $object->fetch($id);
  222. $object->outstanding_limit = GETPOST('outstanding_limit');
  223. $result = $object->update($object->id, $user);
  224. if ($result < 0) {
  225. setEventMessages($object->error, $object->errors, 'errors');
  226. }
  227. }
  228. // update order min amount
  229. if ($action == 'setorder_min_amount') {
  230. $object->fetch($id);
  231. $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha'));
  232. $result = $object->update($object->id, $user);
  233. if ($result < 0) {
  234. setEventMessages($object->error, $object->errors, 'errors');
  235. }
  236. }
  237. // Set sales representatives
  238. if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) {
  239. $object->fetch($id);
  240. $result = $object->setSalesRep(GETPOST('commercial', 'array'));
  241. }
  242. if ($action == 'update_extras') {
  243. $object->fetch($id);
  244. $object->oldcopy = dol_clone($object);
  245. // Fill array 'array_options' with data from update form
  246. $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
  247. if ($ret < 0) {
  248. $error++;
  249. }
  250. if (!$error) {
  251. $result = $object->insertExtraFields('COMPANY_MODIFY');
  252. if ($result < 0) {
  253. setEventMessages($object->error, $object->errors, 'errors');
  254. $error++;
  255. }
  256. }
  257. if ($error) {
  258. $action = 'edit_extras';
  259. }
  260. }
  261. // warehouse
  262. if ($action == 'setwarehouse' && $user->rights->societe->creer) {
  263. $result = $object->setWarehouse(GETPOST('fk_warehouse', 'int'));
  264. }
  265. }
  266. /*
  267. * View
  268. */
  269. $contactstatic = new Contact($db);
  270. $userstatic = new User($db);
  271. $form = new Form($db);
  272. $formcompany = new FormCompany($db);
  273. $title = $langs->trans("ThirdParty")." - ".$langs->trans('Customer');
  274. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  275. $title = $object->name." - ".$langs->trans('Customer');
  276. }
  277. $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
  278. llxHeader('', $title, $help_url);
  279. if ($object->id > 0) {
  280. $head = societe_prepare_head($object);
  281. print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company');
  282. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  283. dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
  284. print '<div class="fichecenter"><div class="fichehalfleft">';
  285. print '<div class="underbanner clearboth"></div>';
  286. print '<table class="border centpercent tableforfield">';
  287. // Type Prospect/Customer/Supplier
  288. print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
  289. print $object->getTypeUrl(1);
  290. print '</td></tr>';
  291. // Prefix
  292. if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
  293. print '<tr><td>'.$langs->trans("Prefix").'</td><td>';
  294. print ($object->prefix_comm ? $object->prefix_comm : '&nbsp;');
  295. print '</td></tr>';
  296. }
  297. if ($object->client) {
  298. $langs->load("compta");
  299. print '<tr><td>';
  300. print $langs->trans('CustomerCode').'</td><td>';
  301. print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
  302. $tmpcheck = $object->check_codeclient();
  303. if ($tmpcheck != 0 && $tmpcheck != -5) {
  304. print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
  305. }
  306. print '</td></tr>';
  307. print '<tr>';
  308. print '<td>';
  309. print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);
  310. print '</td><td>';
  311. print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);
  312. print '</td>';
  313. print '</tr>';
  314. }
  315. // This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier.
  316. // We don't need them into customer profile.
  317. // Except for spain and localtax where localtax depends on buyer and not seller
  318. // VAT is used
  319. /*
  320. print '<tr>';
  321. print '<td class="nowrap">';
  322. print $form->textwithpicto($langs->trans('VATIsUsed'),$langs->trans('VATIsUsedWhenSelling'));
  323. print '</td>';
  324. print '<td>';
  325. print yn($object->tva_assuj);
  326. print '</td>';
  327. print '</tr>';
  328. */
  329. if ($mysoc->country_code == 'ES') {
  330. // Local Taxes
  331. if ($mysoc->localtax1_assuj == "1") {
  332. print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
  333. print yn($object->localtax1_assuj);
  334. print '</td></tr>';
  335. }
  336. if ($mysoc->localtax1_assuj == "1") {
  337. print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
  338. print yn($object->localtax2_assuj);
  339. print '</td></tr>';
  340. }
  341. }
  342. // TVA Intra
  343. print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
  344. print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra));
  345. print '</td></tr>';
  346. // default terms of the settlement
  347. $langs->load('bills');
  348. print '<tr><td>';
  349. print '<table width="100%" class="nobordernopadding"><tr><td>';
  350. print $langs->trans('PaymentConditions');
  351. print '<td>';
  352. if (($action != 'editconditions') && $user->rights->societe->creer) {
  353. 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>';
  354. }
  355. print '</tr></table>';
  356. print '</td><td>';
  357. if ($action == 'editconditions') {
  358. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1);
  359. } else {
  360. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none');
  361. }
  362. print "</td>";
  363. print '</tr>';
  364. // Mode de reglement par defaut
  365. print '<tr><td class="nowrap">';
  366. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  367. print $langs->trans('PaymentMode');
  368. print '<td>';
  369. if (($action != 'editmode') && $user->rights->societe->creer) {
  370. 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>';
  371. }
  372. print '</tr></table>';
  373. print '</td><td>';
  374. if ($action == 'editmode') {
  375. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1);
  376. } else {
  377. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'none');
  378. }
  379. print "</td>";
  380. print '</tr>';
  381. if (!empty($conf->banque->enabled)) {
  382. // Compte bancaire par défaut
  383. print '<tr><td class="nowrap">';
  384. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  385. print $langs->trans('PaymentBankAccount');
  386. print '<td>';
  387. if (($action != 'editbankaccount') && $user->rights->societe->creer) {
  388. 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>';
  389. }
  390. print '</tr></table>';
  391. print '</td><td>';
  392. if ($action == 'editbankaccount') {
  393. $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'fk_account', 1);
  394. } else {
  395. $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'none');
  396. }
  397. print "</td>";
  398. print '</tr>';
  399. }
  400. $isCustomer = ($object->client == 1 || $object->client == 3);
  401. // Relative discounts (Discounts-Drawbacks-Rebates)
  402. if ($isCustomer) {
  403. print '<tr><td class="nowrap">';
  404. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  405. print $langs->trans("CustomerRelativeDiscountShort");
  406. print '<td><td class="right">';
  407. if ($user->rights->societe->creer && !$user->socid > 0) {
  408. 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>';
  409. }
  410. print '</td></tr></table>';
  411. print '</td><td>'.($object->remise_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>' : '').'</td>';
  412. print '</tr>';
  413. // Absolute discounts (Discounts-Drawbacks-Rebates)
  414. print '<tr><td class="nowrap">';
  415. print '<table width="100%" class="nobordernopadding">';
  416. print '<tr><td class="nowrap">';
  417. print $langs->trans("CustomerAbsoluteDiscountShort");
  418. print '<td><td class="right">';
  419. if ($user->rights->societe->creer && !$user->socid > 0) {
  420. 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>';
  421. }
  422. print '</td></tr></table>';
  423. print '</td>';
  424. print '<td>';
  425. $amount_discount = $object->getAvailableDiscounts();
  426. if ($amount_discount < 0) {
  427. dol_print_error($db, $object->error);
  428. }
  429. if ($amount_discount > 0) {
  430. 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>';
  431. }
  432. //else print $langs->trans("DiscountNone");
  433. print '</td>';
  434. print '</tr>';
  435. }
  436. // Max outstanding bill
  437. if ($object->client) {
  438. print '<tr class="nowrap">';
  439. print '<td>';
  440. print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer);
  441. print '</td><td>';
  442. $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
  443. print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
  444. print '</td>';
  445. print '</tr>';
  446. }
  447. if ($object->client) {
  448. if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
  449. print '<!-- Minimim amount for orders -->'."\n";
  450. print '<tr class="nowrap">';
  451. print '<td>';
  452. print $form->editfieldkey("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer);
  453. print '</td><td>';
  454. 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) : ''));
  455. print '</td>';
  456. print '</tr>';
  457. }
  458. }
  459. // Multiprice level
  460. if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
  461. print '<tr><td class="nowrap">';
  462. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  463. print $langs->trans("PriceLevel");
  464. print '<td><td class="right">';
  465. if ($user->rights->societe->creer) {
  466. print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
  467. }
  468. print '</td></tr></table>';
  469. print '</td><td>';
  470. print $object->price_level;
  471. $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
  472. if (!empty($conf->global->$keyforlabel)) {
  473. print ' - '.$langs->trans($conf->global->$keyforlabel);
  474. }
  475. print "</td>";
  476. print '</tr>';
  477. }
  478. // Warehouse
  479. if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
  480. $langs->load('stocks');
  481. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  482. $formproduct = new FormProduct($db);
  483. print '<tr class="nowrap">';
  484. print '<td>';
  485. print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $user->rights->societe->creer);
  486. print '</td><td>';
  487. if ($action == 'editwarehouse') {
  488. $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'fk_warehouse', 1);
  489. } else {
  490. if ($object->fk_warehouse > 0) {
  491. print img_picto('', 'stock', 'class="paddingrightonly"');
  492. }
  493. $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'none');
  494. }
  495. print '</td>';
  496. print '</tr>';
  497. }
  498. // Preferred shipping Method
  499. if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
  500. print '<tr><td class="nowrap">';
  501. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  502. print $langs->trans('SendingMethod');
  503. print '<td>';
  504. if (($action != 'editshipping') && $user->rights->societe->creer) {
  505. 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>';
  506. }
  507. print '</tr></table>';
  508. print '</td><td>';
  509. if ($action == 'editshipping') {
  510. $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
  511. } else {
  512. $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'none');
  513. }
  514. print "</td>";
  515. print '</tr>';
  516. }
  517. if (!empty($conf->intracommreport->enabled)) {
  518. // Transport mode by default
  519. print '<tr><td class="nowrap">';
  520. print '<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
  521. print $langs->trans('IntracommReportTransportMode');
  522. print '<td>';
  523. if (($action != 'edittransportmode') && $user->rights->societe->creer) {
  524. 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>';
  525. }
  526. print '</tr></table>';
  527. print '</td><td>';
  528. if ($action == 'edittransportmode') {
  529. $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id : ''), 'transport_mode_id', 1);
  530. } else {
  531. $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, (!empty($object->transport_mode_id) ? $object->transport_mode_id : ''), 'none');
  532. }
  533. print "</td>";
  534. print '</tr>';
  535. }
  536. // Categories
  537. if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
  538. $langs->load("categories");
  539. print '<tr><td>'.$langs->trans("CustomersCategoriesShort").'</td>';
  540. print '<td>';
  541. print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
  542. print "</td></tr>";
  543. }
  544. // Other attributes
  545. $parameters = array('socid'=>$object->id);
  546. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  547. // Sales representative
  548. include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
  549. // Module Adherent
  550. if (!empty($conf->adherent->enabled)) {
  551. $langs->load("members");
  552. $langs->load("users");
  553. print '<tr><td class="titlefield">'.$langs->trans("LinkedToDolibarrMember").'</td>';
  554. print '<td>';
  555. $adh = new Adherent($db);
  556. $result = $adh->fetch('', '', $object->id);
  557. if ($result > 0) {
  558. $adh->ref = $adh->getFullName($langs);
  559. print $adh->getNomUrl(-1);
  560. } else {
  561. print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
  562. }
  563. print '</td>';
  564. print "</tr>\n";
  565. }
  566. print "</table>";
  567. // Prospection level and status
  568. if ($object->client == 2 || $object->client == 3) {
  569. print '<br>';
  570. print '<div class="underbanner clearboth"></div>';
  571. print '<table class="border centpercent tableforfield">';
  572. // Level of prospection
  573. print '<tr><td class="titlefield nowrap">';
  574. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  575. print $langs->trans('ProspectLevel');
  576. print '<td>';
  577. if ($action != 'editlevel' && $user->rights->societe->creer) {
  578. 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>';
  579. }
  580. print '</tr></table>';
  581. print '</td><td>';
  582. if ($action == 'editlevel') {
  583. $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_prospectlevel, 'prospect_level_id', 1);
  584. } else {
  585. print $object->getLibProspLevel();
  586. }
  587. print "</td>";
  588. print '</tr>';
  589. // Status of prospection
  590. $object->loadCacheOfProspStatus();
  591. print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
  592. print ' &nbsp; &nbsp; ';
  593. print '<div class="floatright">';
  594. foreach ($object->cacheprospectstatus as $key => $val) {
  595. $titlealt = 'default';
  596. if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
  597. $titlealt = $val['label'];
  598. }
  599. if ($object->stcomm_id != $val['id']) {
  600. 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>';
  601. }
  602. }
  603. print '</div></td></tr>';
  604. print "</table>";
  605. }
  606. print '</div><div class="fichehalfright">';
  607. print '<div class="underbanner clearboth"></div>';
  608. $boxstat = '';
  609. // Nbre max d'elements des petites listes
  610. $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  611. // Lien recap
  612. $boxstat .= '<div class="box">';
  613. $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
  614. $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
  615. if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
  616. // Box proposals
  617. $tmp = $object->getOutstandingProposals();
  618. $outstandingOpened = $tmp['opened'];
  619. $outstandingTotal = $tmp['total_ht'];
  620. $outstandingTotalIncTax = $tmp['total_ttc'];
  621. $text = $langs->trans("OverAllProposals");
  622. $link = DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id;
  623. $icon = 'bill';
  624. if ($link) {
  625. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  626. }
  627. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  628. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  629. $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
  630. $boxstat .= '</div>';
  631. if ($link) {
  632. $boxstat .= '</a>';
  633. }
  634. }
  635. if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
  636. // Box commandes
  637. $tmp = $object->getOutstandingOrders();
  638. $outstandingOpened = $tmp['opened'];
  639. $outstandingTotal = $tmp['total_ht'];
  640. $outstandingTotalIncTax = $tmp['total_ttc'];
  641. $text = $langs->trans("OverAllOrders");
  642. $link = DOL_URL_ROOT.'/commande/list.php?socid='.$object->id;
  643. $icon = 'bill';
  644. if ($link) {
  645. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  646. }
  647. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  648. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  649. $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
  650. $boxstat .= '</div>';
  651. if ($link) {
  652. $boxstat .= '</a>';
  653. }
  654. }
  655. if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
  656. // Box factures
  657. $tmp = $object->getOutstandingBills('customer', 0);
  658. $outstandingOpened = $tmp['opened'];
  659. $outstandingTotal = $tmp['total_ht'];
  660. $outstandingTotalIncTax = $tmp['total_ttc'];
  661. $text = $langs->trans("OverAllInvoices");
  662. $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id;
  663. $icon = 'bill';
  664. if ($link) {
  665. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  666. }
  667. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  668. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  669. $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
  670. $boxstat .= '</div>';
  671. if ($link) {
  672. $boxstat .= '</a>';
  673. }
  674. // Box outstanding bill
  675. $warn = '';
  676. if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) {
  677. $warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
  678. }
  679. $text = $langs->trans("CurrentOutstandingBill");
  680. $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
  681. $icon = 'bill';
  682. if ($link) {
  683. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  684. }
  685. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  686. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  687. $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
  688. $boxstat .= '</div>';
  689. if ($link) {
  690. $boxstat .= '</a>';
  691. }
  692. $tmp = $object->getOutstandingBills('customer', 1);
  693. $outstandingOpenedLate = $tmp['opened'];
  694. if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
  695. $warn = '';
  696. if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpenedLate) {
  697. $warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
  698. }
  699. $text = $langs->trans("CurrentOutstandingBillLate");
  700. $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
  701. $icon = 'bill';
  702. if ($link) {
  703. $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
  704. }
  705. $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
  706. $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
  707. $boxstat .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
  708. $boxstat .= '</div>';
  709. if ($link) {
  710. $boxstat .= '</a>';
  711. }
  712. }
  713. }
  714. $parameters = array();
  715. $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action);
  716. if (empty($reshook)) {
  717. $boxstat .= $hookmanager->resPrint;
  718. }
  719. $boxstat .= '</td></tr>';
  720. $boxstat .= '</table>';
  721. $boxstat .= '</div>';
  722. print $boxstat;
  723. /*
  724. * Latest proposals
  725. */
  726. if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
  727. $langs->load("propal");
  728. $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
  729. $sql .= ", p.total_tva";
  730. $sql .= ", p.total_ttc";
  731. $sql .= ", p.ref, p.ref_client, p.remise";
  732. $sql .= ", p.datep as dp, p.fin_validite as date_limit";
  733. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
  734. $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
  735. $sql .= " AND s.rowid = ".((int) $object->id);
  736. $sql .= " AND p.entity IN (".getEntity('propal').")";
  737. $sql .= " ORDER BY p.datep DESC";
  738. $resql = $db->query($sql);
  739. if ($resql) {
  740. $propal_static = new Propal($db);
  741. $num = $db->num_rows($resql);
  742. if ($num > 0) {
  743. print '<div class="div-table-responsive-no-min">';
  744. print '<table class="noborder centpercent lastrecordtable">';
  745. print '<tr class="liste_titre">';
  746. 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>';
  747. 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>';
  748. print '</tr></table></td>';
  749. print '</tr>';
  750. }
  751. $i = 0;
  752. while ($i < $num && $i < $MAXLIST) {
  753. $objp = $db->fetch_object($resql);
  754. print '<tr class="oddeven">';
  755. print '<td class="nowraponall">';
  756. $propal_static->id = $objp->propalid;
  757. $propal_static->ref = $objp->ref;
  758. $propal_static->ref_client = $objp->ref_client;
  759. $propal_static->total_ht = $objp->total_ht;
  760. $propal_static->total_tva = $objp->total_tva;
  761. $propal_static->total_ttc = $objp->total_ttc;
  762. print $propal_static->getNomUrl(1);
  763. if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
  764. print " ".img_warning();
  765. }
  766. print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
  767. print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
  768. print '<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).'</td></tr>';
  769. $i++;
  770. }
  771. $db->free($resql);
  772. if ($num > 0) {
  773. print "</table>";
  774. print '</div>';
  775. }
  776. } else {
  777. dol_print_error($db);
  778. }
  779. }
  780. /*
  781. * Latest orders
  782. */
  783. if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
  784. $sql = "SELECT s.nom, s.rowid";
  785. $sql .= ", c.rowid as cid, c.total_ht";
  786. $sql .= ", c.total_tva";
  787. $sql .= ", c.total_ttc";
  788. $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture";
  789. $sql .= ", c.date_commande as dc";
  790. $sql .= ", c.facture as billed";
  791. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
  792. $sql .= " WHERE c.fk_soc = s.rowid ";
  793. $sql .= " AND s.rowid = ".((int) $object->id);
  794. $sql .= " AND c.entity IN (".getEntity('commande').')';
  795. $sql .= " ORDER BY c.date_commande DESC";
  796. $resql = $db->query($sql);
  797. if ($resql) {
  798. $commande_static = new Commande($db);
  799. $num = $db->num_rows($resql);
  800. if ($num > 0) {
  801. // Check if there are orders billable
  802. $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
  803. $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
  804. $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
  805. $sql2 .= ', '.MAIN_DB_PREFIX.'commande as c';
  806. $sql2 .= ' WHERE c.fk_soc = s.rowid';
  807. $sql2 .= ' AND s.rowid = '.((int) $object->id);
  808. // Show orders with status validated, shipping started and delivered (well any order we can bill)
  809. $sql2 .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
  810. $resql2 = $db->query($sql2);
  811. $orders2invoice = $db->num_rows($resql2);
  812. $db->free($resql2);
  813. print '<div class="div-table-responsive-no-min">';
  814. print '<table class="noborder centpercent lastrecordtable">';
  815. print '<tr class="liste_titre">';
  816. 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>';
  817. 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>';
  818. print '</tr></table></td>';
  819. print '</tr>';
  820. }
  821. $i = 0;
  822. while ($i < $num && $i < $MAXLIST) {
  823. $objp = $db->fetch_object($resql);
  824. $commande_static->id = $objp->cid;
  825. $commande_static->ref = $objp->ref;
  826. $commande_static->ref_client = $objp->ref_client;
  827. $commande_static->total_ht = $objp->total_ht;
  828. $commande_static->total_tva = $objp->total_tva;
  829. $commande_static->total_ttc = $objp->total_ttc;
  830. $commande_static->billed = $objp->billed;
  831. print '<tr class="oddeven">';
  832. print '<td class="nowraponall">';
  833. print $commande_static->getNomUrl(1);
  834. print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day')."</td>\n";
  835. print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
  836. print '<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>';
  837. $i++;
  838. }
  839. $db->free($resql);
  840. if ($num > 0) {
  841. print "</table>";
  842. print '</div>';
  843. }
  844. } else {
  845. dol_print_error($db);
  846. }
  847. }
  848. /*
  849. * Latest shipments
  850. */
  851. if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
  852. $sql = 'SELECT e.rowid as id';
  853. $sql .= ', e.ref';
  854. $sql .= ', e.date_creation';
  855. $sql .= ', e.fk_statut as statut';
  856. $sql .= ', s.nom';
  857. $sql .= ', s.rowid as socid';
  858. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
  859. $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
  860. $sql .= " AND e.entity IN (".getEntity('expedition').")";
  861. $sql .= ' GROUP BY e.rowid';
  862. $sql .= ', e.ref';
  863. $sql .= ', e.date_creation';
  864. $sql .= ', e.fk_statut';
  865. $sql .= ', s.nom';
  866. $sql .= ', s.rowid';
  867. $sql .= " ORDER BY e.date_creation DESC";
  868. $resql = $db->query($sql);
  869. if ($resql) {
  870. $sendingstatic = new Expedition($db);
  871. $num = $db->num_rows($resql);
  872. if ($num > 0) {
  873. print '<div class="div-table-responsive-no-min">';
  874. print '<table class="noborder centpercent lastrecordtable">';
  875. print '<tr class="liste_titre">';
  876. 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>';
  877. 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>';
  878. print '</tr></table></td>';
  879. print '</tr>';
  880. }
  881. $i = 0;
  882. while ($i < $num && $i < $MAXLIST) {
  883. $objp = $db->fetch_object($resql);
  884. $sendingstatic->id = $objp->id;
  885. $sendingstatic->ref = $objp->ref;
  886. print '<tr class="oddeven">';
  887. print '<td class="nowraponall">';
  888. print $sendingstatic->getNomUrl(1);
  889. print '</td>';
  890. if ($objp->date_creation > 0) {
  891. print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>';
  892. } else {
  893. print '<td class="right"><b>!!!</b></td>';
  894. }
  895. print '<td class="nowrap right" width="100" >'.$sendingstatic->LibStatut($objp->statut, 5).'</td>';
  896. print "</tr>\n";
  897. $i++;
  898. }
  899. $db->free($resql);
  900. if ($num > 0) {
  901. print "</table>";
  902. print '</div>';
  903. }
  904. } else {
  905. dol_print_error($db);
  906. }
  907. }
  908. /*
  909. * Latest contracts
  910. */
  911. if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
  912. $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";
  913. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
  914. $sql .= " WHERE c.fk_soc = s.rowid ";
  915. $sql .= " AND s.rowid = ".((int) $object->id);
  916. $sql .= " AND c.entity IN (".getEntity('contract').")";
  917. $sql .= " ORDER BY c.datec DESC";
  918. $resql = $db->query($sql);
  919. if ($resql) {
  920. $contrat = new Contrat($db);
  921. $num = $db->num_rows($resql);
  922. if ($num > 0) {
  923. print '<div class="div-table-responsive-no-min">';
  924. print '<table class="noborder centpercent lastrecordtable">';
  925. print '<tr class="liste_titre">';
  926. print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
  927. 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>';
  928. //print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/contract/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
  929. print '</tr></table></td>';
  930. print '</tr>';
  931. }
  932. $i = 0;
  933. while ($i < $num && $i < $MAXLIST) {
  934. $objp = $db->fetch_object($resql);
  935. $contrat->id = $objp->id;
  936. $contrat->ref = $objp->ref ? $objp->ref : $objp->id;
  937. $contrat->ref_customer = $objp->refcus;
  938. $contrat->ref_supplier = $objp->refsup;
  939. $contrat->statut = $objp->contract_status;
  940. $contrat->fetch_lines();
  941. $late = '';
  942. foreach ($contrat->lines as $line) {
  943. if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
  944. if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) {
  945. $late = img_warning($langs->trans("Late"));
  946. }
  947. }
  948. }
  949. print '<tr class="oddeven">';
  950. print '<td class="nowraponall">';
  951. print $contrat->getNomUrl(1, 12);
  952. print $late;
  953. print "</td>\n";
  954. print '<td class="nowrap">'.dol_trunc($objp->refsup, 12)."</td>\n";
  955. //print '<td class="right" width="80px"><span title="'.$langs->trans("DateCreation").'">'.dol_print_date($db->jdate($objp->dc), 'day')."</span></td>\n";
  956. print '<td class="right" width="80px"><span title="'.$langs->trans("DateContract").'">'.dol_print_date($db->jdate($objp->dcon), 'day')."</span></td>\n";
  957. print '<td width="20">&nbsp;</td>';
  958. print '<td class="nowraponall right">';
  959. print $contrat->getLibStatut(4);
  960. print "</td>\n";
  961. print '</tr>';
  962. $i++;
  963. }
  964. $db->free($resql);
  965. if ($num > 0) {
  966. print "</table>";
  967. print '</div>';
  968. }
  969. } else {
  970. dol_print_error($db);
  971. }
  972. }
  973. /*
  974. * Latest interventions
  975. */
  976. if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) {
  977. $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate";
  978. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
  979. $sql .= " WHERE f.fk_soc = s.rowid";
  980. $sql .= " AND s.rowid = ".((int) $object->id);
  981. $sql .= " AND f.entity IN (".getEntity('intervention').")";
  982. $sql .= " ORDER BY f.tms DESC";
  983. $resql = $db->query($sql);
  984. if ($resql) {
  985. $fichinter_static = new Fichinter($db);
  986. $num = $db->num_rows($resql);
  987. if ($num > 0) {
  988. print '<div class="div-table-responsive-no-min">';
  989. print '<table class="noborder centpercent lastrecordtable">';
  990. print '<tr class="liste_titre">';
  991. 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>';
  992. 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>';
  993. print '</tr></table></td>';
  994. print '</tr>';
  995. }
  996. $i = 0;
  997. while ($i < $num && $i < $MAXLIST) {
  998. $objp = $db->fetch_object($resql);
  999. $fichinter_static->id = $objp->id;
  1000. $fichinter_static->ref = $objp->ref;
  1001. $fichinter_static->statut = $objp->fk_statut;
  1002. print '<tr class="oddeven">';
  1003. print '<td class="nowraponall">';
  1004. print $fichinter_static->getNomUrl(1);
  1005. print '</td>'."\n";
  1006. //print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
  1007. print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
  1008. print '<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n";
  1009. print '</tr>';
  1010. $i++;
  1011. }
  1012. $db->free($resql);
  1013. if ($num > 0) {
  1014. print "</table>";
  1015. print '</div>';
  1016. }
  1017. } else {
  1018. dol_print_error($db);
  1019. }
  1020. }
  1021. /*
  1022. * Latest invoices templates
  1023. */
  1024. if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
  1025. $sql = 'SELECT f.rowid as id, f.titre as ref';
  1026. $sql .= ', f.total_ht';
  1027. $sql .= ', f.total_tva';
  1028. $sql .= ', f.total_ttc';
  1029. $sql .= ', f.datec as dc';
  1030. $sql .= ', f.date_last_gen, f.date_when';
  1031. $sql .= ', f.frequency';
  1032. $sql .= ', f.unit_frequency';
  1033. $sql .= ', f.suspended as suspended';
  1034. $sql .= ', s.nom, s.rowid as socid';
  1035. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
  1036. $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
  1037. $sql .= " AND f.entity IN (".getEntity('invoice').")";
  1038. $sql .= ' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
  1039. $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
  1040. $sql .= ' f.suspended, f.date_when,';
  1041. $sql .= ' s.nom, s.rowid';
  1042. $sql .= " ORDER BY f.date_last_gen, f.datec DESC";
  1043. $resql = $db->query($sql);
  1044. if ($resql) {
  1045. $invoicetemplate = new FactureRec($db);
  1046. $num = $db->num_rows($resql);
  1047. if ($num > 0) {
  1048. print '<div class="div-table-responsive-no-min">';
  1049. print '<table class="noborder centpercent lastrecordtable">';
  1050. print '<tr class="liste_titre">';
  1051. 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>';
  1052. print '</tr></table></td>';
  1053. print '</tr>';
  1054. }
  1055. $i = 0;
  1056. while ($i < $num && $i < $MAXLIST) {
  1057. $objp = $db->fetch_object($resql);
  1058. $invoicetemplate->id = $objp->id;
  1059. $invoicetemplate->ref = $objp->ref;
  1060. $invoicetemplate->suspended = $objp->suspended;
  1061. $invoicetemplate->frequency = $objp->frequency;
  1062. $invoicetemplate->unit_frequency = $objp->unit_frequency;
  1063. $invoicetemplate->total_ht = $objp->total_ht;
  1064. $invoicetemplate->total_tva = $objp->total_tva;
  1065. $invoicetemplate->total_ttc = $objp->total_ttc;
  1066. $invoicetemplate->date_last_gen = $objp->date_last_gen;
  1067. $invoicetemplate->date_when = $objp->date_when;
  1068. print '<tr class="oddeven">';
  1069. print '<td class="nowrap">';
  1070. print $invoicetemplate->getNomUrl(1);
  1071. print '</td>';
  1072. if ($objp->frequency && $objp->date_last_gen > 0) {
  1073. print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
  1074. } else {
  1075. if ($objp->dc > 0) {
  1076. print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day').'</td>';
  1077. } else {
  1078. print '<td class="right"><b>!!!</b></td>';
  1079. }
  1080. }
  1081. print '<td class="right" style="min-width: 60px">';
  1082. print price($objp->total_ht);
  1083. print '</td>';
  1084. if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
  1085. print '<td class="right" style="min-width: 60px">';
  1086. print price($objp->total_ttc);
  1087. print '</td>';
  1088. }
  1089. print '<td class="nowrap right" style="min-width: 60px">';
  1090. print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - ';
  1091. print ($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
  1092. print '</td>';
  1093. print "</tr>\n";
  1094. $i++;
  1095. }
  1096. $db->free($resql);
  1097. if ($num > 0) {
  1098. print "</table>";
  1099. print '</div>';
  1100. }
  1101. } else {
  1102. dol_print_error($db);
  1103. }
  1104. }
  1105. /*
  1106. * Latest invoices
  1107. */
  1108. if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
  1109. $sql = 'SELECT f.rowid as facid, f.ref, f.type';
  1110. $sql .= ', f.total_ht';
  1111. $sql .= ', f.total_tva';
  1112. $sql .= ', f.total_ttc';
  1113. $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status';
  1114. $sql .= ', s.nom, s.rowid as socid';
  1115. $sql .= ', SUM(pf.amount) as am';
  1116. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
  1117. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
  1118. $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
  1119. $sql .= " AND f.entity IN (".getEntity('invoice').")";
  1120. $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.total_ht, f.total_tva, f.total_ttc,';
  1121. $sql .= ' f.datef, f.datec, f.paye, f.fk_statut,';
  1122. $sql .= ' s.nom, s.rowid';
  1123. $sql .= " ORDER BY f.datef DESC, f.datec DESC";
  1124. $resql = $db->query($sql);
  1125. if ($resql) {
  1126. $facturestatic = new Facture($db);
  1127. $num = $db->num_rows($resql);
  1128. if ($num > 0) {
  1129. print '<div class="div-table-responsive-no-min">';
  1130. print '<table class="noborder centpercent lastrecordtable">';
  1131. print '<tr class="liste_titre">';
  1132. 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>';
  1133. 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>';
  1134. print '</tr></table></td>';
  1135. print '</tr>';
  1136. }
  1137. $i = 0;
  1138. while ($i < $num && $i < $MAXLIST) {
  1139. $objp = $db->fetch_object($resql);
  1140. $facturestatic->id = $objp->facid;
  1141. $facturestatic->ref = $objp->ref;
  1142. $facturestatic->type = $objp->type;
  1143. $facturestatic->total_ht = $objp->total_ht;
  1144. $facturestatic->total_tva = $objp->total_tva;
  1145. $facturestatic->total_ttc = $objp->total_ttc;
  1146. $facturestatic->statut = $objp->status;
  1147. print '<tr class="oddeven">';
  1148. print '<td class="nowraponall">';
  1149. print $facturestatic->getNomUrl(1);
  1150. print '</td>';
  1151. if ($objp->df > 0) {
  1152. print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->df), 'day').'</td>';
  1153. } else {
  1154. print '<td class="right"><b>!!!</b></td>';
  1155. }
  1156. print '<td class="right" style="min-width: 60px">';
  1157. print price($objp->total_ht);
  1158. print '</td>';
  1159. if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
  1160. print '<td class="right" style="min-width: 60px">';
  1161. print price($objp->total_ttc);
  1162. print '</td>';
  1163. }
  1164. print '<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->status, 5, $objp->am)).'</td>';
  1165. print "</tr>\n";
  1166. $i++;
  1167. }
  1168. $db->free($resql);
  1169. if ($num > 0) {
  1170. print "</table>";
  1171. print '</div>';
  1172. }
  1173. } else {
  1174. dol_print_error($db);
  1175. }
  1176. }
  1177. // Allow external modules to add their own shortlist of recent objects
  1178. $parameters = array();
  1179. $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action);
  1180. if ($reshook < 0) {
  1181. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  1182. } else {
  1183. print $hookmanager->resPrint;
  1184. }
  1185. print '</div></div>';
  1186. print '<div style="clear:both"></div>';
  1187. print dol_get_fiche_end();
  1188. /*
  1189. * Action bar
  1190. */
  1191. print '<div class="tabsAction">';
  1192. $parameters = array();
  1193. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
  1194. if (empty($reshook)) {
  1195. if ($object->status != 1) {
  1196. print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
  1197. }
  1198. if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) {
  1199. $langs->load("propal");
  1200. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a></div>';
  1201. }
  1202. if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) {
  1203. $langs->load("orders");
  1204. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddOrder").'</a></div>';
  1205. }
  1206. if (!empty($user->rights->contrat->creer) && $object->status == 1) {
  1207. $langs->load("contracts");
  1208. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContract").'</a></div>';
  1209. }
  1210. if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) {
  1211. $langs->load("fichinter");
  1212. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a></div>';
  1213. }
  1214. // Add invoice
  1215. if ($user->socid == 0) {
  1216. if (!empty($conf->deplacement->enabled) && $object->status == 1) {
  1217. $langs->load("trips");
  1218. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
  1219. }
  1220. if (!empty($conf->facture->enabled) && $object->status == 1) {
  1221. if (empty($user->rights->facture->creer)) {
  1222. print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
  1223. } else {
  1224. $langs->loadLangs(array("orders", "bills"));
  1225. if (!empty($conf->commande->enabled)) {
  1226. if ($object->client != 0 && $object->client != 2) {
  1227. if (!empty($orders2invoice) && $orders2invoice > 0) {
  1228. 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>';
  1229. } else {
  1230. print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
  1231. }
  1232. } else {
  1233. print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
  1234. }
  1235. }
  1236. if ($object->client != 0 && $object->client != 2) {
  1237. 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>';
  1238. } else {
  1239. print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
  1240. }
  1241. }
  1242. }
  1243. }
  1244. // Add action
  1245. if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
  1246. if ($user->rights->agenda->myactions->create) {
  1247. 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>';
  1248. } else {
  1249. print '<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a></div>';
  1250. }
  1251. }
  1252. }
  1253. print '</div>';
  1254. if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) {
  1255. // List of contacts
  1256. show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
  1257. }
  1258. if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {
  1259. print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
  1260. // List of todo actions
  1261. show_actions_todo($conf, $langs, $db, $object);
  1262. // List of done actions
  1263. show_actions_done($conf, $langs, $db, $object);
  1264. }
  1265. } else {
  1266. $langs->load("errors");
  1267. print $langs->trans('ErrorRecordNotFound');
  1268. }
  1269. // End of page
  1270. llxFooter();
  1271. $db->close();