#1546 REPLACE statements (continued)
authorPaul POULAIN <paul@koha-fr.org>
Fri, 2 Nov 2007 14:26:07 +0000 (15:26 +0100)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 8 Nov 2007 23:50:12 +0000 (17:50 -0600)
- biblio framework
- marc tag
- auth tag

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
admin/auth_tag_structure.pl
admin/biblio_framework.pl
admin/marctagstructure.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tmpl

index cfa54e0..106c136 100755 (executable)
@@ -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<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode\">";
        exit;
                                                                                                        # END $OP eq ADD_VALIDATE
index 4568a17..c388762 100755 (executable)
@@ -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<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=biblio_framework.pl\"></html>";
        exit;
                                                                                                        # END $OP eq ADD_VALIDATE
index 78cc6eb..b98d965 100755 (executable)
@@ -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<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
        exit;
                                                                                                        # END $OP eq ADD_VALIDATE
index 47c5b68..98e4fd7 100644 (file)
@@ -85,6 +85,7 @@ return false;
     </h2>
     <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
         <input type="hidden" name="op" value="add_validate" />
+        <!-- TMPL_IF NAME="heading-modify-tag-p" --><input type="hidden" name="modif" value="1" /><!-- /TMPL_IF -->
         <input type="hidden" name="authtypecode" value="<!-- TMPL_VAR NAME="authtypecode" -->" />
         <fieldset class="rows"><ol>
                <li><span class="label">Tag</span><!-- TMPL_VAR NAME="searchfield" --></li>
index c067aa3..ffc3aae 100644 (file)
@@ -80,7 +80,7 @@ function Check(f) {
        <!-- /TMPL_IF -->
                        <!-- TMPL_IF NAME="authtypecode" -->
                                <tr><td><label for="authtypecode">Authority type<label></td><td><input type="hidden" name="op" value="add_validate" />
-               <input type="hidden" name="checked" value="0" /><input type="hidden" name="authtypecode" value="<!-- TMPL_VAR NAME="authtypecode" -->" /><!-- TMPL_VAR NAME="authtypecode" --></td></tr>
+               <input type="hidden" name="modif" value="1" /><input type="hidden" name="authtypecode" value="<!-- TMPL_VAR NAME="authtypecode" -->" /><!-- TMPL_VAR NAME="authtypecode" --></td></tr>
                        <!-- TMPL_ELSE -->
                                <tr><td><label for="authtypecode">Authority type</label></td><td><input id="authtypecode" type="text" name="authtypecode" size="10" maxlength="10" onblur="toUC(this)" /></td></tr>
                        <!-- /TMPL_IF -->
index afaa2c7..6cda08e 100644 (file)
@@ -73,9 +73,9 @@ function Check(f) {
     <h1><!-- TMPL_IF NAME="frameworkcode" -->Modify framework text<!-- TMPL_ELSE -->Add framework<!-- /TMPL_IF --></h1>
     <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
         <input type="hidden" name="op" value="add_validate" />
-        <input type="hidden" name="checked" value="0" />
 <fieldset class="rows">        <ol><!-- TMPL_IF NAME="frameworkcode" -->
             <li><span class="label">Framework Code</span><input type="hidden" id="frameworkcode" name="frameworkcode" value="<!-- TMPL_VAR NAME="frameworkcode" -->" /><!-- TMPL_VAR NAME="frameworkcode" --></li>
+            <input type="hidden" name="modif" value=1" />
         <!-- TMPL_ELSE -->
             <li><label for="frameworkcode">Framework Code</label><input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" /></li>
         <!-- /TMPL_IF -->
index 7fcfa0c..69ae11b 100644 (file)
@@ -80,7 +80,7 @@
 
     <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
        
-      <fieldset class="rows"><legend><!-- TMPL_IF NAME="use-heading-flags-p" --><!-- TMPL_IF NAME="heading-modify-tag-p" -->Modify tag <!-- TMPL_VAR NAME="searchfield" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="heading-add-tag-p" -->Add tag<!-- /TMPL_IF --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="action" --><!-- /TMPL_IF --></legend>  <input type="hidden" name="op" value="add_validate" />
+      <fieldset class="rows"><legend><!-- TMPL_IF NAME="use-heading-flags-p" --><!-- TMPL_IF NAME="heading-modify-tag-p" -->Modify tag <input type="hidden" name="modif" value="1" /><!-- TMPL_VAR NAME="searchfield" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="heading-add-tag-p" -->Add tag<!-- /TMPL_IF --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="action" --><!-- /TMPL_IF --></legend>  <input type="hidden" name="op" value="add_validate" />
        <input type="hidden" name="frameworkcode" value="<!-- TMPL_VAR NAME="frameworkcode" -->" />
 
        <ol> <li><label for="tagfield">Tag</label><input id="tagfield" type="text" name="tagfield" value="<!-- TMPL_VAR NAME="searchfield" -->" maxlength="3" size="3" /></li>