Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tutorat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZHANG David
tutorat
Commits
a3fdf02e
Commit
a3fdf02e
authored
4 months ago
by
ZHANG David
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
b7d68b71
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/view_reports.php
+75
-0
75 additions, 0 deletions
code/view_reports.php
with
75 additions
and
0 deletions
code/view_reports.php
0 → 100644
+
75
−
0
View file @
a3fdf02e
<?php
include
'config.php'
;
session_start
();
// Vérifiez si l'utilisateur est connecté et s'il est un administrateur
if
(
!
isset
(
$_SESSION
[
'user'
])
||
$_SESSION
[
'user'
][
'role'
]
!==
'admin'
)
{
header
(
'Location: login.php'
);
exit
;
}
$user
=
$_SESSION
[
'user'
];
// Récupérer les données pour les statistiques
$total_users
=
$db
->
query
(
"SELECT COUNT(*) AS total FROM User"
)
->
fetch
(
PDO
::
FETCH_ASSOC
)[
'total'
];
$active_users
=
$db
->
query
(
"SELECT COUNT(*) AS active FROM User WHERE status = TRUE"
)
->
fetch
(
PDO
::
FETCH_ASSOC
)[
'active'
];
$inactive_users
=
$db
->
query
(
"SELECT COUNT(*) AS inactive FROM User WHERE status = FALSE"
)
->
fetch
(
PDO
::
FETCH_ASSOC
)[
'inactive'
];
// Récupérer les détails de tous les utilisateurs
$users
=
$db
->
query
(
"SELECT id, first_name, last_name, email, role, status FROM User"
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
?>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
User Reports
</title>
<link
rel=
"stylesheet"
href=
"style.css"
><style>
</
head
>
<
body
>
<?php
include
'sidebar.php'
;
?>
<
div
class
=
"main-content"
>
<
div
class
=
"view-report"
>
<
h1
>
User
Reports
</
h1
>
<
div
class
=
"stats"
>
<
div
class
=
"stat"
>
<
h2
>
<?=
$total_users
?>
</
h2
>
<
p
>
Total
Users
</
p
>
</
div
>
<
div
class
=
"stat"
>
<
h2
>
<?=
$active_users
?>
</
h2
>
<
p
>
Active
Users
</
p
>
</
div
>
<
div
class
=
"stat"
>
<
h2
>
<?=
$inactive_users
?>
</
h2
>
<
p
>
Inactive
Users
</
p
>
</
div
>
</
div
>
<
table
>
<
thead
>
<
tr
>
<
th
>
ID
</
th
>
<
th
>
Name
</
th
>
<
th
>
Email
</
th
>
<
th
>
Role
</
th
>
<
th
>
Status
</
th
>
</
tr
>
</
thead
>
<
tbody
>
<?php
foreach
(
$users
as
$user
)
:
?>
<
tr
>
<
td
>
<?=
htmlspecialchars
(
$user
[
'id'
])
?>
</
td
>
<
td
>
<?=
htmlspecialchars
(
$user
[
'first_name'
]
.
' '
.
$user
[
'last_name'
])
?>
</
td
>
<
td
>
<?=
htmlspecialchars
(
$user
[
'email'
])
?>
</
td
>
<
td
>
<?=
htmlspecialchars
(
ucfirst
(
$user
[
'role'
]))
?>
</
td
>
<
td
class
=
"
<?=
$user
[
'status'
]
?
'status-active'
:
'status-inactive'
?>
"
>
<?=
$user
[
'status'
]
?
'Active'
:
'Inactive'
?>
</
td
>
</
tr
>
<?php
endforeach
;
?>
</
tbody
>
</
table
>
</
div
>
</
div
>
</
body
>
</
html
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment