New framework handling. New koha_attr table for mapping MARC to koha
This commit is contained in:
parent
ad657e71eb
commit
fe59c6c516
|
|
@ -5,8 +5,7 @@ use CGI;
|
|||
use C4::Auth;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Database;
|
||||
use HTML::Template;
|
||||
|
||||
|
||||
my $query = new CGI;
|
||||
my ($template, $loggedinuser, $cookie)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,24 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
#script to administer the aqbudget table
|
||||
#written 20/02/2002 by paul.poulain@free.fr
|
||||
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
|
||||
|
||||
# ALGO :
|
||||
# this script use an $op to know what to do.
|
||||
# if $op is empty or none of the above values,
|
||||
# - the default screen is build (with all records, or filtered datas).
|
||||
# - the user can clic on add, modify or delete record.
|
||||
# if $op=add_form
|
||||
# - if primkey exists, this is a modification,so we read the $primkey record
|
||||
# - builds the add/modify form
|
||||
# if $op=add_validate
|
||||
# - the user has just send datas, so we create/modify the record
|
||||
# if $op=delete_form
|
||||
# - we show the record having primkey=$primkey and ask for deletion validation form
|
||||
# if $op=delete_confirm
|
||||
# - we delete the record having primkey=$primkey
|
||||
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
|
|
@ -19,91 +37,73 @@
|
|||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
aqbookfund.pl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
script to administer the aqbudget table.
|
||||
|
||||
=head1 CGI PARAMETERS
|
||||
|
||||
=over 4
|
||||
|
||||
=item op
|
||||
this script use an C<$op> to know what to do.
|
||||
C<op> can be equal to:
|
||||
* empty or none of the above values, then
|
||||
- the default screen is build (with all records, or filtered datas).
|
||||
- the user can clic on add, modify or delete record.
|
||||
* add_form, then
|
||||
- if primkey exists, this is a modification,so we read the $primkey record
|
||||
- builds the add/modify form
|
||||
* add_validate, then
|
||||
- the user has just send datas, so we create/modify the record
|
||||
* delete_form, then
|
||||
- we show the record having primkey=$primkey and ask for deletion validation form
|
||||
* delete_confirm, then
|
||||
- we delete the record having primkey=$primkey
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
use HTML::Template;
|
||||
use List::Util qw/min/;
|
||||
use C4::Auth;
|
||||
use C4::Koha;
|
||||
use C4::Context;
|
||||
use C4::Bookfund;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
use C4::Date;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup from aqbookfund where (bookfundname like ?) order by bookfundid");
|
||||
$sth->execute("%$data[0]%");
|
||||
my @results;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
}
|
||||
# $sth->execute;
|
||||
$sth->finish;
|
||||
return (scalar(@results),\@results);
|
||||
}
|
||||
|
||||
my $input = new CGI;
|
||||
my $searchfield=$input->param('searchfield');
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/aqbookfund.pl";
|
||||
my $bookfundid=$input->param('bookfundid');
|
||||
my $pagesize = 10;
|
||||
my $op = $input->param('op') || '';
|
||||
my $pagesize=20;
|
||||
my $op = $input->param('op');
|
||||
$searchfield=~ s/\,//g;
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user(
|
||||
{template_name => "admin/aqbookfund.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1, management => 1},
|
||||
debug => 1,
|
||||
}
|
||||
);
|
||||
= get_template_and_user({template_name => "admin/aqbookfund.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1, management => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
if ($op) {
|
||||
$template->param(
|
||||
script_name => $script_name,
|
||||
$op => 1,
|
||||
); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
else {
|
||||
$template->param(script_name => $script_name,
|
||||
$template->param(script_name => $script_name,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
$template->param(action => $script_name);
|
||||
|
||||
my $branches = GetBranches;
|
||||
|
||||
################## ADD_FORM ##################################
|
||||
# called by default. Used to create form to add or modify a record
|
||||
if ($op eq 'add_form') {
|
||||
#---- if primkey exists, it's a modify action, so read values to modify...
|
||||
my $dataaqbookfund;
|
||||
my $data;
|
||||
my $header;
|
||||
if ($bookfundid) {
|
||||
$dataaqbookfund = GetBookFund($bookfundid);
|
||||
}
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup from aqbookfund where bookfundid=?");
|
||||
$sth->execute($bookfundid);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
if ($bookfundid) {
|
||||
$header = "Modify book fund";
|
||||
$template->param('header-is-modify-p' => 1);
|
||||
|
|
@ -119,171 +119,78 @@ if ($op eq 'add_form') {
|
|||
}
|
||||
$template->param(add_or_modify => $add_or_modify);
|
||||
$template->param(bookfundid =>$bookfundid);
|
||||
$template->param(bookfundname =>$dataaqbookfund->{'bookfundname'});
|
||||
|
||||
my @branchloop;
|
||||
foreach my $branchcode (sort keys %{$branches}) {
|
||||
my $row = {
|
||||
branchcode => $branchcode,
|
||||
branchname => $branches->{$branchcode}->{branchname},
|
||||
};
|
||||
|
||||
if (defined $bookfundid
|
||||
and defined $dataaqbookfund->{branchcode}
|
||||
and $dataaqbookfund->{branchcode} eq $branchcode) {
|
||||
$row->{selected} = 1;
|
||||
}
|
||||
|
||||
push @branchloop, $row;
|
||||
}
|
||||
|
||||
$template->param(branches => \@branchloop);
|
||||
|
||||
} # END $OP eq ADD_FORM
|
||||
$template->param(bookfundname =>$data->{'bookfundname'});
|
||||
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
elsif ($op eq 'add_validate') {
|
||||
my $bookfundid = uc $input->param('bookfundid');
|
||||
|
||||
my $number = Countbookfund($bookfundid);
|
||||
|
||||
my $bookfund_already_exists = $number > 0 ? 1 : 0;
|
||||
|
||||
if ($bookfund_already_exists) {
|
||||
my $bookfundname = $input->param('bookfundname');
|
||||
my $branchcode = $input->param('branchcode') || undef;
|
||||
|
||||
ModBookFund($bookfundname,$branchcode,$bookfundid);
|
||||
}
|
||||
else {
|
||||
NewBookFund(
|
||||
$bookfundid,
|
||||
$input->param('bookfundname'),
|
||||
$input->param('branchcode')
|
||||
);
|
||||
}
|
||||
$input->redirect('aqbookfund.pl');
|
||||
# END $OP eq ADD_VALIDATE
|
||||
}
|
||||
} elsif ($op eq 'add_validate') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $bookfundid=uc($input->param('bookfundid'));
|
||||
my $sth=$dbh->prepare("delete from aqbookfund where bookfundid =?");
|
||||
$sth->execute($bookfundid);
|
||||
$sth->finish;
|
||||
my $sth=$dbh->prepare("replace aqbookfund (bookfundid,bookfundname) values (?,?)");
|
||||
$sth->execute($input->param('bookfundid'),$input->param('bookfundname'));
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=aqbookfund.pl\"></html>";
|
||||
exit;
|
||||
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
# called by default form, used to confirm deletion of data in DB
|
||||
|
||||
elsif ($op eq 'delete_confirm') {
|
||||
my $data = GetBookFund($bookfundid);
|
||||
} elsif ($op eq 'delete_confirm') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup from aqbookfund where bookfundid=?");
|
||||
$sth->execute($bookfundid);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
$template->param(bookfundid => $bookfundid);
|
||||
$template->param(bookfundname => $data->{'bookfundname'});
|
||||
} # END $OP eq DELETE_CONFIRM
|
||||
|
||||
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
################## DELETE_CONFIRMED ##################################
|
||||
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
||||
elsif ($op eq 'delete_confirmed') {
|
||||
DelBookFund(uc($input->param('bookfundid')));
|
||||
|
||||
}# END $OP eq DELETE_CONFIRMED
|
||||
|
||||
|
||||
} elsif ($op eq 'delete_confirmed') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $bookfundid=uc($input->param('bookfundid'));
|
||||
my $sth=$dbh->prepare("delete from aqbookfund where bookfundid=?");
|
||||
$sth->execute($bookfundid);
|
||||
$sth->finish;
|
||||
$sth=$dbh->prepare("delete from aqbudget where bookfundid=?");
|
||||
$sth->execute($bookfundid);
|
||||
$sth->finish;
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
################## DEFAULT ##################################
|
||||
else { # DEFAULT
|
||||
my ($query, $sth);
|
||||
|
||||
$template->param(scriptname => $script_name);
|
||||
|
||||
# filters
|
||||
my @branchloop;
|
||||
foreach my $branchcode (sort keys %{$branches}) {
|
||||
my $row = {
|
||||
code => $branchcode,
|
||||
name => $branches->{$branchcode}->{branchname},
|
||||
};
|
||||
|
||||
if (defined $input->param('filter_branchcode')
|
||||
and $input->param('filter_branchcode') eq $branchcode) {
|
||||
$row->{selected} = 1;
|
||||
}
|
||||
|
||||
push @branchloop, $row;
|
||||
}
|
||||
|
||||
my @bookfundids_loop;
|
||||
my $sth = GetBookFundsId();
|
||||
|
||||
while (my $row = $sth->fetchrow_hashref) {
|
||||
if (defined $input->param('filter_bookfundid') and $input->param('filter_bookfundid') eq $row->{bookfundid}){
|
||||
$row->{selected} = 1;
|
||||
}
|
||||
push @bookfundids_loop, $row;
|
||||
}
|
||||
|
||||
$template->param(
|
||||
filter_bookfundids => \@bookfundids_loop,
|
||||
filter_branches => \@branchloop,
|
||||
filter_bookfundname => $input->param('filter_bookfundname') || undef,
|
||||
);
|
||||
|
||||
# searching the bookfunds corresponding to our filtering rules
|
||||
my @results = SearchBookFund(
|
||||
$input->param('filter'),
|
||||
$input->param('filter_bookfundid'),
|
||||
$input->param('filter_bookfundname'),
|
||||
$input->param('filter_branchcode'),
|
||||
);
|
||||
|
||||
# does the book funds have budgets?
|
||||
my @loop_id;
|
||||
my $sth = GetBookFundsId();
|
||||
while (my $row = $sth->fetchrow){
|
||||
push @loop_id, $row;
|
||||
}
|
||||
|
||||
my ($id,%nb_budgets_of);
|
||||
foreach $id (@loop_id){
|
||||
my $number = Countbookfund($id);
|
||||
$nb_budgets_of{$id} = $number;
|
||||
}
|
||||
|
||||
# pagination informations
|
||||
my $page = $input->param('page') || 1;
|
||||
my @loop;
|
||||
|
||||
my $first = ($page - 1) * $pagesize;
|
||||
|
||||
# if we are on the last page, the number of the last word to display
|
||||
# must not exceed the length of the results array
|
||||
my $last = min(
|
||||
$first + $pagesize - 1,
|
||||
scalar(@results) - 1,
|
||||
);
|
||||
|
||||
my $toggle = 0;
|
||||
foreach my $result (@results[$first .. $last]) {
|
||||
push(
|
||||
@loop,
|
||||
{
|
||||
%{$result},
|
||||
toggle => $toggle++%2,
|
||||
branchname =>
|
||||
$branches->{ $result->{branchcode} }->{branchname},
|
||||
has_budgets => defined $nb_budgets_of{ $result->{bookfundid} },
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$template->param(
|
||||
bookfund => \@loop,
|
||||
pagination_bar => pagination_bar(
|
||||
$script_name,
|
||||
getnbpages(scalar @results, $pagesize),
|
||||
$page,
|
||||
'page'
|
||||
)
|
||||
);
|
||||
} else { # DEFAULT
|
||||
$template->param(scriptname => $script_name);
|
||||
if ($searchfield ne '') {
|
||||
$template->param(search => 1);
|
||||
$template->param(searchfield => $searchfield);
|
||||
}
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$searchfield,'web');
|
||||
my $toggle="white";
|
||||
my @loop_data =();
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth2 = $dbh->prepare("Select aqbudgetid,startdate,enddate,budgetamount from aqbudget where bookfundid = ? order by bookfundid");
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
my %row_data;
|
||||
$row_data{bookfundid} =$results->[$i]{'bookfundid'};
|
||||
$row_data{bookfundname} = $results->[$i]{'bookfundname'};
|
||||
$sth2->execute($row_data{bookfundid});
|
||||
my @budget_loop;
|
||||
while (my ($aqbudgetid,$startdate,$enddate,$budgetamount) = $sth2->fetchrow) {
|
||||
my %budgetrow_data;
|
||||
$budgetrow_data{aqbudgetid} = $aqbudgetid;
|
||||
$budgetrow_data{startdate} = format_date($startdate);
|
||||
$budgetrow_data{enddate} = format_date($enddate);
|
||||
$budgetrow_data{budgetamount} = $budgetamount;
|
||||
push @budget_loop,\%budgetrow_data;
|
||||
}
|
||||
$row_data{budget} = \@budget_loop;
|
||||
push @loop_data,\%row_data;
|
||||
}
|
||||
$template->param(bookfund => \@loop_data);
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(
|
||||
intranetcolorstylesheet =>C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -39,198 +39,115 @@
|
|||
|
||||
use strict;
|
||||
use CGI;
|
||||
use HTML::Template;
|
||||
use List::Util qw/min/;
|
||||
|
||||
use C4::Date;
|
||||
use C4::Auth;
|
||||
use C4::Acquisition;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
use C4::Koha;
|
||||
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("Select aqbudgetid,bookfundid,startdate,enddate,budgetamount from aqbudget where (bookfundid like ?) order by bookfundid,aqbudgetid");
|
||||
$sth->execute("$data[0]%");
|
||||
my @results;
|
||||
my $cnt=0;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
$cnt ++;
|
||||
}
|
||||
# $sth->execute;
|
||||
$sth->finish;
|
||||
return ($cnt,\@results);
|
||||
}
|
||||
|
||||
my $input = new CGI;
|
||||
my $searchfield=$input->param('searchfield');
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/aqbudget.pl";
|
||||
my $bookfundid=$input->param('bookfundid');
|
||||
my $aqbudgetid=$input->param('aqbudgetid');
|
||||
my $pagesize = 20;
|
||||
my $pagesize=20;
|
||||
my $op = $input->param('op');
|
||||
$searchfield=~ s/\,//g;
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user(
|
||||
{template_name => "admin/aqbudget.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
}
|
||||
);
|
||||
= get_template_and_user({template_name => "admin/aqbudget.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
$template->param(
|
||||
action => $script_name,
|
||||
DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(),
|
||||
script_name => $script_name,
|
||||
$op || 'else' => 1,
|
||||
);
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
|
||||
$sthtemp->execute($borrowernumber);
|
||||
my ($flags, $homebranch)=$sthtemp->fetchrow;
|
||||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
$template->param(action => $script_name);
|
||||
################## ADD_FORM ##################################
|
||||
# called by default. Used to create form to add or modify a record
|
||||
if ($op eq 'add_form') {
|
||||
my ($query, $dataaqbudget, $dataaqbookfund, $sth);
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
#---- if primkey exists, it's a modify action, so read values to modify...
|
||||
if ($aqbudgetid) {
|
||||
$query = '
|
||||
SELECT aqbudgetid,
|
||||
bookfundname,
|
||||
aqbookfund.bookfundid,
|
||||
startdate,
|
||||
enddate,
|
||||
budgetamount,
|
||||
aqbudget.branchcode
|
||||
FROM aqbudget
|
||||
INNER JOIN aqbookfund ON aqbudget.bookfundid = aqbookfund.bookfundid
|
||||
WHERE aqbudgetid = ?
|
||||
';
|
||||
$sth=$dbh->prepare($query);
|
||||
$sth->execute($aqbudgetid);
|
||||
$dataaqbudget=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT aqbookfund.branchcode,
|
||||
branches.branchname,
|
||||
aqbookfund.bookfundname
|
||||
FROM aqbookfund
|
||||
LEFT JOIN branches ON aqbookfund.branchcode = branches.branchcode
|
||||
WHERE bookfundid = ?
|
||||
';
|
||||
$sth=$dbh->prepare($query);
|
||||
$sth->execute(
|
||||
defined $aqbudgetid ? $dataaqbudget->{bookfundid} : $bookfundid,
|
||||
);
|
||||
$dataaqbookfund=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
||||
if (defined $aqbudgetid) {
|
||||
$template->param(
|
||||
bookfundid => $dataaqbudget->{'bookfundid'},
|
||||
bookfundname => $dataaqbudget->{'bookfundname'}
|
||||
);
|
||||
}
|
||||
else {
|
||||
$template->param(
|
||||
bookfundid => $bookfundid,
|
||||
bookfundname => $dataaqbookfund->{bookfundname},
|
||||
);
|
||||
}
|
||||
|
||||
# Available branches
|
||||
my @branches = ();
|
||||
|
||||
$query = '
|
||||
SELECT branchcode,
|
||||
branchname
|
||||
FROM branches
|
||||
ORDER BY branchname
|
||||
';
|
||||
$sth=$dbh->prepare($query);
|
||||
$sth->execute();
|
||||
while (my $row = $sth->fetchrow_hashref) {
|
||||
my $branch = $row;
|
||||
|
||||
if (defined $dataaqbookfund->{branchcode}) {
|
||||
$branch->{selected} =
|
||||
$dataaqbookfund->{branchcode} eq $row->{branchcode} ? 1 : 0;
|
||||
}
|
||||
elsif (defined $aqbudgetid) {
|
||||
$branch->{selected} =
|
||||
$dataaqbudget->{branchcode} eq $row->{branchcode} ? 1 : 0;
|
||||
}
|
||||
|
||||
push @branches, $branch;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
$template->param(
|
||||
dateformat => display_date_format(),
|
||||
aqbudgetid => $dataaqbudget->{'aqbudgetid'},
|
||||
startdate => format_date($dataaqbudget->{'startdate'}),
|
||||
enddate => format_date($dataaqbudget->{'enddate'}),
|
||||
budgetamount => $dataaqbudget->{'budgetamount'},
|
||||
branches => \@branches,
|
||||
);
|
||||
|
||||
if (defined $dataaqbookfund->{branchcode}) {
|
||||
$template->param(
|
||||
disable_branchselection => 1,
|
||||
branch => $dataaqbookfund->{branchcode},
|
||||
);
|
||||
}
|
||||
#---- if primkey exists, it's a modify action, so read values to modify...
|
||||
my $dataaqbudget;
|
||||
my $dataaqbookfund;
|
||||
if ($aqbudgetid) {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select aqbudgetid,bookfundname,aqbookfund.bookfundid,startdate,enddate,budgetamount from aqbudget,aqbookfund where aqbudgetid=? and aqbudget.bookfundid=aqbookfund.bookfundid");
|
||||
$sth->execute($aqbudgetid);
|
||||
$dataaqbudget=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
my $header;
|
||||
if ($aqbudgetid) {
|
||||
$header = "Modify budget";
|
||||
} else {
|
||||
$header = "Add budget";
|
||||
}
|
||||
$template->param(header => $header);
|
||||
if ($aqbudgetid) {
|
||||
$template->param(modify => 1);
|
||||
$template->param(bookfundid => $dataaqbudget->{bookfundid});
|
||||
$template->param(bookfundname => $dataaqbudget->{bookfundname});
|
||||
} else {
|
||||
$template->param(bookfundid => $bookfundid,
|
||||
adding => 1);
|
||||
}
|
||||
$template->param(dateformat => display_date_format(),
|
||||
aqbudgetid => $dataaqbudget->{'aqbudgetid'},
|
||||
startdate => format_date($dataaqbudget->{'startdate'}),
|
||||
enddate => format_date($dataaqbudget->{'enddate'}),
|
||||
budgetamount => $dataaqbudget->{'budgetamount'}
|
||||
);
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
my ($query, $sth);
|
||||
|
||||
if (defined $aqbudgetid) {
|
||||
$query = '
|
||||
UPDATE aqbudget
|
||||
SET bookfundid = ?,
|
||||
startdate = ?,
|
||||
enddate = ?,
|
||||
budgetamount = ?,
|
||||
branchcode = ?
|
||||
WHERE aqbudgetid = ?
|
||||
';
|
||||
$sth=$dbh->prepare($query);
|
||||
$sth->execute(
|
||||
$input->param('bookfundid'),
|
||||
format_date_in_iso($input->param('startdate')),
|
||||
format_date_in_iso($input->param('enddate')),
|
||||
$input->param('budgetamount'),
|
||||
$input->param('branch') || undef,
|
||||
$aqbudgetid,
|
||||
);
|
||||
$sth->finish;
|
||||
}
|
||||
else {
|
||||
$query = '
|
||||
INSERT
|
||||
INTO aqbudget
|
||||
(bookfundid, startdate, enddate, budgetamount, branchcode)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?)
|
||||
';
|
||||
$sth=$dbh->prepare($query);
|
||||
$sth->execute(
|
||||
$input->param('bookfundid'),
|
||||
format_date_in_iso($input->param('startdate')),
|
||||
format_date_in_iso($input->param('enddate')),
|
||||
$input->param('budgetamount'),
|
||||
$input->param('branch') || undef,
|
||||
);
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
$input->redirect("aqbudget.pl");
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("replace aqbudget (aqbudgetid,bookfundid,startdate,enddate,budgetamount) values (?,?,?,?,?)");
|
||||
$sth->execute($input->param('aqbudgetid'),$input->param('bookfundid'),
|
||||
format_date_in_iso($input->param('startdate')),
|
||||
format_date_in_iso($input->param('enddate')),
|
||||
$input->param('budgetamount')
|
||||
);
|
||||
$sth->finish;
|
||||
print $input->redirect("aqbookfund.pl");
|
||||
exit;
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
# called by default form, used to confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirm') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select aqbudgetid,bookfundid,startdate,enddate,budgetamount,branchcode from aqbudget where aqbudgetid=?");
|
||||
my $sth=$dbh->prepare("select aqbudgetid,bookfundid,startdate,enddate,budgetamount from aqbudget where aqbudgetid=?");
|
||||
$sth->execute($aqbudgetid);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
|
@ -253,181 +170,54 @@ INSERT
|
|||
# END $OP eq DELETE_CONFIRMED
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
my ($query, $sth);
|
||||
|
||||
# create a look-up table for bookfund names from bookfund ids,
|
||||
# instead of having on query per budget
|
||||
my %bookfundname_of = ();
|
||||
$query = '
|
||||
SELECT bookfundid, bookfundname
|
||||
FROM aqbookfund
|
||||
';
|
||||
$sth=$dbh->prepare($query);
|
||||
$sth->execute;
|
||||
while (my $row = $sth->fetchrow_hashref) {
|
||||
$bookfundname_of{ $row->{bookfundid} } = $row->{bookfundname};
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
# filters
|
||||
my $branches = GetBranches();
|
||||
my @branchloop;
|
||||
foreach my $branchcode (sort keys %{$branches}) {
|
||||
my $row = {
|
||||
code => $branchcode,
|
||||
name => $branches->{$branchcode}->{branchname},
|
||||
};
|
||||
|
||||
if (defined $input->param('filter_branchcode')
|
||||
and $input->param('filter_branchcode') eq $branchcode) {
|
||||
$row->{selected} = 1;
|
||||
}
|
||||
|
||||
push @branchloop, $row;
|
||||
}
|
||||
|
||||
my @bookfundids_loop;
|
||||
$query = '
|
||||
SELECT bookfundid
|
||||
FROM aqbookfund
|
||||
';
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute();
|
||||
while (my $row = $sth->fetchrow_hashref) {
|
||||
if (defined $input->param('filter_bookfundid')
|
||||
and $input->param('filter_bookfundid') eq $row->{bookfundid}) {
|
||||
$row->{selected} = 1;
|
||||
}
|
||||
|
||||
push @bookfundids_loop, $row;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
$template->param(
|
||||
filter_bookfundids => \@bookfundids_loop,
|
||||
filter_branches => \@branchloop,
|
||||
filter_amount => $input->param('filter_amount') || undef,
|
||||
filter_startdate => $input->param('filter_startdate') || undef,
|
||||
filter_enddate => $input->param('filter_enddate') || undef,
|
||||
);
|
||||
|
||||
my %sign_label_of = (
|
||||
'=' => 'equal',
|
||||
'>=' => 'superior',
|
||||
'<=' => 'inferior',
|
||||
);
|
||||
|
||||
foreach my $field (qw/startdate enddate amount/) {
|
||||
my $param = 'filter_'.$field.'_sign';
|
||||
|
||||
foreach my $sign (keys %sign_label_of) {
|
||||
if ($input->param($param) eq $sign) {
|
||||
$template->param(
|
||||
$param.'_'.$sign_label_of{$sign}.'_selected' => 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Search all available budgets
|
||||
$query = '
|
||||
SELECT aqbudgetid,
|
||||
bookfundid,
|
||||
startdate,
|
||||
enddate,
|
||||
budgetamount,
|
||||
branchcode
|
||||
FROM aqbudget
|
||||
WHERE 1 = 1';
|
||||
|
||||
my @bindings;
|
||||
|
||||
if ($input->param('filter_bookfundid')) {
|
||||
$query.= '
|
||||
AND bookfundid = ?
|
||||
';
|
||||
push @bindings, $input->param('filter_bookfundid');
|
||||
}
|
||||
if ($input->param('filter_branchcode')) {
|
||||
$query.= '
|
||||
AND branchcode = ?
|
||||
';
|
||||
push @bindings, $input->param('filter_branchcode');
|
||||
}
|
||||
if ($input->param('filter_startdate')) {
|
||||
$query.= '
|
||||
AND startdate '.$input->param('filter_startdate_sign').' ?
|
||||
';
|
||||
push @bindings, format_date_in_iso($input->param('filter_startdate'));
|
||||
}
|
||||
if ($input->param('filter_enddate')) {
|
||||
$query.= '
|
||||
AND enddate '.$input->param('filter_enddate_sign').' ?
|
||||
';
|
||||
push @bindings, format_date_in_iso($input->param('filter_enddate'));
|
||||
}
|
||||
if ($input->param('filter_amount')) {
|
||||
$query.= '
|
||||
AND budgetamount '.$input->param('filter_amount_sign').' ?
|
||||
';
|
||||
# the amount must be a quantity, with 2 digits after the decimal
|
||||
# separator
|
||||
$input->param('filter_amount') =~ m{(\d* (?:\.\d{,2})? )}xms;
|
||||
my ($amount) = $1;
|
||||
push @bindings, $amount;
|
||||
}
|
||||
|
||||
$query.= '
|
||||
ORDER BY bookfundid, aqbudgetid
|
||||
';
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute(@bindings);
|
||||
my @results;
|
||||
while (my $row = $sth->fetchrow_hashref){
|
||||
push @results, $row;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
# filter budgets depending on the pagination
|
||||
my $page = $input->param('page') || 1;
|
||||
my $first = ($page - 1) * $pagesize;
|
||||
|
||||
# if we are on the last page, the number of the last word to display
|
||||
# must not exceed the length of the results array
|
||||
my $last = min(
|
||||
$first + $pagesize - 1,
|
||||
scalar @results - 1,
|
||||
);
|
||||
|
||||
my $toggle = 0;
|
||||
my @loop;
|
||||
foreach my $result (@results[$first .. $last]) {
|
||||
push(
|
||||
@loop,
|
||||
{
|
||||
%{$result},
|
||||
toggle => $toggle++%2,
|
||||
bookfundname => $bookfundname_of{ $result->{'bookfundid'} },
|
||||
branchname => $branches->{ $result->{branchcode} }->{branchname},
|
||||
startdate => format_date($result->{startdate}),
|
||||
enddate => format_date($result->{enddate}),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$template->param(
|
||||
budget => \@loop,
|
||||
pagination_bar => pagination_bar(
|
||||
$script_name,
|
||||
getnbpages(scalar @results, $pagesize),
|
||||
$page,
|
||||
'page'
|
||||
)
|
||||
);
|
||||
if ($searchfield ne '') {
|
||||
$template->param(search => 1);
|
||||
$template->param(searchfield => $searchfield);
|
||||
}
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$searchfield,'web');
|
||||
my $toggle="white";
|
||||
my @loop_data =();
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
#find out stats
|
||||
# my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'});
|
||||
# $fines=$fines+0;
|
||||
my $dataaqbookfund;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select bookfundid,bookfundname from aqbookfund where bookfundid=?");
|
||||
$sth->execute($results->[$i]{'bookfundid'});
|
||||
$dataaqbookfund=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
my @toggle = ();
|
||||
my @bookfundid = ();
|
||||
my @bookfundname = ();
|
||||
my @startdate = ();
|
||||
my @enddate = ();
|
||||
my @budgetamount = ();
|
||||
push(@toggle,$toggle);
|
||||
push(@bookfundid,$results->[$i]{'bookfundid'});
|
||||
push(@bookfundname,$dataaqbookfund->{'bookfundname'});
|
||||
push(@startdate,format_date($results->[$i]{'startdate'}));
|
||||
push(@enddate,format_date($results->[$i]{'enddate'}));
|
||||
push(@budgetamount,$results->[$i]{'budgetamount'});
|
||||
if ($toggle eq 'white'){
|
||||
$toggle="#ffffcc";
|
||||
} else {
|
||||
$toggle="white";
|
||||
}
|
||||
while (@toggle and @bookfundid and @bookfundname and @startdate and @enddate and @budgetamount) {
|
||||
my %row_data;
|
||||
$row_data{toggle} = shift @toggle;
|
||||
$row_data{bookfundid} = shift @bookfundid;
|
||||
$row_data{bookfundname} = shift @bookfundname;
|
||||
$row_data{startdate} = shift @startdate;
|
||||
$row_data{enddate} = shift @enddate;
|
||||
$row_data{budgetamount} = shift @budgetamount;
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
}
|
||||
$template->param(budget => \@loop_data);
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use C4::Auth;
|
|||
use CGI;
|
||||
use C4::Search;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$authtypecode)=@_;
|
||||
|
|
@ -86,18 +86,10 @@ if ($op eq 'add_form') {
|
|||
my $data;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $more_subfields = $input->param("more_subfields")+1;
|
||||
# builds kohafield tables
|
||||
my @kohafields;
|
||||
push @kohafields, "";
|
||||
my $sth2=$dbh->prepare("SHOW COLUMNS from auth_header");
|
||||
$sth2->execute;
|
||||
while ((my $field) = $sth2->fetchrow_array) {
|
||||
push @kohafields, "auth_header.".$field;
|
||||
}
|
||||
|
||||
# build authorised value list
|
||||
$sth2->finish;
|
||||
$sth2 = $dbh->prepare("select distinct category from authorised_values");
|
||||
|
||||
my $sth2 = $dbh->prepare("select distinct category from authorised_values");
|
||||
$sth2->execute;
|
||||
my @authorised_values;
|
||||
push @authorised_values,"";
|
||||
|
|
@ -147,23 +139,20 @@ if ($op eq 'add_form') {
|
|||
},
|
||||
-default=>$data->{'tab'},
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
|
||||
-id=>"ohidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>substr($data->{'hidden'},0,1),
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
|
||||
-id=>"ihidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-default=>substr($data->{'hidden'},1,1),
|
||||
|
|
@ -184,19 +173,11 @@ if ($op eq 'add_form') {
|
|||
$row_data{liblibrarian} = CGI::escapeHTML($data->{'liblibrarian'});
|
||||
$row_data{libopac} = CGI::escapeHTML($data->{'libopac'});
|
||||
$row_data{seealso} = CGI::escapeHTML($data->{'seealso'});
|
||||
$row_data{kohafield}= CGI::scrolling_list( -name=>"kohafield",
|
||||
-id=>"kohafield$i",
|
||||
-values=> \@kohafields,
|
||||
-default=> "$data->{'kohafield'}",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-id=>'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-default=>$data->{'authorised_value'},
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{value_builder} = CGI::scrolling_list(-name=>'value_builder',
|
||||
|
|
@ -204,7 +185,6 @@ if ($op eq 'add_form') {
|
|||
-values=> \@value_builder,
|
||||
-default=>$data->{'value_builder'},
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
|
||||
|
|
@ -245,15 +225,12 @@ if ($op eq 'add_form') {
|
|||
},
|
||||
-default=>"",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
|
||||
-id=>"ohidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
|
|
@ -261,10 +238,8 @@ if ($op eq 'add_form') {
|
|||
|
||||
$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
|
||||
-id=>"ihidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
|
|
@ -299,18 +274,11 @@ if ($op eq 'add_form') {
|
|||
-checked => '',
|
||||
-value => 1,
|
||||
-label => '');
|
||||
$row_data{kohafield}= CGI::scrolling_list( -name=>'kohafield',
|
||||
-id => "kohafield$i",
|
||||
-values=> \@kohafields,
|
||||
-default=> "",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
|
||||
$row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-id => 'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{link} = CGI::checkbox( -name => "link",
|
||||
|
|
@ -326,7 +294,7 @@ if ($op eq 'add_form') {
|
|||
$template->param('use-heading-flags-p' => 1);
|
||||
$template->param('heading-edit-subfields-p' => 1);
|
||||
$template->param(action => "Edit subfields",
|
||||
tagfield => "<input type=\"hidden\" name=\"tagfield\" value=\"$tagfield\" />$tagfield",
|
||||
tagfield => "<input type=\"hidden\" name=\"tagfield\" value=\"$tagfield\">$tagfield",
|
||||
loop => \@loop_data,
|
||||
more_subfields => $more_subfields,
|
||||
more_tag => $tagfield);
|
||||
|
|
@ -337,12 +305,11 @@ if ($op eq 'add_form') {
|
|||
} elsif ($op eq 'add_validate') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
$template->param(tagfield => "$input->param('tagfield')");
|
||||
my $sth=$dbh->prepare("replace auth_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl, link)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
my $sth=$dbh->prepare("replace auth_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl, link)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
my @tagsubfield = $input->param('tagsubfield');
|
||||
my @liblibrarian = $input->param('liblibrarian');
|
||||
my @libopac = $input->param('libopac');
|
||||
my @kohafield = $input->param('kohafield');
|
||||
my @tab = $input->param('tab');
|
||||
my @seealso = $input->param('seealso');
|
||||
#my @hidden = $input->param('hidden');
|
||||
|
|
@ -362,7 +329,7 @@ if ($op eq 'add_form') {
|
|||
my $libopac =$libopac[$i];
|
||||
my $repeatable =$input->param("repeatable$i")?1:0;
|
||||
my $mandatory =$input->param("mandatory$i")?1:0;
|
||||
my $kohafield =$kohafield[$i];
|
||||
|
||||
my $tab =$tab[$i];
|
||||
my $seealso =$seealso[$i];
|
||||
my $authorised_value =$authorised_values[$i];
|
||||
|
|
@ -379,7 +346,6 @@ if ($op eq 'add_form') {
|
|||
$libopac,
|
||||
$repeatable,
|
||||
$mandatory,
|
||||
$kohafield,
|
||||
$tab,
|
||||
$seealso,
|
||||
$authorised_value,
|
||||
|
|
@ -445,7 +411,6 @@ if ($op eq 'add_form') {
|
|||
$row_data{tagfield} = $results->[$i]{'tagfield'};
|
||||
$row_data{tagsubfield} = $results->[$i]{'tagsubfield'};
|
||||
$row_data{liblibrarian} = $results->[$i]{'liblibrarian'};
|
||||
$row_data{kohafield} = $results->[$i]{'kohafield'};
|
||||
$row_data{repeatable} = $results->[$i]{'repeatable'};
|
||||
$row_data{mandatory} = $results->[$i]{'mandatory'};
|
||||
$row_data{tab} = $results->[$i]{'tab'};
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use C4::Output;
|
|||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
|
||||
|
||||
# retrieve parameters
|
||||
my $input = new CGI;
|
||||
|
|
@ -118,7 +118,6 @@ if ($op eq 'add_form') {
|
|||
my $authorised_value = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
-default => $data->{'authorised_value'},
|
||||
);
|
||||
|
|
@ -211,13 +210,13 @@ if ($op eq 'add_form') {
|
|||
}
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$searchfield,$authtypecode);
|
||||
my $toggle=1;
|
||||
my $toggle="white";
|
||||
my @loop_data = ();
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
if ($toggle eq 1){
|
||||
$toggle=0;
|
||||
if ($toggle eq 'white'){
|
||||
$toggle="#ffffcc";
|
||||
} else {
|
||||
$toggle=1;
|
||||
$toggle="white";
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tagfield} = $results->[$i]{'tagfield'};
|
||||
|
|
@ -228,7 +227,7 @@ if ($op eq 'add_form') {
|
|||
$row_data{subfield_link} ="auth_subfields_structure.pl?tagfield=".$results->[$i]{'tagfield'}."&authtypecode=".$authtypecode;
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'tagfield'}."&authtypecode=".$authtypecode;
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}."&authtypecode=".$authtypecode;
|
||||
$row_data{toggle} = $toggle;
|
||||
$row_data{bgcolor} = $toggle;
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data,
|
||||
|
|
@ -251,12 +250,7 @@ if ($op eq 'add_form') {
|
|||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
|
||||
$template->param(loggeninuser => $loggedinuser,
|
||||
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
$template->param(loggeninuser => $loggedinuser);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ use C4::Context;
|
|||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
use HTML::Template;
|
||||
use C4::Context;
|
||||
|
||||
|
||||
|
|
@ -126,6 +125,7 @@ if ($op eq 'add_form') {
|
|||
$sth->execute($id);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
||||
$template->param(searchfield => $searchfield,
|
||||
Tvalue => $data->{'authorised_value'},
|
||||
id =>$id,
|
||||
|
|
@ -139,6 +139,7 @@ if ($op eq 'add_form') {
|
|||
my $sth=$dbh->prepare("delete from authorised_values where id=?");
|
||||
$sth->execute($id);
|
||||
$sth->finish;
|
||||
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=$searchfield\"></html>";
|
||||
exit;
|
||||
|
||||
|
|
@ -157,7 +158,6 @@ if ($op eq 'add_form') {
|
|||
-values=> \@category_list,
|
||||
-default=>"",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
if (!$searchfield) {
|
||||
|
|
@ -203,8 +203,5 @@ if ($op eq 'add_form') {
|
|||
);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ use C4::Output;
|
|||
use C4::Search;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
use HTML::Template;
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
|
|
@ -84,7 +83,7 @@ if ($op eq 'add_form') {
|
|||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
warn "=> $data->{'authtypetext'} : ".$data->{'summary'};
|
||||
# warn "=> $data->{'authtypetext'} : ".$data->{'summary'};
|
||||
$template->param(authtypecode => $authtypecode,
|
||||
authtypetext => $data->{'authtypetext'},
|
||||
auth_tag_to_report => $data->{'auth_tag_to_report'},
|
||||
|
|
@ -171,10 +170,6 @@ if ($op eq 'add_form') {
|
|||
$template->param(next => "$script_name?offset=".$nextpage);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
# Local Variables:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use C4::Output;
|
|||
use C4::Search;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
use HTML::Template;
|
||||
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
|
|
@ -36,7 +36,7 @@ sub StringSearch {
|
|||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("Select * from biblio_framework where (frameworkcode like ?) order by frameworktext");
|
||||
my $sth=$dbh->prepare("Select * from biblios_framework where (frameworkcode like ?) order by frameworktext");
|
||||
$sth->execute("$data[0]%");
|
||||
my @results;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
|
|
@ -50,13 +50,13 @@ sub StringSearch {
|
|||
my $input = new CGI;
|
||||
my $searchfield=$input->param('frameworkcode');
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/biblio_framework.pl";
|
||||
my $script_name="/cgi-bin/koha/admin/biblios_framework.pl";
|
||||
my $frameworkcode=$input->param('frameworkcode');
|
||||
my $pagesize=20;
|
||||
my $op = $input->param('op');
|
||||
$searchfield=~ s/\,//g;
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "admin/biblio_framework.tmpl",
|
||||
= get_template_and_user({template_name => "admin/biblios_framework.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
|
|
@ -83,7 +83,7 @@ if ($op eq 'add_form') {
|
|||
my $data;
|
||||
if ($frameworkcode) {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select * from biblio_framework where frameworkcode=?");
|
||||
my $sth=$dbh->prepare("select * from biblios_framework where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
|
@ -97,10 +97,10 @@ if ($op eq 'add_form') {
|
|||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("replace biblio_framework (frameworkcode,frameworktext) values (?,?)");
|
||||
my $sth=$dbh->prepare("replace biblios_framework (frameworkcode,frameworktext) values (?,?)");
|
||||
$sth->execute($input->param('frameworkcode'),$input->param('frameworktext'));
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=biblio_framework.pl\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=biblios_framework.pl\"></html>";
|
||||
exit;
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
|
|
@ -111,14 +111,14 @@ if ($op eq 'add_form') {
|
|||
|
||||
# Check both categoryitem and biblioitems, see Bug 199
|
||||
my $total = 0;
|
||||
for my $table ('marc_tag_structure') {
|
||||
for my $table ('biblios_tag_structure') {
|
||||
my $sth=$dbh->prepare("select count(*) as total from $table where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$total += $sth->fetchrow_hashref->{total};
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
my $sth=$dbh->prepare("select * from biblio_framework where frameworkcode=?");
|
||||
my $sth=$dbh->prepare("select * from biblios_framework where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
|
@ -133,14 +133,14 @@ if ($op eq 'add_form') {
|
|||
#start the page and read in includes
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $frameworkcode=uc($input->param('frameworkcode'));
|
||||
my $sth=$dbh->prepare("delete from marc_tag_structure where frameworkcode=?");
|
||||
my $sth=$dbh->prepare("delete from biblios_tag_structure where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$sth=$dbh->prepare("delete from marc_subfield_structure where frameworkcode=?");
|
||||
$sth=$dbh->prepare("delete from biblios_subfield_structure where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$sth=$dbh->prepare("delete from biblio_framework where frameworkcode=?");
|
||||
$sth=$dbh->prepare("delete from biblios_framework where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=biblio_framework.pl\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=biblios_framework.pl\"></html>";
|
||||
exit;
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
################## DEFAULT ##################################
|
||||
|
|
@ -170,10 +170,6 @@ if ($op eq 'add_form') {
|
|||
$template->param(next => "$script_name?offset=".$nextpage);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
# Local Variables:
|
||||
168
admin/marc_subfields_structure.pl → admin/biblios_subfields_structure.pl
Executable file → Normal file
168
admin/marc_subfields_structure.pl → admin/biblios_subfields_structure.pl
Executable file → Normal file
|
|
@ -25,7 +25,6 @@ use C4::Auth;
|
|||
use CGI;
|
||||
use C4::Search;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$frameworkcode)=@_;
|
||||
|
|
@ -33,7 +32,7 @@ sub StringSearch {
|
|||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("Select * from marc_subfield_structure where (tagfield like ? and frameworkcode=?) order by tagfield");
|
||||
my $sth=$dbh->prepare("Select * from biblios_subfield_structure where (tagfield like ? and frameworkcode=?) order by tagfield");
|
||||
$sth->execute("$searchstring%",$frameworkcode);
|
||||
my @results;
|
||||
my $cnt=0;
|
||||
|
|
@ -54,10 +53,10 @@ my $tagsubfield=$input->param('tagsubfield');
|
|||
my $frameworkcode=$input->param('frameworkcode');
|
||||
my $pkfield="tagfield";
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/marc_subfields_structure.pl";
|
||||
my $script_name="/cgi-bin/koha/admin/biblios_subfields_structure.pl";
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "admin/marc_subfields_structure.tmpl",
|
||||
= get_template_and_user({template_name => "admin/biblios_subfields_structure.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
|
|
@ -86,33 +85,11 @@ if ($op eq 'add_form') {
|
|||
my $data;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $more_subfields = $input->param("more_subfields")+1;
|
||||
# builds kohafield tables
|
||||
my @kohafields;
|
||||
push @kohafields, "";
|
||||
my $sth2=$dbh->prepare("SHOW COLUMNS from biblio");
|
||||
$sth2->execute;
|
||||
while ((my $field) = $sth2->fetchrow_array) {
|
||||
push @kohafields, "biblio.".$field;
|
||||
}
|
||||
my $sth2=$dbh->prepare("SHOW COLUMNS from biblioitems");
|
||||
$sth2->execute;
|
||||
while ((my $field) = $sth2->fetchrow_array) {
|
||||
if ($field eq 'notes') { $field = 'bnotes'; }
|
||||
push @kohafields, "biblioitems.".$field;
|
||||
}
|
||||
my $sth2=$dbh->prepare("SHOW COLUMNS from items");
|
||||
$sth2->execute;
|
||||
while ((my $field) = $sth2->fetchrow_array) {
|
||||
push @kohafields, "items.".$field;
|
||||
}
|
||||
|
||||
# other subfields
|
||||
push @kohafields, "additionalauthors.author";
|
||||
push @kohafields, "bibliosubject.subject";
|
||||
push @kohafields, "bibliosubtitle.subtitle";
|
||||
|
||||
# build authorised value list
|
||||
$sth2->finish;
|
||||
$sth2 = $dbh->prepare("select distinct category from authorised_values");
|
||||
|
||||
my $sth2 = $dbh->prepare("select distinct category from authorised_values");
|
||||
$sth2->execute;
|
||||
my @authorised_values;
|
||||
push @authorised_values,"";
|
||||
|
|
@ -150,7 +127,7 @@ if ($op eq 'add_form') {
|
|||
closedir DIR;
|
||||
|
||||
# build values list
|
||||
my $sth=$dbh->prepare("select * from marc_subfield_structure where tagfield=? and frameworkcode=?"); # and tagsubfield='$tagsubfield'");
|
||||
my $sth=$dbh->prepare("select * from biblios_subfield_structure where tagfield=? and frameworkcode=?"); # and tagsubfield='$tagsubfield'");
|
||||
$sth->execute($tagfield,$frameworkcode);
|
||||
my @loop_data = ();
|
||||
my $toggle=1;
|
||||
|
|
@ -164,35 +141,54 @@ if ($op eq 'add_form') {
|
|||
}
|
||||
$row_data{tab} = CGI::scrolling_list(-name=>'tab',
|
||||
-id=>"tab$i",
|
||||
-values=>['-1','0','1','2','3','4','5','6','7','8','9','10'],
|
||||
-labels => {'-1' =>'ignore','0'=>'0','1'=>'1',
|
||||
'2' =>'2','3'=>'3','4'=>'4',
|
||||
-values=>['-1','0','1','2','3','4','5','6','7','8','9'],
|
||||
-labels => {'-1' =>'ignore','0'=>'0','1'=>'1','2' =>'2','3'=>'3','4'=>'4',
|
||||
'5' =>'5','6'=>'6','7'=>'7',
|
||||
'8' =>'8','9'=>'9','10'=>'items (10)',
|
||||
},
|
||||
'8' =>'8','9'=>'9',},
|
||||
-default=>$data->{'tab'},
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
|
||||
-id=>"ohidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-default=>substr($data->{'hidden'},0,1),
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
|
||||
-id=>"ihidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-default=>substr($data->{'hidden'},1,1),
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden',
|
||||
-id=>"ehidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-default=>substr($data->{'hidden'},2,1),
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{tagsubfield} =$data->{'tagsubfield'}."<input type=\"hidden\" name=\"tagsubfield\" value=\"".$data->{'tagsubfield'}."\" id=\"tagsubfield\">";
|
||||
$row_data{liblibrarian} = CGI::escapeHTML($data->{'liblibrarian'});
|
||||
$row_data{libopac} = CGI::escapeHTML($data->{'libopac'});
|
||||
$row_data{seealso} = CGI::escapeHTML($data->{'seealso'});
|
||||
$row_data{kohafield}= CGI::scrolling_list( -name=>"kohafield",
|
||||
-id=>"kohafield$i",
|
||||
-values=> \@kohafields,
|
||||
-default=> "$data->{'kohafield'}",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
|
||||
$row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-id=>'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-default=>$data->{'authorised_value'},
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{value_builder} = CGI::scrolling_list(-name=>'value_builder',
|
||||
|
|
@ -200,7 +196,6 @@ if ($op eq 'add_form') {
|
|||
-values=> \@value_builder,
|
||||
-default=>$data->{'value_builder'},
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{authtypes} = CGI::scrolling_list(-name=>'authtypecode',
|
||||
|
|
@ -208,19 +203,16 @@ if ($op eq 'add_form') {
|
|||
-values=> \@authtypes,
|
||||
-default=>$data->{'authtypecode'},
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{repeatable} = CGI::checkbox(-name=>"repeatable$i",
|
||||
-checked => $data->{'repeatable'}?'checked':'',
|
||||
-value => 1,
|
||||
-tabindex=>'',
|
||||
-label => '',
|
||||
-id => "repeatable$i");
|
||||
$row_data{mandatory} = CGI::checkbox(-name => "mandatory$i",
|
||||
-checked => $data->{'mandatory'}?'checked':'',
|
||||
-value => 1,
|
||||
-tabindex=>'',
|
||||
-label => '',
|
||||
-id => "mandatory$i");
|
||||
$row_data{hidden} = CGI::escapeHTML($data->{hidden});
|
||||
|
|
@ -228,7 +220,6 @@ if ($op eq 'add_form') {
|
|||
-id => "isurl$i",
|
||||
-checked => $data->{'isurl'}?'checked':'',
|
||||
-value => 1,
|
||||
-tabindex=>'',
|
||||
-label => '');
|
||||
$row_data{row} = $i;
|
||||
$row_data{toggle} = $toggle;
|
||||
|
|
@ -241,60 +232,74 @@ if ($op eq 'add_form') {
|
|||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tab} = CGI::scrolling_list(-name=>'tab',
|
||||
-id => "tab$i",
|
||||
-values=>['-1','0','1','2','3','4','5','6','7','8','9','10'],
|
||||
-values=>['-1','0','1','2','3','4','5','6','7','8','9'],
|
||||
-labels => {'-1' =>'ignore','0'=>'0','1'=>'1',
|
||||
'2' =>'2','3'=>'3','4'=>'4',
|
||||
'5' =>'5','6'=>'6','7'=>'7',
|
||||
'8' =>'8','9'=>'9','10'=>'items (10)',
|
||||
'8' =>'8','9'=>'9',
|
||||
},
|
||||
-default=>"",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
|
||||
-id=>"ohidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
|
||||
$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
|
||||
-id=>"ihidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden',
|
||||
-id=>"ehidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{tagsubfield} = "<input type=\"text\" name=\"tagsubfield\" value=\"".$data->{'tagsubfield'}."\" size=\"1\" id=\"tagsubfield\" maxlength=\"1\">";
|
||||
$row_data{liblibrarian} = "";
|
||||
$row_data{libopac} = "";
|
||||
$row_data{seealso} = "";
|
||||
$row_data{hidden} = "";
|
||||
$row_data{hidden} = "000";
|
||||
$row_data{repeatable} = CGI::checkbox( -name=> 'repeatable',
|
||||
-id => "repeatable$i",
|
||||
-checked => '',
|
||||
-value => 1,
|
||||
-tabindex=>'',
|
||||
-label => '');
|
||||
$row_data{mandatory} = CGI::checkbox( -name=> 'mandatory',
|
||||
-id => "mandatory$i",
|
||||
-checked => '',
|
||||
-value => 1,
|
||||
-tabindex=>'',
|
||||
-label => '');
|
||||
$row_data{isurl} = CGI::checkbox(-name => 'isurl',
|
||||
-id => "isurl$i",
|
||||
-checked => '',
|
||||
-value => 1,
|
||||
-tabindex=>'',
|
||||
-label => '');
|
||||
$row_data{kohafield}= CGI::scrolling_list( -name=>'kohafield',
|
||||
-id => "kohafield$i",
|
||||
-values=> \@kohafields,
|
||||
-default=> "",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
|
||||
$row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-id => 'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{authtypes} = CGI::scrolling_list(-name=>'authtypecode',
|
||||
-id => 'authtypecode',
|
||||
-values=> \@authtypes,
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{link} = CGI::escapeHTML($data->{'link'});
|
||||
|
|
@ -316,15 +321,19 @@ if ($op eq 'add_form') {
|
|||
} elsif ($op eq 'add_validate') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
$template->param(tagfield => "$input->param('tagfield')");
|
||||
my $sth=$dbh->prepare("replace marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
my $sth=$dbh->prepare("replace biblios_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
my @tagsubfield = $input->param('tagsubfield');
|
||||
my @liblibrarian = $input->param('liblibrarian');
|
||||
my @libopac = $input->param('libopac');
|
||||
my @kohafield = $input->param('kohafield');
|
||||
|
||||
my @tab = $input->param('tab');
|
||||
my @seealso = $input->param('seealso');
|
||||
my @hidden = $input->param('hidden');
|
||||
# my @hidden = $input->param('hidden');
|
||||
my @hidden;
|
||||
my @ohidden = $input->param('ohidden');
|
||||
my @ihidden = $input->param('ihidden');
|
||||
my @ehidden = $input->param('ehidden');
|
||||
my @authorised_values = $input->param('authorised_value');
|
||||
my @authtypecodes = $input->param('authtypecode');
|
||||
my @value_builder =$input->param('value_builder');
|
||||
|
|
@ -337,13 +346,13 @@ if ($op eq 'add_form') {
|
|||
my $libopac =$libopac[$i];
|
||||
my $repeatable =$input->param("repeatable$i")?1:0;
|
||||
my $mandatory =$input->param("mandatory$i")?1:0;
|
||||
my $kohafield =$kohafield[$i];
|
||||
|
||||
my $tab =$tab[$i];
|
||||
my $seealso =$seealso[$i];
|
||||
my $authorised_value =$authorised_values[$i];
|
||||
my $authtypecode =$authtypecodes[$i];
|
||||
my $value_builder=$value_builder[$i];
|
||||
my $hidden = $hidden[$i]; #input->param("hidden$i");
|
||||
my $hidden = $ohidden[$i].$ihidden[$i].$ehidden[$i]; #collate from 3 hiddens;
|
||||
my $isurl = $input->param("isurl$i")?1:0;
|
||||
my $link = $link[$i];
|
||||
if ($liblibrarian) {
|
||||
|
|
@ -354,7 +363,7 @@ if ($op eq 'add_form') {
|
|||
$libopac,
|
||||
$repeatable,
|
||||
$mandatory,
|
||||
$kohafield,
|
||||
|
||||
$tab,
|
||||
$seealso,
|
||||
$authorised_value,
|
||||
|
|
@ -370,7 +379,7 @@ if ($op eq 'add_form') {
|
|||
}
|
||||
}
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=biblios_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
exit;
|
||||
|
||||
# END $OP eq ADD_VALIDATE
|
||||
|
|
@ -378,7 +387,7 @@ if ($op eq 'add_form') {
|
|||
# called by default form, used to confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirm') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select * from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
|
||||
my $sth=$dbh->prepare("select * from biblios_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
|
||||
#FIXME : called with 2 bind variables when 3 are needed
|
||||
$sth->execute($tagfield,$tagsubfield);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
|
|
@ -396,11 +405,11 @@ if ($op eq 'add_form') {
|
|||
} elsif ($op eq 'delete_confirmed') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
my $sth=$dbh->prepare("delete from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
|
||||
my $sth=$dbh->prepare("delete from biblios_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
|
||||
$sth->execute($tagfield,$tagsubfield,$frameworkcode);
|
||||
$sth->finish;
|
||||
}
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=biblios_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
exit;
|
||||
$template->param(tagfield => $tagfield);
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
|
|
@ -420,7 +429,6 @@ if ($op eq 'add_form') {
|
|||
$row_data{tagfield} = $results->[$i]{'tagfield'};
|
||||
$row_data{tagsubfield} = $results->[$i]{'tagsubfield'};
|
||||
$row_data{liblibrarian} = $results->[$i]{'liblibrarian'};
|
||||
$row_data{kohafield} = $results->[$i]{'kohafield'};
|
||||
$row_data{repeatable} = $results->[$i]{'repeatable'};
|
||||
$row_data{mandatory} = $results->[$i]{'mandatory'};
|
||||
$row_data{tab} = $results->[$i]{'tab'};
|
||||
|
|
@ -428,7 +436,7 @@ if ($op eq 'add_form') {
|
|||
$row_data{authorised_value} = $results->[$i]{'authorised_value'};
|
||||
$row_data{authtypecode} = $results->[$i]{'authtypecode'};
|
||||
$row_data{value_builder} = $results->[$i]{'value_builder'};
|
||||
$row_data{hidden} = $results->[$i]{'hidden'};
|
||||
$row_data{hidden} = $results->[$i]{'hidden'} if($results->[$i]{'hidden'} gt "000") ;
|
||||
$row_data{isurl} = $results->[$i]{'isurl'};
|
||||
$row_data{link} = $results->[$i]{'link'};
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}."&frameworkcode=$frameworkcode";
|
||||
|
|
@ -0,0 +1,397 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
use C4::Auth;
|
||||
use C4::Koha;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
|
||||
|
||||
# retrieve parameters
|
||||
my $input = new CGI;
|
||||
my $frameworkcode = $input->param('frameworkcode'); # set to select framework
|
||||
$frameworkcode="" unless $frameworkcode;
|
||||
my $existingframeworkcode = $input->param('existingframeworkcode'); # set when we have to create a new framework (in frameworkcode) by copying an old one (in existingframeworkcode)
|
||||
$existingframeworkcode = "" unless $existingframeworkcode;
|
||||
my $frameworkinfo = getframeworkinfo($frameworkcode);
|
||||
my $searchfield=$input->param('searchfield');
|
||||
$searchfield=0 unless $searchfield;
|
||||
$searchfield=~ s/\,//g;
|
||||
|
||||
my $offset=$input->param('offset');
|
||||
my $op = $input->param('op');
|
||||
my $dspchoice = $input->param('select_display');
|
||||
my $pagesize=20;
|
||||
|
||||
my $script_name="/cgi-bin/koha/admin/bibliostagstructure.pl";
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
# open template
|
||||
my ($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "admin/bibliostagstructure.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
# get framework list
|
||||
my $frameworks = getframeworks();
|
||||
my @frameworkloop;
|
||||
foreach my $thisframeworkcode (keys %$frameworks) {
|
||||
my $selected = 1 if $thisframeworkcode eq $frameworkcode;
|
||||
my %row =(value => $thisframeworkcode,
|
||||
selected => $selected,
|
||||
frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
|
||||
);
|
||||
push @frameworkloop, \%row;
|
||||
}
|
||||
|
||||
# check that framework is defined in biblios_tag_structure
|
||||
my $sth=$dbh->prepare("select count(*) from biblios_tag_structure where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
my ($frameworkexist) = $sth->fetchrow;
|
||||
if ($frameworkexist) {
|
||||
} else {
|
||||
# if frameworkcode does not exists, then OP must be changed to "create framework" if we are not on the way to create it
|
||||
# (op = itemtyp_create_confirm)
|
||||
if ($op eq "framework_create_confirm") {
|
||||
duplicate_framework($frameworkcode, $existingframeworkcode);
|
||||
$op=""; # unset $op to go back to framework list
|
||||
} else {
|
||||
$op = "framework_create";
|
||||
}
|
||||
}
|
||||
$template->param(frameworkloop => \@frameworkloop,
|
||||
frameworkcode => $frameworkcode,
|
||||
frameworktext => $frameworkinfo->{frameworktext});
|
||||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
|
||||
################## ADD_FORM ##################################
|
||||
# called by default. Used to create form to add or modify a record
|
||||
if ($op eq 'add_form') {
|
||||
#---- if primkey exists, it's a modify action, so read values to modify...
|
||||
my $data;
|
||||
if ($searchfield) {
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from biblios_tag_structure where tagfield=? and frameworkcode=?");
|
||||
$sth->execute($searchfield,$frameworkcode);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
my $sth = $dbh->prepare("select distinct category from authorised_values");
|
||||
$sth->execute;
|
||||
my @authorised_values;
|
||||
push @authorised_values,"";
|
||||
while ((my $category) = $sth->fetchrow_array) {
|
||||
push @authorised_values, $category;
|
||||
}
|
||||
my $authorised_value = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-id=>"authorised_value",
|
||||
-multiple=>0,
|
||||
-default => $data->{'authorised_value'},
|
||||
);
|
||||
|
||||
if ($searchfield) {
|
||||
$template->param(action => "Modify tag",
|
||||
searchfield => "<input type=\"hidden\" name=\"tagfield\" value=\"$searchfield\" />$searchfield");
|
||||
$template->param('heading-modify-tag-p' => 1);
|
||||
} else {
|
||||
$template->param(action => "Add tag",
|
||||
searchfield => "<input type=\"text\" name=\"tagfield\" size=\"5\" maxlength=\"3\" />");
|
||||
$template->param('heading-add-tag-p' => 1);
|
||||
}
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
$template->param(liblibrarian => $data->{'liblibrarian'},
|
||||
libopac => $data->{'libopac'},
|
||||
repeatable => CGI::checkbox(-name=>'repeatable',
|
||||
-checked=> $data->{'repeatable'}?'checked':'',
|
||||
-value=> 1,
|
||||
-label => '',
|
||||
-id=> 'repeatable'),
|
||||
mandatory => CGI::checkbox(-name => 'mandatory',
|
||||
-checked => $data->{'mandatory'}?'checked':'',
|
||||
-value => 1,
|
||||
-label => '',
|
||||
-id => 'mandatory'),
|
||||
authorised_value => $authorised_value,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
$sth=$dbh->prepare("replace biblios_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)");
|
||||
my $tagfield =$input->param('tagfield');
|
||||
my $liblibrarian = $input->param('liblibrarian');
|
||||
my $libopac =$input->param('libopac');
|
||||
my $repeatable =$input->param('repeatable');
|
||||
my $mandatory =$input->param('mandatory');
|
||||
my $authorised_value =$input->param('authorised_value');
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
$sth->execute($tagfield,
|
||||
$liblibrarian,
|
||||
$libopac,
|
||||
$repeatable?1:0,
|
||||
$mandatory?1:0,
|
||||
$authorised_value,
|
||||
$frameworkcode
|
||||
);
|
||||
}
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=bibliostagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
exit;
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
# called by default form, used to confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirm') {
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from biblios_tag_structure where tagfield=? and frameworkcode=?");
|
||||
$sth->execute($searchfield,$frameworkcode);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
$template->param(liblibrarian => $data->{'liblibrarian'},
|
||||
searchfield => $searchfield,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
################## DELETE_CONFIRMED ##################################
|
||||
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirmed') {
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
$dbh->do("delete from biblios_tag_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
|
||||
$dbh->do("delete from biblios_subfield_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
|
||||
|
||||
}
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
################## ITEMTYPE_CREATE ##################################
|
||||
# called automatically if an unexisting frameworkis selected
|
||||
} elsif ($op eq 'framework_create') {
|
||||
$sth = $dbh->prepare("select count(*),biblios_tag_structure.frameworkcode,frameworktext from biblios_tag_structure,biblios_framework where biblios_framework.frameworkcode=biblios_tag_structure.frameworkcode group by biblios_tag_structure.frameworkcode");
|
||||
$sth->execute;
|
||||
my @existingframeworkloop;
|
||||
while (my ($tot,$thisframeworkcode,$frameworktext) = $sth->fetchrow) {
|
||||
if ($tot>0) {
|
||||
my %line = ( value => $thisframeworkcode,
|
||||
frameworktext => $frameworktext,
|
||||
);
|
||||
push @existingframeworkloop,\%line;
|
||||
}
|
||||
}
|
||||
$template->param(existingframeworkloop => \@existingframeworkloop,
|
||||
frameworkcode => $frameworkcode,
|
||||
# FRtext => $frameworkinfo->{frameworktext},
|
||||
);
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
# here, $op can be unset or set to "framework_create_confirm".
|
||||
if ($searchfield ne '') {
|
||||
$template->param(searchfield => $searchfield);
|
||||
}
|
||||
my $cnt=0;
|
||||
if ($dspchoice) {
|
||||
#here, user only wants used tags/subfields displayed
|
||||
my $env;
|
||||
$searchfield=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchfield);
|
||||
my $sth=$dbh->prepare("Select biblios_tag_structure.tagfield as mts_tagfield,biblios_tag_structure.liblibrarian as mts_liblibrarian,biblios_tag_structure.libopac as mts_libopac,biblios_tag_structure.repeatable as mts_repeatable,biblios_tag_structure.mandatory as mts_mandatory,biblios_tag_structure.authorised_value as mts_authorized_value,biblios_subfield_structure.* from biblios_tag_structure LEFT JOIN biblios_subfield_structure ON (biblios_tag_structure.tagfield=biblios_subfield_structure.tagfield AND biblios_tag_structure.frameworkcode=biblios_subfield_structure.frameworkcode) where (biblios_tag_structure.tagfield >= ? and biblios_tag_structure.frameworkcode=?) AND biblios_subfield_structure.tab>=0 order by biblios_tag_structure.tagfield,biblios_subfield_structure.tagsubfield");
|
||||
#could be ordoned by tab
|
||||
$sth->execute($data[0], $frameworkcode);
|
||||
my @results = ();
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
$cnt++;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
my $toggle=0;
|
||||
my @loop_data = ();
|
||||
my $j=1;
|
||||
my $i=$offset;
|
||||
while ($i < ($offset+$pagesize<$cnt?$offset+$pagesize:$cnt)) {
|
||||
if ($toggle eq 0){
|
||||
$toggle=1;
|
||||
} else {
|
||||
$toggle=0;
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tagfield} = $results[$i]->{'mts_tagfield'};
|
||||
$row_data{liblibrarian} = $results[$i]->{'mts_liblibrarian'};
|
||||
$row_data{repeatable} = $results[$i]->{'mts_repeatable'};
|
||||
$row_data{mandatory} = $results[$i]->{'mts_mandatory'};
|
||||
$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
|
||||
$row_data{subfield_link} ="biblios_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{toggle} = $toggle;
|
||||
$j=$i;
|
||||
my @internal_loop = ();
|
||||
while (($results[$i]->{'tagfield'}==$results[$j]->{'tagfield'}) and ($j< ($offset+$pagesize<$cnt?$offset+$pagesize:$cnt))) {
|
||||
if ($toggle eq 0) {
|
||||
$toggle=1;
|
||||
} else {
|
||||
$toggle=0;
|
||||
}
|
||||
my %subfield_data;
|
||||
$subfield_data{tagsubfield} = $results[$j]->{'tagsubfield'};
|
||||
$subfield_data{liblibrarian} = $results[$j]->{'liblibrarian'};
|
||||
$subfield_data{repeatable} = $results[$j]->{'repeatable'};
|
||||
$subfield_data{mandatory} = $results[$j]->{'mandatory'};
|
||||
$subfield_data{tab} = $results[$j]->{'tab'};
|
||||
$subfield_data{seealso} = $results[$j]->{'seealso'};
|
||||
$subfield_data{authorised_value} = $results[$j]->{'authorised_value'};
|
||||
$subfield_data{authtypecode}= $results[$j]->{'authtypecode'};
|
||||
$subfield_data{value_builder}= $results[$j]->{'value_builder'};
|
||||
$subfield_data{toggle} = $toggle;
|
||||
# warn "tagfield : ".$results[$j]->{'tagfield'}." tagsubfield :".$results[$j]->{'tagsubfield'};
|
||||
push @internal_loop,\%subfield_data;
|
||||
$j++;
|
||||
}
|
||||
$row_data{'subfields'}=\@internal_loop;
|
||||
push(@loop_data, \%row_data);
|
||||
# undef @internal_loop;
|
||||
$i=$j;
|
||||
}
|
||||
$template->param(select_display => "True",
|
||||
loop => \@loop_data);
|
||||
# $sth->execute;
|
||||
$sth->finish;
|
||||
} else {
|
||||
#here, normal old style : display every tags
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$searchfield,$frameworkcode);
|
||||
$cnt = $count;
|
||||
my $toggle=0;
|
||||
my @loop_data = ();
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
if ($toggle eq 0){
|
||||
$toggle=1;
|
||||
} else {
|
||||
$toggle=0;
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tagfield} = $results->[$i]{'tagfield'};
|
||||
$row_data{liblibrarian} = $results->[$i]{'liblibrarian'};
|
||||
$row_data{repeatable} = $results->[$i]{'repeatable'};
|
||||
$row_data{mandatory} = $results->[$i]{'mandatory'};
|
||||
$row_data{authorised_value} = $results->[$i]{'authorised_value'};
|
||||
$row_data{subfield_link} ="biblios_subfields_structure.pl?tagfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{toggle} = $toggle;
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data);
|
||||
}
|
||||
if ($offset>0) {
|
||||
my $prevpage = $offset-$pagesize;
|
||||
$template->param(isprevpage => $offset,
|
||||
prevpage=> $prevpage,
|
||||
searchfield => $searchfield,
|
||||
script_name => $script_name,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
}
|
||||
if ($offset+$pagesize<$cnt) {
|
||||
my $nextpage =$offset+$pagesize;
|
||||
$template->param(nextpage =>$nextpage,
|
||||
searchfield => $searchfield,
|
||||
script_name => $script_name,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
|
||||
$template->param(loggeninuser => $loggedinuser,
|
||||
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
||||
#
|
||||
# the sub used for searches
|
||||
#
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$frameworkcode)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from biblios_tag_structure where (tagfield >= ? and frameworkcode=?) order by tagfield");
|
||||
$sth->execute($data[0], $frameworkcode);
|
||||
my @results;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
}
|
||||
# $sth->execute;
|
||||
$sth->finish;
|
||||
return (scalar(@results),\@results);
|
||||
}
|
||||
|
||||
#
|
||||
# the sub used to duplicate a framework from an existing one in MARC parameters tables.
|
||||
#
|
||||
sub duplicate_framework {
|
||||
my ($newframeworkcode,$oldframeworkcode) = @_;
|
||||
my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from biblios_tag_structure where frameworkcode=?");
|
||||
$sth->execute($oldframeworkcode);
|
||||
my $sth_insert = $dbh->prepare("insert into biblios_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) values (?,?,?,?,?,?,?)");
|
||||
while ( my ($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value) = $sth->fetchrow) {
|
||||
$sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode);
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,authtypecode,value_builder,seealso from biblios_subfield_structure where frameworkcode=?");
|
||||
$sth->execute($oldframeworkcode);
|
||||
$sth_insert = $dbh->prepare("insert into biblios_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,authtypecode,value_builder,seealso) values (?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso) = $sth->fetchrow) {
|
||||
$sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso);
|
||||
}
|
||||
|
||||
## now the same for holdings
|
||||
$sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from holdings_tag_structure where frameworkcode=?");
|
||||
$sth->execute($oldframeworkcode);
|
||||
my $sth_insert = $dbh->prepare("insert into holdings_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) values (?,?,?,?,?,?,?)");
|
||||
while ( my ($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value) = $sth->fetchrow) {
|
||||
$sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode);
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,authtypecode,value_builder,seealso from holdings_subfield_structure where frameworkcode=?");
|
||||
$sth->execute($oldframeworkcode);
|
||||
$sth_insert = $dbh->prepare("insert into holdings_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,authtypecode,value_builder,seealso) values (?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso) = $sth->fetchrow) {
|
||||
$sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,8 +50,6 @@ use C4::Auth;
|
|||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use HTML::Template;
|
||||
use C4::Koha;
|
||||
|
||||
# Fixed variables
|
||||
my $linecolor1='#ffffcc';
|
||||
|
|
@ -89,24 +87,25 @@ if ($op eq 'add') {
|
|||
# If the user has pressed the "add new branch" button.
|
||||
heading("Branches: Add Branch");
|
||||
$template->param('heading-branches-add-branch-p' => 1);
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
editbranchform();
|
||||
|
||||
} elsif ($op eq 'edit') {
|
||||
# if the user has pressed the "edit branch settings" button.
|
||||
heading("Branches: Edit Branch");
|
||||
$template->param('heading-branches-edit-branch-p' => 1);
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
$template->param(add => 1);
|
||||
editbranchform($branchcode);
|
||||
} elsif ($op eq 'add_validate') {
|
||||
# confirm settings change...
|
||||
my $params = $input->Vars;
|
||||
unless ($params->{'branchcode'} && $params->{'branchname'}) {
|
||||
$template->param(else => 1);
|
||||
default ("MESSAGE1");
|
||||
default ("Cannot change branch record: You must specify a Branchname and a Branchcode");
|
||||
} else {
|
||||
setbranchinfo($params);
|
||||
$template->param(else => 1);
|
||||
default ("MESSAGE2");
|
||||
default ("Branch record changed for branch: $params->{'branchname'}");
|
||||
}
|
||||
} elsif ($op eq 'delete') {
|
||||
# if the user has pressed the "delete branch" button.
|
||||
|
|
@ -123,21 +122,22 @@ if ($op eq 'add') {
|
|||
# actually delete branch and return to the main screen....
|
||||
deletebranch($branchcode);
|
||||
$template->param(else => 1);
|
||||
default("MESSAGE3");
|
||||
default("The branch \"$branchname\" ($branchcode) has been deleted.");
|
||||
} elsif ($op eq 'editcategory') {
|
||||
# If the user has pressed the "add new category" or "modify" buttons.
|
||||
heading("Branches: Edit Category");
|
||||
$template->param('heading-branches-edit-category-p' => 1);
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
editcatform($categorycode);
|
||||
} elsif ($op eq 'addcategory_validate') {
|
||||
# confirm settings change...
|
||||
my $params = $input->Vars;
|
||||
unless ($params->{'categorycode'} && $params->{'categoryname'}) {
|
||||
$template->param(else => 1);
|
||||
default ("MESSAGE4");
|
||||
default ("Cannot change branch record: You must specify a Branchname and a Branchcode");
|
||||
} else {
|
||||
setcategoryinfo($params);
|
||||
$template->param(else => 1);
|
||||
default ("MESSAGE5");
|
||||
default ("Category record changed for category $params->{'categoryname'}");
|
||||
}
|
||||
} elsif ($op eq 'delete_category') {
|
||||
# if the user has pressed the "delete branch" button.
|
||||
|
|
@ -153,7 +153,7 @@ if ($op eq 'add') {
|
|||
# actually delete branch and return to the main screen....
|
||||
deletecategory($categorycode);
|
||||
$template->param(else => 1);
|
||||
default("MESSAGE6");
|
||||
default("The category with code $categorycode has been deleted.");
|
||||
|
||||
} else {
|
||||
# if no operation has been set...
|
||||
|
|
@ -170,7 +170,8 @@ sub default {
|
|||
my ($message) = @_;
|
||||
heading("Branches");
|
||||
$template->param('heading-branches-p' => 1);
|
||||
$template->param("$message" => 1);
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
$template->param(message => $message);
|
||||
$template->param(action => $script_name);
|
||||
branchinfotable();
|
||||
}
|
||||
|
|
@ -183,52 +184,20 @@ sub heading {
|
|||
|
||||
sub editbranchform {
|
||||
# prepares the edit form...
|
||||
|
||||
# initiate the scrolling-list to select the printers
|
||||
my %env;
|
||||
my $printers=getprinters(\%env);
|
||||
my @printerloop;
|
||||
my $printercount=0;
|
||||
my $oldprinter;
|
||||
my $CGIprinter;
|
||||
my ($branchcode) = @_;
|
||||
my $data;
|
||||
|
||||
if ($branchcode) {
|
||||
$data = getbranchinfo($branchcode);
|
||||
$data = $data->[0];
|
||||
# get the old printer of the branch
|
||||
$oldprinter = $data->{'branchprinter'};
|
||||
# printer loop
|
||||
foreach my $thisprinter (keys %$printers) {
|
||||
my $selected = 1 if $oldprinter eq $printers->{$thisprinter}->{'printqueue'};
|
||||
my %row =(value => $thisprinter,
|
||||
selected => $selected,
|
||||
branchprinter => $printers->{$thisprinter}->{'printqueue'},
|
||||
);
|
||||
push @printerloop, \%row;
|
||||
}
|
||||
|
||||
$template->param(printerloop => \@printerloop );
|
||||
$template->param(branchcode => $data->{'branchcode'});
|
||||
$template->param(branch_name => $data->{'branchname'});
|
||||
$template->param(branchname => $data->{'branchname'});
|
||||
$template->param(branchaddress1 => $data->{'branchaddress1'});
|
||||
$template->param(branchaddress2 => $data->{'branchaddress2'});
|
||||
$template->param(branchaddress3 => $data->{'branchaddress3'});
|
||||
$template->param(branchphone => $data->{'branchphone'});
|
||||
$template->param(branchfax => $data->{'branchfax'});
|
||||
$template->param(branchemail => $data->{'branchemail'});
|
||||
$template->param(branchip => $data->{'branchip'});
|
||||
}
|
||||
else { #case of an add branch select printer
|
||||
foreach my $thisprinter (keys %$printers) {
|
||||
my %row =(value => $thisprinter,
|
||||
branchprinter => $printers->{$thisprinter}->{'printqueue'},
|
||||
);
|
||||
push @printerloop, \%row;
|
||||
}
|
||||
$template->param(printerloop => \@printerloop );
|
||||
}
|
||||
}
|
||||
|
||||
# make the checkboxs.....
|
||||
#
|
||||
|
|
@ -293,11 +262,10 @@ sub branchinfotable {
|
|||
} else {
|
||||
$branchinfo = getbranchinfo();
|
||||
}
|
||||
my $toggle;
|
||||
my $i;
|
||||
my $color;
|
||||
my @loop_data =();
|
||||
foreach my $branch (@$branchinfo) {
|
||||
($i % 2) ? ($toggle = 1) : ($toggle = 0);
|
||||
($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
|
||||
#
|
||||
# We export the following fields to the template. These are not
|
||||
# pre-composed as a single "address" field because the template
|
||||
|
|
@ -325,7 +293,7 @@ sub branchinfotable {
|
|||
# Handle address fields separately
|
||||
my $address_empty_p = 1;
|
||||
for my $field ('branchaddress1', 'branchaddress2', 'branchaddress3',
|
||||
'branchphone', 'branchfax', 'branchemail', 'branchip', 'branchprinter') {
|
||||
'branchphone', 'branchfax', 'branchemail') {
|
||||
$row{$field} = $branch->{$field};
|
||||
if ( $branch->{$field} ) {
|
||||
$address_empty_p = 0;
|
||||
|
|
@ -353,27 +321,21 @@ sub branchinfotable {
|
|||
# Handle all other fields
|
||||
$row{'branch_name'} = $branch->{'branchname'};
|
||||
$row{'branch_code'} = $branch->{'branchcode'};
|
||||
$row{'toggle'} = $toggle;
|
||||
$row{'color'} = $color;
|
||||
$row{'value'} = $branch->{'branchcode'};
|
||||
$row{'action'} = '/cgi-bin/koha/admin/branches.pl';
|
||||
|
||||
push @loop_data, { %row };
|
||||
$i++;
|
||||
}
|
||||
my @branchcategories =();
|
||||
my $catinfo = getcategoryinfo();
|
||||
my $toggle;
|
||||
my $i = 0;
|
||||
foreach my $cat (@$catinfo) {
|
||||
($i % 2) ? ($toggle = 1) : ($toggle = 0);
|
||||
push @branchcategories, {
|
||||
toggle => $toggle,
|
||||
categoryname => $cat->{'categoryname'},
|
||||
categorycode => $cat->{'categorycode'},
|
||||
codedescription => $cat->{'codedescription'},
|
||||
};
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$template->param(branches => \@loop_data,
|
||||
branchcategories => \@branchcategories);
|
||||
|
|
@ -456,11 +418,11 @@ sub setbranchinfo {
|
|||
# sets the data from the editbranch form, and writes to the database...
|
||||
my ($data) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("replace branches (branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail,branchip,branchprinter) values (?,?,?,?,?,?,?,?,?,?)");
|
||||
my $sth=$dbh->prepare("replace branches (branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail) values (?,?,?,?,?,?,?,?)");
|
||||
$sth->execute(uc($data->{'branchcode'}), $data->{'branchname'},
|
||||
$data->{'branchaddress1'}, $data->{'branchaddress2'},
|
||||
$data->{'branchaddress3'}, $data->{'branchphone'},
|
||||
$data->{'branchfax'}, $data->{'branchemail'}, $data->{'branchip'},$data->{'branchprinter'});
|
||||
$data->{'branchfax'}, $data->{'branchemail'});
|
||||
|
||||
$sth->finish;
|
||||
# sort out the categories....
|
||||
|
|
@ -538,7 +500,7 @@ sub checkdatabasefor {
|
|||
my $message;
|
||||
if ($total) {
|
||||
# FIXME: need to be replaced by an exported boolean parameter
|
||||
$message = "MESSAGE7";
|
||||
$message = "Branch cannot be deleted because there are $total items using that branch.";
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
|
@ -558,10 +520,7 @@ sub checkcategorycode {
|
|||
}
|
||||
return $message;
|
||||
}
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
# Local Variables:
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@
|
|||
|
||||
use strict;
|
||||
use CGI;
|
||||
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Search;
|
||||
use HTML::Template;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ sub StringSearch {
|
|||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("Select * from categories where (description like ?) order by category_type,description");
|
||||
my $sth=$dbh->prepare("Select * from categories where (description like ?)");
|
||||
$sth->execute("$data[0]%");
|
||||
my @results;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
|
|
@ -73,7 +73,7 @@ my ($template, $loggedinuser, $cookie)
|
|||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1, management => 1},
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
|
|
@ -92,35 +92,34 @@ if ($op eq 'add_form') {
|
|||
my $data;
|
||||
if ($categorycode) {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired,category_type from categories where categorycode=?");
|
||||
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired, canmakepublicshelves, addRequestToShelves, allowrenewsfromopac from categories where categorycode=?");
|
||||
$sth->execute($categorycode);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
$template->param(description => $data->{'description'},
|
||||
$template->param(description => $data->{'description'},
|
||||
enrolmentperiod => $data->{'enrolmentperiod'},
|
||||
upperagelimit => $data->{'upperagelimit'},
|
||||
dateofbirthrequired => $data->{'dateofbirthrequired'},
|
||||
enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'}),
|
||||
enrolmentfee => $data->{'enrolmentfee'},
|
||||
overduenoticerequired => $data->{'overduenoticerequired'},
|
||||
issuelimit => $data->{'issuelimit'},
|
||||
reservefee => sprintf("%.2f",$data->{'reservefee'}),
|
||||
category_type => $data->{'category_type'},
|
||||
"type_".$data->{'category_type'} => " SELECTED ",
|
||||
);
|
||||
reservefee => $data->{'reservefee'},
|
||||
canmakepublicshelves => $data->{'canmakepublicshelves'},
|
||||
addRequestToShelves => $data->{'addRequestToShelves'},
|
||||
allowrenewsfromopac => $data->{'allowrenewsfromopac'}
|
||||
);
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
$template->param(add_validate => 1);
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?)");
|
||||
$sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','overduenoticerequired','category_type'));
|
||||
my $sth=$dbh->prepare("replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,overduenoticerequired, issuelimit, canmakepublicshelves, addRequestToShelves , allowrenewsfromopac) values (?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','overduenoticerequired', 'issuelimit', 'canmakepublicshelves', 'addRequestToShelves', 'allowrenewsfromopac'));
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>";
|
||||
exit;
|
||||
|
||||
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
# called by default form, used to confirm deletion of data in DB
|
||||
|
|
@ -134,7 +133,7 @@ if ($op eq 'add_form') {
|
|||
$sth->finish;
|
||||
$template->param(total => $total->{'total'});
|
||||
|
||||
my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired,category_type from categories where categorycode=?");
|
||||
my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,overduenoticerequired, canmakepublicshelves, addRequestToShelves,allowrenewsfromopac from categories where categorycode=?");
|
||||
$sth2->execute($categorycode);
|
||||
my $data=$sth2->fetchrow_hashref;
|
||||
$sth2->finish;
|
||||
|
|
@ -146,12 +145,17 @@ if ($op eq 'add_form') {
|
|||
enrolmentperiod => $data->{'enrolmentperiod'},
|
||||
upperagelimit => $data->{'upperagelimit'},
|
||||
dateofbirthrequired => $data->{'dateofbirthrequired'},
|
||||
enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'}),
|
||||
enrolmentfee => $data->{'enrolmentfee'},
|
||||
overduenoticerequired => $data->{'overduenoticerequired'},
|
||||
issuelimit => $data->{'issuelimit'},
|
||||
reservefee => sprintf("%.2f",$data->{'reservefee'}),
|
||||
category_type => $data->{'category_type'}
|
||||
);
|
||||
reservefee => $data->{'reservefee'},
|
||||
canmakepublicshelves => $data->{'canmakepublicshelves'},
|
||||
addRequestToShelves => $data->{'addRequestToShelves'},
|
||||
allowrenewsfromopac => $data->{'allowrenewsfromopac'},
|
||||
|
||||
);
|
||||
|
||||
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
################## DELETE_CONFIRMED ##################################
|
||||
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
||||
|
|
@ -162,9 +166,6 @@ if ($op eq 'add_form') {
|
|||
my $sth=$dbh->prepare("delete from categories where categorycode=?");
|
||||
$sth->execute($categorycode);
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>";
|
||||
exit;
|
||||
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
} else { # DEFAULT
|
||||
$template->param(else => 1);
|
||||
|
|
@ -178,30 +179,25 @@ if ($op eq 'add_form') {
|
|||
enrolmentperiod => $results->[$i]{'enrolmentperiod'},
|
||||
upperagelimit => $results->[$i]{'upperagelimit'},
|
||||
dateofbirthrequired => $results->[$i]{'dateofbirthrequired'},
|
||||
enrolmentfee => sprintf("%.2f",$results->[$i]{'enrolmentfee'}),
|
||||
enrolmentfee => $results->[$i]{'enrolmentfee'},
|
||||
overduenoticerequired => $results->[$i]{'overduenoticerequired'},
|
||||
issuelimit => $results->[$i]{'issuelimit'},
|
||||
reservefee => sprintf("%.2f",$results->[$i]{'reservefee'}),
|
||||
category_type => $results->[$i]{'category_type'},
|
||||
reservefee => $results->[$i]{'reservefee'},
|
||||
canmakepublicshelves => $results->[$i]{'canmakepublicshelves'},
|
||||
addRequestToShelves => $results->[$i]{'addRequestToShelves'},
|
||||
allowrenewsfromopac => $results->[$i]{'allowrenewsfromopac'},
|
||||
toggle => $toggle );
|
||||
push @loop, \%row;
|
||||
if ( $toggle eq 0 )
|
||||
{
|
||||
$toggle = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$toggle = 0;
|
||||
}
|
||||
$toggle = not $toggle;
|
||||
}
|
||||
$template->param(loop => \@loop);
|
||||
# check that I (institution) and C (child) exists. otherwise => warning to the user
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select category_type from categories where category_type='C'");
|
||||
my $sth=$dbh->prepare("select categorycode from categories where categorycode='C'");
|
||||
$sth->execute;
|
||||
my ($categoryChild) = $sth->fetchrow;
|
||||
$template->param(categoryChild => $categoryChild);
|
||||
$sth=$dbh->prepare("select category_type from categories where category_type='I'");
|
||||
$sth=$dbh->prepare("select categorycode from categories where categorycode='I'");
|
||||
$sth->execute;
|
||||
my ($categoryInstitution) = $sth->fetchrow;
|
||||
$template->param(categoryInstitution => $categoryInstitution);
|
||||
|
|
@ -211,9 +207,6 @@ if ($op eq 'add_form') {
|
|||
} #---- END $OP eq DEFAULT
|
||||
|
||||
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@
|
|||
|
||||
use strict;
|
||||
use CGI;
|
||||
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Search;
|
||||
use HTML::Template;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
|
||||
|
|
@ -193,10 +193,7 @@ if ($op eq 'add_form') {
|
|||
|
||||
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ use CGI;
|
|||
use C4::Search;
|
||||
use C4::Context;
|
||||
use C4::Biblio;
|
||||
use HTML::Template;
|
||||
|
||||
my $input = new CGI;
|
||||
|
||||
|
|
@ -41,111 +40,81 @@ my ($template, $borrowernumber, $cookie)
|
|||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $total;
|
||||
# checks itemnum field
|
||||
my $sth = $dbh->prepare("select tab from marc_subfield_structure where kohafield=\"items.itemnumber\"");
|
||||
# checks itemnumber field
|
||||
my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"itemnumber\"");
|
||||
$sth->execute;
|
||||
my ($res) = $sth->fetchrow;
|
||||
if ($res==-1) {
|
||||
$template->param(itemnum => 0);
|
||||
} else {
|
||||
$template->param(itemnum => 1);
|
||||
unless ($res) {
|
||||
$template->param(itemnumber => 1);
|
||||
$total++;
|
||||
}
|
||||
|
||||
# checks biblio.biblionumber and biblioitem.biblioitemnumber (same tag and tab=-1)
|
||||
$sth = $dbh->prepare("select tagfield,tab from marc_subfield_structure where kohafield=\"biblio.biblionumber\"");
|
||||
#check biblionumber
|
||||
my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"biblionumber\"");
|
||||
$sth->execute;
|
||||
my $tab;
|
||||
($res,$tab) = $sth->fetchrow;
|
||||
$sth = $dbh->prepare("select tagfield,tab from marc_subfield_structure where kohafield=\"biblioitems.biblioitemnumber\"");
|
||||
$sth->execute;
|
||||
my ($res2,$tab2) = $sth->fetchrow;
|
||||
if ($res && $res2 && ($res eq $res2) && $tab==-1 && $tab2==-1) {
|
||||
$template->param(biblionumber => 0);
|
||||
} else {
|
||||
my ($res) = $sth->fetchrow;
|
||||
if ($res ){
|
||||
($res) = $sth->fetchrow;
|
||||
unless ($res){
|
||||
$template->param(biblionumber => 1);
|
||||
$total++;
|
||||
}
|
||||
|
||||
# checks all item fields are in the same tag and in tab 10
|
||||
|
||||
$sth = $dbh->prepare("select tagfield,tab,kohafield from marc_subfield_structure where kohafield like \"items.%\"");
|
||||
$sth->execute;
|
||||
my $field;
|
||||
($res,$res2,$field) = $sth->fetchrow;
|
||||
my $tagfield = $res;
|
||||
my $tab = $res2;
|
||||
my $subtotal=0;
|
||||
warn "TAGF : $tagfield";
|
||||
while (($res,$res2,$field) = $sth->fetchrow) {
|
||||
# (ignore itemnumber, that must be in -1 tab)
|
||||
if (($res ne $tagfield or $res2 ne $tab ) && $res2 ne -1) {
|
||||
$subtotal++;
|
||||
}
|
||||
}
|
||||
$sth = $dbh->prepare("select kohafield from marc_subfield_structure where tagfield=?");
|
||||
$sth->execute($tagfield);
|
||||
while (($res2) = $sth->fetchrow) {
|
||||
if (!$res2 || $res2 =~ /^items/) {
|
||||
} else {
|
||||
$subtotal++;
|
||||
}
|
||||
}
|
||||
if ($subtotal eq 0) {
|
||||
$template->param(itemfields => 0);
|
||||
} else {
|
||||
$template->param(itemfields => 1);
|
||||
#check barcode
|
||||
my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"barcode\"");
|
||||
$sth->execute;
|
||||
my ($res) = $sth->fetchrow;
|
||||
unless ($res){
|
||||
$template->param(barcode=> 1);
|
||||
$total++;
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where tab = 10");
|
||||
#check isbn
|
||||
my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"isbn\"");
|
||||
$sth->execute;
|
||||
my $totaltags = 0;
|
||||
my $list = "";
|
||||
while (($res2) = $sth->fetchrow) {
|
||||
$totaltags++;
|
||||
$list.=$res2.",";
|
||||
}
|
||||
if ($totaltags > 1) {
|
||||
$template->param(itemtags => $list);
|
||||
my ($res) = $sth->fetchrow;
|
||||
unless ($res){
|
||||
$template->param(isbn => 1);
|
||||
$total++;
|
||||
} else {
|
||||
$template->param(itemtags => 0);
|
||||
}
|
||||
|
||||
|
||||
# checks biblioitems.itemtype must be mapped and use authorised_value=itemtype
|
||||
$sth = $dbh->prepare("select tagfield,tab,authorised_value from marc_subfield_structure where kohafield = \"biblioitems.itemtype\"");
|
||||
## Check for itemtype
|
||||
my $sth = $dbh->prepare("select tagfield,tagsubfield from koha_attr where marctokoha=\"itemtype\"");
|
||||
$sth->execute;
|
||||
($res,$res2,$field) = $sth->fetchrow;
|
||||
if ($res && $res2>=0 && $field eq "itemtypes") {
|
||||
$template->param(itemtype => 0);
|
||||
} else {
|
||||
my ($res,$res2) = $sth->fetchrow;
|
||||
if ($res) {
|
||||
$sth = $dbh->prepare("select authorised_value from biblios_subfield_structure where tagfield=? and tagsubfield=?");
|
||||
$sth->execute($res,$res2);
|
||||
my ($item)=$sth->fetchrow;
|
||||
unless ($item eq "itemtypes"){
|
||||
$template->param(itemtype => 1);
|
||||
$total++;
|
||||
}
|
||||
}
|
||||
|
||||
# checks items.homebranch must be mapped and use authorised_value=branches
|
||||
$sth = $dbh->prepare("select tagfield,tab,authorised_value from marc_subfield_structure where kohafield = \"items.homebranch\"");
|
||||
## Check for homebranch
|
||||
my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"homebranch\"");
|
||||
$sth->execute;
|
||||
($res,$res2,$field) = $sth->fetchrow;
|
||||
if ($res && $res2 eq 10 && $field eq "branches") {
|
||||
$template->param(branch => 0);
|
||||
} else {
|
||||
my ($res) = $sth->fetchrow;
|
||||
unless ($res) {
|
||||
$template->param(branch => 1);
|
||||
$total++;
|
||||
|
||||
}
|
||||
# checks items.homebranch must be mapped and use authorised_value=branches
|
||||
$sth = $dbh->prepare("select tagfield,tab,authorised_value from marc_subfield_structure where kohafield = \"items.holdingbranch\"");
|
||||
|
||||
## Check for holdingbranch
|
||||
my $sth = $dbh->prepare("select tagfield,tagsubfield from koha_attr where marctokoha=\"holdingbranch\"");
|
||||
$sth->execute;
|
||||
($res,$res2,$field) = $sth->fetchrow;
|
||||
if ($res && $res2 eq 10 && $field eq "branches") {
|
||||
$template->param(holdingbranch => 0);
|
||||
} else {
|
||||
my ($res,$res2) = $sth->fetchrow;
|
||||
if ($res) {
|
||||
$sth = $dbh->prepare("select authorised_value from biblios_subfield_structure where tagfield=? and tagsubfield=?");
|
||||
$sth->execute($res,$res2);
|
||||
my ($item)=$sth->fetchrow;
|
||||
unless ($item eq "branches"){
|
||||
$template->param(holdingbranch => 1);
|
||||
$total++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# checks that itemtypes & branches tables are not empty
|
||||
$sth = $dbh->prepare("select count(*) from itemtypes");
|
||||
$sth->execute;
|
||||
|
|
@ -163,31 +132,5 @@ unless ($res) {
|
|||
$total++;
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("select count(*) from marc_biblio where frameworkcode is NULL");
|
||||
$sth->execute;
|
||||
($res) = $sth->fetchrow;
|
||||
if ($res) {
|
||||
$template->param(frameworknull =>1);
|
||||
$total++;
|
||||
}
|
||||
$sth = $dbh->prepare("select count(*) from marc_subfield_structure where frameworkcode is NULL");
|
||||
$sth->execute;
|
||||
($res) = $sth->fetchrow;
|
||||
if ($res) {
|
||||
$template->param(frameworknull =>1);
|
||||
$total++;
|
||||
}
|
||||
$sth = $dbh->prepare("select count(*) from marc_tag_structure where frameworkcode is NULL");
|
||||
$sth->execute;
|
||||
($res) = $sth->fetchrow;
|
||||
if ($res) {
|
||||
$template->param(frameworknull =>1);
|
||||
$total++;
|
||||
}
|
||||
|
||||
$template->param(total => $total,
|
||||
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
$template->param(total => $total);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ use CGI;
|
|||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Search;
|
||||
use HTML::Template;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
|
||||
|
|
@ -194,9 +193,6 @@ if ($op eq 'add_form') {
|
|||
nextpage => $offset+$pagesize);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,458 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Auth;
|
||||
use CGI;
|
||||
use C4::Search;
|
||||
use C4::Context;
|
||||
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$frameworkcode)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("Select * from holdings_subfield_structure where (tagfield like ? and frameworkcode=?) order by tagfield");
|
||||
$sth->execute("$searchstring%",$frameworkcode);
|
||||
my @results;
|
||||
my $cnt=0;
|
||||
my $u=1;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
$cnt ++;
|
||||
$u++;
|
||||
}
|
||||
$sth->finish;
|
||||
$dbh->disconnect;
|
||||
return ($cnt,\@results);
|
||||
}
|
||||
|
||||
my $input = new CGI;
|
||||
my $tagfield=$input->param('tagfield');
|
||||
my $tagsubfield=$input->param('tagsubfield');
|
||||
my $frameworkcode=$input->param('frameworkcode');
|
||||
my $pkfield="tagfield";
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/holdings_subfields_structure.pl";
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "admin/holdings_subfields_structure.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
});
|
||||
my $pagesize=30;
|
||||
my $op = $input->param('op');
|
||||
$tagfield=~ s/\,//g;
|
||||
|
||||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
tagfield =>$tagfield,
|
||||
frameworkcode => $frameworkcode,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
tagfield =>$tagfield,
|
||||
frameworkcode => $frameworkcode,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
################## ADD_FORM ##################################
|
||||
# called by default. Used to create form to add or modify a record
|
||||
if ($op eq 'add_form') {
|
||||
my $data;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $more_subfields = $input->param("more_subfields")+1;
|
||||
|
||||
|
||||
# build authorised value list
|
||||
|
||||
my $sth2 = $dbh->prepare("select distinct category from authorised_values");
|
||||
$sth2->execute;
|
||||
my @authorised_values;
|
||||
push @authorised_values,"";
|
||||
while ((my $category) = $sth2->fetchrow_array) {
|
||||
push @authorised_values, $category;
|
||||
}
|
||||
push (@authorised_values,"branches");
|
||||
push (@authorised_values,"itemtypes");
|
||||
# build thesaurus categories list
|
||||
$sth2->finish;
|
||||
$sth2 = $dbh->prepare("select authtypecode from auth_types");
|
||||
$sth2->execute;
|
||||
my @authtypes;
|
||||
push @authtypes,"";
|
||||
while ((my $authtypecode) = $sth2->fetchrow_array) {
|
||||
push @authtypes, $authtypecode;
|
||||
}
|
||||
# build value_builder list
|
||||
my @value_builder=('');
|
||||
|
||||
# read value_builder directory.
|
||||
# 2 cases here : on CVS install, $cgidir does not need a /cgi-bin
|
||||
# on a standard install, /cgi-bin need to be added.
|
||||
# test one, then the other
|
||||
my $cgidir = C4::Context->intranetdir ."/cgi-bin";
|
||||
unless (opendir(DIR, "$cgidir/value_builder")) {
|
||||
$cgidir = C4::Context->intranetdir;
|
||||
opendir(DIR, "$cgidir/value_builder") || die "can't opendir $cgidir/value_builder: $!";
|
||||
}
|
||||
while (my $line = readdir(DIR)) {
|
||||
if ($line =~ /\.pl$/) {
|
||||
push (@value_builder,$line);
|
||||
}
|
||||
}
|
||||
closedir DIR;
|
||||
|
||||
# build values list
|
||||
my $sth=$dbh->prepare("select * from holdings_subfield_structure where tagfield=? and frameworkcode=?"); # and tagsubfield='$tagsubfield'");
|
||||
$sth->execute($tagfield,$frameworkcode);
|
||||
my @loop_data = ();
|
||||
my $toggle=1;
|
||||
my $i=0;
|
||||
while ($data =$sth->fetchrow_hashref) {
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
if ($toggle eq 1){
|
||||
$toggle=0;
|
||||
} else {
|
||||
$toggle=1;
|
||||
}
|
||||
$row_data{tab} = CGI::scrolling_list(-name=>'tab',
|
||||
-id=>"tab$i",
|
||||
-values=>['-1','10'],
|
||||
-labels => {'-1' =>'ignore','10'=>'items (10)', },
|
||||
-default=>$data->{'tab'},
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
|
||||
-id=>"ohidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>substr($data->{'hidden'},0,1),
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
|
||||
-id=>"ihidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>substr($data->{'hidden'},1,1),
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden',
|
||||
-id=>"ehidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-default=>substr($data->{'hidden'},2,1),
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{tagsubfield} =$data->{'tagsubfield'}."<input type=\"hidden\" name=\"tagsubfield\" value=\"".$data->{'tagsubfield'}."\" id=\"tagsubfield\">";
|
||||
$row_data{liblibrarian} = CGI::escapeHTML($data->{'liblibrarian'});
|
||||
$row_data{libopac} = CGI::escapeHTML($data->{'libopac'});
|
||||
$row_data{seealso} = CGI::escapeHTML($data->{'seealso'});
|
||||
|
||||
$row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-id=>'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-default=>$data->{'authorised_value'},
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{value_builder} = CGI::scrolling_list(-name=>'value_builder',
|
||||
-id=>'value_builder',
|
||||
-values=> \@value_builder,
|
||||
-default=>$data->{'value_builder'},
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{authtypes} = CGI::scrolling_list(-name=>'authtypecode',
|
||||
-id=>'authtypecode',
|
||||
-values=> \@authtypes,
|
||||
-default=>$data->{'authtypecode'},
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{repeatable} = CGI::checkbox(-name=>"repeatable$i",
|
||||
-checked => $data->{'repeatable'}?'checked':'',
|
||||
-value => 1,
|
||||
-label => '',
|
||||
-id => "repeatable$i");
|
||||
$row_data{mandatory} = CGI::checkbox(-name => "mandatory$i",
|
||||
-checked => $data->{'mandatory'}?'checked':'',
|
||||
-value => 1,
|
||||
-label => '',
|
||||
-id => "mandatory$i");
|
||||
$row_data{hidden} = CGI::escapeHTML($data->{hidden});
|
||||
$row_data{isurl} = CGI::checkbox( -name => "isurl$i",
|
||||
-id => "isurl$i",
|
||||
-checked => $data->{'isurl'}?'checked':'',
|
||||
-value => 1,
|
||||
-label => '');
|
||||
$row_data{row} = $i;
|
||||
$row_data{toggle} = $toggle;
|
||||
$row_data{link} = CGI::escapeHTML($data->{'link'});
|
||||
push(@loop_data, \%row_data);
|
||||
$i++;
|
||||
}
|
||||
# add more_subfields empty lines for add if needed
|
||||
for (my $i=1;$i<=$more_subfields;$i++) {
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tab} = CGI::scrolling_list(-name=>'tab',
|
||||
-id => "tab$i",
|
||||
-values=>['-1','10'],
|
||||
-labels => {'-1' =>'ignore','10'=>'items (10)',},
|
||||
-default=>"",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
|
||||
-id=>"ohidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
|
||||
-id=>"ihidden$i",
|
||||
-values=>['0','2'],
|
||||
-labels => {'0'=>'Show','2' =>'Hide',},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden',
|
||||
-id=>"ehidden$i",
|
||||
-values=>['0','1','2'],
|
||||
-labels => {'0'=>'Show','1'=>'Show Collapsed',
|
||||
'2' =>'Hide',
|
||||
},
|
||||
-default=>"0",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{tagsubfield} = "<input type=\"text\" name=\"tagsubfield\" value=\"".$data->{'tagsubfield'}."\" size=\"1\" id=\"tagsubfield\" maxlength=\"1\">";
|
||||
$row_data{liblibrarian} = "";
|
||||
$row_data{libopac} = "";
|
||||
$row_data{seealso} = "";
|
||||
$row_data{hidden} = "000";
|
||||
$row_data{repeatable} = CGI::checkbox( -name=> 'repeatable',
|
||||
-id => "repeatable$i",
|
||||
-checked => '',
|
||||
-value => 1,
|
||||
-label => '');
|
||||
$row_data{mandatory} = CGI::checkbox( -name=> 'mandatory',
|
||||
-id => "mandatory$i",
|
||||
-checked => '',
|
||||
-value => 1,
|
||||
-label => '');
|
||||
$row_data{isurl} = CGI::checkbox(-name => 'isurl',
|
||||
-id => "isurl$i",
|
||||
-checked => '',
|
||||
-value => 1,
|
||||
-label => '');
|
||||
|
||||
$row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-id => 'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{authtypes} = CGI::scrolling_list(-name=>'authtypecode',
|
||||
-id => 'authtypecode',
|
||||
-values=> \@authtypes,
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$row_data{link} = CGI::escapeHTML($data->{'link'});
|
||||
$row_data{toggle} = $toggle;
|
||||
$row_data{row} = $i;
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
$template->param('heading-edit-subfields-p' => 1);
|
||||
$template->param(action => "Edit subfields",
|
||||
tagfield => "<input type=\"hidden\" name=\"tagfield\" value=\"$tagfield\">$tagfield",
|
||||
loop => \@loop_data,
|
||||
more_subfields => $more_subfields,
|
||||
more_tag => $tagfield);
|
||||
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
$template->param(tagfield => "$input->param('tagfield')");
|
||||
my $sth=$dbh->prepare("replace holdings_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
my @tagsubfield = $input->param('tagsubfield');
|
||||
my @liblibrarian = $input->param('liblibrarian');
|
||||
my @libopac = $input->param('libopac');
|
||||
|
||||
my @tab = $input->param('tab');
|
||||
my @seealso = $input->param('seealso');
|
||||
# my @hidden = $input->param('hidden');
|
||||
my @hidden;
|
||||
my @ohidden = $input->param('ohidden');
|
||||
my @ihidden = $input->param('ihidden');
|
||||
my @ehidden = $input->param('ehidden');
|
||||
my @authorised_values = $input->param('authorised_value');
|
||||
my @authtypecodes = $input->param('authtypecode');
|
||||
my @value_builder =$input->param('value_builder');
|
||||
my @link =$input->param('link');
|
||||
for (my $i=0; $i<= $#tagsubfield ; $i++) {
|
||||
my $tagfield =$input->param('tagfield');
|
||||
my $tagsubfield =$tagsubfield[$i];
|
||||
$tagsubfield="@" unless $tagsubfield ne '';
|
||||
my $liblibrarian =$liblibrarian[$i];
|
||||
my $libopac =$libopac[$i];
|
||||
my $repeatable =$input->param("repeatable$i")?1:0;
|
||||
my $mandatory =$input->param("mandatory$i")?1:0;
|
||||
|
||||
my $tab =$tab[$i];
|
||||
my $seealso =$seealso[$i];
|
||||
my $authorised_value =$authorised_values[$i];
|
||||
my $authtypecode =$authtypecodes[$i];
|
||||
my $value_builder=$value_builder[$i];
|
||||
my $hidden = $ohidden[$i].$ihidden[$i].$ehidden[$i]; #collate from 3 hiddens;
|
||||
my $isurl = $input->param("isurl$i")?1:0;
|
||||
my $link = $link[$i];
|
||||
if ($liblibrarian) {
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
$sth->execute ($tagfield,
|
||||
$tagsubfield,
|
||||
$liblibrarian,
|
||||
$libopac,
|
||||
$repeatable,
|
||||
$mandatory,
|
||||
|
||||
$tab,
|
||||
$seealso,
|
||||
$authorised_value,
|
||||
$authtypecode,
|
||||
$value_builder,
|
||||
$hidden,
|
||||
$isurl,
|
||||
$frameworkcode,
|
||||
|
||||
$link,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=holdings_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
exit;
|
||||
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
# called by default form, used to confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirm') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select * from holdings_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
|
||||
#FIXME : called with 2 bind variables when 3 are needed
|
||||
$sth->execute($tagfield,$tagsubfield);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
$template->param(liblibrarian => $data->{'liblibrarian'},
|
||||
tagsubfield => $data->{'tagsubfield'},
|
||||
delete_link => $script_name,
|
||||
tagfield =>$tagfield,
|
||||
tagsubfield => $tagsubfield,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
################## DELETE_CONFIRMED ##################################
|
||||
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirmed') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
my $sth=$dbh->prepare("delete from holdings_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
|
||||
$sth->execute($tagfield,$tagsubfield,$frameworkcode);
|
||||
$sth->finish;
|
||||
}
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=holdings_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
exit;
|
||||
$template->param(tagfield => $tagfield);
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$tagfield,$frameworkcode);
|
||||
my $toggle=1;
|
||||
my @loop_data = ();
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
if ($toggle eq 1){
|
||||
$toggle=0;
|
||||
} else {
|
||||
$toggle=1;
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tagfield} = $results->[$i]{'tagfield'};
|
||||
$row_data{tagsubfield} = $results->[$i]{'tagsubfield'};
|
||||
$row_data{liblibrarian} = $results->[$i]{'liblibrarian'};
|
||||
|
||||
$row_data{repeatable} = $results->[$i]{'repeatable'};
|
||||
$row_data{mandatory} = $results->[$i]{'mandatory'};
|
||||
$row_data{tab} = $results->[$i]{'tab'};
|
||||
$row_data{seealso} = $results->[$i]{'seealso'};
|
||||
$row_data{authorised_value} = $results->[$i]{'authorised_value'};
|
||||
$row_data{authtypecode} = $results->[$i]{'authtypecode'};
|
||||
$row_data{value_builder} = $results->[$i]{'value_builder'};
|
||||
$row_data{hidden} = $results->[$i]{'hidden'} if($results->[$i]{'hidden'} gt "000") ;
|
||||
$row_data{isurl} = $results->[$i]{'isurl'};
|
||||
$row_data{link} = $results->[$i]{'link'};
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}."&frameworkcode=$frameworkcode";
|
||||
$row_data{toggle} = $toggle;
|
||||
if ($row_data{tab} eq -1) {
|
||||
$row_data{subfield_ignored} = 1;
|
||||
}
|
||||
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data);
|
||||
$template->param(edit_tagfield => $tagfield,
|
||||
edit_frameworkcode => $frameworkcode);
|
||||
|
||||
if ($offset>0) {
|
||||
my $prevpage = $offset-$pagesize;
|
||||
$template->param(prev =>"<a href=\"$script_name?offset=$prevpage\">");
|
||||
}
|
||||
if ($offset+$pagesize<$count) {
|
||||
my $nextpage =$offset+$pagesize;
|
||||
$template->param(next => "<a href=\"$script_name?offset=$nextpage\">");
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
@ -26,8 +26,7 @@ use C4::Context;
|
|||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
|
||||
|
||||
# retrieve parameters
|
||||
my $input = new CGI;
|
||||
|
|
@ -40,18 +39,18 @@ my $searchfield=$input->param('searchfield');
|
|||
$searchfield=0 unless $searchfield;
|
||||
$searchfield=~ s/\,//g;
|
||||
|
||||
my $offset=$input->param('offset') || 0;
|
||||
my $op = $input->param('op') || '';
|
||||
my $offset=$input->param('offset');
|
||||
my $op = $input->param('op');
|
||||
my $dspchoice = $input->param('select_display');
|
||||
my $pagesize=20;
|
||||
|
||||
my $script_name="/cgi-bin/koha/admin/marctagstructure.pl";
|
||||
my $script_name="/cgi-bin/koha/admin/holdingstagstructure.pl";
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
# open template
|
||||
my ($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "admin/marctagstructure.tmpl",
|
||||
= get_template_and_user({template_name => "admin/holdingstagstructure.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
|
|
@ -71,8 +70,8 @@ foreach my $thisframeworkcode (keys %$frameworks) {
|
|||
push @frameworkloop, \%row;
|
||||
}
|
||||
|
||||
# check that framework is defined in marc_tag_structure
|
||||
my $sth=$dbh->prepare("select count(*) from marc_tag_structure where frameworkcode=?");
|
||||
# check that framework is defined in holdings_tag_structure
|
||||
my $sth=$dbh->prepare("select count(*) from holdings_tag_structure where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
my ($frameworkexist) = $sth->fetchrow;
|
||||
if ($frameworkexist) {
|
||||
|
|
@ -104,7 +103,7 @@ if ($op eq 'add_form') {
|
|||
#---- if primkey exists, it's a modify action, so read values to modify...
|
||||
my $data;
|
||||
if ($searchfield) {
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?");
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from holdings_tag_structure where tagfield=? and frameworkcode=?");
|
||||
$sth->execute($searchfield,$frameworkcode);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
|
@ -119,7 +118,6 @@ if ($op eq 'add_form') {
|
|||
my $authorised_value = CGI::scrolling_list(-name=>'authorised_value',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-id=>"authorised_value",
|
||||
-multiple=>0,
|
||||
-default => $data->{'authorised_value'},
|
||||
|
|
@ -127,10 +125,11 @@ if ($op eq 'add_form') {
|
|||
|
||||
if ($searchfield) {
|
||||
$template->param(action => "Modify tag",
|
||||
searchfield => $searchfield);
|
||||
searchfield => "<input type=\"hidden\" name=\"tagfield\" value=\"$searchfield\" />$searchfield");
|
||||
$template->param('heading-modify-tag-p' => 1);
|
||||
} else {
|
||||
$template->param(action => "Add tag");
|
||||
$template->param(action => "Add tag",
|
||||
searchfield => "<input type=\"text\" name=\"tagfield\" size=\"5\" maxlength=\"3\" />");
|
||||
$template->param('heading-add-tag-p' => 1);
|
||||
}
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
|
|
@ -139,13 +138,11 @@ if ($op eq 'add_form') {
|
|||
repeatable => CGI::checkbox(-name=>'repeatable',
|
||||
-checked=> $data->{'repeatable'}?'checked':'',
|
||||
-value=> 1,
|
||||
-tabindex=>'',
|
||||
-label => '',
|
||||
-id=> 'repeatable'),
|
||||
mandatory => CGI::checkbox(-name => 'mandatory',
|
||||
-checked => $data->{'mandatory'}?'checked':'',
|
||||
-value => 1,
|
||||
-tabindex=>'',
|
||||
-label => '',
|
||||
-id => 'mandatory'),
|
||||
authorised_value => $authorised_value,
|
||||
|
|
@ -155,7 +152,7 @@ if ($op eq 'add_form') {
|
|||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
$sth=$dbh->prepare("replace marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)");
|
||||
$sth=$dbh->prepare("replace holdings_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)");
|
||||
my $tagfield =$input->param('tagfield');
|
||||
my $liblibrarian = $input->param('liblibrarian');
|
||||
my $libopac =$input->param('libopac');
|
||||
|
|
@ -173,13 +170,13 @@ if ($op eq 'add_form') {
|
|||
);
|
||||
}
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=holdingstagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
exit;
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
# called by default form, used to confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirm') {
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?");
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from holdings_tag_structure where tagfield=? and frameworkcode=?");
|
||||
$sth->execute($searchfield,$frameworkcode);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
|
@ -192,14 +189,15 @@ if ($op eq 'add_form') {
|
|||
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirmed') {
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
$dbh->do("delete from marc_tag_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
|
||||
$dbh->do("delete from marc_subfield_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
|
||||
$dbh->do("delete from holdings_tag_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
|
||||
$dbh->do("delete from holdings_subfield_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
|
||||
|
||||
}
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
################## ITEMTYPE_CREATE ##################################
|
||||
# called automatically if an unexisting frameworkis selected
|
||||
} elsif ($op eq 'framework_create') {
|
||||
$sth = $dbh->prepare("select count(*),marc_tag_structure.frameworkcode,frameworktext from marc_tag_structure,biblio_framework where biblio_framework.frameworkcode=marc_tag_structure.frameworkcode group by marc_tag_structure.frameworkcode");
|
||||
$sth = $dbh->prepare("select count(*),holdings_tag_structure.frameworkcode,frameworktext from holdings_tag_structure,biblio_framework where biblio_framework.frameworkcode=holdings_tag_structure.frameworkcode group by holdings_tag_structure.frameworkcode");
|
||||
$sth->execute;
|
||||
my @existingframeworkloop;
|
||||
while (my ($tot,$thisframeworkcode,$frameworktext) = $sth->fetchrow) {
|
||||
|
|
@ -226,7 +224,7 @@ if ($op eq 'add_form') {
|
|||
my $env;
|
||||
$searchfield=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchfield);
|
||||
my $sth=$dbh->prepare("Select marc_tag_structure.tagfield as mts_tagfield,marc_tag_structure.liblibrarian as mts_liblibrarian,marc_tag_structure.libopac as mts_libopac,marc_tag_structure.repeatable as mts_repeatable,marc_tag_structure.mandatory as mts_mandatory,marc_tag_structure.authorised_value as mts_authorized_value,marc_subfield_structure.* from marc_tag_structure LEFT JOIN marc_subfield_structure ON (marc_tag_structure.tagfield=marc_subfield_structure.tagfield AND marc_tag_structure.frameworkcode=marc_subfield_structure.frameworkcode) where (marc_tag_structure.tagfield >= ? and marc_tag_structure.frameworkcode=?) AND marc_subfield_structure.tab>=0 order by marc_tag_structure.tagfield,marc_subfield_structure.tagsubfield");
|
||||
my $sth=$dbh->prepare("Select holdings_tag_structure.tagfield as mts_tagfield,holdings_tag_structure.liblibrarian as mts_liblibrarian,holdings_tag_structure.libopac as mts_libopac,holdings_tag_structure.repeatable as mts_repeatable,holdings_tag_structure.mandatory as mts_mandatory,holdings_tag_structure.authorised_value as mts_authorized_value,holdings_subfield_structure.* from holdings_tag_structure LEFT JOIN holdings_subfield_structure ON (holdings_tag_structure.tagfield=holdings_subfield_structure.tagfield AND holdings_tag_structure.frameworkcode=holdings_subfield_structure.frameworkcode) where (holdings_tag_structure.tagfield >= ? and holdings_tag_structure.frameworkcode=?) AND holdings_subfield_structure.tab>=0 order by holdings_tag_structure.tagfield,holdings_subfield_structure.tagsubfield");
|
||||
#could be ordoned by tab
|
||||
$sth->execute($data[0], $frameworkcode);
|
||||
my @results = ();
|
||||
|
|
@ -252,7 +250,7 @@ if ($op eq 'add_form') {
|
|||
$row_data{repeatable} = $results[$i]->{'mts_repeatable'};
|
||||
$row_data{mandatory} = $results[$i]->{'mts_mandatory'};
|
||||
$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
|
||||
$row_data{subfield_link} ="marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{subfield_link} ="holdings_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{toggle} = $toggle;
|
||||
|
|
@ -267,7 +265,7 @@ if ($op eq 'add_form') {
|
|||
my %subfield_data;
|
||||
$subfield_data{tagsubfield} = $results[$j]->{'tagsubfield'};
|
||||
$subfield_data{liblibrarian} = $results[$j]->{'liblibrarian'};
|
||||
$subfield_data{kohafield} = $results[$j]->{'kohafield'};
|
||||
|
||||
$subfield_data{repeatable} = $results[$j]->{'repeatable'};
|
||||
$subfield_data{mandatory} = $results[$j]->{'mandatory'};
|
||||
$subfield_data{tab} = $results[$j]->{'tab'};
|
||||
|
|
@ -308,7 +306,7 @@ if ($op eq 'add_form') {
|
|||
$row_data{repeatable} = $results->[$i]{'repeatable'};
|
||||
$row_data{mandatory} = $results->[$i]{'mandatory'};
|
||||
$row_data{authorised_value} = $results->[$i]{'authorised_value'};
|
||||
$row_data{subfield_link} ="marc_subfields_structure.pl?tagfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{subfield_link} ="holdings_subfields_structure.pl?tagfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
|
||||
$row_data{toggle} = $toggle;
|
||||
|
|
@ -352,12 +350,11 @@ sub StringSearch {
|
|||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $sth=$dbh->prepare("Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where (tagfield >= ? and frameworkcode=?) order by tagfield");
|
||||
my $sth=$dbh->prepare("Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from holdings_tag_structure where (tagfield >= ? and frameworkcode=?) order by tagfield");
|
||||
$sth->execute($data[0], $frameworkcode);
|
||||
my @results;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
warn "=> ".$data->{liblibrarian};
|
||||
}
|
||||
# $sth->execute;
|
||||
$sth->finish;
|
||||
|
|
@ -365,22 +362,5 @@ sub StringSearch {
|
|||
}
|
||||
|
||||
#
|
||||
# the sub used to duplicate a framework from an existing one in MARC parameters tables.
|
||||
#
|
||||
sub duplicate_framework {
|
||||
my ($newframeworkcode,$oldframeworkcode) = @_;
|
||||
my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where frameworkcode=?");
|
||||
$sth->execute($oldframeworkcode);
|
||||
my $sth_insert = $dbh->prepare("insert into marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) values (?,?,?,?,?,?,?)");
|
||||
while ( my ($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value) = $sth->fetchrow) {
|
||||
$sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode);
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso from marc_subfield_structure where frameworkcode=?");
|
||||
$sth->execute($oldframeworkcode);
|
||||
$sth_insert = $dbh->prepare("insert into marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso) values (?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso) = $sth->fetchrow) {
|
||||
$sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Script to manage the educational institutions and its careers.
|
||||
# written 12/04
|
||||
# Castañeda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::AcademicInfo;
|
||||
|
||||
my $cgi = new CGI;
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "admin/institutions-careers.tmpl",
|
||||
query => $cgi,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {editcatalogue => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
my $op = $cgi->param('op');
|
||||
my $id_institution = $cgi->param('id_institution');
|
||||
my $institution_name = $cgi->param('institution_name');
|
||||
|
||||
if ($op eq 'add_form') {
|
||||
$template->param(add_form => 1);
|
||||
|
||||
if ($id_institution) {
|
||||
my $info = get_educational_institution($id_institution);
|
||||
$template->param(op => 'edit');
|
||||
$template->param(institution_name => $info->{'institution_name'});
|
||||
$template->param(id_institution => $id_institution);
|
||||
} else {
|
||||
$template->param(op => 'add');
|
||||
}
|
||||
|
||||
} elsif ($op eq 'add') {
|
||||
add_educational_institution($institution_name);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/institutions-careers.pl');
|
||||
} elsif ($op eq 'edit') {
|
||||
update_educational_institution($id_institution, $institution_name);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/institutions-careers.pl');
|
||||
} elsif ($op eq 'del') {
|
||||
del_educational_institution($id_institution);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/institutions-careers.pl');
|
||||
} else {
|
||||
my @educ_institutions = &get_careers_by_institution();
|
||||
$template->param(institutions => \@educ_institutions);
|
||||
}
|
||||
|
||||
output_html_with_http_headers $cgi, $cookie, $template->output;
|
||||
|
|
@ -21,12 +21,10 @@ use strict;
|
|||
use CGI;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Database;
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
use C4::Koha;
|
||||
use C4::Interface::CGI::Output;
|
||||
use HTML::Template;
|
||||
|
||||
my $input = new CGI;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
|
@ -55,8 +53,8 @@ if ($op eq 'save') {
|
|||
my $sth_Fupdate=$dbh->prepare("Update issuingrules set fine=?,firstremind=?,chargeperiod=? where branchcode=? and categorycode=? and itemtype=?");
|
||||
my $sth_Fdelete=$dbh->prepare("delete from issuingrules where branchcode=? and categorycode=? and itemtype=? and issuelength=0");
|
||||
|
||||
my $sth_Iinsert = $dbh->prepare("insert into issuingrules (branchcode,categorycode,itemtype,maxissueqty,issuelength,rentaldiscount) values (?,?,?,?,?,?)");
|
||||
my $sth_Iupdate=$dbh->prepare("Update issuingrules set maxissueqty=?, issuelength=?, rentaldiscount=? where branchcode=? and categorycode=? and itemtype=?");
|
||||
my $sth_Iinsert = $dbh->prepare("insert into issuingrules (branchcode,categorycode,itemtype,maxissueqty,issuelength) values (?,?,?,?,?)");
|
||||
my $sth_Iupdate=$dbh->prepare("Update issuingrules set maxissueqty=?, issuelength=? where branchcode=? and categorycode=? and itemtype=?");
|
||||
my $sth_Idelete=$dbh->prepare("delete from issuingrules where branchcode=? and categorycode=? and itemtype=? and fine=0");
|
||||
foreach my $key (@names){
|
||||
# ISSUES
|
||||
|
|
@ -65,14 +63,14 @@ if ($op eq 'save') {
|
|||
my $bor = $2; # borrower category
|
||||
my $cat = $3; # item type
|
||||
my $data=$input->param($key);
|
||||
my ($issuelength,$maxissueqty,$rentaldiscount)=split(',',$data);
|
||||
my ($issuelength,$maxissueqty)=split(',',$data);
|
||||
# if ($maxissueqty >0) {
|
||||
$sth_search->execute($br,$bor,$cat);
|
||||
my $res = $sth_search->fetchrow_hashref();
|
||||
if ($res->{total}) {
|
||||
$sth_Iupdate->execute($maxissueqty,$issuelength,$rentaldiscount,$br,$bor,$cat);
|
||||
$sth_Iupdate->execute($maxissueqty,$issuelength,$br,$bor,$cat);
|
||||
} else {
|
||||
$sth_Iinsert->execute($br,$bor,$cat,$maxissueqty,$issuelength,$rentaldiscount);
|
||||
$sth_Iinsert->execute($br,$bor,$cat,$maxissueqty,$issuelength);
|
||||
}
|
||||
# } else {
|
||||
# $sth_Idelete->execute($br,$bor,$cat);
|
||||
|
|
@ -100,7 +98,7 @@ if ($op eq 'save') {
|
|||
}
|
||||
|
||||
}
|
||||
my $branches = GetBranches;
|
||||
my $branches = getbranches;
|
||||
my @branchloop;
|
||||
foreach my $thisbranch (keys %$branches) {
|
||||
my $selected = 1 if $thisbranch eq $branch;
|
||||
|
|
@ -113,7 +111,7 @@ foreach my $thisbranch (keys %$branches) {
|
|||
|
||||
my $sth=$dbh->prepare("Select description,categorycode from categories order by description");
|
||||
$sth->execute;
|
||||
my @trow3;
|
||||
my @trow3;
|
||||
my @title_loop;
|
||||
# my $i=0;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
|
|
@ -158,12 +156,11 @@ foreach my $data (@itemtypes) {
|
|||
my $fine=$dat->{'fine'}+0;
|
||||
my $maxissueqty = $dat->{'maxissueqty'}+0;
|
||||
my $issuelength = $dat->{'issuelength'}+0;
|
||||
my $rentaldiscount = $dat->{'rentaldiscount'}+0;
|
||||
my $finesvalue;
|
||||
$finesvalue= "$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}" if $fine+$dat->{'firstremind'}+$dat->{'chargeperiod'}>0;
|
||||
my $issuingvalue;
|
||||
# if ($maxissueqty>0) {
|
||||
$issuingvalue = "$issuelength,$maxissueqty,$rentaldiscount" if $issuelength+$maxissueqty>0;
|
||||
$issuingvalue = "$issuelength,$maxissueqty" if $issuelength+$maxissueqty>0;
|
||||
# }
|
||||
# else {
|
||||
# $issuingvalue = "$issuelength, 5";
|
||||
|
|
@ -186,9 +183,5 @@ $sth->finish;
|
|||
$template->param(title => \@title_loop,
|
||||
row => \@row_loop,
|
||||
branchloop => \@branchloop,
|
||||
branch => $branch,
|
||||
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
branch => $branch);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -40,16 +40,13 @@
|
|||
|
||||
use strict;
|
||||
use CGI;
|
||||
use HTML::Template;
|
||||
use List::Util qw/min/;
|
||||
|
||||
use C4::Koha;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Search;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
|
@ -69,9 +66,10 @@ sub StringSearch {
|
|||
|
||||
my $input = new CGI;
|
||||
my $searchfield=$input->param('description');
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/itemtypes.pl";
|
||||
my $itemtype=$input->param('itemtype');
|
||||
my $pagesize=5;
|
||||
my $pagesize=20;
|
||||
my $op = $input->param('op');
|
||||
$searchfield=~ s/\,//g;
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
|
|
@ -98,76 +96,28 @@ if ($op eq 'add_form') {
|
|||
my $data;
|
||||
if ($itemtype) {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select * from itemtypes where itemtype=?");
|
||||
my $sth=$dbh->prepare("select itemtype,description,renewalsallowed,rentalcharge,notforloan from itemtypes where itemtype=?");
|
||||
$sth->execute($itemtype);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
# build list of images
|
||||
my $imagedir_filesystem = getitemtypeimagedir();
|
||||
my $imagedir_web = getitemtypeimagesrc();
|
||||
opendir(DIR, $imagedir_filesystem)
|
||||
or die "can't opendir ".$imagedir_filesystem.": ".$!;
|
||||
my @imagelist;
|
||||
while (my $line = readdir(DIR)) {
|
||||
if ($line =~ /\.(gif|png)$/i) {
|
||||
push(
|
||||
@imagelist,
|
||||
{
|
||||
KohaImage => $line,
|
||||
KohaImageSrc => $imagedir_web.'/'.$line,
|
||||
checked => $line eq $data->{imageurl} ? 1 : 0,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
closedir DIR;
|
||||
|
||||
my $remote_image = undef;
|
||||
if (defined $data->{imageurl} and $data->{imageurl} =~ m/^http/) {
|
||||
$remote_image = $data->{imageurl};
|
||||
}
|
||||
|
||||
$template->param(
|
||||
itemtype => $itemtype,
|
||||
description => $data->{'description'},
|
||||
renewalsallowed => $data->{'renewalsallowed'},
|
||||
rentalcharge => sprintf("%.2f",$data->{'rentalcharge'}),
|
||||
notforloan => $data->{'notforloan'},
|
||||
imageurl => $data->{'imageurl'},
|
||||
template => C4::Context->preference('template'),
|
||||
IMAGESLOOP => \@imagelist,
|
||||
remote_image => $remote_image,
|
||||
);
|
||||
$template->param(itemtype => $itemtype,
|
||||
description => $data->{'description'},
|
||||
renewalsallowed => $data->{'renewalsallowed'},
|
||||
rentalcharge => sprintf("%.2f",$data->{'rentalcharge'}),
|
||||
notforloan => $data->{'notforloan'}
|
||||
);
|
||||
;
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $query = '
|
||||
UPDATE itemtypes
|
||||
SET description = ?
|
||||
, renewalsallowed = ?
|
||||
, rentalcharge = ?
|
||||
, notforloan = ?
|
||||
, imageurl = ?
|
||||
WHERE itemtype = ?
|
||||
';
|
||||
my $sth=$dbh->prepare($query);
|
||||
my $sth=$dbh->prepare("replace itemtypes (itemtype,description,renewalsallowed,rentalcharge,notforloan) values (?,?,?,?,?)");
|
||||
$sth->execute(
|
||||
$input->param('description'),
|
||||
$input->param('renewalsallowed'),
|
||||
$input->param('rentalcharge'),
|
||||
$input->param('notforloan') ? 1 : 0,
|
||||
$input->param('image') eq 'removeImage'
|
||||
? undef
|
||||
: $input->param('image') eq 'remoteImage'
|
||||
? $input->param('remoteImage')
|
||||
: $input->param('image'),
|
||||
$input->param('itemtype'),
|
||||
);
|
||||
|
||||
$input->param('itemtype'),$input->param('description'),
|
||||
$input->param('renewalsallowed'),$input->param('rentalcharge'),
|
||||
$input->param('notforloan')?1:0);
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=itemtypes.pl\"></html>";
|
||||
exit;
|
||||
|
|
@ -193,10 +143,9 @@ UPDATE itemtypes
|
|||
$sth->finish;
|
||||
|
||||
$template->param(itemtype => $itemtype,
|
||||
description => $data->{description},
|
||||
renewalsallowed => $data->{renewalsallowed},
|
||||
rentalcharge => sprintf("%.2f",$data->{rentalcharge}),
|
||||
imageurl => $data->{imageurl},
|
||||
description => $data->{'description'},
|
||||
renewalsallowed => $data->{'renewalsallowed'},
|
||||
rentalcharge => sprintf("%.2f",$data->{'rentalcharge'}),
|
||||
total => $total);
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
################## DELETE_CONFIRMED ##################################
|
||||
|
|
@ -215,45 +164,35 @@ UPDATE itemtypes
|
|||
# END $OP eq DELETE_CONFIRMED
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$searchfield,'web');
|
||||
|
||||
my $page = $input->param('page') || 1;
|
||||
my $first = ($page - 1) * $pagesize;
|
||||
|
||||
# if we are on the last page, the number of the last word to display
|
||||
# must not exceed the length of the results array
|
||||
my $last = min(
|
||||
$first + $pagesize - 1,
|
||||
scalar @{$results} - 1,
|
||||
);
|
||||
|
||||
my $toggle = 0;
|
||||
my @loop;
|
||||
foreach my $result (@{$results}[$first .. $last]) {
|
||||
my $itemtype = $result;
|
||||
$itemtype->{toggle} = ($toggle++%2 eq 0 ? 1 : 0);
|
||||
$itemtype->{imageurl} =
|
||||
getitemtypeimagesrcfromurl($itemtype->{imageurl});
|
||||
$itemtype->{rentalcharge} = sprintf('%.2f', $itemtype->{rentalcharge});
|
||||
|
||||
push(@loop, $itemtype);
|
||||
}
|
||||
|
||||
$template->param(
|
||||
loop => \@loop,
|
||||
pagination_bar => pagination_bar(
|
||||
$script_name,
|
||||
getnbpages(scalar @{$results}, $pagesize),
|
||||
$page,
|
||||
'page'
|
||||
)
|
||||
);
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$searchfield,'web');
|
||||
my $toggle=0;
|
||||
my @loop_data;
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
my %row_data;
|
||||
if ($toggle eq 0){
|
||||
$toggle=1;
|
||||
} else {
|
||||
$toggle=0;
|
||||
}
|
||||
$row_data{toggle} = $toggle;
|
||||
$row_data{itemtype} = $results->[$i]{itemtype};
|
||||
$row_data{description} = $results->[$i]{description};
|
||||
$row_data{renewalsallowed} = $results->[$i]{renewalsallowed};
|
||||
$row_data{notforloan} = $results->[$i]{notforloan};
|
||||
$row_data{rentalcharge} = sprintf("%.2f",$results->[$i]{rentalcharge});
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data);
|
||||
if ($offset>0) {
|
||||
my $prevpage = $offset-$pagesize;
|
||||
$template->param(previous => "$script_name?offset=".$prevpage);
|
||||
}
|
||||
if ($offset+$pagesize<$count) {
|
||||
my $nextpage =$offset+$pagesize;
|
||||
$template->param(next => "$script_name?offset=".$nextpage);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
# Local Variables:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Script to manage the opac news.
|
||||
# written 11/04
|
||||
# Castañeda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::NewsChannels;
|
||||
|
||||
|
||||
my $cgi = new CGI;
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "admin/koha-electronic.tmpl",
|
||||
query => $cgi,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
my $op = $cgi->param('op');
|
||||
|
||||
if ($op eq 'add_form') {
|
||||
$template->param(add_form => 1);
|
||||
my $id = $cgi->param("id");
|
||||
my $edata;
|
||||
# warn "add_form";
|
||||
if ($id) {
|
||||
$template->param(op => 'edit');
|
||||
$edata = get_opac_electronic($id);
|
||||
$template->param($edata);
|
||||
$template->param(id => $edata->{'idelectronic'});
|
||||
} else {
|
||||
$template->param(op => 'add');
|
||||
}
|
||||
|
||||
} elsif ($op eq 'add') {
|
||||
# warn "add";
|
||||
my $title = $cgi->param('title');
|
||||
my $edata = $cgi->param('edata');
|
||||
my $lang = $cgi->param('lang');
|
||||
my $image = $cgi->param('image');
|
||||
my $href = $cgi->param('href');
|
||||
my $section = $cgi->param('section');
|
||||
add_opac_electronic($title, $edata, $lang,$image, $href,$section);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/opac-electronic.pl');
|
||||
|
||||
} elsif ($op eq 'edit') {
|
||||
# warn "edit";
|
||||
my $id = $cgi->param('id');
|
||||
my $title = $cgi->param('title');
|
||||
my $edata = $cgi->param('edata');
|
||||
my $lang = $cgi->param('lang');
|
||||
my $image = $cgi->param('image');
|
||||
my $href = $cgi->param('href');
|
||||
my $section = $cgi->param('section');
|
||||
upd_opac_electronic($id, $title, $edata, $lang,$image,$href,$section);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/opac-electronic.pl');
|
||||
|
||||
} elsif ($op eq 'del') {
|
||||
# warn "del";
|
||||
my @ids = $cgi->param('ids');
|
||||
del_opac_electronic(join ",", @ids);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/opac-electronic.pl');
|
||||
|
||||
} else {
|
||||
# warn "else";
|
||||
|
||||
my $lang = $cgi->param('lang');
|
||||
|
||||
my ($opac_electronic_count, $opac_electronic) = &get_opac_electronics(undef, $lang);
|
||||
$template->param($lang => 1);
|
||||
$template->param(opac_electronic => $opac_electronic);
|
||||
$template->param(opac_electronic_count => $opac_electronic_count);
|
||||
|
||||
}
|
||||
|
||||
output_html_with_http_headers $cgi, $cookie, $template->output;
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Script to manage the opac news.
|
||||
# written 11/04
|
||||
# Castañeda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::NewsChannels;
|
||||
|
||||
|
||||
my $cgi = new CGI;
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "admin/koha-news.tmpl",
|
||||
query => $cgi,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {management => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
my $op = $cgi->param('op');
|
||||
|
||||
if ($op eq 'add_form') {
|
||||
$template->param(add_form => 1);
|
||||
my $id = $cgi->param("id");
|
||||
my $new;
|
||||
|
||||
if ($id) {
|
||||
$template->param(op => 'edit');
|
||||
$new = get_opac_new($id);
|
||||
$template->param($new);
|
||||
$template->param(id => $new->{'idnew'});
|
||||
} else {
|
||||
$template->param(op => 'add');
|
||||
}
|
||||
|
||||
} elsif ($op eq 'add') {
|
||||
|
||||
my $title = $cgi->param('title');
|
||||
my $new = $cgi->param('new');
|
||||
my $lang = $cgi->param('lang');
|
||||
|
||||
add_opac_new($title, $new, $lang);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/koha-news.pl');
|
||||
|
||||
} elsif ($op eq 'edit') {
|
||||
|
||||
my $id = $cgi->param('id');
|
||||
my $title = $cgi->param('title');
|
||||
my $new = $cgi->param('new');
|
||||
my $lang = $cgi->param('lang');
|
||||
|
||||
upd_opac_new($id, $title, $new, $lang);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/koha-news.pl');
|
||||
|
||||
} elsif ($op eq 'del') {
|
||||
my @ids = $cgi->param('ids');
|
||||
del_opac_new(join ",", @ids);
|
||||
print $cgi->redirect('/cgi-bin/koha/admin/koha-news.pl');
|
||||
|
||||
} else {
|
||||
|
||||
my $lang = $cgi->param('lang');
|
||||
my ($opac_news_count, $opac_news) = &get_opac_news(undef, $lang);
|
||||
$template->param($lang => 1);
|
||||
$template->param(opac_news => $opac_news);
|
||||
$template->param(opac_news_count => $opac_news_count);
|
||||
|
||||
}
|
||||
|
||||
output_html_with_http_headers $cgi, $cookie, $template->output;
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Auth;
|
||||
use CGI;
|
||||
use C4::Search;
|
||||
use C4::Context;
|
||||
use C4::Biblio;
|
||||
use HTML::Template;
|
||||
|
||||
my $input = new CGI;
|
||||
my $tablename=$input->param('tablename');
|
||||
$tablename="biblio" unless ($tablename);
|
||||
my $kohafield = $input->param('kohafield');
|
||||
my $op=$input->param('op');
|
||||
my $script_name = 'koha2marclinks.pl';
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "admin/koha2marclinks.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
################## ADD_FORM ##################################
|
||||
# called by default. Used to create form to add or modify a record
|
||||
if ($op eq 'add_form') {
|
||||
my $data;
|
||||
my $sth = $dbh->prepare("select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where kohafield=?");
|
||||
$sth->execute($tablename.".".$kohafield);
|
||||
my ($defaulttagfield, $defaulttagsubfield,$defaultliblibrarian) = $sth->fetchrow;
|
||||
|
||||
for (my $i=0;$i<=9;$i++) {
|
||||
my $sth2=$dbh->prepare("select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where tagfield like ?");
|
||||
$sth2->execute("$i%");
|
||||
my @marcarray;
|
||||
push @marcarray," ";
|
||||
while (my ($field, $tagsubfield, $liblibrarian) = $sth2->fetchrow_array) {
|
||||
push @marcarray, "$field $tagsubfield - $liblibrarian";
|
||||
}
|
||||
my $marclist = CGI::scrolling_list(-name=>"marc",
|
||||
-values=> \@marcarray,
|
||||
-default=>"$defaulttagfield $defaulttagsubfield - $defaultliblibrarian",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
$template->param("marclist$i" => $marclist);
|
||||
}
|
||||
$template->param( tablename => $tablename,
|
||||
kohafield => $kohafield);
|
||||
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
#----- empty koha field :
|
||||
$dbh->do("update marc_subfield_structure set kohafield='' where kohafield='$tablename.$kohafield'");
|
||||
#---- reload if not empty
|
||||
my @temp = split / /,$input->param('marc');
|
||||
$dbh->do("update marc_subfield_structure set kohafield='$tablename.$kohafield' where tagfield='$temp[0]' and tagsubfield='$temp[1]'");
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=koha2marclinks.pl?tablename=$tablename\"></html>";
|
||||
exit;
|
||||
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
my $env;
|
||||
my $sth=$dbh->prepare("Select tagfield,tagsubfield,liblibrarian,kohafield from marc_subfield_structure");
|
||||
$sth->execute;
|
||||
my %fields;
|
||||
while ((my $tagfield,my $tagsubfield,my $liblibrarian,my $kohafield) = $sth->fetchrow) {
|
||||
$fields{$kohafield}->{tagfield} = $tagfield;
|
||||
$fields{$kohafield}->{tagsubfield} = $tagsubfield;
|
||||
$fields{$kohafield}->{liblibrarian} = $liblibrarian;
|
||||
}
|
||||
#XXX: This might not work. Maybe should use a DBI call instead of SHOW COLUMNS
|
||||
my $sth2=$dbh->prepare("SHOW COLUMNS from $tablename");
|
||||
$sth2->execute;
|
||||
|
||||
my $toggle="white";
|
||||
my @loop_data = ();
|
||||
while ((my $field) = $sth2->fetchrow_array) {
|
||||
if ($toggle eq 'white'){
|
||||
$toggle="#ffffcc";
|
||||
} else {
|
||||
$toggle="white";
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tagfield} = $fields{$tablename.".".$field}->{tagfield};
|
||||
$row_data{tagsubfield} = $fields{$tablename.".".$field}->{tagsubfield};
|
||||
$row_data{liblibrarian} = $fields{$tablename.".".$field}->{liblibrarian};
|
||||
$row_data{kohafield} = $field;
|
||||
$row_data{edit} = "$script_name?op=add_form&tablename=$tablename&kohafield=$field";
|
||||
$row_data{bgcolor} = $toggle;
|
||||
push(@loop_data,\%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data,
|
||||
tablename => CGI::scrolling_list(-name=>'tablename',
|
||||
-values=>['biblio','biblioitems','items','bibliosubject','bibliosubtitle','additionalauthors'],
|
||||
-default=>$tablename,
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0
|
||||
)
|
||||
);
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
use C4::Auth;
|
||||
use C4::Koha;
|
||||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
|
||||
|
||||
# retrieve parameters
|
||||
my $input = new CGI;
|
||||
|
||||
my $searchfield=$input->param('searchfield');
|
||||
$searchfield="" unless $searchfield;
|
||||
my $id=$input->param('id');
|
||||
my $offset=$input->param('offset');
|
||||
$offset=0 unless $offset;
|
||||
my $op = $input->param('op');
|
||||
my $dspchoice = $input->param('select_display');
|
||||
my $pagesize=20;
|
||||
my @results = ();
|
||||
my $script_name="/cgi-bin/koha/admin/koha_attr.pl";
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth;
|
||||
# open template
|
||||
my ($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "admin/koha_attr.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => {parameters => 1},
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
|
||||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
|
||||
################## ADD_FORM ##################################
|
||||
# called by default. Used to create form to add or modify a record
|
||||
if ($op eq 'add_form') {
|
||||
#---- if primkey exists, it's a modify action, so read values to modify...
|
||||
my $data;
|
||||
if ($id) {
|
||||
$sth=$dbh->prepare("select id,marctokoha,attr,liblibrarian,sorts,recordtype,tagfield,tagsubfield,opacshow,intrashow from koha_attr where id=? ");
|
||||
$sth->execute($id);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
my $sth = $dbh->prepare("select authorised_value from authorised_values where category='recordtype'");
|
||||
$sth->execute;
|
||||
my @authorised_values;
|
||||
#push @authorised_values,"";
|
||||
while ((my $category) = $sth->fetchrow_array) {
|
||||
push @authorised_values, $category;
|
||||
}
|
||||
my $recordlist = CGI::scrolling_list(-name=>'recordtype',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
-default => $data->{'recordtype'},
|
||||
);
|
||||
my $sth = $dbh->prepare("select authorised_value from authorised_values where category='mfield' order by lib");
|
||||
$sth->execute;
|
||||
my @authorised_values;
|
||||
#push @authorised_values,"";
|
||||
while ((my $category) = $sth->fetchrow_array) {
|
||||
push @authorised_values, $category;
|
||||
}
|
||||
my $taglist = CGI::scrolling_list(-name=>'tagfield',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
-default => $data->{'tagfield'},
|
||||
);
|
||||
my $sth = $dbh->prepare("select authorised_value from authorised_values where category='subfield' order by lib ");
|
||||
$sth->execute;
|
||||
my @authorised_values;
|
||||
#push @authorised_values,"";
|
||||
while ((my $category) = $sth->fetchrow_array) {
|
||||
push @authorised_values, $category;
|
||||
}
|
||||
my $tagsublist = CGI::scrolling_list(-name=>'tagsubfield',
|
||||
-values=> \@authorised_values,
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
-default => $data->{'tagsubfield'},
|
||||
);
|
||||
|
||||
if ($searchfield) {
|
||||
$template->param(action => "Modify tag",id=>$id ,searchfield => "<input type=\"hidden\" name=\"marctokoha\" value=\"$searchfield\" />$searchfield");
|
||||
$template->param('heading-modify-tag-p' => 1);
|
||||
} else {
|
||||
$template->param(action => "Add tag",
|
||||
searchfield => "<input type=\"text\" name=\"marctokoha\" size=\"40\" maxlength=\"80\" />");
|
||||
$template->param('heading-add-tag-p' => 1);
|
||||
}
|
||||
$template->param('use-heading-flags-p' => 1);
|
||||
$template->param(liblibrarian => $data->{'liblibrarian'},
|
||||
attr=> $data->{'attr'},
|
||||
recordtype=>$recordlist,
|
||||
tagfield=>$taglist,
|
||||
tagsubfield=>$tagsublist,
|
||||
sorts => CGI::checkbox(-name=>'sorts',
|
||||
-checked=> $data->{'sorts'}?'checked':'',
|
||||
-value=> 1,
|
||||
-label => '',
|
||||
-id=> 'sorts'),
|
||||
opacshow => CGI::checkbox(-name=>'opacshow',
|
||||
-checked=> $data->{'opacshow'}?'checked':'',
|
||||
-value=> 1,
|
||||
-label => '',
|
||||
-id=> 'opacshow'),
|
||||
intrashow => CGI::checkbox(-name=>'intrashow',
|
||||
-checked=> $data->{'intrashow'}?'checked':'',
|
||||
-value=> 1,
|
||||
-label => '',
|
||||
-id=> 'intrashow'),
|
||||
|
||||
|
||||
);
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
my $id =$input->param('id');
|
||||
|
||||
$sth=$dbh->prepare("replace koha_attr set id=?,marctokoha=?,attr=?,liblibrarian=?,sorts=?,recordtype=?,tagfield=?,tagsubfield=? ,opacshow=?,intrashow=? ");
|
||||
|
||||
|
||||
my $marctokoha =$input->param('marctokoha');
|
||||
my $attr =$input->param('attr');
|
||||
my $liblibrarian = $input->param('liblibrarian');
|
||||
my $sorts =$input->param('sorts');
|
||||
my $opacshow =$input->param('opacshow');
|
||||
my $intrashow =$input->param('intrashow');
|
||||
my $recordtype =$input->param('recordtype');
|
||||
my $tagfield =$input->param('tagfield');
|
||||
my $tagsubfield =$input->param('tagsubfield');
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
$sth->execute( $id,$marctokoha,$attr,$liblibrarian,$sorts?1:0,$recordtype,$tagfield,$tagsubfield,$opacshow?1:0,$intrashow?1:0);
|
||||
}
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=koha_attr.pl?searchfield=$marctokoha\"></html>";
|
||||
|
||||
exit;
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DELETE_CONFIRM ##################################
|
||||
# called by default form, used to confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirm') {
|
||||
$sth=$dbh->prepare("select id,marctokoha,liblibrarian,recordtype from koha_attr where id=? ");
|
||||
$sth->execute($id);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
$template->param(liblibrarian => $data->{'liblibrarian'}."/". $data->{'recordtype'},id=>$data->{'id'},
|
||||
searchfield => $searchfield,
|
||||
);
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
################## DELETE_CONFIRMED ##################################
|
||||
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
||||
} elsif ($op eq 'delete_confirmed') {
|
||||
|
||||
unless (C4::Context->config('demo') eq 1) {
|
||||
$dbh->do("delete from koha_attr where id=$id ");
|
||||
}
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
# here, $op can be unset or set
|
||||
if ($searchfield ne '') {
|
||||
$template->param(searchfield => $searchfield);
|
||||
}
|
||||
my $cnt=0;
|
||||
if ($dspchoice) {
|
||||
#here, user only wants used tags/subfields displayed
|
||||
my $sth=$dbh->prepare("Select * from koha_attr where tagfield <>'' and marctokoha >= ? ");
|
||||
#could be ordoned by tab
|
||||
$sth->execute($searchfield);
|
||||
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
$cnt++;
|
||||
}
|
||||
|
||||
$sth->finish;
|
||||
|
||||
my $toggle=0;
|
||||
my @loop_data = ();
|
||||
my $j=1;
|
||||
my $i=$offset;
|
||||
while ($i < ($offset+$pagesize<$cnt?$offset+$pagesize:$cnt)) {
|
||||
if ($toggle eq 0){
|
||||
$toggle=1;
|
||||
} else {
|
||||
$toggle=0;
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{id} = $results[$i]->{'id'};
|
||||
$row_data{marctokoha} = $results[$i]->{'marctokoha'};
|
||||
$row_data{liblibrarian} = $results[$i]->{'liblibrarian'};
|
||||
$row_data{sorts} = $results[$i]->{'sorts'};
|
||||
$row_data{attr} = $results[$i]->{'attr'};
|
||||
$row_data{recordtype} = $results[$i]->{'recordtype'};
|
||||
$row_data{tagfield} = $results[$i]->{'tagfield'};
|
||||
$row_data{tagsubfield} = $results[$i]->{'tagsubfield'};
|
||||
$row_data{opacshow} = $results[$i]->{'opacshow'};
|
||||
$row_data{intrashow} = $results[$i]->{'intrashow'};
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results[$i]->{'marctokoha'}."&id=".$results[$i]->{'id'};
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results[$i]->{'marctokoha'}."&id=".$results[$i]->{'id'};
|
||||
$row_data{toggle} = $toggle;
|
||||
push(@loop_data, \%row_data);
|
||||
$i++;
|
||||
}
|
||||
$template->param(select_display => "True",
|
||||
loop => \@loop_data);
|
||||
$sth->finish;
|
||||
} else {
|
||||
#here, normal old style : display every tags
|
||||
my ($count,@results)=StringSearch($dbh,$searchfield);
|
||||
$cnt = $count;
|
||||
my $toggle=0;
|
||||
my @loop_data = ();
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
if ($toggle eq 0){
|
||||
$toggle=1;
|
||||
} else {
|
||||
$toggle=0;
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{id} = $results[$i]->{'id'};
|
||||
$row_data{marctokoha} = $results[$i]->{marctokoha};
|
||||
$row_data{liblibrarian} = $results[$i]->{liblibrarian};
|
||||
$row_data{sorts} = $results[$i]->{sorts};
|
||||
$row_data{opacshow} = $results[$i]->{'opacshow'};
|
||||
$row_data{intrashow} = $results[$i]->{'intrashow'};
|
||||
$row_data{attr} = $results[$i]->{attr};
|
||||
$row_data{recordtype} = $results[$i]->{'recordtype'};
|
||||
$row_data{tagfield} = $results[$i]->{'tagfield'};
|
||||
$row_data{tagsubfield} = $results[$i]->{'tagsubfield'};
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results[$i]->{marctokoha}."&id=".$results[$i]->{'id'};
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results[$i]->{marctokoha}."&id=".$results[$i]->{'id'};
|
||||
$row_data{toggle} = $toggle;
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data);
|
||||
}
|
||||
if ($offset>0) {
|
||||
my $prevpage = $offset-$pagesize;
|
||||
$template->param(isprevpage => $offset,
|
||||
prevpage=> $prevpage,
|
||||
searchfield => $searchfield,
|
||||
script_name => $script_name,
|
||||
|
||||
);
|
||||
}
|
||||
if ($offset+$pagesize<$cnt) {
|
||||
my $nextpage =$offset+$pagesize;
|
||||
$template->param(nextpage =>$nextpage,
|
||||
searchfield => $searchfield,
|
||||
script_name => $script_name,
|
||||
|
||||
);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
|
||||
$template->param(loggeninuser => $loggedinuser,
|
||||
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
||||
#
|
||||
# the sub used for searches
|
||||
#
|
||||
sub StringSearch {
|
||||
my ($dbh,$searchstring)=@_;
|
||||
my $sth=$dbh->prepare("Select * from koha_attr where marctokoha >=? order by marctokoha");
|
||||
$sth->execute($searchstring);
|
||||
my @dataresults;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@dataresults,$data);
|
||||
|
||||
}
|
||||
|
||||
$sth->finish;
|
||||
return (scalar(@dataresults),@dataresults);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -42,7 +42,6 @@ use CGI;
|
|||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Search;
|
||||
use HTML::Template;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
|
||||
|
|
@ -181,9 +180,6 @@ if ($op eq 'add_form') {
|
|||
}
|
||||
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,12 +45,8 @@ use C4::Koha;
|
|||
use C4::Output;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Search;
|
||||
use HTML::Template;
|
||||
use C4::Context;
|
||||
|
||||
|
||||
# Fix me, shouldnt we store this stuff in the systempreferences table?
|
||||
|
||||
my %tabsysprefs;
|
||||
# Acquisitions
|
||||
$tabsysprefs{acquisitions}="Acquisitions";
|
||||
|
|
@ -73,20 +69,37 @@ my %tabsysprefs;
|
|||
$tabsysprefs{marcflavour}="Catalogue";
|
||||
$tabsysprefs{serialsadditems}="Catalogue";
|
||||
$tabsysprefs{sortbynonfiling}="Catalogue";
|
||||
$tabsysprefs{MARCOrgCode}="Catalogue";
|
||||
$tabsysprefs{z3950AuthorAuthFields}="Catalogue";
|
||||
$tabsysprefs{z3950NormalizeAuthor}="Catalogue";
|
||||
$tabsysprefs{SQLorZEBRA}="Catalogue";
|
||||
# Circulation
|
||||
$tabsysprefs{maxoutstanding}="Circulation";
|
||||
$tabsysprefs{maxreserves}="Circulation";
|
||||
$tabsysprefs{noissuescharge}="Circulation";
|
||||
$tabsysprefs{IssuingInProcess}="Circulation";
|
||||
$tabsysprefs{patronimages}="Circulation";
|
||||
$tabsysprefs{printcirculationslips}="Circulation";
|
||||
$tabsysprefs{ReturnBeforeExpiry}="Circulation";
|
||||
$tabsysprefs{allowrenewalsbefore}="Circulation";
|
||||
$tabsysprefs{defaultBranch}="Circulation";
|
||||
$tabsysprefs{strictrenewals}="Circulation";
|
||||
# Intranet
|
||||
$tabsysprefs{TemplateEncoding}="Intranet";
|
||||
$tabsysprefs{template}="Intranet";
|
||||
$tabsysprefs{intranetstylesheet}="Intranet";
|
||||
$tabsysprefs{IntranetNav}="Intranet";
|
||||
$tabsysprefs{intranetcolorstylesheet}="Intranet";
|
||||
$tabsysprefs{Activate_Log}="Intranet";
|
||||
$tabsysprefs{allowrenewalsbefore}="Intranet";
|
||||
|
||||
$tabsysprefs{zebrawait}="Intranet";
|
||||
$tabsysprefs{retrieve_from}="Intranet";
|
||||
$tabsysprefs{batchMode}="Intranet";
|
||||
|
||||
# Members
|
||||
$tabsysprefs{automembernum}="Members";
|
||||
$tabsysprefs{checkdigit}="Members";
|
||||
$tabsysprefs{NotifyBorrowerDeparture}="Members";
|
||||
$tabsysprefs{memberofinstitution}="Members";
|
||||
$tabsysprefs{ReadingHistory}="Members";
|
||||
# OPAC
|
||||
$tabsysprefs{AmazonAssocTag}="OPAC";
|
||||
$tabsysprefs{AmazonContent}="OPAC";
|
||||
|
|
@ -113,6 +126,8 @@ my %tabsysprefs;
|
|||
$tabsysprefs{SubscriptionHistory}="OPAC";
|
||||
$tabsysprefs{suggestion}="OPAC";
|
||||
$tabsysprefs{virtualshelves}="OPAC";
|
||||
$tabsysprefs{opacheader}="OPAC";
|
||||
$tabsysprefs{allowrenewsfromopac}="OPAC";
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
|
|
@ -157,14 +172,13 @@ sub StringSearch {
|
|||
return ($cnt,\@results);
|
||||
}
|
||||
|
||||
|
||||
my $input = new CGI;
|
||||
my $searchfield=$input->param('searchfield');
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => "parameters/systempreferences.tmpl",
|
||||
= get_template_and_user({template_name => "admin/systempreferences.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
|
|
@ -177,10 +191,10 @@ $searchfield=~ s/\,//g;
|
|||
|
||||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
$op => 1,); # we show only the TMPL_VAR names $op
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
else => 1,); # we show only the TMPL_VAR names $op
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
if ($op eq 'update_and_reedit') {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ use C4::Interface::CGI::Output;
|
|||
use C4::Context;
|
||||
use C4::Output;
|
||||
use C4::Search;
|
||||
use HTML::Template;
|
||||
use C4::Authorities;
|
||||
|
||||
my $input = new CGI;
|
||||
|
|
@ -153,7 +152,6 @@ if ($op eq 'add_form') {
|
|||
-values=> \@category_list,
|
||||
-default=>"$search_category",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
if (!$search_category) {
|
||||
|
|
@ -202,7 +200,6 @@ if ($op eq 'add_form') {
|
|||
-values=> \@category_list,
|
||||
-default=>"$search_category",
|
||||
-size=>1,
|
||||
-tabindex=>'',
|
||||
-multiple=>0,
|
||||
);
|
||||
if (!$search_category) {
|
||||
|
|
@ -265,8 +262,5 @@ if ($op eq 'add_form') {
|
|||
$template->param(next => "$script_name?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$nextpage");
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use strict;
|
|||
use C4::Auth;
|
||||
use CGI;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
use C4::Koha;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Log;
|
||||
|
|
@ -31,7 +30,7 @@ use Date::Manip;
|
|||
|
||||
=head1 NAME
|
||||
|
||||
plugin that shows a stats on borrowers
|
||||
plugin that shows a stats on catalogers
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ plugin that shows a stats on borrowers
|
|||
|
||||
my $input = new CGI;
|
||||
my $do_it=$input->param('do_it');
|
||||
my $fullreportname = "admin/viewlog.tmpl";
|
||||
my $fullreportname = "parameters/viewlog.tmpl";
|
||||
my $modulename = $input->param("module");
|
||||
my $userfilter = $input->param("user");
|
||||
my $actionfilter = $input->param("action");
|
||||
|
|
@ -53,7 +52,7 @@ my $mime = $input->param("MIME");
|
|||
my $del = $input->param("sep");
|
||||
my $output = $input->param("output");
|
||||
|
||||
#warn "module : ".$modulename;
|
||||
|
||||
my ($template, $borrowernumber, $cookie)
|
||||
= get_template_and_user({template_name => $fullreportname,
|
||||
query => $input,
|
||||
|
|
@ -86,7 +85,7 @@ if ($do_it) {
|
|||
my ($count, $results) = displaylog( $modulename, @filters);
|
||||
if ($output eq "screen"){
|
||||
# Printing results to screen
|
||||
$template->param(modulename =>$modulename, $modulename => 1, looprow => $results);
|
||||
$template->param(modulename =>$modulename, $modulename => 1, looprow => $results,counter=>$count);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
exit(1);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ use strict;
|
|||
use C4::Output;
|
||||
use CGI;
|
||||
use C4::Search;
|
||||
use C4::Database;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
|
||||
|
|
@ -200,8 +198,5 @@ if ($op eq 'add_form') {
|
|||
nextpage => $offset+$pagesize);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
|
||||
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
|
||||
IntranetNav => C4::Context->preference("IntranetNav"),
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
|
|
|||
Loading…
Reference in New Issue