/
profileURCA.php
208 lines (179 loc) · 8.82 KB
/
profileURCA.php
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
<?php
require_once "autoload.inc.php";
include_once "init.inc.php";
$p = new webpage("Iut Stage");
$p->appendToHead(<<<head
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
head
);
$p->appendCssUrl("style/bootstrap-3.3.5-dist/css/bootstrap.min.css");
$p->appendCssUrl("style/profileStyle.css");
//inclusion de la barre de navigation
include_once "navbar.inc.php";
if($user instanceof Etudiant || $user instanceof Enseignant){
$nom= htmlspecialchars( $user->getNom() );
$prenom = htmlspecialchars( $user->getPrenom() );
$mail = htmlspecialchars( $user->getMail() );
$tel = htmlspecialchars( $user->getTel() );
//Gestion des réponse de l'enregistrement d'un entrepreneur
if(isset($_GET['err'])){
$toggleScript="$('#alert').show();";
if($_GET['err'] == 'compteImcomplet' && $user instanceof Enseignant){
$action="danger";
$contenu = "Les champs précédé de '*' doivent être rempli pour commenter une entreprise.";
}
else{
$action="danger";
$contenu = "Les champs précédé de '*' doivent être rempli postuler à un stage.";
}
}
else{
$toggleScript="";
$action ="";
$contenu ="";
}
$p->appendJs(<<<JS
function controlInfo(){
if(document.getElementById('nom').value.match(/[A-Za-z]/)==null && document.getElementById('nom').value != ""){
document.getElementById('formNom').classList.add("has-error");
if(document.getElementById('formNom').classList.contains("has-success")){
document.getElementById('formNom').classList.remove("has-success");
}
}else{
if(document.getElementById('nom').value != ""){
document.getElementById('formNom').classList.add("has-success");
if(document.getElementById('formNom').classList.contains("has-error")){
document.getElementById('formNom').classList.remove("has-error");
}
}
}
if(document.getElementById('prenom').value.match(/[A-Za-z]/)==null && document.getElementById('prenom').value != ""){
document.getElementById('formPrenom').classList.add("has-error");
if(document.getElementById('formPrenom').classList.contains("has-success")){
document.getElementById('formPrenom').classList.remove("has-success");
}
}else{
if(document.getElementById('prenom').value != ""){
document.getElementById('formPrenom').classList.add("has-success");
if(document.getElementById('formPrenom').classList.contains("has-error")){
document.getElementById('formPrenom').classList.remove("has-error");
}
}
}
if(document.getElementById('mail').value.match(/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/)==null && document.getElementById('mail').value != ""){
document.getElementById('formMail').classList.add("has-error");
if(document.getElementById('formMail').classList.contains("has-success")){
document.getElementById('formMail').classList.remove("has-success");
}
}else{
if(document.getElementById('mail').value != ""){
document.getElementById('formMail').classList.add("has-success");
if(document.getElementById('formMail').classList.contains("has-error")){
document.getElementById('formMail').classList.remove("has-error");
}
}
}
if(document.getElementById('tel').value.match(/(0|\\+33|0033)[1-9][0-9]{8}/) == null && document.getElementById('tel').value != ""){
document.getElementById('formTel').classList.add("has-error");
if(document.getElementById('formTel').classList.contains("has-success")){
document.getElementById('formTel').classList.remove("has-success");
}
}else{
if(document.getElementById('tel').value != ""){
document.getElementById('formTel').classList.add("has-success");
if(document.getElementById('formTel').classList.contains("has-error")){
document.getElementById('formTel').classList.remove("has-error");
}
}
}
}
JS
);
$p->appendContent(<<<HTML
<div class="container">
<div class="row"> <!-- ROW -->
<div id="alert" class="alert alert-{$action} collapse" role="alert">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>{$contenu}</strong>
</div>
<div class="col-md-12">
<div class="tab-content">
<div class="tab-pane fade in active" id="profil">
<div class="panel panel-default">
<div class="blue panel-heading">
<h3 class="panel-title"><strong>Information Profil : {$user->getId()}</strong></h3>
</div>
<div class="panel-body">
<strong>Nom : </strong>{$nom}<br>
<strong>Prénom : </strong>{$prenom}<br>
<strong>Adresse mail : </strong>{$mail}<br>
<strong>Téléphone : </strong>{$tel}
</div>
</div>
<div class="panel panel-default">
<div class="blue panel-heading">
<h3 class="panel-title"><strong>Modification Profil</strong></h3>
</div>
<div class="panel-body">
<form method="POST" action="updateProfil.php">
<div class="form-group" id="formNom">
<label for="nomEtudiant">Nom*</label>
<input type="text" class="form-control" id="nom" name="nom" pattern="[a-zA-Z].+" placeholder="{$nom}" value="{$nom}" onChange="controlInfo()">
</div>
<div class="form-group" id="formPrenom">
<label for="prenomEtudiant">Prenom*</label>
<input type="text" class="form-control" id="prenom" name="prenom" pattern="[a-zA-Z].+" placeholder="{$prenom}" value="{$prenom}" onChange="controlInfo()">
</div>
<div class="form-group" id="formMail">
<label for="mailEtudiant">Email*</label>
<input type="email" class="form-control" id="mail" name="mail" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" placeholder="{$mail}" value="{$mail}" onChange="controlInfo()">
</div>
<div class="form-group" id="formTel">
<label for="telEtudiant">Telephone</label>
<input type="text" class="form-control" id="tel" name="tel" placeholder="{$tel}" value="{$tel}" onChange="controlInfo()">
</div>
<button type="submit" class="btn btn-success " name="maj"><strong>Mise à jour</strong></button>
</form>
</div>
</div>
<div class="panel panel-default" >
<div class="red panel-heading">
<h3 class="panel-title"><strong>Supprimer le compte</strong></h3>
</div>
<div class="panel-body">
</div>
</div>
</div><!-- end Profil-->
</div>
</div>
</div> <!-- end row -->
</div>
HTML
);
$p->appendToFooter(<<<Footer
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="style/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
$(".nav-tabs a").click(function(){
$(this).tab('show');
});
//affiche le message d'alerte
{$toggleScript}
});
</script>
Footer
);
echo $p->toHTML();
}
else if($user instanceof Administrateur){
header("Location: pageAdmin.php");
}