IMPROVEMENT : serialsadditems at subscription level (bump 071)
[koha_gimpoz] / admin / biblio_framework.pl
index c81c698..1f345b7 100755 (executable)
 use strict;
 use CGI;
 use C4::Context;
-use C4::Output;
-use C4::Search;
 use C4::Auth;
-use C4::Interface::CGI::Output;
-use HTML::Template;
+use C4::Output;
+
 
 sub StringSearch  {
-       my ($env,$searchstring,$type)=@_;
+       my ($searchstring,$type)=@_;
        my $dbh = C4::Context->dbh;
        $searchstring=~ s/\'/\\\'/g;
        my @data=split(' ',$searchstring);
@@ -56,7 +54,7 @@ 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",
+    = get_template_and_user({template_name => "admin/biblio_framework.tmpl",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
@@ -97,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
@@ -132,21 +136,23 @@ if ($op eq 'add_form') {
 } 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;
+#      my $frameworkcode=uc($input->param('frameworkcode'));
+#   
+       unless($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 ($count,$results)=StringSearch($searchfield,'web');
        my $toggle="white";
        my @loop_data;
        for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){