Completed
Push — master ( 7bb44a...72105c )
by Laurent
02:19
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/* Copyright (C) 2007-2015 Laurent Destailleur  <[email protected]>
3
 * Copyright (C) ---Put here your own copyright and developer email---
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
/**
20
 *    \file       flightLog/bbcvols_card.php
21
 *        \ingroup    flightLog
22
 *        \brief      This file is an example of a php page
23
 *                    Initialy built by build_class_from_table on 2017-02-09 11:10
24
 */
25
26
// Change this following line to use the correct relative path (../, ../../, etc)
27
$res = 0;
28
if (!$res && file_exists("../main.inc.php")) {
29
    $res = @include '../main.inc.php';
30
}                    // to work if your module directory is into dolibarr root htdocs directory
31
if (!$res && file_exists("../../main.inc.php")) {
32
    $res = @include '../../main.inc.php';
33
}            // to work if your module directory is into a subdir of root htdocs directory
34
if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php")) {
35
    $res = @include '../../../dolibarr/htdocs/main.inc.php';
36
}     // Used on dev env only
37
if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) {
38
    $res = @include '../../../../dolibarr/htdocs/main.inc.php';
39
}   // Used on dev env only
40
if (!$res) {
41
    die("Include of main fails");
42
}
43
// Change this following line to use the correct relative path from htdocs
44
include_once(DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php');
45
dol_include_once('/flightLog/class/bbcvols.class.php');
46
dol_include_once('/flightLog/class/bbctypes.class.php');
47
dol_include_once('/flightLog/lib/flightLog.lib.php');
48
dol_include_once('/flightLog/lib/card.lib.php');
49
dol_include_once('/flightLog/lib/PilotService.php');
50
dol_include_once('/flightBalloon/bbc_ballons.class.php');
51
dol_include_once('/user/class/usergroup.class.php');
52
53
global $langs, $user;
54
55
// Load traductions files requiredby by page
56
$langs->load("mymodule@flightLog");
57
$langs->load("other");
58
59
// Get parameters
60
$id = GETPOST('id', 'int') ?: GETPOST('idBBC_vols', 'int');
61
$action = GETPOST('action', 'alpha');
62
$cancel = GETPOST('cancel');
63
$backtopage = GETPOST('backtopage');
64
$myparam = GETPOST('myparam', 'alpha');
65
66
$isAllowedEdit = ($user->rights->flightLog->vol->edit || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id));
67
$isAllowedDelete = ($user->rights->flightLog->vol->delete || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id && !$object->is_facture));
68
69
$search_idBBC_vols = GETPOST('search_idBBC_vols', 'int');
70
$search_lieuD = GETPOST('search_lieuD', 'alpha');
71
$search_lieuA = GETPOST('search_lieuA', 'alpha');
72
$search_heureD = GETPOST('search_heureD', 'alpha');
73
$search_heureA = GETPOST('search_heureA', 'alpha');
74
$search_BBC_ballons_idBBC_ballons = GETPOST('search_BBC_ballons_idBBC_ballons', 'int');
75
$search_nbrPax = GETPOST('search_nbrPax', 'int');
76
$search_remarque = GETPOST('search_remarque', 'alpha');
77
$search_incidents = GETPOST('search_incidents', 'alpha');
78
$search_fk_type = GETPOST('search_fk_type', 'int');
79
$search_fk_pilot = GETPOST('search_fk_pilot', 'int');
80
$search_fk_organisateur = GETPOST('search_fk_organisateur', 'int');
81
$search_is_facture = GETPOST('search_is_facture', 'int');
82
$search_kilometers = GETPOST('search_kilometers', 'int');
83
$search_cost = GETPOST('search_cost', 'alpha');
84
$search_fk_receiver = GETPOST('search_fk_receiver', 'int');
85
$search_justif_kilometers = GETPOST('search_justif_kilometers', 'alpha');
86
87
$pageTitle = "Fiche vol " . $id;
88
89
if (!$user->rights->flightLog->vol->access) {
90
    accessforbidden($langs->trans("Tu n'as pas accès au vol"));
91
}
92
93
if (empty($action) && empty($id) && empty($ref)) {
94
    $action = 'view';
95
}
96
97
$object = new Bbcvols($db);
98
$extrafields = new ExtraFields($db);
99
100
$receiver = new User($db);
101
102
$pilotService = new PilotService($db);
103
$pilot = new User($db);
104
105
$organisator = new User($db);
106
107
$flightType = new Bbctypes($db);
108
$balloon = new Bbc_ballons($db);
109
110
// fetch optionals attributes and labels
111
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
112
113
// Load object
114
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php';  // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
115
116
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
117
$hookmanager->initHooks(array('bbcvols'));
118
$object->ref = $object->idBBC_vols;
119
$receiver->fetch($object->fk_receiver);
120
$pilot->fetch($object->fk_pilot);
121
$organisator->fetch($object->fk_organisateur);
122
$flightType->fetch($object->fk_type);
123
$balloon->fetch($object->BBC_ballons_idBBC_ballons);
124
125
/*******************************************************************
126
 * ACTIONS
127
 *
128
 * Put here all code to do according to value of "action" parameter
129
 ********************************************************************/
