dolibarr 25.0.0-alpha
modFicheinter.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2009 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-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2026 Charlene Benke <charlene@patas-monkey.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';
34
35
40{
46 public function __construct($db)
47 {
48 global $conf;
49
50 $this->db = $db;
51 $this->numero = 70;
52
53 $this->family = "crm";
54 $this->module_position = '41';
55 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56 $this->name = preg_replace('/^mod/i', '', get_class($this));
57 $this->description = "Gestion des fiches d'intervention";
58
59 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
60 $this->version = 'dolibarr';
61
62 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
63 $this->picto = "intervention";
64
65 // Data directories to create when module is enabled
66 $this->dirs = array("/ficheinter/temp");
67
68 // Dependencies
69 $this->depends = array("modSociete");
70 $this->requiredby = array();
71 $this->conflictwith = array();
72 $this->langfiles = array("bills", "companies", "interventions");
73
74 // Config pages
75 $this->config_page_url = array("fichinter.php");
76
77 if (!isset($conf->ficheinter) || !isset($conf->ficheinter->enabled)) {
78 $conf->ficheinter = new stdClass();
79 $conf->ficheinter->enabled = 0;
80 }
81
82 // Constants
83 // 0:name
84 // 1:type
85 // 2:val
86 // 3:note
87 // 4:visible
88 // 5:entity
89 // 6:deleteonunactive
90 $this->const = [
91 [
92 "FICHEINTER_ADDON_PDF",
93 "chaine",
94 "soleil",
95 "",
96 0,
97 ],
98 [
99 "FICHEINTER_ADDON",
100 "chaine",
101 "pacific",
102 "",
103 0,
104 ],
105 ];
106
107 // Boxes
108 $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home'));
109
110 // Permissions
111 $this->rights = array();
112 $this->rights_class = 'ficheinter';
113 $r = 0;
114
115 $r++;
116 $this->rights[$r][0] = 61;
117 $this->rights[$r][1] = 'Lire les fiches d\'intervention';
118 $this->rights[$r][2] = 'r';
119 $this->rights[$r][3] = 0;
120 $this->rights[$r][4] = 'lire';
121
122 $r++;
123 $this->rights[$r][0] = 62;
124 $this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention';
125 $this->rights[$r][2] = 'w';
126 $this->rights[$r][3] = 0;
127 $this->rights[$r][4] = 'creer';
128
129 $r++;
130 $this->rights[$r][0] = 64;
131 $this->rights[$r][1] = 'Supprimer les fiches d\'intervention';
132 $this->rights[$r][2] = 'd';
133 $this->rights[$r][3] = 0;
134 $this->rights[$r][4] = 'supprimer';
135
136 $r++;
137 $this->rights[$r][0] = 67;
138 $this->rights[$r][1] = 'Exporter les fiches interventions';
139 $this->rights[$r][2] = 'r';
140 $this->rights[$r][3] = 0;
141 $this->rights[$r][4] = 'export';
142
143 $r++;
144 $this->rights[$r][0] = 68;
145 $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel';
146 $this->rights[$r][2] = 'r';
147 $this->rights[$r][3] = 0;
148 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
149 $this->rights[$r][5] = 'send';
150
151 $r++;
152 $this->rights[$r][0] = 69;
153 $this->rights[$r][1] = 'Valider les fiches d\'intervention ';
154 $this->rights[$r][2] = 'a';
155 $this->rights[$r][3] = 0;
156 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
157 $this->rights[$r][5] = 'validate';
158
159 $r++;
160 $this->rights[$r][0] = 70;
161 $this->rights[$r][1] = 'Dévalider les fiches d\'intervention';
162 $this->rights[$r][2] = 'a';
163 $this->rights[$r][3] = 0;
164 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
165 $this->rights[$r][5] = 'unvalidate';
166
167
168 // Menus
169 //-------
170 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
171
172
173 //Exports
174 //--------
175 $r = 1;
176
177 $this->export_code[$r] = $this->rights_class.'_'.$r;
178 $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
179 $this->export_permission[$r] = array(array("ficheinter", "export"));
180 $this->export_fields_array[$r] = array(
181 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country', 's.phone'=>'Phone',
182 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
183 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'f.rowid'=>"InterId", 'f.ref'=>"InterRef", 'f.datec'=>"InterDateCreation",
184 'f.duree'=>"InterDuration", 'f.fk_statut'=>'InterStatus', 'f.description'=>"InterNote");
185 $keyforselect = 'fichinter';
186 $keyforelement = 'intervention';
187 $keyforaliasextra = 'extra';
188 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
189 $this->export_fields_array[$r] += array(
190 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel',
191 'fd.rowid'=>'InterLineId',
192 'fd.date'=>"InterLineDate", 'fd.duree'=>"InterLineDuration", 'fd.description'=>"InterLineDesc"
193 );
194 $this->export_TypeFields_array[$r] = array(
195 's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', 's.phone'=>'Text', 's.siren'=>'Text',
196 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text',
197 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date",
198 'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Text",
199 'pj.ref'=>'Text', 'pj.title'=>'Text',
200 'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric"
201 );
202 $this->export_entities_array[$r] = array(
203 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company',
204 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company',
205 's.code_compta_fournisseur'=>'company', 'f.rowid'=>"intervention", 'f.ref'=>"intervention", 'f.datec'=>"intervention", 'f.duree'=>"intervention",
206 'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line",
207 'fd.duree'=>'inter_line', 'fd.description'=>'inter_line'
208 );
209 $this->export_dependencies_array[$r] = array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
210 $keyforselect = 'fichinterdet';
211 $keyforelement = 'inter_line';
212 $keyforaliasextra = 'extradet';
213 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
214
215 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
216 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'fichinter as f';
217 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object';
218 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
219 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter';
220 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,';
221 $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
222 $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
223 $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')';
224 $r++;
225 }
226
227
236 public function init($options = '')
237 {
238 global $conf;
239
240 $result = $this->_load_tables('/install/mysql/', 'fichinter');
241 if ($result < 0) {
242 return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
243 }
244
245 // Permissions
246 $this->remove($options);
247
248 $sql = array(
249 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".((int) $conf->entity),
250 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".((int) $conf->entity).")",
251 );
252
253 return $this->_init($sql, $options);
254 }
255}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to describe and enable module Ficheinter.
__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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133