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/PilotService.php');
49
dol_include_once('/flightBalloon/bbc_ballons.class.php');
50
dol_include_once('/user/class/usergroup.class.php');
51
52
use PilotService;
53
54
// Load traductions files requiredby by page
55
$langs->load("mymodule@flightLog");
56
$langs->load("other");
57
58
// Get parameters
59
$id = GETPOST('id', 'int')?: GETPOST('idBBC_vols', 'int');
60
$action = GETPOST('action', 'alpha');
61
$cancel = GETPOST('cancel');
62
$backtopage = GETPOST('backtopage');
63
$myparam = GETPOST('myparam', 'alpha');
64
65
66
$search_idBBC_vols = GETPOST('search_idBBC_vols', 'int');
67
$search_lieuD = GETPOST('search_lieuD', 'alpha');
68
$search_lieuA = GETPOST('search_lieuA', 'alpha');
69
$search_heureD = GETPOST('search_heureD', 'alpha');
70
$search_heureA = GETPOST('search_heureA', 'alpha');
71
$search_BBC_ballons_idBBC_ballons = GETPOST('search_BBC_ballons_idBBC_ballons', 'int');
72
$search_nbrPax = GETPOST('search_nbrPax', 'int');
73
$search_remarque = GETPOST('search_remarque', 'alpha');
74
$search_incidents = GETPOST('search_incidents', 'alpha');
75
$search_fk_type = GETPOST('search_fk_type', 'int');
76
$search_fk_pilot = GETPOST('search_fk_pilot', 'int');
77
$search_fk_organisateur = GETPOST('search_fk_organisateur', 'int');
78
$search_is_facture = GETPOST('search_is_facture', 'int');
79
$search_kilometers = GETPOST('search_kilometers', 'int');
80
$search_cost = GETPOST('search_cost', 'alpha');
81
$search_fk_receiver = GETPOST('search_fk_receiver', 'int');
82
$search_justif_kilometers = GETPOST('search_justif_kilometers', 'alpha');
83
84
$pageTitle = "Fiche vol " . $id;
85
86
if (empty($action) && empty($id) && empty($ref)) {
87
    $action = 'view';
88
}
89
90
// Protection if external user
91
92
$object = new Bbcvols($db);
93
$extrafields = new ExtraFields($db);
94
95
$receiver = new User($db);
96
97
$pilotService = new PilotService($db);
98
$pilot = new User($db);
99
100
$organisator = new User($db);
101
102
$flightType = new Bbctypes($db);
103
$balloon = new Bbc_ballons($db);
104
105
// fetch optionals attributes and labels
106
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
107
108
// Load object
109
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
110
111
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
112
$hookmanager->initHooks(array('bbcvols'));
113
$object->ref = $object->idBBC_vols;
114
$receiver->fetch($object->fk_receiver);
115
$pilot->fetch($object->fk_pilot);
116
$organisator->fetch($object->fk_organisateur);
117
$flightType->fetch($object->fk_type);
118
$balloon->fetch($object->BBC_ballons_idBBC_ballons);
119
120
/*******************************************************************
121
 * ACTIONS
122
 *
123
 * Put here all code to do according to value of "action" parameter
124
 ********************************************************************/
125
126
$parameters = array();
127
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object,
128
    $action);    // Note that $action and $object may have been modified by some hooks
129
if ($reshook < 0) {
130
    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
131
}
132
133
if (empty($reshook)) {
134
    $isAllowedEdit = ($user->rights->flightLog->vol->edit || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id));
135
    $isAllowedDelete = ($user->rights->flightLog->vol->delete || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id && !$object->is_facture));
136
    if ($cancel || (!$isAllowedDelete && $action == 'update') || (!$isAllowedDelete && $action == "confirm_delete")) {
137
        if ($id > 0 || !empty($ref)) {
138
            $object->fetch($id);
139
140
            $receiver->fetch($object->fk_receiver);
141
            $pilot->fetch($object->fk_pilot);
142
            $organisator->fetch($object->fk_organisateur);
143
            $flightType->fetch($object->fk_type);
144
            $balloon->fetch($object->BBC_ballons_idBBC_ballons);
145
        }
146
        $action = '';
147
    }
148
149
    // Action to add record
