payments.lib.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <?php
  2. /**
  3. * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
  4. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  5. * Copyright (C) 2020 Abbes Bahfir <bafbes@gmail.com>
  6. * Copyright (C) 2021 Waël Almoman <info@almoman.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. * or see https://www.gnu.org/
  21. */
  22. /**
  23. * Returns an array with the tabs for the "Payment" section
  24. * It loads tabs from modules looking for the entity payment
  25. *
  26. * @param Paiement $object Current payment object
  27. * @return array Tabs for the payment section
  28. */
  29. function payment_prepare_head(Paiement $object)
  30. {
  31. global $langs, $conf;
  32. $h = 0;
  33. $head = array();
  34. $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id;
  35. $head[$h][1] = $langs->trans("Payment");
  36. $head[$h][2] = 'payment';
  37. $h++;
  38. // Show more tabs from modules
  39. // Entries must be declared in modules descriptor with line
  40. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  41. // $this->tabs = array('entity:-tabname); to remove a tab
  42. complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment');
  43. $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id;
  44. $head[$h][1] = $langs->trans("Info");
  45. $head[$h][2] = 'info';
  46. $h++;
  47. complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove');
  48. return $head;
  49. }
  50. /**
  51. * Returns an array with the tabs for the "Bannkline" section
  52. * It loads tabs from modules looking for the entity payment
  53. *
  54. * @param int $id ID of bank line
  55. * @return array Tabs for the Bankline section
  56. */
  57. function bankline_prepare_head($id)
  58. {
  59. global $langs, $conf;
  60. $h = 0;
  61. $head = array();
  62. $head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id;
  63. $head[$h][1] = $langs->trans('BankTransaction');
  64. $head[$h][2] = 'bankline';
  65. $h++;
  66. // Show more tabs from modules
  67. // Entries must be declared in modules descriptor with line
  68. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  69. // $this->tabs = array('entity:-tabname); to remove a tab
  70. complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline');
  71. $head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$id;
  72. $head[$h][1] = $langs->trans("Info");
  73. $head[$h][2] = 'info';
  74. $h++;
  75. complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline', 'remove');
  76. return $head;
  77. }
  78. /**
  79. * Returns an array with the tabs for the "Supplier payment" section
  80. * It loads tabs from modules looking for the entity payment_supplier
  81. *
  82. * @param Paiement $object Current payment object
  83. * @return array Tabs for the payment section
  84. */
  85. function payment_supplier_prepare_head(Paiement $object)
  86. {
  87. global $db, $langs, $conf;
  88. $h = 0;
  89. $head = array();
  90. $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$object->id;
  91. $head[$h][1] = $langs->trans("Payment");
  92. $head[$h][2] = 'payment';
  93. $h++;
  94. // Show more tabs from modules
  95. // Entries must be declared in modules descriptor with line
  96. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  97. // $this->tabs = array('entity:-tabname); to remove a tab
  98. complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier');
  99. $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id;
  100. $head[$h][1] = $langs->trans('Info');
  101. $head[$h][2] = 'info';
  102. $h++;
  103. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  104. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  105. $upload_dir = $conf->fournisseur->payment->dir_output.'/'.$object->ref;
  106. $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
  107. $nbLinks = Link::count($db, $object->element, $object->id);
  108. $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/document.php?id='.$object->id;
  109. $head[$h][1] = $langs->trans('Documents');
  110. if (($nbFiles + $nbLinks) > 0) {
  111. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
  112. }
  113. $head[$h][2] = 'documents';
  114. $h++;
  115. complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier', 'remove');
  116. return $head;
  117. }
  118. /**
  119. * Return array of valid payment mode
  120. *
  121. * @param string $paymentmethod Filter on this payment method (''=none, 'paypal', ...)
  122. * @return array Array of valid payment method
  123. */
  124. function getValidOnlinePaymentMethods($paymentmethod = '')
  125. {
  126. global $conf, $langs, $db;// @todo, $user;
  127. $validpaymentmethod = array();
  128. if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) {
  129. $langs->load("paypal");
  130. $validpaymentmethod['paypal'] = 'valid';
  131. }
  132. if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) {
  133. $langs->load("paybox");
  134. $validpaymentmethod['paybox'] = 'valid';
  135. }
  136. if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) {
  137. $langs->load("stripe");
  138. $validpaymentmethod['stripe'] = 'valid';
  139. }
  140. // Added by MMI Mathieu Moulin iProspective
  141. if ((empty($paymentmethod) || $paymentmethod == 'mbietransactions') && !empty($conf->mbietransactions->enabled)) {
  142. $langs->load("mbietransactions@mbietransactions");
  143. $validpaymentmethod['mbietransactions'] = 'valid';
  144. }
  145. // TODO Add trigger
  146. //include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
  147. //$interface = new Interfaces($db);
  148. //$result = $interface->run_triggers('', NULL, $user, $langs, $conf);
  149. //var_dump($validpaymentmethod);
  150. return $validpaymentmethod;
  151. }
  152. /**
  153. * Return string with full online payment Url
  154. *
  155. * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
  156. * @param string $ref Ref of object
  157. * @return string Url string
  158. */
  159. function showOnlinePaymentUrl($type, $ref)
  160. {
  161. global $langs;
  162. // Load translation files required by the page
  163. $langs->loadLangs(array('payment', 'stripe'));
  164. $servicename = ''; // Link is a generic link for all payments services (paypal, stripe, ...)
  165. $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'</span><br>';
  166. $url = getOnlinePaymentUrl(0, $type, $ref);
  167. $out .= '<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercentminusx" value="'.$url.'">';
  168. $out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
  169. $out .= '</div>';
  170. $out .= ajax_autoselect("onlinepaymenturl", 0);
  171. return $out;
  172. }
  173. /**
  174. * Return string with HTML link for online payment
  175. *
  176. * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
  177. * @param string $ref Ref of object
  178. * @param string $label Text or HTML tag to display, if empty it display the URL
  179. * @return string Url string
  180. */
  181. function getHtmlOnlinePaymentLink($type, $ref, $label = '')
  182. {
  183. $url = getOnlinePaymentUrl(0, $type, $ref);
  184. $label = $label ? $label : $url;
  185. return '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$label.'</a>';
  186. }
  187. /**
  188. * Return string with full Url
  189. *
  190. * @param int $mode 0=True url, 1=Url formated with colors
  191. * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...)
  192. * @param string $ref Ref of object
  193. * @param int $amount Amount (required and used for $type='free' only)
  194. * @param string $freetag Free tag (required and used for $type='free' only)
  195. * @param string $localorexternal 0=Url for browser, 1=Url for external access
  196. * @return string Url string
  197. */
  198. function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 1)
  199. {
  200. global $conf, $dolibarr_main_url_root;
  201. $ref = str_replace(' ', '', $ref);
  202. $out = '';
  203. // Define $urlwithroot
  204. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  205. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  206. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  207. $urltouse = DOL_MAIN_URL_ROOT;
  208. if ($localorexternal) {
  209. $urltouse = $urlwithroot;
  210. }
  211. if ($type == 'free') {
  212. $out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '<span style="color: #666666">' : '').$amount.($mode ? '</span>' : '').'&tag='.($mode ? '<span style="color: #666666">' : '').$freetag.($mode ? '</span>' : '');
  213. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  214. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  215. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  216. } else {
  217. $out .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2));
  218. }
  219. }
  220. //if ($mode) $out.='&noidempotency=1';
  221. // Added by MMI Mathieu Moulin iProspective
  222. } elseif ($type == 'propal') {
  223. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  224. if ($mode == 1) {
  225. $out .= 'propal_ref';
  226. }
  227. if ($mode == 0) {
  228. $out .= urlencode($ref);
  229. }
  230. $out .= ($mode ? '</font>' : '');
  231. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  232. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  233. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  234. } else {
  235. $out .= '&securekey='.($mode ? '<font color="#666666">' : '');
  236. if ($mode == 1) {
  237. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + propal_ref)";
  238. }
  239. if ($mode == 0) {
  240. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  241. }
  242. $out .= ($mode ? '</font>' : '');
  243. }
  244. }
  245. } elseif ($type == 'order') {
  246. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  247. if ($mode == 1) {
  248. $out .= 'order_ref';
  249. }
  250. if ($mode == 0) {
  251. $out .= urlencode($ref);
  252. }
  253. $out .= ($mode ? '</span>' : '');
  254. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  255. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  256. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  257. } else {
  258. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  259. if ($mode == 1) {
  260. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)";
  261. }
  262. if ($mode == 0) {
  263. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  264. }
  265. $out .= ($mode ? '</span>' : '');
  266. }
  267. }
  268. } elseif ($type == 'invoice') {
  269. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  270. if ($mode == 1) {
  271. $out .= 'invoice_ref';
  272. }
  273. if ($mode == 0) {
  274. $out .= urlencode($ref);
  275. }
  276. $out .= ($mode ? '</span>' : '');
  277. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  278. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  279. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  280. } else {
  281. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  282. if ($mode == 1) {
  283. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
  284. }
  285. if ($mode == 0) {
  286. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  287. }
  288. $out .= ($mode ? '</span>' : '');
  289. }
  290. }
  291. } elseif ($type == 'contractline') {
  292. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  293. if ($mode == 1) {
  294. $out .= 'contractline_ref';
  295. }
  296. if ($mode == 0) {
  297. $out .= urlencode($ref);
  298. }
  299. $out .= ($mode ? '</span>' : '');
  300. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  301. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  302. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  303. } else {
  304. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  305. if ($mode == 1) {
  306. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)";
  307. }
  308. if ($mode == 0) {
  309. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  310. }
  311. $out .= ($mode ? '</span>' : '');
  312. }
  313. }
  314. } elseif ($type == 'member' || $type == 'membersubscription') {
  315. $newtype = 'member';
  316. $out = $urltouse.'/public/payment/newpayment.php?source=member&ref='.($mode ? '<span style="color: #666666">' : '');
  317. if ($mode == 1) {
  318. $out .= 'member_ref';
  319. }
  320. if ($mode == 0) {
  321. $out .= urlencode($ref);
  322. }
  323. $out .= ($mode ? '</span>' : '');
  324. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  325. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  326. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  327. } else {
  328. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  329. if ($mode == 1) {
  330. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$newtype."' + member_ref)";
  331. }
  332. if ($mode == 0) {
  333. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$newtype.$ref, 2);
  334. }
  335. $out .= ($mode ? '</span>' : '');
  336. }
  337. }
  338. } elseif ($type == 'donation') {
  339. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  340. if ($mode == 1) {
  341. $out .= 'donation_ref';
  342. }
  343. if ($mode == 0) {
  344. $out .= urlencode($ref);
  345. }
  346. $out .= ($mode ? '</span>' : '');
  347. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  348. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  349. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  350. } else {
  351. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  352. if ($mode == 1) {
  353. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)";
  354. }
  355. if ($mode == 0) {
  356. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  357. }
  358. $out .= ($mode ? '</span>' : '');
  359. }
  360. }
  361. } elseif ($type == 'boothlocation') {
  362. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  363. if ($mode == 1) {
  364. $out .= 'invoice_ref';
  365. }
  366. if ($mode == 0) {
  367. $out .= urlencode($ref);
  368. }
  369. $out .= ($mode ? '</span>' : '');
  370. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  371. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  372. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  373. } else {
  374. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  375. if ($mode == 1) {
  376. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
  377. }
  378. if ($mode == 0) {
  379. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  380. }
  381. $out .= ($mode ? '</span>' : '');
  382. }
  383. }
  384. }
  385. // For multicompany
  386. if (!empty($out) && !empty($conf->multicompany->enabled)) {
  387. $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
  388. }
  389. return $out;
  390. }
  391. /**
  392. * Show footer of company in HTML pages
  393. *
  394. * @param Societe $fromcompany Third party
  395. * @param Translate $langs Output language
  396. * @param int $addformmessage Add the payment form message
  397. * @param string $suffix Suffix to use on constants
  398. * @param Object $object Object related to payment
  399. * @return void
  400. */
  401. function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null)
  402. {
  403. global $conf;
  404. // Juridical status
  405. $line1 = "";
  406. if ($fromcompany->forme_juridique_code) {
  407. $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
  408. }
  409. // Capital
  410. if ($fromcompany->capital) {
  411. $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
  412. }
  413. // Prof Id 1
  414. if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
  415. $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
  416. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  417. $field = $reg[1];
  418. }
  419. $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
  420. }
  421. // Prof Id 2
  422. if ($fromcompany->idprof2) {
  423. $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
  424. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  425. $field = $reg[1];
  426. }
  427. $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
  428. }
  429. // Second line of company infos
  430. $line2 = "";
  431. // Prof Id 3
  432. if ($fromcompany->idprof3) {
  433. $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
  434. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  435. $field = $reg[1];
  436. }
  437. $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
  438. }
  439. // Prof Id 4
  440. if ($fromcompany->idprof4) {
  441. $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
  442. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  443. $field = $reg[1];
  444. }
  445. $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
  446. }
  447. // IntraCommunautary VAT
  448. if ($fromcompany->tva_intra != '') {
  449. $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
  450. }
  451. print '<!-- htmlPrintOnlinePaymentFooter -->'."\n";
  452. print '<br>';
  453. print '<div class="center paddingleft paddingright">'."\n";
  454. if ($addformmessage) {
  455. print '<!-- object = '.$object->element.' -->';
  456. print '<br>';
  457. $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
  458. if (!empty($conf->global->$parammessageform)) {
  459. print $langs->transnoentities($conf->global->$parammessageform);
  460. } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) {
  461. print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
  462. }
  463. // Add other message if VAT exists
  464. if ($object->total_vat != 0 || $object->total_tva != 0) {
  465. $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
  466. if (!empty($conf->global->$parammessageform)) {
  467. print $langs->transnoentities($conf->global->$parammessageform);
  468. } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) {
  469. print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
  470. }
  471. }
  472. }
  473. print '<span style="font-size: 10px;"><br><hr>'."\n";
  474. print $fromcompany->name.'<br>';
  475. print $line1;
  476. if (strlen($line1.$line2) > 50) {
  477. print '<br>';
  478. } else {
  479. print ' - ';
  480. }
  481. print $line2;
  482. print '</span></div>'."\n";
  483. }