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;
33 my ($template, $borrowernumber, $cookie)
34 = get_template_and_user({template_name => "parameters/checkmarc.tmpl",
38 flagsrequired => {parameters => 1},
42 my $dbh = C4::Context->dbh;
44 # checks itemnum field
45 my $sth = $dbh->prepare("select tab from marc_subfield_structure where kohafield=\"items.itemnumber\"");
47 my ($res) = $sth->fetchrow;
49 $template->param(itemnum => 0);
51 $template->param(itemnum => 1);
55 # checks biblio.biblionumber and biblioitem.biblioitemnumber (same tag and tab=-1)
56 $sth = $dbh->prepare("select tagfield,tab from marc_subfield_structure where kohafield=\"biblio.biblionumber\"");
59 ($res,$tab) = $sth->fetchrow;
60 $sth = $dbh->prepare("select tagfield,tab from marc_subfield_structure where kohafield=\"biblioitems.biblioitemnumber\"");
62 my ($res2,$tab2) = $sth->fetchrow;
63 if ($res && $res2 && ($res eq $res2) && $tab==-1 && $tab2==-1) {
64 $template->param(biblionumber => 0);
66 $template->param(biblionumber => 1);
70 # checks all item fields are in the same tag and in tab 10
71 $sth = $dbh->prepare("select tagfield,tab,kohafield from marc_subfield_structure where kohafield like \"items.%\"");
74 ($res,$res2,$field) = $sth->fetchrow;
78 while (($res,$res2,$field) = $sth->fetchrow) {
79 # (ignore itemnumber, that must be in -1 tab)
80 if (($res ne $tagfield or $res2 ne $tab ) && $res2 ne -1) {
85 $template->param(itemfields => 0);
87 $template->param(itemfields => 1);
90 # checks biblioitems.itemtype must be mapped and use authorised_value=itemtype
91 $sth = $dbh->prepare("select tagfield,tab,authorised_value from marc_subfield_structure where kohafield = \"biblioitems.itemtype\"");
93 ($res,$res2,$field) = $sth->fetchrow;
94 warn "==> $res / $res2 / $field";
95 if ($res && $res2>=0 && $field eq "itemtypes") {
96 $template->param(itemtype => 0);
98 $template->param(itemtype => 1);
102 # checks items.homebranch must be mapped and use authorised_value=branches
103 $sth = $dbh->prepare("select tagfield,tab,authorised_value from marc_subfield_structure where kohafield = \"items.homebranch\"");
105 ($res,$res2,$field) = $sth->fetchrow;
106 if ($res && $res2 eq 10 && $field eq "branches") {
107 $template->param(branch => 0);
109 $template->param(branch => 1);
112 # checks items.homebranch must be mapped and use authorised_value=branches
113 $sth = $dbh->prepare("select tagfield,tab,authorised_value from marc_subfield_structure where kohafield = \"items.holdingbranch\"");
115 ($res,$res2,$field) = $sth->fetchrow;
116 if ($res && $res2 eq 10 && $field eq "branches") {
117 $template->param(holdingbranch => 0);
119 $template->param(holdingbranch => 1);
123 $template->param(total => $total);
124 output_html_with_http_headers $input, $cookie, $template->output;