1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \file flightlog/bbcvols_card.php |
5
|
|
|
* \ingroup flightlog |
6
|
|
|
* \brief This file is an example of a php page |
7
|
|
|
* Initialy built by build_class_from_table on 2017-02-09 11:10 |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
// Change this following line to use the correct relative path (../, ../../, etc) |
11
|
|
|
$res = 0; |
12
|
|
|
if (!$res && file_exists("../main.inc.php")) { |
13
|
|
|
$res = @include '../main.inc.php'; |
14
|
|
|
} // to work if your module directory is into dolibarr root htdocs directory |
15
|
|
|
if (!$res && file_exists("../../main.inc.php")) { |
16
|
|
|
$res = @include '../../main.inc.php'; |
17
|
|
|
} // to work if your module directory is into a subdir of root htdocs directory |
18
|
|
|
if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php")) { |
19
|
|
|
$res = @include '../../../dolibarr/htdocs/main.inc.php'; |
20
|
|
|
} // Used on dev env only |
21
|
|
|
if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) { |
22
|
|
|
$res = @include '../../../../dolibarr/htdocs/main.inc.php'; |
23
|
|
|
} // Used on dev env only |
24
|
|
|
if (!$res) { |
25
|
|
|
die("Include of main fails"); |
26
|
|
|
} |
27
|
|
|
// Change this following line to use the correct relative path from htdocs |
28
|
|
|
include_once(DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'); |
29
|
|
|
|
30
|
|
|
dol_include_once('/flightlog/class/bbcvols.class.php'); |
31
|
|
|
dol_include_once('/flightlog/class/bbctypes.class.php'); |
32
|
|
|
dol_include_once('/flightlog/lib/flightLog.lib.php'); |
33
|
|
|
dol_include_once('/flightlog/lib/card.lib.php'); |
34
|
|
|
dol_include_once('/flightlog/lib/PilotService.php'); |
35
|
|
|
dol_include_once('/flightballoon/bbc_ballons.class.php'); |
36
|
|
|
dol_include_once('/user/class/usergroup.class.php'); |
37
|
|
|
|
38
|
|
|
global $langs, $user; |
39
|
|
|
|
40
|
|
|
// Load traductions files requiredby by page |
41
|
|
|
$langs->load("mymodule@flightlog"); |
42
|
|
|
$langs->load("other"); |
43
|
|
|
|
44
|
|
|
$id = GETPOST('id', 'int') ?: GETPOST('idBBC_vols', 'int'); |
45
|
|
|
$action = GETPOST('action', 'alpha'); |
46
|
|
|
$permissiondellink=$user->rights->flightlog->vol->financial; |
47
|
|
|
|
48
|
|
|
$object = new Bbcvols($db); |
49
|
|
|
$extrafields = new ExtraFields($db); |
50
|
|
|
|
51
|
|
|
$receiver = new User($db); |
52
|
|
|
|
53
|
|
|
$pilotService = new PilotService($db); |
54
|
|
|
$pilot = new User($db); |
55
|
|
|
|
56
|
|
|
$organisator = new User($db); |
57
|
|
|
|
58
|
|
|
$flightType = new Bbctypes($db); |
59
|
|
|
$balloon = new Bbc_ballons($db); |
60
|
|
|
|
61
|
|
|
// fetch optionals attributes and labels |
62
|
|
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
63
|
|
|
|
64
|
|
|
// Load object |
65
|
|
|
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
66
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; |
67
|
|
|
|
68
|
|
|
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array |
69
|
|
|
$hookmanager->initHooks(array('bbcvols')); |
70
|
|
|
$object->ref = $object->idBBC_vols; |
71
|
|
|
|
72
|
|
|
if (!($user->rights->flightlog->vol->financial || $user->id == $object->fk_pilot)) { |
73
|
|
|
accessforbidden($langs->trans("Tu n'as pas accès au vol")); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$receiver->fetch($object->fk_receiver); |
77
|
|
|
$pilot->fetch($object->fk_pilot); |
78
|
|
|
$organisator->fetch($object->fk_organisateur); |
79
|
|
|
$flightType->fetch($object->fk_type); |
80
|
|
|
$balloon->fetch($object->BBC_ballons_idBBC_ballons); |
81
|
|
|
|
82
|
|
|
llxHeader('', $langs->trans('financial of flight'), ''); |
83
|
|
|
|
84
|
|
|
$head = prepareFlightTabs($object); |
85
|
|
|
dol_fiche_head($head, 'financial', $langs->trans("Vol")); |
86
|
|
|
|
87
|
|
|
$linkback = '<a href="' . DOL_URL_ROOT . '/flightlog/list.php">' . $langs->trans("BackToList") . '</a>'; |
88
|
|
|
print $form->showrefnav($object, "idBBC_vols", $linkback, true, "idBBC_vols"); |
89
|
|
|
|
90
|
|
|
print '<table class="border centpercent">' . "\n"; |
91
|
|
|
|
92
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("FieldidBBC_vols") . '</td><td>' . $object->idBBC_vols . '</td></tr>'; |
93
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("Fielddate") . '</td><td>' . dol_print_date($object->date) . '</td></tr>'; |
94
|
|
|
|
95
|
|
|
if ($user->rights->flightlog->vol->financial) { |
96
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("Fieldis_facture") . '</td><td>' . $object->getLibStatut(5). '</td></tr>'; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("Fieldkilometers") . '</td><td>' . $object->kilometers . ' KM</td></tr>'; |
100
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("Fieldjustif_kilometers") . '</td><td>' . $object->justif_kilometers . '</td></tr>'; |
101
|
|
|
if(!$object->isLinkedToOrder()){ |
102
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("Fieldcost") . '</td><td>' . $object->cost . " " . $langs->getCurrencySymbol($conf->currency) . '</td></tr>'; |
103
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_receiver") . '</td><td>' . $receiver->getNomUrl(1) . '</td></tr>'; |
104
|
|
|
}else{ |
105
|
|
|
print '<tr><td class="fieldrequired">' . $langs->trans("Order") . '</td><td>' . $object->getOrder()->getNomUrl(1). '</td></tr>'; |
106
|
|
|
} |
107
|
|
|
print '</table>'; |
108
|
|
|
|
109
|
|
|
dol_fiche_end(); |
110
|
|
|
|
111
|
|
|
// Buttons |
112
|
|
|
print '<div class="tabsAction">' . "\n"; |
113
|
|
|
|
114
|
|
View Code Duplication |
if($user->rights->flightlog->vol->financial && $object->fk_type == 2 && !$object->hasFacture()){ |
|
|
|
|
115
|
|
|
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"; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
print '</div>' . "\n"; |
119
|
|
|
|
120
|
|
|
if($user->rights->flightlog->vol->financial){ |
121
|
|
|
print '<div class="fichecenter"><div class="fichehalfleft">'; |
122
|
|
|
$form->showLinkedObjectBlock($object); |
123
|
|
|
print '</div></div>'; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
// End of page |
127
|
|
|
llxFooter(); |
128
|
|
|
$db->close(); |
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.