4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
23 use C4::Interface::CGI::Output;
32 my ($template, $borrowernumber, $cookie)
33 = get_template_and_user({template_name => "admin/checkmarc.tmpl",
37 flagsrequired => {parameters => 1},
41 my $dbh = C4::Context->dbh;
43 # checks itemnumber field
44 my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"itemnumber\"");
46 my ($res) = $sth->fetchrow;
48 $template->param(itemnumber => 1);
52 my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"biblionumber\"");
54 my ($res) = $sth->fetchrow;
56 ($res) = $sth->fetchrow;
58 $template->param(biblionumber => 1);
63 my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"barcode\"");
65 my ($res) = $sth->fetchrow;
67 $template->param(barcode=> 1);
71 my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"isbn\"");
73 my ($res) = $sth->fetchrow;
75 $template->param(isbn => 1);
79 my $sth = $dbh->prepare("select tagfield,tagsubfield from koha_attr where marctokoha=\"itemtype\"");
81 my ($res,$res2) = $sth->fetchrow;
83 $sth = $dbh->prepare("select authorised_value from biblios_subfield_structure where tagfield=? and tagsubfield=?");
84 $sth->execute($res,$res2);
85 my ($item)=$sth->fetchrow;
86 unless ($item eq "itemtypes"){
87 $template->param(itemtype => 1);
92 ## Check for homebranch
93 my $sth = $dbh->prepare("select tagfield from koha_attr where marctokoha=\"homebranch\"");
95 my ($res) = $sth->fetchrow;
97 $template->param(branch => 1);
102 ## Check for holdingbranch
103 my $sth = $dbh->prepare("select tagfield,tagsubfield from koha_attr where marctokoha=\"holdingbranch\"");
105 my ($res,$res2) = $sth->fetchrow;
107 $sth = $dbh->prepare("select authorised_value from biblios_subfield_structure where tagfield=? and tagsubfield=?");
108 $sth->execute($res,$res2);
109 my ($item)=$sth->fetchrow;
110 unless ($item eq "branches"){
111 $template->param(holdingbranch => 1);
118 # checks that itemtypes & branches tables are not empty
119 $sth = $dbh->prepare("select count(*) from itemtypes");
121 ($res) = $sth->fetchrow;
123 $template->param(itemtypes_empty =>1);
127 $sth = $dbh->prepare("select count(*) from branches");
129 ($res) = $sth->fetchrow;
131 $template->param(branches_empty =>1);
135 $template->param(total => $total);
136 output_html_with_http_headers $input, $cookie, $template->output;