150
    if ($action == 'add') {
151
152
        if (GETPOST('cancel')) {
153
            $urltogo = $backtopage ? $backtopage : dol_buildpath('/flightLog/list.php', 1);
154
            header("Location: " . $urltogo);
155
            exit;
156
        }
157
158
        $error = 0;
159
160
        /* object_prop_getpost_prop */
161
162
        $object->idBBC_vols = GETPOST('idBBC_vols', 'int');
163
        $object->lieuD = GETPOST('lieuD', 'alpha');
164
        $object->lieuA = GETPOST('lieuA', 'alpha');
165
        $object->heureD = GETPOST('heureD', 'alpha');
166
        $object->heureA = GETPOST('heureA', 'alpha');
167
        $object->BBC_ballons_idBBC_ballons = GETPOST('BBC_ballons_idBBC_ballons', 'int');
168
        $object->nbrPax = GETPOST('nbrPax', 'alpha');
169
        $object->remarque = GETPOST('remarque', 'alpha');
170
        $object->incidents = GETPOST('incidents', 'alpha');
171
        $object->fk_type = GETPOST('fk_type', 'int');
172
        $object->fk_pilot = GETPOST('fk_pilot', 'int');
173
        $object->fk_organisateur = GETPOST('fk_organisateur', 'int');
174
        $object->is_facture = GETPOST('is_facture', 'int');
175
        $object->kilometers = GETPOST('kilometers', 'int');
176
        $object->cost = GETPOST('cost', 'alpha');
177
        $object->fk_receiver = GETPOST('fk_receiver', 'int');
178
        $object->justif_kilometers = GETPOST('justif_kilometers', 'alpha');
179
180
181 View Code Duplication
        if (empty($object->idBBC_vols)) {
182
            $error++;
183
            setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("idBBC_vols")), null, 'errors');
184
        }
185
186
        if (!$error) {
187
            $result = $object->create($user);
188
            if ($result > 0) {
189
                // Creation OK
190
                $urltogo = $backtopage ? $backtopage : dol_buildpath('/flightLog/list.php', 1);
191
                header("Location: " . $urltogo);
192
                exit;
193
            }
194
            {
195
                // Creation KO
196 View Code Duplication
                if (!empty($object->errors)) {
197
                    setEventMessages(null, $object->errors, 'errors');
198
                } else {
199
                    setEventMessages($object->error, null, 'errors');
200
                }
201
                $action = 'create';
202
            }
203
        } else {
204
            $action = 'create';
205
        }
206
    }
207
208
    // Action to update record
209
    if ($action == 'update') {
210
        $error = 0;
211
212
        $object->date = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
213
        $object->idBBC_vols = GETPOST('idBBC_vols', 'int');
214
        $object->id = $object->idBBC_vols;
215
        $object->lieuD = GETPOST('lieuD', 'alpha');
216
        $object->lieuA = GETPOST('lieuA', 'alpha');
217
        $object->heureD = GETPOST('heureD_h', 'int').":".GETPOST('heureD_m', 'int').":00";
218
        $object->heureA = GETPOST('heureA_h', 'int').":".GETPOST('heureA_m', 'int').":00";
219
        $object->BBC_ballons_idBBC_ballons = GETPOST('BBC_ballons_idBBC_ballons', 'int');
220
        $object->nbrPax = GETPOST('nbrPax', 'alpha');
221
        $object->remarque = GETPOST('remarque', 'alpha');
222
        $object->incidents = GETPOST('incidents', 'alpha');
223
        $object->fk_type = GETPOST('fk_type', 'int');
224
        $object->fk_pilot = GETPOST('fk_pilot', 'int');
225
        $object->fk_organisateur = GETPOST('fk_organisateur', 'int');
226
        $object->kilometers = GETPOST('kilometers', 'int');
227
        $object->cost = GETPOST('cost', 'alpha');
228
        $object->fk_receiver = GETPOST('fk_receiver', 'int');
229
        $object->justif_kilometers = GETPOST('justif_kilometers', 'alpha');
230
231
232
        //validation
233 View Code Duplication
        if (empty($object->idBBC_vols)) {
234
            $error++;
235
            setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("idBBC_vols")),
236
                null, 'errors');
237
        }
