+=head2 CheckIfIssuedToPatron
+
+ CheckIfIssuedToPatron($borrowernumber, $biblionumber)
+
+ Return 1 if any record item is issued to patron, otherwise return 0
+
+=cut
+
+sub CheckIfIssuedToPatron {
+ my ($borrowernumber, $biblionumber) = @_;
+
+ my $items = GetItemsByBiblioitemnumber($biblionumber);
+
+ foreach my $item (@{$items}) {
+ return 1 if ($item->{borrowernumber} && $item->{borrowernumber} eq $borrowernumber);
+ }
+
+ return;
+}
+
+=head2 IsItemIssued
+
+ IsItemIssued( $itemnumber )
+
+ Return 1 if the item is on loan, otherwise return 0
+
+=cut
+
+sub IsItemIssued {
+ my $itemnumber = shift;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(q{
+ SELECT COUNT(*)
+ FROM issues
+ WHERE itemnumber = ?
+ });
+ $sth->execute($itemnumber);
+ return $sth->fetchrow;
+}
+
+sub GetAgeRestriction {
+ my ($record_restrictions) = @_;
+ my $markers = C4::Context->preference('AgeRestrictionMarker');
+
+ # Split $record_restrictions to something like FSK 16 or PEGI 6
+ my @values = split ' ', uc($record_restrictions);
+ return unless @values;
+
+ # Search first occurence of one of the markers
+ my @markers = split /\|/, uc($markers);
+ return unless @markers;
+
+ my $index = 0;
+ my $restriction_year = 0;
+ for my $value (@values) {
+ $index++;
+ for my $marker (@markers) {
+ $marker =~ s/^\s+//; #remove leading spaces
+ $marker =~ s/\s+$//; #remove trailing spaces
+ if ( $marker eq $value ) {
+ if ( $index <= $#values ) {
+ $restriction_year += $values[$index];
+ }
+ last;
+ }
+ elsif ( $value =~ /^\Q$marker\E(\d+)$/ ) {
+
+ # Perhaps it is something like "K16" (as in Finland)
+ $restriction_year += $1;
+ last;
+ }
+ }
+ last if ( $restriction_year > 0 );
+ }
+
+ return $restriction_year;
+}