modDon.class.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \defgroup don Module donations
  22. * \brief Module to manage the follow-up of the donations
  23. * \file htdocs/core/modules/modDon.class.php
  24. * \ingroup donations
  25. * \brief Description and activation file for module Donation
  26. */
  27. include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
  28. /**
  29. * Class to describe and enable module Donation
  30. */
  31. class modDon extends DolibarrModules
  32. {
  33. /**
  34. * Constructor. Define names, constants, directories, boxes, permissions
  35. *
  36. * @param DoliDB $db Database handler
  37. */
  38. function __construct($db)
  39. {
  40. $this->db = $db;
  41. $this->numero = 700;
  42. $this->family = "financial";
  43. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  44. $this->name = preg_replace('/^mod/i','',get_class($this));
  45. $this->description = "Gestion des dons";
  46. $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
  47. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  48. $this->special = 0;
  49. // Name of png file (without png) used for this module.
  50. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
  51. $this->picto='bill';
  52. // Data directories to create when module is enabled
  53. $this->dirs = array("/don/temp");
  54. // Dependancies
  55. $this->depends = array();
  56. $this->requiredby = array();
  57. // Config pages
  58. $this->config_page_url = array("donation.php@don");
  59. // Constants
  60. $this->const = array();
  61. $r=0;
  62. $this->const[$r][0] = "DON_ADDON_MODEL";
  63. $this->const[$r][1] = "chaine";
  64. $this->const[$r][2] = "html_cerfafr";
  65. $this->const[$r][3] = 'Nom du gestionnaire de generation de recu de dons';
  66. $this->const[$r][4] = 0;
  67. $r++;
  68. $this->const[$r][0] = "DONATION_ART200";
  69. $this->const[$r][1] = "yesno";
  70. $this->const[$r][2] = "0";
  71. $this->const[$r][3] = 'Option Française - Eligibilité Art200 du CGI';
  72. $this->const[$r][4] = 0;
  73. $r++;
  74. $this->const[$r][0] = "DONATION_ART238";
  75. $this->const[$r][1] = "yesno";
  76. $this->const[$r][2] = "0";
  77. $this->const[$r][3] = 'Option Française - Eligibilité Art238 bis du CGI';
  78. $this->const[$r][4] = 0;
  79. $r++;
  80. $this->const[$r][0] = "DONATION_ART885";
  81. $this->const[$r][1] = "yesno";
  82. $this->const[$r][2] = "0";
  83. $this->const[$r][3] = 'Option Française - Eligibilité Art885-0 V bis du CGI';
  84. $this->const[$r][4] = 0;
  85. $r++;
  86. $this->const[$r][0] = "DONATION_MESSAGE";
  87. $this->const[$r][1] = "chaine";
  88. $this->const[$r][2] = "Thank you";
  89. $this->const[$r][3] = 'Message affiché sur le récépissé de versements ou dons';
  90. $this->const[$r][4] = 0;
  91. $r++;
  92. $this->const[$r][0] = "DONATION_ACCOUNTINGACCOUNT";
  93. $this->const[$r][1] = "chaine";
  94. $this->const[$r][2] = "758";
  95. $this->const[$r][3] = 'Compte comptable de remise des versements ou dons';
  96. $this->const[$r][4] = 0;
  97. // Boxes
  98. $this->boxes = array();
  99. // Permissions
  100. $this->rights = array();
  101. $this->rights_class = 'don';
  102. $this->rights[1][0] = 701;
  103. $this->rights[1][1] = 'Lire les dons';
  104. $this->rights[1][2] = 'r';
  105. $this->rights[1][3] = 1;
  106. $this->rights[1][4] = 'lire';
  107. $this->rights[2][0] = 702;
  108. $this->rights[2][1] = 'Creer/modifier les dons';
  109. $this->rights[2][2] = 'w';
  110. $this->rights[2][3] = 0;
  111. $this->rights[2][4] = 'creer';
  112. $this->rights[3][0] = 703;
  113. $this->rights[3][1] = 'Supprimer les dons';
  114. $this->rights[3][2] = 'd';
  115. $this->rights[3][3] = 0;
  116. $this->rights[3][4] = 'supprimer';
  117. }
  118. /**
  119. * Function called when module is enabled.
  120. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  121. * It also creates data directories
  122. *
  123. * @param string $options Options when enabling module ('', 'noboxes')
  124. * @return int 1 if OK, 0 if KO
  125. */
  126. function init($options='')
  127. {
  128. global $conf;
  129. $sql = array(
  130. "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
  131. "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','donation',".$conf->entity.")",
  132. );
  133. return $this->_init($sql,$options);
  134. }
  135. }