-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
220 lines (178 loc) · 6.14 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="http://w2ui.com/src/w2ui-1.4.2.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript" src="http://w2ui.com/src/w2ui-1.4.2.min.js"></script>
<title>THYP Yann MAHUET</title>
</head>
<body>
<header>
<h1>Partiel</h1>
<h2>Professeur : Samuel Szoniecky</h2>
<h3>Etudiant : Yann Mahuet</h3>
</header>
<br>
<h3>Personnes : </h3>
<div id="grid" style="width: 100%; height: 400px;"></div>
<br>
Chercher les Colis pour l'ID d'un user :
<input type="text" name="id_personne" id="id_pers" value=""/>
<button onclick="showColisUser();">Submit</button>
<br>
<div id="grid_colis_user" style="width: 100%; height: 400px;"></div>
<br>
Céer une personne :<br>
Nom : <input type="text" id="id_nomC" value=""/><br>
Prenom : <input type="text" id="id_prenomC" value=""/><br>
Adresse : <input type="text" id="id_AddC" value=""/><br>
<button onclick="createUser();">Submit</button>
<br>
Céer un colis :<br>
Id de l'utilisateur : <input type="text" id="id_personneC" value=""/><br>
<button onclick="createColis();">Submit</button>
<br>
Delete un user et ces colis :<br>
Id de l'utilisateur : <input type="text" id="id_personneD" value=""/><br>
<button onclick="deleteUserAndColis();">Submit</button>
<br>
Delete un user :<br>
Id de l'utilisateur : <input type="text" id="id_personneDOnly" value=""/><br>
<button onclick="deleteUser();">Submit</button>
<br>
<!-- <button class="btn" onclick="showChanged()">Get Changed</button> -->
<script type="text/javascript">
var tab_w2;
var ready = 0;
var list_documents;
var id_user = 1;
function getAllUsers(){
var data = {"action":"getAllUsers"};
$.ajax({
url: 'r.php',
data: data,
success: function(html){
console.log('fct to get all personnes');
list_documents = JSON.parse(html);
prepareRecordsUsers();
}
});
}
function prepareRecordsUsers(){
for (i = 0; i < list_documents.length; i++){
var tab_temp = list_documents[i];
w2ui['grid'].add({ recid: tab_temp[0], Nom: tab_temp[1], Prenom: tab_temp[2], Addresse: tab_temp[3]});
}
}
$(function () {
$('#grid').w2grid({
name: 'grid',
show: {
toolbar: true,
footer: true,
},
columns: [
{ field: 'recid', caption: 'ID', size: '250px', sortable: true, resizable: true },
{ field: 'Nom', caption: 'Nom', size: '250px', sortable: true, resizable: true, editable: { type: 'text' }},
{ field: 'Prenom', caption: 'Prénom', size: '250px', sortable: true, resizable: true, editable: { type: 'text' }},
{ field: 'Addresse', caption: 'Addresse', size: '250px', sortable: true, resizable: true, editable: { type: 'text' }},
],
});
getAllUsers();
});
function showChanged() {
console.log(w2ui['grid'].getChanges());
//w2alert('Changed records are displayed in the console');
}
function getColisIfUser(){
var data = {"action":"getColisIfUser", "id_personne":id_user};
$.ajax({
url: 'r.php',
data: data,
success: function(html){
console.log('fct to get all Colis for 1 user');
list_documents = JSON.parse(html);
console.log(list_documents);
prepareRecordsColisUser();
}
});
}
function prepareRecordsColisUser(){
for (i = 0; i < list_documents.length; i++){
var tab_temp = list_documents[i];
w2ui['grid_colis_user'].add({ recid: tab_temp[0], Nom: tab_temp[1], Prenom: tab_temp[2], idColis: tab_temp[3]});
}
}
$(function () {
$('#grid_colis_user').w2grid({
name: 'grid_colis_user',
show: {
toolbar: true,
footer: true,
},
columns: [
{ field: 'recid', caption: 'ID', size: '250px', sortable: true, resizable: true },
{ field: 'Nom', caption: 'Nom', size: '250px', sortable: true, resizable: true, editable: { type: 'text' }},
{ field: 'Prenom', caption: 'Prénom', size: '250px', sortable: true, resizable: true, editable: { type: 'text' }},
{ field: 'idColis', caption: 'ID Colis', size: '250px', sortable: true, resizable: true},
],
});
getColisIfUser();
});
function showChanged() {
console.log(w2ui['grid'].getChanges());
//w2alert('Changed records are displayed in the console');
}
function showColisUser(){
id_user = document.getElementById("id_pers").value;
}
function createUser(){
console.log("Create personne");
var data = {"action":"personne", "nom":document.getElementById("id_nomC").value, "prenom":document.getElementById("id_prenomC").value, "adresse":document.getElementById("id_AddC").value};
$.ajax({
url: 'c.php',
data: data,
success: function(html){
console.log('fct create personne ok');
}
});
}
function createColis(){
console.log("Create colis");
var data = {"action":"colis", "id_personne":document.getElementById("id_personneC").value};
$.ajax({
url: 'c.php',
data: data,
success: function(html){
console.log('fct create Colis ok');
}
});
}
function deleteUserAndColis(){
console.log("Delete user and colis");
var data = {"action":"personneColis", "id_personne":document.getElementById("id_personneD").value};
$.ajax({
url: 'd.php',
data: data,
success: function(html){
console.log('fct delete user and colis ok');
}
});
}
function deleteUser(){
console.log("Delete user and colis");
console.log(document.getElementById("id_personneDOnly").value);
var data = {"action":"personne", "id_personne":document.getElementById("id_personneDOnly").value};
$.ajax({
url: 'd.php',
data: data,
success: function(html){
console.log('fct delete ok');
}
});
}
</script>
</body>
</html>