* frameworks and itemtypes are independant
* bugfixes in authority types & framework management (mainly deletion)
This commit is contained in:
parent
5f4179a6c3
commit
af996a21e8
5 changed files with 272 additions and 88 deletions
|
@ -238,8 +238,8 @@ 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 tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,value_builder from auth_subfield_structure where tagfield=? and tagsubfield=? and itemtype=?");
|
||||
$sth->execute($tagfield,$tagsubfield);
|
||||
my $sth=$dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,value_builder from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?");
|
||||
$sth->execute($tagfield,$tagsubfield,$authtypecode);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
$template->param(liblibrarian => $data->{'liblibrarian'},
|
||||
|
@ -257,6 +257,7 @@ if ($op eq 'add_form') {
|
|||
unless (C4::Context->config('demo') eq 1) {
|
||||
my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?");
|
||||
$sth->execute($tagfield,$tagsubfield,$authtypecode);
|
||||
warn "DEL : $tagfield,$tagsubfield,$authtypecode";
|
||||
$sth->finish;
|
||||
}
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode\"></html>";
|
||||
|
@ -287,6 +288,9 @@ if ($op eq 'add_form') {
|
|||
$row_data{value_builder} = $results->[$i]{'value_builder'};
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}."&authtypecode=$authtypecode";
|
||||
$row_data{bgcolor} = $toggle;
|
||||
if ($row_data{tab} eq -1) {
|
||||
$row_data{subfield_ignored} = 1;
|
||||
}
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data);
|
||||
|
|
|
@ -106,7 +106,6 @@ if ($op eq 'add_form') {
|
|||
#start the page and read in includes
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
# Check both categoryitem and biblioitems, see Bug 199
|
||||
my $total = 0;
|
||||
for my $table ('auth_tag_structure') {
|
||||
my $sth=$dbh->prepare("select count(*) as total from $table where authtypecode=?");
|
||||
|
@ -115,7 +114,7 @@ if ($op eq 'add_form') {
|
|||
$sth->finish;
|
||||
}
|
||||
|
||||
my $sth=$dbh->prepare("select authtypecode,authtypetext from authtypes where authtypecode=?");
|
||||
my $sth=$dbh->prepare("select authtypecode,authtypetext from auth_types where authtypecode=?");
|
||||
$sth->execute($authtypecode);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
@ -130,7 +129,11 @@ if ($op eq 'add_form') {
|
|||
#start the page and read in includes
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $authtypecode=uc($input->param('authtypecode'));
|
||||
my $sth=$dbh->prepare("delete from auth_types where authtypecode=?");
|
||||
my $sth=$dbh->prepare("delete from auth_tag_structure where authtypecode=?");
|
||||
$sth->execute($authtypecode);
|
||||
$sth=$dbh->prepare("delete from auth_subfield_structure where authtypecode=?");
|
||||
$sth->execute($authtypecode);
|
||||
$sth=$dbh->prepare("delete from auth_types where authtypecode=?");
|
||||
$sth->execute($authtypecode);
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authtypes.pl\"></html>";
|
||||
|
|
173
admin/biblio_framework.pl
Executable file
173
admin/biblio_framework.pl
Executable file
|
@ -0,0 +1,173 @@
|
|||
#!/usr/bin/perl
|
||||
# NOTE: 4-character tabs
|
||||
|
||||
#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)
|
||||
|
||||
# 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::Context;
|
||||
use C4::Output;
|
||||
use C4::Search;
|
||||
use C4::Auth;
|
||||
use C4::Interface::CGI::Output;
|
||||
use HTML::Template;
|
||||
|
||||
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 * from biblio_framework where (frameworkcode like ?) order by frameworktext");
|
||||
$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('frameworkcode');
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/biblio_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 => "parameters/biblio_framework.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') {
|
||||
#start the page and read in includes
|
||||
#---- if primkey exists, it's a modify action, so read values to modify...
|
||||
my $data;
|
||||
if ($frameworkcode) {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select * from biblio_framework where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
$template->param(frameworkcode => $frameworkcode,
|
||||
frameworktext => $data->{'frameworktext'},
|
||||
);
|
||||
;
|
||||
# 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 $sth=$dbh->prepare("replace biblio_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>";
|
||||
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') {
|
||||
#start the page and read in includes
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
# Check both categoryitem and biblioitems, see Bug 199
|
||||
my $total = 0;
|
||||
for my $table ('marc_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=?");
|
||||
$sth->execute($frameworkcode);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
||||
$template->param(frameworkcode => $frameworkcode,
|
||||
frameworktext => $data->{'frameworktext'},
|
||||
total => $total);
|
||||
# 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') {
|
||||
#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=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$sth=$dbh->prepare("delete from marc_subfield_structure where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
$sth=$dbh->prepare("delete from biblio_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>";
|
||||
exit;
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
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++){
|
||||
my %row_data;
|
||||
if ($toggle eq 'white'){
|
||||
$row_data{toggle}="#ffffcc";
|
||||
} else {
|
||||
$row_data{toggle}="white";
|
||||
}
|
||||
$row_data{frameworkcode} = $results->[$i]{'frameworkcode'};
|
||||
$row_data{frameworktext} = $results->[$i]{'frameworktext'};
|
||||
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
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 4
|
||||
# End:
|
|
@ -28,13 +28,13 @@ use C4::Context;
|
|||
use HTML::Template;
|
||||
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$itemtype)=@_;
|
||||
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 marc_subfield_structure where (tagfield like ? and itemtype=?) order by tagfield");
|
||||
$sth->execute("$searchstring%",$itemtype);
|
||||
my $sth=$dbh->prepare("Select * from marc_subfield_structure where (tagfield like ? and frameworkcode=?) order by tagfield");
|
||||
$sth->execute("$searchstring%",$frameworkcode);
|
||||
my @results;
|
||||
my $cnt=0;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
|
@ -49,7 +49,7 @@ sub StringSearch {
|
|||
my $input = new CGI;
|
||||
my $tagfield=$input->param('tagfield');
|
||||
my $tagsubfield=$input->param('tagsubfield');
|
||||
my $itemtype=$input->param('itemtype');
|
||||
my $frameworkcode=$input->param('frameworkcode');
|
||||
my $pkfield="tagfield";
|
||||
my $offset=$input->param('offset');
|
||||
my $script_name="/cgi-bin/koha/admin/marc_subfields_structure.pl";
|
||||
|
@ -69,12 +69,12 @@ $tagfield=~ s/\,//g;
|
|||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
tagfield =>$tagfield,
|
||||
itemtype => $itemtype,
|
||||
frameworkcode => $frameworkcode,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
tagfield =>$tagfield,
|
||||
itemtype => $itemtype,
|
||||
frameworkcode => $frameworkcode,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
|
@ -139,8 +139,8 @@ if ($op eq 'add_form') {
|
|||
closedir DIR;
|
||||
|
||||
# build values list
|
||||
my $sth=$dbh->prepare("select * from marc_subfield_structure where tagfield=? and itemtype=?"); # and tagsubfield='$tagsubfield'");
|
||||
$sth->execute($tagfield,$itemtype);
|
||||
my $sth=$dbh->prepare("select * from marc_subfield_structure where tagfield=? and frameworkcode=?"); # and tagsubfield='$tagsubfield'");
|
||||
$sth->execute($tagfield,$frameworkcode);
|
||||
my @loop_data = ();
|
||||
my $toggle="white";
|
||||
my $i=0;
|
||||
|
@ -253,7 +253,7 @@ 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,thesaurus_category,value_builder,hidden,isurl,itemtype)
|
||||
my $sth=$dbh->prepare("replace marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,thesaurus_category,value_builder,hidden,isurl,frameworkcode)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
my @tagsubfield = $input->param('tagsubfield');
|
||||
my @liblibrarian = $input->param('liblibrarian');
|
||||
|
@ -296,13 +296,13 @@ if ($op eq 'add_form') {
|
|||
$value_builder,
|
||||
$hidden,
|
||||
$isurl,
|
||||
$itemtype,
|
||||
$frameworkcode,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&itemtype=$itemtype\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
|
||||
exit;
|
||||
|
||||
# END $OP eq ADD_VALIDATE
|
||||
|
@ -310,7 +310,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 itemtype=?");
|
||||
my $sth=$dbh->prepare("select * from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
|
||||
$sth->execute($tagfield,$tagsubfield);
|
||||
my $data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
|
@ -319,7 +319,7 @@ if ($op eq 'add_form') {
|
|||
delete_link => $script_name,
|
||||
tagfield =>$tagfield,
|
||||
tagsubfield => $tagsubfield,
|
||||
itemtype => $itemtype,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
################## DELETE_CONFIRMED ##################################
|
||||
|
@ -327,18 +327,18 @@ 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 itemtype=?");
|
||||
$sth->execute($tagfield,$tagsubfield,$itemtype);
|
||||
my $sth=$dbh->prepare("delete from marc_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&itemtype=$itemtype\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_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,$itemtype);
|
||||
my ($count,$results)=StringSearch($env,$tagfield,$frameworkcode);
|
||||
my $toggle="white";
|
||||
my @loop_data = ();
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
|
@ -361,7 +361,7 @@ if ($op eq 'add_form') {
|
|||
$row_data{value_builder} = $results->[$i]{'value_builder'};
|
||||
$row_data{hidden} = $results->[$i]{'hidden'};
|
||||
$row_data{isurl} = $results->[$i]{'isurl'};
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}."&itemtype=$itemtype";
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}."&frameworkcode=$frameworkcode";
|
||||
$row_data{bgcolor} = $toggle;
|
||||
if ($row_data{tab} eq -1) {
|
||||
$row_data{subfield_ignored} = 1;
|
||||
|
@ -370,7 +370,7 @@ if ($op eq 'add_form') {
|
|||
push(@loop_data, \%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data);
|
||||
$template->param(edit => "<a href=\"$script_name?op=add_form&tagfield=$tagfield&itemtype=$itemtype\">");
|
||||
$template->param(edit => "<a href=\"$script_name?op=add_form&tagfield=$tagfield&frameworkcode=$frameworkcode\">");
|
||||
if ($offset>0) {
|
||||
my $prevpage = $offset-$pagesize;
|
||||
$template->param(prev =>"<a href=\"$script_name?offset=$prevpage\">");
|
||||
|
|
|
@ -31,11 +31,11 @@ use HTML::Template;
|
|||
|
||||
# retrieve parameters
|
||||
my $input = new CGI;
|
||||
my $itemtype = $input->param('itemtype'); # set to select framework
|
||||
$itemtype="" unless $itemtype;
|
||||
my $existingitemtype = $input->param('existingitemtype'); # set when we have to create a new framework (in itemtype) by copying an old one (in existingitemtype)
|
||||
$existingitemtype = "" unless $existingitemtype;
|
||||
my $itemtypeinfo = getitemtypeinfo($itemtype);
|
||||
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;
|
||||
|
@ -58,33 +58,36 @@ my ($template, $loggedinuser, $cookie)
|
|||
debug => 1,
|
||||
});
|
||||
|
||||
# get itemtype list
|
||||
my $itemtypes = getitemtypes;
|
||||
my @itemtypesloop;
|
||||
foreach my $thisitemtype (keys %$itemtypes) {
|
||||
my $selected = 1 if $thisitemtype eq $itemtype;
|
||||
my %row =(value => $thisitemtype,
|
||||
# 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,
|
||||
description => $itemtypes->{$thisitemtype}->{'description'},
|
||||
frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
|
||||
);
|
||||
push @itemtypesloop, \%row;
|
||||
push @frameworkloop, \%row;
|
||||
}
|
||||
|
||||
# check that itemtype framework is defined in marc_tag_structure
|
||||
my $sth=$dbh->prepare("select count(*) from marc_tag_structure where itemtype=?");
|
||||
$sth->execute($itemtype);
|
||||
my ($itemtypeexist) = $sth->fetchrow;
|
||||
if ($itemtypeexist) {
|
||||
# check that framework is defined in marc_tag_structure
|
||||
my $sth=$dbh->prepare("select count(*) from marc_tag_structure where frameworkcode=?");
|
||||
$sth->execute($frameworkcode);
|
||||
my ($frameworkexist) = $sth->fetchrow;
|
||||
if ($frameworkexist) {
|
||||
} else {
|
||||
# if itemtype does not exists, then OP must be changed to "create itemtype" if we are not on the way to create it
|
||||
# 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 "itemtype_create_confirm") {
|
||||
duplicate_framework($itemtype, $existingitemtype);
|
||||
if ($op eq "framework_create_confirm") {
|
||||
duplicate_framework($frameworkcode, $existingframeworkcode);
|
||||
$op=""; # unset $op to go back to framework list
|
||||
} else {
|
||||
$op = "itemtype_create";
|
||||
$op = "framework_create";
|
||||
}
|
||||
}
|
||||
$template->param(itemtypeloop => \@itemtypesloop);
|
||||
$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
|
||||
|
@ -100,8 +103,8 @@ 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 itemtype=?");
|
||||
$sth->execute($searchfield,$itemtype);
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?");
|
||||
$sth->execute($searchfield,$frameworkcode);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
|
@ -134,13 +137,13 @@ if ($op eq 'add_form') {
|
|||
repeatable => CGI::checkbox('repeatable',$data->{'repeatable'}?'checked':'',1,''),
|
||||
mandatory => CGI::checkbox('mandatory',$data->{'mandatory'}?'checked':'',1,''),
|
||||
authorised_value => $authorised_value,
|
||||
itemtype => $itemtype,
|
||||
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 marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,itemtype) values (?,?,?,?,?,?,?)");
|
||||
$sth=$dbh->prepare("replace marc_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');
|
||||
|
@ -154,58 +157,59 @@ if ($op eq 'add_form') {
|
|||
$repeatable?1:0,
|
||||
$mandatory?1:0,
|
||||
$authorised_value,
|
||||
$itemtype
|
||||
$frameworkcode
|
||||
);
|
||||
}
|
||||
$sth->finish;
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.pl?tagfield=$tagfield&itemtype=$itemtype\"></html>";
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.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') {
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=?");
|
||||
$sth->execute($searchfield);
|
||||
$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_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 marc_tag_structure where tagfield='$searchfield'");
|
||||
$dbh->do("delete from marc_subfield_structure where tagfield='$searchfield'");
|
||||
$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'");
|
||||
}
|
||||
# END $OP eq DELETE_CONFIRMED
|
||||
################## ITEMTYPE_CREATE ##################################
|
||||
# called automatically if an unexisting itemtype is selected
|
||||
} elsif ($op eq 'itemtype_create') {
|
||||
$sth = $dbh->prepare("select count(*),marc_tag_structure.itemtype,description from marc_tag_structure,itemtypes where itemtypes.itemtype=marc_tag_structure.itemtype group by marc_tag_structure.itemtype");
|
||||
# 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->execute;
|
||||
my @existingitemtypeloop;
|
||||
while (my ($tot,$thisitemtype,$description) = $sth->fetchrow) {
|
||||
my @existingframeworkloop;
|
||||
while (my ($tot,$thisframeworkcode,$frameworktext) = $sth->fetchrow) {
|
||||
if ($tot>0) {
|
||||
my %line = ( value => $thisitemtype,
|
||||
description => $description,
|
||||
my %line = ( value => $thisframeworkcode,
|
||||
frameworktext => $frameworktext,
|
||||
);
|
||||
push @existingitemtypeloop,\%line;
|
||||
push @existingframeworkloop,\%line;
|
||||
}
|
||||
}
|
||||
$template->param(existingitemtypeloop => \@existingitemtypeloop,
|
||||
itemtype => $itemtype,
|
||||
ITdescription => $itemtypeinfo->{description},
|
||||
$template->param(existingframeworkloop => \@existingframeworkloop,
|
||||
frameworkcode => $frameworkcode,
|
||||
# FRtext => $frameworkinfo->{frameworktext},
|
||||
);
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
# here, $op can be unset or set to "itemtype_create_confirm".
|
||||
# here, $op can be unset or set to "framework_create_confirm".
|
||||
if ($searchfield ne '') {
|
||||
$template->param(searchfield => $searchfield);
|
||||
}
|
||||
my $env;
|
||||
my ($count,$results)=StringSearch($env,$searchfield,$itemtype);
|
||||
my ($count,$results)=StringSearch($env,$searchfield,$frameworkcode);
|
||||
my $toggle="white";
|
||||
my @loop_data = ();
|
||||
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
|
||||
|
@ -220,9 +224,9 @@ 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'}."&itemtype=".$itemtype;
|
||||
$row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'tagfield'}."&itemtype=".$itemtype;
|
||||
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}."&itemtype=".$itemtype;
|
||||
$row_data{subfield_link} ="marc_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{bgcolor} = $toggle;
|
||||
push(@loop_data, \%row_data);
|
||||
}
|
||||
|
@ -233,7 +237,7 @@ if ($op eq 'add_form') {
|
|||
prevpage=> $prevpage,
|
||||
searchfield => $searchfield,
|
||||
script_name => $script_name,
|
||||
itemtype => $itemtype,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
}
|
||||
if ($offset+$pagesize<$count) {
|
||||
|
@ -241,7 +245,7 @@ if ($op eq 'add_form') {
|
|||
$template->param(nextpage =>$nextpage,
|
||||
searchfield => $searchfield,
|
||||
script_name => $script_name,
|
||||
itemtype => $itemtype,
|
||||
frameworkcode => $frameworkcode,
|
||||
);
|
||||
}
|
||||
} #---- END $OP eq DEFAULT
|
||||
|
@ -254,13 +258,13 @@ output_html_with_http_headers $input, $cookie, $template->output;
|
|||
# the sub used for searches
|
||||
#
|
||||
sub StringSearch {
|
||||
my ($env,$searchstring,$itemtype)=@_;
|
||||
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 marc_tag_structure where (tagfield >= ? and itemtype=?) order by tagfield");
|
||||
$sth->execute($data[0], $itemtype);
|
||||
my $sth=$dbh->prepare("Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_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);
|
||||
|
@ -274,19 +278,19 @@ sub StringSearch {
|
|||
# the sub used to duplicate a framework from an existing one in MARC parameters tables.
|
||||
#
|
||||
sub duplicate_framework {
|
||||
my ($newitemtype,$olditemtype) = @_;
|
||||
my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where itemtype=?");
|
||||
$sth->execute($olditemtype);
|
||||
my $sth_insert = $dbh->prepare("insert into marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, itemtype) values (?,?,?,?,?,?,?)");
|
||||
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,$newitemtype);
|
||||
$sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode);
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("select itemtype,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,value_builder,seealso from marc_subfield_structure where itemtype=?");
|
||||
$sth->execute($olditemtype);
|
||||
$sth_insert = $dbh->prepare("insert into marc_subfield_structure (itemtype,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,value_builder,seealso) values (?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
while ( my ($itemtype, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso) = $sth->fetchrow) {
|
||||
$sth_insert->execute($newitemtype, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso);
|
||||
$sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,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,thesaurus_category,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue