dolibarr 22.0.5
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
40{
46 public function __construct($db)
47 {
48 global $conf, $user; // Required by some include code
49
50 $this->db = $db;
51
52 // Id for module (must be unique).
53 // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
54 $this->numero = SUBTOTALS_SPECIAL_CODE;
55 // Key text used to identify module (for permissions, menus, etc...)
56 $this->rights_class = 'subtotals';
57
58 // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
59 // It is used to group modules in module setup page
60 $this->family = "technic";
61 $this->module_position = '42';
62 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
63 $this->name = preg_replace('/^mod/i', '', get_class($this));
64 // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
65 $this->description = "Subtotal and title lines for certain documents";
66 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
67 $this->version = 'experimental';
68 // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
69 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
70 // Name of image file used for this module.
71 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
72 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
73 $this->picto = 'donation';
74
75 // Data directories to create when module is enabled.
76 // Example: this->dirs = array("/mymodule/temp");
77 $this->dirs = array("/subtotals/temp");
78 $r = 0;
79
80 // Config pages
81 $this->config_page_url = array("subtotals.php");
82
83 // Dependencies
84 $this->hidden = false; // A condition to hide module
85 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
86 $this->requiredby = array(); // List of module ids to disable if this one is disabled
87 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
88 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
89 $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
90 $this->langfiles = array("subtotals");
91
92 // Constants
93 // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
94 // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
95 $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
96 $r = 0;
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 $r = 0;
105
106 // Add here list of php file(s) stored in includes/boxes that contains class to show a box.
107 // Example:
108 //$this->boxes[$r][1] = "myboxa.php";
109 //$r++;
110 //$this->boxes[$r][1] = "myboxb.php";
111 //$r++;
112
113 // Permissions
114 $this->rights = array(); // Permission array used by this module
115 $r = 0;
116
117 // Menus
118 //-------
119 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
120
121 $this->module_parts = array('substitutions' => 1);
122
123 // Exports
124 $r = 0;
125 }
126
135 public function init($options = '')
136 {
137 global $conf;
138
139 // Permissions
140 $this->remove($options);
141
142 //ODT template
143 /*$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/holiday/template_holiday.odt';
144 $dirodt=DOL_DATA_ROOT.'/doctemplates/holiday';
145 $dest=$dirodt.'/template_order.odt';
146
147 if (file_exists($src) && ! file_exists($dest))
148 {
149 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
150 dol_mkdir($dirodt);
151 $result=dol_copy($src, $dest, 0, 0);
152 if ($result < 0)
153 {
154 $langs->load("errors");
155 $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
156 return 0;
157 }
158 }
159 */
160
161 $sql = array(
162 // "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".((int) $conf->entity),
163 // "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".((int) $conf->entity).")"
164 );
165
166 return $this->_init($sql, $options);
167 }
168}
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161