130
131
$parameters = array();
132
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object,
133
    $action);    // Note that $action and $object may have been modified by some hooks
134
if ($reshook < 0) {
135
    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
136
}
137
138
if (empty($reshook)) {
139
    if ($cancel || (!$isAllowedEdit && $action == 'update') || (!$isAllowedDelete && $action == "confirm_delete")) {
140
        if ($id > 0 || !empty($ref)) {
141
            $object->fetch($id);
142
143
            $receiver->fetch($object->fk_receiver);
144
            $pilot->fetch($object->fk_pilot);
145
            $organisator->fetch($object->fk_organisateur);
146
            $flightType->fetch($object->fk_type);
147
            $balloon->fetch($object->BBC_ballons_idBBC_ballons);
148
        }
149
        $action = '';
150
    }
151
152
    // Action to add record
153
    if ($action == 'add') {
154
155
        if (GETPOST('cancel')) {
156
            $urltogo = $backtopage ? $backtopage : dol_buildpath('/flightLog/list.php', 1);
157
            header("Location: " . $urltogo);
158
            exit;
159
        }
160
161
        $error = 0;
162
163
        /* object_prop_getpost_prop */
164
165
        $object->idBBC_vols = GETPOST('idBBC_vols', 'int');
166
        $object->lieuD = GETPOST('lieuD', 'alpha');
167
        $object->lieuA = GETPOST('lieuA', 'alpha');
168
        $object->heureD = GETPOST('heureD', 'alpha');
169
        $object->heureA = GETPOST('heureA', 'alpha');
170
        $object->BBC_ballons_idBBC_ballons = GETPOST('BBC_ballons_idBBC_ballons', 'int');
171
        $object->nbrPax = GETPOST('nbrPax', 'alpha');
172
        $object->remarque = GETPOST('remarque', 'alpha');
173
        $object->incidents = GETPOST('incidents', 'alpha');
174
        $object->fk_type = GETPOST('fk_type', 'int');
175
        $object->fk_pilot = GETPOST('fk_pilot', 'int');
176
        $object->fk_organisateur = GETPOST('fk_organisateur', 'int');
177
        $object->is_facture = GETPOST('is_facture', 'int');
178
        $object->kilometers = GETPOST('kilometers', 'int');
179
        $object->cost = GETPOST('cost', 'alpha');
180
        $object->fk_receiver = GETPOST('fk_receiver', 'int');
181
        $object->justif_kilometers = GETPOST('justif_kilometers', 'alpha');
182
183
184 View Code Duplication
        if (empty($object->idBBC_vols)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
185
            $error++;
186
            setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("idBBC_vols")), null,
187
                'errors');
188
        }
