openstamanager/add.php

93 lines
2.4 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/core.php';
// Inclusione elementi fondamentali del modulo
include $docroot.'/actions.php';
// Controllo dei permessi
if (empty($id_plugin)) {
Permissions::check('rw');
}
// Caricamento template
echo '
<div id="form_'.$id_module.'-'.$id_plugin.'">
';
2018-09-19 10:44:32 +02:00
include !empty(get('edit')) ? $structure->getEditFile() : $structure->getAddFile();
echo '
</div>';
// Campi personalizzati
echo '
2018-02-14 18:39:41 +01:00
<div class="hide" id="custom_fields_top-add">
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.'">
{( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "top", "place": "add" )}
</div>
2018-02-14 18:39:41 +01:00
<div class="hide" id="custom_fields_bottom-add">
{( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "bottom", "place": "add" )}
</div>
<script>
$(document).ready(function(){
2019-07-26 17:40:52 +02:00
cleanup_inputs();
var form = $("#custom_fields_top-add").parent().find("form").first();
2019-07-26 17:40:52 +02:00
// Campi a inizio form
form.prepend($("#custom_fields_top-add").html());
// Campi a fine form
var last = form.find(".panel").last();
2018-09-24 10:51:48 +02:00
if (!last.length) {
last = form.find(".box").last();
}
if (!last.length) {
last = form.find(".row").eq(-2);
}
2019-06-07 15:01:00 +02:00
2019-07-26 17:40:52 +02:00
last.after($("#custom_fields_bottom-add").html());
restart_inputs();
});
</script>';
if (isAjaxRequest()) {
echo '
<script>
$(document).ready(function(){
2019-07-05 17:10:20 +02:00
$("#form_'.$id_module.'-'.$id_plugin.'").find("form").submit(function () {
$form = $(this);
$form.variables = new Object();
$form.variables.id_module = \''.$id_module.'\';
$form.variables.id_plugin = \''.$id_plugin.'\';
submitAjax(this, $form.variables, function(response) {
2019-07-05 17:10:20 +02:00
// Selezione automatica nuovo valore per il select
select = "#'.get('select').'";
console.log($(select).val());
2019-07-05 17:10:20 +02:00
if ($(select).val() !== undefined) {
console.log(response.id + " | " + response.text);
2019-11-12 17:16:10 +01:00
$(select).selectSetNew(response.id, response.text, response.data);
}
$form.closest("div[id^=bs-popup").modal("hide");
2019-07-05 17:10:20 +02:00
});
return false;
})
});
</script>';
}
echo '
2019-07-26 17:40:52 +02:00
<script>$(document).ready(init)</script>';