X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=admin%2Fmarctagstructure.pl;h=a86d78841b34a755b8508249b9d6e7bf7a01f010;hb=e11a6b20256545292fc864de8e96ba68cde52d7a;hp=5c805eaf491c12fcfa8200c073170f9cdb42d5e7;hpb=6ffc27d72f9d123a964bbdb8813791618c1dafce;p=koha_fer
diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl
index 5c805eaf49..a86d78841b 100755
--- a/admin/marctagstructure.pl
+++ b/admin/marctagstructure.pl
@@ -14,43 +14,41 @@
# 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
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
+use warnings;
use CGI;
use C4::Auth;
use C4::Koha;
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;
-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 $frameworkcode = $input->param('frameworkcode') || ''; # set to select framework
+my $existingframeworkcode = $input->param('existingframeworkcode') || '';
+my $searchfield = $input->param('searchfield') || 0;
+# set when we have to create a new framework (in frameworkcode) by copying an old one (in 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 $pagesize=20;
+my $offset = $input->param('offset') || 0;
+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/marctagstructure.pl";
my $dbh = C4::Context->dbh;
# open template
my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "parameters/marctagstructure.tmpl",
+ = get_template_and_user({template_name => "admin/marctagstructure.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
@@ -62,39 +60,34 @@ my ($template, $loggedinuser, $cookie)
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;
+ push @frameworkloop, {
+ value => $thisframeworkcode,
+ selected => ($thisframeworkcode eq $frameworkcode) ? 1 : 0,
+ frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
+ };
}
# 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 {
+unless ($frameworkexist) {
# 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
+ $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
-}
+$template->param(
+ frameworkloop => \@frameworkloop,
+ frameworkcode => $frameworkcode,
+ frameworktext => $frameworkinfo->{frameworktext},
+ script_name => $script_name,
+ ($op||'else') => 1,
+);
################## ADD_FORM ##################################
@@ -106,7 +99,6 @@ if ($op eq 'add_form') {
$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;
}
my $sth = $dbh->prepare("select distinct category from authorised_values");
$sth->execute;
@@ -118,71 +110,100 @@ if ($op eq 'add_form') {
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 => "$searchfield");
- $template->param('heading-modify-tag-p' => 1);
+ $template->param(searchfield => $searchfield);
+ $template->param(action => "Modify tag");
+ $template->param('heading_modify_tag_p' => 1);
} else {
- $template->param(action => "Add tag",
- searchfield => "");
- $template->param('heading-add-tag-p' => 1);
+ $template->param(action => "Add tag");
+ $template->param('heading_add_tag_p' => 1);
}
- $template->param('use-heading-flags-p' => 1);
+ $template->param('use_heading_flags_p' => 1);
$template->param(liblibrarian => $data->{'liblibrarian'},
- libopac => $data->{'libopac'},
- repeatable => CGI::checkbox('repeatable',$data->{'repeatable'}?'checked':'',1,''),
- mandatory => CGI::checkbox('mandatory',$data->{'mandatory'}?'checked':'',1,''),
- authorised_value => $authorised_value,
- frameworkcode => $frameworkcode,
- );
+ 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,
+ ); # FIXME: move checkboxes to presentation layer
# 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,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
- );
+ my $tagfield = $input->param('tagfield');
+ my $liblibrarian = $input->param('liblibrarian');
+ my $libopac = $input->param('libopac');
+ my $repeatable = $input->param('repeatable') ? 1 : 0;
+ my $mandatory = $input->param('mandatory') ? 1 : 0;
+ my $authorised_value = $input->param('authorised_value');
+ unless (C4::Context->config('demo') == 1) {
+ if ($input->param('modif')) {
+ $sth = $dbh->prepare(
+ "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
+ );
+ $sth->execute( $liblibrarian,
+ $libopac,
+ $repeatable,
+ $mandatory,
+ $authorised_value,
+ $frameworkcode,
+ $tagfield
+ );
+ } else {
+ $sth = $dbh->prepare(
+ "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)"
+ );
+ $sth->execute($tagfield,
+ $liblibrarian,
+ $libopac,
+ $repeatable,
+ $mandatory,
+ $authorised_value,
+ $frameworkcode
+ );
+ }
}
- $sth->finish;
- print "Content-Type: text/html\n\n