2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/core.php';
|
|
|
|
|
2018-07-18 16:12:25 +02:00
|
|
|
// Inclusione elementi fondamentali del modulo
|
2020-09-23 13:36:37 +02:00
|
|
|
include base_dir().'/actions.php';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-07-18 16:12:25 +02:00
|
|
|
// Controllo dei permessi
|
|
|
|
if (empty($id_plugin)) {
|
2017-08-04 16:28:16 +02:00
|
|
|
Permissions::check('rw');
|
|
|
|
}
|
|
|
|
|
2018-07-18 16:12:25 +02:00
|
|
|
// Caricamento template
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
|
|
|
<div id="form_'.$id_module.'-'.$id_plugin.'">
|
|
|
|
';
|
|
|
|
|
2018-09-19 10:44:32 +02:00
|
|
|
include !empty(get('edit')) ? $structure->getEditFile() : $structure->getAddFile();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
|
2018-02-10 17:24:16 +01:00
|
|
|
// Campi personalizzati
|
|
|
|
echo '
|
|
|
|
|
2024-01-24 15:52:26 +01:00
|
|
|
<div class="hide" id="custom_fields_top-add_'.$id_module.'-'.$id_plugin.'">
|
2018-07-03 12:24:29 +02:00
|
|
|
<input type="hidden" name="id_module" value="'.$id_module.'">
|
|
|
|
<input type="hidden" name="id_plugin" value="'.$id_plugin.'">
|
|
|
|
|
2018-02-15 17:30:42 +01:00
|
|
|
{( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "top", "place": "add" )}
|
2018-02-10 17:24:16 +01:00
|
|
|
</div>
|
|
|
|
|
2024-01-24 15:52:26 +01:00
|
|
|
<div class="hide" id="custom_fields_bottom-add_'.$id_module.'-'.$id_plugin.'">
|
2018-02-15 17:30:42 +01:00
|
|
|
{( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "bottom", "place": "add" )}
|
2018-02-10 17:24:16 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
2024-01-24 15:52:26 +01:00
|
|
|
let form = $("#custom_fields_top-add_'.$id_module.'-'.$id_plugin.'").parent().find("form").first();
|
2019-07-26 17:40:52 +02:00
|
|
|
|
2021-02-23 15:47:25 +01:00
|
|
|
// Ultima sezione/campo del form
|
|
|
|
let last = form.find(".panel").last();
|
2018-09-24 10:51:48 +02:00
|
|
|
|
|
|
|
if (!last.length) {
|
|
|
|
last = form.find(".box").last();
|
|
|
|
}
|
|
|
|
|
2024-05-16 18:02:50 +02:00
|
|
|
if (!last.length) {
|
|
|
|
last = form.find(".card").last();
|
|
|
|
}
|
|
|
|
|
2018-02-15 17:30:42 +01:00
|
|
|
if (!last.length) {
|
|
|
|
last = form.find(".row").eq(-2);
|
|
|
|
}
|
2020-02-23 15:58:30 +01:00
|
|
|
|
2021-02-23 15:47:25 +01:00
|
|
|
// Campi a inizio form
|
2024-01-24 15:52:26 +01:00
|
|
|
aggiungiContenuto(form, "#custom_fields_top-add_'.$id_module.'-'.$id_plugin.'", {}, true);
|
2021-02-23 15:47:25 +01:00
|
|
|
|
|
|
|
// Campi a fine form
|
2024-01-24 15:52:26 +01:00
|
|
|
aggiungiContenuto(last, "#custom_fields_bottom-add_'.$id_module.'-'.$id_plugin.'", {});
|
2018-02-10 17:24:16 +01:00
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
if (isAjaxRequest()) {
|
|
|
|
echo '
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
2019-07-05 17:10:20 +02:00
|
|
|
$("#form_'.$id_module.'-'.$id_plugin.'").find("form").submit(function () {
|
2022-02-06 10:06:48 +01:00
|
|
|
var form = input(this);
|
2020-02-05 12:40:44 +01:00
|
|
|
|
2021-03-29 18:31:23 +02:00
|
|
|
salvaForm(this, {
|
|
|
|
id_module: "'.$id_module.'",
|
|
|
|
id_plugin: "'.$id_plugin.'",
|
|
|
|
}).then(function(response) {
|
2019-07-05 17:10:20 +02:00
|
|
|
// Selezione automatica nuovo valore per il select
|
2022-03-22 17:14:26 +01:00
|
|
|
var select = input("#'.get('select').'");
|
2022-02-06 10:06:48 +01:00
|
|
|
if (select) {
|
2022-03-22 17:05:32 +01:00
|
|
|
select.getElement().selectSetNew(response.id, response.text, response.data);
|
2022-02-06 10:06:48 +01:00
|
|
|
//select.change();
|
2017-09-13 17:08:27 +02:00
|
|
|
}
|
|
|
|
|
2022-02-06 10:06:48 +01:00
|
|
|
form.getElement().closest("div[id^=bs-popup").modal("hide");
|
2021-03-29 18:31:23 +02:00
|
|
|
})
|
2020-02-23 15:58:30 +01:00
|
|
|
|
2019-07-05 17:10:20 +02:00
|
|
|
return false;
|
|
|
|
})
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2019-07-26 17:40:52 +02:00
|
|
|
<script>$(document).ready(init)</script>';
|