bug fixing :
[koha-ffzg.git] / admin / authtypes.pl
index dd6ccfb..ad68d19 100755 (executable)
@@ -56,7 +56,7 @@ my $pagesize=20;
 my $op = $input->param('op');
 $searchfield=~ s/\,//g;
 my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "parameters/authtypes.tmpl",
+    = get_template_and_user({template_name => "admin/authtypes.tmpl",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
@@ -79,14 +79,16 @@ if ($op eq 'add_form') {
        my $data;
        if ($authtypecode) {
                my $dbh = C4::Context->dbh;
-               my $sth=$dbh->prepare("select authtypecode,authtypetext,auth_tag_to_report from auth_types where authtypecode=?");
+               my $sth=$dbh->prepare("select * from auth_types where authtypecode=?");
                $sth->execute($authtypecode);
                $data=$sth->fetchrow_hashref;
                $sth->finish;
        }
+       warn "=> $data->{'authtypetext'} : ".$data->{'summary'};
        $template->param(authtypecode => $authtypecode,
                                                        authtypetext => $data->{'authtypetext'},
                                                        auth_tag_to_report => $data->{'auth_tag_to_report'},
+                                                       summary => $data->{'summary'},
                                                        );
 ;
                                                                                                        # END $OP eq ADD_FORM
@@ -94,8 +96,8 @@ 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 auth_types (authtypecode,authtypetext,auth_tag_to_report) values (?,?,?)");
-       $sth->execute($input->param('authtypecode'),$input->param('authtypetext'),$input->param('auth_tag_to_report'));
+       my $sth=$dbh->prepare("replace auth_types (authtypecode,authtypetext,auth_tag_to_report,summary) values (?,?,?,?)");
+       $sth->execute($input->param('authtypecode'),$input->param('authtypetext'),$input->param('auth_tag_to_report'),$input->param('summary'));
        $sth->finish;
        print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authtypes.pl\"></html>";
        exit;
@@ -106,7 +108,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,13 +116,14 @@ if ($op eq 'add_form') {
           $sth->finish;
        }
 
-       my $sth=$dbh->prepare("select authtypecode,authtypetext from authtypes where authtypecode=?");
+       my $sth=$dbh->prepare("select * from auth_types where authtypecode=?");
        $sth->execute($authtypecode);
        my $data=$sth->fetchrow_hashref;
        $sth->finish;
 
        $template->param(authtypecode => $authtypecode,
                                                        authtypetext => $data->{'authtypetext'},
+                                                       summary => $data->{'summary'},
                                                        total => $total);
                                                                                                        # END $OP eq DELETE_CONFIRM
 ################## DELETE_CONFIRMED ##################################
@@ -130,7 +132,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>";
@@ -152,6 +158,7 @@ if ($op eq 'add_form') {
                $row_data{authtypecode} = $results->[$i]{'authtypecode'};
                $row_data{authtypetext} = $results->[$i]{'authtypetext'};
                $row_data{auth_tag_to_report} = $results->[$i]{'auth_tag_to_report'};
+               $row_data{summary} = $results->[$i]{'summary'};
                push(@loop_data, \%row_data);
        }
        $template->param(loop => \@loop_data);