3 # Copyright 2006 SAN OUEST-PROVENCE et Paul POULAIN
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 my $sth = C4
::Context
->dbh->prepare("Select * from roadtype where (road_type like ?) ORDER BY road_type");
31 $sth->execute((shift || '') . '%');
32 return $sth->fetchall_arrayref({});
36 my $searchfield=$input->param('road_type');
37 my $script_name="/cgi-bin/koha/admin/roadtype.pl";
38 my $roadtypeid=$input->param('roadtypeid');
39 my $op = $input->param('op') || '';
41 my ($template, $loggedinuser, $cookie)
42 = get_template_and_user
({template_name
=> "admin/roadtype.tmpl",
46 flagsrequired
=> {parameters
=> 1},
51 $template->param( script_name
=> $script_name,
52 roadtypeid
=> $roadtypeid ,
53 searchfield
=> $searchfield);
56 ################## ADD_FORM ##################################
57 # called by default. Used to create form to add or modify a record
58 if ($op eq 'add_form') {
59 $template->param(add_form
=> 1);
61 #---- if primkey exists, it's a modify action, so read values to modify...
64 my $dbh = C4
::Context
->dbh;
65 my $sth=$dbh->prepare("select roadtypeid,road_type from roadtype where roadtypeid=?");
66 $sth->execute($roadtypeid);
67 $data=$sth->fetchrow_hashref;
72 road_type
=> $data->{'road_type'},
74 ##############ICI#####################
76 ################## ADD_VALIDATE #################################
77 # called by add_form, used to insert/modify data in DB
78 } elsif ($op eq 'add_validate') {
79 my $dbh = C4
::Context
->dbh;
82 if ($input->param('roadtypeid') ){
83 $sth=$dbh->prepare("UPDATE roadtype SET road_type=? WHERE roadtypeid=?");
84 $sth->execute($input->param('road_type'),$input->param('roadtypeid'));
88 $sth=$dbh->prepare("INSERT INTO roadtype (road_type) VALUES (?)");
89 $sth->execute($input->param('road_type'));
92 print $input->redirect("/cgi-bin/koha/admin/roadtype.pl");
95 # END $OP eq ADD_VALIDATE
96 ################## DELETE_CONFIRM ##################################
97 # called by default form, used to confirm deletion of data in DB
98 } elsif ($op eq 'delete_confirm') {
99 $template->param(delete_confirm
=> 1);
100 my $dbh = C4
::Context
->dbh;
101 my $sth2=$dbh->prepare("select roadtypeid,road_type from roadtype where roadtypeid=?");
102 $sth2->execute($roadtypeid);
103 my $data=$sth2->fetchrow_hashref;
107 road_type
=> ( $data->{'road_type'}),
111 # END $OP eq DELETE_CONFIRM
112 ################## DELETE_CONFIRMED ##################################
113 # called by delete_confirm, used to effectively confirm deletion of data in DB
114 } elsif ($op eq 'delete_confirmed') {
115 my $dbh = C4
::Context
->dbh;
116 my $categorycode=uc($input->param('roadtypeid'));
117 my $sth=$dbh->prepare("delete from roadtype where roadtypeid=?");
118 $sth->execute($roadtypeid);
120 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=roadtype.pl\"></html>";
122 # END $OP eq DELETE_CONFIRMED
124 $template->param(else => 1);
125 $template->param(loop => StringSearch
($searchfield));
128 } #---- END $OP eq DEFAULT
129 output_html_with_http_headers
$input, $cookie, $template->output;