238
239
        if(!dol_validElement($object->lieuD)){
240
            $error++;
241
            setEventMessage("Erreur le champ : lieu de décollage", 'errors');
242
        }
243
244
        if(!dol_validElement($object->lieuA)){
245
            $error++;
246
            setEventMessage("Erreur le champ : lieu d'atterissage", 'errors');
247
        }
248
249
        $dateD = date_create_from_format("H:i:s", $object->heureD);
250
        $dateA = date_create_from_format("H:i:s", $object->heureA);
251
        if ($dateA <= $dateD) {
252
            $error++;
253
            setEventMessage("Erreur avec les heures de vol", 'errors');
254
        }
255
256
        if(!is_numeric($object->nbrPax) || $object->nbrPax < 0 ){
257
            $error++;
258
            setEventMessage("Erreur le champ : nombre de passagers", 'errors');
259
        }
260
261
        if(!$pilotService->isPilot($object->fk_pilot)){
262
            $error++;
263
            setEventMessage("Le pilote selectionne n'est pas pilote", 'errors');
264
        }
265
266
        // action : edit
267
        if (!$error) {
268
            $result = $object->update($user);
269
            if ($result > 0) {
270
                $action = 'view';
271
272
                $receiver->fetch($object->fk_receiver);
273
                $pilot->fetch($object->fk_pilot);
274
                $organisator->fetch($object->fk_organisateur);
275
                $flightType ->fetch($object->fk_type);
276
                $balloon->fetch($object->BBC_ballons_idBBC_ballons);
277
278 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...
279
                // Creation KO
280
                if (!empty($object->errors)) {
281
                    setEventMessages(null, $object->errors, 'errors');
282
                } else {
283
                    setEventMessages($object->error, null, 'errors');
284
                }
285
                $action = 'edit';
286
            }
287
        } else {
288
            $action = 'edit';
289
        }
290
    }
291
292
    // Action to delete
293
    if ($action == 'confirm_delete') {
294
        $result = $object->delete($user);
295
        if ($result > 0) {
296
            // Delete OK
297
            setEventMessages("RecordDeleted", null, 'mesgs');
298
            header("Location: " . dol_buildpath('/flightLog/list.php', 1));
299
            exit;
300 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...
301
            if (!empty($object->errors)) {
302
                setEventMessages(null, $object->errors, 'errors');
303
            } else {
304
                setEventMessages($object->error, null, 'errors');
305
            }
306
        }
307
    }
308
}
309
310
311
/***************************************************
312
 * VIEW
313
 *
314
 * Put here all code to build page
315
 ****************************************************/
