-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofil.php
More file actions
307 lines (254 loc) · 11.9 KB
/
Copy pathprofil.php
File metadata and controls
307 lines (254 loc) · 11.9 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
include_once $_SERVER['DOCUMENT_ROOT'].'/assets/config/functions.inc.php';
session_start();
//Classe Outils
$outil = new Outils;
$isConnected = $outil->isConnected();
if(!$isConnected) {
$outil->redirectUrl("/");
}
//Vérifier si c'est notre propre profil
if(isset($_GET['id'])) {
if($_SESSION['idUser'] == $_GET['id']) {
$outil->redirectUrl("/profil.php");
}
}
//Vérifier le profil de la personne
if(isset($_GET['id'])) {
$id = (int) $_GET['id'];
} else {
$id = (int) $_SESSION['idUser'];
}
$user = new User(
[
'IdUser' => $id
]
);
$manager = new UserManager($db);
$dataUser = $manager->recupData($user);
//Vérifier si le profil regardé est bien photographe et si se n'est pas celui de la session en cours.
if(isset($_GET['id'])) {
if($dataUser['rankUser'] != 2) {
$outil->redirectUrl('/profil.php');
}
}
//Donnée du rank
$rank = new Rank(
[
'IdRank' => (int) $dataUser['rankUser']
]
);
$rankManager = new RankManager($db);
$dataRank = $rankManager->recupRank($rank);
//Récupère les articles de l'utilisateur
$photo = new Photo(
[
'IdUserPhotographer' => $id
]
);
$managerPhoto = new PhotoManager($db);
if(!isset($_GET['id'])) {
if($dataUser['rankUser'] == 1) {
$dataPhoto = $managerPhoto->recupArticlesBuyUser($photo);
} elseif($dataUser['rankUser'] == 2) {
$dataPhoto = $managerPhoto->recupAllArticlesPhotographerNoBuy($photo);
}
} else {
$dataPhoto = $managerPhoto->recupAllArticlesPhotographerNoBuy($photo);
}
//Si le photographe clique sur le bouton pour mettre à jour la remise
if(isset($_POST['clickRemise'])) {
$user = new User(
[
'IdUser' => $id,
'ReductionCreditUser' => (int) $_POST["remise"]
]
);
$manager = new UserManager($db);
$dataUser = $manager->updateRemise($user);
$outil->redirectUrl('profil.php');
}
//Afficher le panier
$ifPhotographer = true;
if(isset($dataUser['rankUser'])) {
if($dataUser['rankUser'] == 2) {
$ifPhotographer = false;
}
}
?>
<!DOCTYPE html>
<html lang="<?= $defaultLanguage; ?>">
<head>
<?php include_once($headerMeta); ?>
<?php include_once($headerLink); ?>
<title>Profil</title>
</head>
<body>
<?php include_once($headerPath); ?>
<?php if(!isset($_GET['id'])): ?>
<section class="py-3 text-center container">
<div class="row">
<div class="col-lg-8 col-md-8 mx-auto">
<h1 class="fw-light"><?= ucfirst($dataUser['nameUser']) ?> <?= ucfirst($dataUser['surnameUser']) ?></h1>
<h5><span <?php if($dataUser['rankUser'] == 3) { echo('onclick="location.href = \'/admin/\';"'); } ?> class="badge bg-warning mt-2 mb-2"><?= ucfirst($dataRank) ?></span></h5>
<button type="button" class="btn btn-secondary"><?= number_format($dataUser['creditUser'], 2, ',', ' ') ?> Crédit<?php if($dataUser['creditUser'] > 1) {echo 's';} ?></button>
<?php if($dataUser['rankUser'] == 2): ?>
<button type="button" class="btn btn-primary" onclick="location.href = '/addPhoto.php';">Ajouter une photo</button>
<?php endif; ?>
<button type="button" class="btn btn-danger" onclick="location.href = '/unsubscribe.php';">Désinscription</button>
</div>
</div>
</section>
<section class="py-3 text-center container">
<hr>
</section>
<!-- View client -->
<?php if($dataUser['rankUser'] == 1): ?>
<?= $outil->generateTitleBlok("Galerie Photo","Bienvenue dans votre galerie photo ! Vous pouvez télécharger les images que vous avez débloqué directement depuis votre compte."); ?>
<div class="album py-5 bg-light">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<?php foreach($dataPhoto as $photo): ?>
<?= $outil->
generateImageBlockInUser(
[
$photo['titlePhoto'],
$photo['descriptionPhoto'],
"/assets/images/photos/".$photo['idPhoto'],
$photo['datePublicPhoto'],
$photo['nameTag'],
$photo['idPhoto'],
$dataUser['rankUser']
]
); ?>
<?php endforeach; ?>
</div>
</div>
</div>
<?php elseif($dataUser['rankUser'] == 2): ?>
<?= $outil->generateTitleBlok("Galerie Photo","Vous pouvez voir ici tout les photos que vous avez publié."); ?>
<div class="album py-5 bg-light">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<?php foreach($dataPhoto as $photo): ?>
<?= $outil->
generateImageBlockInUser(
[
$photo['titlePhoto'],
$photo['descriptionPhoto'],
"/assets/images/photos/".$photo['idPhoto'],
$photo['datePublicPhoto'],
$photo['nameTag'],
$photo['idPhoto'],
$photo['rankUser']
]
); ?>
<?php endforeach; ?>
</div>
</div>
</div>
<section class="py-3 container">
<hr>
</section>
<?php if($dataUser['creditUser'] > 10): ?>
<?= $outil->generateTitleBlok("Retrait", "Vous pouvez choisir une option pour échanger vos crédits en euros."); ?>
<section class="py-1 px-5 text-center container d-flex justify-content-center gap-3">
<div>
<img class='bi me-2' src='/assets/images/icons/paypal.png' height='60'>
<div>Paypal</div>
</div>
<div>
<img class='bi me-2' src='/assets/images/icons/cheque.png' height='60'>
<div>Cheque</div>
</div>
</section>
<section class="py-5 container">
<hr>
</section>
<?php else: ?>
<?= $outil->generateTitleBlok("Retrait", "Vous pouvez demander un retrait en euros quand votre montant de crédit sera suppérieur à 10."); ?>
<section class="py-2 container">
<hr>
</section>
<?php endif; ?>
<section class=" px-5 text-center container">
<form class="px-5" method="post">
<div class="input-group px-5">
<?= $outil->generateTitleBlok("Remise", "Cette option vous permet de réduire vos prix sur l'ensemble de vos photos."); ?>
<select class="form-select" aria-label="Default select example" name="remise">
<?php if(isset($dataUser['reductionCreditUser'])): ?>
<option value="<?= $dataUser['reductionCreditUser'] ?>" selected><?= $dataUser['reductionCreditUser'] ?> % de réduction</option>
<?php else: ?>
<option selected>---</option>
<?php endif; ?>
<?php if($dataUser['reductionCreditUser'] != 0): ?>
<option value="0">0 % de réduction</option>
<?php endif; ?>
<?php if($dataUser['reductionCreditUser'] != 5): ?>
<option value="5">5 % de réduction</option>
<?php endif; ?>
<?php if($dataUser['reductionCreditUser'] != 10): ?>
<option value="10">10 % de réduction</option>
<?php endif; ?>
<?php if($dataUser['reductionCreditUser'] != 15): ?>
<option value="15">15 % de réduction</option>
<?php endif; ?>
<?php if($dataUser['reductionCreditUser'] != 20): ?>
<option value="20">20 % de réduction</option>
<?php endif; ?>
<?php if($dataUser['reductionCreditUser'] != 25): ?>
<option value="25">25 % de réduction</option>
<?php endif; ?>
<?php if($dataUser['reductionCreditUser'] != 30): ?>
<option value="30">30 % de réduction</option>
<?php endif; ?>
</select>
<button class="btn btn-outline-primary" name='clickRemise' type='submit'>Mettre à jour</button>
</div>
</form>
</section>
<?php endif; ?>
<?php else: ?>
<!-- ----- PARTIE EXTERIEUR ---- -->
<section class="py-3 text-center container">
<div class="row">
<div class="col-lg-8 col-md-8 mx-auto">
<h1 class="fw-light"><?= ucfirst($dataUser['nameUser']) ?> <?= ucfirst($dataUser['surnameUser']) ?></h1>
<h5><span class="badge bg-warning mt-2 mb-2"><?= ucfirst($dataRank) ?></span></h5>
</div>
</div>
</section>
<section class="py-3 text-center container">
<hr>
</section>
<?= $outil->generateTitleBlok("Galerie Photo","Vous pouvez voir les images du photographe ici."); ?>
<div class="album py-5 bg-light">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<?php foreach($dataPhoto as $photo): ?>
<?= $outil->
generateImageBlock(
[
$photo['titlePhoto'],
$photo['descriptionPhoto'],
"/assets/images/photos/".$photo['idPhoto'],
$photo['datePublicPhoto'],
$photo['creditPricePhoto'],
$photo['nameTag'],
$photo['idPhoto'],
$photo['nameUser']." ".$photo['surnameUser'],
$photo['idUser'],
$photo['reductionCreditUser'],
$ifPhotographer
]
);
?>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php include_once($footerPath); ?>
<?php include_once($script); ?>
</body>
</html>