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