316
317
llxHeader('', $pageTitle, '');
318
319
$form = new Form($db);
320
321
322
// Put here content of your page
323
324
print '<script type="text/javascript" language="javascript">
325
jQuery(document).ready(function() {
326
	function init_myfunc()
327
	{
328
		jQuery("#myid").removeAttr(\'disabled\');
329
		jQuery("#myid").attr(\'disabled\',\'disabled\');
330
	}
331
	init_myfunc();
332
	jQuery("#mybutton").click(function() {
333
		init_myfunc();
334
	});
335
});
336
</script>';
337
338
339
// Part to create
340
if ($action == 'create') {
341
    print load_fiche_titre($langs->trans("NewMyModule"));
342
343
    print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
344
    print '<input type="hidden" name="action" value="add">';
345
    print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
346
347
    dol_fiche_head();
348
349
    print '<table class="border centpercent">' . "\n";
350
    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>';
351
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuD") . '</td><td><input class="flat" type="text" name="lieuD" value="' . GETPOST('lieuD') . '"></td></tr>';
352
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuA") . '</td><td><input class="flat" type="text" name="lieuA" value="' . GETPOST('lieuA') . '"></td></tr>';
353
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureD") . '</td><td><input class="flat" type="text" name="heureD" value="' . GETPOST('heureD') . '"></td></tr>';
354
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureA") . '</td><td><input class="flat" type="text" name="heureA" value="' . GETPOST('heureA') . '"></td></tr>';
355
    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>';
356
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldnbrPax") . '</td><td><input class="flat" type="text" name="nbrPax" value="' . GETPOST('nbrPax') . '"></td></tr>';
357
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldremarque") . '</td><td><input class="flat" type="text" name="remarque" value="' . GETPOST('remarque') . '"></td></tr>';
358
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldincidents") . '</td><td><input class="flat" type="text" name="incidents" value="' . GETPOST('incidents') . '"></td></tr>';
359
    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>';
360
    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>';
361
    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>';
362
    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>';
363
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldkilometers") . '</td><td><input class="flat" type="text" name="kilometers" value="' . GETPOST('kilometers') . '"></td></tr>';
364
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldcost") . '</td><td><input class="flat" type="text" name="cost" value="' . GETPOST('cost') . '"></td></tr>';
365
    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>';
366
    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>';
367
368
    print '</table>' . "\n";
369
370
    dol_fiche_end();
371
372
    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>';
373
374
    print '</form>';
375
}
376
377
378
// Part to edit record
379
if (($id || $ref) && $action == 'edit') {
380
    print load_fiche_titre($langs->trans("MyModule"));
381
382
    print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
383
    print '<input type="hidden" name="action" value="update">';
384
    print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
385
    print '<input type="hidden" name="idBBC_vols" value="' . $object->id . '">';
386
387
    dol_fiche_head();
388
389
    print '<table class="border centpercent">' . "\n";
390
391
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldDate") . "</td><td>";
392
    print $form->select_date($object->date, '', '', '', '', 'add', 1, 1);
393
    print "</td></tr>";
394
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldlieuD") . "</td><td><input class=\"flat\" type=\"text\" name=\"lieuD\" value=\"" . $object->lieuD . "\"></td></tr>";
395
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldlieuA") . "</td><td><input class=\"flat\" type=\"text\" name=\"lieuA\" value=\"" . $object->lieuA . "\"></td></tr>";
396
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldheureD") . "</td><td><input class=\"flat\" min=\"0\" max=\"23\" type=\"number\" name=\"heureD_h\" value=\"" . explode(":", $object->heureD)[0] . "\">h<input class=\"flat\" type=\"number\" min=\"0\" max=\"59\" name=\"heureD_m\" value=\"" . explode(":", $object->heureD)[1] . "\"></td></tr>";
397
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldheureA") . "</td><td><input class=\"flat\" type=\"number\" min=\"0\" max=\"23\" name=\"heureA_h\" value=\"" . explode(":", $object->heureA)[0] . "\">h<input class=\"flat\" type=\"number\" min=\"0\" max=\"59\" name=\"heureA_m\" value=\"" . explode(":", $object->heureA)[1] . "\"></td></tr>";
398
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldBBC_ballons_idBBC_ballons") . "</td><td>";
399
        select_balloons($object->BBC_ballons_idBBC_ballons, "BBC_ballons_idBBC_ballons");
400
    print "</td></tr>";
401
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("FieldnbrPax") . "</td><td><input class=\"flat\" type=\"number\" name=\"nbrPax\" value=\"" . $object->nbrPax . "\"></td></tr>";
402
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldremarque") . "</td><td><textarea class=\"flat\" name=\"remarque\">".$object->remarque."</textarea></td></tr>";
403
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldincidents") . "</td><td><textarea class=\"flat\" name=\"incidents\">".$object->incidents."</textarea></td></tr>";
404
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_type") . "</td><td>";
405
        select_flight_type($object->fk_type, "fk_type");
406
    print "</td></tr>";
407
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_pilot") . "</td><td>".$form->select_dolusers($object->fk_pilot, "fk_pilot", 0, '', 0, '', '', 0, 0, 0, '', 0, '', '', 1)."</td></tr>";
408
    print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_organisateur") . "</td><td>".$form->select_dolusers($object->fk_organisateur, "fk_organisateur")."</td></tr>";
409
410 View Code Duplication
    if($user->rights->flightLog->vol->financial || $user->id == $object->fk_pilot) {
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...
411
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldkilometers") . "</td><td><input class=\"flat\" type=\"number\" name=\"kilometers\" value=\"" . $object->kilometers . "\"></td></tr>";
412
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldcost") . "</td><td><input class=\"flat\" type=\"number\" name=\"cost\" value=\"" . $object->cost . "\"></td></tr>";
413
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldfk_receiver") . "</td><td>" . $form->select_dolusers($object->fk_receiver,"fk_receiver", true ) . "</td></tr>";
414
        print "<tr><td class=\"fieldrequired\">" . $langs->trans("Fieldjustif_kilometers") . "</td><td><textarea class=\"flat\" name=\"justif_kilometers\">" . $object->justif_kilometers . "</textarea></td></tr>";
415
    }
416
    print '</table>';
417
418
    dol_fiche_end();
419
420
    print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
421
    print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
422
    print '</div>';
423
424
    print '</form>';
425
}
426
427
428
// Part to show record
429
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
430
    $res = $object->fetch_optionals($object->id, $extralabels);
431
432
433
    print load_fiche_titre($langs->trans($pageTitle));
434
435
    $linkback = '<a href="'.DOL_URL_ROOT.'/flightLog/list.php">'.$langs->trans("BackToList").'</a>';
436
    print $form->showrefnav($object, "idBBC_vols", $linkback, true, "idBBC_vols");
437
    dol_fiche_head();
438
439
    if ($action == 'delete') {
440
        $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'),
441
            $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
442
        print $formconfirm;
443
    }
444
445
    print '<table class="border centpercent">' . "\n";
446
447
448
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldidBBC_vols") . '</td><td>' . $object->idBBC_vols . '</td></tr>';
449
    print '<tr><td class="fieldrequired">' . $langs->trans("Fielddate") . '</td><td>' . dol_print_date($object->date) . '</td></tr>';
450
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuD") . '</td><td>' . $object->lieuD . '</td></tr>';
451
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuA") . '</td><td>' . $object->lieuA . '</td></tr>';
452
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureD") . '</td><td>' . $object->heureD . '</td></tr>';
453
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureA") . '</td><td>' . $object->heureA . '</td></tr>';
454
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldBBC_ballons_idBBC_ballons") . '</td><td>' . $balloon->immat . '</td></tr>';
455
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldnbrPax") . '</td><td>' . $object->nbrPax . '</td></tr>';
456
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldremarque") . '</td><td>' . $object->remarque . '</td></tr>';
457
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldincidents") . '</td><td>' . $object->incidents . '</td></tr>';
458
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_type") . '</td><td>' . $object->fk_type . '</td></tr>';
459
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_pilot") . '</td><td>' . $pilot->getNomUrl(1) . '</td></tr>';
460
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_organisateur") . '</td><td>' . $organisator->getNomUrl(1) . '</td></tr>';
461
462
    if($user->rights->flightLog->vol->financial){
463
        print '<tr><td class="fieldrequired">' . $langs->trans("Fieldis_facture") . '</td><td>' . $object->is_facture . '</td></tr>';
464
    }
465
466 View Code Duplication
    if($user->rights->flightLog->vol->financial || $user->id == $object->fk_pilot) {
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...
467
        print '<tr><td class="fieldrequired">' . $langs->trans("Fieldkilometers") . '</td><td>' . $object->kilometers . ' KM</td></tr>';
468
        print '<tr><td class="fieldrequired">' . $langs->trans("Fieldcost") . '</td><td>' . $object->cost ." ". $langs->getCurrencySymbol($conf->currency).'</td></tr>';
469
        print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_receiver") . '</td><td>' . $receiver->getNomUrl(1) . '</td></tr>';
470
        print '<tr><td class="fieldrequired">' . $langs->trans("Fieldjustif_kilometers") . '</td><td>' . $object->justif_kilometers . '</td></tr>';
471
    }
472
473
    print '</table>';
474
475
    dol_fiche_end();
476
477
    // Buttons
478
    print '<div class="tabsAction">' . "\n";
479
    $parameters = array();
480
    $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object,
481
        $action);    // Note that $action and $object may have been modified by hook
482
    if ($reshook < 0) {
483
        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
484
    }
485
486 View Code Duplication
    if ($user->rights->flightLog->vol->edit || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id)) {
487
        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";
488
    }
489
490 View Code Duplication
    if ($user->rights->flightLog->vol->delete || ($user->rights->flightLog->vol->add && $object->fk_pilot == $user->id && !$object->is_facture)) {
491
        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";
492
    }
493
    print '</div>' . "\n";
494
}
495
496
497
// End of page
498
llxFooter();
499
$db->close();
500