'Programa de Pós-Graduação em Agronomia',
'PGM' => 'Programa de Pós-Graduação em Genética do Melhoramento',
'PPZ' => 'Programa de Pós-Graduação em Zootecnia',
'PBC' => 'Programa de Pós-Graduação em Ciências Biológicas',
'PGB' => 'Programa de Pós-Graduação em Biologia Comparada',
'PEA' => 'Programa de Pós-Graduação em Ecologia de Ambientes Aquáticos Continentais',
'CC' => 'Ciência da Computação',
'PCM' => 'Programa de Pós-Graduação em Ciência da Matemática',
'PFI' => 'Programa de Pós-Graduação em Física',
'PMA' => 'Programa de Pós-Graduação em Matemática',
'PQU' => 'Programa de Pós-Graduação em Química',
'PPE' => 'Programa de Pós-Graduação em Educação',
'PGE' => 'Programa de Pós-Graduação em Geografia',
'PPH' => 'Programa de Pós-Graduação em História',
'PPP' => 'Programa de Pós-Graduação em Psicologia',
'PPA' => 'Programa de Pós-Graduação em Administração',
'MDI' => 'Programa de Pós-Graduação em Direito',
'PME' => 'Programa de Pós-Graduação em Economia',
'PEC' => 'Programa de Pós-Graduação Engenharia Química',
'PEU' => 'Programa de Pós-Graduação em Engenharia Urbana',
'PLE' => 'Programa de Pós-Graduação em Letras',
);
// read titles from other database
$c = pg_connect("dbname=$cfg_other_base user=$cfg_user");
$q = pg_exec($c, "SELECT code,title,topic_id,downloads FROM nr_document WHERE code LIKE 'vtls%'");
//-------------------------------------
$t_total = 0;
$d_total = 0;
$title = array();
$t_bio = $t_hum = $t_exa = $t_agr = $t_sau = $t_apl = $t_eng = $t_lin = 0;
$d_bio = $d_hum = $d_exa = $d_agr = $d_sau = $d_apl = $d_eng = $d_lin = 0;
for ($i = 0; $i < pg_numrows($q); $i++) {
$a = pg_fetch_array($q, $i);
$title[$a['code']] = $a['title'];
$vtls[$a['code']] = $a['downloads'];
$teste[$a['topic_id']] = $a['downloads'];
$t_total = $t_total + 1;
$d_total = $d_total+$vtls[$a['code']] = $a['downloads'];
// Contabiliza teses por area
if ($a['topic_id'] ==143 or $a['topic_id'] == 248 or
$a['topic_id'] == 249 )
$t_bio++;
else if ($a['topic_id'] == 257 or $a['topic_id'] == 259 or
$a['topic_id'] == 260 or $a['topic_id'] == 274 )
$t_hum++ ;
else if ($a['topic_id'] == 272 or $a['topic_id'] == 251 or
$a['topic_id'] == 252 or $a['topic_id'] == 253 or
$a['topic_id'] == 255)
$t_exa++ ;
else if ($a['topic_id'] == 245 or $a['topic_id'] == 246 or
$a['topic_id'] == 247)
$t_agr++ ;
else if ($a['topic_id'] == 250 or $a['topic_id'] == 261 or
$a['topic_id'] == 263 or $a['topic_id'] == 265
or $a['topic_id'] == 267 or $a['topic_id'] == 276)
$t_sau++ ;
else if ($a['topic_id'] == 262 or $a['topic_id'] == 284 or
$a['topic_id'] == 264 or $a['topic_id'] == 266 )
$t_apl++ ;
else if ($a['topic_id'] == 256 or $a['topic_id'] == 258 )
$t_eng++ ;
else if ($a['topic_id'] == 254)
$t_lin++ ;
// contabiliza teses por downloads
if ($a['topic_id'] ==143 or $a['topic_id'] == 248 or
$a['topic_id'] == 249 )
$d_bio = $d_bio + $teste[$a['topic_id']];
else if ($a['topic_id'] == 257 or $a['topic_id'] == 259 or
$a['topic_id'] == 260 or $a['topic_id'] == 274 )
$d_hum = $d_hum + $teste[$a['topic_id']] ;
else if ($a['topic_id'] == 272 or $a['topic_id'] == 251 or
$a['topic_id'] == 252 or $a['topic_id'] == 253 or
$a['topic_id'] == 255)
$d_exa = $d_exa + $teste[$a['topic_id']] ;
else if ($a['topic_id'] == 245 or $a['topic_id'] == 246 or
$a['topic_id'] == 247)
$d_agr = $d_agr + $teste[$a['topic_id']];
else if ($a['topic_id'] == 250 or $a['topic_id'] == 261 or
$a['topic_id'] == 263 or $a['topic_id'] == 265
or $a['topic_id'] == 267 or $a['topic_id'] == 276)
$d_sau = $d_sau + $teste[$a['topic_id']];
else if ($a['topic_id'] == 262 or $a['topic_id'] == 284 or
$a['topic_id'] == 264 or $a['topic_id'] == 266 )
$d_apl = $d_apl + $teste[$a['topic_id']];
else if ($a['topic_id'] == 256 or $a['topic_id'] == 258 )
$d_eng = $d_eng + $teste[$a['topic_id']];
else if ($a['topic_id'] == 254)
$d_lin = $d_lin + $teste[$a['topic_id']];
}
pg_close($c);
// header
echo <<
HTML;
// global totals
if ($pg=="" or $pg=="1") {
echo "
[Total Gerais]
[Teses mais Acessadas]
";
echo "
";
echo <<
Totais gerais |
Total de downloads |
$d_total |
Total de teses |
$t_total |
|
|
HTML;
$bd_bio = bar($d_bio, $d_total, 'blue');
$bd_hum = bar($d_hum, $d_total, 'blue');
$bd_exa = bar($d_exa, $d_total, 'blue');
$bd_agr = bar($d_agr, $d_total, 'blue');
$bd_sau = bar($d_sau, $d_total, 'blue');
$bd_apl = bar($d_apl, $d_total, 'blue');
$bd_eng = bar($d_eng, $d_total, 'blue');
$bd_lin = bar($d_lin, $d_total, 'blue');
$bt_bio = bar($t_bio, $t_total, 'red');
$bt_hum = bar($t_hum, $t_total, 'red');
$bt_exa = bar($t_exa, $t_total, 'red');
$bt_agr = bar($t_agr, $t_total, 'red');
$bt_sau = bar($t_sau, $t_total, 'red');
$bt_apl = bar($t_apl, $t_total, 'red');
$bt_eng = bar($t_eng, $t_total, 'red');
$bt_lin = bar($t_lin, $t_total, 'red');
echo <<
| Quantidade de downloads (azul) e de teses (vermelho) por área |
Área |
Porcentagem |
Quantidade |
Agrárias |
$bd_agr |
$d_agr |
|
$bt_agr |
$t_agr |
Biológicas |
$bd_bio |
$d_bio |
|
$bt_bio |
$t_bio |
Saúde |
$bd_sau |
$d_sau |
|
$bt_sau |
$t_sau |
Exatas e da Terra |
$bd_exa |
$d_exa |
|
$bt_exa |
$t_exa |
Humanas |
$bd_hum |
$d_hum |
|
$bt_hum |
$t_hum |
Sociais Aplicadas |
$bd_apl |
$d_apl |
|
$bt_apl |
$t_apl |
Engenharias |
$bd_eng |
$d_eng |
|
$bt_eng |
$t_eng |
Lingüistica, Letras e Artes |
$bd_lin |
$d_lin |
|
$bt_lin |
$t_lin |
|
|
HTML;
}
if ($pg=="2") {
echo "
[Total Gerais]
[Teses mais Acessadas]
";
echo "
";
echo <<
Total de downloads por unidade |
Unidade |
Downloads |
HTML;
$i = 0;
$q = db_query("SELECT unit,COUNT(user_id) AS downloads FROM z_log GROUP BY unit ORDER BY downloads DESC");
echo "\n";
while ($a = db_fetch_array($q)) {
// if (!($a['unit'] == 'IFGW')) {
if (!($a['unit'] == 'x')) {
if ($i++ & 1)
echo " \n";
else
echo " \n";
echo "{$unit[$a['unit']]} | \n";
echo "{$a['visits']} | \n";
echo " \n";
}
}
echo <<
|
HTML;
// number of downloads per institution (max 40)
echo <<
|
Total de downloads por instituição |
Instituição/Empresa |
Downloads |
HTML;
$q = db_query("SELECT U.institution,COUNT(L.user_id) AS downloads FROM z_log L,z_user U WHERE L.user_id=U.id GROUP BY U.institution ORDER BY downloads DESC LIMIT 40");
$i = 0;
while ($a = db_fetch_array($q)) {
if ($i++ & 1)
echo "\n";
else
echo " \n";
echo "{$a['institution']} | \n";
echo "{$a['visits']} | \n";
echo " \n";
}
echo <<
|
HTML;
}
if ($pg=="3") {
echo "[Total Gerais]
[Teses mais Acessadas]
";
echo "
";
echo <<
|
Teses e dissertações com mais downloads |
Código |
Título |
Downloads |
HTML;
$i = 0;
$lim = 10;
//$q = db_query("SELECT code,unit,COUNT(user_id) AS downloads FROM z_log WHERE code LIKE 'vtls%' GROUP BY code,unit ORDER BY downloads DESC LIMIT 40");
// $q = pg_exec($db_conn2, "SELECT author, title, code, downloads FROM (Select author, title, code, downloads, visits FROM nr_document WHERE code LIKE 'vtls%' ORDER BY visits DESC LIMIT $lim) as ord ORDER BY downloads DESC");
//$q = pg_exec($db_conn2, "SELECT code, downloads FROM nr_document WHERE code LIKE 'vtls%' ORDER BY downloads DESC LIMIT 20"); //ORI
$c = pg_connect("dbname=$cfg_other_base user=$cfg_user"); //NAO TINHA ESSA LINHA
$q = pg_exec($c, "SELECT code, downloads FROM nr_document WHERE code LIKE 'vtls%' ORDER BY downloads DESC LIMIT 20");
while ($a = db_fetch_array($q)) {
if (trim($a['unit']) != 'x') {
if ($i++ & 1)
echo "\n";
else
echo " \n";
echo "{$a['code']} | \n";
echo "{$title[$a['code']]} | \n";
echo "{$vtls[$a['code']]} | \n";
echo " \n";
}
}
echo <<
|
HTML;
}
//---------------------------
echo " Sistema Integrado de Bibliotecas - SIB / UEM - @ ltktanaka@uem.br";
echo <<
HTML;
/*-------------- functions --------------*/
function bar ($value, $total, $color)
{
$p = round($value * 100 / $total);
return " $p % | \n";
}
?>