|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @param int $active |
|
5
|
|
|
* |
|
6
|
|
|
* @return BbctypesLine[] |
|
7
|
|
|
*/ |
|
8
|
|
|
function fetchBbcFlightTypes($active = 1) |
|
9
|
|
|
{ |
|
10
|
|
|
global $db; |
|
11
|
|
|
|
|
12
|
|
|
$bbcTypes = new Bbctypes($db); |
|
13
|
|
|
|
|
14
|
|
|
$bbcTypes->fetchAll('', '', 0, 0, [ |
|
15
|
|
|
"active" => $active |
|
16
|
|
|
]); |
|
17
|
|
|
|
|
18
|
|
|
return $bbcTypes->lines; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Return list of flight type |
|
23
|
|
|
* |
|
24
|
|
|
* @param mixed $selected Preselected type |
|
25
|
|
|
* @param mixed $htmlname Name of field in form |
|
26
|
|
|
* @param mixed $showempty Add an empty field |
|
27
|
|
|
*/ |
|
28
|
|
|
function select_flight_type($selected = '1', $htmlname = 'type', $showempty = false) |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
global $langs; |
|
32
|
|
|
$langs->load("trips"); |
|
33
|
|
|
|
|
34
|
|
|
$types = fetchBbcFlightTypes(); |
|
35
|
|
|
|
|
36
|
|
|
print '<select class="flat js-flight-type" name="' . $htmlname . '">'; |
|
37
|
|
|
|
|
38
|
|
|
if ($showempty) { |
|
39
|
|
|
print sprintf('<option selected="%s" value=""></option>', (($selected == "" || $selected == 0 || $selected == -1) ? "selected" : "")); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
foreach ($types as $flightType) { |
|
43
|
|
|
print '<option value="' . $flightType->id . '"'; |
|
44
|
|
|
if ($flightType->numero == $selected) { |
|
45
|
|
|
print ' selected="selected"'; |
|
46
|
|
|
} |
|
47
|
|
|
print '>'; |
|
48
|
|
|
echo "T" . $flightType->numero . '-' . $flightType->nom; |
|
49
|
|
|
print "</option>"; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
print '</select>'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param string $selected |
|
57
|
|
|
* @param string $htmlname |
|
58
|
|
|
* @param int $showimmat |
|
59
|
|
|
* @param int $showDeclasse |
|
60
|
|
|
*/ |
|
61
|
|
|
function select_balloons($selected = '', $htmlname = 'ballon', $showimmat = 0, $showDeclasse = 1) |
|
62
|
|
|
{ |
|
63
|
|
|
|
|
64
|
|
|
global $db, $langs; |
|
65
|
|
|
|
|
66
|
|
|
$langs->load("trips"); |
|
67
|
|
|
print '<!-- select_balloons in form class -->'; |
|
68
|
|
|
print '<select class="flat" name="' . $htmlname . '">'; |
|
69
|
|
|
|
|
70
|
|
|
print '<option value=""'; |
|
71
|
|
|
if ($selected == -1 || $selected == '' || $selected == 0) { |
|
72
|
|
|
print ' selected="selected"'; |
|
73
|
|
|
} |
|
74
|
|
|
print '> </option>'; |
|
75
|
|
|
|
|
76
|
|
|
if (!$showDeclasse) { |
|
77
|
|
|
$resql = $db->query("SELECT B.immat,B.rowid FROM llx_bbc_ballons as B WHERE is_disable = false ORDER BY B.immat"); |
|
78
|
|
|
} else { |
|
79
|
|
|
$resql = $db->query("SELECT B.immat,B.rowid FROM llx_bbc_ballons as B ORDER BY B.immat"); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
if ($resql) { |
|
83
|
|
|
$num = $db->num_rows($resql); |
|
84
|
|
|
$i = 0; |
|
85
|
|
|
if ($num) { |
|
86
|
|
|
while ($i < $num) { |
|
87
|
|
|
$obj = $db->fetch_object($resql); |
|
88
|
|
|
if ($obj) { |
|
89
|
|
|
if ($showimmat) { |
|
90
|
|
|
print '<option value="' . $obj->immat . '"'; |
|
91
|
|
|
} else { |
|
92
|
|
|
print '<option value="' . $obj->rowid . '"'; |
|
93
|
|
|
} |
|
94
|
|
|
if ($obj->rowid == $selected) { |
|
95
|
|
|
print ' selected="selected"'; |
|
96
|
|
|
} |
|
97
|
|
|
print '>'; |
|
98
|
|
|
echo strtoupper($obj->immat); |
|
99
|
|
|
print "</option>"; |
|
100
|
|
|
} |
|
101
|
|
|
$i++; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
print '</select>'; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param null $year |
|
111
|
|
|
* @param null $pilotId |
|
112
|
|
|
* @param null $quarter |
|
113
|
|
|
* @param bool $groupBy |
|
114
|
|
|
* |
|
115
|
|
|
* @return string |
|
116
|
|
|
*/ |
|
117
|
|
|
function generateQuarterQuery($year = null, $pilotId = null, $quarter = null, $groupBy = true) |
|
118
|
|
|
{ |
|
119
|
|
|
|
|
120
|
|
|
global $db; |
|
121
|
|
|
|
|
122
|
|
|
$sql = "SELECT USR.rowid, USR.lastname, USR.firstname, QUARTER(VOL.date) as quartil "; |
|
123
|
|
|
|
|
124
|
|
|
if ($groupBy) { |
|
125
|
|
|
$sql .= " , SUM(VOL.kilometers) as SUM"; |
|
126
|
|
|
$sql .= " , COUNT(VOL.idBBC_vols) as nbrFlight"; |
|
127
|
|
|
} else { |
|
128
|
|
|
$sql .= " , VOL.*"; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
$sql .= " FROM llx_bbc_vols as VOL"; |
|
132
|
|
|
$sql .= " LEFT OUTER JOIN llx_user AS USR ON VOL.fk_pilot = USR.rowid"; |
|
133
|
|
|
$sql .= " WHERE "; |
|
134
|
|
|
$sql .= " 1 = 1 "; |
|
135
|
|
|
$sql .= " AND YEAR(VOL.date) = " . ($year ?: 'YEAR(NOW())'); |
|
136
|
|
|
$sql .= " AND ( VOL.fk_type = 1 OR VOL.fk_type = 2 ) "; |
|
137
|
|
|
|
|
138
|
|
|
if ($pilotId !== null) { |
|
139
|
|
|
$sql .= " AND USR.rowid = " . $pilotId; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
if ($quarter !== null) { |
|
143
|
|
|
$sql .= " AND QUARTER(VOL.date) = " . $quarter; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
if ($groupBy) { |
|
147
|
|
|
$sql .= " GROUP BY QUARTER(VOL.date), VOL.fk_pilot"; |
|
148
|
|
|
} |
|
149
|
|
|
$sql .= " ORDER BY QUARTER(VOL.date), VOL.fk_pilot"; |
|
150
|
|
|
|
|
151
|
|
|
return $db->escape($sql); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param int $pilotId |
|
156
|
|
|
* @param int $year |
|
157
|
|
|
* @param int $quarter |
|
158
|
|
|
* |
|
159
|
|
|
* @return array |
|
160
|
|
|
*/ |
|
161
|
|
|
function findFlightByPilotAndQuarter($pilotId, $year, $quarter) |
|
162
|
|
|
{ |
|
163
|
|
|
global $db; |
|
164
|
|
|
|
|
165
|
|
|
$sql = generateQuarterQuery($year, $pilotId, $quarter, false); |
|
166
|
|
|
$flights = []; |
|
167
|
|
|
$resql = $db->query($sql); |
|
168
|
|
|
if ($resql) { |
|
169
|
|
|
$num = $db->num_rows($resql); |
|
170
|
|
|
$i = 0; |
|
171
|
|
|
if ($num) { |
|
172
|
|
|
while ($i < $num) { |
|
173
|
|
|
$flight = $db->fetch_object($resql); |
|
174
|
|
|
if ($flight) { |
|
175
|
|
|
$flights[] = $flight; |
|
176
|
|
|
} |
|
177
|
|
|
$i++; |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
|
|
183
|
|
|
return $flights; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @param int $year |
|
188
|
|
|
* |
|
189
|
|
|
* @return array |
|
190
|
|
|
*/ |
|
191
|
|
|
function bbcKilometersByQuartil($year) |
|
192
|
|
|
{ |
|
193
|
|
|
global $db; |
|
194
|
|
|
|
|
195
|
|
|
$sql = generateQuarterQuery($year); |
|
196
|
|
|
$resql = $db->query($sql); |
|
197
|
|
|
|
|
198
|
|
|
$kmByQuartil = array(); |
|
199
|
|
|
if ($resql) { |
|
200
|
|
|
$num = $db->num_rows($resql); |
|
201
|
|
|
$i = 0; |
|
202
|
|
|
if ($num) { |
|
203
|
|
|
while ($i < $num) { |
|
204
|
|
|
$obj = $db->fetch_object($resql); //vol |
|
205
|
|
|
if ($obj) { |
|
206
|
|
|
|
|
207
|
|
|
$rowId = $obj->rowid; |
|
208
|
|
|
$name = $obj->lastname; |
|
209
|
|
|
$firstname = $obj->firstname; |
|
210
|
|
|
$sum = $obj->SUM; |
|
211
|
|
|
$quartil = $obj->quartil; |
|
212
|
|
|
|
|
213
|
|
|
$kmByQuartil[$rowId]["name"] = $name; |
|
214
|
|
|
$kmByQuartil[$rowId]["name"] = $name; |
|
215
|
|
|
$kmByQuartil[$rowId]["name"] = $name; |
|
216
|
|
|
$kmByQuartil[$rowId]["firstname"] = $firstname; |
|
217
|
|
|
|
|
218
|
|
|
$kmByQuartil[$rowId]["quartil"][$quartil]["km"] = $sum; |
|
219
|
|
|
$kmByQuartil[$rowId]["quartil"][$quartil]["flight"] = $obj->nbrFlight; |
|
220
|
|
|
|
|
221
|
|
|
|
|
222
|
|
|
} |
|
223
|
|
|
$i++; |
|
224
|
|
|
} |
|
225
|
|
|
} |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
return $kmByQuartil; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* @param $kmByQuartil |
|
233
|
|
|
* @param $tauxRemb |
|
234
|
|
|
*/ |
|
235
|
|
|
function printBbcKilometersByQuartil($kmByQuartil, $tauxRemb, $unitPriceMission) |
|
236
|
|
|
{ |
|
237
|
|
|
print '<table class="border" width="100%">'; |
|
238
|
|
|
|
|
239
|
|
|
print '<tr>'; |
|
240
|
|
|
print '<td></td>'; |
|
241
|
|
|
print '<td></td>'; |
|
242
|
|
|
|
|
243
|
|
|
print '<td class="liste_titre" colspan="5">Trimestre 1 (Jan - Mars)</td>'; |
|
244
|
|
|
print '<td class="liste_titre" colspan="5">Trimestre 2 (Avr - Juin)</td>'; |
|
245
|
|
|
print '<td class="liste_titre" colspan="5">Trimestre 3 (Juil - Sept)</td>'; |
|
246
|
|
|
print '<td class="liste_titre" colspan="5">Trimestre 4 (Oct - Dec)</td>'; |
|
247
|
|
|
print '<td class="liste_titre" >Total</td>'; |
|
248
|
|
|
|
|
249
|
|
|
print '</tr>'; |
|
250
|
|
|
|
|
251
|
|
|
print '<tr class="liste_titre">'; |
|
252
|
|
|
print '<td class="liste_titre" > Nom </td>'; |
|
253
|
|
|
print '<td class="liste_titre" > Prenom </td>'; |
|
254
|
|
|
|
|
255
|
|
|
|
|
256
|
|
|
print '<td class="liste_titre" > # T1 & T2</td>'; |
|
257
|
|
|
print '<td class="liste_titre" > Forfaits pil </td>'; |
|
258
|
|
|
print '<td class="liste_titre" > Total des KM </td>'; |
|
259
|
|
|
print '<td class="liste_titre" > Remb km €</td>'; |
|
260
|
|
|
print '<td class="liste_titre" > Total € </td>'; |
|
261
|
|
|
|
|
262
|
|
|
print '<td class="liste_titre" > # T1 & T2</td>'; |
|
263
|
|
|
print '<td class="liste_titre" > Forfaits pil </td>'; |
|
264
|
|
|
print '<td class="liste_titre" > Total des KM </td>'; |
|
265
|
|
|
print '<td class="liste_titre" > Remb km €</td>'; |
|
266
|
|
|
print '<td class="liste_titre" > Total € </td>'; |
|
267
|
|
|
|
|
268
|
|
|
print '<td class="liste_titre" > # T1 & T2</td>'; |
|
269
|
|
|
print '<td class="liste_titre" > Forfaits pil </td>'; |
|
270
|
|
|
print '<td class="liste_titre" > Total des KM </td>'; |
|
271
|
|
|
print '<td class="liste_titre" > Remb km €</td>'; |
|
272
|
|
|
print '<td class="liste_titre" > Total € </td>'; |
|
273
|
|
|
|
|
274
|
|
|
print '<td class="liste_titre" > # T1 & T2</td>'; |
|
275
|
|
|
print '<td class="liste_titre" > Forfaits pil </td>'; |
|
276
|
|
|
print '<td class="liste_titre" > Total des KM </td>'; |
|
277
|
|
|
print '<td class="liste_titre" > Remb km €</td>'; |
|
278
|
|
|
print '<td class="liste_titre" > Total € </td>'; |
|
279
|
|
|
|
|
280
|
|
|
print '<td class="liste_titre" > Total € </td>'; |
|
281
|
|
|
print '</tr>'; |
|
282
|
|
|
|
|
283
|
|
|
$totalQ1 = 0; |
|
284
|
|
|
$totalQ2 = 0; |
|
285
|
|
|
$totalQ3 = 0; |
|
286
|
|
|
$totalQ4 = 0; |
|
287
|
|
|
|
|
288
|
|
|
$curMonth = date("m", time()); |
|
289
|
|
|
$curQuarter = ceil($curMonth/3); |
|
290
|
|
|
$disableColor = 'style="background-color: lightyellow;" title="N/A" data-toggle="tooltip"'; |
|
291
|
|
|
|
|
292
|
|
|
foreach ($kmByQuartil as $id => $rembKm) { |
|
293
|
|
|
$name = $rembKm["name"]; |
|
294
|
|
|
$firstname = $rembKm["firstname"]; |
|
295
|
|
|
$sumQ1 = isset($rembKm["quartil"]["1"]["km"]) ? $rembKm["quartil"]["1"]["km"] : 0; |
|
296
|
|
|
$sumQ2 = isset($rembKm["quartil"]["2"]["km"]) ? $rembKm["quartil"]["2"]["km"] : 0; |
|
297
|
|
|
$sumQ3 = isset($rembKm["quartil"]["3"]["km"]) ? $rembKm["quartil"]["3"]["km"] : 0; |
|
298
|
|
|
$sumQ4 = isset($rembKm["quartil"]["4"]["km"]) ? $rembKm["quartil"]["4"]["km"] : 0; |
|
299
|
|
|
|
|
300
|
|
|
$flightsQ1 = isset($rembKm["quartil"]["1"]["flight"]) ? $rembKm["quartil"]["1"]["flight"] : 0; |
|
301
|
|
|
$flightsQ2 = isset($rembKm["quartil"]["2"]["flight"]) ? $rembKm["quartil"]["2"]["flight"] : 0; |
|
302
|
|
|
$flightsQ3 = isset($rembKm["quartil"]["3"]["flight"]) ? $rembKm["quartil"]["3"]["flight"] : 0; |
|
303
|
|
|
$flightsQ4 = isset($rembKm["quartil"]["4"]["flight"]) ? $rembKm["quartil"]["4"]["flight"] : 0; |
|
304
|
|
|
|
|
305
|
|
|
$amoutQ1 = ($sumQ1 * $tauxRemb) + ($flightsQ1 * $unitPriceMission); |
|
306
|
|
|
$amoutQ2 = ($sumQ2 * $tauxRemb) + ($flightsQ2 * $unitPriceMission); |
|
307
|
|
|
$amoutQ3 = ($sumQ3 * $tauxRemb) + ($flightsQ3 * $unitPriceMission); |
|
308
|
|
|
$amoutQ4 = ($sumQ4 * $tauxRemb) + ($flightsQ4 * $unitPriceMission); |
|
309
|
|
|
|
|
310
|
|
|
$totalQ1 += $amoutQ1; |
|
311
|
|
|
$totalQ2 += $amoutQ2; |
|
312
|
|
|
$totalQ3 += $amoutQ3; |
|
313
|
|
|
$totalQ4 += $amoutQ4; |
|
314
|
|
|
|
|
315
|
|
|
$sumKm = ($sumQ1 + $sumQ2 + $sumQ3 + $sumQ4); |
|
316
|
|
|
$sumFlights = ($flightsQ1 + $flightsQ2 + $flightsQ3 + $flightsQ4); |
|
317
|
|
|
|
|
318
|
|
|
print '<tr>'; |
|
319
|
|
|
|
|
320
|
|
|
print '<td>' . $name . '</td>'; |
|
321
|
|
|
print '<td>' . $firstname . '</td>'; |
|
322
|
|
|
|
|
323
|
|
|
print '<td'.($curQuarter < 1 ? $disableColor: '').'>' . ($flightsQ1) . '</td>'; |
|
324
|
|
|
print '<td'.($curQuarter < 1 ? $disableColor: '').'>' . ($flightsQ1 * $unitPriceMission) . '€</td>'; |
|
325
|
|
|
print '<td'.($curQuarter < 1 ? $disableColor: '').'>' . $sumQ1 . '</td>'; |
|
326
|
|
|
print '<td'.($curQuarter < 1 ? $disableColor: '').'>' . ($sumQ1 * $tauxRemb) . '</td>'; |
|
327
|
|
|
print '<td'.($curQuarter < 1 ? $disableColor: '').'><b>' . $amoutQ1 . '€</b></td>'; |
|
328
|
|
|
|
|
329
|
|
|
print '<td '.($curQuarter < 2 ? $disableColor: '').'>' . ($flightsQ2) . '</td>'; |
|
330
|
|
|
print '<td '.($curQuarter < 2 ? $disableColor: '').'>' . ($flightsQ2 * $unitPriceMission) . '€</td>'; |
|
331
|
|
|
print '<td '.($curQuarter < 2 ? $disableColor: '').'>' . $sumQ2 . '</td>'; |
|
332
|
|
|
print '<td '.($curQuarter < 2 ? $disableColor: '').'>' . ($sumQ2 * $tauxRemb) . '</td>'; |
|
333
|
|
|
print '<td '.($curQuarter < 2 ? $disableColor: '').'><b>' . $amoutQ2 . '€</b></td>'; |
|
334
|
|
|
|
|
335
|
|
|
print '<td '.($curQuarter < 3 ? $disableColor: '').'>' . ($flightsQ3) . '</td>'; |
|
336
|
|
|
print '<td '.($curQuarter < 3 ? $disableColor: '').'>' . ($flightsQ3 * $unitPriceMission) . '€</td>'; |
|
337
|
|
|
print '<td '.($curQuarter < 3 ? $disableColor: '').'>' . $sumQ3 . '</td>'; |
|
338
|
|
|
print '<td '.($curQuarter < 3 ? $disableColor: '').'>' . ($sumQ3 * $tauxRemb) . '</td>'; |
|
339
|
|
|
print '<td '.($curQuarter < 3 ? $disableColor: '').'><b>' . $amoutQ3 . '€</b></td>'; |
|
340
|
|
|
|
|
341
|
|
|
print '<td '.($curQuarter < 4 ? $disableColor: '').'>' . ($flightsQ4) . '</td>'; |
|
342
|
|
|
print '<td '.($curQuarter < 4 ? $disableColor: '').'>' . ($flightsQ4 * $unitPriceMission) . '€</td>'; |
|
343
|
|
|
print '<td '.($curQuarter < 4 ? $disableColor: '').'>' . $sumQ4 . '</td>'; |
|
344
|
|
|
print '<td '.($curQuarter < 4 ? $disableColor: '').'>' . ($sumQ4 * $tauxRemb) . '</td>'; |
|
345
|
|
|
print '<td '.($curQuarter < 4 ? $disableColor: '').'><b>' . $amoutQ4 . '€</b></td>'; |
|
346
|
|
|
|
|
347
|
|
|
print '<td>' . (($sumFlights * $unitPriceMission) + ($sumKm * $tauxRemb)) . '€</td>'; |
|
348
|
|
|
|
|
349
|
|
|
print '</tr>'; |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
print "<td colspan='6'></td>"; |
|
353
|
|
|
print "<td>".price($totalQ1)."€</td>"; |
|
354
|
|
|
print "<td colspan='4'></td>"; |
|
355
|
|
|
print "<td>".price($totalQ2)."€</td>"; |
|
356
|
|
|
print "<td colspan='4'></td>"; |
|
357
|
|
|
print "<td>".price($totalQ3)."€</td>"; |
|
358
|
|
|
print "<td colspan='4'></td>"; |
|
359
|
|
|
print "<td>".price($totalQ4)."€</td>"; |
|
360
|
|
|
print "<td></td>"; |
|
361
|
|
|
|
|
362
|
|
|
print '</table>'; |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
366
|
|
|
* @return int[] |
|
367
|
|
|
*/ |
|
368
|
|
|
function getFlightYears() |
|
369
|
|
|
{ |
|
370
|
|
|
global $db; |
|
371
|
|
|
|
|
372
|
|
|
$results = []; |
|
373
|
|
|
|
|
374
|
|
|
$sqlYear = "SELECT DISTINCT(YEAR(llx_bbc_vols.date)) as annee FROM llx_bbc_vols "; |
|
375
|
|
|
$resql_years = $db->query($sqlYear); |
|
376
|
|
|
|
|
377
|
|
|
$num = $db->num_rows($resql_years); |
|
378
|
|
|
$i = 0; |
|
379
|
|
|
if ($num) { |
|
380
|
|
|
while ($i < $num) { |
|
381
|
|
|
$obj = $db->fetch_object($resql_years); |
|
382
|
|
|
|
|
383
|
|
|
if ($obj->annee) { |
|
384
|
|
|
$results[] = $obj->annee; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
$i++; |
|
388
|
|
|
} |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
return $results; |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
/** |
|
395
|
|
|
* @param GraphicalData $graphData |
|
396
|
|
|
* |
|
397
|
|
|
* @return GraphicalData |
|
398
|
|
|
*/ |
|
399
|
|
|
function fetchGraphByTypeAndYearData(GraphicalData $graphData) |
|
400
|
|
|
{ |
|
401
|
|
|
global $db; |
|
402
|
|
|
|
|
403
|
|
|
$sql = "SELECT YEAR(date) as year, fk_type as type,COUNT(idBBC_vols) as val FROM llx_bbc_vols GROUP BY YEAR(date), fk_type ORDER BY year,fk_type"; |
|
404
|
|
|
$resql = $db->query($sql); |
|
405
|
|
|
|
|
406
|
|
|
$num = $db->num_rows($resql); |
|
407
|
|
|
$i = 0; |
|
408
|
|
|
if ($num) { |
|
409
|
|
|
while ($i < $num) { |
|
410
|
|
|
$obj = $db->fetch_object($resql); |
|
411
|
|
|
|
|
412
|
|
|
if ($obj->year) { |
|
413
|
|
|
$graphData->addValue($obj->year, new GraphicalValue($obj->val, $obj->year, $obj->type)); |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
$i++; |
|
417
|
|
|
} |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
return $graphData; |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
/** |
|
424
|
|
|
* @return GraphicalData |
|
425
|
|
|
*/ |
|
426
|
|
|
function getGraphByTypeAndYearData() |
|
427
|
|
|
{ |
|
428
|
|
|
|
|
429
|
|
|
$flightTypes = fetchBbcFlightTypes(); |
|
430
|
|
|
|
|
431
|
|
|
$graphData = new GraphicalData(); |
|
432
|
|
|
|
|
433
|
|
|
foreach (getFlightYears() as $flightYear) { |
|
434
|
|
|
$pieceData = new YearGraphicalData($flightYear); |
|
435
|
|
|
|
|
436
|
|
|
foreach ($flightTypes as $flightType) { |
|
437
|
|
|
$pieceData->addType(new GraphicalType($flightType->id, $flightType->nom)); |
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
$graphData->addData($pieceData); |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
return fetchGraphByTypeAndYearData($graphData); |
|
444
|
|
|
} |