Completed
Push — feature/pilot_information ( cc067b...4835e7 )
by Laurent
01:49
created

card.php (12 issues)

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