Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apisub
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stephane Crozat
apisub
Commits
2767f89e
Commit
2767f89e
authored
Feb 08, 2019
by
Stephane Crozat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout de la fonction d'export CSV (en JS)
parent
c2e35acb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
api.php
api.php
+0
-2
js/main.js
js/main.js
+13
-0
lib/views.php
lib/views.php
+12
-2
No files found.
api.php
View file @
2767f89e
...
...
@@ -15,9 +15,7 @@ else {
$view
->
printHtmlBegin
(
$admin
);
$view
->
printUser
(
$db
->
isResp
(
$_SESSION
[
'utclogin'
]),
$db
->
isAdmin
(
$_SESSION
[
'utclogin'
]));
$view
->
apiStudents
(
$db
->
apiStudents
(
$_SESSION
[
'utclogin'
],
$_GET
[
'api'
]));
}
?>
js/main.js
0 → 100644
View file @
2767f89e
function
download_csv
(
students
)
{
var
csv
=
''
;
students
.
forEach
(
function
(
row
)
{
csv
+=
row
.
join
(
'
,
'
);
csv
+=
"
\n
"
;
});
console
.
log
(
csv
);
var
a
=
document
.
getElementById
(
'
csvlink
'
);
a
.
href
=
'
data:text/csv;charset=utf-8,
'
+
encodeURI
(
csv
);
a
.
target
=
'
_blank
'
;
a
.
download
=
'
people.csv
'
;
a
.
click
();
}
lib/views.php
View file @
2767f89e
...
...
@@ -179,16 +179,26 @@ class Views {
public
function
apiStudents
(
$students
)
{
echo
"<hr/>"
;
if
(
isset
(
$students
[
0
]))
{
// Api Title
echo
'<h2>'
.
$this
->
printApi
(
$students
[
0
])
.
'</h2>'
;
// Api mailing list
$mailinglist
=
'mailto:'
;
foreach
(
$students
as
$s
)
{
$mailinglist
=
$mailinglist
.
"
$s[email]
,"
;
}
echo
"<div class='menu'><a href='
$mailinglist
'>[Mailing list]</a></div>"
;
// Api CSV data (for JavaScript function)
echo
'<script src="js/main.js"></script>'
;
echo
"<script>var csvstudents = [['Nom','Prénom','Niveau','Mail','Login'],"
;
foreach
(
$students
as
$s
)
{
echo
"['
$s[surname]','$s[firstname]','$s[level]','$s[email]','$s[utclogin]']
,"
;
}
echo
"];</script>"
;
// Api Menu
echo
"<div class='menu'><a href='
$mailinglist
'>[Mailing list]</a> <a id='csvlink' onclick='download_csv(csvstudents)' href=''>[Fichier CSV]</a></div>"
;
echo
"<hr/>"
;
}
else
{
echo
'<h2>Aucun inscrit</h2>'
;
echo
'<h2>Aucun inscrit
validé
</h2>'
;
}
foreach
(
$students
as
$s
)
{
echo
"<div class='student'>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment