These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * \file mypage.php |
||
4 | * \ingroup mymodule |
||
5 | * \brief Example PHP page. |
||
6 | * |
||
7 | * read flights |
||
8 | */ |
||
9 | |||
10 | // Load Dolibarr environment |
||
11 | if (false === (@include '../main.inc.php')) { // From htdocs directory |
||
12 | require '../../documents/custom/main.inc.php'; // From "custom" directory |
||
13 | } |
||
14 | |||
15 | global $db, $langs, $user; |
||
16 | |||
17 | dol_include_once('/flightLog/class/bbcvols.class.php'); |
||
18 | dol_include_once("/flightBalloon/bbc_ballons.class.php"); |
||
19 | dol_include_once('/flightLog/class/bbctypes.class.php'); |
||
20 | dol_include_once("/flightLog/lib/flightLog.lib.php"); |
||
21 | |||
22 | // Load translation files required by the page |
||
23 | $langs->load("mymodule@mymodule"); |
||
24 | |||
25 | // Get parameters |
||
26 | $myparam = isset($_GET["myparam"]) ? $_GET["myparam"] : ''; |
||
27 | |||
28 | // Protection if the user can't acces to the module |
||
29 | if (!$user->rights->flightLog->vol->access) { |
||
30 | accessforbidden(); |
||
31 | } |
||
32 | |||
33 | |||
34 | /* * ***************************************************************** |
||
35 | * ACTIONS |
||
36 | * |
||
37 | * Put here all code to do according to value of "action" parameter |
||
38 | * ****************************************************************** */ |
||
39 | |||
40 | //l'utilisateur a le droit de selectionner le ballon qu'il veut |
||
41 | if (isset($_GET["ballon"])) { |
||
42 | $idBallon = $_GET['ballon']; |
||
43 | } else { |
||
44 | //l'utilisateur n'a pas le choix du ballon |
||
45 | //il est titulaire d'un ballon |
||
46 | $query = 'SELECT * FROM llx_bbc_ballons'; |
||
47 | if (!$user->rights->flightLog->vol->detail) { |
||
48 | $query.= ' WHERE `fk_responsable` = ' . $user->id; |
||
49 | $query.= ' OR `fk_co_responsable` = ' . $user->id; |
||
50 | } |
||
51 | $resql = $db->query($query); |
||
52 | View Code Duplication | if ($resql) { |
|
0 ignored issues
–
show
|
|||
53 | $num = $db->num_rows($resql); |
||
54 | $i = 0; |
||
55 | if ($num) { |
||
56 | // print'</tr>'; |
||
57 | while ($i < $num) { |
||
58 | $obj = $db->fetch_object($resql); //vol |
||
59 | if ($obj) { |
||
60 | $idBallon = ($obj->rowid); |
||
61 | } |
||
62 | $i++; |
||
63 | } |
||
64 | } else { |
||
65 | //il n'est pas titulaire d'un ballon |
||
66 | accessforbidden("Vous n'êtes pas titulaire du ballon"); |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 | if ($idBallon != -1) { |
||
71 | |||
72 | //balloon with ID |
||
73 | $ballon = New Bbc_ballons($db); |
||
74 | |||
75 | //date |
||
76 | $datep = dol_mktime(-1, -1, -1, $_GET["apmonth"], $_GET["apday"], $_GET["apyear"]); |
||
77 | $datef = dol_mktime(-1, -1, -1, $_GET["p2month"], $_GET["p2day"], $_GET["p2year"]); |
||
78 | |||
79 | if ($ballon->fetch($idBallon) == -1) { |
||
80 | print "ERROR" . $idBallon . "<br/>"; |
||
81 | } |
||
82 | |||
83 | //titulaire with ballon ID |
||
84 | $titulaire = new User($db); |
||
85 | $titulaire->fetch($ballon->fk_responsable); |
||
86 | //flight with balloon ID |
||
87 | $query = 'SELECT *, TIMEDIFF(heureA,heureD) AS time FROM llx_bbc_vols'; |
||
88 | $query.= ' WHERE `BBC_ballons_idBBC_ballons` = ' . $ballon->id; |
||
89 | if ($datep) { |
||
90 | $query.= ' AND date >= \'' . dol_print_date($datep, 'dayrfc') . '\''; |
||
91 | } |
||
92 | if ($datef) { |
||
93 | $query.= ' AND date <= \'' . dol_print_date($datef, 'dayrfc') . '\''; |
||
94 | } |
||
95 | |||
96 | $query.= ' ORDER BY date'; |
||
97 | |||
98 | $resql = $db->query($query); |
||
99 | } |
||
100 | |||
101 | |||
102 | |||
103 | /* * ************************************************* |
||
104 | * PAGE |
||
105 | * |
||
106 | * Put here all code to build page |
||
107 | * ************************************************** */ |
||
108 | |||
109 | llxHeader('', 'Carnet de vol', ''); |
||
110 | if ($msg && $idBallon != -1) { |
||
111 | print $msg; |
||
112 | } else { |
||
113 | $form = new Form($db); |
||
114 | |||
115 | print ' |
||
116 | <div class="tabs"> |
||
117 | <a id="active" class="tab" href="readFlightsBalloon.php?ballon=' . $idBallon . '">Carnet de vol</a> |
||
118 | <a class="tab" href="readBalloonInc.php?ballon=' . $idBallon . '">Incidents</a> |
||
119 | </div>'; |
||
120 | print '<div class="tabBar">'; |
||
121 | print "<form name='readBalloon' action=\"readFlightsBalloon.php\" method=\"get\">\n"; |
||
122 | print '<input type="hidden" name="mode" value="SELECT">'; |
||
123 | print '<table width="100%" class="border">'; |
||
124 | print '<tr><td>Ballon</td><td colspan="3">'; |
||
125 | if ($user->rights->flightLog->vol->detail) { |
||
126 | select_balloons($idBallon); |
||
127 | } else { |
||
128 | $query2 = 'SELECT * FROM llx_bbc_ballons'; |
||
129 | $query2.= ' WHERE `fk_responsable` = ' . $user->id; |
||
130 | $query2.= ' OR `fk_co_responsable` = ' . $user->id; |
||
131 | $resql2 = $db->query($query2); |
||
132 | if ($resql2) { |
||
133 | $num = $db->num_rows($resql2); |
||
134 | $i = 0; |
||
135 | if ($num) { |
||
136 | print '<select name="ballon" class="flat">'; |
||
137 | while ($i < $num) { |
||
138 | $obj = $db->fetch_object($resql2); //vol |
||
139 | print '<option ' . ($obj->rowid == $idBallon ? 'selected="selected"' : '') . ' value="' . $obj->rowid . '">' . $obj->immat . '</option>'; |
||
140 | $i++; |
||
141 | } |
||
142 | print '</select>'; |
||
143 | } else { |
||
144 | //il n'est pas titulaire d'un ballon |
||
145 | accessforbidden("Vous n'êtes pas titulaire du ballon"); |
||
146 | } |
||
147 | } |
||
148 | } |
||
149 | |||
150 | print'</td></tr>'; |
||
151 | //titulaire |
||
152 | print '<tr>'; |
||
153 | print '<td>Titulaire</td>'; |
||
154 | print '<td>' . $titulaire->getLoginUrl(1) . '</td>'; |
||
155 | print '</tr>'; |
||
156 | //Vol initial |
||
157 | print '<tr>'; |
||
158 | print '<td>Bapteme</td>'; |
||
159 | print '<td>' . dol_print_date($ballon->date, 'dayrfc') . '</td>'; |
||
160 | print '</tr>'; |
||
161 | |||
162 | $num = 0; |
||
163 | View Code Duplication | if ($resql) { |
|
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. ![]() |
|||
164 | $num = $db->num_rows($resql); |
||
165 | //Nbr de vols |
||
166 | print '<tr>'; |
||
167 | print '<td>Nombre de vol(s)</td>'; |
||
168 | print '<td>' . $num . '</td>'; |
||
169 | print '</tr>'; |
||
170 | } |
||
171 | // Date start |
||
172 | View Code Duplication | if (GETPOST('datep', 'int', 1)) |
|
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. ![]() |
|||
173 | $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); |
||
174 | print '<tr><td width="30%" nowrap="nowrap"><span>Debut</span></td><td>'; |
||
175 | $form->select_date($datep, 'ap', 0, 0, 1, "readBalloon", 1, 1, 0, 0); |
||
176 | print '</td></tr>'; |
||
177 | |||
178 | // Date end |
||
179 | View Code Duplication | if (GETPOST('datef', 'int', 1)) |
|
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. ![]() |
|||
180 | $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); |
||
181 | print '<tr><td>Fin</span></td><td>'; |
||
182 | $form->select_date($datef, 'p2', 0, 0, 1, "readBalloon", 1, 1, 0, 0); |
||
183 | print '</td></tr>'; |
||
184 | print '<tr><td colspan="4" align="center"><input type="submit" class="button" name="submit" value="Rafraichir"></td></tr></table>'; |
||
185 | print '</form></div>'; |
||
186 | |||
187 | print '<table class="border" width="100%">'; |
||
188 | $i = 0; |
||
189 | View Code Duplication | if ($num) { |
|
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. ![]() |
|||
190 | print '<tr class="liste_titre">'; |
||
191 | print '<td class="liste_titre"> identifiant </td>'; |
||
192 | print '<td class="liste_titre"> Type </td>'; |
||
193 | print '<td class="liste_titre"> Date </td>'; |
||
194 | print '<td class="liste_titre"> Ballon </td>'; |
||
195 | print '<td class="liste_titre"> Pilote </td>'; |
||
196 | print '<td class="liste_titre"> Lieu depart </td>'; |
||
197 | print '<td class="liste_titre"> Lieu arrivee </td>'; |
||
198 | print '<td class="liste_titre"> Heure depart</td>'; |
||
199 | print '<td class="liste_titre"> Heure Arrivee </td>'; |
||
200 | print '<td class="liste_titre"> Duree (min) </td>'; |
||
201 | print '<td class="liste_titre"> Nbr Pax </td>'; |
||
202 | print '<td class="liste_titre"> Rem </td>'; |
||
203 | print '<td class="liste_titre"> Incidents </td>'; |
||
204 | print '<td class="liste_titre"> KM </td>'; |
||
205 | print '<td class="liste_titre"> Justificatif KM </td>'; |
||
206 | if ($user->rights->flightLog->vol->status) { |
||
207 | print '<td class="liste_titre"> Statut </td>'; |
||
208 | } |
||
209 | print'</tr>'; |
||
210 | while ($i < $num) { |
||
211 | $obj = $db->fetch_object($resql); //vol |
||
212 | print '<tr>'; |
||
213 | if ($obj) { |
||
214 | $pilot = New User($db); //pilot |
||
215 | $pilot->fetch($obj->fk_pilot); |
||
216 | print '<td><a href="fiche.php?vol=' . $obj->idBBC_vols . '">' . $obj->idBBC_vols . '</a></td>'; |
||
217 | print '<td>' . $obj->fk_type . '</td>'; |
||
218 | print '<td>' . $obj->date . '</td>'; |
||
219 | print '<td>' . $ballon->immat . '</td>'; |
||
220 | print '<td>' . $pilot->getNomUrl(). '</td>'; |
||
221 | print '<td>' . $obj->lieuD . '</td>'; |
||
222 | print '<td>' . $obj->lieuA . '</td>'; |
||
223 | print '<td>' . $obj->heureD . '</td>'; |
||
224 | print '<td>' . $obj->heureA . '</td>'; |
||
225 | print '<td>' . $obj->time . '</td>'; |
||
226 | print '<td>' . $obj->nbrPax . '</td>'; |
||
227 | print '<td>' . $obj->remarque . '</td>'; |
||
228 | print '<td>' . $obj->incidents . '</td>'; |
||
229 | print '<td>' . $obj->kilometers . '</td>'; |
||
230 | print '<td>' . $obj->justif_kilometers . '</td>'; |
||
231 | if ($user->rights->flightLog->vol->status) { |
||
232 | $vol = new Bbcvols($db); |
||
233 | $vol->fetch($obj->idBBC_vols); |
||
234 | print '<td>' . $vol->getStatus().'</td>'; |
||
235 | } |
||
236 | } |
||
237 | print'</tr>'; |
||
238 | $i++; |
||
239 | } |
||
240 | } |
||
241 | print'</table>'; |
||
242 | } |
||
243 | |||
244 | llxFooter(); |
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.