use strict;
use C4::Output;
-use C4::Charset;
use C4::Auth;
use CGI;
-use C4::Search;
use C4::Context;
use C4::Biblio;
-use HTML::Template;
+
my $input = new CGI;
my ($template, $borrowernumber, $cookie)
- = get_template_and_user({template_name => "parameters/checkmarc.tmpl",
+ = get_template_and_user({template_name => "admin/checkmarc.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
});
my $dbh = C4::Context->dbh;
-my $total;
+my $total = 0;
# checks itemnum field
my $sth = $dbh->prepare("select tab from marc_subfield_structure where kohafield=\"items.itemnumber\"");
$sth->execute;
$sth = $dbh->prepare("select tagfield,tab from marc_subfield_structure where kohafield=\"biblioitems.biblioitemnumber\"");
$sth->execute;
my ($res2,$tab2) = $sth->fetchrow;
-if ($res && $res2 && ($res eq $res2) && $tab==-1 && $tab2==-1) {
+if ($res && $res2 && $tab==-1 && $tab2==-1) {
$template->param(biblionumber => 0);
} else {
$template->param(biblionumber => 1);
}
# checks all item fields are in the same tag and in tab 10
-$sth = $dbh->prepare("select tagfield,tab,kohafield from marc_subfield_structure where kohafield like \"items.%\"");
+
+$sth = $dbh->prepare("select tagfield,tab,kohafield from marc_subfield_structure where kohafield like \"items.%\" and tab >=0");
$sth->execute;
my $field;
($res,$res2,$field) = $sth->fetchrow;
my $tagfield = $res;
my $tab = $res2;
my $subtotal=0;
+#warn "TAGF : $tagfield";
while (($res,$res2,$field) = $sth->fetchrow) {
# (ignore itemnumber, that must be in -1 tab)
- if (($res ne $tagfield or $res2 ne $tab ) && $field ne "items.itemnumber") {
+ if (($res ne $tagfield) or ($res2 ne $tab)) {
+ $subtotal++;
+ }
+}
+$sth = $dbh->prepare("select kohafield from marc_subfield_structure where tagfield=?");
+$sth->execute($tagfield);
+while (($res2) = $sth->fetchrow) {
+ if (!$res2 || $res2 =~ /^items/) {
+ } else {
$subtotal++;
}
}
-if ($subtotal eq 0) {
+if ($subtotal == 0) {
$template->param(itemfields => 0);
} else {
$template->param(itemfields => 1);
$total++;
}
+
+$sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where tab = 10");
+$sth->execute;
+my $totaltags = 0;
+my $list = "";
+while (($res2) = $sth->fetchrow) {
+ $totaltags++;
+ $list.=$res2.",";
+}
+if ($totaltags > 1) {
+ $template->param(itemtags => $list);
+ $total++;
+} else {
+ $template->param(itemtags => 0);
+}
+
+
# checks biblioitems.itemtype must be mapped and use authorised_value=itemtype
$sth = $dbh->prepare("select tagfield,tab,authorised_value from marc_subfield_structure where kohafield = \"biblioitems.itemtype\"");
$sth->execute;
($res,$res2,$field) = $sth->fetchrow;
-warn "==> $res / $res2 / $field";
if ($res && $res2>=0 && $field eq "itemtypes") {
$template->param(itemtype => 0);
} else {
$total++;
}
-$template->param(total => $total);
-print $input->header(
- -type => guesstype($template->output),
- -cookie => $cookie
-), $template->output;
+# checks that itemtypes & branches tables are not empty
+$sth = $dbh->prepare("select count(*) from itemtypes");
+$sth->execute;
+($res) = $sth->fetchrow;
+if ($res) {
+ $template->param(itemtypes_empty =>0);
+} else {
+ $template->param(itemtypes_empty =>1);
+ $total++;
+}
+
+
+$sth = $dbh->prepare("select count(*) from branches");
+$sth->execute;
+($res) = $sth->fetchrow;
+if ($res) {
+ $template->param(branches_empty =>0);
+} else {
+ $template->param(branches_empty =>1);
+ $total++;
+}
+
+$sth = $dbh->prepare("select count(*) from marc_subfield_structure where frameworkcode is NULL");
+$sth->execute;
+($res) = $sth->fetchrow;
+if ($res) {
+ $template->param(frameworknull =>1);
+ $total++;
+}
+$sth = $dbh->prepare("select count(*) from marc_tag_structure where frameworkcode is NULL");
+$sth->execute;
+($res) = $sth->fetchrow;
+if ($res) {
+ $template->param(frameworknull =>1);
+ $total++;
+}
+
+$template->param(total => $total,
+ intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+ );
+output_html_with_http_headers $input, $cookie, $template->output;