-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflight_list.php
More file actions
185 lines (171 loc) · 8.03 KB
/
flight_list.php
File metadata and controls
185 lines (171 loc) · 8.03 KB
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
<?php
/*
Copyright 2014-2023 Eric Vyncke
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
require_once 'flight_header.php' ;
$pattern="";
if (isset($_REQUEST['pattern'])) {
$pattern = mysqli_real_escape_string($mysqli_link, web2db(trim($_REQUEST['pattern']))) ;
$other_filter = " AND (p_lname LIKE '%$pattern%' OR p_fname LIKE '%$pattern%' or f_description LIKE '%$pattern%' or f_reference LIKE '%$pattern%' or f_notes LIKE '%$pattern%' or p_email LIKE '%$pattern%' OR first_name LIKE '%$pattern%' OR last_name LIKE '%$pattern%') " ;
} else
$other_filter = '' ;
if (isset($_REQUEST['deleted'])) {
$deleted = ' checked' ;
$deleted_filter = '' ;
} else {
$deleted = '' ;
$deleted_filter = " AND f_date_cancelled IS NULL" ;
}
// Should check exclusive choices
if (isset($_REQUEST['if_only'])) {
$if_only = ' checked' ;
$if_only_filter = " AND f_type = 'D'" ;
} else {
$if_only = '' ;
$if_only_filter = '' ;
}
if (isset($_REQUEST['init_only'])) {
$init_only = ' checked' ;
$init_only_filter = " AND f_type = 'I'" ;
} else {
$init_only = '' ;
$init_only_filter = '' ;
}
if (isset($_REQUEST['completed']) and $_REQUEST['completed'] == "true") {
$completed = "true" ;
$completed_filter = ' AND f_date_flown IS NOT NULL' ;
$title = 'terminés' ;
} else {
$completed = "false" ;
$completed_filter = ' AND f_date_flown IS NULL' ;
$title = 'prévus' ;
}
?>
<div class="page-header hidden-xs">
<h3>Tous les vols <?=$title?></h3>
</div><!-- page header -->
<div class="row">
<form class="" action="<?=$_SERVER['PHP_SELF']?>">
<input type="hidden" name="completed" value="<?=$completed?>"/>
<!--div class="form-group"-->
<div class="checkbox col-md-offset-1 col-xs-6 col-md-2">
<label><input type="checkbox" name="deleted"<?=$deleted?> onchange="this.form.submit();">Inclure les vols annulés</label>
</div><!-- checkbox-->
<div class="checkbox col-xs-4 col-md-2">
<label><input type="checkbox" name="init_only"<?=$init_only?> onchange="this.form.submit();">Initiations seulement</label>
</div><!-- checkbox-->
<div class="checkbox col-xs-4 col-md-2">
<label><input type="checkbox" name="if_only"<?=$if_only?> onchange="this.form.submit();">Découvertes seulement</label>
</div><!-- checkbox-->
<div class="form-group">
<div class="col-xs-6 col-md-offset-1 col-md-4">
<input type="text" class="form-control" name="pattern" value="<?=db2web($pattern)?>"/>
</div>
</div> <!-- formgroup-->
<div class="form-group">
<div class="col-xs-3 col-md-1">
<input type="submit" class="btn btn-primary" name="add" value="Chercher"/>
</div><!-- col -->
</div><!-- formgroup-->
</form>
</div><!-- row -->
<table class="table table-striped table-responsive table-hover" id="allFlights">
<thead>
<tr><th>#</th><th>Réf</th><th>Actions</th><th>Créé le</th><th>Etat</th><th>Depuis</th><th>Vol</th><th id="pilots">Pilote</th><th>Type</th><th>Client</th><th>Passager</th><th>Remarque client</th><th>Notes club</th></tr>
</thead>
<tbody>
<?php
$result = mysqli_query($mysqli_link, "SELECT *, SYSDATE() AS today, SUM(fl_amount) AS payment
FROM $table_flight JOIN $table_pax_role ON f_id = pr_flight JOIN $table_pax ON pr_pax = p_id LEFT JOIN $table_person ON f_pilot = jom_id
LEFT JOIN $table_bookings AS b ON f_booking = b.r_id
LEFT JOIN $table_flights_ledger AS fl on fl_flight = f_id
WHERE pr_role = 'C' $other_filter $deleted_filter $completed_filter $if_only_filter $init_only_filter
GROUP BY f_id
ORDER BY f_id DESC")
or journalise($userId, "F", "Impossible de lister les vols: " . mysqli_error($mysqli_link));
$count=0;
while ($row = mysqli_fetch_array($result)) {
$reference = db2web($row['f_reference']) ;
$email = ($row['p_email']) ? " <a href=\"mailto:$row[p_email]\"><span class=\"glyphicon glyphicon-envelope\" title=\"Envoyer un email\"></span></a>" : "" ;
$telephone = ($row['p_tel']) ? " <a href=\"tel:$row[p_tel]\"><span class=\"glyphicon glyphicon-earphone\" title=\"Téléphoner\"></span></a>" : "" ;
$edit = " <a href=\"flight_create.php?flight_id=$row[f_id]\"><span class=\"glyphicon glyphicon-pencil\" title=\"Modifier/Annuler\"></span></a> " ;
$print = " <a href=\"flight_pdf.php?flight_id=$row[f_id]\" target=\"_blank\"><span class=\"glyphicon glyphicon-print\" title=\"Imprimer sous format PDF\"></span></a> " ;
$pay = ($row['payment'] > 0) ? "<span class=\"glyphicon glyphicon-euro\" style=\"color: green;\" title=\"Vol déjà payé\"></span>" :
" <a href=\"flight_create.php?flight_id=$row[f_id]&pay_open=true\"><span class=\"glyphicon glyphicon-euro\" style=\"color: red;\" title=\"Indiquer le paiement\"></span></a> " ;
$is_gift = ($row['f_gift'] != 0) ? ' <span class="glyphicon glyphicon-gift" style="color: red;" title="Bon cadeau"></span>' : '' ;
$type = ($row['f_type'] == 'D') ? 'découverte' : 'initiation' ;
$description = nl2br(db2web($row['f_description'])) ;
$notes = nl2br(db2web($row['f_notes'])) ;
$row_style = '' ;
if ($row['f_date_cancelled']) {
$status = "Annulé</td><td>$row[f_date_cancelled]" ;
$row_style = ' style="color: lightgray;"' ;
} else if ($row['f_expired']) {
$status = "Bon expiré</td><td>" ;
$row_style = ' style="color: lightgray;"' ;
} else if ($row['f_date_flown'])
$status = "Accompli</td><td>$row[f_date_flown]" ;
else if ($row['f_date_linked'])
$status = "Avion réservé</td><td>$row[f_date_linked]" ;
else if ($row['f_date_assigned'])
$status = "Pilote sélectionné</td><td>$row[f_date_assigned]" ;
else if ($row['fl_date'])
$status = "Paiement effectué</td><td>$row[fl_date]" ;
else
$status = "Attente paiement</td><td>" ;
if ($row['f_date_flown'])
$date_vol = "ATD $row[f_date_flown] ($row[r_plane])" ;
else if ($row['r_start'])
$date_vol = "ETD $row[r_start] ($row[r_plane])" ;
else
$date_vol = "à déterminer" ;
$passenger="";
//print("SELECT *, SYSDATE() AS today FROM rapcs_pax_role join rapcs_pax ON p_id= pr_pax WHERE pr_flight=$row[f_id] and (pr_role='P' or pr_role='S')</br>");
$resultPassenger= mysqli_query($mysqli_link, "SELECT *, SYSDATE() AS today FROM rapcs_pax_role join rapcs_pax ON p_id= pr_pax
WHERE pr_flight=$row[f_id] and (pr_role='P'or pr_role='S')")
or journalise($userId, "F", "Impossible de loader les passagers: " . mysqli_error($mysqli_link));
while ($rowPassenger = mysqli_fetch_array($resultPassenger)) {
$passenger=db2web($rowPassenger['p_fname']) . " <b>" . db2web($rowPassenger['p_lname']). "</b>";
break;
}
$count++;
print("<tr$row_style><td>$count</td><td>$reference</td><td>$edit$print$pay</td><td>$row[f_date_created]</td><td>$status</td><td>$date_vol</td>
<td>" . db2web($row['first_name']) . " <b>" . db2web($row['last_name']) . "</b></td>
<td>$type$is_gift</td>
<td>" . db2web($row['p_fname']) . " <b>" . db2web($row['p_lname']) . "$email$telephone</b></td>
<td>$passenger</td>
<td>$description</td>
<td>$notes</td></tr>\n") ;
}
?>
</tbody>
</table>
<script>
// Let sort the row by clicking on the header https://stackoverflow.com/questions/3160277/jquery-table-sort/19947532#19947532
$('th').click(function(){
var table = $(this).parents('table').eq(0)
var rows = table.find('tr:gt(0)').toArray().sort(comparer($(this).index()))
this.asc = !this.asc
if (!this.asc){rows = rows.reverse()}
for (var i = 0; i < rows.length; i++){table.append(rows[i])}
})
function comparer(index) {
return function(a, b) {
var valA = getCellValue(a, index), valB = getCellValue(b, index)
return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB)
}
}
function getCellValue(row, index){ return $(row).children('td').eq(index).text() }
</script>
<?php
require_once 'flight_trailer.php' ;
?>