PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/modules/modService.class.php

https://github.com/asterix14/dolibarr
PHP | 161 lines | 77 code | 30 blank | 54 comment | 2 complexity | 6c5d5aae12135753f813200760ff51ca MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  5. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  6. * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
  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 2 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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * \defgroup service Module services
  24. * \brief Module pour gerer le suivi de services predefinis
  25. * \file htdocs/core/modules/modService.class.php
  26. * \ingroup service
  27. * \brief Fichier de description et activation du module Service
  28. */
  29. include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
  30. /** \class modService
  31. * \brief Classe de description et activation du module Service
  32. */
  33. class modService extends DolibarrModules
  34. {
  35. /**
  36. * Constructor. Define names, constants, directories, boxes, permissions
  37. *
  38. * @param DoliDB $DB Database handler
  39. */
  40. function modService($DB)
  41. {
  42. global $conf;
  43. $this->db = $DB ;
  44. $this->numero = 53 ;
  45. $this->family = "products";
  46. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  47. $this->name = preg_replace('/^mod/i','',get_class($this));
  48. $this->description = "Gestion des services";
  49. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  50. $this->version = 'dolibarr';
  51. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  52. $this->special = 0;
  53. $this->picto='service';
  54. // Data directories to create when module is enabled
  55. $this->dirs = array("/produit/temp");
  56. // Dependancies
  57. $this->depends = array();
  58. $this->requiredby = array("modContrat");
  59. // Config pages
  60. $this->config_page_url = array("produit.php@product");
  61. $this->langfiles = array("products","companies","bills");
  62. // Constants
  63. $this->const = array();
  64. // Boxes
  65. $this->boxes = array();
  66. $this->boxes[0][1] = "box_services_vendus.php";
  67. // Permissions
  68. $this->rights = array();
  69. $this->rights_class = 'service';
  70. $r=0;
  71. $this->rights[$r][0] = 531; // id de la permission
  72. $this->rights[$r][1] = 'Lire les services'; // libelle de la permission
  73. $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
  74. $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
  75. $this->rights[$r][4] = 'lire';
  76. $r++;
  77. $this->rights[$r][0] = 532; // id de la permission
  78. $this->rights[$r][1] = 'Creer/modifier les services'; // libelle de la permission
  79. $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
  80. $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
  81. $this->rights[$r][4] = 'creer';
  82. $r++;
  83. $this->rights[$r][0] = 534; // id de la permission
  84. $this->rights[$r][1] = 'Supprimer les services'; // libelle de la permission
  85. $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
  86. $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
  87. $this->rights[$r][4] = 'supprimer';
  88. $r++;
  89. $this->rights[$r][0] = 538; // Must be same permission than in product module
  90. $this->rights[$r][1] = 'Exporter les services';
  91. $this->rights[$r][2] = 'r';
  92. $this->rights[$r][3] = 0;
  93. $this->rights[$r][4] = 'export';
  94. $r++;
  95. // Exports
  96. //--------
  97. $r=0;
  98. $r++;
  99. $this->export_code[$r]=$this->rights_class.'_'.$r;
  100. $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found)
  101. $this->export_permission[$r]=array(array("service","export"));
  102. $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
  103. if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge ($this->export_fields_array[$r],array('p.stock'=>'Stock'));
  104. $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service");
  105. if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge ($this->export_entities_array[$r],array('p.stock'=>'product'));
  106. $this->export_sql_start[$r]='SELECT DISTINCT ';
  107. $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p';
  108. $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity = '.$conf->entity;
  109. }
  110. /**
  111. * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module.
  112. * Definit egalement les repertoires de donnees a creer pour ce module.
  113. */
  114. function init()
  115. {
  116. // Permissions et valeurs par defaut
  117. $this->remove();
  118. $sql = array();
  119. return $this->_init($sql);
  120. }
  121. /**
  122. * \brief Fonction appelee lors de la desactivation d'un module.
  123. * Supprime de la base les constantes, boites et permissions du module.
  124. */
  125. function remove()
  126. {
  127. $sql = array();
  128. return $this->_remove($sql);
  129. }
  130. }
  131. ?>