189
190
        if (!$error) {
191
            $result = $object->create($user);
192
            if ($result > 0) {
193
                // Creation OK
194
                $urltogo = $backtopage ? $backtopage : dol_buildpath('/flightLog/list.php', 1);
195
                header("Location: " . $urltogo);
196
                exit;
197
            }
198
            {
199
                // Creation KO
200 View Code Duplication
                if (!empty($object->errors)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
201
                    setEventMessages(null, $object->errors, 'errors');
202
                } else {
203
                    setEventMessages($object->error, null, 'errors');
204
                }
205
                $action = 'create';
206
            }
207
        } else {
208
            $action = 'create';
209
        }
210
    }
211
212
    // Action to update record
213
    if ($action == 'update') {
214
        $error = 0;
215
216
        $object->date = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
217
        $object->idBBC_vols = GETPOST('idBBC_vols', 'int');
218
        $object->id = $object->idBBC_vols;
219
        $object->lieuD = GETPOST('lieuD', 'alpha');
220
        $object->lieuA = GETPOST('lieuA', 'alpha');
221
        $object->heureD = GETPOST('heureD_h', 'int') . ":" . GETPOST('heureD_m', 'int') . ":00";
222
        $object->heureA = GETPOST('heureA_h', 'int') . ":" . GETPOST('heureA_m', 'int') . ":00";
223
        $object->BBC_ballons_idBBC_ballons = GETPOST('BBC_ballons_idBBC_ballons', 'int');
224
        $object->nbrPax = GETPOST('nbrPax', 'alpha');
225
        $object->remarque = GETPOST('remarque', 'alpha');
226
        $object->incidents = GETPOST('incidents', 'alpha');
227
        $object->fk_type = GETPOST('fk_type', 'int');
228
        $object->fk_pilot = GETPOST('fk_pilot', 'int');
229
        $object->fk_organisateur = GETPOST('fk_organisateur', 'int');
230
        $object->kilometers = GETPOST('kilometers', 'int') ?: $object->kilometers;
231
        $object->cost = GETPOST('cost', 'alpha') ?: $object->cost;
232
        $object->fk_receiver = GETPOST('fk_receiver', 'int') ?: $object->fk_receiver;
233
        $object->justif_kilometers = GETPOST('justif_kilometers', 'alpha') ?: $object->justif_kilometers;
234
235
236
        //validation
237 View Code Duplication
        if (empty($object->idBBC_vols)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
238
            $error++;
239
            setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",
240
                $langs->transnoentitiesnoconv("idBBC_vols")),
241
                null, 'errors');
242
        }
243
244
        if (!dol_validElement($object->lieuD)) {
245
            $error++;
246
            setEventMessage("Erreur le champ : lieu de décollage", 'errors');
247
        }
248
249
        if (!dol_validElement($object->lieuA)) {
250
            $error++;
251
            setEventMessage("Erreur le champ : lieu d'atterissage", 'errors');
252
        }
253
254
        $dateD = date_create_from_format("H:i:s", $object->heureD);
255
        $dateA = date_create_from_format("H:i:s", $object->heureA);
256
        if ($dateA <= $dateD) {
257
            $error++;
258
            setEventMessage("Erreur avec les heures de vol", 'errors');
259
        }
260
261
        if (!is_numeric($object->nbrPax) || $object->nbrPax < 0) {
262
            $error++;
263
            setEventMessage("Erreur le champ : nombre de passagers", 'errors');
264
        }
265
266
        if (!$pilotService->isPilot($object->fk_pilot)) {
267
            $error++;
268
            setEventMessage($langs->trans("Le pilote selectionne n'est pas pilote", 'errors'));
269
        }
270
271
        // action : edit
