dolibarr 21.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 *
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 // Constants
76 $this->const = array();
77 $r = 0;
78
79 if (!isset($conf->ficheinter) || !isset($conf->ficheinter->enabled)) {
80 $conf->ficheinter = new stdClass();
81 $conf->ficheinter->enabled = 0;
82 }
83
84 $this->const[$r][0] = "FICHEINTER_ADDON_PDF";
85 $this->const[$r][1] = "chaine";
86 $this->const[$r][2] = "soleil";
87 $r++;
88
89 $this->const[$r][0] = "FICHEINTER_ADDON";
90 $this->const[$r][1] = "chaine";
91 $this->const[$r][2] = "pacific";
92 $r++;
93
94 // Boxes
95 $this->boxes = array(0=>array('file'=>'box_ficheinter.php', 'enabledbydefaulton'=>'Home'));
96
97 // Permissions
98 $this->rights = array();
99 $this->rights_class = 'ficheinter';
100 $r = 0;
101
102 $r++;
103 $this->rights[$r][0] = 61;
104 $this->rights[$r][1] = 'Lire les fiches d\'intervention';
105 $this->rights[$r][2] = 'r';
106 $this->rights[$r][3] = 0;
107 $this->rights[$r][4] = 'lire';
108
109 $r++;
110 $this->rights[$r][0] = 62;
111 $this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention';
112 $this->rights[$r][2] = 'w';
113 $this->rights[$r][3] = 0;
114 $this->rights[$r][4] = 'creer';
115
116 $r++;
117 $this->rights[$r][0] = 64;
118 $this->rights[$r][1] = 'Supprimer les fiches d\'intervention';
119 $this->rights[$r][2] = 'd';
120 $this->rights[$r][3] = 0;
121 $this->rights[$r][4] = 'supprimer';
122
123 $r++;
124 $this->rights[$r][0] = 67;
125 $this->rights[$r][1] = 'Exporter les fiches interventions';
126 $this->rights[$r][2] = 'r';
127 $this->rights[$r][3] = 0;
128 $this->rights[$r][4] = 'export';
129
130 $r++;
131 $this->rights[$r][0] = 68;
132 $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel';
133 $this->rights[$r][2] = 'r';
134 $this->rights[$r][3] = 0;
135 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
136 $this->rights[$r][5] = 'send';
137
138 $r++;
139 $this->rights[$r][0] = 69;
140 $this->rights[$r][1] = 'Valider les fiches d\'intervention ';
141 $this->rights[$r][2] = 'a';
142 $this->rights[$r][3] = 0;
143 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
144 $this->rights[$r][5] = 'validate';
145
146 $r++;
147 $this->rights[$r][0] = 70;
148 $this->rights[$r][1] = 'Dévalider les fiches d\'intervention';
149 $this->rights[$r][2] = 'a';
150 $this->rights[$r][3] = 0;
151 $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
152 $this->rights[$r][5] = 'unvalidate';
153
154
155 // Menus
156 //-------
157 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
158
159
160 //Exports
161 //--------
162 $r = 1;
163
164 $this->export_code[$r] = $this->rights_class.'_'.$r;
165 $this->export_label[$r] = 'InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
166 $this->export_permission[$r] = array(array("ficheinter", "export"));
167 $this->export_fields_array[$r] = array(
168 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country', 's.phone'=>'Phone',
169 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode',
170 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'f.rowid'=>"InterId", 'f.ref'=>"InterRef", 'f.datec'=>"InterDateCreation",
171 'f.duree'=>"InterDuration", 'f.fk_statut'=>'InterStatus', 'f.description'=>"InterNote");
172 $keyforselect = 'fichinter';
173 $keyforelement = 'intervention';
174 $keyforaliasextra = 'extra';
175 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
176 $this->export_fields_array[$r] += array(
177 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel',
178 'fd.rowid'=>'InterLineId',
179 'fd.date'=>"InterLineDate", 'fd.duree'=>"InterLineDuration", 'fd.description'=>"InterLineDesc"
180 );
181 $this->export_TypeFields_array[$r] = array(
182 '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',
183 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text',
184 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date",
185 'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Text",
186 'pj.ref'=>'Text', 'pj.title'=>'Text',
187 'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric"
188 );
189 $this->export_entities_array[$r] = array(
190 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company',
191 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company',
192 's.code_compta_fournisseur'=>'company', 'f.rowid'=>"intervention", 'f.ref'=>"intervention", 'f.datec'=>"intervention", 'f.duree'=>"intervention",
193 'f.fk_statut'=>"intervention", 'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line", 'fd.date'=>"inter_line",
194 'fd.duree'=>'inter_line', 'fd.description'=>'inter_line'
195 );
196 $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
197 $keyforselect = 'fichinterdet';
198 $keyforelement = 'inter_line';
199 $keyforaliasextra = 'extradet';
200 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
201
202 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
203 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'fichinter as f';
204 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object';
205 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
206 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter';
207 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,';
208 $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
209 $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
210 $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('intervention').')';
211 $r++;
212 }
213
214
223 public function init($options = '')
224 {
225 global $conf;
226
227 // Permissions
228 $this->remove($options);
229
230 $sql = array(
231 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".((int) $conf->entity),
232 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".((int) $conf->entity).")",
233 );
234
235 return $this->_init($sql, $options);
236 }
237}
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:142