Passed
Push — master ( 0f9140...c4489d )
by Alxarafe
22:27
created

htdocs/core/modules/modFicheinter.class.php (1 issue)

1
<?php
2
/* Copyright (C) 2003      Rodolphe Quiedeville <[email protected]>
3
 * Copyright (C) 2004-2009 Laurent Destailleur  <[email protected]>
4
 * Copyright (C) 2004      Sebastien Di Cintio  <[email protected]>
5
 * Copyright (C) 2004      Benoit Mortier       <[email protected]>
6
 * Copyright (C) 2005-2012 Regis Houssin        <[email protected]>
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 <http://www.gnu.org/licenses/>.
20
 * or see http://www.gnu.org/
21
 */
22
23
/**
24
 *	\defgroup   ficheinter     Module Interventions
25
 *	\brief      Module to manage intervention cards
26
 *	\file       htdocs/core/modules/modFicheinter.class.php
27
 *	\ingroup    ficheinter
28
 *	\brief      Fichier de description et activation du module Ficheinter
29
 */
30
31
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
32
33
34
/**
35
 *	Class to describe and enable module Ficheinter
36
 */
37
class modFicheinter extends DolibarrModules
38
{
39
40
    /**
41
	 *   Constructor. Define names, constants, directories, boxes, permissions
42
	 *
43
	 *   @param      DoliDB		$db      Database handler
44
     */
45
    function __construct($db)
46
    {
47
        global $conf;
48
49
        $this->db = $db;
50
        $this->numero = 70;
51
52
        $this->family = "crm";
53
        $this->module_position = '45';
54
        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55
        $this->name = preg_replace('/^mod/i','',get_class($this));
56
        $this->description = "Gestion des fiches d'intervention";
57
58
        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59
        $this->version = 'dolibarr';
60
61
        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62
        $this->picto = "intervention";
63
64
        // Data directories to create when module is enabled
65
        $this->dirs = array("/ficheinter/temp");
66
67
        // Dependencies
68
        $this->depends = array("modSociete");
69
        $this->requiredby = array();
70
        $this->conflictwith = array();
71
        $this->langfiles = array("bills","companies","interventions");
72
73
        // Config pages
74
        $this->config_page_url = array("fichinter.php");
75
76
        // Constants
77
        $this->const = array();
78
        $r=0;
79
80
        $this->const[$r][0] = "FICHEINTER_ADDON_PDF";
81
        $this->const[$r][1] = "chaine";
82
        $this->const[$r][2] = "soleil";
83
        $r++;
84
85
        $this->const[$r][0] = "FICHEINTER_ADDON";
86
        $this->const[$r][1] = "chaine";
87
        $this->const[$r][2] = "pacific";
88
        $r++;
89
90
        // Boxes
91
        $this->boxes = array(0=>array('file'=>'box_ficheinter.php','enabledbydefaulton'=>'Home'));
92
93
        // Permissions
94
        $this->rights = array();
95
        $this->rights_class = 'ficheinter';
96
        $r=0;
97
98
        $r++;
99
        $this->rights[$r][0] = 61;
100
        $this->rights[$r][1] = 'Lire les fiches d\'intervention';
101
        $this->rights[$r][2] = 'r';
102
        $this->rights[$r][3] = 0;
103
        $this->rights[$r][4] = 'lire';
104
105
        $r++;
106
        $this->rights[$r][0] = 62;
107
        $this->rights[$r][1] = 'Creer/modifier les fiches d\'intervention';
108
        $this->rights[$r][2] = 'w';
109
        $this->rights[$r][3] = 0;
110
        $this->rights[$r][4] = 'creer';
111
112
        $r++;
113
        $this->rights[$r][0] = 64;
114
        $this->rights[$r][1] = 'Supprimer les fiches d\'intervention';
115
        $this->rights[$r][2] = 'd';
116
        $this->rights[$r][3] = 0;
117
        $this->rights[$r][4] = 'supprimer';
118
119
        $r++;
120
        $this->rights[$r][0] = 67;
121
        $this->rights[$r][1] = 'Exporter les fiches interventions';
122
        $this->rights[$r][2] = 'r';
123
        $this->rights[$r][3] = 0;
124
        $this->rights[$r][4] = 'export';
125
126
        $r++;
127
        $this->rights[$r][0] = 68;
128
        $this->rights[$r][1] = 'Envoyer les fiches d\'intervention par courriel';
129
        $this->rights[$r][2] = 'r';
130
        $this->rights[$r][3] = 0;
131
        $this->rights[$r][4] = 'ficheinter_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
132
        $this->rights[$r][5] = 'send';
133
134
        $r++;
135
        $this->rights[$r][0] = 69;
136
        $this->rights[$r][1] = 'Valider les fiches d\'intervention ';
137
        $this->rights[$r][2] = 'a';
138
        $this->rights[$r][3] = 0;
139
        $this->rights[$r][4] = 'ficheinter_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
140
        $this->rights[$r][5] = 'validate';
141
142
        $r++;
143
        $this->rights[$r][0] = 70;
144
        $this->rights[$r][1] = 'Dévalider les fiches d\'intervention';
145
        $this->rights[$r][2] = 'a';
146
        $this->rights[$r][3] = 0;
147
        $this->rights[$r][4] = 'ficheinter_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
148
        $this->rights[$r][5] = 'unvalidate';
149
150
151
        // Menus
152
        //-------
153
        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
0 ignored issues
show
Documentation Bug introduced by
It seems like 1 of type integer is incompatible with the declared type array of property $menu.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
154
155
156
        //Exports
157
        //--------
158
        $r=1;
159
160
        $this->export_code[$r]=$this->rights_class.'_'.$r;
161
        $this->export_label[$r]='InterventionCardsAndInterventionLines';	// Translation key (used only if key ExportDataset_xxx_z not found)
162
        $this->export_permission[$r]=array(array("ficheinter","export"));
163
        $this->export_fields_array[$r]=array(
164
			's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone',
165
			's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
166
			's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation",
167
			'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote", 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'InterLineId',
168
			'fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc"
169
		);
170
        //$this->export_TypeFields_array[$r]=array(
171
		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
172
		//	's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text',
173
		//	's.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",
174
		//	'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",
175
		//	'fd.total_ht'=>"Numeric"
176
		//);
177
        $this->export_TypeFields_array[$r]=array(
178
			'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',
179
			's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",
180
			'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean", 'pj.ref'=>'Text',
181
			 'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric"
182
		);
183
        $this->export_entities_array[$r]=array(
184
			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company',
185
			's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company',
186
			's.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention",
187
			'f.fk_statut'=>"intervention",'f.description'=>"intervention", 'pj.ref'=>'project', 'fd.rowid'=>"inter_line",'fd.date'=>"inter_line",
188
			'fd.duree'=>'inter_line','fd.description'=>'inter_line'
189
		);
190
        $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
191
192
        $this->export_sql_start[$r]='SELECT DISTINCT ';
193
        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'fichinter as f';
194
        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
195
        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,';
196
        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
197
        $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
198
        $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention').')';
199
        $r++;
200
    }
201
202
203
    /**
204
	 *		Function called when module is enabled.
205
	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
206
	 *		It also creates data directories
207
	 *
208
     *      @param      string	$options    Options when enabling module ('', 'noboxes')
209
	 *      @return     int             	1 if OK, 0 if KO
210
     */
211
    function init($options='')
212
    {
213
        global $conf;
214
215
        // Permissions
216
        $this->remove($options);
217
218
        $sql = array(
219
			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'ficheinter' AND entity = ".$conf->entity,
220
			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','ficheinter',".$conf->entity.")",
221
        );
222
223
        return $this->_init($sql,$options);
224
    }
225
}
226