#!/usr/bin/perl # # $Id: prenumeraty.pl,v 1.1 1999/04/05 21:34:22 jwr Exp $ # $dbName = "prenumeraty"; $pageFooter = <
Zawartosc bazy: (C) Copyright by Polska Fundacja Upowszechniania Nauki, Warszawa 1998
Opracowanie i umieszczenie w sieci: ICM UW J. Rychter
EFOOT ; use CGI; use DBI; use CGI::FastTemplate; $DataDir = "/www/sunsite/kbn-prenumeraty"; push(@INC, $DataDir); use BibForms; $BibForms::DataDir = "/www/sunsite/kbn-prenumeraty/"; $BibForms::TemplateDir = "/www/sunsite/kbn-prenumeraty/templates/"; # use CGI::Carp; $dbh = DBI->connect("DBI:mysql:$dbName") || die "MySQL database connect failed: $DBI::errstr\n"; $q = new CGI; print $q->header(); print $q->start_html(-title => "Prenumeraty czasopism", -BGCOLOR => 'white'); BibForms::initForm("query", "pola-query"); BibForms::readPopupValues("ilerezultatow", "kody-ilosci"); BibForms::readPopupValues("kategorie", "kody-kategorie"); if(($q->param('Szukaj') ne "Szukaj") and (length($q->param('ile')) < 1) and (length($q->param('rozwin')) < 1)) { print $q->start_multipart_form; BibForms::dumpFormFromTemplate($q, "query", 0, 'normal'); print $q->hidden(-name => "od", -value => '1'); print qq|

|; print $q->submit(-name => 'Szukaj', -value => "Szukaj"); print qq|

