Completed
Push — master ( 9746a1...09623d )
by Laurent
03:41 queued 37s
created

modFlightLog::__construct()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 180
Code Lines 116

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 116
nc 2
nop 1
dl 0
loc 180
rs 8.2857
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) 2003      Rodolphe Quiedeville <[email protected]>
3
 * Copyright (C) 2004-2015 Laurent Destailleur  <[email protected]>
4
 * Copyright (C) 2005-2016 Regis Houssin        <[email protected]>
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
/**
21
 *    \defgroup   mymodule     Module MyModule
22
 *  \brief      Example of a module descriptor.
23
 *                Such a file must be copied into htdocs/mymodule/core/modules directory.
24
 *  \file       htdocs/mymodule/core/modules/modMyModule.class.php
25
 *  \ingroup    mymodule
26
 *  \brief      Description and activation file for module MyModule
27
 */
28
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php';
29
30
31
/**
32
 *  Description and activation class for module MyModule
33
 */
34
class modFlightLog extends DolibarrModules
35
{
36
    const MENU_TYPE_LEFT = 'left';
37
    const MENU_TYPE_TOP = 'top';
38
39
    /**
40
     * @var array Indexed list of export IDs
41
     *
42
     */
43
    public $export_code = array();
44
45
    /**
46
     * @var array Indexed list of export names
47
     *
48
     */
49
    public $export_label = array();
50
51
    /**
52
     * @var array Indexed list of export enabling conditions
53
     *
54
     */
55
    public $export_enabled = array();
56
57
    /**
58
     * @var array Indexed list of export required permissions
59
     *
60
     */
61
    public $export_permission = array();
62
63
    /**
64
     * @var array Indexed list of export fields
65
     *
66
     */
67
    public $export_fields_array = array();
68
69
    /**
70
     * @var array Indexed list of export entities
71
     *
72
     */
73
    public $export_entities_array = array();
74
75
    /**
76
     * @var array Indexed list of export SQL queries start
77
     *
78
     */
79
    public $export_sql_start = array();
80
81
    /**
82
     * @var array Indexed list of export SQL queries end
83
     *
84
     */
85
    public $export_sql_end = array();
86
87
    public $export_TypeFields_array = [];
88
89
    /**
90
     * @var array
91
     */
92
    public $menus;
93
94
    /**
95
     * Constructor. Define names, constants, directories, boxes, permissions
96
     *
97
     * @param DoliDB $db Database handler
98
     */
99
    public function __construct($db)
100
    {
101
        global $langs, $conf;
102
103
        $this->db = $db;
104
105
        // Id for module (must be unique).
106
        $this->numero = 500000;
107
        // Key text used to identify module (for permissions, menus, etc...)
108
        $this->rights_class = 'flightLog';
109
110
        // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
111
        // It is used to group modules by family in module setup page
112
        $this->family = "Belgian Balloon Club";
113
        // Module position in the family
114
        $this->module_position = 500;
115
        // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
116
        //$this->familyinfo = array('myownfamily' => array('position' => '001', 'label' => $langs->trans("MyOwnFamily")));
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
117
118
        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
119
        $this->name = preg_replace('/^mod/i', '', get_class($this));
120
        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
121
        $this->description = "Pilots flight log";
122
        $this->descriptionlong = "Manage flights and flights type for the Belgian Balloon Club";
123
        $this->editor_name = 'De Coninck Laurent';
124
        $this->editor_url = 'http://www.dolibarr.org';
125
126
        // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
127
        $this->version = '1.0';
128
        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
129
        $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
130
        // Name of image file used for this module.
131
        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
132
        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
133
        $this->picto = 'flight@flightLog';
134
135
        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
136
        // for default path (eg: /mymodule/core/xxxxx) (0=disable, 1=enable)
137
        // for specific path of parts (eg: /mymodule/core/modules/barcode)
138
        // for specific css file (eg: /mymodule/css/mymodule.css.php)
139
        //$this->module_parts = array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
140
        //                        	'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
141
        //							'login' => 0,                                    	// Set this to 1 if module has its own login method directory (core/login)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
142
        //							'substitutions' => 0,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
143
        //							'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
144
        //							'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (theme)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
145
        //                        	'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
146
        //							'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
147
        //							'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
148
        //							'css' => array('/mymodule/css/mymodule.css.php'),	// Set this to relative path of css file if module has its own css file
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
149
        //							'js' => array('/mymodule/js/mymodule.js'),          // Set this to relative path of js file if module must load a js on all pages
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
150
        //							'hooks' => array('hookcontext1','hookcontext2',...) // Set here all hooks context managed by module. You can also set hook context 'all'
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
151
        //							'dir' => array('output' => 'othermodulename'),      // To force the default directories names
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
152
        //							'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule')) // Set here all workflow context managed by module
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
153
        //                        );
154
        $this->module_parts = array();
155
156
        // Data directories to create when module is enabled.
157
        $this->dirs = array();
158
159
        // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
160
        $this->config_page_url = array();
161
162
        // Dependencies
163
        $this->hidden = false;
164
        $this->depends = array('modFlightBalloon');
165
        $this->requiredby = array();
166
        $this->conflictwith = array();
167
        $this->phpmin = array(5, 5);
168
        $this->need_dolibarr_version = array(4, 0);
169
        $this->langfiles = array("mymodule@flightLog");
170
171
        // Constants
172
        $this->initConstants();
173
174
        // Array to add new pages in new tabs
175
        $this->tabs = [
176
            'user:+flights:Flights:mymodule@flightLog:$user->rights->flightLog->vol->access:/flightLog/list.php?search_fk_pilot=__ID__',
177
        ];
178
179
        if (!isset($conf->flightLog) || !isset($conf->flightLog->enabled)) {
180
            $conf->flightLog = new stdClass();
181
            $conf->flightLog->enabled = 0;
182
        }
183
184
        $this->boxes = [];
185
186
        $this->initDictionnaries();
187
        $this->initCronJobs();
188
        $this->initMenu();
189
        $this->initPermissions();
190
191
        // Exports
192
        $r = 0;
193
194
        $this->export_code[$r] = $this->rights_class . '_' . $r;
195
        $this->export_label[$r] = 'Flights export';
196
        $this->export_enabled[$r] = '1';
197
        $this->export_permission[$r] = array(array("flightLog", "vol", "detail"));
198
        $this->export_fields_array[$r] = array(
199
            "flight.idBBC_vols"                => "Identifiant",
200
            "flight.date"                      => "Date",
201
            "flight.lieuD"                     => "Lieu décollage ",
202
            "flight.lieuA"                     => "Lieu atterissage",
203
            "flight.heureD"                    => "Heure décollage",
204
            "flight.heureA"                    => "Heure atterissage",
205
            "flight.BBC_ballons_idBBC_ballons" => "Identifiant ballon",
206
            "flight.nbrPax"                    => "# pax",
207
            "flight.remarque"                  => "Remarque",
208
            "flight.incidents"                 => "Incidents",
209
            "flight.fk_type"                   => "Identifiant type",
210
            "flight.fk_pilot"                  => "Identifiant pilote",
211
            "flight.fk_organisateur"           => "Identifiant organisateur",
212
            "flight.is_facture"                => "Facture Oui/Non",
213
            "flight.kilometers"                => "# Km",
214
            "flight.cost"                      => "Cout",
215
            "flight.fk_receiver"               => "Identifiant receveur d'argent",
216
            "flight.justif_kilometers"         => "Justificatif kilomètres",
217
            "balloon.immat"                    => "Immat.",
218
            "pilot.login"                      => "Pilote",
219
            "flightType.nom"                   => "Type de vol",
220
            "organisator.login"                => "Organisateur",
221
            "receiver.login"                   => "Percepteur",
222
        );
223
224
        $this->export_TypeFields_array[$r] = [
225
            "flight.date"                      => "Date",
226
            "flight.lieuD"                     => "Text",
227
            "flight.lieuA"                     => "Text",
228
            "flight.heureD"                    => "Text",
229
            "flight.heureA"                    => "Text",
230
            "flight.BBC_ballons_idBBC_ballons" => implode(":", ["List", "bbc_ballons", "immat", "rowid"]),
231
            "flight.nbrPax"                    => "Numeric",
232
            "flight.remarque"                  => "Text",
233
            "flight.incidents"                 => "Text",
234
            "flight.fk_type"                   => implode(":", ["List", "bbc_types", "nom", "idType"]),
235
            "flight.fk_pilot"                  => implode(":", ["List", "user", "login", "rowid"]),
236
            "flight.fk_organisateur"           => implode(":", ["List", "user", "login", "rowid"]),
237
            "flight.is_facture"                => "Boolean",
238
            "flight.kilometers"                => "Numeric",
239
            "flight.cost"                      => "Numeric",
240
            "flight.fk_receiver"               => implode(":", ["List", "user", "login", "rowid"]),
241
            "flight.justif_kilometers"         => "Text",
242
        ];
243
244
        $this->export_entities_array[$r] = array(
245
            "flight.idBBC_vols"                => "Flight",
246
            "flight.date"                      => "Flight",
247
            "flight.lieuD"                     => "Flight",
248
            "flight.lieuA"                     => "Flight",
249
            "flight.heureD"                    => "Flight",
250
            "flight.heureA"                    => "Flight",
251
            "flight.BBC_ballons_idBBC_ballons" => "Flight",
252
            "flight.nbrPax"                    => "Flight",
253
            "flight.remarque"                  => "Flight",
254
            "flight.incidents"                 => "Flight",
255
            "flight.fk_type"                   => "Flight",
256
            "flight.fk_pilot"                  => "Flight",
257
            "flight.fk_organisateur"           => "Flight",
258
            "flight.is_facture"                => "Flight",
259
            "flight.kilometers"                => "Flight",
260
            "flight.cost"                      => "Flight",
261
            "flight.fk_receiver"               => "Flight",
262
            "flight.justif_kilometers"         => "Flight",
263
            "balloon.immat"                    => "Balloon",
264
            "pilot.login"                      => "Pilot",
265
            "flightType.nom"                   => "FlightType",
266
            "organisator.login"                => "Organisator",
267
            "receiver.login"                   => "Percepteur",
268
        );
269
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
270
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'bbc_vols as flight';
271
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bbc_ballons as balloon on (flight.BBC_ballons_idBBC_ballons = balloon.rowid)';
272
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bbc_types as flightType on (flight.fk_type = flightType.idType)';
273
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as pilot on (flight.fk_pilot = pilot.rowid)';
274
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as organisator on (flight.fk_organisateur = organisator.rowid)';
275
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as receiver on (flight.fk_receiver = receiver.rowid)';
276
        $this->export_sql_end[$r] .= ' WHERE 1 = 1';
277
        $r++;
278
    }
279
280
    /**
281
     *        Function called when module is enabled.
282
     *        The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
283
     *        It also creates data directories
284
     *
285
     * @param      string $options Options when enabling module ('', 'noboxes')
286
     *
287
     * @return     int                1 if OK, 0 if KO
288
     */
289
    public function init($options = '')
290
    {
291
        $sql = array();
292
293
        $this->_load_tables('/flightLog/sql/');
294
295
        return $this->_init($sql, $options);
296
    }
297
298
    /**
299
     * Function called when module is disabled.
300
     * Remove from database constants, boxes and permissions from Dolibarr database.
301
     * Data directories are not deleted
302
     *
303
     * @param      string $options Options when enabling module ('', 'noboxes')
304
     *
305
     * @return     int                1 if OK, 0 if KO
306
     */
307
    public function remove($options = '')
308
    {
309
        $sql = array();
310
311
        return $this->_remove($sql, $options);
312
    }
313
314
    /**
315
     * Init menu
316
     */
317
    private function initMenu()
318
    {
319
        $this->menus = array();
320
        $r = 0;
321
322
        $this->menu[$r] = array(
323
            'fk_menu'  => 'fk_mainmenu=flightLog',
324
            'type'     => self::MENU_TYPE_TOP,
325
            'titre'    => 'Carnet de vols',
326
            'mainmenu' => 'flightLog',
327
            'leftmenu' => 'readFlight',
328
            'url'      => '/flightLog/readFlights.php',
329
            'langs'    => 'mylangfile',
330
            'position' => 100,
331
            'enabled'  => '1',
332
            'perms'    => '$user->rights->flightLog->vol->access',
333
            'target'   => '',
334
            'user'     => 0
335
        );
336
        $r++;
337
338
        $this->menu[$r] = array(
339
            'fk_menu'  => 'fk_mainmenu=flightLog',
340
            'type'     => self::MENU_TYPE_LEFT,
341
            'titre'    => 'Ajouter un vol',
342
            'mainmenu' => 'flightLog',
343
            'leftmenu' => 'addFlight',
344
            'url'      => '/flightLog/addFlight.php',
345
            'langs'    => 'mylangfile',
346
            'position' => 101,
347
            'enabled'  => '1',
348
            'perms'    => '$user->rights->flightLog->vol->add',
349
            'target'   => '',
350
            'user'     => 2
351
        );
352
        $r++;
353
        $this->menu[$r] = array(
354
            'fk_menu'  => 'fk_mainmenu=flightLog',
355
            'type'     => self::MENU_TYPE_LEFT,
356
            'titre'    => 'Visualisation',
357
            'mainmenu' => 'flightLog',
358
            'leftmenu' => 'showFlight',
359
            'url'      => '/flightLog/readFlights.php',
360
            'langs'    => 'mylangfile',
361
            'position' => 102,
362
            'enabled'  => '1',
363
            'perms'    => '1',
364
            'target'   => '',
365
            'user'     => 2
366
        );
367
        $this->menu[$r] = array(
368
            'fk_menu'  => 'fk_mainmenu=flightLog',
369
            'type'     => self::MENU_TYPE_LEFT,
370
            'titre'    => 'Les vols',
371
            'mainmenu' => 'flightLog',
372
            'leftmenu' => 'flightLog',
373
            'url'      => '/flightLog/list.php',
374
            'langs'    => 'mylangfile',
375
            'position' => 105,
376
            'enabled'  => '1',
377
            'perms'    => '1',
378
            'target'   => '',
379
            'user'     => 2
380
        );
381
        $r++;
382
        $this->menu[$r] = array(
383
            'fk_menu'  => 'fk_mainmenu=flightLog',
384
            'type'     => self::MENU_TYPE_LEFT,
385
            'titre'    => 'Gestion',
386
            'mainmenu' => 'flightLog',
387
            'leftmenu' => 'management',
388
            'url'      => '',
389
            'langs'    => 'mylangfile',
390
            'position' => 106,
391
            'enabled'  => '1',
392
            'perms'    => '$user->rights->flightLog->vol->status||$user->rights->flightLog->vol->detail',
393
            'target'   => '',
394
            'user'     => 2
395
        );
396
        $r++;
397
        $this->menu[$r] = array(
398
            'fk_menu'  => 'fk_mainmenu=flightLog,fk_leftmenu=management',
399
            'type'     => self::MENU_TYPE_LEFT,
400
            'titre'    => 'Payement',
401
            'mainmenu' => 'flightLog',
402
            'leftmenu' => 'flightBilling',
403
            'url'      => '/flightLog/listFact.php?view=1',
404
            'langs'    => 'mylangfile',
405
            'position' => 107,
406
            'enabled'  => '1',
407
            'perms'    => '$user->rights->flightLog->vol->financial',
408
            'target'   => '',
409
            'user'     => 2
410
        );
411
        $r++;
412
        $this->menu[$r] = array(
413
            'fk_menu'  => 'fk_mainmenu=flightLog,fk_leftmenu=management',
414
            'type'     => self::MENU_TYPE_LEFT,
415
            'titre'    => 'Aviabel',
416
            'mainmenu' => 'flightLog',
417
            'leftmenu' => 'flightAviabel',
418
            'url'      => '/flightLog/listFact.php?view=2',
419
            'langs'    => 'mylangfile',
420
            'position' => 108,
421
            'enabled'  => '1',
422
            'perms'    => '$user->rights->flightLog->vol->detail',
423
            'target'   => '',
424
            'user'     => 2
425
        );
426
    }
427
428
    /**
429
     * Init permissions
430
     */
431
    private function initPermissions()
432
    {
433
        $this->rights = array();        // Permission array used by this module
434
        $r = 0;
435
436
        $this->rights[$r][0] = 9993;
437
        $this->rights[$r][1] = 'Permet d\'acceder au module des vols.';
438
        $this->rights[$r][3] = 0;
439
        $this->rights[$r][4] = 'vol';
440
        $this->rights[$r][5] = 'access';
441
        $r++;
442
443
        $this->rights[$r][0] = 9998;
444
        $this->rights[$r][1] = 'Enregistrer un nouveau vol.';
445
        $this->rights[$r][3] = 0;
446
        $this->rights[$r][4] = 'vol';
447
        $this->rights[$r][5] = 'add';
448
        $r++;
449
450
        $this->rights[$r][0] = 9997;
451
        $this->rights[$r][1] = 'Permet de facturer un vol.';
452
        $this->rights[$r][3] = 0;
453
        $this->rights[$r][4] = 'vol';
454
        $this->rights[$r][5] = 'status';
455
        $r++;
456
457
        $this->rights[$r][0] = 9996;
458
        $this->rights[$r][1] = 'Permet de supprimer un vol.';
459
        $this->rights[$r][3] = 0;
460
        $this->rights[$r][4] = 'vol';
461
        $this->rights[$r][5] = 'delete';
462
        $r++;
463
464
        $this->rights[$r][0] = 9995;
465
        $this->rights[$r][1] = 'Permet de modifier tous les vols.';
466
        $this->rights[$r][3] = 0;
467
        $this->rights[$r][4] = 'vol';
468
        $this->rights[$r][5] = 'edit';
469
        $r++;
470
471
        $this->rights[$r][0] = 9994;
472
        $this->rights[$r][1] = 'affiche les details de tous les ballons et de tous les pilotes.';
473
        $this->rights[$r][3] = 0;
474
        $this->rights[$r][4] = 'vol';
475
        $this->rights[$r][5] = 'detail';
476
        $r++;
477
478
        $this->rights[$r][0] = 9999;
479
        $this->rights[$r][1] = 'Gérer les aspects financier des vols';
480
        $this->rights[$r][3] = 0;
481
        $this->rights[$r][4] = 'vol';
482
        $this->rights[$r][5] = 'financial';
483
        $r++;
484
    }
485
486
    private function initCronJobs()
487
    {
488
        $this->cronjobs = array();            // List of cron jobs entries to add
489
        // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'test'=>true),
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
490
        //                                1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'test'=>true)
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
491
        // );
492
    }
493
494
    private function initDictionnaries()
495
    {
496
        $this->initFlightTypeDictionnary();
497
    }
498
499
    private function initFlightTypeDictionnary()
500
    {
501
        $this->dictionaries = array(
502
            'langs'          => 'mylangfile@mymodule',
503
            'tabname'        => array(MAIN_DB_PREFIX . "bbc_types"),
504
            'tablib'         => array("Types de vols"),
505
            'tabsql'         => array('SELECT f.idType, f.numero, f.nom, f.active FROM ' . MAIN_DB_PREFIX . 'bbc_types as f',),
506
            'tabsqlsort'     => array("numero ASC"),
507
            'tabfield'       => array("idType,numero,nom"),
508
            'tabfieldvalue'  => array("numero,nom"),
509
            'tabfieldinsert' => array("numero,nom"),
510
            'tabrowid'       => array("idType"),
511
            'tabcond'        => array('$conf->flightLog->enabled'),
512
        );
513
    }
514
515
    private function initConstants()
516
    {
517
        $this->const = array(
518
            0 => [
519
                'BBC_FLIGHT_LOG_TAUX_REMB_KM',
520
                'chaine',
521
                '0.25',
522
                'Taux remboursement des kilomètres au BBC',
523
                true,
524
                'current',
525
                true
526
            ],
527
            1 => [
528
                'BBC_FLIGHT_LOG_UNIT_PRICE_MISSION',
529
                'chaine',
530
                '35',
531
                'Unit price special mission',
532
                true,
533
                'current',
534
                true
535
            ],
536
        );
537
    }
538
539
}
540
541