Source for file xmlreport.php
Documentation is available at xmlreport.php
* Sono qui definite le procedure per gestire i report di VFront.
* @desc Modulo di gestione dei report
* @subpackage Administration
* @author M.Marcello Verona
* @copyright 2007 M.Marcello Verona
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
include("../inc/conn.php");
include("../inc/layouts.php");
include("../inc/func.comuni.php");
include("../inc/func.frontend.php");
######################################
######################################
if(isset ($_GET['creanew'])){
// gestione file -------------------------------------------------------------------------------
if($_FILES['new_xsl']['size']> 0){
// è stato richiesto un nuovo file XSL da uplodare
$NEW_XSL_NAME= preg_replace("'[^a-z0-9_.]'i","_",$_FILES['new_xsl']['name']);
$NEW_XSL_NAME= "_". $NEW_XSL_NAME;
if($_dati['xsl']!= 'default') $NEW_XSL_NAME= $_dati['xsl'];
}// gestione file -------------------------------------------------------------------------------
// gestione file -------------------------------------------------------------------------------
if($_FILES['new_fo']['size']> 0){
// è stato richiesto un nuovo file XSL da uplodare
$NEW_XSLFO_NAME= preg_replace("'[^a-z0-9_.]'i","_",$_FILES['new_fo']['name']);
$NEW_XSLFO_NAME= "_". $NEW_XSLFO_NAME;
if($_dati['fo']== '') $NEW_XSLFO_NAME= '-1';
else if($_dati['fo']!= 'default') $NEW_XSLFO_NAME= $_dati['xsl'];
}// gestione file -------------------------------------------------------------------------------
$nome_report = preg_replace("|[^\w-_]+|","_",$_dati['nome_report']);
if(!is_array($_dati['gid'])) $_dati['gid']= array();
$sql= sprintf("INSERT INTO {$db1['frontend']}.xml_rules (nome_report,tabella,accesso, accesso_gruppo, autore, lastData, xsl, xslfo, def_query, tipo_report)
VALUES ('%s','%s','%s','%s',%d,'%s','%s','%s','%s','%s')",
$_SESSION['user']['uid'],
header("Location: ". $_SERVER['PHP_SELF']. "?feed=ok");
header("Location: ". $_SERVER['PHP_SELF']. "?feed=ko");
######################################
######################################
if(isset ($_GET['appmod'])){
// gestione file -------------------------------------------------------------------------------
if($_FILES['new_xsl']['size']> 0){
// è stato richiesto un nuovo file XSL da uplodare
$NEW_XSL_NAME= preg_replace("'[^a-z0-9_.]'i","_",$_FILES['new_xsl']['name']);
$NEW_XSL_NAME= "_". $NEW_XSL_NAME;
if($_dati['xsl']!= 'default') $NEW_XSL_NAME= $_dati['xsl'];
}// gestione file -------------------------------------------------------------------------------
// gestione file -------------------------------------------------------------------------------
if($_FILES['new_fo']['size']> 0){
// E' stato richiesto un nuovo file XSL da uplodare
$NEW_XSLFO_NAME= preg_replace("'[^a-z0-9_.]'i","_",$_FILES['new_fo']['name']);
$NEW_XSLFO_NAME= "_". $NEW_XSLFO_NAME;
if($_dati['fo']== '') $NEW_XSLFO_NAME= '-1';
else if($_dati['fo']!= 'default') $NEW_XSLFO_NAME= $_dati['fo'];
}// gestione file -------------------------------------------------------------------------------
if(!is_array($_dati['gid'])) $_dati['gid']= array();
$nome_report = preg_replace("|[^\w-_]+|","_",$_dati['nome_report']);
$sql= sprintf("UPDATE {$db1['frontend']}.xml_rules SET
nome_report='%s', accesso='%s', accesso_gruppo='%s', autore=%d,
lastData='%s', xsl='%s', xslfo='%s', def_query='%s'
$_SESSION['user']['uid'],
header("Location: ". $_SERVER['PHP_SELF']. "?feed=ok");
header("Location: ". $_SERVER['PHP_SELF']. "?feed=ko");
######################################
######################################
else if(isset ($_GET['del'])){
// verifico che l'allegato sia presente in un solo record
$sql_xsl= "SELECT count(id_xml_rules) FROM {$db1['frontend']}.xml_rules
WHERE xsl=(SELECT xsl FROM {$db1['frontend']}.xml_rules WHERE id_xml_rules=". intval($_GET['del']). ")";
$q= vmsql_query("DELETE FROM {$db1['frontend']}.xml_rules WHERE id_xml_rules=". intval($_GET['del']),$link);
header("Location: ". $_SERVER['PHP_SELF']. "?feed=delok");
header("Location: ". $_SERVER['PHP_SELF']. "?feed=delko");
######################################
######################################
else if(isset ($_GET['new']) || isset ($_GET['newquery'])){
$files= array("js/test_query.js");
$TIPO_NEW = (isset ($_GET['new'])) ? "tabella" : "query";
echo openLayout1("Amministrazione XML e Reportistica",$files);
echo "<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> » <a href=\"xmlreport.php\">amministrazione xml e reportistica</a> » nuovo report XML</div>\n";
$testo_tit = ($TIPO_NEW== "tabella") ? "basato su tabella" : "basato su query";
echo "<h1>Nuovo report XML $testo_tit</h1>\n";
echo "<form action=\"". $_SERVER['PHP_SELF']. "?creanew\" method=\"post\" enctype=\"multipart/form-data\" >\n";
echo "<label for=\"nome_report\" >Nome del report (solo lettere, numeri e trattini):</label>\n ";
echo "<input type=\"text\" name=\"nome_report\" id=\"nome_report\" maxlength=\"250\" size=\"40\" /><br /><br />\n";
if($TIPO_NEW== "tabella"){
echo "<input type=\"hidden\" name=\"tipo_report\" value=\"t\" />\n";
echo "<input type=\"hidden\" name=\"def_query\" value=\"\" />\n";
echo "<label for=\"tabella\" >Tabella:</label>\n ";
echo "<select name=\"tabella\" id=\"tabella\">\n";
for($i= 0;$i< count($tab);$i++ ){
echo "<option value=\"". $tab[$i]['table_name']. "\">". $tab[$i]['table_name']. "</option>\n";
echo "<input type=\"hidden\" name=\"tabella\" value=\"\" />\n";
echo "<input type=\"hidden\" name=\"tipo_report\" value=\"q\" />\n";
echo "<label for=\"def_query\" >Query SQL per il report:</label>\n ";
echo "<input value=\"Test\" onclick=\"try_query(document.getElementById('def_query').value,1)\" type=\"button\" />\n";
echo "<span id=\"feed_altro_1\" class=\"feed_altro\"> </span>\n";
echo "<textarea name=\"def_query\" id=\"def_query\" cols=\"80\" rows=\"8\"></textarea>\n";
echo "<br /><br /><label for=\"accesso\" >Tipo di accesso:</label>\n ";
echo "<select name=\"accesso\" id=\"accesso\" onchange=\"if(this.value=='GROUP'){ document.getElementById('gruppi').style.display='';} else {document.getElementById('gruppi').style.display='none';}\">
<option value=\"RESTRICT\" >Non accessibile</option>
<option value=\"PUBLIC\" >Pubblico (web)</option>
<option value=\"FRONTEND\" >Frontend (solo utenti del frontend autenticati)</option>
<option value=\"GROUP\" >Solo il/i gruppo/i (selezionare)</option>
echo "<div id=\"gruppi\" style=\"display:none;\">
<br /><br /><label for=\"gid\" >Gruppi con accesso:</label><select name=\"gid[]\" id=\"gid\" multiple=\"multiple\" size=\"5\">
for($g= 0;$g< count($gruppi);$g++ ){
echo "<option value=\"". $gruppi[$g]['gid']. "\">". $gruppi[$g]['gid']. " - ". $gruppi[$g]['nome_gruppo']. "</option>\n";
// cerca fogli di stile XSL custom
while (($file_xsl = readdir($dh)) !== false) {
if($file_xsl!= '.' && $file_xsl!= '..') $xsl_custom[]= $file_xsl;
echo "<br /><br /><label for=\"xsl\" >Foglio di stile XSL da associare:</label>\n<select name=\"xsl\" id=\"xsl\">
<option value=\"default\">default</option>";
for($i= 0;$i< count($xsl_custom);$i++ ){
echo "\t\t<option value=\"". $xsl_custom[$i]. "\">". $xsl_custom[$i]. "</option>\n";
echo "oppure associa a nuovo file: <input type=\"file\" name=\"new_xsl\" id=\"new_xsl\" size=\"48\" />\n";
###################################################
// cerca fogli di stile FO custom
while (($file_fo = readdir($dh)) !== false) {
if($file_fo!= '.' && $file_fo!= '..') $fo_custom[]= $file_xsl;
echo "<br /><br /><label for=\"fo\" >Foglio di stile XSL-FO da associare:</label>\n<select name=\"fo\" id=\"fo\">
<option value=\"\"> - nessuno - </option>
<option value=\"default\">default</option>
for($i= 0;$i< count($fo_custom);$i++ ){
echo "\t\t<option value=\"". $fo_custom[$i]. "\">". $fo_custom[$i]. "</option>\n";
echo "oppure associa a nuovo file: <input type=\"file\" name=\"new_fo\" id=\"new_fo\" size=\"48\" />\n";
echo "<br /><br /><input type=\"submit\" name=\"invia\" value=\" Salva \" />\n";
######################################
######################################
else if(isset ($_GET['mod']) && $_GET['mod']> 0){
$files= array("js/test_query.js");
echo openLayout1("Amministrazione XML e Reportistica",$files);
echo "<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> » <a href=\"xmlreport.php\">amministrazione xml e reportistica</a> » modifica report XML</div>\n";
echo "<h1>Modifica report XML</h1>\n";
echo "<form action=\"". $_SERVER['PHP_SELF']. "?appmod\" method=\"post\" enctype=\"multipart/form-data\" >\n";
$q= vmsql_query("SELECT * FROM {$db1['frontend']}.xml_rules WHERE id_xml_rules=". intval($_GET['mod']),$link);
$TIPO_REPORT = ($RS['tipo_report']== 't') ? "t" : "q";
$sel_RESTRICT = ($RS['accesso']== 'RESTRICT') ? "selected=\"selected\"" : "";
$sel_PUBLIC = ($RS['accesso']== 'PUBLIC') ? "selected=\"selected\"" : "";
$sel_FRONTEND = ($RS['accesso']== 'FRONTEND') ? "selected=\"selected\"" : "";
$sel_GROUP = ($RS['accesso']== 'GROUP') ? "selected=\"selected\"" : "";
echo "<label for=\"nome_report\" >Nome del report (solo lettere, numeri e trattini):</label>\n ";
echo "<input type=\"text\" name=\"nome_report\" id=\"nome_report\" maxlength=\"250\" size=\"40\" value=\"". $RS['nome_report']. "\"/><br /><br />\n";
else if ($TIPO_REPORT== "q"){
echo "<input type=\"hidden\" name=\"tabella\" value=\"\" />\n";
echo "<input type=\"hidden\" name=\"tipo_report\" value=\"q\" />\n";
echo "<label for=\"def_query\" >Query SQL per il report:</label>\n ";
echo "<input value=\"Test\" onclick=\"try_query(document.getElementById('def_query').value,1)\" type=\"button\" />\n";
echo "<span id=\"feed_altro_1\" class=\"feed_altro\"> </span>\n";
echo "<textarea name=\"def_query\" id=\"def_query\" cols=\"80\" rows=\"8\">". stripslashes($RS['def_query']). "</textarea>\n";
echo "<br /><br /><label for=\"accesso\" >Tipo di accesso:</label>\n ";
echo "<select name=\"accesso\" id=\"accesso\" onchange=\"if(this.value=='GROUP'){ document.getElementById('gruppi').style.display='';} else {document.getElementById('gruppi').style.display='none';}\">
<option value=\"RESTRICT\" $sel_RESTRICT>Non accessibile</option>
<option value=\"PUBLIC\" $sel_PUBLIC>Pubblico (web)</option>
<option value=\"FRONTEND\" $sel_FRONTEND>Frontend (solo utenti del frontend autenticati)</option>
<option value=\"GROUP\" $sel_GROUP>Solo il/i gruppo/i (selezionare)</option>
$sty_gruppi = ($sel_GROUP== '') ? "display:none;" : "";
echo "<div id=\"gruppi\" style=\"$sty_gruppi\">
<br /><br /><label for=\"gid\" >Gruppi con accesso:</label><select name=\"gid[]\" id=\"gid\" multiple=\"multiple\" size=\"5\">
$gids= explode(",",$RS['accesso_gruppo']);
for($g= 0;$g< count($gruppi);$g++ ){
$gsel= "selected=\"selected\"";
echo "<option value=\"". $gruppi[$g]['gid']. "\" $gsel>". $gruppi[$g]['gid']. " - ". $gruppi[$g]['nome_gruppo']. "</option>\n";
// cerca fogli di stile XSL custom
while (($file_xsl = readdir($dh)) !== false) {
if($file_xsl!= '.' && $file_xsl!= '..') $xsl_custom[]= $file_xsl;
echo "<br /><br /><label for=\"xsl\" >Foglio di stile XSL da associare:</label>\n<select name=\"xsl\" id=\"xsl\">
<option value=\"default\">default</option>";
for($i= 0;$i< count($xsl_custom);$i++ ){
$sel_xsl= ($RS['xsl']== $xsl_custom[$i]) ? "selected=\"selected\"" : "";
echo "\t\t<option value=\"". $xsl_custom[$i]. "\" $sel_xsl>". $xsl_custom[$i]. "</option>\n";
echo "oppure associa a nuovo file: <input type=\"file\" name=\"new_xsl\" id=\"new_xsl\" size=\"48\" />\n";
###################################################
// cerca fogli di stile FO custom
while (($file_fo = readdir($dh)) !== false) {
if($file_fo!= '.' && $file_fo!= '..') $fo_custom[]= $file_xsl;
$sel_fo_none= ($RS['xslfo']== '-1') ? "selected=\"selected\"" : "";
echo "<br /><br /><label for=\"fo\" >Foglio di stile XSL-FO da associare:</label>\n<select name=\"fo\" id=\"fo\">
<option value=\"default\">default</option>
<option value=\"-1\" $sel_fo_none> - nessuno - </option>
for($i= 0;$i< count($fo_custom);$i++ ){
$sel_fo= ($RS['xsl']== $fo_custom[$i]) ? "selected=\"selected\"" : "";
echo "\t\t<option value=\"". $fo_custom[$i]. "\" $sel_fo>". $fo_custom[$i]. "</option>\n";
echo "oppure associa a nuovo file: <input type=\"file\" name=\"new_fo\" id=\"new_fo\" size=\"48\" />\n";
echo "<input type=\"hidden\" name=\"id_xml_rules\" value=\"". intval($_GET['mod']). "\" />\n";
echo "<br /><br /><input type=\"submit\" name=\"invia\" value=\" Salva \" />\n";
$files= array('sty/tabelle.css');
echo openLayout1("Amministrazione XML e Reportistica",$files);
echo "<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> » amministrazione xml e reportistica</div>\n";
echo "<h1>Amministrazione XML e Reportistica</h1>\n";
echo "<p><a href=\"?new\">Crea nuovo report XML da tabella o vista</a> <span class=\"nocss\">|</span> <br /><br /><a href=\"?newquery\">Crea nuovo report XML da query</a></p>";
$q= vmsql_query("SELECT x.*, ". concat_sintax("u.nome,' ',u.cognome", 'nomecognome'). " FROM {$db1['frontend']}.xml_rules x, {$db1['frontend']}.utente u
WHERE x.autore=u.id_utente
ORDER BY tabella ASC",$link);
echo "<table class=\"tab-color\" summary=\"Tabella Log\">
<th>gruppi autorizzati</th>
<th class=\"arancio\">elimina</th>
for($i= 0;$i< count($mat_xml);$i++ ){
$xsl_riga= ($mat_xml[$i]['xsl']== '') ? '<em>default</em>' : "<em>". $mat_xml[$i]['xsl']. "</em>";
if($mat_xml[$i]['xslfo']== '-1') $xslfo_riga= "-";
else if($mat_xml[$i]['xslfo']== '') $xslfo_riga= "<em>default</em>";
else $xslfo_riga= $mat_xml[$i]['xslfo'];
$tipo_report= ($mat_xml[$i]['tipo_report']== 't') ? "da tabella" : "da query";
$link_anteprima = ($mat_xml[$i]['tipo_report']== 't') ?
<td>". $mat_xml[$i]['nome_report']. "</td>
<td>". $tipo_report. "</td>
<td>". $mat_xml[$i]['tabella']. "</td>
<td>". $mat_xml[$i]['accesso']. "</td>
<td>". $mat_xml[$i]['accesso_gruppo']. "</td>
<td>". $mat_xml[$i]['nomecognome']. "</td>
<td>". $data['ita']. "</td>
<td><a href=\"". $link_anteprima. "/\">anteprima</a></td>
<td><a href=\"xmlreport.php?mod=". $mat_xml[$i]['id_xml_rules']. "\">modifica</a></td>
<td><a href=\"xmlreport.php?del=". $mat_xml[$i]['id_xml_rules']. "\">elimina</a></td>
|