-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdto.students.php
More file actions
141 lines (130 loc) · 6.22 KB
/
dto.students.php
File metadata and controls
141 lines (130 loc) · 6.22 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
<?php
/*
Copyright 2023-2026 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 "dbi.php" ;
if ($userId == 0) {
header("Location: https://www.spa-aviation.be/resa/mobile_login.php?cb=" . urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']) , TRUE, 307) ;
exit ;
}
if (! ($userIsBoardMember or $userIsInstructor))
journalise($userId, "F", "Vous devez être administrateur ou instructeur pour voir cette page.") ;
$header_postamble = '<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">' ;
require_once 'mobile_header5.php' ;
require_once 'dto.class.php' ;
if (isset($_REQUEST['fi']) and is_numeric($_REQUEST['fi']) and $_REQUEST['fi'] != '') {
$fi = $_REQUEST['fi'] ;
} else {
$fi = NULL ;
}
// Let's get some data from Odoo
require_once 'odoo.class.php' ;
$odooClient = new OdooClient($odoo_host, $odoo_db, $odoo_username, $odoo_password) ;
// Find all Odoo IDs
$sql = "SELECT odoo_id
FROM $table_person
JOIN $table_user_usergroup_map ON jom_id = user_id
WHERE group_id IN ($joomla_flying_student_group, $joomla_theory_student_group)
GROUP BY jom_id" ;
$result = mysqli_query($mysqli_link, $sql)
or journalise($userId, "F", "Cannot retrieve all Odoo ids: " . mysqli_error($mysqli_link)) ;
$ids = array() ;
while ($row = mysqli_fetch_array($result)) {
$ids[] = intval($row['odoo_id']) ;
}
mysqli_free_result($result) ;
$members = $odooClient->Read('res.partner',
[$ids],
['fields' => ['email', 'total_due']]) ;
$odoo_customers = array() ;
foreach($members as $member) {
$email = strtolower($member['email']) ;
$member['email'] = $email ; // Be sure to store the lowercase version
$odoo_customers[$email] = $member ; // Let's build a dict indexed by the email addresses
}
?>
<h2>Liste des élèves en cours de formation</h2>
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-7">
<div class="table-responsive">
<table class="table table-striped table-hover" id="students-table">
<thead>
<th>Élève</th><th>Cours théoriques</th><th>Premier/dernier vols</th><th class="d-none d-md-table-cell">Email</th><th class="d-none d-md-table-cell">Mobile</th></tr>
</thead>
<tbody class="table-group-divider">
<?php
$dto = new DTO() ;
$students = $dto->Students($fi) ;
foreach($students as $student) {
if (isset($odoo_customers[strtolower($student->email)])) {
$odoo_customer = $odoo_customers[strtolower($student->email)] ;
$blocked = ($student->blocked) ? ' <i class="bi bi-sign-stop-fill text-danger" title="This member is blocked (' . $odoo_customer['total_due'] . '€ due)"></i>' : '' ;
$bank_filled = ($odoo_customer['total_due'] < 0) ? ' <i class="bi bi-piggy-bank-fill text-success" title="This member has paid ' .
(-$odoo_customer['total_due']) . '€ for future flights"></i>' : '' ;
} else {
$blocked = '<span class="text-danger">Ce membre n\'est pas lié à un compte dans la comptabilité' . " student->email=$student->email" . '</span>' ;
$bank_filled = '' ;
}
if ($student->membershipPaid)
$membership_filled = '<i class="bi bi-person-check-fill text-success" title="Membership paid"><i>' ;
else
$membership_filled = '<i class="bi bi-person-fill-exclamation text-danger" title="Membership NOT paid"><i>' ;
if ($student->mobilePhone == '')
$mobile_phone = "<i class=\"bi bi-telephone-fill text-danger\" title=\"Pas de téléphone mobile spécifié\">" ;
else
$mobile_phone = "<a href=\"tel:$student->mobilePhone\"><i class=\"bi bi-telephone-fill\" title=\"Call on mobile\"></i></a>" ;
if ($student->daysSinceLastFlight <= 60)
$daysColor = 'text-bg-info' ;
else if ($student->daysSinceLastFlight <= 120)
$daysColor = 'text-bg-warning' ;
else
$daysColor = 'text-bg-danger' ;
print("<tr>
<td>
<a href=\"dto.student.php?student=$student->jom_id\" title=\"Display all flights\">$student->lastName, $student->firstName <i class=\"bi bi-binoculars-fill\"></i></a>
<a href=\"mailto:$student->email\"><i class=\"bi bi-envelope-fill\" title=\"Send email\"></i></a>
$mobile_phone $membership_filled $blocked $bank_filled
</td>") ;
// if ($student->theoryStudent)
print("<td>$student->theoreticalTrainingYear</td>\n") ;
// else
// print("<td>No theory</td>\n") ;
if ($student->flightStudent)
print("<td>$student->firstFlight <span class=\"badge text-bg-info\" title=\"Number of flights\"><i class=\"bi bi-airplane-fill\"></i> $student->countFlights</span><br/>
$student->lastFlight <span class=\"badge $daysColor\" title=\"Days since last flight\"><i class=\"bi bi-calendar3\"></i> $student->daysSinceLastFlight</span></td>\n") ;
else
print("<td>Not flying (theory only)</td>\n") ;
print("<td class=\"d-none d-md-table-cell\"><a href=\"mailto:$student->email\">$student->email</a></td>
<td class=\"d-none d-md-table-cell\"><a href=\"tel:$student->mobilePhone\">$student->mobilePhone</a></td>
</tr>\n") ;
}
?>
</tbody>
</table>
</div><!-- table responsive -->
</div><!-- col -->
</div><!-- row -->
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest"></script>
<script>
new window.simpleDatatables.DataTable("#students-table", {
searchable: true,
fixedHeight: false,
paging: false,
labels: {
placeholder: "Rechercher...",
noRows: "Aucune entrée trouvée",
info: "Affichage de {start} à {end} sur {rows} entrées",
}
});
</script>
</body>
</html>