272
        if (!$error) {
273
            $result = $object->update($user);
274
            if ($result > 0) {
275
                $action = 'view';
276
277
                $receiver->fetch($object->fk_receiver);
278
                $pilot->fetch($object->fk_pilot);
279
                $organisator->fetch($object->fk_organisateur);
280
                $flightType->fetch($object->fk_type);
281
                $balloon->fetch($object->BBC_ballons_idBBC_ballons);
282
283 View Code Duplication
            } else {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
284
                // Creation KO
285
                if (!empty($object->errors)) {
286
                    setEventMessages(null, $object->errors, 'errors');
287
                } else {
288
                    setEventMessages($object->error, null, 'errors');
289
                }
290
                $action = 'edit';
291
            }
292
        } else {
293
            $action = 'edit';
294
        }
295
    }
296
297
    // Action to delete
298
    if ($action == 'confirm_delete') {
299
        $result = $object->delete($user);
300
        if ($result > 0) {
301
            // Delete OK
302
            setEventMessages("RecordDeleted", null, 'mesgs');
303
            header("Location: " . dol_buildpath('/flightLog/list.php', 1));
304
            exit;
305 View Code Duplication
        } else {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
306
            if (!empty($object->errors)) {
307
                setEventMessages(null, $object->errors, 'errors');
308
            } else {
309
                setEventMessages($object->error, null, 'errors');
310
            }
311
        }
312
    }
313
}
314
315
316
/***************************************************
317
 * VIEW
318
 *
319
 * Put here all code to build page
320
 ****************************************************/
