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