modStripe.class.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. * Copyright (C) 2017 Saasprov <saasprov@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \defgroup stripe Module stripe
  20. * \brief Add integration with Stripe online payment system.
  21. * \file htdocs/core/modules/modStripe.class.php
  22. * \ingroup stripe
  23. * \brief Description and activation file for the module Stripe
  24. */
  25. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  26. /**
  27. * Description and activation class for module Paybox
  28. */
  29. class modStripe extends DolibarrModules
  30. {
  31. /**
  32. * Constructor. Define names, constants, directories, boxes, permissions
  33. *
  34. * @param DoliDB $db Database handler
  35. */
  36. public function __construct($db)
  37. {
  38. $this->db = $db;
  39. // Id for module (must be unique).
  40. // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
  41. $this->numero = 50300;
  42. // Key text used to identify module (for permissions, menus, etc...)
  43. $this->rights_class = 'stripe';
  44. // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
  45. // It is used to group modules in module setup page
  46. $this->family = "interface";
  47. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  48. $this->name = preg_replace('/^mod/i', '', get_class($this));
  49. // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
  50. $this->description = "Module to offer an online payment page by credit card with Stripe";
  51. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  52. $this->version = 'dolibarr';
  53. // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
  54. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  55. // Name of image file used for this module.
  56. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
  57. // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png'
  58. $this->picto = 'stripe';
  59. // Data directories to create when module is enabled.
  60. $this->dirs = array();
  61. // Config pages. Put here list of php page names stored in admin directory used to setup module.
  62. $this->config_page_url = array("stripe.php@stripe");
  63. // Dependencies
  64. $this->hidden = false; // A condition to hide module
  65. $this->depends = array(); // List of modules id that must be enabled if this module is enabled
  66. $this->requiredby = array(); // List of modules id to disable if this one is disabled
  67. $this->phpmin = array(5, 6); // Minimum version of PHP required by module
  68. $this->need_dolibarr_version = array(5, 0); // Minimum version of Dolibarr required by module
  69. $this->langfiles = array("stripe");
  70. // Constants
  71. $this->const = array(); // List of particular constants to add when module is enabled
  72. // New pages on tabs
  73. $this->tabs = array();
  74. // List of boxes
  75. $this->boxes = array();
  76. $r = 0;
  77. // Permissions
  78. $this->rights = array(); // Permission array used by this module
  79. $r = 0;
  80. // Main menu entries
  81. $r = 0;
  82. /* $this->menu[$r]=array(
  83. 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  84. 'mainmenu'=>'billing',
  85. 'leftmenu'=>'customers_bills_payment_stripe',
  86. 'type'=>'left', // This is a Left menu entry
  87. 'titre'=>'StripeImportPayment',
  88. 'url'=>'/stripe/importpayments.php',
  89. 'langs'=>'stripe', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  90. 'position'=>500,
  91. 'enabled'=>'$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  92. 'perms'=>'$user->rights->banque->modifier', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
  93. 'target'=>'',
  94. 'user'=>2
  95. ); // 0=Menu for internal users, 1=external users, 2=both
  96. $r++;*/
  97. $this->menu[$r] = array(
  98. 'fk_menu'=>'fk_mainmenu=bank',
  99. 'type'=>'left',
  100. 'titre'=>'StripeAccount',
  101. 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
  102. 'mainmenu'=>'bank',
  103. 'leftmenu'=>'stripe',
  104. 'url' => '',
  105. 'langs' => 'stripe',
  106. 'position' => 100,
  107. 'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
  108. 'perms' => '$user->rights->banque->lire',
  109. 'target' => '',
  110. 'user' => 0
  111. );
  112. $r++;
  113. $this->menu[$r] = array(
  114. 'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
  115. 'type' => 'left',
  116. 'titre' => 'StripeChargeList',
  117. 'url' => '/stripe/charge.php',
  118. 'langs' => 'stripe',
  119. 'position' => 102,
  120. 'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
  121. 'perms' => '$user->rights->banque->lire',
  122. 'target' => '',
  123. 'user' => 0
  124. );
  125. $r++;
  126. $this->menu[$r] = array(
  127. 'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
  128. 'type' => 'left',
  129. 'titre' => 'StripeTransactionList',
  130. 'url' => '/stripe/transaction.php',
  131. 'langs' => 'stripe',
  132. 'position' => 102,
  133. 'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
  134. 'perms' => '$user->rights->banque->lire',
  135. 'target' => '',
  136. 'user' => 0
  137. );
  138. $r++;
  139. $this->menu[$r] = array(
  140. 'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
  141. 'type' => 'left',
  142. 'titre' => 'StripePayoutList',
  143. 'url' => '/stripe/payout.php',
  144. 'langs' => 'stripe',
  145. 'position' => 103,
  146. 'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 1',
  147. 'perms' => '$user->rights->banque->lire',
  148. 'target' => '',
  149. 'user' => 0
  150. );
  151. // Exports
  152. $r = 1;
  153. }
  154. }