gest366/add.php

80 lines
2.1 KiB
PHP
Raw Normal View History

2021-02-24 20:40:04 +00:00
<?php
include_once(__DIR__."/core.php");
$module_dir = $modules_info[$modules_info[$id_module]['name']]['module_dir'];
echo '
<div id="form_'.$id_module.'">
';
$modulo_custom=get_var("Cartella Custom");
//Caricamento template popup
if(file_exists($docroot."/modules/".$module_dir."/".$modulo_custom."/add.php")){
include($docroot."/modules/".$module_dir."/".$modulo_custom."/add.php");
}
else if(file_exists($docroot."/modules/".$module_dir."/".$modulo_custom."/add.html")){
include($docroot."/modules/".$module_dir."/".$modulo_custom."/add.html");
}
else if(file_exists($docroot."/modules/".$module_dir."/add.php")){
include($docroot."/modules/".$module_dir."/add.php");
}
if(file_exists($docroot."/modules/".$module_dir."/add_wizard.php")){
include($docroot."/modules/".$module_dir."/add_wizard.php");
}
echo '
</div>';
if( $_GET['ajax'] == "yes"){
echo '
<script>
$(document).ready(function(){
$("#form_'.$id_module.'").find("form").submit(function(){
var go = true;
$(this).find("[required]").each(function(){
if($(this).val() == "") go = false;
});
if(go){
var form_data = new FormData();
form_data.append("ajax", "yes");
form_data.append("id_module","'.$id_module .'");
form_data.append("id_modules","'. $id_modules.'");
$(this).find("input, textarea, select").each(function(){
form_data.append($(this).attr("name"), $(this).val());
});
$.ajax({
url: "'. $rootdir.'/modules/'.$modules_info[$modules_info[$id_module]['name']]['module_dir'].'/actions.php",
cache: false,
type: "post",
processData: false,
contentType: false,
dataType : "html",
data: form_data,
success: function(data) {
data = data.trim();
if (typeof customAction !== "undefined" && typeof customAction === "function"){
customAction(data);
}
$("#bs-popup2").modal("hide");
},
error: function() {
alert("Errore: "+form_data);
}
});
}
return false;
});
});
</script>';
}
echo '
<script src="'.$rootdir.'/lib/init.js"></script>';
?>