with this script, it's easy to see which koha-DB fields are not mapped to MARC-DB and map them.
This commit is contained in:
parent
4ebff7b4a0
commit
bf1b862180
2 changed files with 312 additions and 0 deletions
130
admin/koha2marclinks.pl
Executable file
130
admin/koha2marclinks.pl
Executable file
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use C4::Output;
|
||||
use CGI;
|
||||
use C4::Search;
|
||||
use C4::Context;
|
||||
use C4::Biblio;
|
||||
use HTML::Template;
|
||||
|
||||
my $input = new CGI;
|
||||
my $tablename=$input->param('tablename');
|
||||
$tablename="biblio." unless ($tablename);
|
||||
my $kohafield = $input->param('kohafield');
|
||||
my $op=$input->param('op');
|
||||
my $script_name = 'koha2marclinks.pl';
|
||||
|
||||
my $template = gettemplate("parameters/koha2marclinks.tmpl",0);
|
||||
|
||||
if ($op) {
|
||||
$template->param(script_name => $script_name,
|
||||
$op => 1); # we show only the TMPL_VAR names $op
|
||||
} else {
|
||||
$template->param(script_name => $script_name,
|
||||
else => 1); # we show only the TMPL_VAR names $op
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
################## ADD_FORM ##################################
|
||||
# called by default. Used to create form to add or modify a record
|
||||
if ($op eq 'add_form') {
|
||||
my $data;
|
||||
my $sth = $dbh->prepare("select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where kohafield=?");
|
||||
$sth->execute($tablename.".".$kohafield);
|
||||
my ($defaulttagfield, $defaulttagsubfield,$defaultliblibrarian) = $sth->fetchrow;
|
||||
|
||||
for (my $i=0;$i<=9;$i++) {
|
||||
my $sth2=$dbh->prepare("select tagfield,tagsubfield,liblibrarian as lib,tab from marc_subfield_structure where tagfield like '$i%'");
|
||||
$sth2->execute;
|
||||
my @marcarray;
|
||||
push @marcarray," ";
|
||||
while (my ($field, $tagsubfield, $liblibrarian) = $sth2->fetchrow_array) {
|
||||
# warn "$field$tagsubfield - $liblibrarian";
|
||||
push @marcarray, "$field $tagsubfield - $liblibrarian";
|
||||
}
|
||||
my $marclist = CGI::scrolling_list(-name=>"marc",
|
||||
-values=> \@marcarray,
|
||||
-default=>"$defaulttagfield $defaulttagsubfield - $defaultliblibrarian",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$template->param("marclist$i" => $marclist);
|
||||
}
|
||||
$template->param( tablename => $tablename,
|
||||
kohafield => $kohafield);
|
||||
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
} elsif ($op eq 'add_validate') {
|
||||
#----- empty koha field :
|
||||
$dbh->do("update marc_subfield_structure set kohafield='' where kohafield='$tablename.$kohafield'");
|
||||
#---- reload if not empty
|
||||
my @temp = split / /,$input->param('marc');
|
||||
$dbh->do("update marc_subfield_structure set kohafield='$tablename.$kohafield' where tagfield='$temp[0]' and tagsubfield='$temp[1]'");
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=koha2marclinks.pl?tablename=$tablename\"></html>";
|
||||
exit;
|
||||
|
||||
# END $OP eq ADD_VALIDATE
|
||||
################## DEFAULT ##################################
|
||||
} else { # DEFAULT
|
||||
my $env;
|
||||
my $sth=$dbh->prepare("Select tagfield,tagsubfield,liblibrarian,kohafield from marc_subfield_structure");
|
||||
$sth->execute;
|
||||
my %fields;
|
||||
while ((my $tagfield,my $tagsubfield,my $liblibrarian,my $kohafield) = $sth->fetchrow) {
|
||||
$fields{$kohafield}->{tagfield} = $tagfield;
|
||||
$fields{$kohafield}->{tagsubfield} = $tagsubfield;
|
||||
$fields{$kohafield}->{liblibrarian} = $liblibrarian;
|
||||
}
|
||||
my $sth2=$dbh->prepare("SHOW COLUMNS from $tablename");
|
||||
$sth2->execute;
|
||||
|
||||
my $toggle="white";
|
||||
my @loop_data = ();
|
||||
while ((my $field) = $sth2->fetchrow_array) {
|
||||
if ($toggle eq 'white'){
|
||||
$toggle="#ffffcc";
|
||||
} else {
|
||||
$toggle="white";
|
||||
}
|
||||
my %row_data; # get a fresh hash for the row data
|
||||
$row_data{tagfield} = $fields{$tablename.".".$field}->{tagfield};
|
||||
$row_data{tagsubfield} = $fields{$tablename.".".$field}->{tagsubfield};
|
||||
$row_data{liblibrarian} = $fields{$tablename.".".$field}->{liblibrarian};
|
||||
$row_data{kohafield} = $field;
|
||||
$row_data{edit} = "$script_name?op=add_form&tablename=$tablename&kohafield=$field";
|
||||
$row_data{bgcolor} = $toggle;
|
||||
push(@loop_data,\%row_data);
|
||||
}
|
||||
$template->param(loop => \@loop_data,
|
||||
tablename => CGI::scrolling_list(-name=>'tablename',
|
||||
-values=>['biblio','biblioitems','items'],
|
||||
-default=>$tablename,
|
||||
-size=>1,
|
||||
-multiple=>0
|
||||
)
|
||||
);
|
||||
} #---- END $OP eq DEFAULT
|
||||
|
||||
print "Content-Type: text/html\n\n", $template->output;
|
|
@ -0,0 +1,182 @@
|
|||
<TMPL_INCLUDE NAME="cat-top.inc">
|
||||
|
||||
<TMPL_IF name="add_form">
|
||||
<!-------------------------------------------------------------------------------------------------->
|
||||
<H1><TMPL_VAR name="action"></H1>
|
||||
<p>Choose and validate 1 of the following for <b><TMPL_VAR name="tablename">.<TMPL_VAR name="kohafield"></b></p>
|
||||
<table>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist0">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist1">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist2">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist3">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist4">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist5">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist6">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist7">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist8">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action='<TMPL_VAR name="script_name">'method=put>
|
||||
<td>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<TMPL_VAR name="marclist9">
|
||||
</td>
|
||||
<td>
|
||||
<INPUT type=submit value='OK'>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p align="right">To "unmap", click ==></p>
|
||||
</td>
|
||||
<td>
|
||||
<form action='<TMPL_VAR name="script_name">' name=Aform method=put>
|
||||
<input type=hidden name=op value='add_validate'>
|
||||
<input type="hidden" name="tablename" value="<TMPL_VAR name="tablename">">
|
||||
<input type="hidden" name="kohafield" value="<TMPL_VAR name="kohafield">">
|
||||
<input type="hidden" name="choice" value="">
|
||||
<INPUT type=submit value='HERE'>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</TMPL_IF>
|
||||
|
||||
<!-------------------------------------------------------------------------------------------------->
|
||||
<TMPL_IF name="else">
|
||||
<font SIZE=6><em>MARC links<TMPL_VAR name="tagfield"></em></font>
|
||||
<p></p>
|
||||
<form action='<TMPL_VAR name="script_name">' method=post>
|
||||
<TMPL_VAR name="tablename"> <input type="submit" value="OK">
|
||||
</form>
|
||||
|
||||
<table border=0 cellspacing=0 cellpadding=5>
|
||||
<tr valign=top bgcolor=#99cc33>
|
||||
<td background="/images/background-mem.gif" width=10%><b>koha field</b> <span style="font-size:8;color:red" title="the koha-DB field linked to this subfield">?</span></td>
|
||||
<td background="/images/background-mem.gif" width=5%><b>Tag</b></td>
|
||||
<td background="/images/background-mem.gif" width=5%><b>Subfield</b></td>
|
||||
<td background="/images/background-mem.gif" width=42%><b>Lib</b></td>
|
||||
<td background="/images/background-mem.gif" width=8%>
|
||||
<TMPL_LOOP name="loop">
|
||||
<tr valign=top bgcolor='<TMPL_VAR name="bgcolor">'>
|
||||
<td><b><TMPL_VAR name="kohafield"></b></td>
|
||||
<td><TMPL_VAR name="tagfield"></td>
|
||||
<td><TMPL_VAR name="tagsubfield"></td>
|
||||
<td><TMPL_VAR name="liblibrarian"></td>
|
||||
<td><a href="<TMPL_VAR name="edit">">edit</a></td>
|
||||
</tr>
|
||||
</TMPL_LOOP>
|
||||
</table>
|
||||
</TMPL_IF>
|
||||
|
||||
<TMPL_INCLUDE NAME="cat-bottom.inc">
|
Loading…
Reference in a new issue