321
322
llxHeader('', $pageTitle, '');
323
324
$form = new Form($db);
325
326
327
// Put here content of your page
328
329
print '<script type="text/javascript" language="javascript">
330
jQuery(document).ready(function() {
331
	function init_myfunc()
332
	{
333
		jQuery("#myid").removeAttr(\'disabled\');
334
		jQuery("#myid").attr(\'disabled\',\'disabled\');
335
	}
336
	init_myfunc();
337
	jQuery("#mybutton").click(function() {
338
		init_myfunc();
339
	});
340
});
341
</script>';
342
343
344
// Part to create
345
if ($action == 'create') {
346
    print load_fiche_titre($langs->trans("NewMyModule"));
347
348
    print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
349
    print '<input type="hidden" name="action" value="add">';
350
    print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
351
352
    dol_fiche_head();
353
354
    print '<table class="border centpercent">' . "\n";
355
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldidBBC_vols") . '</td><td><input class="flat" type="text" name="idBBC_vols" value="' . GETPOST('idBBC_vols') . '"></td></tr>';
356
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuD") . '</td><td><input class="flat" type="text" name="lieuD" value="' . GETPOST('lieuD') . '"></td></tr>';
357
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuA") . '</td><td><input class="flat" type="text" name="lieuA" value="' . GETPOST('lieuA') . '"></td></tr>';
358
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureD") . '</td><td><input class="flat" type="text" name="heureD" value="' . GETPOST('heureD') . '"></td></tr>';
359
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureA") . '</td><td><input class="flat" type="text" name="heureA" value="' . GETPOST('heureA') . '"></td></tr>';
360
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldBBC_ballons_idBBC_ballons") . '</td><td><input class="flat" type="text" name="BBC_ballons_idBBC_ballons" value="' . GETPOST('BBC_ballons_idBBC_ballons') . '"></td></tr>';
361
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldnbrPax") . '</td><td><input class="flat" type="text" name="nbrPax" value="' . GETPOST('nbrPax') . '"></td></tr>';
362
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldremarque") . '</td><td><input class="flat" type="text" name="remarque" value="' . GETPOST('remarque') . '"></td></tr>';
363
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldincidents") . '</td><td><input class="flat" type="text" name="incidents" value="' . GETPOST('incidents') . '"></td></tr>';
364
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_type") . '</td><td><input class="flat" type="text" name="fk_type" value="' . GETPOST('fk_type') . '"></td></tr>';
365
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_pilot") . '</td><td><input class="flat" type="text" name="fk_pilot" value="' . GETPOST('fk_pilot') . '"></td></tr>';
366
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_organisateur") . '</td><td><input class="flat" type="text" name="fk_organisateur" value="' . GETPOST('fk_organisateur') . '"></td></tr>';
367
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldis_facture") . '</td><td><input class="flat" type="text" name="is_facture" value="' . GETPOST('is_facture') . '"></td></tr>';
368
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldkilometers") . '</td><td><input class="flat" type="text" name="kilometers" value="' . GETPOST('kilometers') . '"></td></tr>';
369
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldcost") . '</td><td><input class="flat" type="text" name="cost" value="' . GETPOST('cost') . '"></td></tr>';
370
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_receiver") . '</td><td><input class="flat" type="text" name="fk_receiver" value="' . GETPOST('fk_receiver') . '"></td></tr>';
371
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldjustif_kilometers") . '</td><td><input class="flat" type="text" name="justif_kilometers" value="' . GETPOST('justif_kilometers') . '"></td></tr>';
372
373
    print '</table>' . "\n";
374
375
    dol_fiche_end();
376
377
    print '<div class="center"><input type="submit" class="button" name="add" value="' . $langs->trans("Create") . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></div>';
378
379
    print '</form>';
380
}
381
382
383
// Part to edit record
384
if (($id || $ref) && $action == 'edit') {
385
    print load_fiche_titre($langs->trans("MyModule"));
386
387
    print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
388
    print '<input type="hidden" name="action" value="update">';
389
    print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
390
    print '<input type="hidden" name="idBBC_vols" value="' . $object->id . '">';
391
392
    dol_fiche_head();
393
394
    print '<table class="border centpercent">' . "\n";
395
396
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldDate") . "</td><td>";
397
    print $form->select_date($object->date, '', '', '', '', 'add', 1, 1);
398
    print "</td></tr>";
399
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldlieuD") . "</td><td><input class=\"flat\" type=\"text\" name=\"lieuD\" value=\"" . $object->lieuD . "\"></td></tr>";
400
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldlieuA") . "</td><td><input class=\"flat\" type=\"text\" name=\"lieuA\" value=\"" . $object->lieuA . "\"></td></tr>";
401
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldheureD") . "</td><td><input class=\"flat\" min=\"0\" max=\"23\" type=\"number\" name=\"heureD_h\" value=\"" . explode(":",
402
            $object->heureD)[0] . "\">h<input class=\"flat\" type=\"number\" min=\"0\" max=\"59\" name=\"heureD_m\" value=\"" . explode(":",
403
            $object->heureD)[1] . "\"></td></tr>";
404
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldheureA") . "</td><td><input class=\"flat\" type=\"number\" min=\"0\" max=\"23\" name=\"heureA_h\" value=\"" . explode(":",
405
            $object->heureA)[0] . "\">h<input class=\"flat\" type=\"number\" min=\"0\" max=\"59\" name=\"heureA_m\" value=\"" . explode(":",
406
            $object->heureA)[1] . "\"></td></tr>";
407
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldBBC_ballons_idBBC_ballons") . "</td><td>";
408
    select_balloons($object->BBC_ballons_idBBC_ballons, "BBC_ballons_idBBC_ballons");
409
    print "</td></tr>";
410
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldnbrPax") . "</td><td><input class=\"flat\" type=\"number\" name=\"nbrPax\" value=\"" . $object->nbrPax . "\"></td></tr>";
411
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldremarque") . "</td><td><textarea class=\"flat\" name=\"remarque\">" . $object->remarque . "</textarea></td></tr>";
412
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldincidents") . "</td><td><textarea class=\"flat\" name=\"incidents\">" . $object->incidents . "</textarea></td></tr>";
413
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_type") . "</td><td>";
414
    select_flight_type($object->fk_type, "fk_type");
415
    print "</td></tr>";
416
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_pilot") . "</td><td>" . $form->select_dolusers($object->fk_pilot,
417
            "fk_pilot", 0, '', 0, '', '', 0, 0, 0, '', 0, '', '', 1) . "</td></tr>";
418
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_organisateur") . "</td><td>" . $form->select_dolusers($object->fk_organisateur,
419
            "fk_organisateur") . "</td></tr>";
420
421
    if ($user->rights->flightLog->vol->financial || $user->id == $object->fk_pilot) {
422
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldkilometers") . "</td><td><input class=\"flat\" type=\"number\" name=\"kilometers\" value=\"" . $object->kilometers . "\"></td></tr>";
423
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldcost") . "</td><td><input class=\"flat\" type=\"number\" name=\"cost\" value=\"" . $object->cost . "\"></td></tr>";
424
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_receiver") . "</td><td>" . $form->select_dolusers($object->fk_receiver,
425
                "fk_receiver", true) . "</td></tr>";
426
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldjustif_kilometers") . "</td><td><textarea class=\"flat\" name=\"justif_kilometers\">" . $object->justif_kilometers . "</textarea></td></tr>";
427
    }
