From 5b4d5b6a0ed3d14a46ed3da5058caff2602573a2 Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Fri, 2 Nov 2007 15:26:07 +0100 Subject: [PATCH] #1546 REPLACE statements (continued) - biblio framework - marc tag - auth tag Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- admin/auth_tag_structure.pl | 58 +++++++++++++------ admin/biblio_framework.pl | 12 +++- admin/marctagstructure.pl | 55 ++++++++++++------ .../en/modules/admin/auth_tag_structure.tmpl | 1 + .../prog/en/modules/admin/authtypes.tmpl | 2 +- .../en/modules/admin/biblio_framework.tmpl | 2 +- .../en/modules/admin/marctagstructure.tmpl | 2 +- 7 files changed, 91 insertions(+), 41 deletions(-) diff --git a/admin/auth_tag_structure.pl b/admin/auth_tag_structure.pl index cfa54e0ffd..106c13649b 100755 --- a/admin/auth_tag_structure.pl +++ b/admin/auth_tag_structure.pl @@ -143,24 +143,46 @@ 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 auth_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,authtypecode) 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, - $authtypecode - ); - } - $sth->finish; + if ($input->param('modif')) { + $sth=$dbh->prepare("UPDATE auth_tag_structure SET tagfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, authorised_value=? WHERE authtypecode=? AND tagfield=?"); + 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( + $liblibrarian, + $libopac, + $repeatable?1:0, + $mandatory?1:0, + $authorised_value, + $authtypecode, + $tagfield, + ); + } + $sth->finish; + } else { + $sth=$dbh->prepare("INSERT INTO auth_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,authtypecode) 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, + $authtypecode + ); + } + $sth->finish; + } print "Content-Type: text/html\n\n"; exit; # END $OP eq ADD_VALIDATE diff --git a/admin/biblio_framework.pl b/admin/biblio_framework.pl index 4568a17101..c388762795 100755 --- a/admin/biblio_framework.pl +++ b/admin/biblio_framework.pl @@ -95,9 +95,15 @@ 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 (?,?)"); - $sth->execute($input->param('frameworkcode'),$input->param('frameworktext')); - $sth->finish; + if ($input->param('modif')) { + my $sth=$dbh->prepare("UPDATE biblio_framework SET frameworktext=? WHERE frameworkcode=?"); + $sth->execute($input->param('frameworktext'),$input->param('frameworkcode')); + $sth->finish; + } else { + my $sth=$dbh->prepare("INSERT into biblio_framework (frameworkcode,frameworktext) values (?,?)"); + $sth->execute($input->param('frameworkcode'),$input->param('frameworktext')); + $sth->finish; + } print "Content-Type: text/html\n\n"; exit; # END $OP eq ADD_VALIDATE diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index 78cc6eb6b6..b98d965f99 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -153,24 +153,45 @@ 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 (?,?,?,?,?,?,?)"); - 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 - ); + if ($input->param('modif')) { + $sth=$dbh->prepare("UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"); + 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( $liblibrarian, + $libopac, + $repeatable?1:0, + $mandatory?1:0, + $authorised_value, + $frameworkcode, + $tagfield + ); + } + $sth->finish; + } else { + $sth=$dbh->prepare("INSERT INTO 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 + ); + } + $sth->finish; } - $sth->finish; print "Content-Type: text/html\n\n"; exit; # END $OP eq ADD_VALIDATE diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tmpl index 47c5b68e87..98e4fd7721 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tmpl @@ -85,6 +85,7 @@ return false;
" name="Aform" method="post"> + " />
  1. Tag
  2. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl index c067aa36b9..ffc3aae8b6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl @@ -80,7 +80,7 @@ function Check(f) {