dolibarr 24.0.0-beta
modSubtotals.class.php
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
6 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 * or see https://www.gnu.org/
23 */
24
33include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
34require_once DOL_DOCUMENT_ROOT.'/subtotals/class/commonsubtotal.class.php';
35
36if (!defined('SUBTOTALS_SPECIAL_CODE')) {
37 define('SUBTOTALS_SPECIAL_CODE', 81);
38}
39
44{
50 public function __construct($db)
51 {
52 $this->db = $db;
53
54 // Id for module (must be unique).
55 // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
56 $this->numero = SUBTOTALS_SPECIAL_CODE;
57 // Key text used to identify module (for permissions, menus, etc...)
58 $this->rights_class = 'subtotals';
59
60 // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
61 // It is used to group modules in module setup page
62 $this->family = "technic";
63 $this->module_position = '42';
64 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
65 $this->name = preg_replace('/^mod/i', '', get_class($this));
66 // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
67 $this->description = "SubTotalModuleDesc";
68 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
69 $this->version = 'dolibarr';
70 // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
71 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
72 // Name of image file used for this module.
73 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
74 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
75 $this->picto = 'donation';
76
77 // Data directories to create when module is enabled.
78 // Example: this->dirs = array("/mymodule/temp");
79 $this->dirs = array("/subtotals/temp");
80
81 // Config pages
82 $this->config_page_url = array("subtotals.php");
83
84 // Dependencies
85 $this->hidden = false; // A condition to hide module
86 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
87 $this->requiredby = array(); // List of module ids to disable if this one is disabled
88 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
89 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
90 $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
91 $this->langfiles = array("subtotals");
92
93 // Constants
94 // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
95 // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
96 $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
97
98 // Array to add new pages in new tabs
99 //$this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // We avoid to get one tab for each module. RH data are already in RH tab.
100 $this->tabs[] = array(); // To add a new tab identified by code tabname1
101
102 // Boxes
103 $this->boxes = array(); // List of boxes
104
105 // Permissions
106 $this->rights = array(); // Permission array used by this module
107
108 // Menus
109 //-------
110 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
111
112 $this->module_parts = array('substitutions' => 1);
113 }
114
123 public function init($options = '')
124 {
125 // Permissions
126 $this->remove($options);
127
128 $sql = array(
129 // "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".((int) $conf->entity),
130 // "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".((int) $conf->entity).")"
131 );
132
133 return $this->_init($sql, $options);
134 }
135}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Description and activation class for module subtotals.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133