forked from RickyLeRoi/proges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lista_clienti.php
277 lines (261 loc) · 11 KB
/
lista_clienti.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
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
<!DOCTYPE html>
<html lang="it">
<head>
<!-- blu #071E3F arancione #EA640C -->
<meta charset="utf-8">
<title>Lista Clienti - Gestionale Provenzano</title>
<meta name="description" content="Gestionale per etichettificio Provenzano"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<?php include_once("template/parrot/style.php");
include_once("function/session.php");
include_once("DB/config.php");?>
</head>
<body>
<!-- #### Navbars #### -->
<?php include_once("template/parrot/navbar.php") ?>
<div class="masthead">
<div class="masthead-title">
<div class="container">
Lista Clienti sintetica
</div>
</div>
</div>
<div class="container">
<div>
<form action="lista_clienti_big.php">
<input style="width: auto" class="form-control" type="submit" value="Lista completa">
</form>
</div>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Cognome</th>
<th>Codice</th>
<th>Descrizione</th>
<th>Note</th>
<th>Telefono legale</th>
<th>Cellulare</th>
<th>P.IVA</th>
<th>Cod Fisc</th>
<th>Elimina</th>
<th>Modifica</th>
<th>+ info</th>
</tr>
</thead>
<tbody id="records">
</tbody>
</table>
<div class="row">
<nav class="col-sm-12">
<ul class="pager">
<li class="previous"><a id="prec" href="#"><span aria-hidden="true">←</span> Precedente</a></li>
<li class="next"><a id="succ" href="#">Successivo <span aria-hidden="true">→</span></a></li>
</ul>
</nav>
</div>
</div>
<div class="modal fade" id="clientModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Scheda Completa</h4>
</div>
<div class="modalClienti" style="color: #000" class="modal-body">
<div class="container">
<table>
<tr><td><h4>Cliente</h4></b></td><td></td></tr>
<tr><td><b>Nome: </b></td><td><span id="nomeC"></span></td></tr>
<tr><td><b>Cognome: </b></td><td><span id="cognomeC"></span></td></tr>
<tr><td><b>Codice Cliente: </b></td><td><span id="cC"></span></td></tr>
<tr><td><b>Descrizione: </b></td><td><span id="descC"></span></td></tr>
<tr><td><b>Note Cliente: </b></td><td><span id="noteC"></span></td></tr>
<tr><td><h4>Sede legale</h4></b></td><td></td></tr>
<tr><td><b>Indirizzo legale: </b></td><td><span id="indirizzoL"></span></td></tr>
<tr><td><b>Città legale: </b></td><td><span id="cittaL"></span></td></tr>
<tr><td><b>Cap legale: </b></td><td><span id="capL"></span></td></tr>
<tr><td><b>Provincia legale: </b></td><td><span id="provinciaL"></span></td></tr>
<tr><td><b>Tel legale: </b></td><td><span id="telL"></span></td></tr>
<tr><td><b>Fax Legale: </b></td><td><span id="faxL"></span></td></tr>
<tr><td><b>Stato legale: </b></td><td><span id="provL"></span></td></tr>
<tr><td><b>Email Legale: </b></td><td><span id="emailL"></span></td></tr>
<tr><td><b>Sito web legale: </b></td><td><span id="sitoWebL"></span></td></tr>
<tr><td><h4>Sede Amministrativa</h4></b></td><td></td></tr>
<tr>
<td><b>Indirizzo:</b></td>
<td><span id="indirizzoAC"></span></td>
</tr>
<tr><td><b>Città: </b></td><td><span id="cittaAc"></span></td></tr>
<tr><td><b>Cap: </b></td><td><span id="capAc"></span></td></tr>
<tr><td><b>Provincia: </b></td><td><span id="provinciaAc"></span></td></tr>
<tr><td><b>Telefono: </b></td><td><span id="telefonoAc"></span></td></tr>
<tr><td><b>Cellulare: </b></td><td><span id="cellulareAc"></span></td></tr>
<tr><td><b>Stato: </b></td><td><span id="statoAc"></span></td></tr>
<tr><td><b>Email: </b></td><td><span id="emailAc"></span></td></tr>
<tr><td><b>Sito web: </b></td><td><span id="sitoAc"></span></td></tr>
<tr><td><b>P.Iva: </b></td><td><span id="pivaAc"></span></td></tr>
<tr><td><b>C. Fiscale: </b></td><td><span id="cfiscAc"></span></td></tr>
<tr><td><b>Iban: </b></td><td><span id="ibanAc"></span></td></tr>
<tr><td><b>Banca: </b></td><td><span id="bancaAc"></span></td></tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Chiudi</button>
</div>
</div>
</div>
</div>
<?php include_once("template/parrot/foot.php") ?>
<script type="text/javascript">
var records,
page = 0,
limit = 30;
function loadPage(page, limit){
$.ajax({
url: "json/get_listaclienti.php",
dataType: "JSON",
type: "GET",
error: function(){
alert("Chiamata fallita!!!");
},
data: "page="+page+"&limit="+limit,
success: function(result){
records = result;
loadQuery();
page = limit + page;
limit = limit * 2;
}
});
}
</script>
<script type="text/javascript">
var rowsReturned;
function loadQuery() {
rowsReturned = 0;
var tab = document.getElementById('records'),
newTr,
info,
att,
td;
prevNext();
document.getElementById("records").innerHTML = "";
for (var id in records ) {
var texts = [records[id].id,
records[id].nomeC,
records[id].cognomeC,
records[id].codC,
records[id].descrC,
records[id].noteC,
records[id].telLC,
records[id].cellAC,
records[id].PIVAC,
records[id].CFC];
rowsReturned++;
newTds = generateTd(texts);
for ( var td in newTds) {
newTr.appendChild(newTds[td]);
}
info = document.createElement("input");
info.className = "form-control";
info.type = "button";
//info.id = records[id].id;
att = document.createAttribute("data-row"); // Create a "href" attribute
att.value = records[id]["count"]; // Set the value of the href attribute
info.setAttributeNode(att);
info.value ="Dettagli";
info.onclick = function(num) {
var num = this.getAttribute("data-row");
console.log(num);
associativeModal(
{
"#nomeC": records[num].nomeC,
"#cognomeC": records[num].cognomeC,
"#cC": records[num].codC,
"#descC": records[num].descrC,
"#noteC": records[num].noteC,
"#indirizzoL": records[num].indirizzoLC,
"#cittaL": records[num].cittaLC,
"#capL": records[num].capLC,
"#provinciaL": records[num].provLC,
"#telL": records[num].telLC,
"#faxL": records[num].faxLC,
"#provL": records[num].statoLC,
"#emailL": records[num].emailLC,
"#sitoWebL": records[num].urlLC,
"#cittaAc": records[num].cittaAC,
"#capAc": records[num].capAC,
"#provinciaAc": records[num].provAC,
"#indirizzoAC": records[num].indirizzoAC,
"#telefonoAc": records[num].provAC,
"#cellulareAc": records[num].telAC,
"#statoAc": records[num].cellAC,
"#emailAc": records[num].statoAC,
"#sitoAc": records[num].emailAC,
"#cfiscAc": records[num].urlAC,
"#pivaAc": records[num].PIVAC,
"#ibanAc": records[num].IBANC,
"#bancaAc": records[num].bancaC
}
)};
td = document.createElement("td");
var elimina = "<td><a href='./function/azioni_cliente.php?elimina=" + records[id].codC + "'>Elimina</a></td>";
var modifica = "<td><a href='./function/azioni_cliente.php?modifica=" + records[id].codC + "'>Modifica</a></td>";
$(newTr).append(elimina);
$(newTr).append(modifica);
td.appendChild(info);
newTr.appendChild(td);
document.getElementById('records').appendChild(newTr);
}
function generateTd(arr) {
var newTd,
text;
obj = [];
newTr = document.createElement("tr");
newTr.id = "row-" + records[id]["count"]; // per capire: count è l'ultimo record che indica su quale array siamo
for (key in arr) {
arr[key] == null ? arr[key] = "N/D" : arr[key];
newTd = document.createElement("td");
text = document.createTextNode(arr[key]);
newTd.appendChild(text);
obj.push(newTd);
}
return obj;
}
}
$("#succ").click(function() {
if (rowsReturned == 29) {
page += +30;
limit += +30;
loadPage(page, limit);
}
});
$("#prec").click(function() {
if (page !=0 ) {
page += -30;
limit += -30;
loadPage(page, limit)
}
});
function prevNext() {
var prev = document.getElementById("prec").parentNode;
if (page < 0 || page == 0) {
prev.className = "hide";
}
else {
prev.className = "previous";
}
var succ = document.getElementById("succ").parentNode;
if (rowsReturned != 29) {
succ.className = "hide";
}
else {
succ.className = "next";
}
}
loadPage(0, 30);
</script>
</body>
</html>