#!/usr/bin/perl

#use utf8;
use strict;
use CGI;
use Encode;

use Opals::Context;
use Opals::Template qw(
    tmpl_read
    tmpl_write
    tmpl_redirect
);
use Opals::Locale qw(
    loc_getMsgFile
    loc_write
);

my $dbh = Opals::Context->dbh();
END { $dbh->disconnect(); }

my $cgi = CGI->new;
my $input = $cgi->Vars();
my ($permission, $cookie, $template) = tmpl_read(
            {
                dbh             => $dbh,
                cgi             => $cgi,
                tmplFile        => 'ill/illList.tmpl',
                reqPermission   => 'circ_ill_filter',
            }
    );
my $unionId  = Opals::Context->preference('unionId');
my $ill_host = Opals::Context->preference('unionSvcUrl');
   $ill_host =~ s/^http:\/\///g;
   $ill_host =~ s/\/+$//g;

my $pageId    = $input->{'pageId'};
my $url="http://$ill_host/bin/svc/openPage?unionId=$unionId&pageId=$pageId"; 

my @inName=$cgi->param();
foreach my $f(@inName){
    if($f !~ m/pageId/g){
        $url .="&$f=" .$input->{$f};
    }
}

tmpl_redirect($cgi,$url);
#$dbh->disconnect();



