payments.lib.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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, $hookmanager, $action;
  127. $validpaymentmethod = array();
  128. if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) {
  129. $langs->load("paypal");
  130. $validpaymentmethod['paypal'] = 'valid';
  131. }
  132. if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) {
  133. $langs->load("paybox");
  134. $validpaymentmethod['paybox'] = 'valid';
  135. }
  136. if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) {
  137. $langs->load("stripe");
  138. $validpaymentmethod['stripe'] = 'valid';
  139. }
  140. // This hook is used to complete the $validpaymentmethod array so an external payment modules
  141. // can add its own key (ie 'payzen' for Payzen, ...)
  142. $parameters = [
  143. 'paymentmethod' => $paymentmethod,
  144. 'validpaymentmethod' => &$validpaymentmethod
  145. ];
  146. $tmpobject = new stdClass();
  147. $reshook = $hookmanager->executeHooks('getValidPayment', $parameters, $tmpobject, $action);
  148. if ($reshook < 0) {
  149. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  150. } elseif (!empty($hookmanager->resArray['validpaymentmethod'])) {
  151. if ($reshook == 0) {
  152. $validpaymentmethod = array_merge($validpaymentmethod, $hookmanager->resArray['validpaymentmethod']);
  153. } else {
  154. $validpaymentmethod = $hookmanager->resArray['validpaymentmethod'];
  155. }
  156. }
  157. return $validpaymentmethod;
  158. }
  159. /**
  160. * Return string with full online payment Url
  161. *
  162. * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
  163. * @param string $ref Ref of object
  164. * @param int $amount Amount of money to request for
  165. * @return string Url string
  166. */
  167. function showOnlinePaymentUrl($type, $ref, $amount = '9.99')
  168. {
  169. global $langs;
  170. // Load translation files required by the page
  171. $langs->loadLangs(array('payment', 'stripe'));
  172. $servicename = ''; // Link is a generic link for all payments services (paypal, stripe, ...)
  173. $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'</span><br>';
  174. $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
  175. $out .= '<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercentminusx" value="'.$url.'">';
  176. $out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
  177. $out .= '</div>';
  178. $out .= ajax_autoselect("onlinepaymenturl", 0);
  179. return $out;
  180. }
  181. /**
  182. * Return string with HTML link for online payment
  183. *
  184. * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
  185. * @param string $ref Ref of object
  186. * @param string $label Text or HTML tag to display, if empty it display the URL
  187. * @param int $amount Amount of money to request for
  188. * @return string Url string
  189. */
  190. function getHtmlOnlinePaymentLink($type, $ref, $label = '', $amount = '9.99')
  191. {
  192. $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
  193. $label = $label ? $label : $url;
  194. return '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$label.'</a>';
  195. }
  196. /**
  197. * Return string with full Url
  198. *
  199. * @param int $mode 0=True url, 1=Url formated with colors
  200. * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...)
  201. * @param string $ref Ref of object
  202. * @param int $amount Amount of money to request for
  203. * @param string $freetag Free tag (required and used for $type='free' only)
  204. * @param string $localorexternal 0=Url for browser, 1=Url for external access
  205. * @return string Url string
  206. */
  207. function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 1)
  208. {
  209. global $conf, $dolibarr_main_url_root;
  210. $ref = str_replace(' ', '', $ref);
  211. $out = '';
  212. // Define $urlwithroot
  213. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  214. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  215. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  216. $urltouse = DOL_MAIN_URL_ROOT;
  217. if ($localorexternal) {
  218. $urltouse = $urlwithroot;
  219. }
  220. if ($type == 'free') {
  221. $out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '<span style="color: #666666">' : '').$amount.($mode ? '</span>' : '').'&tag='.($mode ? '<span style="color: #666666">' : '').$freetag.($mode ? '</span>' : '');
  222. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  223. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  224. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  225. } else {
  226. $out .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2));
  227. }
  228. }
  229. //if ($mode) $out.='&noidempotency=1';
  230. } elseif ($type == 'order') {
  231. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  232. if ($mode == 1) {
  233. $out .= 'order_ref';
  234. }
  235. if ($mode == 0) {
  236. $out .= urlencode($ref);
  237. }
  238. $out .= ($mode ? '</span>' : '');
  239. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  240. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  241. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  242. } else {
  243. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  244. if ($mode == 1) {
  245. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)";
  246. }
  247. if ($mode == 0) {
  248. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  249. }
  250. $out .= ($mode ? '</span>' : '');
  251. }
  252. }
  253. } elseif ($type == 'invoice') {
  254. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  255. if ($mode == 1) {
  256. $out .= 'invoice_ref';
  257. }
  258. if ($mode == 0) {
  259. $out .= urlencode($ref);
  260. }
  261. $out .= ($mode ? '</span>' : '');
  262. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  263. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  264. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  265. } else {
  266. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  267. if ($mode == 1) {
  268. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
  269. }
  270. if ($mode == 0) {
  271. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  272. }
  273. $out .= ($mode ? '</span>' : '');
  274. }
  275. }
  276. } elseif ($type == 'contractline') {
  277. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  278. if ($mode == 1) {
  279. $out .= 'contractline_ref';
  280. }
  281. if ($mode == 0) {
  282. $out .= urlencode($ref);
  283. }
  284. $out .= ($mode ? '</span>' : '');
  285. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  286. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  287. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  288. } else {
  289. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  290. if ($mode == 1) {
  291. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)";
  292. }
  293. if ($mode == 0) {
  294. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  295. }
  296. $out .= ($mode ? '</span>' : '');
  297. }
  298. }
  299. } elseif ($type == 'member' || $type == 'membersubscription') {
  300. $newtype = 'member';
  301. $out = $urltouse.'/public/payment/newpayment.php?source=member';
  302. $out .= '&amount='.$amount;
  303. $out .= '&ref='.($mode ? '<span style="color: #666666">' : '');
  304. if ($mode == 1) {
  305. $out .= 'member_ref';
  306. }
  307. if ($mode == 0) {
  308. $out .= urlencode($ref);
  309. }
  310. $out .= ($mode ? '</span>' : '');
  311. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  312. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  313. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  314. } else {
  315. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  316. if ($mode == 1) {
  317. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$newtype."' + member_ref)";
  318. }
  319. if ($mode == 0) {
  320. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$newtype.$ref, 2);
  321. }
  322. $out .= ($mode ? '</span>' : '');
  323. }
  324. }
  325. } elseif ($type == 'donation') {
  326. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  327. if ($mode == 1) {
  328. $out .= 'donation_ref';
  329. }
  330. if ($mode == 0) {
  331. $out .= urlencode($ref);
  332. }
  333. $out .= ($mode ? '</span>' : '');
  334. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  335. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  336. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  337. } else {
  338. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  339. if ($mode == 1) {
  340. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)";
  341. }
  342. if ($mode == 0) {
  343. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  344. }
  345. $out .= ($mode ? '</span>' : '');
  346. }
  347. }
  348. } elseif ($type == 'boothlocation') {
  349. $out = $urltouse.'/public/payment/newpayment.php?source='.$type.'&ref='.($mode ? '<span style="color: #666666">' : '');
  350. if ($mode == 1) {
  351. $out .= 'invoice_ref';
  352. }
  353. if ($mode == 0) {
  354. $out .= urlencode($ref);
  355. }
  356. $out .= ($mode ? '</span>' : '');
  357. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  358. if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  359. $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
  360. } else {
  361. $out .= '&securekey='.($mode ? '<span style="color: #666666">' : '');
  362. if ($mode == 1) {
  363. $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
  364. }
  365. if ($mode == 0) {
  366. $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
  367. }
  368. $out .= ($mode ? '</span>' : '');
  369. }
  370. }
  371. }
  372. // For multicompany
  373. if (!empty($out) && isModEnabled('multicompany')) {
  374. $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
  375. }
  376. return $out;
  377. }
  378. /**
  379. * Show footer of company in HTML pages
  380. *
  381. * @param Societe $fromcompany Third party
  382. * @param Translate $langs Output language
  383. * @param int $addformmessage Add the payment form message
  384. * @param string $suffix Suffix to use on constants
  385. * @param Object $object Object related to payment
  386. * @return void
  387. */
  388. function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null)
  389. {
  390. global $conf;
  391. // Juridical status
  392. $line1 = "";
  393. if ($fromcompany->forme_juridique_code) {
  394. $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
  395. }
  396. // Capital
  397. if ($fromcompany->capital) {
  398. $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
  399. }
  400. // Prof Id 1
  401. if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
  402. $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
  403. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  404. $field = $reg[1];
  405. }
  406. $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
  407. }
  408. // Prof Id 2
  409. if ($fromcompany->idprof2) {
  410. $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
  411. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  412. $field = $reg[1];
  413. }
  414. $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
  415. }
  416. // Second line of company infos
  417. $line2 = "";
  418. // Prof Id 3
  419. if ($fromcompany->idprof3) {
  420. $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
  421. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  422. $field = $reg[1];
  423. }
  424. $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
  425. }
  426. // Prof Id 4
  427. if ($fromcompany->idprof4) {
  428. $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
  429. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  430. $field = $reg[1];
  431. }
  432. $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
  433. }
  434. // IntraCommunautary VAT
  435. if ($fromcompany->tva_intra != '') {
  436. $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
  437. }
  438. print '<!-- htmlPrintOnlinePaymentFooter -->'."\n";
  439. print '<br>';
  440. print '<div class="center paddingleft paddingright">'."\n";
  441. if ($addformmessage) {
  442. print '<!-- object = '.(empty($object) ? 'undefined' : $object->element).' -->';
  443. print '<br>';
  444. $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
  445. if (!empty($conf->global->$parammessageform)) {
  446. print $langs->transnoentities($conf->global->$parammessageform);
  447. } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) {
  448. print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
  449. }
  450. // Add other message if VAT exists
  451. if (!empty($object->total_vat) || !empty($object->total_tva)) {
  452. $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
  453. if (!empty($conf->global->$parammessageform)) {
  454. print $langs->transnoentities($conf->global->$parammessageform);
  455. } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) {
  456. print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
  457. }
  458. }
  459. }
  460. print '<span style="font-size: 10px;"><br><hr>'."\n";
  461. print $fromcompany->name.'<br>';
  462. print $line1;
  463. if (strlen($line1.$line2) > 50) {
  464. print '<br>';
  465. } else {
  466. print ' - ';
  467. }
  468. print $line2;
  469. print '</span></div>'."\n";
  470. }