-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
104 lines (86 loc) · 2.83 KB
/
index.php
File metadata and controls
104 lines (86 loc) · 2.83 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
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Conti</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4Q6Gf2aSP4eDXB8Miphtr37CMZZQ5oXLH2yaXMJ2w8e2ZtHTl7GptT4jmndRuHDT" crossorigin="anonymous">
<link href="style.css" rel="stylesheet">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" crossorigin="anonymous"></script>
<div class="container w-50">
<form method="post" id="form">
<h2>Pagante</h2>
<select class="form-select w-50 mx-auto" id="pagante" name="pagante" required>
<?php
include_once("db.php");
$res = $db->query("SELECT * FROM nomi");
while ($row = $res->fetch()) {
echo "<option value='$row[id]'>$row[nome]</option>";
}
?>
</select>
<br>
<h2>Soggetti</h2>
<?php
$res = $db->query("SELECT * FROM nomi");
?>
<?php if ($res->rowCount() > 2) : ?>
<button type="button" class="btn btn-secondary" id="btnAll">Tutti</button><br/><br/>
<?php endif; ?>
<?php while ($row = $res->fetch()) : ?>
<div class="d-block">
<input class="form-check-input" type="checkbox" name="soggetto_<?= $row["id"] ?>" id="soggetto_<?= $row["id"] ?>">
<label class="form-check-label" for="soggetto_<?= $row["id"] ?>"><?= $row["nome"] ?></label>
</div>
<?php endwhile; ?>
<br/>
<label for="importo" class="form-label">Importo (€)</label>
<input type="number" class="form-control w-50 mx-auto" id="importo" name="importo" step="0.01" min="0" value="0.0" required>
<br/>
<label for="causale" class="form-label">Causale</label>
<input type="text" class="form-control w-50 mx-auto" id="causale" name="causale">
<br/><br/>
<button type="submit" class="btn btn-primary">Salva</button>
</form>
<br>
<a href="riepilogoTransazioni.php">
<h2>Riepilogo Transazioni</h2>
</a><a href="riepilogoConti.php">
<h2>Riepilogo Conti</h2>
</a>
</div>
</body>
<script>
$(document).ready(function() {
$("#btnAll").click(function() {
$("input[type=checkbox]").prop("checked", "true")
})
$("#form").submit(function(e) {
e.preventDefault();
var inputs = $(this).find("input, select, button, textarea");
var serializedData = $(this).serialize();
inputs.prop("disabled", true);
$.ajax({
type: 'POST',
url: "r_salvaTransazione.php",
data: serializedData,
dataType: "html",
cache: false,
complete: function(r, ts) {
if (ts === "success") {
location.reload()
}
inputs.prop("disabled", false);
},
error: function() {
console.log("Errore")
alert("La richiesta non è andata a buon fine, riprovare")
}
})
})
})
</script>
</html>