|
@@ -1,20 +1,11 @@
|
1
|
1
|
<!DOCTYPE html>
|
2
|
2
|
<html>
|
3
|
3
|
<head>
|
|
4
|
+ <title>Miembros</title>
|
4
|
5
|
<style>
|
5
|
6
|
body {
|
6
|
7
|
margin:0px;
|
7
|
8
|
}
|
8
|
|
- table, th, td {
|
9
|
|
- border: 1px solid black;
|
10
|
|
- border-collapse: collapse;
|
11
|
|
- }
|
12
|
|
- th, td {
|
13
|
|
- padding: 5px;
|
14
|
|
- }
|
15
|
|
- th {
|
16
|
|
- text-align: left;
|
17
|
|
- }
|
18
|
9
|
|
19
|
10
|
.container {
|
20
|
11
|
height:100%;
|
|
@@ -59,7 +50,143 @@
|
59
|
50
|
height: 54px;
|
60
|
51
|
}
|
61
|
52
|
|
|
53
|
+ /* The Modal (background) */
|
|
54
|
+ .modal {
|
|
55
|
+ display: none; /* Hidden by default */
|
|
56
|
+ position: fixed; /* Stay in place */
|
|
57
|
+ z-index: 1; /* Sit on top */
|
|
58
|
+ padding-top: 100px; /* Location of the box */
|
|
59
|
+ left: 0;
|
|
60
|
+ top: 0;
|
|
61
|
+ width: 100%; /* Full width */
|
|
62
|
+ height: 100%; /* Full height */
|
|
63
|
+ overflow: auto; /* Enable scroll if needed */
|
|
64
|
+ background-color: rgb(0,0,0); /* Fallback color */
|
|
65
|
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ /* Modal Content */
|
|
69
|
+ .modal-content {
|
|
70
|
+ background-color: #fefefe;
|
|
71
|
+ margin: auto;
|
|
72
|
+ padding: 20px;
|
|
73
|
+ border: 1px solid #888;
|
|
74
|
+ max-width: 10%;
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ /* The Close Button */
|
|
78
|
+ .close {
|
|
79
|
+ color: #aaaaaa;
|
|
80
|
+ float: right;
|
|
81
|
+ font-size: 28px;
|
|
82
|
+ font-weight: bold;
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ .close:hover, .close:focus {
|
|
86
|
+ color: #000;
|
|
87
|
+ text-decoration: none;
|
|
88
|
+ cursor: pointer;
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ table.dataTable tbody th, table.dataTable tbody td {
|
|
92
|
+ text-align: center;
|
|
93
|
+ }
|
|
94
|
+}
|
|
95
|
+
|
62
|
96
|
</style>
|
|
97
|
+ <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css"/>
|
|
98
|
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
|
99
|
+ <script type="text/javascript" src="//cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js">
|
|
100
|
+ </script>
|
|
101
|
+ <script>
|
|
102
|
+ $(document).ready(function() {
|
|
103
|
+ $('#membersTable').DataTable({
|
|
104
|
+ "columnDefs": [ {
|
|
105
|
+ "targets": 0,
|
|
106
|
+ "orderable": false
|
|
107
|
+ }, {
|
|
108
|
+ "targets": 11,
|
|
109
|
+ "orderable": false
|
|
110
|
+ }, {
|
|
111
|
+ "targets": 12,
|
|
112
|
+ "orderable": false
|
|
113
|
+ } ],
|
|
114
|
+ "order": [[ 1, "asc" ]]
|
|
115
|
+ });
|
|
116
|
+
|
|
117
|
+ $('.editor').click(function(e) {
|
|
118
|
+ e.preventDefault();
|
|
119
|
+
|
|
120
|
+ $.ajax({
|
|
121
|
+ url: '/editMembers.php',
|
|
122
|
+ type: 'POST',
|
|
123
|
+ data: {
|
|
124
|
+ userid: $('#rowID').val(),
|
|
125
|
+ username: $('#username').val(),
|
|
126
|
+ nombre: $('#nombre').val(),
|
|
127
|
+ organizacion: $('#organizacion').val(),
|
|
128
|
+ puesto: $('#puesto').val(),
|
|
129
|
+ urbanizacion: $('#urbanizacion').val(),
|
|
130
|
+ calle: $('#calle').val(),
|
|
131
|
+ pueblo: $('#pueblo').val(),
|
|
132
|
+ cpostal: $('#cpostal').val(),
|
|
133
|
+ telefono: $('#telefono').val(),
|
|
134
|
+ correo: $('#correo').val()
|
|
135
|
+ },
|
|
136
|
+
|
|
137
|
+ success: function(msg) {
|
|
138
|
+ alert("Usuario editado");
|
|
139
|
+
|
|
140
|
+ document.getElementById("myModal").style.display = "none";
|
|
141
|
+
|
|
142
|
+ var id = $('#rowID').val();
|
|
143
|
+
|
|
144
|
+ document.getElementById(id).childNodes[1].innerText = $('#username').val();
|
|
145
|
+ document.getElementById(id).childNodes[2].innerText = $('#nombre').val();
|
|
146
|
+ document.getElementById(id).childNodes[3].innerText = $('#organizacion').val();
|
|
147
|
+ document.getElementById(id).childNodes[4].innerText = $('#puesto').val();
|
|
148
|
+ document.getElementById(id).childNodes[5].innerText = $('#urbanizacion').val();
|
|
149
|
+ document.getElementById(id).childNodes[6].innerText = $('#calle').val();
|
|
150
|
+ document.getElementById(id).childNodes[7].innerText = $('#pueblo').val();
|
|
151
|
+ document.getElementById(id).childNodes[8].innerText = $('#cpostal').val();
|
|
152
|
+ document.getElementById(id).childNodes[9].innerText = $('#telefono').val();
|
|
153
|
+ document.getElementById(id).childNodes[10].innerText = $('#correo').val();
|
|
154
|
+ },
|
|
155
|
+
|
|
156
|
+ error: function(request, status, error) {
|
|
157
|
+ alert(status + ": " + error);
|
|
158
|
+ }
|
|
159
|
+ });
|
|
160
|
+ });
|
|
161
|
+
|
|
162
|
+ });
|
|
163
|
+
|
|
164
|
+ function openModal(id){
|
|
165
|
+ document.getElementById("myModal").style.display = "block";
|
|
166
|
+
|
|
167
|
+ document.getElementsByClassName("close")[0].onclick = function() {
|
|
168
|
+ document.getElementById("myModal").style.display = "none";
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+ window.onclick = function(event) {
|
|
172
|
+ if (event.target == document.getElementById("myModal")) {
|
|
173
|
+ document.getElementById("myModal").style.display = "none";
|
|
174
|
+ }
|
|
175
|
+ }
|
|
176
|
+
|
|
177
|
+ document.getElementById("rowID").value = id;
|
|
178
|
+ document.getElementById("username").value = document.getElementById(id).childNodes[1].innerText;
|
|
179
|
+ document.getElementById("nombre").value = document.getElementById(id).childNodes[2].innerText;
|
|
180
|
+ document.getElementById("organizacion").value = document.getElementById(id).childNodes[3].innerText;
|
|
181
|
+ document.getElementById("puesto").value = document.getElementById(id).childNodes[4].innerText;
|
|
182
|
+ document.getElementById("urbanizacion").value = document.getElementById(id).childNodes[5].innerText;
|
|
183
|
+ document.getElementById("calle").value = document.getElementById(id).childNodes[6].innerText;
|
|
184
|
+ document.getElementById("pueblo").value = document.getElementById(id).childNodes[7].innerText;
|
|
185
|
+ document.getElementById("cpostal").value = document.getElementById(id).childNodes[8].innerText;
|
|
186
|
+ document.getElementById("telefono").value = document.getElementById(id).childNodes[9].innerText;
|
|
187
|
+ document.getElementById("correo").value = document.getElementById(id).childNodes[10].innerText;
|
|
188
|
+ }
|
|
189
|
+ </script>
|
63
|
190
|
</head>
|
64
|
191
|
<body>
|
65
|
192
|
<div class="topnav">
|
|
@@ -70,23 +197,45 @@
|
70
|
197
|
<div class="container">
|
71
|
198
|
<div class="members">
|
72
|
199
|
<?php
|
|
200
|
+
|
73
|
201
|
if ($_SERVER["REQUEST_METHOD"] == "GET") {
|
74
|
202
|
include 'db.php';
|
75
|
203
|
|
76
|
204
|
# Select username row
|
77
|
|
- $sql = "SELECT username, nombre, organizacion, puesto, urbanizacion, calle, pueblo, cpostal, telefono, correo, membresia, vigencia FROM login NATURAL JOIN miembros;";
|
|
205
|
+ $sql = "SELECT userid, username, nombre, organizacion, puesto, urbanizacion, calle,
|
|
206
|
+ pueblo, cpostal, telefono, correo, membresia, vigencia FROM login NATURAL JOIN miembros;";
|
78
|
207
|
|
79
|
208
|
|
80
|
209
|
if($result = $conn->query($sql)){
|
81
|
|
- // username nombre organizacion puesto urbanizacion calle pueblo cpostal telefono correo membresia vigencia
|
82
|
|
- echo "<table style=\"width:100%\"><tr><th>Username</th><th>Nombre</th><th>Organizacion</th><th>Puesto</th><th>Urbanizacion</th>
|
83
|
|
- <th>Calle</th><th>Pueblo</th><th>Codigo Posta</th><th>Telefono</th><th>Correo</th><th>Membresia</th><th>Vigencia</th></tr>";
|
|
210
|
+ ?>
|
|
211
|
+ <table id="membersTable" style="width:100%">
|
|
212
|
+ <thead>
|
|
213
|
+ <th></th>
|
|
214
|
+ <th>Username</th>
|
|
215
|
+ <th>Nombre</th>
|
|
216
|
+ <th>Organizacion</th>
|
|
217
|
+ <th>Puesto</th>
|
|
218
|
+ <th>Urbanizacion</th>
|
|
219
|
+ <th>Calle</th>
|
|
220
|
+ <th>Pueblo</th>
|
|
221
|
+ <th>Codigo Posta</th>
|
|
222
|
+ <th>Telefono</th>
|
|
223
|
+ <th>Correo</th>
|
|
224
|
+ <th>Membresia</th>
|
|
225
|
+ <th>Vigencia</th>
|
|
226
|
+ </thead>
|
|
227
|
+ <tbody>
|
|
228
|
+ <?php
|
84
|
229
|
while($row = $result->fetch_assoc()){
|
85
|
|
- echo "<tr><td>".$row["username"]."</td><td>".$row["nombre"]."</td><td>".$row["organizacion"]."</td><td>".$row["puesto"]."</td><td>".
|
86
|
|
- $row["urbanizacion"]."</td><td>".$row["calle"]."</td><td>".$row["pueblo"]."</td><td>".$row["cpostal"]."</td><td>".$row["telefono"]."</td><td>"
|
87
|
|
- .$row["correo"]."</td><td>".$row["membresia"]."</td><td>".$row["vigencia"]."</tr>";
|
|
230
|
+ echo "<tr id=\"".$row["userid"]."\"><td><button onClick=\"openModal(".$row["userid"].")\">Editar</button></td><td>".$row["username"]."</td><td>".$row["nombre"]."</td><td>".$row["organizacion"].
|
|
231
|
+ "</td><td>".$row["puesto"]."</td><td>". $row["urbanizacion"]."</td><td>".$row["calle"].
|
|
232
|
+ "</td><td>".$row["pueblo"]."</td><td>".$row["cpostal"]."</td><td>".$row["telefono"]."</td><td>"
|
|
233
|
+ .$row["correo"]."</td><td>".$row["membresia"]."</td><td>".$row["vigencia"]."</tr>";
|
88
|
234
|
}
|
89
|
|
- echo "</table>";
|
|
235
|
+ ?>
|
|
236
|
+ </tbody>
|
|
237
|
+ </table>
|
|
238
|
+ <?php
|
90
|
239
|
|
91
|
240
|
} else {
|
92
|
241
|
echo "Could not get rows";
|
|
@@ -103,5 +252,41 @@
|
103
|
252
|
?>
|
104
|
253
|
</div>
|
105
|
254
|
</div>
|
|
255
|
+
|
|
256
|
+ <!-- The Modal -->
|
|
257
|
+ <div id="myModal" class="modal">
|
|
258
|
+
|
|
259
|
+ <!-- Modal content -->
|
|
260
|
+ <div class="modal-content">
|
|
261
|
+ <span class="close">×</span>
|
|
262
|
+ <form method="post" action="" id="editform">
|
|
263
|
+ <input type="hidden" id="rowID">
|
|
264
|
+ <label>Username:</label><br>
|
|
265
|
+ <input type="text" id="username"><br><br>
|
|
266
|
+ <label>Nombre:</label><br>
|
|
267
|
+ <input type="text" id="nombre"><br><br>
|
|
268
|
+ <label>Organizacion</label><br>
|
|
269
|
+ <input type="text" id="organizacion"><br><br>
|
|
270
|
+ <label>Puesto:</label><br>
|
|
271
|
+ <input type="text" id="puesto"><br><br>
|
|
272
|
+ <label>Urbanizacion:</label><br>
|
|
273
|
+ <input type="text" id="urbanizacion"><br><br>
|
|
274
|
+ <label>Calle:</label><br>
|
|
275
|
+ <input type="text" id="calle"><br><br>
|
|
276
|
+ <label>Pueblo:</label><br>
|
|
277
|
+ <input type="text" id="pueblo"><br><br>
|
|
278
|
+ <label>Codigo Postal:</label><br>
|
|
279
|
+ <input type="text" id="cpostal"><br><br>
|
|
280
|
+ <label>Telefono:</label><br>
|
|
281
|
+ <input type="text" id="telefono"><br><br>
|
|
282
|
+ <label>Correo:</label><br>
|
|
283
|
+ <input type="text" id="correo"><br><br>
|
|
284
|
+ <input type="submit" class="editor" value="Editar Usiario">
|
|
285
|
+ </form>
|
|
286
|
+ </div>
|
|
287
|
+
|
|
288
|
+</div>
|
106
|
289
|
</body>
|
|
290
|
+
|
|
291
|
+
|
107
|
292
|
</html>
|