stripe.lib.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/stripe/lib/stripe.lib.php
  19. * \ingroup stripe
  20. * \brief Library for common stripe functions
  21. */
  22. require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
  23. /**
  24. * Define head array for tabs of stripe tools setup pages
  25. *
  26. * @return Array of head
  27. */
  28. function stripeadmin_prepare_head()
  29. {
  30. global $langs, $conf;
  31. $h = 0;
  32. $head = array();
  33. $head[$h][0] = DOL_URL_ROOT."/stripe/admin/stripe.php";
  34. $head[$h][1] = $langs->trans("Stripe");
  35. $head[$h][2] = 'stripeaccount';
  36. $h++;
  37. $object = new stdClass();
  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, 'stripeadmin');
  43. complete_head_from_modules($conf, $langs, $object, $head, $h, 'stripeadmin', 'remove');
  44. return $head;
  45. }
  46. /**
  47. * Show footer of company in HTML pages
  48. *
  49. * @param Societe $fromcompany Third party
  50. * @param Translate $langs Output language
  51. * @return void
  52. */
  53. function html_print_stripe_footer($fromcompany, $langs)
  54. {
  55. global $conf;
  56. // Juridical status
  57. $line1 = "";
  58. if ($fromcompany->forme_juridique_code) {
  59. $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
  60. }
  61. // Capital
  62. if ($fromcompany->capital) {
  63. $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
  64. }
  65. $reg = array();
  66. // Prof Id 1
  67. if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
  68. $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
  69. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  70. $field = $reg[1];
  71. }
  72. $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
  73. }
  74. // Prof Id 2
  75. if ($fromcompany->idprof2) {
  76. $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
  77. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  78. $field = $reg[1];
  79. }
  80. $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
  81. }
  82. // Second line of company infos
  83. $line2 = "";
  84. // Prof Id 3
  85. if ($fromcompany->idprof3) {
  86. $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
  87. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  88. $field = $reg[1];
  89. }
  90. $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
  91. }
  92. // Prof Id 4
  93. if ($fromcompany->idprof4) {
  94. $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
  95. if (preg_match('/\((.*)\)/i', $field, $reg)) {
  96. $field = $reg[1];
  97. }
  98. $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
  99. }
  100. // IntraCommunautary VAT
  101. if ($fromcompany->tva_intra != '') {
  102. $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
  103. }
  104. print '<br><br><hr>'."\n";
  105. print '<div class="center"><span style="font-size: 10px;">'."\n";
  106. print $fromcompany->name.'<br>';
  107. print $line1.'<br>';
  108. print $line2;
  109. print '</span></div>'."\n";
  110. }