428
    print '</table>';
429
430
    dol_fiche_end();
431
432
    print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
433
    print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
434
    print '</div>';
435
436
    print '</form>';
437
}
438
439
440
// Part to show record
441
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
442
    $res = $object->fetch_optionals($object->id, $extralabels);
443
444
    /*
445
             * Show tabs
446
             */
447
    $head = prepareFlightTabs($object);
448
449
    dol_fiche_head($head, 'general', $langs->trans("Vol"));
450
451
    $linkback = '<a href="' . DOL_URL_ROOT . '/flightLog/list.php">' . $langs->trans("BackToList") . '</a>';
452
    print $form->showrefnav($object, "idBBC_vols", $linkback, true, "idBBC_vols");
453
454
    if ($action == 'delete') {
455
        $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'),
456
            $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
457
        print $formconfirm;
458
    }
459
460
    print '<table class="border centpercent">' . "\n";
461
462
463
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldidBBC_vols") . '</td><td>' . $object->idBBC_vols . '</td></tr>';
464
    print '<tr><td class="fieldrequired">' . $langs->trans("Fielddate") . '</td><td>' . dol_print_date($object->date) . '</td></tr>';
465
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuD") . '</td><td>' . $object->lieuD . '</td></tr>';
466
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuA") . '</td><td>' . $object->lieuA . '</td></tr>';
467
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureD") . '</td><td>' . $object->heureD . '</td></tr>';
468
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureA") . '</td><td>' . $object->heureA . '</td></tr>';
469
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldBBC_ballons_idBBC_ballons") . '</td><td>' . $balloon->immat . '</td></tr>';
470
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldnbrPax") . '</td><td>' . $object->nbrPax . '</td></tr>';
471
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_type") . '</td><td>' . $object->fk_type . '</td></tr>';
472
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_pilot") . '</td><td>' . $pilot->getNomUrl(1) . '</td></tr>';
473
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_organisateur") . '</td><td>' . $organisator->getNomUrl(1) . '</td></tr>';
474
475
    print '</table>';
476
477
    dol_fiche_end();
478
479
    // Buttons
480
    print '<div class="tabsAction">' . "\n";
481
    $parameters = array();
482
    $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object,
483
        $action);    // Note that $action and $object may have been modified by hook
484
    if ($reshook < 0) {
485
        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
486
    }
487
488 View Code Duplication
    if ($user->rights->flightLog->vol->edit || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
489
        print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit">' . $langs->trans("Modify") . '</a></div>' . "\n";
490
    }
491
492 View Code Duplication
    if ($user->rights->flightLog->vol->delete || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id && !$object->is_facture)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
493
        print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>' . "\n";
494
    }
495
    print '</div>' . "\n";
496
}
497
498
499
// End of page
500
llxFooter();
501
$db->close();
502