Commit 44ee3209 authored by Stephane Crozat's avatar Stephane Crozat

Add super-pouvoir mail des responsables

parent 1c183986
......@@ -28,7 +28,7 @@ if (isset($_GET['mode'])) {
$view->respValidation($db->apiListResp($admin, $_SESSION['utclogin']));
}
if ($_GET['mode']=='admin') {
$view->adminFunction($_SESSION['utclogin']);
$view->adminFunction($_SESSION['utclogin'], $db->mailresp(), $db->apiStudentsAll());
}
}
else {
......
......@@ -208,18 +208,10 @@ class DB {
}
public function apiStudents($utclogin, $api) {
if ($this->isAdmin($utclogin)) {
$sql = 'SELECT *
FROM vsubscription
WHERE id=:api AND resplogin=:utclogin AND validation
ORDER BY surname, firstname' ; //TODO donner accès aux admins même si ne sont pas les resp
}
else {
$sql = 'SELECT *
FROM vsubscription
WHERE id=:api AND resplogin=:utclogin AND validation
ORDER BY surname, firstname';
}
$sql = 'SELECT *
FROM vsubscription
WHERE id=:api AND resplogin=:utclogin AND validation
ORDER BY surname, firstname';
$st = $this->conn->prepare($sql);
$st->bindValue(':api',$api,PDO::PARAM_STR);
$st->bindValue(':utclogin',$utclogin,PDO::PARAM_STR);
......@@ -228,5 +220,30 @@ class DB {
return $res;
}
public function apiStudentsAll() {
$sql = 'SELECT *
FROM vsubscription
WHERE validation
ORDER BY code, surname, firstname';
$st = $this->conn->prepare($sql);
$st->bindValue(':api',$api,PDO::PARAM_STR);
$st->bindValue(':utclogin',$utclogin,PDO::PARAM_STR);
$st->execute();
$res = $st->fetchAll(PDO::FETCH_ASSOC);
return $res;
}
public function mailResp() {
$sql = "SELECT DISTINCT u.email AS email
FROM vapi a JOIN localuser u ON a.resplogin=u.utclogin
ORDER BY u.email";
$st = $this->conn->prepare($sql);
$st->execute();
$res = $st->fetchAll(PDO::FETCH_ASSOC);
return $res;
}
}
......@@ -224,7 +224,19 @@ class Views {
}
}
public function adminFunction ($utclogin) {
echo "<p>Je dois vérifier que $utclogin a vraiment des super-pouvoirs...</p>";
public function adminFunction ($utclogin, $mailresp, $students) {
echo '<h2>Super-pouvoirs</h2>';
echo "<p>Je suis en train d'ajouter des super-pouvoirs à $utclogin...</p>";
// Resp Emails
echo '<h3>Mails aux reponsables d\'Api</h3>';
$all = '';
foreach ($mailresp as $m) {
echo "<a href='mailto:$m[email]'>$m[email]</a> |";
$all = "$all,$m[email]";
}
echo "<b><a href='mailto:$all'>[all]</a></b>";
//
}
}
......@@ -17,7 +17,6 @@ cat /var/www/html/apisub/lib/connexion.php && psql -U apisub -d apisub -h localh
# Génération CSV depuis la base Postgres
\COPY (SELECT * FROM vapi) TO '/home/stc/api.csv' CSV HEADER DELIMITER ';' QUOTE '"'
\COPY (SELECT DISTINCT mail FROM vapi) TO '/home/stc/api_ml.txt'
\COPY (SELECT * FROM vsubscription) TO '/home/stc/api_sub.csv' CSV HEADER DELIMITER ';' QUOTE '"'
\COPY (SELECT * FROM vsubscription_anonymous) TO '/home/stc/api_sub_anonymous.csv' CSV HEADER DELIMITER ';' QUOTE '"'
......
# Procédures d'import
## Import des niveaux des étudiants
## Import des niveaux des étudiants
fichier CSV : utclogin;level
```
DELETE FROM student;
\copy student FROM 'data/students.csv' DELIMITER ';'
```
## TODO
......@@ -58,4 +60,4 @@ BEGIN;
\i /home/stc/Bureau/apisub20181213.sql
SELECT pg_catalog.set_config('search_path', 'public', false);
COMMIT;
```
\ No newline at end of file
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment