dolibarr 23.0.4
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 *
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 3 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 <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
31include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
32
33
38{
44 public function __construct($db)
45 {
46 global $conf;
47
48 $this->db = $db;
49 $this->numero = 70;
50
51 $this->family = "crm";
52 $this->module_position = '41';
53 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
54 $this->name = preg_replace('/^mod/i', '', get_class($this));
55 $this->description = "Gestion des fiches d'intervention";
56
57 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
58 $this->version = 'dolibarr';
59
60 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
61 $this->picto = "intervention";
62
63 // Data directories to create when module is enabled
64 $this->dirs = array("/ficheinter/temp");
65
66 // Dependencies
67 $this->depends = array("modSociete");
68 $this->requiredby = array();
69 $this->conflictwith = array();
70 $this->langfiles = array("bills", "companies", "interventions");
71
72 // Config pages
73 $this->config_page_url = array("fichinter.php");
74
75 if (!isset($conf->ficheinter) || !isset($conf->ficheinter->enabled)) {
76 $conf->ficheinter = new stdClass();
77 $conf->ficheinter->enabled = 0;
78 }
79
80 // Constants
81 // 0:name
82 // 1:type
83 // 2:val
84 // 3:note
85 // 4:visible
86 // 5:entity
87 // 6:deleteonunactive
88 $this->const = [
89 [
90 "FICHEINTER_ADDON_PDF",
91 "chaine",
92 "soleil",
93 "",
94 0,
95 ],
96 [
97 "FICHEINTER_ADDON",
98 "chaine",
99 "pacific",
100 "",
101 0,
102 ],
103 ];
104
105 // Boxes
106 $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home'));
107
108 // Permissions
109 $this->rights = array();
110 $this->rights_class = 'ficheinter';
111 $r = 0;
112
113 $r++;
114 $this->rights[$r][0] = 61;
115 $this->rights[$r][1] = 'Lire les fiches d\'intervention';
116 $this->rights[$r][2] = 'r';
117 $this->rights[$r][3] = 0;
118 $this->rights[$r][4] = 'lire';
119
120 $r++;
121 $this->rights[$r][0] = 62;
122 $this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention';
123 $this->rights[$r][2] = 'w';
124 $this->rights[$r][3] = 0;
125 $this->rights[$r][4] = 'creer';
126
127 $r++;
128 $this->rights[$r][0] = 64;
129 $this->rights[$r][1] = 'Supprimer les fiches d\'intervention';
130 $this->rights[$r][2] = 'd';
131 $this->rights[$r][3] = 0;
132 $this->rights[$r][4] = 'supprimer';
133
134 $r++;
135 $this->rights[$r][0] = 67;
136 $this->rights[$r][1] = 'Exporter les fiches interventions';
137 $this->rights[$r][2] = 'r';
138 $this->rights[$r][3] = 0;
139 $this->rights[$r][4] = 'export';
140
141 $r++;
142 $this->rights[$r][0] = 68;
143 $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel';
144 $this->rights[$r][2] = 'r';
145 $this->rights[$r][3] = 0;
146 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
147 $this->rights[$r][5] = 'send';
148
149 $r++;
150 $this->rights[$r][0] = 69;
151 $this->rights[$r][1] = 'Valider les fiches d\'intervention ';
152 $this->rights[$r][2] = 'a';
153 $this->rights[$r][3] = 0;
154 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
155 $this->rights[$r][5] = 'validate';
156
157 $r++;
158 $this->rights[$r][0] = 70;
159 $this->rights[$r][1] = 'Dévalider les fiches d\'intervention';
160 $this->rights[$r][2] = 'a';
161 $this->rights[$r][3] = 0;
162 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
163 $this->rights[$r][5] = 'unvalidate';
164
165
166 // Menus
167 //-------
168 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
169
170
171 //Exports
172 //--------
173 $r = 1;
174
175 $this->export_code[$r] = $this->rights_class.'_'.$r;
176 $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
177 $this->export_permission[$r] = array(array("ficheinter", "export"));
178 $this->export_fields_array[$r] = array(
179 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country', 's.phone'=>'Phone',
180 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
181 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'f.rowid'=>"InterId", 'f.ref'=>"InterRef", 'f.datec'=>"InterDateCreation",
182 'f.duree'=>"InterDuration", 'f.fk_statut'=>'InterStatus', 'f.description'=>"InterNote");
183 $keyforselect = 'fichinter';
184 $keyforelement = 'intervention';
185 $keyforaliasextra = 'extra';
186 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
187 $this->export_fields_array[$r] += array(
188 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel',
189 'fd.rowid'=>'InterLineId',
190 'fd.date'=>"InterLineDate", 'fd.duree'=>"InterLineDuration", 'fd.description'=>"InterLineDesc"
191 );
192 $this->export_TypeFields_array[$r] = array(
193 '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',
194 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text',
195 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date",
196 'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Text",
197 'pj.ref'=>'Text', 'pj.title'=>'Text',
198 'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric"
199 );
200 $this->export_entities_array[$r] = array(
201 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company',
202 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company',
203 's.code_compta_fournisseur'=>'company', 'f.rowid'=>"intervention", 'f.ref'=>"intervention", 'f.datec'=>"intervention", 'f.duree'=>"intervention",
204 'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line",
205 'fd.duree'=>'inter_line', 'fd.description'=>'inter_line'
206 );
207 $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
208 $keyforselect = 'fichinterdet';
209 $keyforelement = 'inter_line';
210 $keyforaliasextra = 'extradet';
211 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
212
213 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
214 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'fichinter as f';
215 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object';
216 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
217 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter';
218 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,';
219 $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
220 $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
221 $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')';
222 $r++;
223 }
224
225
234 public function init($options = '')
235 {
236 global $conf;
237
238 // Permissions
239 $this->remove($options);
240
241 $sql = array(
242 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".((int) $conf->entity),
243 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".((int) $conf->entity).")",
244 );
245
246 return $this->_init($sql, $options);
247 }
248}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a 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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:128