-
Notifications
You must be signed in to change notification settings - Fork 69
/
add.php
executable file
·106 lines (84 loc) · 3.13 KB
/
add.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
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/core.php';
// Inclusione elementi fondamentali del modulo
include base_dir().'/actions.php';
// Controllo dei permessi
if (empty($id_plugin)) {
Permissions::check('rw');
}
// Caricamento template
echo '
<div id="form_'.$id_module.'-'.$id_plugin.'">
';
include !empty(get('edit')) ? $structure->getEditFile() : $structure->getAddFile();
echo '
</div>';
// Campi personalizzati
echo '
<div class="hide" id="custom_fields_top-add_'.$id_module.'-'.$id_plugin.'">
<input type="hidden" name="id_module" value="'.$id_module.'">
<input type="hidden" name="id_plugin" value="'.$id_plugin.'">
{( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "top", "place": "add" )}
</div>
<div class="hide" id="custom_fields_bottom-add_'.$id_module.'-'.$id_plugin.'">
{( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "bottom", "place": "add" )}
</div>
<script>
$(document).ready(function(){
let form = $("#custom_fields_top-add_'.$id_module.'-'.$id_plugin.'").parent().find("form").first();
// Ultima sezione/campo del form
let last = form.find(".panel").last();
if (!last.length) {
last = form.find(".box").last();
}
if (!last.length) {
last = form.find(".row").eq(-2);
}
// Campi a inizio form
aggiungiContenuto(form, "#custom_fields_top-add_'.$id_module.'-'.$id_plugin.'", {}, true);
// Campi a fine form
aggiungiContenuto(last, "#custom_fields_bottom-add_'.$id_module.'-'.$id_plugin.'", {});
});
</script>';
if (isAjaxRequest()) {
echo '
<script>
$(document).ready(function(){
$("#form_'.$id_module.'-'.$id_plugin.'").find("form").submit(function () {
var form = input(this);
salvaForm(this, {
id_module: "'.$id_module.'",
id_plugin: "'.$id_plugin.'",
}).then(function(response) {
// Selezione automatica nuovo valore per il select
var select = input("#'.get('select').'");
if (select) {
select.getElement().selectSetNew(response.id, response.text, response.data);
//select.change();
}
form.getElement().closest("div[id^=bs-popup").modal("hide");
})
return false;
})
});
</script>';
}
echo '
<script>$(document).ready(init)</script>';