Completed
Push — feature/multi_order ( eb7707 )
by Laurent
01:37
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
46
dol_include_once('/flightlog/flightlog.inc.php');
47
dol_include_once('/flightlog/class/bbcvols.class.php');
48
dol_include_once('/flightlog/class/bbctypes.class.php');
49
dol_include_once('/flightlog/lib/card.lib.php');
50
dol_include_once('/flightlog/lib/PilotService.php');
51
dol_include_once('/flightballoon/class/bbc_ballons.class.php');
52
dol_include_once('/user/class/usergroup.class.php');
53
54
global $langs, $user, $conf;
55
56
const ACTION_FLAG_BILLED = 'action_flag_bill';
57
const ACTION_CONFIRM_FLAG_BILLED = 'confirm_flag_bill';
58
59
// Load traductions files requiredby by page
60
$langs->load("mymodule@flightlog");
61
$langs->load("other");
62
63
// Get parameters
64
$id = GETPOST('id', 'int') ?: GETPOST('idBBC_vols', 'int');
65
$action = GETPOST('action', 'alpha');
66
$cancel = GETPOST('cancel');
67
$backtopage = GETPOST('backtopage');
68
$myparam = GETPOST('myparam', 'alpha');
69
70
$isAllowedEdit = ($user->rights->flightlog->vol->advanced || $user->rights->flightlog->vol->edit || ($user->rights->flightlog->vol->add && $object->fk_pilot == $user->id));
71
$isAllowedDelete = ($user->rights->flightlog->vol->delete || ($user->rights->flightlog->vol->add && $object->fk_pilot == $user->id && !$object->is_facture));
72
$permissiondellink = $user->rights->flightlog->vol->financial;
73
74
$search_idBBC_vols = GETPOST('search_idBBC_vols', 'int');
75
$search_lieuD = GETPOST('search_lieuD', 'alpha');
76
$search_lieuA = GETPOST('search_lieuA', 'alpha');
77
$search_heureD = GETPOST('search_heureD', 'alpha');
78
$search_heureA = GETPOST('search_heureA', 'alpha');
79
$search_BBC_ballons_idBBC_ballons = GETPOST('search_BBC_ballons_idBBC_ballons', 'int');
80
$search_nbrPax = GETPOST('search_nbrPax', 'int');
81
$search_remarque = GETPOST('search_remarque', 'alpha');
82
$search_incidents = GETPOST('search_incidents', 'alpha');
83
$search_fk_type = GETPOST('search_fk_type', 'int');
84
$search_fk_pilot = GETPOST('search_fk_pilot', 'int');
85
$search_fk_organisateur = GETPOST('search_fk_organisateur', 'int');
86
$search_is_facture = GETPOST('search_is_facture', 'int');
87
$search_kilometers = GETPOST('search_kilometers', 'int');
88
$search_cost = GETPOST('search_cost', 'alpha');
89
$search_fk_receiver = GETPOST('search_fk_receiver', 'int');
90
$search_justif_kilometers = GETPOST('search_justif_kilometers', 'alpha');
91
92
$pageTitle = "Fiche vol " . $id;
93
94
if (!$user->rights->flightlog->vol->access) {
95
    accessforbidden($langs->trans("Tu n'as pas accès au vol"));
96
}
97
98
if (empty($action) && empty($id) && empty($ref)) {
99
    $action = 'view';
100
}
101
102
$object = new Bbcvols($db);
103
$extrafields = new ExtraFields($db);
104
105
$receiver = new User($db);
106
107
$pilotService = new PilotService($db);
108
$pilot = new User($db);
109
110
$organisator = new User($db);
111
112
$flightType = new Bbctypes($db);
113
$balloon = new Bbc_ballons($db);
114
115
// fetch optionals attributes and labels
116
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
117
118
// Load object
119
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php';  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
120
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php';
121
122
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
123
$hookmanager->initHooks(array('bbcvols'));
124
$object->ref = $object->idBBC_vols;
125
$receiver->fetch($object->fk_receiver);
126
$pilot->fetch($object->fk_pilot);
127
$organisator->fetch($object->fk_organisateur);
128
$flightType->fetch($object->fk_type);
129
$balloon->fetch($object->BBC_ballons_idBBC_ballons);
130
131
$formFlight = new \flightlog\form\FlightForm(new FlightValidator($langs, $db, $conf->global->BBC_FLIGHT_TYPE_CUSTOMER), $object, $db, $conf->global, $user);
132
$formFlight->bind($object);
133
134
135
if (($action == "update" || $action == "edit") && !($user->rights->flightlog->vol->advanced || $user->rights->flightlog->vol->edit || ($user->rights->flightlog->vol->add && $object->fk_pilot == $user->id))) {
136
    setEventMessage("Ceci n'est pas un de tes vols tu ne peux l'editer ! ", 'errors');
137
    $action = 'view';
138
}
139
140
/*******************************************************************
141
 * ACTIONS
142
 *
143
 * Put here all code to do according to value of "action" parameter
144
 ********************************************************************/
145
146
$parameters = array();
147
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object,
148
    $action);    // Note that $action and $object may have been modified by some hooks
149
if ($reshook < 0) {
150
    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
151
}
152
153
if (empty($reshook)) {
154
155
    // Action to update record
156
    if (($user->rights->flightlog->vol->advanced || $user->rights->flightlog->vol->edit || ($user->rights->flightlog->vol->add && $object->fk_pilot == $user->id)) && $action == 'update') {
157
158
        $formFlight->setData($_POST);
159
160
        // action : edit
161
        if ($formFlight->validate()) {
162
            /** @var Bbcvols $object */
163
            $object = $formFlight->getObject();
164
            $result = $object->update($user);
165
            if ($result > 0) {
166
                $action = 'view';
167
168
                $object->id = $object->idBBC_vols;
169
                $receiver->fetch($object->fk_receiver);
170
                $pilot->fetch($object->fk_pilot);
171
                $organisator->fetch($object->fk_organisateur);
172
                $flightType->fetch($object->fk_type);
173
                $balloon->fetch($object->BBC_ballons_idBBC_ballons);
174
175 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...
176
                // Creation KO
177
                if (!empty($object->errors)) {
178
                    setEventMessages(null, $object->errors, 'errors');
179
                } else {
180
                    setEventMessages($object->error, null, 'errors');
181
                }
182
                $action = 'edit';
183
            }
184
        } else {
185
            $action = 'edit';
186
        }
187
    }
188
189
    // Action to delete
190
    if ($action == 'confirm_delete') {
191
        $result = $object->delete($user);
192
        if ($result > 0) {
193
            // Delete OK
194
            setEventMessages("RecordDeleted", null, 'mesgs');
195
            header("Location: " . dol_buildpath('/flightlog/list.php', 1));
196
            exit;
197 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...
198
            if (!empty($object->errors)) {
199
                setEventMessages(null, $object->errors, 'errors');
200
            } else {
201
                setEventMessages($object->error, null, 'errors');
202
            }
203
        }
204
    }
205
206
    // Action to delete
207
    if ($user->rights->flightlog->vol->financial && !$object->isBilled() && $action === ACTION_CONFIRM_FLAG_BILLED) {
208
        $result = $object
209
            ->bill()
210
            ->update($user);
211
212
        if ($result > 0) {
213
            setEventMessages("Facturé", null, 'mesgs');
214
            $action = 'show';
215 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...
216
            if (!empty($object->errors)) {
217
                setEventMessages(null, $object->errors, 'errors');
218
            } else {
219
                setEventMessages($object->error, null, 'errors');
220
            }
221
        }
222
    }
223
}
224
225
226
/***************************************************
227
 * VIEW
228
 *
229
 * Put here all code to build page
230
 ****************************************************/
231
232
llxHeader('', $pageTitle, '');
233
234
$form = new Form($db);
235
236
// Put here content of your page
237
238
print '<script type="text/javascript" language="javascript">
239
jQuery(document).ready(function() {
240
	function init_myfunc()
241
	{
242
		jQuery("#myid").removeAttr(\'disabled\');
243
		jQuery("#myid").attr(\'disabled\',\'disabled\');
244
	}
245
	init_myfunc();
246
	jQuery("#mybutton").click(function() {
247
		init_myfunc();
248
	});
249
});
250
</script>';
251
252
253
// Part to edit record
254
if (($user->rights->flightlog->vol->edit || ($user->rights->flightlog->vol->add && $object->fk_pilot == $user->id )) && ($id || $ref) && $action == 'edit'): ?>
255
256
    <?php $renderer = new \flightlog\form\SimpleFormRenderer(); ?>
257
258
    <div class="errors error-messages">
259
        <?php
260
        foreach ($formFlight->getErrorMessages() as $errorMessage) {
261
            print sprintf('<div class="error"><span>%s</span></div>', $errorMessage);
262
        }
263
        ?>
264
    </div>
265
266
    <form class="flight-form js-form" name='add' action="card.php?rowid=<?php echo $object->getId(); ?>" method="POST">
267
        <input type="hidden" name="action" value="update"/>
268
269
        <?php echo $renderer->render($formFlight->getElement('idBBC_vols')); ?>
270
271
        <?php if($formFlight->has('fk_type')): ?>
272
        <section class="form-section">
273
            <h1 class="form-section-title"><?php echo $langs->trans('Type de vol'); ?></h1>
274
            <table class="border" width="50%">
275
276
                <tr>
277
                    <td class="fieldrequired" width="25%"> Type du vol</td>
278
                    <td ><?php echo $renderer->render($formFlight->getElement('fk_type')); ?></td>
279
                </tr>
280
            </table>
281
        </section>
282
        <?php endif; ?>
283
284
        <!-- Date et heures -->
285 View Code Duplication
        <?php if($formFlight->has('date')): ?>
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...
286
            <section class="form-section">
287
                <h1 class="form-section-title"><?php echo $langs->trans('Date'); ?></h1>
288
                <table class="border" width="50%">
289
                    <tr>
290
                        <td class="fieldrequired" width="25%">Date du vol</td>
291
                        <td ><?php echo $renderer->render($formFlight->getElement('date')); ?></td>
292
                    </tr>
293
                </table>
294
            </section>
295
        <?php endif; ?>
296
297
        <?php if($formFlight->has('heureD') && $formFlight->has('heureA')): ?>
298
            <section class="form-section">
299
                <h1 class="form-section-title"><?php echo $langs->trans('Heures'); ?></h1>
300
                <table class="border" width="50%">
301
                    <tr>
302
                        <td class="fieldrequired" width="25%">Heure du décollage</td>
303
                        <td ><?php echo $renderer->render($formFlight->getElement('heureD')); ?></td>
304
                    </tr>
305
                    <tr>
306
                        <td class="fieldrequired" width="25%">Heure de l'atterrissage</td>
307
                        <td ><?php echo $renderer->render($formFlight->getElement('heureA')); ?></td>
308
                    </tr>
309
                </table>
310
            </section>
311
        <?php endif; ?>
312
313
        <section class="form-section">
314
            <h1 class="form-section-title"><?php echo $langs->trans('Pilote & ballon') ?></h1>
315
            <table class="border" width="50%">
316
317 View Code Duplication
                <?php if($formFlight->has('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...
318
                <tr>
319
                    <td class="fieldrequired"> Pilote </td>
320
                    <td><?php echo $renderer->render($formFlight->getElement('fk_pilot'),['ajax' => true]); ?></td>
321
                </tr>
322
                <?php endif; ?>
323
324
                <?php if($formFlight->has('BBC_ballons_idBBC_ballons')): ?>
325
                <tr>
326
                    <td width="25%" class="fieldrequired">Ballon</td>
327
                    <td><?php echo $renderer->render($formFlight->getElement('BBC_ballons_idBBC_ballons')); ?></td>
328
                </tr>
329
                <?php endif; ?>
330
331
                <tr>
332
                    <td>Il y'avait-il plusieurs ballons ?</td>
333
                    <td colspan="3"><input type="checkbox" value="1" name="grouped_flight"/> - Oui</td>
334
                </tr>
335
            </table>
336
        </section>
337
338
        <section class="form-section">
339
            <h1 class="form-section-title"><?php echo $langs->trans('Lieux') ?></h1>
340
            <table class="border" width="100%">
341
                <?php
342
343
                //place start
344
                print "<tr>";
345
                print '<td class="fieldrequired">Lieu de d&#233;part </td><td width="25%" >';
346
                print $renderer->render($formFlight->getElement('lieuD'));
347
                print '</td>';
348
349
                //place end
350
                print '<td class="fieldrequired">Lieu d\'arriv&#233;e </td><td>';
351
                print $renderer->render($formFlight->getElement('lieuA'));
352
                print '</td></tr>';
353
354
                ?>
355
356
            </table>
357
        </section>
358
359 View Code Duplication
        <?php if($formFlight->has('fk_organisateur')): ?>
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...
360
            <section class="form-section">
361
                <h1 class="form-section-title"><span class="js-organisator-field">Organisateur</span></h1>
362
                <table class="border" width="50%">
363
                    <tr>
364
                        <td class="fieldrequired"><span class="js-organisator-field">Organisateur</span></td>
365
                        <td>
366
                            <?php
367
                            //organisateur
368
                            print $renderer->render($formFlight->getElement('fk_organisateur'),['ajax' => true]);
369
                            ?>
370
                        </td>
371
                    </tr>
372
                </table>
373
            </section>
374
        <?php endif; ?>
375
376
377
        <section class="form-section js-expensable-field">
378
            <h1 class="form-section-title"><?php echo $langs->trans('Déplacements') ?></h1>
379
            <table class="border" width="50%">
380
                <?php if($formFlight->has('kilometers')): ?>
381
                    <!-- number of kilometers done for the flight -->
382
                    <tr>
383
                        <td class="fieldrequired">Nombre de kilometres effectués pour le vol</td>
384
                        <td>
385
                            <?php print $renderer->render($formFlight->getElement('kilometers')); ?>
386
                        </td>
387
                    </tr>
388
                <?php endif; ?>
389
390
                <?php if($formFlight->has('justif_kilometers')): ?>
391
                    <!-- Justif Kilometers -->
392
                    <tr>
393
394
                        <td width="25%" class="fieldrequired">Justificatif des KM</td>
395
                        <td>
396
                            <?php print $renderer->render($formFlight->getElement('justif_kilometers')); ?>
397
                        </textarea>
398
                        </td>
399
                    </tr>
400
                <?php endif; ?>
401
            </table>
402
        </section>
403
404
        <!-- Passagers -->
405
        <section class="form-section">
406
            <h1 class="form-section-title"><?php echo $langs->trans('Passager') ?></h1>
407
            <table class="border" width="50%">
408
                <?php if($formFlight->has('nbrPax')): ?>
409
                    <tr>
410
                        <td class="fieldrequired"><?php echo $langs->trans('Nombre de passagers'); ?></td>
411
                        <td>
412
                            <?php print $renderer->render($formFlight->getElement('nbrPax')); ?>
413
                        </td>
414
                    </tr>
415
                <?php endif; ?>
416
417
                <?php if($formFlight->has('passengerNames')): ?>
418
                    <!-- passenger names -->
419
                    <tr>
420
                        <td width="25%" class="fieldrequired"><?php echo $langs->trans('Noms des passagers'); ?><br/>(Séparé
421
                            par des ; )
422
                        </td>
423
                        <td>
424
                            <?php print $renderer->render($formFlight->getElement('passengerNames')); ?>
425
                        </td>
426
                    </tr>
427
                <?php endif;?>
428
            </table>
429
        </section>
430
431
        <!-- billing information -->
432
        <section class="form-section">
433
            <h1 class="form-section-title js-billable-field"><?php echo $langs->trans('Facturation') ?></h1>
434
            <table class="border" width="50%">
435
436
                <?php if($formFlight->has('fk_receiver')): ?>
437
                    <!-- Money receiver -->
438
                    <tr class="js-hide-order js-billable-field">
439
                        <td class="fieldrequired"><?php echo $langs->trans('Qui a perçu l\'argent') ?></td>
440
                        <td>
441
                            <?php print $renderer->render($formFlight->getElement('fk_receiver'),['ajax' => true]); ?>
442
                        </td>
443
                    </tr>
444
                <?php endif; ?>
445
446
                <?php if($formFlight->has('cost')): ?>
447
                    <!-- Flight cost -->
448
                    <tr class="js-hide-order js-billable-field">
449
                        <td class="fieldrequired">Montant perçu</td>
450
                        <td>
451
                            <?php print $renderer->render($formFlight->getElement('cost')); ?>
452
                            &euro;
453
                        </td>
454
                    </tr>
455
                <?php endif; ?>
456
            </table>
457
        </section>
458
459
        <!-- comments -->
460
        <section class="form-section">
461
            <h1 class="form-section-title"><?php echo $langs->trans('Commentaires') ?></h1>
462
            <table class="border" width="50%">
463
464
                <?php if($formFlight->has('remarque')): ?>
465
                    <!-- commentaires -->
466
                    <tr class="">
467
                        <td class="fieldrequired"> Commentaire</td>
468
                        <td>
469
                            <?php print $renderer->render($formFlight->getElement('remarque')); ?>
470
                        </td>
471
                    </tr>
472
                <?php endif; ?>
473
474
                <?php if($formFlight->has('incidents')): ?>
475
                    <!-- incidents -->
476
                    <tr class="">
477
                        <td class="fieldrequired"> incidents</td>
478
                        <td>
479
                            <?php print $renderer->render($formFlight->getElement('incidents')); ?>
480
                        </td>
481
                    </tr>
482
                <?php endif; ?>
483
            </table>
484
        </section>
485
486
        <button class="button" type="submit">Modifier</button>
487
        <a href="card.php?id=<?php echo $object->getId(); ?>" class="btn button button-a">Annuler</a>
488
    </form>
489
490
<?php endif;
491
492
493
// Part to show record
494
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
495
    $res = $object->fetch_optionals($object->id, $extralabels);
496
497
    $head = prepareFlightTabs($object);
498
499
    dol_fiche_head($head, 'general', $langs->trans("Vol"));
500
501
    $linkback = '<a href="' . DOL_URL_ROOT . '/flightlog/list.php">' . $langs->trans("BackToList") . '</a>';
502
    print $form->showrefnav($object, "idBBC_vols", $linkback, true, "idBBC_vols");
503
504
    if ($action == 'delete') {
505
        $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'),
506
            $langs->trans('êtes-vous sure de vouloir supprimer ce vol ?'), 'confirm_delete', '', 0, 1);
507
        print $formconfirm;
508
    } elseif ($user->rights->flightlog->vol->financial  && $action == ACTION_FLAG_BILLED) {
509
        $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id,
510
            $langs->trans('Marque comme facturé'),
511
            $langs->trans('Ce vol va être marqué comme facturé, est-ce bien le cas ?'), ACTION_CONFIRM_FLAG_BILLED, '',
512
            0, 1);
513
        print $formconfirm;
514
    }
515
516
    print '<table class="border centpercent">' . "\n";
517
518
519
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldidBBC_vols") . '</td><td>' . $object->idBBC_vols . '</td></tr>';
520
    print '<tr><td class="fieldrequired">' . $langs->trans("Fielddate") . '</td><td>' . dol_print_date($object->date) . '</td></tr>';
521
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuD") . '</td><td>' . $object->lieuD . '</td></tr>';
522
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldlieuA") . '</td><td>' . $object->lieuA . '</td></tr>';
523
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureD") . '</td><td>' . $object->heureD . '</td></tr>';
524
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldheureA") . '</td><td>' . $object->heureA . '</td></tr>';
525
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldBBC_ballons_idBBC_ballons") . '</td><td>' . $balloon->immat . '</td></tr>';
526
    print '<tr><td class="fieldrequired">' . $langs->trans("FieldnbrPax") . '</td><td>' . $object->nbrPax . '</td></tr>';
527
    print '<tr><td class="fieldrequired">' . $langs->trans("Noms des passagers") . '</td><td>' . $object->getPassengerNames() . '</td></tr>';
528
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_type") . '</td><td>' . $object->fk_type . '</td></tr>';
529
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_pilot") . '</td><td>' . $pilot->getNomUrl(1) . '</td></tr>';
530
    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_organisateur") . '</td><td>' . $organisator->getNomUrl(1) . '</td></tr>';
531
532
    print '</table>';
533
534
    dol_fiche_end();
535
536
    // Buttons
537
    print '<div class="tabsAction">' . "\n";
538
    $parameters = array();
539
    $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object,
540
        $action);    // Note that $action and $object may have been modified by hook
541
    if ($reshook < 0) {
542
        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
543
    }
544
545
    if ($user->rights->flightlog->vol->advanced || $user->rights->flightlog->vol->edit || ($user->rights->flightlog->vol->add && $object->fk_pilot == $user->id)) {
546
        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";
547
    }
548
549
    if ($user->rights->flightlog->vol->delete || ($user->rights->flightlog->vol->add && $object->fk_pilot == $user->id && !$object->isBilled())) {
550
        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";
551
    }
552
553 View Code Duplication
    if ($user->rights->flightlog->vol->financial && $object->fk_type == 2 && !$object->hasFacture() && $object->hasReceiver()) {
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...
554
        print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/facture.php?id=' . $object->id . '">' . $langs->trans("Facturer") . '</a></div>' . "\n";
555
    }
556
    ?>
557
558
    <?php if ($user->rights->flightlog->vol->financial && !$object->isBilled()): ?>
559
        <div class="inline-block divButAction">
560
            <a class="butAction" href="<?php echo sprintf('%s?id=%s&action=%s', $_SERVER["PHP_SELF"], $object->id,
561
                ACTION_FLAG_BILLED); ?>">
562
                <?php echo $langs->trans("Marqué comme facturé ") ?>
563
            </a>
564
        </div>
565
    <?php endif; ?>
566
567
    </div>
568
    <?php
569
    if ($user->rights->flightlog->vol->financial) {
570
        print '<div class="fichecenter"><div class="fichehalfleft">';
571
        $form->showLinkedObjectBlock($object);
572
        print '</div></div>';
573
    }
574
575
}
576
577
578
// End of page
579
llxFooter();
580
$db->close();
581