2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/core.php';
|
|
|
|
|
|
|
|
if (!empty($id_plugin)) {
|
2017-09-22 15:19:59 +02:00
|
|
|
$info = Plugins::get($id_plugin);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
$directory = '/plugins/'.$info['directory'];
|
|
|
|
} else {
|
|
|
|
Permissions::check('rw');
|
|
|
|
|
2017-09-22 15:19:59 +02:00
|
|
|
$module = Modules::get($id_module);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
$directory = '/modules/'.$module['directory'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$module_dir = $module['directory'];
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<div id="form_'.$id_module.'-'.$id_plugin.'">
|
|
|
|
';
|
|
|
|
|
|
|
|
// Caricamento template popup
|
|
|
|
if (file_exists($docroot.$directory.'/custom/add.php')) {
|
|
|
|
include $docroot.$directory.'/custom/add.php';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/custom/add.html')) {
|
|
|
|
include $docroot.$directory.'/custom/add.html';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/add.php')) {
|
|
|
|
include $docroot.$directory.'/add.php';
|
|
|
|
} elseif (file_exists($docroot.$directory.'/add.html')) {
|
|
|
|
include $docroot.$directory.'/add.html';
|
|
|
|
}
|
|
|
|
|
|
|
|
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">
|
|
|
|
{( "name": "custom_fields", "id_module": "'.$id_module.'", "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">
|
|
|
|
{( "name": "custom_fields", "id_module": "'.$id_module.'", "position": "bottom", "place": "add" )}
|
2018-02-10 17:24:16 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
2018-02-14 18:39:41 +01:00
|
|
|
$("#form_'.$id_module.'-'.$id_plugin.' form:first").prepend($("#custom_fields_top-add").html());
|
2018-02-10 17:24:16 +01:00
|
|
|
|
2018-02-14 18:39:41 +01:00
|
|
|
$("#form_'.$id_module.'-'.$id_plugin.' form:first .panel").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
|
|
|
|
|
|
|
foreach ($get as $key => $value) {
|
|
|
|
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({
|
|
|
|
url: "'.$rootdir.$directory.'/actions.php",
|
|
|
|
data: data,
|
|
|
|
type: "post",
|
|
|
|
success: function(data){
|
|
|
|
data = data.trim();
|
|
|
|
|
|
|
|
if(data && !$("#'.$get['select'].'").val()) {
|
|
|
|
result = JSON.parse(data);
|
|
|
|
$("#'.$get['select'].'").selectSetNew(result.id, result.text);
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#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>';
|