2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/core.php';
|
|
|
|
|
2018-07-18 16:12:25 +02:00
|
|
|
// Inclusione elementi fondamentali del modulo
|
|
|
|
include $docroot.'/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-08-11 15:37:38 +02:00
|
|
|
include !empty(get('edit')) ? $element->getEditFile() : $element->getAddFile();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
|
2018-02-10 17:24:16 +01:00
|
|
|
// 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.'">
|
|
|
|
|
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>
|
|
|
|
|
2018-02-14 18:39:41 +01:00
|
|
|
<div class="hide" id="custom_fields_bottom-add">
|
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(){
|
2018-02-15 17:30:42 +01:00
|
|
|
var form = $("#custom_fields_top-add").parent().find("form").first();
|
2018-02-10 17:24:16 +01:00
|
|
|
|
2018-02-15 17:30:42 +01:00
|
|
|
// Campi a inizio form
|
|
|
|
form.prepend($("#custom_fields_top-add").html());
|
|
|
|
|
|
|
|
// Campi a fine form
|
|
|
|
var last = form.find(".panel").last();
|
|
|
|
if (!last.length) {
|
|
|
|
last = form.find(".row").eq(-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
last.after($("#custom_fields_bottom-add").html());
|
2018-02-10 17:24:16 +01:00
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
if (isAjaxRequest()) {
|
|
|
|
echo '
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
2017-09-13 17:08:27 +02:00
|
|
|
data = {};';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-08-11 15:37:38 +02:00
|
|
|
foreach (Filter::getGET() as $key => $value) {
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2017-09-13 17:08:27 +02:00
|
|
|
data.'.$key.' = "'.$value.'";';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|
2017-09-13 17:08:27 +02:00
|
|
|
$("#form_'.$id_module.'-'.$id_plugin.'").find("form").ajaxForm({
|
2018-06-26 14:26:40 +02:00
|
|
|
url: globals.rootdir + "/actions.php",
|
2018-02-23 15:39:43 +01:00
|
|
|
beforeSubmit: function(arr, $form, options) {
|
|
|
|
return $form.parsley().validate();
|
|
|
|
},
|
2017-09-13 17:08:27 +02:00
|
|
|
data: data,
|
|
|
|
type: "post",
|
|
|
|
success: function(data){
|
|
|
|
data = data.trim();
|
|
|
|
|
2018-07-19 15:33:32 +02:00
|
|
|
if(data && $("#'.get('select').'").val() !== undefined ) {
|
2017-09-13 17:08:27 +02:00
|
|
|
result = JSON.parse(data);
|
2018-07-19 15:33:32 +02:00
|
|
|
$("#'.get('select').'").selectSetNew(result.id, result.text);
|
2017-09-13 17:08:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$("#bs-popup2").modal("hide");
|
|
|
|
},
|
|
|
|
error: function(data) {
|
|
|
|
alert("'.tr('Errore').': " + data);
|
|
|
|
}
|
|
|
|
});
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<script src="'.$rootdir.'/lib/init.js"></script>';
|