|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione |
| 5 | + * Copyright (C) DevCode s.r.l. |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +include_once __DIR__.'/../../../core.php'; |
| 22 | + |
| 23 | +// Contenuto del modal per il calcolo dello sconto combinato |
| 24 | +echo ' |
| 25 | +<form id="form-sconto-combinato"> |
| 26 | + <div class="row"> |
| 27 | + <div class="offset-md-4 col-md-4"> |
| 28 | + {[ "type": "text", "label": "'.tr('Sconto/magg. combinato').'", "name": "prc_combinato", "icon-after": "%", "class": "math-mask text-right", "help": "'.tr('Esempio: 2+2+2 viene convertito in 2% di sconto con 2% aggiuntivo sul totale scontato e 2% di maggiorazione sul totale finale').'. '.tr('Sono ammessi i segni + e -').'" ]} |
| 29 | + </div> |
| 30 | + </div> |
| 31 | +</form> |
| 32 | +
|
| 33 | +<div class="row"> |
| 34 | + <div class="col-md-12 text-right"> |
| 35 | + <button type="button" class="btn btn-success" id="btn-confirm-sconto"><i class="fa fa-check"></i> '.tr('Conferma').'</button> |
| 36 | + </div> |
| 37 | +</div> |
| 38 | +
|
| 39 | +<script> |
| 40 | +$(document).ready(function() { |
| 41 | + var modal = $("#modals > div:last"); |
| 42 | +
|
| 43 | + // Determina quale campo sconto è presente (sconto_percentuale o sconto) |
| 44 | + var sconto_field = $("#sconto_percentuale").length ? $("#sconto_percentuale") : $("#sconto"); |
| 45 | +
|
| 46 | + // Reinizializza i componenti del form quando il modal si apre |
| 47 | + modal.on("shown.bs.modal", function() { |
| 48 | + restart_inputs(); |
| 49 | + }); |
| 50 | +
|
| 51 | + // Gestisci il click del pulsante di conferma |
| 52 | + $("#form-sconto-combinato").on("submit", function(e) { |
| 53 | + e.preventDefault(); |
| 54 | + var prc_combinato = $("#prc_combinato").val(); |
| 55 | +
|
| 56 | + if (prc_combinato) { |
| 57 | + // Calcola lo sconto combinato |
| 58 | + $.ajax({ |
| 59 | + url: globals.rootdir + "/ajax.php", |
| 60 | + type: "POST", |
| 61 | + data: { |
| 62 | + op: "calcola_sconto_combinato", |
| 63 | + prc_combinato: prc_combinato |
| 64 | + }, |
| 65 | + dataType: "json", |
| 66 | + success: function(response) { |
| 67 | + if (response.success) { |
| 68 | + sconto_field.val(response.sconto.toLocale()); |
| 69 | + sconto_field.trigger("keyup"); |
| 70 | + modal.modal("hide"); |
| 71 | + } else { |
| 72 | + alert(response.error); |
| 73 | + } |
| 74 | + } |
| 75 | + }); |
| 76 | + } else { |
| 77 | + alert("'.tr('Inserire uno sconto').'"); |
| 78 | + } |
| 79 | + }); |
| 80 | +
|
| 81 | + // Gestisci il click del pulsante di conferma |
| 82 | + modal.find("#btn-confirm-sconto").click(function() { |
| 83 | + $("#form-sconto-combinato").submit(); |
| 84 | + }); |
| 85 | +}); |
| 86 | +</script>'; |
| 87 | + |
0 commit comments