1+ <?php
2+ /*
3+ * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+ * Copyright (C) DevCode s.r.l.
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18+ */
19+
20+ include_once __DIR__ .'/../../core.php ' ;
21+
22+ $ id_record = get ('id_record ' );
23+ $ id_parent = get ('id_parent ' );
24+ $ id_plugin = get ('id_plugin ' );
25+ $ id_module = get ('id_module ' );
26+
27+ $ barcode = $ dbo ->table ('mg_articoli_barcode ' )->where ('id ' ,$ id_record )->first ();
28+
29+ echo '
30+ <form action="" method="post" role="form" id="form_sedi">
31+ <input type="hidden" name="id_plugin" value=" ' .$ id_plugin .'">
32+ <input type="hidden" name="id_parent" value=" ' .$ id_parent .'">
33+ <input type="hidden" name="id_record" value=" ' .$ id_record .'">
34+ <input type="hidden" name="backto" value="record-edit">
35+ <input type="hidden" name="op" value="updatebarcode">
36+
37+ <div class="row">
38+ <div class="col-md-12">
39+ <button type="button" class="btn btn-default btn-xs tip pull-right" id="generaBarcode"><i class="fa fa-refresh"></i> ' .tr ('Genera ' ).'</button>
40+ {[ "type": "text", "label": " ' .tr ('Barcode ' ).'", "name": "barcode", "required": 1, "value": " ' .$ barcode ->barcode .'" ]}
41+ </div>
42+ </div>
43+
44+ <!-- PULSANTI -->
45+ <div class="row">
46+ <div class="col-md-12">
47+ <button type="button" class="btn btn-danger ' .$ disabled .'" onclick="rimuoviBarcode(this)">
48+ <i class="fa fa-trash"></i> ' .tr ('Elimina ' ).'
49+ </button>
50+
51+ <a type="button" class="btn btn-info" href=" ' .$ rootdir .'/pdfgen.php?id_print= ' .Prints::getPrints ()['Barcode ' ].'&id_record= ' .$ id_parent .'&idbarcode= ' .$ id_record .'" target="_blank"><i class="fa fa-print"></i> ' .tr ('Stampa barcode ' ).'</a>
52+ <button type="submit" class="btn btn-primary pull-right"><i class="fa fa-edit"></i> ' .tr ('Modifica ' ).'</button>
53+ </div>
54+ </div>
55+ </form> ' ;
56+
57+ echo '
58+ <script>
59+ function rimuoviBarcode(button) {
60+ let hash = window.location.href.split("#")[1];
61+
62+ confirmDelete(button).then(function () {
63+ redirect(globals.rootdir + "/editor.php", {
64+ backto: "record-edit",
65+ hash: hash,
66+ op: "deletebarcode",
67+ id: " ' .$ id_record .'",
68+ id_plugin: " ' .$ id_plugin .'",
69+ id_module: " ' .$ id_module .'",
70+ id_parent: " ' .$ id_parent .'",
71+ });
72+ }).catch(swal.noop);
73+ }
74+
75+ function generaBarcode() {
76+ $.ajax({
77+ url: globals.rootdir + "/actions.php",
78+ type: "POST",
79+ data: {
80+ id_module: globals.id_module,
81+ id_record: globals.id_record,
82+ op: "generate-barcode"
83+ },
84+ success: function(response) {
85+ response = JSON.parse(response);
86+ let input = $("#barcode");
87+ input.val(response.barcode);
88+ },
89+ error: function(xhr, status, error) {
90+ }
91+ });
92+ }
93+
94+ $("#generaBarcode").click( function() {
95+ generaBarcode();
96+ });
97+ </script> ' ;
0 commit comments