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