Page MenuHomeGRNET

reports.php
No OneTemporary

File Metadata

Created
Thu, Feb 20, 1:26 PM

reports.php

<?php
include_once("modules/db.php");
include_once("modules/utility.php");
include_once("modules/form.php");
include_once("modules/biblio.php");
include_once("modules/session_header.php");
include_once("modules/jpgraph/src/jpgraph.php");
include_once("modules/jpgraph/src/jpgraph_line.php");
include_once("modules/jpgraph/src/jpgraph_bar.php");
include_once("modules/jpgraph/src/jpgraph_pie.php");
include_once("modules/jpgraph/src/jpgraph_pie3d.php");
include_once("modules/jpgraph/src/jpgraph_table.php");
include_once("modules/jpgraph/src/jpgraph_canvas.php");
function show_report_menu($op2) {
switch ($op2) {
case "report_sovrannuali":
$ret = "<a class=\"active_report\" href=\"javascript:display_report('globale1A');\" id=\"globale1A\">" . getConstVar("REPORTS_GRAPH_GLOBALE1A") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('globale1E');\" id=\"globale1E\">" . getConstVar("REPORTS_GRAPH_GLOBALE1E") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('globale1C');\" id=\"globale1C\">" . getConstVar("REPORTS_GRAPH_GLOBALE1C") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('globale1D');\" id=\"globale1D\">" . getConstVar("REPORTS_GRAPH_GLOBALE1D") . "</a>";
return $ret;
break;
case "report_biblioteca":
$ret = "<a class=\"active_report\" href=\"javascript:display_report('biblio2A');\" id=\"biblio2A\">" . getConstVar("REPORTS_GRAPH_BIBLIO2A") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('riepilogo');\" id=\"riepilogo\">" . getConstVar("REPORTS_GRAPH_RIEPILOGO") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2D');\" id=\"biblio2D\">" . getConstVar("REPORTS_GRAPH_BIBLIO2D") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2E');\" id=\"biblio2E\">" . getConstVar("REPORTS_GRAPH_BIBLIO2E") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2F');\" id=\"biblio2F\">" . getConstVar("REPORTS_GRAPH_BIBLIO2F") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2G');\" id=\"biblio2G\">" . getConstVar("REPORTS_GRAPH_BIBLIO2G") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2H');\" id=\"biblio2H\">" . getConstVar("REPORTS_GRAPH_BIBLIO2H") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2I');\" id=\"biblio2I\">" . getConstVar("REPORTS_GRAPH_BIBLIO2I") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2L');\" id=\"biblio2L\">" . getConstVar("REPORTS_GRAPH_BIBLIO2L") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('biblio2M');\" id=\"biblio2M\">" . getConstVar("REPORTS_GRAPH_BIBLIO2M") . "</a>";
return $ret;
break;
case "report_utenti":
$ret = "<a class=\"active_report\" href=\"javascript:display_report('utente3A');\" id=\"utente3A\">" . getConstVar("REPORTS_GRAPH_UTENTE3A") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('utente3B');\" id=\"utente3B\">" . getConstVar("REPORTS_GRAPH_UTENTE3B") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('utente3M');\" id=\"utente3M\">" . getConstVar("REPORTS_GRAPH_UTENTE3M") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('utente3H');\" id=\"utente3H\">" . getConstVar("REPORTS_GRAPH_UTENTE3H") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('utente3L');\" id=\"utente3L\">" . getConstVar("REPORTS_GRAPH_UTENTE3L") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('utente3G');\" id=\"utente3G\">" . getConstVar("REPORTS_GRAPH_UTENTE3G") . "</a>&nbsp;-&nbsp;
<a class=\"viola\" href=\"javascript:display_report('utente3I');\" id=\"utente3I\">" . getConstVar("REPORTS_GRAPH_UTENTE3I") . "</a>";
return $ret;
break;
case "export":
$ret = "";
$ret.= "<a class=\"active_report\" href=\"javascript:display_report('export_biblio');\" id=\"export_biblio\">" . getConstVar("EXPORT_BIBLIO") . "</a>&nbsp;-&nbsp";
$ret.= "<a class=\"viola\" href=\"javascript:display_report('ente');\" id=\"ente\">" . getConstVar("REPORTS_GRAPH_ENTE") . "</a>&nbsp;-&nbsp";
$ret.= "<a class=\"viola\" href=\"javascript:display_report('progetto');\" id=\"progetto\">" . getConstVar("REPORTS_GRAPH_PROJECT") . "</a>";
return $ret;
break;
}
}
function print_tagimg($gr) {
$temp_file = tempnam(sys_get_temp_dir(), 'img');
$gr->Stroke($temp_file);
$fp = fopen($temp_file, "r");
$bytes = filesize($temp_file);
$buffer = fread($fp, $bytes);
fclose($fp);
@unlink($temp_file);
$base = base64_encode($buffer);
$code = "<br /><img src=\"data:image/jpeg;base64,$base\" class=\"nilde_graph\"/><br />";
return $code;
}
function cutstring($stringa) {
if (strlen($stringa) > 40) {
$s = substr_replace($stringa, "\n", strlen($stringa) / 2, 0);
} else {
$s = $stringa;
}
return $s;
}
function print_graph($typegraph, $year = null, $report_order = null, $report_qualif = null) {
$ret = "";
switch ($typegraph) {
case 'scambi_globali_year':
$result = $_SESSION['db']->execute("SELECT SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel)+ SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro) as tot_rich,re_anno FROM report_biblio WHERE re_anno>=2011 GROUP BY re_anno ORDER BY re_anno ASC");
$assex = array("2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010");
$data = array(16988, 56081, 86465, 101250, 114425, 123150, 139020, 159571);
$ret = "";
if ($_SESSION['db']->numrows($result) != 0) {
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row['tot_rich'];
$assex[] = $row['re_anno'];
}
$graph = new Graph(500, 300);
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->title->Set(getConstVar("NETWORK_TOT_SCAMBI"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->SetScale('textint');
$graph->ygrid->Show(false);
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$bplot = new BarPlot($data);
$bplot->SetFillColor("bisque3");
$bplot->value->Show();
$bplot->value->SetFormat('%01.0f');
$graph->Add($bplot);
$graph->xaxis->SetTickLabels($assex);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->title->Set(getConstVar("ANNI"));
$ret.= print_tagimg($graph);
}
return $ret;
break;
case 'tempo_risp':
$result = $_SESSION['db']->execute("SELECT AVG(re_tempo_risp_bw)/86400 as tasso,re_anno FROM report_biblio WHERE re_anno>=2011 GROUP BY re_anno ORDER BY re_anno ASC");
$assex = array("2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010");
$data = array(3.5, 2.63, 1.81, 1.85, 1.44, 1.08, 1.03, 0.95);
$ret = "";
if ($_SESSION['db']->numrows($result) != 0) {
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row['tasso'];
$assex[] = $row['re_anno'];
}
$graph = new Graph(500, 300);
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->title->Set(getConstVar("NETWORK_AVG_GIACENZA"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->SetScale('textint');
$graph->ygrid->Show(false);
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$bplot = new LinePlot($data);
$bplot->SetFillColor("white");
$bplot->mark->SetType(MARK_FILLEDCIRCLE);
$bplot->mark->SetFillColor("red");
$bplot->mark->SetWidth(4);
$bplot->value->Show();
$graph->Add($bplot);
$graph->xaxis->SetTickLabels($assex);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->title->Set(getConstVar("ANNI"));
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->title->Set(getConstVar("DAYS"));
$ret.= print_tagimg($graph);
}
return $ret;
break;
case 'distr_tipoente':
$result = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot,t_tipoente.tipoente AS ente FROM `biblio` LEFT JOIN ente ON biblio.en_id=ente.en_id LEFT JOIN tipoente ON ente.ti_id=tipoente.ti_id LEFT join t_tipoente ON t_tipoente.ti_id=tipoente.ti_id AND lang_id='" . $_SESSION['lang'] . "' WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") GROUP BY ente");
$data = array();
$datalegend = array();
$ret = "";
if ($_SESSION['db']->numrows($result) != 0) {
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row['tot'];
$datalegend[] = "(" . $row['tot'] . ") " . $row['ente'];
}
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->title->Set(getConstVar("NET_DISTRBIB_IST"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
}
return $ret;
break;
case 'distr_cataloghi':
$ret = "";
$res_acnp = $_SESSION['db']->execute("SELECT COUNT( tab_acnp.bi_id ) AS tot
FROM tab_acnp, biblio_catalogo, biblio
WHERE biblio_catalogo.bi_id = tab_acnp.bi_id
AND biblio_catalogo.ca_id =1
AND bc_attivo =1
AND biblio.bi_id = biblio_catalogo.bi_id
AND bi_nilde =1
AND biblio.na_id = 'ITA'
AND acnp_attivo IN (0,1,2)
AND bi_stato
IN ( " . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ")");
$res_acnp_attivo = $_SESSION['db']->execute("SELECT COUNT( tab_acnp.bi_id ) AS tot
FROM tab_acnp, biblio_catalogo, biblio
WHERE biblio_catalogo.bi_id = tab_acnp.bi_id
AND biblio_catalogo.ca_id =1
AND bc_attivo =1
AND biblio.bi_id = biblio_catalogo.bi_id
AND bi_nilde =1
AND biblio.na_id = 'ITA'
AND acnp_attivo=1
AND bi_stato
IN ( " . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ")");
$res_mai = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM `biblio_catalogo` LEFT JOIN catalogo ON catalogo.ca_id=biblio_catalogo.ca_id WHERE bc_attivo=1 AND biblio_catalogo.ca_id=3 AND bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") )");
$res_sbn = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM `biblio_catalogo` LEFT JOIN catalogo ON catalogo.ca_id=biblio_catalogo.ca_id WHERE bc_attivo=1 AND biblio_catalogo.ca_id=2 AND bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") )");
$res_rebiun = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM `biblio_catalogo` LEFT JOIN catalogo ON catalogo.ca_id=biblio_catalogo.ca_id WHERE bc_attivo=1 AND biblio_catalogo.ca_id=5 AND bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") )");
$res_altre = $_SESSION['db']->execute("SELECT COUNT(bi_id) AS tot FROM biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") AND bi_id not IN (SELECT distinct(bi_id) from biblio_catalogo WHERE bc_attivo=1)");
$tot_acnp = $_SESSION['db']->fetch_single($res_acnp_attivo);
$tot_sbn = $_SESSION['db']->fetch_single($res_sbn);
$tot_mai = $_SESSION['db']->fetch_single($res_mai);
$tot_altre = $_SESSION['db']->fetch_single($res_altre);
$tot_rebiun = $_SESSION['db']->fetch_single($res_rebiun);
$ca_array = array();
$cat_res = $_SESSION['db']->execute("SELECT ca_id,ca_nome from catalogo");
while ($c = $_SESSION['db']->fetch($cat_res)) {
$key = $c["ca_id"];
$v = $c["ca_nome"];
$ca_array[$key] = $v;
}
$data = array();
$data[] = $tot_acnp;
$data[] = $tot_sbn;
$data[] = $tot_mai;
$data[] = $tot_rebiun;
$data[] = $tot_altre;
$assex[] = $ca_array['1'];
$assex[] = $ca_array['2'];
$assex[] = $ca_array['3'];
$assex[] = $ca_array['5'];
getConstVar("REBIUN");
$assex[] = getConstVar("OTHERS");
$graph = new Graph(500, 300);
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->title->Set(getConstVar("NET_DISTRBIB_CATNAZIONALI"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->SetScale('textint');
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$bplot = new BarPlot($data);
$color = getConstVar("GRAPH_COLOR_LIST");
$bplot->SetFillColor($color);
$bplot->value->Show();
$bplot->value->SetFormat('%01.0f');
$graph->Add($bplot);
$graph->xaxis->SetTickLabels($assex);
$ret.= print_tagimg($graph);
return $ret;
break;
case "pie_multidisciplina":
$result = $_SESSION['db']->execute("SELECT t_disciplina.disciplina AS nome, COUNT(biblio.di_id) AS tot FROM biblio,disciplina,t_disciplina WHERE disciplina.di_id=t_disciplina.di_id AND t_disciplina.lang_id='" . $_SESSION["lang"] . "' AND biblio.di_id=disciplina.di_id AND bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") GROUP BY nome");
$data = array();
$datalegend = array();
$ret = "";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row['tot'];
$datalegend[] = "(" . $row['tot'] . ") " . $row['nome'];
}
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->title->Set(getConstVar("NET_DISTRBIB_DISCIPLINE"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
}
return $ret;
break;
case "distr_nazione":
$result = $_SESSION['db']->execute("SELECT count(bi_id) as tot, biblio.na_id,na_nome from biblio,nazione where biblio.na_id=nazione.na_id AND bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") group by biblio.na_id");
$data = array();
$datalegend = array();
$ret = "";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row['tot'];
$datalegend[] = "(" . $row['tot'] . ") " . $row['na_id'] . " - " . $row['na_nome'];
}
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->title->Set(getConstVar("NET_DISTRBIB_NAZIONE"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
}
return $ret;
break;
case 'distr_ute_tipoente':
$result = $_SESSION['db']->execute("SELECT COUNT(ut_id) as tot, TE.tipoente as nometipo FROM appartiene as APP, biblio AS B, ente AS E, tipoente AS T,t_tipoente AS TE WHERE TE.ti_id=T.ti_id AND TE.lang_id='" . $_SESSION['lang'] . "' AND APP.ap_stato=1 AND APP.bi_id=B.bi_id AND B.en_id=E.en_id AND E.ti_id=T.ti_id AND B.bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") ) GROUP BY TE.tipoente");
$data = array();
$datalegend = array();
$ret = "";
if ($_SESSION['db']->numrows($result) != 0) {
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row['tot'];
$datalegend[] = "(" . $row['tot'] . ") " . $row['nometipo'];
}
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->title->Set(getConstVar("NET_DISTRUTE_IST"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
}
return $ret;
break;
case 'distr_ute_multidisciplina':
$result = $_SESSION['db']->execute("SELECT COUNT(ut_id) as tot,TD.disciplina as discip FROM appartiene as APP, biblio AS B, disciplina D,t_disciplina TD WHERE TD.di_id=D.di_id AND TD.lang_id='" . $_SESSION['lang'] . "' AND APP.ap_stato=1 AND APP.bi_id=B.bi_id AND B.di_id=D.di_id AND B.bi_id IN (SELECT bi_id from biblio WHERE bi_nilde=1 AND bi_stato IN (" . getConstVar('BIBLIO_ATTIVE_SQL_LIST') . ") ) GROUP BY TD.disciplina");
$data = array();
$datalegend = array();
$ret = "";
if ($_SESSION['db']->numrows($result) != 0) {
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row['tot'];
$datalegend[] = "(" . $row['tot'] . ") " . $row['discip'];
}
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->title->Set(getConstVar("NET_DISTRUTE_DISCIP"));
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
}
return $ret;
break;
case "globale1A":
$result = $_SESSION['db']->execute("SELECT SUM(re_evase_dir)+SUM(re_evase_nilde)+SUM(re_inevase_nilde)+SUM(re_inevase_dir) as borrowing, SUM(re_evase_dir)+SUM(re_evase_nilde) as lending, re_anno FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno HAVING (borrowing > 0 OR lending > 0 )ORDER BY re_anno ASC ");
$data_rich = array();
$data_forn = array();
$assex = array();
while ($row = $_SESSION['db']->fetch($result)) {
$data_rich[] = $row["borrowing"];
$data_forn[] = $row["lending"];
$assex[] = $row["re_anno"];
}
$ret .= "<h3>" . getConstVar("REPORTS_GRAPHTITLE_GLOBALE1A") . "</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->SetScale('textint');
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->legend->Pos(0.05, 0.01, 'top', 'left');
$b1plot = new BarPlot($data_rich);
$b1plot->SetFillColor(getConstVar("GRAPH_BAR1COLOR"));
$b1plot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI"));
$b1plot->value->SetFormat('%01.0f');
$b1plot->value->Show();
$b2plot = new BarPlot($data_forn);
$b2plot->SetFillColor(getConstVar("GRAPH_BAR2COLOR"));
$b2plot->SetLegend(getConstVar("REPORTS_ART_FORNITI"));
$b2plot->value->SetFormat('%01.0f');
$b2plot->value->Show();
$gbplot = new GroupBarPlot(array($b1plot, $b2plot));
$graph->Add($gbplot);
$graph->xaxis->SetTickLabels($assex);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->title->Set(getConstVar("ANNI"));
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->title->Set(getConstVar("REPORTS_NUM_RICHIE"));
$ret.= print_tagimg($graph);
}
return $ret;
break;
case "globale1B":
$result = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_ricev) as ricevuti
FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY rv HAVING ricevuti>0 ORDER BY ricevuti DESC LIMIT 20");
$result1 = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_forni) as forniti
FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY rv HAVING forniti>0 ORDER BY forniti DESC LIMIT 20");
$data_rich = array();
$data_forn = array();
$assex = array();
$assexf = array();
$a = array();
$array_nomi = array();
$array_nomif = array();
while ($row = $_SESSION['db']->fetch($result)) {
$data_rich[] = $row["ricevuti"]; //borrowing
$assex[] = $row["rv"];
}
while ($row = $_SESSION['db']->fetch($result1)) {
$data_forn[] = $row["forniti"]; //lending
$assexf[] = $row["rv"];
}
$array_nomi = array_map("cutstring", $assex);
$array_nomif = array_map("cutstring", $assexf);
$ret.= "<h3>" . getConstVar("REPORTS_GRAPHTITLE_GLOBALE1B") . " " . date("Y", strtotime($_SESSION['biblio']->bi_data_reg)) . "</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0 && $_SESSION['db']->numrows($result1) == 0)
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
else {
if ($_SESSION['db']->numrows($result) != 0) {
$graph = new Graph(800, 600);
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->SetScale('textint');
$graph->Set90AndMargin(250, 50, 80, 30);
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->legend->Pos(0.05, 0.01, 'top', 'left');
$graph->xaxis->SetTickLabels($array_nomi);
$graph->xaxis->SetFont(FF_DV_SERIF, FS_NORMAL, 8);
$graph->xaxis->SetLabelMargin(10);
$graph->xaxis->SetLabelAlign('right', 'center');
$bplot = new BarPlot($data_rich);
$bplot->SetFillColor(getConstVar("GRAPH_BAR1COLOR"));
$bplot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI"));
$bplot->value->Show();
$bplot->value->SetFormat('%01.0f');
$bplot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 8);
$bplot->value->SetAlign('left', 'center');
$bplot->value->SetColor('black', 'darkred');
$graph->Add($bplot);
$ret.= print_tagimg($graph);
}
if ($_SESSION['db']->numrows($result1) != 0) {
$graph1 = new Graph(800, 600);
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph1->SetScale('textint');
$graph1->Set90AndMargin(250, 50, 80, 30);
$graph1->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$graph1->legend->SetLayout(LEGEND_HOR);
$graph1->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph1->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph1->legend->Pos(0.05, 0.01, 'top', 'left');
$graph1->xaxis->SetTickLabels($array_nomif);
$graph1->xaxis->SetFont(FF_DV_SERIF, FS_NORMAL, 8);
$graph1->xaxis->SetLabelMargin(10);
$graph1->xaxis->SetLabelAlign('right', 'center');
$b2plot = new BarPlot($data_forn);
$b2plot->SetFillColor(getConstVar("GRAPH_BAR2COLOR"));
$b2plot->SetLegend(getConstVar("REPORTS_ART_FORNITI"));
$b2plot->value->Show();
$b2plot->value->SetFormat('%01.0f');
$b2plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 8);
$b2plot->value->SetAlign('left', 'center');
$b2plot->value->SetColor('black', 'darkred');
$graph1->Add($b2plot);
$ret.= print_tagimg($graph1);
}
}
return $ret;
break;
case "globale1C":
$nameview = "view_" . rand(0, 999999);
$_SESSION['db']->execute("CREATE VIEW $nameview AS SELECT ut_id,SUM(re_richieste) as num_rich, re_anno FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY ut_id ");
$result1 = $_SESSION['db']->execute("SELECT AVG(num_rich) AS media, re_anno FROM $nameview GROUP BY re_anno ");
$_SESSION['db']->execute("DROP VIEW IF EXISTS $nameview");
$data = array();
$assex = array();
$c = "";
$assex[0] = '';
$data[0] = '';
while ($row = $_SESSION['db']->fetch($result1)) {
$data[] = round($row["media"], 2);
$c = $assex[] = $row["re_anno"];
}
$ret.= "<h3>" . getConstVar("REPORTS_GRAPH_GLOBALE1C") . " (" . getConstVar("AVG") . ")" . "</h3><br/>";
if ($_SESSION['db']->numrows($result1) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->SetScale('intlin');
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->legend->Pos(0.05, 0.01, 'top', 'left');
$lineplot = new LinePlot($data);
$lineplot->SetWeight(getConstVar("GRAPH_LINE_WIDTH"));
$lineplot->SetLegend(getConstVar("REPORTS_GRAPHLABEL_GLOBALE1C"));
$lineplot->value->SetFormat("%01.2f");
$lineplot->value->Show();
$lineplot->SetColor("red");
$lineplot->mark->SetType(MARK_IMG_DIAMOND, 'red', 0.4);
$graph->Add($lineplot);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->title->Set(getConstVar("ANNI"));
$graph->xaxis->SetTickLabels($assex);
$ret.= print_tagimg($graph);
}
return $ret;
break;
case "globale1D":
$nameview = "view_" . rand(0, 999999);
$view = $_SESSION['db']->execute("CREATE VIEW $nameview AS SELECT ut_id,SUM(re_richieste) as re_richieste,re_anno FROM `report_utente` WHERE bi_id=" . $_SESSION['biblio']->bi_id . " GROUP BY ut_id");
$result = $_SESSION['db']->execute("SELECT re_anno,SUM(CASE when re_richieste <=2 THEN 1 ELSE 0 END) as gruppo1,SUM(CASE when re_richieste >2 AND re_richieste <5 THEN 1 ELSE 0 END) as gruppo2,SUM(CASE when re_richieste >=5 AND re_richieste <=10 THEN 1 ELSE 0 END) as gruppo3,SUM(CASE when re_richieste >10 AND re_richieste <=20 THEN 1 ELSE 0 END) as gruppo4,SUM(CASE when re_richieste >20 AND re_richieste <=50 THEN 1 ELSE 0 END) as gruppo5,SUM(CASE when re_richieste > 50 AND re_richieste <=100 THEN 1 ELSE 0 END) as gruppo6,SUM(CASE when re_richieste >100 THEN 1 ELSE 0 END) as gruppo7 FROM $nameview GROUP by re_anno order by re_anno ASC");
$data = array();
$gruppo1 = array();
$gruppo2 = array();
$gruppo3 = array();
$gruppo4 = array();
$gruppo5 = array();
$gruppo6 = array();
$gruppo7 = array();
$assex = array();
$_SESSION['db']->execute("DROP VIEW IF EXISTS $nameview");
while ($row = $_SESSION['db']->fetch($result)) {
$gruppo1[] = $row["gruppo1"];
$gruppo2[] = $row["gruppo2"];
$gruppo3[] = $row["gruppo3"];
$gruppo4[] = $row["gruppo4"];
$gruppo5[] = $row["gruppo5"];
$gruppo6[] = $row["gruppo6"];
$gruppo7[] = $row["gruppo7"];
$assex[] = $row["re_anno"];
}
$ret.= "<h3>" . getConstVar("REPORTS_GRAPH_GLOBALE1D") . "</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->SetScale("textint");
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$b1plot = new BarPlot($gruppo1);
$b1plot->SetFillColor("bisque4");
$b1plot->SetLegend("1 ή 2 " . getConstVar("REPORTS_RICHIESTE"));
$b2plot = new BarPlot($gruppo2);
$b2plot->SetFillColor("bisque");
$b2plot->SetLegend(">2 " . getConstVar("REPORTS_RICHIESTE"));
$b3plot = new BarPlot($gruppo3);
$b3plot->SetFillColor("plum");
$b3plot->SetLegend(">5 " . getConstVar("REPORTS_RICHIESTE"));
$b4plot = new BarPlot($gruppo4);
$b4plot->SetFillColor("thistle");
$b4plot->SetLegend(">10 " . getConstVar("REPORTS_RICHIESTE"));
$b5plot = new BarPlot($gruppo5);
$b5plot->SetFillColor("cornflowerblue");
$b5plot->SetLegend(">20 " . getConstVar("REPORTS_RICHIESTE"));
$b6plot = new BarPlot($gruppo6);
$b6plot->SetFillColor("lightpink");
$b6plot->SetLegend(">50 " . getConstVar("REPORTS_RICHIESTE"));
$b7plot = new BarPlot($gruppo7);
$b7plot->SetFillColor("lightblue");
$b7plot->SetLegend(">100 " . getConstVar("REPORTS_RICHIESTE"));
$gbplot = new AccBarPlot(array($b1plot, $b2plot, $b3plot, $b4plot, $b5plot, $b6plot, $b7plot));
$graph->Add($gbplot);
$graph->legend->SetColumns(4);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->legend->Pos(0.05, 0.01, 'right', 'top');
$graph->xaxis->SetTickLabels($assex);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->title->Set(getConstVar("ANNI"));
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->title->Set(getConstVar("REPORTS_NUM_UTENTI"));
$ret.= print_tagimg($graph);
}
return $ret;
break;
case "globale1E":
$result = $_SESSION['db']->execute("SELECT YEAR(rm_datarichie) as re_anno, IFNULL(ROUND(AVG(UNIX_TIMESTAMP(STR_TO_DATE(dd_lastmodify, '%Y-%m-%d %H:%i:%s')) - UNIX_TIMESTAMP(STR_TO_DATE(rm_datarichie, '%Y-%m-%d %H:%i:%s')))/86400,3),0) as tempo_medio_L from docdel GROUP BY re_anno");
$datay = array();
$datay1 = array();
$assex = array();
$c = "";
$assex[0] = '';
$datay[0] = '';
$datay1[0] = '';
while ($row = $_SESSION['db']->fetch($result)) {
$datay[] = 0;
$datay1[] = $row["tempo_medio_L"];
$c = $assex[] = $row["re_anno"];
}
$ret.= "<h3>" . getConstVar("REPORTS_GRAPHTITLE_GLOBALE1E") . " (" . getConstVar("INDAYS") . ")" . " </h3><br/>";
if ($_SESSION['db']->numrows($result) == 0 || (array_sum($datay) == 0 && array_sum($datay1) == 0)) {
$ret.= "<div>" . getConstVar("NOWORKTODOAVG") . "</div>";
} else {
$graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->SetScale('intlin');
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->legend->Pos(0.05, 0.01, 'top', 'left');
$lineplot = new LinePlot($datay);
$lineplot->SetWeight(getConstVar("GRAPH_LINE_WIDTH"));
$lineplot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI"));
$lineplot->value->SetFormat("%01.2f");
$lineplot->value->Show();
$lineplot->SetColor(getConstVar("GRAPH_BAR1COLOR"));
$lineplot->mark->SetType(MARK_IMG_DIAMOND, 'red', 0.4);
$graph->Add($lineplot);
$lineplot2 = new LinePlot($datay1);
$lineplot2->SetWeight(getConstVar("GRAPH_LINE_WIDTH"));
$lineplot2->SetLegend(getConstVar("REPORTS_ART_FORNITI"));
$lineplot2->value->SetFormat("%01.2f");
$lineplot2->value->Show();
$lineplot2->SetColor(getConstVar("GRAPH_BAR2COLOR"));
$lineplot2->mark->SetType(MARK_IMG_DIAMOND, 'blue', 0.4);
$graph->Add($lineplot2);
$graph->xaxis->SetTickLabels($assex);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->title->Set(getConstVar("ANNI"));
$ret.= print_tagimg($graph);
}
return $ret;
break;
case "biblio2A":
$result = $_SESSION['db']->execute("SELECT SUM(re_richieste_bw) as num_rich, SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel) as articoli_richiesti, SUM(re_richieste_ln) as rich_ln, SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel) AS articoli_forniti,SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro) as inevasi_bw,SUM(re_inevaso_ln_riferr)+SUM(re_inevaso_ln_nonposs)+SUM(re_inevaso_ln_nondisp)+SUM(re_inevaso_ln_over15)+SUM(re_inevaso_ln_overquota)+SUM(re_inevaso_ln_altro) as inevasi_ln FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno = $year GROUP BY re_anno");
$data = array();
$assex = array(getConstVar("BORROWING"), getConstVar("LENDING"));
$ret.="<h3>" . getConstVar("REPORTS_GRAPHTITLE_BIBLIO2A") . "</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
if ($_SESSION['db']->numrows($result) == 1) {
$row = $_SESSION['db']->fetch($result);
$dataT[] = $row["num_rich"];
$dataT[] = $row["rich_ln"];
$dataE[] = $row["articoli_richiesti"];
$dataE[] = $row["articoli_forniti"];
$dataI[] = $row["inevasi_bw"];
$dataI[] = $row["inevasi_ln"];
if (array_sum($dataT) == 0 && array_sum($dataE) == 0 && array_sum($dataI) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->SetScale('textint');
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->legend->Pos(0.05, 0.01, 'top', 'left');
$bplot = new BarPlot($dataT);
$bplot->SetFillColor("lightskyblue");
$bplot->value->SetFormat('%01.0f');
$bplot->value->Show();
$bplot->SetLegend(getConstVar("REPORTS_ALLREQ"));
$b2plot = new BarPlot($dataE);
$b2plot->SetFillColor("seagreen");
$b2plot->value->SetFormat('%01.0f');
$b2plot->value->Show();
$b2plot->SetLegend(getConstVar("REPORTS_REQ_EVASE"));
$b3plot = new BarPlot($dataI);
$b3plot->SetFillColor("tomato");
$b3plot->value->SetFormat('%01.0f');
$b3plot->value->Show();
$b3plot->SetLegend(getConstVar("REPORTS_REQ_INEVASE"));
$gbplot = new GroupBarPlot(array($bplot, $b2plot, $b3plot));
$graph->Add($gbplot);
$graph->xaxis->SetTickLabels($assex);
$ret.= print_tagimg($graph);
}
}
}
return $ret;
break;
case "riepilogo":
$result = $_SESSION['db']->execute("SELECT (SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel))/( SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel)+SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro)) as tasso_successo_bw, (SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel))/( SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel)+SUM(re_inevaso_ln_riferr)+SUM(re_inevaso_ln_nonposs)+SUM(re_inevaso_ln_nondisp)+SUM(re_inevaso_ln_over15)+SUM(re_inevaso_ln_overquota)+SUM(re_inevaso_ln_altro)) AS tasso_successo_ln FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno = $year GROUP BY re_anno");
$result3 = $_SESSION['db']->execute("SELECT SUM(re_tempo_risp_bw)/SUM(re_richieste_bw)/86400 as media_giac_bw,SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as media_giac_ln FROM report_biblio where re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno");
$ret.= "<h3>" . getConstVar("REPORTS_GRAPH_RIEPILOGO") . " " . getConstVar("NILDE_PLAIN") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 1) {
$tassi = $_SESSION['db']->fetch($result);
$tempi = $_SESSION['db']->fetch($result3);
$ret.= " <table class=\"report_table\">";
$ret.= " <tr><th class=\"sx\">" . getConstVar("INDICATORE") . "</th><th class=\"dx\">" . getConstVar("VALORE") . "</th></tr>";
$ret.= " <tr class=\"item1\"><td>" . getConstVar("REPORTS_GRAPH_RIEPILOGO_SB") . "</td><td>" . (round($tassi["tasso_successo_bw"], 3) * 100) . "%</td></tr>";
$ret.= " <tr class=\"item2\"><td>" . getConstVar("REPORTS_GRAPH_RIEPILOGO_SL") . "</td><td>" . (round($tassi["tasso_successo_ln"], 3) * 100) . "%</td></tr>";
$ret.= " <tr class=\"item1\"><td>" . getConstVar("REPORTS_GRAPH_RIEPILOGO_TB") . "</td><td>" . round($tempi["media_giac_bw"], 2) . " " . getConstVar("DAYS") . "</td></tr>";
$ret.= " <tr class=\"item2\"><td>" . getConstVar("REPORTS_GRAPH_RIEPILOGO_TL") . " </td><td>" . round($tempi["media_giac_ln"], 2) . " " . getConstVar("DAYS") . "</td></tr>";
$ret.= "</table>";
} else {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
}
return $ret;
break;
case "biblio2D":
$result = $_SESSION['db']->execute("SELECT SUM(re_evaso_bw_nilde) AS Nilde, SUM(re_evaso_bw_posta) AS Posta, SUM(re_evaso_bw_fax) AS Fax, SUM(re_evaso_bw_ariel) AS Ariel, SUM(re_evaso_bw_altro) AS Altro, SUM(re_evaso_bw_fn) AS FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno");
$data = array();
$tab = "";
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_BIBLIO2D") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$i = 0;
$tabbody = "";
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row["Nilde"];
$data[] = $row["Posta"];
$data[] = $row["Fax"];
$data[] = $row["Ariel"];
$data[] = $row["Altro"];
$data[] = $row["FN"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["Nilde"] . "</td>
<td>" . $row["Posta"] . "</td>
<td>" . $row["Fax"] . "</td>
<td>" . $row["Ariel"] . "</td>
<td>" . $row["Altro"] . "</td>
<td>" . $row["FN"] . "</td>
</tr>";
$i++;
}
$legend = array(getConstVar("NILDE_PLAIN"), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")), getConstVar("FN"));
$datat[] = $legend;
$datat[] = $data;
if (array_sum($data) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($legend);
$graph->Add($p1);
$graph->legend->SetColumns(3);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("NILDE_PLAIN") . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")) . "</th>
<th class=\"dx\">" . getConstVar("FN") . "</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
}
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "biblio2E":
$result = $_SESSION['db']->execute("SELECT SUM(re_inevaso_bw_riferr) as RifErrato, SUM(re_inevaso_bw_nonposs) as NonPoss, SUM(re_inevaso_bw_nondisp) as NonDisp, SUM(re_inevaso_bw_over15) as Over15, SUM(re_inevaso_bw_overquota) as OverQuota, SUM(re_inevaso_bw_altro) as Altro, SUM(re_inevaso_bw_fn) as FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno");
$data = array();
$tab = "";
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_BIBLIO2E") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$i = 0;
$tabbody = "";
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row["RifErrato"];
$data[] = $row["NonPoss"];
$data[] = $row["NonDisp"];
$data[] = $row["Over15"];
$data[] = $row["OverQuota"];
$data[] = $row["Altro"];
$data[] = $row["FN"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["RifErrato"] . "</td>
<td>" . $row["NonPoss"] . "</td>
<td>" . $row["NonDisp"] . "</td>
<td>" . $row["Over15"] . "</td>
<td>" . $row["OverQuota"] . "</td>
<td>" . $row["Altro"] . "</td>
<td>" . $row["FN"] . "</td>
</tr>";
$i++;
}
$legend = array(getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")), 'FN');
$datat[] = $legend;
$datat[] = $data;
if (array_sum($data) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($legend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")) . "</th>
<th class=\"dx\">FN</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
}
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "biblio2F":
$result = $_SESSION['db']->execute("SELECT SUM(re_evaso_ln_nilde) as Nilde, SUM(re_evaso_ln_posta) as Posta, SUM(re_evaso_ln_fax) as Fax, SUM(re_evaso_ln_ariel) as Ariel, SUM(re_evaso_ln_altro) as Altro,SUM(re_evaso_ln_fn) as FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno");
$data = array();
$datat = array();
$tab = "";
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_BIBLIO2F") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$i = 0;
$tabbody = "";
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row["Nilde"];
$data[] = $row["Posta"];
$data[] = $row["Fax"];
$data[] = $row["Ariel"];
$data[] = $row["Altro"];
$data[] = $row["FN"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["Nilde"] . "</td>
<td>" . $row["Posta"] . "</td>
<td>" . $row["Fax"] . "</td>
<td>" . $row["Ariel"] . "</td>
<td>" . $row["Altro"] . "</td>
<td>" . $row["FN"] . "</td>
</tr>";
$i++;
}
$legend = array(getConstVar("NILDE_PLAIN"), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")), getConstVar("FN"));
$datat[] = $legend;
$datat[] = $data;
if (array_sum($data) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($legend);
$graph->Add($p1);
$graph->legend->SetColumns(3);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("NILDE_PLAIN") . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_POSTA")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_FAX")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ARIEL")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_EVASO_ALTRO")) . "</th>
<th class=\"dx\">" . getConstVar("FN") . "</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
}
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "biblio2G":
$result = $_SESSION['db']->execute("SELECT SUM(re_inevaso_ln_riferr) as RifErrato, SUM(re_inevaso_ln_nonposs) as NonPoss, SUM(re_inevaso_ln_nondisp) as NonDisp, SUM(re_inevaso_ln_over15) as Over15, SUM(re_inevaso_ln_overquota) as OverQuota, SUM(re_inevaso_ln_altro) as Altro, SUM(re_inevaso_ln_fn) as FN FROM report_biblio WHERE re_anno=$year AND bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno");
$tab = "";
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_BIBLIO2G") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$i = 0;
$tabbody = "";
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row["RifErrato"];
$data[] = $row["NonPoss"];
$data[] = $row["NonDisp"];
$data[] = $row["Over15"];
$data[] = $row["OverQuota"];
$data[] = $row["Altro"];
$data[] = $row["FN"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["RifErrato"] . "</td>
<td>" . $row["NonPoss"] . "</td>
<td>" . $row["NonDisp"] . "</td>
<td>" . $row["Over15"] . "</td>
<td>" . $row["OverQuota"] . "</td>
<td>" . $row["Altro"] . "</td>
<td>" . $row["FN"] . "</td>
</tr>";
$i++;
}
$legend = array(getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")), getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")), 'FN');
$datat[] = $legend;
$datat[] = $data;
if (array_sum($data) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($legend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_RIFFERR")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONPOSS")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_NONDISP")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVER15")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_OVERQUOTA")) . "</th>
<th>" . getConstVar("dd_stato_ddill_" . getConstVar("DDILL_INEVASO_ALTRO")) . "</th>
<th class=\"dx\">FN</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
}
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "biblio2H":
if (!isset($report_order))
$report_order = "bi_nome";
$report_qualif = isset($report_qualif) ? $report_qualif : "asc";
$ord = $report_order . " " . $report_qualif;
if ($report_order == "bi_nome")
$ord = "prov_id $report_qualif,$report_order $report_qualif";
$result = $_SESSION['db']->execute("SELECT bi_nome, prov_id,rb.bi_idforni, SUM(re_richieste_bw) AS ordini_inviati, SUM(re_richieste_ln) AS ordini_ricevuti, SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_ariel)+SUM(re_evaso_bw_altro) AS art_ricevuti,SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro) AS art_forniti,(SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro))-(SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_ariel)+SUM(re_evaso_bw_altro)) AS diff_forni_ricev,SUM(re_richieste_bw_fn) AS ordini_fn_inviati, SUM(re_richieste_ln_fn) AS ordini_fn_ricevuti, SUM(re_evaso_bw_fn) AS art_fn_ricevuti, SUM(re_evaso_ln_fn) AS art_fn_forniti, (SUM(re_evaso_ln_fn))-(SUM(re_evaso_bw_fn)) AS diff_fn_forni_ricev, SUM(re_costo_bw_fn) AS costo_bw_fn,SUM(re_costo_ln_fn) AS costo_ln_fn FROM report_biblio as rb,biblio WHERE biblio.bi_id=rb.bi_idforni AND rb.bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rb.bi_idforni ORDER BY $ord");
$tab = "<h3>" . getConstVar("REPORTS_GRAPH_BIBLIO2H") . "</h3><br/>";
$tab.="<table class=\"report_table\">
<thead>
<tr><th class=\"empty\"></th><th class=\"centersx\" colspan=\"5\">NILDE</th><th class=\"middle_empty\"></th><th class=\"centerdx\" colspan=\"7\">" . getConstVar("FN") . "</th></tr>
<tr>
<th class=\"sx\">" . print_sorted_table_column('bi_nome', getConstVar("bi_nome"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('ordini_inviati', getConstVar("REPORTS_ORDINI_INVIATI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('art_ricevuti', getConstVar("REPORTS_ART_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('ordini_ricevuti', getConstVar("REPORTS_ORDINI_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('art_forniti', getConstVar("REPORTS_ART_FORNITI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('diff_forni_ricev', getConstVar("REPORTS_DIFF_ARTICOLI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th class=\"middle_empty\"></th>
<th>" . print_sorted_table_column('ordini_fn_inviati', getConstVar("REPORTS_ORDINI_INVIATI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('art_fn_ricevuti', getConstVar("REPORTS_ART_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('ordini_fn_ricevuti', getConstVar("REPORTS_ORDINI_RICEVUTI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('art_fn_forniti', getConstVar("REPORTS_ART_FORNITI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('diff_fn_forni_ricev', getConstVar("REPORTS_DIFF_ARTICOLI"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('costo_bw_fn', getConstVar("REPORTS_COSTO_BORROWING"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('costo_ln_fn', getConstVar("REPORTS_COSTO_LENDING"), $report_order, $report_qualif, "reports.php?typegraph=biblio2H&year=$year", "sort_report") . "</th>
</tr>
</thead>";
$i = 0;
if ($_SESSION['db']->numrows($result) == 0) {
$tab.=" <tr class=\"no_item\">";
$tab.=" <td colspan=\"8\">" . getConstVar("NOWORKTODO") . "</td>";
$tab.=" </tr>";
} else {
$CodACNPsmt = $_SESSION['db']->prepareSTMT("SELECT acnp_cod FROM tab_acnp WHERE bi_id=?");
while ($row = $_SESSION['db']->fetch($result)) {
$acnpcod = "";
$CodACNPsmt->bind_param('i', $row['bi_idforni']);
$CodACNPsmt->execute();
$CodACNPsmt->bind_result($acnpcod);
$CodACNPsmt->fetch();
$CodACNPsmt->free_result();
if ($acnpcod != "")
$acnpcod.=" - ";
$i++;
$fornitrice = SQL_unescape($row["bi_nome"]);
$rich_bw = $row["ordini_inviati"];
$num_ricev = $row["art_ricevuti"];
$rich_ln = $row["ordini_ricevuti"];
$num_forni = $row["art_forniti"];
$diff_forni_ricev = $row["diff_forni_ricev"];
$rich_fn_bw = $row["ordini_fn_inviati"];
$num_fn_ricev = $row["art_fn_ricevuti"];
$rich_fn_ln = $row["ordini_fn_ricevuti"];
$num_fn_forni = $row["art_fn_forniti"];
$diff_fn_ricev_forni = $row["diff_fn_forni_ricev"];
$costo_fn_B = $row["costo_bw_fn"];
$costo_fn_L = $row["costo_ln_fn"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
if ($year >= date('Y') - getConstVar("HISTORY_DATE_INTERVAL")) {
$data = "&datarichie_from_aaaa=$year&datarichie_from_mm=1&datarichie_from_gg=1&datarichie_to_aaaa=$year&datarichie_to_mm=12&datarichie_to_gg=31";
if ($rich_bw > 0) {
$param1 = "tipo=1&label=0&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data;
$rich_bw = "<a href=\"javascript:reportsDetails('$param1')\">$rich_bw</a>";
}
if ($num_ricev > 0) {
$param2 = "tipo=1&label=1&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data;
$num_ricev = "<a href=\"javascript:reportsDetails('$param2')\">$num_ricev</a>";
}
if ($rich_ln > 0) {
$param3 = "tipo=1&label=0&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data;
$rich_ln = "<a href=\"javascript:reportsDetails('$param3')\">$rich_ln</a>";
}
if ($num_forni > 0) {
$param4 = "tipo=1&label=1&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data;
$num_forni = "<a href=\"javascript:reportsDetails('$param4')\">$num_forni</a>";
}
if ($rich_fn_bw > 0) {
$param1 = "tipo=1&label=3&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data;
$rich_fn_bw = "<a href=\"javascript:reportsDetails('$param1')\">$rich_fn_bw</a>";
}
if ($num_fn_ricev > 0) {
$param2 = "tipo=1&label=4&tipobl=1&bibliosel=" . $row["bi_idforni"] . $data;
$num_fn_ricev = "<a href=\"javascript:reportsDetails('$param2')\">$num_fn_ricev</a>";
}
if ($rich_fn_ln > 0) {
$param3 = "tipo=1&label=3&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data;
$rich_fn_ln = "<a href=\"javascript:reportsDetails('$param3')\">$rich_fn_ln</a>";
}
if ($num_fn_forni > 0) {
$param4 = "tipo=1&label=4&tipobl=2&bibliosel=" . $row["bi_idforni"] . $data;
$num_fn_forni = "<a href=\"javascript:reportsDetails('$param4')\">$num_fn_forni</a>";
}
}
$idbibpopup = $row['bi_idforni'];
$fornitrice = $acnpcod . "<a id=\"library_link_$idbibpopup\" href=\"javascript:read_biblio_info($idbibpopup,$idbibpopup)\">" . $fornitrice . "</a>$baloon_library";
$tab.="
<tbody align=\"center\">
<tr class=\"$itemcl\">
<td>" . $fornitrice . "</td>
<td>" . $rich_bw . "</td>
<td>" . $num_ricev . "</td>
<td>" . $rich_ln . "</td>
<td>" . $num_forni . "</td>
<td>" . $diff_forni_ricev . "</td>
<td class=\"middle_empty\"></td>
<td>" . $rich_fn_bw . "</td>
<td>" . $num_fn_ricev . "</td>
<td>" . $rich_fn_ln . "</td>
<td>" . $num_fn_forni . "</td>
<td>" . $diff_fn_ricev_forni . "</td>
<td>" . $costo_fn_B . " &euro;</td>
<td>" . $costo_fn_L . " &euro;</td>
</tr>
</tbody>";
}
}
$tab.="</table>";
return $tab;
break;
case "biblio2I":
$result = $_SESSION['db']->execute("SELECT SUM(re_richieste_bw) as Richieste_Borrowing, SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel) as num_articoli_ricev, SUM(re_richieste_ln) as Richieste_Lending, SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel)+SUM(re_evaso_ln_altro) as num_articoli_forniti, SUM(re_inevaso_bw_riferr)+SUM(re_inevaso_bw_nonposs)+SUM(re_inevaso_bw_nondisp)+SUM(re_inevaso_bw_over15)+SUM(re_inevaso_bw_overquota)+SUM(re_inevaso_bw_altro) as inevasi_bw,SUM(re_inevaso_ln_riferr)+SUM(re_inevaso_ln_nonposs)+SUM(re_inevaso_ln_nondisp)+SUM(re_inevaso_ln_over15)+SUM(re_inevaso_ln_overquota)+SUM(re_inevaso_ln_altro) as inevasi_ln,MONTH(STR_TO_DATE(re_mese,'%m')) as mese FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " AND re_anno = $year GROUP BY re_mese ORDER BY re_mese ASC ");
$data_richbw = array();
$num_rich = array();
$data_richln = array();
$num_forni = array();
$assex = array();
$label = array();
$ret.= "<h3>" . getConstVar("REPORTS_GRAPH_BIBLIO2I") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
while ($row = $_SESSION['db']->fetch($result)) {
$data_richbw[] = $row["inevasi_bw"];
$num_rich[] = $row["num_articoli_ricev"];
$data_richln[] = $row["inevasi_ln"];
$num_forni[] = $row["num_articoli_forniti"];
$assex[] = $row["mese"];
}
foreach (getConstVar("ARRAY_MESI") as $k => $v) {
if (in_array($k, $assex)) {
$label[] = $v;
}
}
if ((array_sum($data_richbw) == 0) && (array_sum($num_rich) == 0) && (array_sum($data_richln) == 0) && (array_sum($num_forni) == 0)) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new Graph(getConstVar("GRAPH_WIDTH"), getConstVar("GRAPH_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->SetScale('textint');
$graph->SetBackgroundGradient(getConstVar("GRAPH_COLOR_BG1"), getConstVar("GRAPH_COLOR_BG2"));
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->legend->Pos(0.05, 0.01, 'top', 'left');
$b1plot = new BarPlot($data_richbw);
$b1plot->SetFillColor('bisque3');
$b1plot->SetLegend(getConstVar("REPORTS_BW_INEVASE"));
$b1plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 9);
$b1plot->value->Show();
$b1plot->value->SetFormat('%01.0f');
$b2plot = new BarPlot($num_rich);
$b2plot->SetFillColor("bisque");
$b2plot->SetLegend(getConstVar("REPORTS_ART_RICEVUTI"));
$b2plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 7);
$b2plot->value->Show();
$b2plot->value->SetFormat('%01.0f');
$b3plot = new BarPlot($data_richln);
$b3plot->SetFillColor("plum");
$b3plot->SetLegend(getConstVar("REPORTS_LN_INEVASE"));
$b3plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 7);
$b3plot->value->Show();
$b3plot->value->SetFormat('%01.0f');
$b4plot = new BarPlot($num_forni);
$b4plot->SetFillColor("thistle");
$b4plot->SetLegend(getConstVar("REPORTS_ART_FORNITI"));
$b4plot->value->SetFont(FF_DV_SERIF, FS_NORMAL, 7);
$b4plot->value->SetAngle(getConstVar("GRAPH_BAR_VALUE_ANGLE"));
$b4plot->value->Show();
$b4plot->value->SetFormat('%01.0f');
$gbplot = new GroupBarPlot(array($b1plot, $b2plot, $b3plot, $b4plot));
$graph->Add($gbplot);
$graph->xaxis->SetTickLabels($label);
$graph->xaxis->SetFont(FF_DV_SERIF, FS_NORMAL, 8);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xaxis->title->Set(getConstVar("MESI"));
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->title->Set(getConstVar("REPORTS_NUM_RICHIE"));
$ret.= print_tagimg($graph);
}
}
return $ret;
break;
case "biblio2L":
$ord1 = "ricevuti";
$ord2 = "forniti";
$q1 = "desc";
$q2 = "desc";
if (isset($report_order)) {
if ($_REQUEST["gr"] == 1) {
$ord1 = $report_order;
$q1 = $report_qualif;
} else if ($_REQUEST["gr"] == 2) {
$ord2 = $report_order;
$q2 = $report_qualif;
}
}
$result = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_ricev) as ricevuti
FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (ricevuti>0) ORDER by $ord1 $q1 LIMIT 50");
$result1 = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_forni) as forniti
FROM report_rivista WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (forniti > 0) ORDER by $ord2 $q2 LIMIT 50");
$tit = "";
$tabB = "";
$tabL = "";
$tit = "<h3>" . getConstVar("REPORTS_GRAPHTITLE_BIBLIO2L") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0 && $_SESSION['db']->numrows($result1) == 0) {
$tabB = getConstVar("NOWORKTODO");
$tabL = "";
} else {
if ($_SESSION['db']->numrows($result) != 0) {
$tabB.="<table class=\"report_table\">
<thead>
<tr>
<th class=\"sx\">" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2L"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2L&year=$year", "sort_report") . "</th>
<th class=\"dx\">" . print_sorted_table_column('ricevuti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_RICEVUTI"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2L&year=$year", "sort_report") . "</th>
</tr>
</thead>";
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabB.="<tr class=\"$itemcl\">
<td>" . $row["rv"] . "</td>
<td>" . $row["ricevuti"] . "</td>
</tr>";
$i++;
}
$tabB.="</table>";
}
if ($_SESSION['db']->numrows($result1) != 0) {
$tabL.="<table class=\"report_table\">
<thead>
<tr>
<th class=\"sx\">" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2L"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2L&year=$year", "sort_report") . "</th>
<th class=\"dx\">" . print_sorted_table_column('forniti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_FORNITI"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2L&year=$year", "sort_report") . "</th>
</tr>
</thead>";
$j = 0;
while ($row = $_SESSION['db']->fetch($result1)) {
$itemcl = "item1";
if ($j % 2 != 0)
$itemcl = "item2";
$tabL.="<tr class=\"$itemcl\">
<td>" . $row["rv"] . "</td>
<td>" . $row["forniti"] . "</td>
</tr>";
$j++;
}
$tabL.="</table>";
}
}
if ($tabB != "")
$tabB.="<br/>";
return $tit . $tabB . $tabL;
break;
case "biblio2M":
$ord1 = "ricevuti";
$ord2 = "forniti";
$q1 = "desc";
$q2 = "desc";
if (isset($report_order)) {
if ($_REQUEST["gr"] == 1) {
$ord1 = $report_order;
$q1 = $report_qualif;
} else if ($_REQUEST["gr"] == 2) {
$ord2 = $report_order;
$q2 = $report_qualif;
}
}
$result = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_ricev) as ricevuti
FROM report_monografia WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (ricevuti>0) order by $ord1 $q1 LIMIT 50");
$result1 = $_SESSION['db']->execute("SELECT rv_nome as rv, SUM(re_art_forni) as forniti
FROM report_monografia WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY rv_nome HAVING (forniti>0) order by $ord2 $q2 LIMIT 50");
$tit = "";
$tabB = "";
$tabL = "";
$tabbody = "";
$tabbodyl = "";
$tit = "<h3>" . getConstVar("REPORTS_GRAPH_BIBLIO2M") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0 && $_SESSION['db']->numrows($result1) == 0) {
$tabB = getConstVar("NOWORKTODO");
$tabL = "";
} else {
if ($_SESSION['db']->numrows($result) != 0) {
$tabB.="<table class=\"report_table\">
<thead>
<tr>
<th class=\"sx\">" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2M"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2M&year=$year", "sort_report") . "</th>
<th class=\"dx\">" . print_sorted_table_column('ricevuti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_RICEVUTI"), $ord1, $q1, "reports.php?gr=1&typegraph=biblio2M&year=$year", "sort_report") . "</th>
</tr>
</thead>";
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabB.="<tr class=\"$itemcl\">
<td>" . $row["rv"] . "</td>
<td>" . $row["ricevuti"] . "</td>
</tr>";
$i++;
}
$tabB.="</table>";
}
if ($_SESSION['db']->numrows($result1) != 0) {
$tabL.="<table class=\"report_table\">
<thead>
<tr>
<th class=\"sx\">" . print_sorted_table_column('rv', getConstVar("REPORTS_TABLE_BIBLIO2M"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2M&year=$year", "sort_report") . "</th>
<th class=\"dx\">" . print_sorted_table_column('forniti', getConstVar("REPORTS_NUM_RICHIE") . " " . getConstVar("REPORTS_ART_FORNITI"), $ord2, $q2, "reports.php?gr=2&typegraph=biblio2M&year=$year", "sort_report") . "</th>
</tr>
</thead>";
$j = 0;
while ($row = $_SESSION['db']->fetch($result1)) {
$itemcl = "item1";
if ($j % 2 != 0)
$itemcl = "item2";
$tabL.="<tr class=\"$itemcl\">
<td>" . $row["rv"] . "</td>
<td>" . $row["forniti"] . "</td>
</tr>";
$j++;
}
$tabL.="</table>";
}
}
if ($tabB != "")
$tabB.="<br/>";
return $tit . $tabB . $tabL;
break;
case "utente3A":
$tab = "";
$result = $_SESSION['db']->execute("SELECT SUM(re_evase_dir) as Evase_direttamente,SUM(re_inevase_dir) as Inevase_direttamente FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year");
$ret.="<h3>" . getConstVar("REPORTS_GRAPHTITLE_UTENTE3A") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$i = 0;
$tabbody = "";
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row["Evase_direttamente"];
$data[] = $row["Inevase_direttamente"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["Evase_direttamente"] . "</td>
<td>" . $row["Inevase_direttamente"] . "</td>
</tr>";
$i++;
}
$legend = array(getConstVar("EVASE_DIR"), getConstVar("INEVASE_DIR"));
$datat[] = $legend;
$datat[] = $data;
if (array_sum($data) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($legend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("EVASE_DIR") . "</th>
<th class=\"dx\">" . getConstVar("INEVASE_DIR") . "</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
}
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "utente3B":
$nameview = "view_" . rand(0, 999999); //tabella
$result = $_SESSION['db']->execute("SELECT count(distinct ut_id) as num FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year AND re_richieste >= 1 ");
$_SESSION['db']->execute("CREATE VIEW $nameview AS SELECT SUM(re_richieste) as num_rich, ut_id FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_id");
$result1 = $_SESSION['db']->execute("SELECT AVG(num_rich) as media, MAX(num_rich) as max FROM $nameview");
$x = $_SESSION['db']->execute("DROP VIEW IF EXISTS $nameview");
$result2 = $_SESSION['db']->execute("SELECT SUM(re_richieste) as num_rich FROM report_utente WHERE bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year");
$ret.= "<h3>" . getConstVar("REPORTS_GRAPH_UTENTE3B") . " ($year)</h3><br/>";
$ret.= " <table class=\"report_table\">";
$ret.= " <tr><th class=\"sx\">" . getConstVar("INDICATORE") . "</th><th class=\"dx\">" . getConstVar("VALORE") . "</th></tr>";
if ($_SESSION['db']->numrows($result) == 1) {
$count = $_SESSION['db']->fetch($result);
$dati = $_SESSION['db']->fetch($result1);
$num = $_SESSION['db']->fetch($result2);
$ret.= " <tr class=\"item1\"><td>" . getConstVar("REPORTS_GRAPH_UTENTE3B_RS") . "</td><td>" . (($num["num_rich"] != null) ? $num["num_rich"] : '0') . "</td></tr>";
$ret.= " <tr class=\"item2\"><td>" . getConstVar("REPORTS_GRAPH_UTENTE3B_RD") . "</td><td>" . $count["num"] . "</td></tr>";
$ret.= " <tr class=\"item1\"><td>" . getConstVar("REPORTS_GRAPH_UTENTE3B_MER") . "</td><td>" . round($dati["media"], 2) . "</td></tr>";
$ret.= " <tr class=\"item2\"><td>" . getConstVar("REPORTS_GRAPH_UTENTE3B_MAXR") . "</td><td>" . ($dati["max"] != null ? $dati["max"] : '0') . "</td></tr>";
}
$ret.= "</table>";
return $ret;
break;
case "utente3G":
$result = $_SESSION['db']->execute("SELECT SUM(re_richieste) as Numero_art_richiesti, ut_dip,dip_nome FROM report_utente LEFT JOIN dipartimento ON report_utente.ut_dip = dipartimento.dip_id WHERE report_utente.bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_dip; ");
$tab = "";
$data = array();
$data1 = array();
$datalegend = array();
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_UTENTE3G") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$tabbody = '<tbody align=\"center\">';
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
if ($row["ut_dip"] == 0)
$row["dip_nome"] = strtoupper(getConstVar("SENZA_DIP"));
$datalegend[] = $row["dip_nome"];
$data[] = $row["dip_nome"];
$data1[] = $row["Numero_art_richiesti"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["dip_nome"] . "</td>
<td>" . $row["Numero_art_richiesti"] . "</td>
</tr>";
$i++;
}
$tabbody.="</tbody>";
if (array_sum($data1) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data1);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(5);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("REPORTS_DIPARTIMENTO") . "</th>
<th class=\"dx\">" . getConstVar("REPORTS_NUM_RICHIE") . "</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
}
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "utente3H":
$result = $_SESSION['db']->execute("SELECT tq.qualifica as nome_qualifica, SUM( re_richieste ) as NUM_ART_RICHIESTI FROM report_utente AS ru, qualifica AS q,t_qualifica AS tq WHERE q.qu_id=tq.qu_id AND tq.lang_id='" . $_SESSION['lang'] . "' AND ru.qu_id = q.qu_id AND ru.bi_id=" . $_SESSION['biblio']->bi_id . " AND ru.re_anno=$year GROUP BY ru.qu_id ");
$ret.="";
$tab = "";
$data = array();
$data1 = array();
$datalegend = array();
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_UTENTE3H") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) > 0) {
$tabbody = '<tbody align=\"center\">';
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row["nome_qualifica"];
$data1[] = $row["NUM_ART_RICHIESTI"];
$datalegend[] = $row['nome_qualifica'];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["nome_qualifica"] . "</td>
<td>" . $row["NUM_ART_RICHIESTI"] . "</td>
</tr>";
$i++;
}
$tabbody.="</tbody>";
if (array_sum($data1) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data1);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("qu_id_LISTUTE_TITLE") . "</th>
<th class=\"dx\">" . getConstVar("REPORTS_NUM_RICHIE") . "</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
} else
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "utente3I":
$result = $_SESSION['db']->execute("SELECT COUNT(distinct ut_id) as Numero_utenti, ut_dip,dip_nome FROM report_utente LEFT JOIN dipartimento ON report_utente.ut_dip = dipartimento.dip_id WHERE report_utente.bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_dip; ");
$tab = "";
$data = array();
$data1 = array();
$datalegend = array();
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_UTENTE3I") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) > 0) {
$tabbody = '<tbody align=\"center\">';
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
if ($row["ut_dip"] == 0)
$row["dip_nome"] = strtoupper(getConstVar("SENZA_DIP"));
$data[] = $row["dip_nome"];
$data1[] = $row["Numero_utenti"];
$datalegend[] = $row["dip_nome"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["dip_nome"] . "</td>
<td>" . $row["Numero_utenti"] . "</td>
</tr>";
$i++;
}
$tabbody.="</tbody>";
if (array_sum($data1) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data1);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(5);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("ut_dip_LISTUTE_TITLE") . "</th>
<th class=\"dx\">" . getConstVar("REPORTS_NUM_UTENTI") . "</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
} else
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "utente3L":
$result = $_SESSION['db']->execute("SELECT COUNT(distinct ut_id) as Numero_utenti, tq.qualifica as Nome_qualifica FROM report_utente as ru, qualifica as q,t_qualifica AS tq WHERE q.qu_id=tq.qu_id AND tq.lang_id='" . $_SESSION['lang'] . "' AND ru.qu_id=q.qu_id AND ru.bi_id=" . $_SESSION['biblio']->bi_id . " AND ru.re_anno=$year GROUP BY ru.qu_id; ");
$tab = "";
$data = array();
$data1 = array();
$datalegend = array();
$ret.="<h3>" . getConstVar("REPORTS_GRAPH_UTENTE3L") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) > 0) {
$tabbody = '<tbody align=\"center\">';
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
$data[] = $row["Nome_qualifica"];
$data1[] = $row["Numero_utenti"];
$datalegend[] = $row["Nome_qualifica"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
$tabbody.="<tr class=\"$itemcl\">
<td>" . $row["Nome_qualifica"] . "</td>
<td>" . $row["Numero_utenti"] . "</td>
</tr>";
$i++;
}
$tabbody.="</tbody>";
if (array_sum($data1) == 0) {
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$graph = new PieGraph(getConstVar("PIE_WIDTH"), getConstVar("PIE_HEIGHT"));
$graph->img->SetAntiAliasing();
$graph->SetMargin(getConstVar("GRAPH_LEFT_MARGIN"), getConstVar("GRAPH_RIGHT_MARGIN"), getConstVar("GRAPH_TOP_MARGIN"), getConstVar("GRAPH_BOTTOM_MARGIN")); //L R TOP BOTTOM
$graph->legend->SetFillColor(getConstVar("GRAPH_LEGEND_COLOR"));
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1 = new PiePlot3D($data1);
$p1->SetSize(getConstVar("PIE_SIZE"));
$p1->SetAngle(getConstVar("PIE_ANGLE"));
$p1->SetCenter(getConstVar("PIE_CENTER_X"), getConstVar("PIE_CENTER_Y"));
$p1->ExplodeAll(getConstVar("PIE_EXPLODE"));
$p1->SetLegends($datalegend);
$graph->Add($p1);
$graph->legend->SetColumns(2);
$graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
$ret.= print_tagimg($graph);
$tab = "<table class=\"report_table report_legenda\">
<thead>
<tr>
<th class=\"sx\">" . getConstVar("qu_id_LISTUTE_TITLE") . "</th>
<th class=\"dx\">" . getConstVar("REPORTS_NUM_UTENTI") . "</th>
</tr>
</thead>";
$tab.=$tabbody;
$tab.="</table>";
}
} else
$ret.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
$tab != null ? $tab : null;
$ret != null ? $ret : null;
return $ret . $tab;
break;
case "utente3M":
$ord = "";
$qual = "";
$report_order = isset($report_order) ? $report_order : "ut_nome";
$report_qualif = isset($report_qualif) ? $report_qualif : "asc";
if ($report_order == "ut_nome") {
$ord = "ut_cognome $report_qualif,$report_order $report_qualif";
$qual = "";
} else {
$ord = $report_order;
$qual = $report_qualif;
}
$result = $_SESSION['db']->execute("SELECT u.ut_nome, u.ut_cognome, ru.ut_id, SUM(ru.re_richieste) AS richieste, SUM(ru.re_evase_dir) AS evase_dir, SUM(ru.re_evase_nilde) AS evase_nilde, (SUM(ru.re_inevase_nilde)+SUM(ru.re_inevase_dir)) AS inevase,re_costo_fn FROM report_utente as ru, utente as u WHERE ru.ut_id=u.ut_id AND ru.bi_id=" . $_SESSION['biblio']->bi_id . " AND ru.re_anno=$year GROUP BY ru.ut_id order by $ord $qual");
$tab = "<h3>" . getConstVar("REPORTS_GRAPH_UTENTE3M") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0) {
$tab .= "<div>" . getConstVar("NOWORKTODO") . "</div>";
} else {
$tab.="<table class=\"report_table\">
<thead>
<tr>
<th class=\"sx\">" . print_sorted_table_column('ut_nome', getConstVar("UTENTE"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('richieste', getConstVar("REPORTS_NUM_RICHIE"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('evase_dir', getConstVar("REPORTS_NUM_RICHIE_EVASE_DIR"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "</th>
<th>" . print_sorted_table_column('inevase', getConstVar("REPORTS_NUM_RICHIE_INEVASE"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "</th>
<th class=\"dx\">" . print_sorted_table_column('re_costo_fn', getConstVar("REPORTS_COSTOFN"), $report_order, $report_qualif, "reports.php?typegraph=utente3M&year=$year", "sort_report") . "</th>
</tr>
</thead>";
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
$i++;
$ut = $row["ut_cognome"] . " " . $row["ut_nome"];
$richieste = $row["richieste"];
$num_evase = $row["evase_dir"];
$evase_nilde = $row["evase_nilde"];
$num_inevase = $row["inevase"];
$costo = $row["re_costo_fn"];
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
if ($year >= date('Y') - getConstVar("HISTORY_DATE_INTERVAL")) {
$data = "&datarichie_from_aaaa=$year&datarichie_from_mm=1&datarichie_from_gg=1&datarichie_to_aaaa=$year&datarichie_to_mm=12&datarichie_to_gg=31";
if ($richieste > 0) {
$param1 = "tipo=2&label=0&utesel=" . $row["ut_id"] . $data;
$richieste = "<a href=\"javascript:reportsDetails('$param1')\">$richieste</a>";
}
if ($num_evase > 0) {
$param2 = "tipo=2&label=3&utesel=" . $row["ut_id"] . $data;
$num_evase = "<a href=\"javascript:reportsDetails('$param2')\">$num_evase</a>";
}
if ($num_inevase > 0) {
$param4 = "tipo=2&label=2&utesel=" . $row["ut_id"] . $data;
$num_inevase = "<a href=\"javascript:reportsDetails('$param4')\">$num_inevase</a>";
}
}
$tab.="
<tbody align=\"center\">
<tr class=\"$itemcl\">
<td>" . $ut . "</td>
<td>" . $richieste . "</td>
<td>" . $num_evase . "</td>
<td>" . $num_inevase . "</td>
<td>" . $costo . " &euro;</td>
</tr>
</tbody>";
}
$tab.="</table>";
return $tab;
}
break;
case "utente3P":
$report_order = isset($report_order) ? $report_order : "dip_nome";
$report_qualif = isset($report_qualif) ? $report_qualif : "asc";
$result = $_SESSION['db']->execute("SELECT ut_dip, SUM(re_costo_fn) AS costo_fn,dip_nome FROM report_utente LEFT join dipartimento ON ut_dip=dip_id WHERE report_utente.bi_id=" . $_SESSION['biblio']->bi_id . " AND re_anno=$year GROUP BY ut_dip HAVING costo_fn > 0 ORDER by $report_order $report_qualif");
$tab = "<h3>" . getConstVar("REPORTS_GRAPH_UTENTE3P") . " ($year)</h3><br/>";
if ($_SESSION['db']->numrows($result) == 0)
$tab.= "<div>" . getConstVar("NOWORKTODO") . "</div>";
else {
$tab.="<table class=\"report_table\">
<thead>
<tr>
<th class=\"sx\">" . print_sorted_table_column('dip_nome', getConstVar("REPORTS_DIPARTIMENTO"), $report_order, $report_qualif, "reports.php?typegraph=utente3P&year=$year", "sort_report") . "</th>
<th class=\"dx\">" . print_sorted_table_column('costo_fn', getConstVar("REPORTS_COSTOFN"), $report_order, $report_qualif, "reports.php?typegraph=utente3P&year=$year", "sort_report") . "</th>
</tr>
</thead>";
$i = 0;
while ($row = $_SESSION['db']->fetch($result)) {
$i++;
$itemcl = "item1";
if ($i % 2 != 0)
$itemcl = "item2";
if ($row["ut_dip"] == 0)
$row["dip_nome"] = strtoupper(getConstVar("SENZA_DIP"));
$dip = $row["dip_nome"];
$costo = $row["costo_fn"];
$tab.="
<tbody align=\"center\">
<tr class=\"$itemcl\">
<td>" . $dip . "</td>
<td>" . $costo . " &euro;</td>
</tr>
</tbody>";
}
$tab.="</table>";
}
return $tab;
break;
case "export_biblio":
$ret = "";
$iconahelp = "<a href=\"http://blogs.office.com/b/microsoft-excel/archive/2010/06/11/importing-text-files-in-an-excel-sheet.aspx\" target=\"_new\"><img id=\"help_csv_icon\" src=\"images/mynilde/tutor.png\"></a>";
$ret .= "<h3>" . getConstVar("EXPORT_BIBLIO") . " $iconahelp</h3><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=scambi_globali_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_SCAMBI_GLOBALI') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=richieste_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_STATI_RICHIESTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=tempi_giacenza_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_TEMPI_GIACENZA') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_richieste_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_RIVISTE_RICHIESTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_distinte_richieste_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_RIVISTE__RICHIESTE_DISTINTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_fornite_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_RIVISTE_FORNITE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=utenti_attivi_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_UTENTI_ATTIVI') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=utenti_biblio&year=$year')\">" . getConstVar('EXPORT_BIBLIO_UTENTI_STATI') . "</a>";
return $ret;
break;
case "ente":
$iconahelp = "<a href=\"http://blogs.office.com/b/microsoft-excel/archive/2010/06/11/importing-text-files-in-an-excel-sheet.aspx\" target=\"_new\"><img id=\"help_csv_icon\" src=\"images/mynilde/tutor.png\"></a>";
$ret = "";
$ret .= "<h3>" . getConstVar("REPORTS_GRAPH_ENTE") . " $iconahelp</h3><br/>";
$result = $_SESSION['db']->execute("SELECT ente.en_id,en_nome from storico_sottoscrizioni,ente where st_anno_contratto=$year and storico_sottoscrizioni.en_id=" . $_SESSION['biblio']->en_id . " AND ente.en_id=storico_sottoscrizioni.en_id");
if ($result && $_SESSION['db']->numrows($result) == 1) {
$entearr = $_SESSION['db']->fetch_row($result);
$ret.="<b>" . getConstVar("en_id") . ":</b> " . $entearr['en_nome'] . "<br/><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=biblio_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_BIBLIOTECHE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=scambi_globali_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_SCAMBI_GLOBALI') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=richieste_interne_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_RICHIESTE_INTERNE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=richieste_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_RICHIESTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=tempi_giacenza_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_TEMPI_GIACENZA') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_richieste_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_RIVISTE_RICHIESTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_distinte_richieste_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_RIVISTE_RICHIESTE_DISTINTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_fornite_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_RIVISTE_FORNITE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=utenti_attivi_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_UTENTI_ATTIVI') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=utenti_ente&year=$year')\">" . getConstVar('EXPORT_ENTE_UTENTI_STATI') . "</a>";
} else
$ret.= "<div>" . getConstVar("REPORTS_NOREPORTENTE") . "</div>";
return $ret;
break;
case "progetto":
$iconahelp = "<a href=\"http://blogs.office.com/b/microsoft-excel/archive/2010/06/11/importing-text-files-in-an-excel-sheet.aspx\" target=\"_new\"><img id=\"help_csv_icon\" src=\"images/mynilde/tutor.png\"></a>";
$ret = "";
$ret .= "<h3>" . getConstVar("REPORTS_GRAPH_PROJECT") . " $iconahelp</h3><br/>";
$result = $_SESSION['db']->execute("SELECT DISTINCT pr_id, pr_nome from progetto where pr_id IN (SELECT pr_id from storico_sottoscrizioni where st_tipo_contratto=4 and st_anno_contratto=$year) and pr_id IN (select pr_id from biblio_progetto WHERE bi_id=" . $_SESSION['biblio']->bi_id . ")");
$i = 0;
if ($_SESSION['db']->numrows($result) > 0) {
while ($pr_lst = $_SESSION['db']->fetch($result)) {
$pr = $pr_lst['pr_id'];
$ret.="<b>" . getConstVar("BIBLIO_PROGETTO") . "</b>: " . $pr_lst["pr_nome"] . "<br/><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=biblio_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_BIBLIOTECHE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=scambi_globali_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_SCAMBI_GLOBALI') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=richieste_interne_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_RICHIESTE_INTERNE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=richieste_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_RICHIESTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=tempi_giacenza_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_TEMPI_GIACENZA') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_richieste_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_RIVISTE_RICHIESTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_distinte_richieste_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_RIVISTE_RICHIESTE_DISTINTE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=riviste_fornite_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_RIVISTE_FORNITE') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=utenti_attivi_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_UTENTI_ATTIVI') . "</a><br/>";
$ret.="<a href=\"javascript:download_report('reports.php?export=csv&typegraph=utenti_progetto&year=$year&prog=$pr')\">" . getConstVar('EXPORT_PROGETTO_UTENTI_STATI') . "</a><br/>";
$ret.="<br/><br/>";
$i++;
}
} else
$ret.= "<div>" . getConstVar("REPORTS_NOREPORTPROGETTO") . "</div>";
return $ret;
break;
}
}
function export_graph_csv($typegraph, $year = null, $prog = null) {
srand();
$rand = rand();
$id = $_SESSION['biblio']->bi_id;
$filecsv = "$rand-$id-report_$typegraph.csv";
$query = "";
switch ($typegraph) {
case 'globale1A': $query = "SELECT SUM(re_evaso_bw_nilde)+SUM(re_evaso_bw_posta)+SUM(re_evaso_bw_fax)+SUM(re_evaso_bw_altro)+SUM(re_evaso_bw_ariel) as borrowing, SUM(re_evaso_ln_nilde)+SUM(re_evaso_ln_posta)+SUM(re_evaso_ln_fax)+SUM(re_evaso_ln_altro)+SUM(re_evaso_ln_ariel) AS lending, re_anno
FROM report_biblio WHERE bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno HAVING (borrowing > 0 OR lending > 0 )ORDER BY re_anno ASC";
break;
case "globale1E": $query = "SELECT re_anno,IFNULL(ROUND(SUM(re_tempo_risp_bw)/SUM(re_richieste_bw)/86400,2),0) as tempo_medio_B,IFNULL(ROUND(SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400,2),0) as tempo_medio_L FROM report_biblio where bi_idrichie=" . $_SESSION['biblio']->bi_id . " GROUP BY re_anno";
break;
case "scambi_globali_ente": $query = "Select RIF.ri_id AS IDRIF,dd_id AS IDRICHIESTA,RIF.ri_titolopub AS TITOLO,RIF.ri_titolopart AS TITOLO_ARTICOLO_o_CAPITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,ri_anno AS ANNO,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,
BR.bi_id AS ID_RICHIEDENTE,BR.bi_nome as RICHIEDENTE,(CASE BR.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,BF.bi_id AS ID_FORNITORE,BF.bi_nome as FORNITORE,(CASE BF.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_FORNITORE,BF.prov_id AS PROV_FORNITORE,ENTEF.en_nome AS ENTE_FORNITORE,
DD.dd_datarichie AS DATA_RICHIESTA,DD.dd_dataeva AS DATA_EVASIONE,
(CASE DD.dd_stato_ddill WHEN 0 THEN 'nuovo' WHEN 10 THEN 'inoltro NILDE' WHEN 11 THEN 'richiesto annullamento' WHEN 20 THEN 'inoltro FN' WHEN 99 THEN 'elaborazione server' WHEN 101 THEN 'evaso NILDE' WHEN 102 THEN 'evaso NILDE (HC)' WHEN 103 THEN 'evaso NILDE (WM)' WHEN 110 THEN 'evaso POSTA' WHEN 111 THEN 'evaso FAX'WHEN 112 THEN 'evaso ARIEL' WHEN 113 THEN 'evaso ALTRO' WHEN 150 THEN 'evaso FN' WHEN 201 THEN 'inevaso (riferim. errato)' WHEN 202 THEN 'inevaso (non posseduto)' WHEN 203 THEN 'inevaso (non disponibile)' WHEN 204 THEN 'inevaso (over 15)' WHEN 205 THEN 'inevaso (over quota)' WHEN 230 THEN 'inevaso ALTRO' WHEN 250 THEN 'inevaso FN' WHEN 299 THEN 'annullata' END ) AS STATO_DD,
(CASE DD.dd_stato_borr WHEN 0 THEN 'nuovo' WHEN 1 THEN 'in corso' WHEN 30 THEN 'attesa accettazione utente' WHEN 31 THEN 'utente rifiuta costo' WHEN 32 THEN 'utente accetta costo' WHEN 34 THEN 'utente non risponde' WHEN 40 THEN 'in gestione' WHEN 50 THEN 'scarìcato' WHEN 51 THEN 'ricevuto' WHEN 33 THEN 'cestinato' WHEN 70 THEN 'inevaso' WHEN 100 THEN 'consegnato ute/archiviato' WHEN 101 THEN 'consegnato (diretta)' WHEN 200 THEN 'non consegnato/arch come inevaso' WHEN 201 THEN 'non consegnato (diretto)' WHEN 202 THEN 'non consegnato (riferim. errato)' WHEN 203 THEN 'non consegnato (cestinato)' WHEN 300 THEN 'reiterato' WHEN 302 THEN 'reiterato (riferimento errato)' WHEN 303 THEN 'reiterato (cestinato)' END) AS STATO_BORROWING,if(ut_id IS NOT NULL AND ut_id>0,'Si','No') AS RICHIESTA_UTENTE
FROM docdel as DD,biblio as BR, biblio as BF, riferimento AS RIF,ente as ENTER,ente as ENTEF
WHERE DD.bi_idrichie=BR.bi_id AND DD.bi_idforni=BF.bi_id AND DD.ri_id=RIF.ri_id AND Year(dd_datarichie)=$year
AND ENTER.en_id=BR.en_id AND ENTEF.en_id=BF.en_id AND (BR.bi_id IN (SELECT bi_id from biblio WHERE en_id=" . $_SESSION['biblio']->en_id . " AND bi_nilde=1)
OR BF.bi_id IN (SELECT bi_id from biblio WHERE en_id=" . $_SESSION['biblio']->en_id . " AND bi_nilde=1) )";
break;
case "richieste_interne_ente": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN
FROM report_biblio, biblio AS BR,biblio as BF
WHERE report_biblio.bi_idrichie = BR.bi_id
AND report_biblio.bi_idforni = BF.bi_id
AND BR.en_id=" . $_SESSION['biblio']->en_id . "
AND BR.bi_nilde =1
AND BF.en_id=" . $_SESSION['biblio']->en_id . "
AND BF.bi_nilde =1
AND re_anno=$year
GROUP BY bi_idrichie";
break;
case "richieste_ente": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN
FROM report_biblio, biblio AS BR
WHERE report_biblio.bi_idrichie = BR.bi_id
AND BR.en_id=" . $_SESSION['biblio']->en_id . "
AND BR.bi_nilde =1
AND re_anno=$year
GROUP BY bi_idrichie";
break;
case "riviste_richieste_ente": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE
FROM docdel as DD,biblio as BR, riferimento AS RIF
WHERE
DD.bi_idrichie=BR.bi_id
AND DD.ri_id=RIF.ri_id
AND BR.en_id=" . $_SESSION['biblio']->en_id . "
AND BR.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "riviste_distinte_richieste_ente": $query = "select distinct (RIF.ri_titolopub) AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(*) as TOTALE
FROM docdel as DD,biblio as BR, riferimento AS RIF
WHERE
DD.bi_idrichie=BR.bi_id
AND DD.ri_id=RIF.ri_id
AND BR.en_id=" . $_SESSION['biblio']->en_id . "
AND BR.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "riviste_fornite_ente": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE
FROM docdel as DD,biblio as BF, riferimento AS RIF
WHERE
DD.bi_idforni=BF.bi_id
AND DD.ri_id=RIF.ri_id
AND BF.en_id=" . $_SESSION['biblio']->en_id . "
AND BF.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "utenti_attivi_ente": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV, COUNT(DISTINCT ut_id) as TOTALE
FROM report_utente,biblio
WHERE biblio.bi_id = report_utente.bi_id
AND re_anno=$year
AND re_richieste >= 1
AND biblio.en_id =" . $_SESSION['biblio']->en_id . "
group by ID
order by TOTALE DESC";
break;
case "utenti_ente": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV, COUNT(ut_id) as TOTALE, SUM(IF(ap_stato = 0,1,0)) as ATTESA,SUM(IF(ap_stato = 1,1,0)) as ABILITATI,SUM(IF(ap_stato = 2,1,0)) as DISABILITATI
FROM biblio,appartiene
WHERE biblio.bi_id = appartiene.bi_id
AND ap_stato in (0,1,2)
AND biblio.en_id =" . $_SESSION['biblio']->en_id . "
group by ID
order by TOTALE DESC";
break;
case "tempi_giacenza_ente": $query = "Select BR.bi_id AS ID,BR.bi_nome as RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as TEMPO_MEDIO_GIACENZA
FROM report_biblio as rep,biblio as BR
WHERE bi_idrichie=BR.bi_id AND BR.en_id=" . $_SESSION['biblio']->en_id . " AND BR.bi_nilde=1
AND re_anno=$year group by BR.bi_id";
break;
case "biblio_ente": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME,bi_indi AS INDIRIZZO,bi_cap AS CAP,bi_citta AS CITTA,prov_id AS PROV,bi_tel AS TELEFONO,bi_fax AS FAX,bi_url AS SITO,bi_opac AS URL_OPAC,bi_piva AS PIVA,bi_cf AS CF,bi_referente_dd AS REFERENTE,bi_email_dd AS EMAIL_REFERENTE,bi_tel_dd AS TEL_REFERENTE,bi_data_reg AS DATA_REGISTRAZIONE,acnp_cod AS COD_ACNP,(CASE acnp_attivo WHEN 0 THEN 'in attesa' WHEN 1 THEN 'attivo' WHEN 2 THEN 'disabilitato' END) as ACNP_LINK,sbn_cod AS COD_SBN,sbn_cod_polo AS COD_SBN_POLO from biblio LEFT JOIN tab_acnp ON biblio.bi_id=tab_acnp.bi_id LEFT JOIN tab_sbn ON biblio.bi_id=tab_sbn.bi_id WHERE bi_nilde=1 AND biblio.en_id=" . $_SESSION['biblio']->en_id; //bi_stato IN (".getConstVar('BIBLIO_ATTIVE_SQL_LIST').")
break;
case "scambi_globali_progetto": $query = "Select RIF.ri_id AS IDRIF,dd_id AS IDRICHIESTA,RIF.ri_titolopub AS TITOLO,RIF.ri_titolopart AS TITOLO_ARTICOLO_o_CAPITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,ri_anno AS ANNO,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,
BR.bi_id AS ID_RICHIEDENTE,BR.bi_nome as RICHIEDENTE,(CASE BR.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,BF.bi_id AS ID_FORNITORE,BF.bi_nome as FORNITORE,(CASE BF.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_FORNITORE,BF.prov_id AS PROV_FORNITORE,ENTEF.en_nome AS ENTE_FORNITORE,
DD.dd_datarichie AS DATA_RICHIESTA,DD.dd_dataeva AS DATA_EVASIONE,
(CASE DD.dd_stato_ddill WHEN 0 THEN 'nuovo' WHEN 10 THEN 'inoltro NILDE' WHEN 11 THEN 'richiesto annullamento' WHEN 20 THEN 'inoltro FN' WHEN 99 THEN 'elaborazione server' WHEN 101 THEN 'evaso NILDE' WHEN 102 THEN 'evaso NILDE (HC)' WHEN 103 THEN 'evaso NILDE (WM)' WHEN 110 THEN 'evaso POSTA' WHEN 111 THEN 'evaso FAX'WHEN 112 THEN 'evaso ARIEL' WHEN 113 THEN 'evaso ALTRO' WHEN 150 THEN 'evaso FN' WHEN 201 THEN 'inevaso (riferim. errato)' WHEN 202 THEN 'inevaso (non posseduto)' WHEN 203 THEN 'inevaso (non disponibile)' WHEN 204 THEN 'inevaso (over 15)' WHEN 205 THEN 'inevaso (over quota)' WHEN 230 THEN 'inevaso ALTRO' WHEN 250 THEN 'inevaso FN' WHEN 299 THEN 'annullata' END ) AS STATO_DD,
(CASE DD.dd_stato_borr WHEN 0 THEN 'nuovo' WHEN 1 THEN 'in corso' WHEN 30 THEN 'attesa accettazione utente' WHEN 31 THEN 'utente rifiuta costo' WHEN 32 THEN 'utente accetta costo' WHEN 34 THEN 'utente non risponde' WHEN 40 THEN 'in gestione' WHEN 50 THEN 'scarìcato' WHEN 51 THEN 'ricevuto' WHEN 33 THEN 'cestinato' WHEN 70 THEN 'inevaso' WHEN 100 THEN 'consegnato ute/archiviato' WHEN 101 THEN 'consegnato (diretta)' WHEN 200 THEN 'non consegnato/arch come inevaso' WHEN 201 THEN 'non consegnato (diretto)' WHEN 202 THEN 'non consegnato (riferim. errato)' WHEN 203 THEN 'non consegnato (cestinato)' WHEN 300 THEN 'reiterato' WHEN 302 THEN 'reiterato (riferimento errato)' WHEN 303 THEN 'reiterato (cestinato)' END) AS STATO_BORROWING,if(ut_id IS NOT NULL AND ut_id>0,'Si','No') AS RICHIESTA_UTENTE
FROM docdel as DD,biblio as BR, biblio as BF, riferimento AS RIF,ente as ENTER,ente as ENTEF
WHERE DD.bi_idrichie=BR.bi_id AND DD.bi_idforni=BF.bi_id AND DD.ri_id=RIF.ri_id AND Year(dd_datarichie)=$year
AND ENTER.en_id=BR.en_id AND ENTEF.en_id=BF.en_id AND
( ( BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND BR.bi_nilde=1) OR ( BF.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND BF.bi_nilde=1) )";
break;
case "richieste_interne_progetto": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,ENTER.en_nome AS ENTE,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN
FROM report_biblio, biblio AS BR,biblio as BF,ente AS ENTER
WHERE report_biblio.bi_idrichie = BR.bi_id
AND report_biblio.bi_idforni = BF.bi_id
AND ENTER.en_id=BR.en_id
AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
AND BR.bi_nilde=1
AND BF.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
AND BF.bi_nilde=1
AND re_anno=$year
GROUP BY bi_idrichie";
break;
case "richieste_progetto": $query = "SELECT bi_idrichie AS ID, BR.bi_nome AS BIBLIOTECA, BR.prov_id AS PROV,ENTER.en_nome AS ENTE,sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN
FROM report_biblio, biblio AS BR,ente as ENTER
WHERE report_biblio.bi_idrichie = BR.bi_id
AND ENTER.en_id=BR.en_id
AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
AND BR.bi_nilde =1
AND re_anno=$year
GROUP BY bi_idrichie";
break;
case "riviste_richieste_progetto": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE
FROM docdel as DD,biblio as BR, riferimento AS RIF
WHERE
DD.bi_idrichie=BR.bi_id
AND DD.ri_id=RIF.ri_id
AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
AND BR.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "riviste_distinte_richieste_progetto": $query = "select distinct (RIF.ri_titolopub) AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(*) as TOTALE
FROM docdel as DD,biblio as BR, riferimento AS RIF
WHERE
DD.bi_idrichie=BR.bi_id
AND DD.ri_id=RIF.ri_id
AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
AND BR.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "riviste_fornite_progetto": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE
FROM docdel as DD,biblio as BF, riferimento AS RIF
WHERE
DD.bi_idforni=BF.bi_id
AND DD.ri_id=RIF.ri_id
AND BF.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
AND BF.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "utenti_attivi_progetto": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV,ente.en_nome AS ENTE, COUNT(DISTINCT ut_id) as TOTALE
FROM report_utente,biblio, ente
WHERE
ente.en_id=biblio.en_id
AND biblio.bi_id = report_utente.bi_id
AND re_anno=$year
AND re_richieste >= 1
AND biblio.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
group by ID
order by TOTALE DESC";
break;
case "utenti_progetto": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME_BIBLIOTECA,biblio.prov_id AS PROV,ente.en_nome AS ENTE,COUNT(ut_id) as TOTALE, SUM(IF(ap_stato = 0,1,0)) as ATTESA,SUM(IF(ap_stato = 1,1,0)) as ABILITATI,SUM(IF(ap_stato = 2,1,0)) as DISABILITATI
FROM biblio,appartiene,ente
WHERE
ente.en_id=biblio.en_id
AND biblio.bi_id = appartiene.bi_id
AND ap_stato in (0,1,2)
AND biblio.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog)
group by ID
order by TOTALE DESC";
break;
case "tempi_giacenza_progetto": $query = "Select BR.bi_id AS ID,BR.bi_nome as RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as TEMPO_MEDIO_GIACENZA
FROM report_biblio as rep,biblio as BR,ente AS ENTER
WHERE
ENTER.en_id=BR.en_id
AND bi_idrichie=BR.bi_id AND BR.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND BR.bi_nilde=1
AND re_anno=$year group by BR.bi_id";
break;
case "biblio_progetto": $query = "SELECT biblio.bi_id AS ID,bi_nome AS NOME,ente.en_nome AS ENTE,bi_indi AS INDIRIZZO,bi_cap AS CAP,bi_citta AS CITTA,prov_id AS PROV,bi_tel AS TELEFONO,bi_fax AS FAX,bi_url AS SITO,bi_opac AS URL_OPAC,bi_piva AS PIVA,bi_cf AS CF,bi_referente_dd AS REFERENTE,bi_email_dd AS EMAIL_REFERENTE,bi_tel_dd AS TEL_REFERENTE,bi_data_reg AS DATA_REGISTRAZIONE,acnp_cod AS COD_ACNP,(CASE acnp_attivo WHEN 0 THEN 'in attesa' WHEN 1 THEN 'attivo' WHEN 2 THEN 'disabilitato' END) as ACNP_LINK,sbn_cod AS COD_SBN,sbn_cod_polo AS COD_SBN_POLO from biblio LEFT JOIN tab_acnp ON biblio.bi_id=tab_acnp.bi_id LEFT JOIN tab_sbn ON biblio.bi_id=tab_sbn.bi_id LEFT JOIN ente ON ente.en_id=biblio.en_id WHERE bi_nilde=1 AND biblio.bi_id IN (SELECT bi_id from biblio_progetto WHERE pr_id=$prog) AND ente.en_id=biblio.en_id"; //bi_stato IN (".getConstVar('BIBLIO_ATTIVE_SQL_LIST').")
break;
case "scambi_globali_biblio": $query = "Select RIF.ri_id AS IDRIF,dd_id AS IDRICHIESTA,RIF.ri_titolopub AS TITOLO,RIF.ri_titolopart AS TITOLO_ARTICOLO_o_CAPITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,ri_anno AS ANNO,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,
BR.bi_id AS ID_RICHIEDENTE,BR.bi_nome as RICHIEDENTE,(CASE BR.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_RICHIEDENTE,BR.prov_id AS PROV_RICHIEDENTE,ENTER.en_nome AS ENTE_RICHIEDENTE,BF.bi_id AS ID_FORNITORE,BF.bi_nome as FORNITORE,(CASE BF.bi_nilde WHEN 1 THEN 'N' WHEN 0 THEN 'FN' END) AS TIPO_FORNITORE,BF.prov_id AS PROV_FORNITORE,ENTEF.en_nome AS ENTE_FORNITORE,
DD.dd_datarichie AS DATA_RICHIESTA,DD.dd_dataeva AS DATA_EVASIONE,
(CASE DD.dd_stato_ddill WHEN 0 THEN 'nuovo' WHEN 10 THEN 'inoltro NILDE' WHEN 11 THEN 'richiesto annullamento' WHEN 20 THEN 'inoltro FN' WHEN 99 THEN 'elaborazione server' WHEN 101 THEN 'evaso NILDE' WHEN 102 THEN 'evaso NILDE (HC)' WHEN 103 THEN 'evaso NILDE (WM)' WHEN 110 THEN 'evaso POSTA' WHEN 111 THEN 'evaso FAX'WHEN 112 THEN 'evaso ARIEL' WHEN 113 THEN 'evaso ALTRO' WHEN 150 THEN 'evaso FN' WHEN 201 THEN 'inevaso (riferim. errato)' WHEN 202 THEN 'inevaso (non posseduto)' WHEN 203 THEN 'inevaso (non disponibile)' WHEN 204 THEN 'inevaso (over 15)' WHEN 205 THEN 'inevaso (over quota)' WHEN 230 THEN 'inevaso ALTRO' WHEN 250 THEN 'inevaso FN' WHEN 299 THEN 'annullata' END ) AS STATO_DD,
(CASE DD.dd_stato_borr WHEN 0 THEN 'nuovo' WHEN 1 THEN 'in corso' WHEN 30 THEN 'attesa accettazione utente' WHEN 31 THEN 'utente rifiuta costo' WHEN 32 THEN 'utente accetta costo' WHEN 34 THEN 'utente non risponde' WHEN 40 THEN 'in gestione' WHEN 50 THEN 'scarìcato' WHEN 51 THEN 'ricevuto' WHEN 33 THEN 'cestinato' WHEN 70 THEN 'inevaso' WHEN 100 THEN 'consegnato ute/archiviato' WHEN 101 THEN 'consegnato (diretta)' WHEN 200 THEN 'non consegnato/arch come inevaso' WHEN 201 THEN 'non consegnato (diretto)' WHEN 202 THEN 'non consegnato (riferim. errato)' WHEN 203 THEN 'non consegnato (cestinato)' WHEN 300 THEN 'reiterato' WHEN 302 THEN 'reiterato (riferimento errato)' WHEN 303 THEN 'reiterato (cestinato)' END) AS STATO_BORROWING,if(ut_id IS NOT NULL AND ut_id>0,'Si','No') AS RICHIESTA_UTENTE
FROM docdel as DD,biblio as BR, biblio as BF, riferimento AS RIF,ente as ENTER,ente as ENTEF
WHERE DD.bi_idrichie=BR.bi_id AND DD.bi_idforni=BF.bi_id AND DD.ri_id=RIF.ri_id AND Year(dd_datarichie)=$year
AND ENTER.en_id=BR.en_id AND ENTEF.en_id=BF.en_id AND ( (BR.bi_id=" . $_SESSION['biblio']->bi_id . " AND BR.bi_nilde=1) OR (BF.bi_id=" . $_SESSION['biblio']->bi_id . " AND BF.bi_nilde=1) )";
break;
case "richieste_biblio": $query = "SELECT sum( re_richieste_bw ) AS TOT_RICHIESTE_NILDE, sum( re_richieste_bw_fn ) AS TOT_RICHIESTE_FN , sum( re_evaso_bw_nilde ) AS TOT_RICHIESTE_EVASE_NILDE, sum( re_evaso_bw_posta ) AS TOT_RICHIESTE_EVASE_POSTA , sum( re_evaso_bw_fax ) AS TOT_RICHIESTE_EVASE_FAX, sum( re_evaso_bw_ariel ) AS TOT_RICHIESTE_EVASE_ARIEL, sum( re_evaso_bw_altro ) AS TOT_RICHIESTE_EVASE_ALTRO, sum( re_evaso_bw_fn ) AS TOT_RICHIESTE_EVASE_FN, sum( re_inevaso_bw_riferr ) AS TOT_RICHIESTE_INEVASE_RIF_ERRATO, sum( re_inevaso_bw_nonposs ) AS TOT_RICHIESTE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_bw_nondisp ) AS TOT_RICHIESTE_INEVASE_NON_DISPONIBILE, sum( re_inevaso_bw_over15 ) AS TOT_RICHIESTE_INEVASE_OVER15, sum( re_inevaso_bw_overquota ) AS TOT_RICHIESTE_INEVASE_OVER_QUOTA, sum( re_inevaso_bw_altro ) AS TOT_RICHIESTE_INEVASE_ALTRO, sum( re_inevaso_bw_fn ) AS TOT_RICHIESTE_INEVASE_FN, sum( re_richieste_ln ) AS TOT_FORNITE, sum( re_richieste_ln_fn ) AS TOT_FORNITE_FN , sum( re_evaso_ln_nilde ) AS TOT_FORNITE_EVASE_NILDE , sum( re_evaso_ln_posta ) AS TOT_FORNITE_EVASE_POSTA , sum( re_evaso_ln_fax ) AS TOT_FORNITE_EVASE_FAX, sum( re_evaso_ln_ariel ) AS TOT_FORNITE_EVASE_ARIEL , sum( re_evaso_ln_altro ) AS TOT_FORNITE_EVASE_ALTRO, sum( re_evaso_ln_fn ) AS TOT_FORNITE_EVASE_FN, sum( re_inevaso_ln_riferr ) AS TOT_FORNITE_INEVASE_RIF_ERRATO, sum( re_inevaso_ln_nonposs ) AS TOT_FORNITE_INEVASE_NON_POSSEDUTO, sum( re_inevaso_ln_nondisp ) AS TOT_FORNITE_INEVASE_NON_DISPONIBILE , sum( re_inevaso_ln_over15 ) AS TOT_FORNITE_INEVASE_OVER15, sum( re_inevaso_ln_overquota ) AS TOT_FORNITE_INEVASE_OVER_QUOTA_SETTIMANALE, sum( re_inevaso_ln_altro ) AS TOT_FORNITE_INEVAS_ALTRO, sum( re_inevaso_ln_fn ) AS TOT_FORNITE_INEVASO_FN
FROM report_biblio
WHERE report_biblio.bi_idrichie=" . $_SESSION['biblio']->bi_id . "
AND re_anno=$year";
break;
case "riviste_richieste_biblio": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE
FROM docdel as DD,biblio as BR, riferimento AS RIF
WHERE
DD.bi_idrichie=BR.bi_id
AND DD.ri_id=RIF.ri_id
AND BR.bi_id=" . $_SESSION['biblio']->bi_id . "
AND BR.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "riviste_distinte_richieste_biblio": $query = "select distinct (RIF.ri_titolopub) AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(*) as TOTALE
FROM docdel as DD,biblio as BR, riferimento AS RIF
WHERE
DD.bi_idrichie=BR.bi_id
AND DD.ri_id=RIF.ri_id
AND BR.bi_id=" . $_SESSION['biblio']->bi_id . "
AND BR.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "riviste_fornite_biblio": $query = "select RIF.ri_titolopub AS TITOLO,(CASE RIF.ri_tipomateriale WHEN 1 THEN 'articolo' WHEN 2 THEN 'libro' END) AS TIPO_MATERIALE,RIF.ri_issn AS ISSN,RIF.ri_isbn AS ISBN,COUNT(RIF.ri_id) as TOTALE
FROM docdel as DD,biblio as BF, riferimento AS RIF
WHERE
DD.bi_idforni=BF.bi_id
AND DD.ri_id=RIF.ri_id
AND BF.bi_id=" . $_SESSION['biblio']->bi_id . "
AND BF.bi_nilde=1
AND Year(dd_datarichie)=$year
group by ri_titolopub
order by TOTALE desc";
break;
case "utenti_attivi_biblio": $query = "SELECT COUNT(DISTINCT ut_id) as TOTALE
FROM report_utente,biblio
WHERE biblio.bi_id = report_utente.bi_id
AND re_anno=$year
AND re_richieste >= 1
AND biblio.bi_id=" . $_SESSION['biblio']->bi_id;
break;
case "utenti_biblio": $query = "SELECT COUNT(ut_id) as TOTALE, SUM(IF(ap_stato = 0,1,0)) as ATTESA,SUM(IF(ap_stato = 1,1,0)) as ABILITATI,SUM(IF(ap_stato = 2,1,0)) as DISABILITATI
FROM biblio,appartiene
WHERE biblio.bi_id = appartiene.bi_id
AND ap_stato in (0,1,2)
AND biblio.bi_id=" . $_SESSION['biblio']->bi_id;
break;
case "tempi_giacenza_biblio": $query = "Select SUM(re_tempo_risp_ln)/SUM(re_richieste_ln)/86400 as TEMPO_MEDIO_GIACENZA
FROM report_biblio as rep,biblio as BR
WHERE bi_idrichie=BR.bi_id AND BR.bi_id=" . $_SESSION['biblio']->bi_id . " AND BR.bi_nilde=1
AND re_anno=$year";
break;
}
if ($query != "") {
$csv_content = $_SESSION['db']->exportQuery2CSV($query);
$path = getConstVar('CSV_TMP_DIR') . $filecsv;
$fp = fopen($path, "w");
fwrite($fp, $csv_content);
fclose($fp);
$size = formatBytes(filesize($path));
echo "<img src=\"images/mynilde/csv_icon.png\">&nbsp;&nbsp;<a href=\"download_report_csv.php?f=$filecsv\">" . getConstVar('FILE_READY') . "</a> ($size)";
}
}
function export_graph_pdf($graph, $year = null) {
return null;
}
$report_order = null;
if (isset($_REQUEST["order"]))
$report_order = $_REQUEST["order"];
if (isset($_REQUEST["qualif"]))
$report_qualif = $_REQUEST["qualif"];
if (isset($_GET['export'])) {
switch ($_GET['export']) {
case "csv": export_graph_csv($_GET["typegraph"], $_GET["year"], $_GET["prog"]);
break;
case "pdf": export_graph_pdf($_GET["typegraph"], $_GET["year"]);
break;
}
} else
if (isset($_GET["typegraph"]))
echo print_graph($_GET["typegraph"], $_GET["year"], $report_order, $report_qualif);
?>

Event Timeline