Skip to content

Commit 2add669

Browse files
committed
feat: salvataggio sessioni via ajax
1 parent 3a163df commit 2add669

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

modules/interventi/modals/manage_sessione.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<!-- PULSANTI -->
118118
<div class="row">
119119
<div class="col-md-12 text-right">
120-
<button type="submit" class="btn btn-primary">'.$button.'</button>
120+
<button type="button" class="btn btn-primary" onclick="salvaSessione()">'.$button.'</button>
121121
</div>
122122
</div>
123123
</form>';
@@ -149,4 +149,36 @@
149149
$("#prezzo_dirittochiamata").val(data.prezzo_dirittochiamata);
150150
});
151151
});
152+
153+
function salvaSessione() {
154+
// Validazione del form
155+
var valid = $("#add_form").parsley().validate();
156+
if (!valid) {
157+
return false;
158+
}
159+
160+
// Invio dei dati via AJAX
161+
$("#add_form").ajaxSubmit({
162+
url: globals.rootdir + "/actions.php",
163+
data: {
164+
id_module: globals.id_module,
165+
id_record: globals.id_record,
166+
ajax: true,
167+
},
168+
type: "post",
169+
success: function(response) {
170+
renderMessages();
171+
172+
// Chiusura del modale
173+
$("#modals > div").modal("hide");
174+
175+
// Ricaricamento dei costi
176+
caricaCosti();
177+
caricaTecnici();
178+
},
179+
error: function() {
180+
alert("'.tr('Errore durante il salvataggio').'");
181+
}
182+
});
183+
}
152184
</script>';

0 commit comments

Comments
 (0)