Lines 108-127
else{
Link Here
|
108 |
if ($documentids) { $found = 1; }; |
108 |
if ($documentids) { $found = 1; }; |
109 |
} |
109 |
} |
110 |
if ($found == 0){ |
110 |
if ($found == 0){ |
|
|
111 |
#choose the field to select depending on marc flavour |
112 |
my $marcflavour = C4::Context->preference("marcflavour"); |
113 |
my %fields; |
114 |
my %inds1; |
115 |
if ($marcflavour eq "UNIMARC"){ |
116 |
%fields = (isbn => "010", issn => "011", ismn => "013", isrn => "015", isrc => "016", upc => "072", ean => "073"); |
117 |
%inds1 = (isbn => "", issn => "", ismn => "", isrn => "", isrc => "", upc => "", ean => ""); |
118 |
} |
119 |
else{ |
120 |
#if nor UNIMARC, assume MARC21 |
121 |
%fields = (isbn => "020", issn => "022", ismn => "024", isrn => "027", isrc => "024", upc => "024", ean => "024"); |
122 |
%inds1 = (isbn => "", issn => "", ismn => " and \@ind1=\"2\"", isrn => "", isrc => " and \@ind1=\"0\"", upc => " and \@ind1=\"1\"", ean => " and \@ind1=\"3\""); |
123 |
} |
124 |
|
111 |
my $dbh = C4::Context->dbh; |
125 |
my $dbh = C4::Context->dbh; |
112 |
my $query = " |
126 |
my $query = q{ |
113 |
SELECT |
127 |
SELECT |
114 |
ExtractValue(metadata, '//datafield[\@tag=\"010\"]/subfield[\@code=\"a\"]') as isbn, |
128 |
ExtractValue(metadata, '//datafield[@tag="}.$fields{isbn}.q{"}.$inds1{isbn}.q{]/subfield[\@code="a"]') as isbn, |
115 |
ExtractValue(metadata, '//datafield[\@tag=\"011\"]/subfield[\@code=\"a\"]') as issn, |
129 |
ExtractValue(metadata, '//datafield[@tag="}.$fields{issn}.q{"}.$inds1{issn}.q{]/subfield[\@code="a"]') as issn, |
116 |
ExtractValue(metadata, '//datafield[\@tag=\"013\"]/subfield[\@code=\"a\"]') as ismn, |
130 |
ExtractValue(metadata, '//datafield[@tag="}.$fields{ismn}.q{"}.$inds1{ismn}.q{]/subfield[@code="a"]') as ismn, |
117 |
ExtractValue(metadata, '//datafield[\@tag=\"015\"]/subfield[\@code=\"a\"]') as isrn, |
131 |
ExtractValue(metadata, '//datafield[@tag="}.$fields{isrn}.q{"}.$inds1{isrn}.q{]/subfield[@code="a"]') as isrn, |
118 |
ExtractValue(metadata, '//datafield[\@tag=\"016\"]/subfield[\@code=\"a\"]') as isrc, |
132 |
ExtractValue(metadata, '//datafield[@tag="}.$fields{isrc}.q{"}.$inds1{isrc}.q{]/subfield[@code="a"]') as isrc, |
119 |
ExtractValue(metadata, '//datafield[\@tag=\"072\"]/subfield[\@code=\"a\"]') as upc, |
133 |
ExtractValue(metadata, '//datafield[@tag="}.$fields{upc}.q{"}.$inds1{upc}.q{]/subfield[@code="a"]') as upc, |
120 |
ExtractValue(metadata, '//datafield[\@tag=\"073\"]/subfield[\@code=\"a\"]') as ean |
134 |
ExtractValue(metadata, '//datafield[@tag="}.$fields{ean}.q{"}.$inds1{ean}.q{]/subfield[@code="a"]') as ean |
121 |
FROM biblio_metadata |
135 |
FROM biblio_metadata |
122 |
WHERE biblionumber = ? |
136 |
WHERE biblionumber="}.$biblionumber.q{" |
123 |
AND format=\"marcxml\" |
137 |
AND format="marcxml" |
124 |
"; |
138 |
}; |
125 |
my $sth = $dbh->prepare( $query ); |
139 |
my $sth = $dbh->prepare( $query ); |
126 |
$sth->execute($biblionumber); |
140 |
$sth->execute($biblionumber); |
127 |
my $row = $sth->fetchrow_hashref; |
141 |
my $row = $sth->fetchrow_hashref; |
Lines 154-159
else{
Link Here
|
154 |
$idtype = "ean"; |
168 |
$idtype = "ean"; |
155 |
$documentids = $row->{ean}; |
169 |
$documentids = $row->{ean}; |
156 |
} |
170 |
} |
|
|
171 |
elsif ($row->{ean}){ |
172 |
$idtype = "ean"; |
173 |
$documentid = $row->{ean}; |
174 |
} |
157 |
else{ |
175 |
else{ |
158 |
die "error: no propper identifier"; |
176 |
die "error: no propper identifier"; |
159 |
} |
177 |
} |
Lines 197-207
else{
Link Here
|
197 |
|
215 |
|
198 |
#create the list of owned suggested resources |
216 |
#create the list of owned suggested resources |
199 |
my $ownedbiblioitem; |
217 |
my $ownedbiblioitem; |
|
|
218 |
my $marcflavour = C4::Context->preference("marcflavour"); |
200 |
foreach my $resource ( @{ $resources } ){ |
219 |
foreach my $resource ( @{ $resources } ){ |
201 |
my $found = 0; |
220 |
my $found = 0; |
202 |
|
221 |
|
203 |
#isbn, issn and ean can be search for with Koha::Biblioitems->search |
222 |
#isbn and issn can be search for with Koha::Biblioitems->search, ean too for unimarc but not for marc21 |
204 |
if ($resource->{idtype} eq "isbn" || $resource->{idtype} eq "issn" || $resource->{idtype} eq "ean"){ |
223 |
if ($resource->{idtype} eq "isbn" || $resource->{idtype} eq "issn" || ($resource->{idtype} eq "ean" && $marcflavour eq "UNIMARC")){ |
205 |
#isbn processsing |
224 |
#isbn processsing |
206 |
if ( $resource->{idtype} eq "isbn" ){ |
225 |
if ( $resource->{idtype} eq "isbn" ){ |
207 |
$documentid= C4::Koha::NormalizeISBN({ isbn => $resource->{documentid}, format => 'ISBN-10', strip_hyphens => 1 }); |
226 |
$documentid= C4::Koha::NormalizeISBN({ isbn => $resource->{documentid}, format => 'ISBN-10', strip_hyphens => 1 }); |
Lines 247-258
else{
Link Here
|
247 |
# other id need to be search with sql |
266 |
# other id need to be search with sql |
248 |
if ($found != 1) { |
267 |
if ($found != 1) { |
249 |
my @params; |
268 |
my @params; |
250 |
my %field=("isbn" => "010", "issn" => "011", "ismn" => "013", "isrn" => "015", "isrc" => "016", "upc" => "072", "ean" => "073"); |
269 |
|
|
|
270 |
#choose the field to select depending on marc flavour |
271 |
my %fields; |
272 |
my %inds1; |
273 |
if ($marcflavour eq "UNIMARC"){ |
274 |
%fields = (isbn => "010", issn => "011", ismn => "013", isrn => "015", isrc => "016", upc => "072", ean => "073"); |
275 |
%inds1 = (isbn => "", issn => "", ismn => "", isrn => "", isrc => "", upc => "", ean => ""); |
276 |
} |
277 |
else{ |
278 |
#if nor UNIMARC, assume MARC21 |
279 |
%fields = (isbn => "020", issn => "022", ismn => "024", isrn => "027", isrc => "024", upc => "024", ean => "024"); |
280 |
%inds1 = (isbn => "", issn => "", ismn => " and \@ind1=\"2\"", isrn => "", isrc => " and \@ind1=\"0\"", upc => " and \@ind1=\"1\"", ean => " and \@ind1=\"3\""); |
281 |
} |
251 |
|
282 |
|
252 |
#pattern to be tolerent on the hyphens |
283 |
#pattern to be tolerent on the hyphens |
253 |
my $pattern=""; |
284 |
my $pattern=""; |
254 |
foreach my $p (split('', $resource->{documentid})){ |
285 |
foreach my $p (split('', $resource->{documentid})){ |
255 |
$pattern .= "$p-*"; |
286 |
$pattern .= "$p-?"; |
256 |
} |
287 |
} |
257 |
|
288 |
|
258 |
my $dbh = C4::Context->dbh; |
289 |
my $dbh = C4::Context->dbh; |
Lines 260-266
else{
Link Here
|
260 |
SELECT biblioitems.biblionumber as biblionumber |
291 |
SELECT biblioitems.biblionumber as biblionumber |
261 |
FROM biblioitems |
292 |
FROM biblioitems |
262 |
LEFT JOIN biblio_metadata ON biblioitems.biblionumber=biblio_metadata.biblionumber |
293 |
LEFT JOIN biblio_metadata ON biblioitems.biblionumber=biblio_metadata.biblionumber |
263 |
WHERE ExtractValue(biblio_metadata.metadata, '//datafield[@tag="}.$field{$resource->{idtype}}.q{"]/subfield[@code="a"]') REGEXP "}.$pattern.q{" |
294 |
WHERE ExtractValue(biblio_metadata.metadata, '//datafield[@tag="}.$fields{$resource->{idtype}}.q{"}.$inds1{$resource->{idtype}}.q{]/subfield[@code="a"]') REGEXP "}.$pattern.q{" |
264 |
AND biblio_metadata.format="marcxml" |
295 |
AND biblio_metadata.format="marcxml" |
265 |
}; |
296 |
}; |
266 |
my $sth = $dbh->prepare( $query ); |
297 |
my $sth = $dbh->prepare( $query ); |
267 |
- |
|
|