3 # written 20/02/2002 by paul.poulain@free.fr
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
29 my $string = shift || '';
30 my $dbh = C4
::Context
->dbh;
31 return $dbh->selectall_arrayref(q
|
32 SELECT authtypecode
, authtypetext
, auth_tag_to_report
, summary
34 WHERE
(authtypecode like ?
) ORDER BY authtypecode
35 |, { Slice
=> {} }, $string . "%" );
39 my $script_name = "/cgi-bin/koha/admin/authtypes.pl";
40 my $searchfield = $input->param('authtypecode'); # FIXME: Auth Type search not really implemented
41 my $authtypecode = $input->param('authtypecode');
42 my $op = $input->param('op') || '';
43 my ($template, $borrowernumber, $cookie)
44 = get_template_and_user
({template_name
=> "admin/authtypes.tt",
48 flagsrequired
=> {parameters
=> 'parameters_remaining_permissions'},
53 script_name
=> $script_name,
57 my $dbh = C4
::Context
->dbh;
59 # called by default. Used to create form to add or modify a record
60 if ($op eq 'add_form') {
61 #---- if primkey exists, it's a modify action, so read values to modify...
62 if ( defined $authtypecode) {
63 my $sth = $dbh->prepare("SELECT * FROM auth_types WHERE authtypecode=?");
64 $sth->execute($authtypecode);
65 my $data = $sth->fetchrow_hashref();
67 authtypecode
=> $authtypecode,
68 authtypetext
=> $data->{'authtypetext'},
69 auth_tag_to_report
=> $data->{'auth_tag_to_report'},
70 summary
=> $data->{'summary'},
74 ################## ADD_VALIDATE ##################################
75 # called by add_form, used to insert/modify data in DB
76 } elsif ($op eq 'add_validate') {
77 my $sth = $input->param('modif') ?
78 $dbh->prepare("UPDATE auth_types SET authtypetext=? ,auth_tag_to_report=?, summary=? WHERE authtypecode=?") :
79 $dbh->prepare("INSERT INTO auth_types SET authtypetext=?, auth_tag_to_report=?, summary=?, authtypecode=?") ;
80 $sth->execute($input->param('authtypetext'),$input->param('auth_tag_to_report'),$input->param('summary'),$input->param('authtypecode'));
81 print $input->redirect($script_name); # FIXME: unnecessary redirect
83 # END $OP eq ADD_VALIDATE
84 ################## DELETE_CONFIRM ##################################
85 # called by default form, used to confirm deletion of data in DB
86 } elsif ($op eq 'delete_confirm') {
87 #start the page and read in includes
88 my $sth=$dbh->prepare("SELECT count(*) AS total FROM auth_tag_structure WHERE authtypecode=?");
89 $sth->execute($authtypecode);
90 my $total = $sth->fetchrow_hashref->{total
};
92 my $sth2 = $dbh->prepare("SELECT * FROM auth_types WHERE authtypecode=?");
93 $sth2->execute($authtypecode);
94 my $data = $sth2->fetchrow_hashref;
96 $template->param(authtypecode
=> $authtypecode,
97 authtypetext
=> $data->{'authtypetext'},
98 summary
=> $data->{'summary'},
100 # END $OP eq DELETE_CONFIRM
101 ################## DELETE_CONFIRMED ##################################
102 # called by delete_confirm, used to effectively confirm deletion of data in DB
103 } elsif ($op eq 'delete_confirmed') {
104 #start the page and read in includes
105 my $sth=$dbh->prepare("DELETE FROM auth_types WHERE authtypecode=?");
106 $sth->execute(uc $input->param('authtypecode'));
107 print $input->redirect($script_name); # FIXME: unnecessary redirect
109 # END $OP eq DELETE_CONFIRMED
110 ################## DEFAULT ##################################
112 my $results = StringSearch
($searchfield);
113 $template->param( loop => $results );
114 } #---- END $OP eq DEFAULT
115 output_html_with_http_headers
$input, $cookie, $template->output;