\n|; print $pageFooter; print $q->end_multipart_form; print $q->end_html; } elsif((length($q->param('rozwin')) < 1) and (length($q->param('sub') < 1))) { # juz wstepne kryteria podane print $q->start_form; $url = $q->self_url(); printNavURL($url, 1); $perPage = $q->param('ILEREZULTATOW'); if(length($perPage) < 1) { $perPage = $q->param('ile'); } $showFrom = $q->param('od'); if(length($showFrom) < 1) { $showFrom = 1; } $total = $q->param('total'); if(length($total) < 1) { $total = -1; } $urlParams = "ile=$perPage"; $selectString = "select number,title,previousTitle,issn,countryCode,publisher,category1,category2,countries.code,countryName,categories.code,categoryName from periodicals,countries,categories where periodicals.countryCode = countries.code and periodicals.category1 = categories.code"; if(length($q->param("TYTUL")) > 1) { $searchString = uc($q->param("TYTUL")); $selectString .= " and title like \'$searchString\'"; $urlParams .= "&TYTUL=" . $q->escape($searchString); } if(length($q->param("ISSN")) > 1) { $searchString = $q->param("ISSN"); $selectString .= " and issn = \'$searchString\'"; $urlParams .= "&ISSN=" . $q->escape($searchString); } if(length($q->param("WYDAWCA")) > 1) { $searchString = $q->param("WYDAWCA"); $selectString .= " and publisher like \'$searchString\'"; $urlParams .= "&WYDAWCA=" . $q->escape($searchString); } if(length($q->param("KATEGORIA")) > 1) { $searchString = $q->param("KATEGORIA"); $selectString .= " and categoryName=\'$searchString\'"; $urlParams .= "&KATEGORIA=" . $q->escape($searchString); } $selectString .= " order by title"; if($total < 0) { $sth = $dbh->prepare($selectString); $sth->execute(); $total = $sth->rows(); } if($total > 0) { print "

Liczba rezultatów: $total.

\n"; $nextFrom = $showFrom + $perPage; $prevFrom = $showFrom - $perPage; print "
\n"; if($prevFrom > 0) { $url = $q->url(); $url .= "?od=$prevFrom"; $url .= "&" . $urlParams; print "

<<< Poprzednia strona

\n"; } print "
\n"; if($nextFrom < $total) { $url = $q->url(); $url .= "?od=$nextFrom"; $url .= "&" . $urlParams; print "

Następna strona >>>

\n"; } print "
\n"; $limitFrom = $showFrom - 1; $selectString .= " limit $limitFrom,$perPage"; $sth = $dbh->prepare($selectString); $sth->execute(); $url = $q->url(); print "\n"; print "\n"; $i = $showFrom; while($row = $sth->fetchrow_hashref) { print "\n"; print "\n"; print ""; print ""; print ""; print ""; print "\n"; $i++; } print "
TytułISSNKrajWydawca
$i{number}&$urlParams&od=$showFrom\">$row->{title}$row->{issn}$row->{countryName}$row->{publisher}
\n"; print "
\n"; if($prevFrom > 0) { $url = $q->url(); $url .= "?od=$prevFrom"; $url .= "&" . $urlParams; print "

<<< Poprzednia strona

\n"; } print "
\n"; if($nextFrom < $total) { $url = $q->url(); $url .= "?od=$nextFrom"; $url .= "&" . $urlParams; print "

Następna strona >>>

\n"; } print "
\n"; } else { print "

Nie znaleziono żadnych rezultatów. Spróbuj zadać mniej precyzyjne zapytanie aby poszerzyć zakres poszukiwań.

\n"; } $url = $q->self_url(); printNavURL($url, 1); print $pageFooter; print $q->end_form; print $q->end_html; } elsif(length($q->param('sub')) < 1) { # rozwijamy print $q->start_form; $url = $q->self_url(); printNavURL($url, 2); $recNo = $q->param('rozwin'); $selectString = "select number,title,previousTitle,issn,countryCode,publisher,category1,category2,countries.code,countryName,categories.code,categoryName from periodicals,countries,categories where periodicals.countryCode = countries.code and periodicals.category1 = categories.code"; if(length($recNo) > 0) { $selectString .= " and number=$recNo"; } $sth = $dbh->prepare($selectString); $sth->execute(); $url = $q->self_url(); $row = $sth->fetchrow_hashref(); print "

Dane czasopisma

\n"; print qq|\n|; print qq||; print qq||; print qq||; print qq||; print qq||; print qq|
Tytuł:$row->{title}
ISSN:$row->{issn}
Kraj:$row->{countryName}
Wydawca:$row->{publisher}
Kategoria:$row->{categoryName}
\n|; $selectString = "select periodical,year,subscriber,exch,code,name from subscriptions,subscribers where subscriptions.periodical = $recNo and subscriptions.subscriber = subscribers.code order by year desc, name"; $sth = $dbh->prepare($selectString); print qq|

Prenumeratorzy:

\n|; $sth->execute(); while($row = $sth->fetchrow_hashref) { print qq|

$row->{year}:$row->{name}

\n|; } $url = $q->self_url(); printNavURL($url, 2); print $pageFooter; print $q->end_form; print $q->end_html; } else { print $q->start_form; $url = $q->self_url(); printNavURL($url, 3); $subNo = $q->param('sub'); $selectString = "select name,postalCode,city,address,telephone,email,code from subscribers where subscribers.code = $subNo"; $sth = $dbh->prepare($selectString); $sth->execute(); print "

Dane instytucji

\n"; $row = $sth->fetchrow_hashref(); print qq|\n|; print qq||; print qq||; print qq||; print qq||; if(length($row->{email}) > 0) { print qq||; } print qq|
Nazwa:$row->{name}
Adres:$row->{address}
$row->{postalCode} $row->{city}
Telefony:$row->{telephone}
E-poczta:$row->{email}
\n|; $url = $q->self_url(); printNavURL($url, 3); print $pageFooter; print $q->end_form; print $q->end_html; } sub printNavURL { my($url, $level) = @_; $urlp = $url; $urlp =~ s/&?sub=(\d+)//; $urlr = $urlp; $urlr =~ s/rozwin=(\d+)&*//; print qq|

Prenumeraty czasopism\n|; if($level == 1) { print qq|/ Lista rezultatów\n|; } if($level > 1) { print qq|/ Lista rezultatów\n|; } if($level == 2) { print qq|/ Dane publikacji\n|; } if($level > 2) { print qq|/ Dane publikacji\n|; } if($level >= 3) { print qq|/ Dane prenumeratora\n|; } print qq|

\n|; }