Lines 839-845
Item's itemcallnumber
Link Here
|
839 |
Item's call number normalized for sorting |
839 |
Item's call number normalized for sorting |
840 |
|
840 |
|
841 |
=back |
841 |
=back |
842 |
|
842 |
|
843 |
=cut |
843 |
=cut |
844 |
|
844 |
|
845 |
sub GetItemsLocationInfo { |
845 |
sub GetItemsLocationInfo { |
Lines 1618-1646
sub PrepareItemrecordDisplay {
Link Here
|
1618 |
|
1618 |
|
1619 |
# loop through each subfield |
1619 |
# loop through each subfield |
1620 |
my $cntsubf; |
1620 |
my $cntsubf; |
1621 |
foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) { |
1621 |
foreach my $subfield ( |
1622 |
next if IsMarcStructureInternal($tagslib->{$tag}{$subfield}); |
1622 |
sort { $a->{display_order} <=> $b->{display_order} || $a->{subfield} cmp $b->{subfield} } |
1623 |
next unless ( $tagslib->{$tag}->{$subfield}->{'tab'} ); |
1623 |
grep { ref($_) && %$_ } # Not a subfield (values for "important", "lib", "mandatory", etc.) or empty |
1624 |
next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" ); |
1624 |
values %{ $tagslib->{$tag} } ) |
|
|
1625 |
{ |
1626 |
next unless ( $subfield->{'tab'} ); |
1627 |
next if ( $subfield->{'tab'} ne "10" ); |
1625 |
my %subfield_data; |
1628 |
my %subfield_data; |
1626 |
$subfield_data{tag} = $tag; |
1629 |
$subfield_data{tag} = $tag; |
1627 |
$subfield_data{subfield} = $subfield; |
1630 |
$subfield_data{subfield} = $subfield->{subfield}; |
1628 |
$subfield_data{countsubfield} = $cntsubf++; |
1631 |
$subfield_data{countsubfield} = $cntsubf++; |
1629 |
$subfield_data{kohafield} = $tagslib->{$tag}->{$subfield}->{'kohafield'}; |
1632 |
$subfield_data{kohafield} = $subfield->{kohafield}; |
1630 |
$subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".int(rand(1000000)); |
1633 |
$subfield_data{id} = "tag_".$tag."_subfield_".$subfield->{subfield}."_".int(rand(1000000)); |
1631 |
|
1634 |
|
1632 |
# $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; |
1635 |
# $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; |
1633 |
$subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib}; |
1636 |
$subfield_data{marc_lib} = $subfield->{lib}; |
1634 |
$subfield_data{mandatory} = $tagslib->{$tag}->{$subfield}->{mandatory}; |
1637 |
$subfield_data{mandatory} = $subfield->{mandatory}; |
1635 |
$subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable}; |
1638 |
$subfield_data{repeatable} = $subfield->{repeatable}; |
1636 |
$subfield_data{hidden} = "display:none" |
1639 |
$subfield_data{hidden} = "display:none" |
1637 |
if ( ( $tagslib->{$tag}->{$subfield}->{hidden} > 4 ) |
1640 |
if ( ( $subfield->{hidden} > 4 ) |
1638 |
|| ( $tagslib->{$tag}->{$subfield}->{hidden} < -4 ) ); |
1641 |
|| ( $subfield->{hidden} < -4 ) ); |
1639 |
my ( $x, $defaultvalue ); |
1642 |
my ( $x, $defaultvalue ); |
1640 |
if ($itemrecord) { |
1643 |
if ($itemrecord) { |
1641 |
( $x, $defaultvalue ) = _find_value( $tag, $subfield, $itemrecord ); |
1644 |
( $x, $defaultvalue ) = _find_value( $tag, $subfield->{subfield}, $itemrecord ); |
1642 |
} |
1645 |
} |
1643 |
$defaultvalue = $tagslib->{$tag}->{$subfield}->{defaultvalue} unless $defaultvalue; |
1646 |
$defaultvalue = $subfield->{defaultvalue} unless $defaultvalue; |
1644 |
if ( !defined $defaultvalue ) { |
1647 |
if ( !defined $defaultvalue ) { |
1645 |
$defaultvalue = q||; |
1648 |
$defaultvalue = q||; |
1646 |
} else { |
1649 |
} else { |
Lines 1664-1673
sub PrepareItemrecordDisplay {
Link Here
|
1664 |
$defaultvalue =~ s/<<USER>>/$username/g; |
1667 |
$defaultvalue =~ s/<<USER>>/$username/g; |
1665 |
} |
1668 |
} |
1666 |
|
1669 |
|
1667 |
my $maxlength = $tagslib->{$tag}->{$subfield}->{maxlength}; |
1670 |
my $maxlength = $subfield->{maxlength}; |
1668 |
|
1671 |
|
1669 |
# search for itemcallnumber if applicable |
1672 |
# search for itemcallnumber if applicable |
1670 |
if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' |
1673 |
if ( $subfield->{kohafield} eq 'items.itemcallnumber' |
1671 |
&& C4::Context->preference('itemcallnumber') && $itemrecord) { |
1674 |
&& C4::Context->preference('itemcallnumber') && $itemrecord) { |
1672 |
foreach my $itemcn_pref (split(/,/,C4::Context->preference('itemcallnumber'))){ |
1675 |
foreach my $itemcn_pref (split(/,/,C4::Context->preference('itemcallnumber'))){ |
1673 |
my $CNtag = substr( $itemcn_pref, 0, 3 ); |
1676 |
my $CNtag = substr( $itemcn_pref, 0, 3 ); |
Lines 1677-1686
sub PrepareItemrecordDisplay {
Link Here
|
1677 |
last if $defaultvalue; |
1680 |
last if $defaultvalue; |
1678 |
} |
1681 |
} |
1679 |
} |
1682 |
} |
1680 |
if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' |
1683 |
if ( $subfield->{kohafield} eq 'items.itemcallnumber' |
1681 |
&& $defaultvalues |
1684 |
&& $defaultvalues |
1682 |
&& $defaultvalues->{'callnumber'} ) { |
1685 |
&& $defaultvalues->{'callnumber'} ) { |
1683 |
if( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ){ |
1686 |
if( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield->{subfield}) ){ |
1684 |
# if the item record exists, only use default value if the item has no callnumber |
1687 |
# if the item record exists, only use default value if the item has no callnumber |
1685 |
$defaultvalue = $defaultvalues->{callnumber}; |
1688 |
$defaultvalue = $defaultvalues->{callnumber}; |
1686 |
} elsif ( !$itemrecord and $defaultvalues ) { |
1689 |
} elsif ( !$itemrecord and $defaultvalues ) { |
Lines 1688-1705
sub PrepareItemrecordDisplay {
Link Here
|
1688 |
$defaultvalue = $defaultvalues->{callnumber}; |
1691 |
$defaultvalue = $defaultvalues->{callnumber}; |
1689 |
} |
1692 |
} |
1690 |
} |
1693 |
} |
1691 |
if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.holdingbranch' || $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.homebranch' ) |
1694 |
if ( ( $subfield->{kohafield} eq 'items.holdingbranch' || $subfield->{kohafield} eq 'items.homebranch' ) |
1692 |
&& $defaultvalues |
1695 |
&& $defaultvalues |
1693 |
&& $defaultvalues->{'branchcode'} ) { |
1696 |
&& $defaultvalues->{'branchcode'} ) { |
1694 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ) { |
1697 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ) { |
1695 |
$defaultvalue = $defaultvalues->{branchcode}; |
1698 |
$defaultvalue = $defaultvalues->{branchcode}; |
1696 |
} |
1699 |
} |
1697 |
} |
1700 |
} |
1698 |
if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.location' ) |
1701 |
if ( ( $subfield->{kohafield} eq 'items.location' ) |
1699 |
&& $defaultvalues |
1702 |
&& $defaultvalues |
1700 |
&& $defaultvalues->{'location'} ) { |
1703 |
&& $defaultvalues->{'location'} ) { |
1701 |
|
1704 |
|
1702 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ) { |
1705 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield->{subfield}) ) { |
1703 |
# if the item record exists, only use default value if the item has no locationr |
1706 |
# if the item record exists, only use default value if the item has no locationr |
1704 |
$defaultvalue = $defaultvalues->{location}; |
1707 |
$defaultvalue = $defaultvalues->{location}; |
1705 |
} elsif ( !$itemrecord and $defaultvalues ) { |
1708 |
} elsif ( !$itemrecord and $defaultvalues ) { |
Lines 1707-1725
sub PrepareItemrecordDisplay {
Link Here
|
1707 |
$defaultvalue = $defaultvalues->{location}; |
1710 |
$defaultvalue = $defaultvalues->{location}; |
1708 |
} |
1711 |
} |
1709 |
} |
1712 |
} |
1710 |
if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { |
1713 |
if ( $subfield->{authorised_value} ) { |
1711 |
my @authorised_values; |
1714 |
my @authorised_values; |
1712 |
my %authorised_lib; |
1715 |
my %authorised_lib; |
1713 |
|
1716 |
|
1714 |
# builds list, depending on authorised value... |
1717 |
# builds list, depending on authorised value... |
1715 |
#---- branch |
1718 |
#---- branch |
1716 |
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { |
1719 |
if ( $subfield->{'authorised_value'} eq "branches" ) { |
1717 |
if ( ( C4::Context->preference("IndependentBranches") ) |
1720 |
if ( ( C4::Context->preference("IndependentBranches") ) |
1718 |
&& !C4::Context->IsSuperLibrarian() ) { |
1721 |
&& !C4::Context->IsSuperLibrarian() ) { |
1719 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" ); |
1722 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" ); |
1720 |
$sth->execute( C4::Context->userenv->{branch} ); |
1723 |
$sth->execute( C4::Context->userenv->{branch} ); |
1721 |
push @authorised_values, "" |
1724 |
push @authorised_values, "" |
1722 |
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
1725 |
unless ( $subfield->{mandatory} ); |
1723 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1726 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1724 |
push @authorised_values, $branchcode; |
1727 |
push @authorised_values, $branchcode; |
1725 |
$authorised_lib{$branchcode} = $branchname; |
1728 |
$authorised_lib{$branchcode} = $branchname; |
Lines 1728-1734
sub PrepareItemrecordDisplay {
Link Here
|
1728 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches ORDER BY branchname" ); |
1731 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches ORDER BY branchname" ); |
1729 |
$sth->execute; |
1732 |
$sth->execute; |
1730 |
push @authorised_values, "" |
1733 |
push @authorised_values, "" |
1731 |
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
1734 |
unless ( $subfield->{mandatory} ); |
1732 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1735 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1733 |
push @authorised_values, $branchcode; |
1736 |
push @authorised_values, $branchcode; |
1734 |
$authorised_lib{$branchcode} = $branchname; |
1737 |
$authorised_lib{$branchcode} = $branchname; |
Lines 1741-1747
sub PrepareItemrecordDisplay {
Link Here
|
1741 |
} |
1744 |
} |
1742 |
|
1745 |
|
1743 |
#----- itemtypes |
1746 |
#----- itemtypes |
1744 |
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { |
1747 |
} elsif ( $subfield->{authorised_value} eq "itemtypes" ) { |
1745 |
my $itemtypes = Koha::ItemTypes->search_with_localization; |
1748 |
my $itemtypes = Koha::ItemTypes->search_with_localization; |
1746 |
push @authorised_values, ""; |
1749 |
push @authorised_values, ""; |
1747 |
while ( my $itemtype = $itemtypes->next ) { |
1750 |
while ( my $itemtype = $itemtypes->next ) { |
Lines 1753-1759
sub PrepareItemrecordDisplay {
Link Here
|
1753 |
} |
1756 |
} |
1754 |
|
1757 |
|
1755 |
#---- class_sources |
1758 |
#---- class_sources |
1756 |
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) { |
1759 |
} elsif ( $subfield->{authorised_value} eq "cn_source" ) { |
1757 |
push @authorised_values, ""; |
1760 |
push @authorised_values, ""; |
1758 |
|
1761 |
|
1759 |
my $class_sources = GetClassSources(); |
1762 |
my $class_sources = GetClassSources(); |
Lines 1771-1777
sub PrepareItemrecordDisplay {
Link Here
|
1771 |
#---- "true" authorised value |
1774 |
#---- "true" authorised value |
1772 |
} else { |
1775 |
} else { |
1773 |
$authorised_values_sth->execute( |
1776 |
$authorised_values_sth->execute( |
1774 |
$tagslib->{$tag}->{$subfield}->{authorised_value}, |
1777 |
$subfield->{authorised_value}, |
1775 |
$branch_limit ? $branch_limit : () |
1778 |
$branch_limit ? $branch_limit : () |
1776 |
); |
1779 |
); |
1777 |
push @authorised_values, ""; |
1780 |
push @authorised_values, ""; |
Lines 1786-1802
sub PrepareItemrecordDisplay {
Link Here
|
1786 |
default => $defaultvalue // q{}, |
1789 |
default => $defaultvalue // q{}, |
1787 |
labels => \%authorised_lib, |
1790 |
labels => \%authorised_lib, |
1788 |
}; |
1791 |
}; |
1789 |
} elsif ( $tagslib->{$tag}->{$subfield}->{value_builder} ) { |
1792 |
} elsif ( $subfield->{value_builder} ) { |
1790 |
# it is a plugin |
1793 |
# it is a plugin |
1791 |
require Koha::FrameworkPlugin; |
1794 |
require Koha::FrameworkPlugin; |
1792 |
my $plugin = Koha::FrameworkPlugin->new({ |
1795 |
my $plugin = Koha::FrameworkPlugin->new({ |
1793 |
name => $tagslib->{$tag}->{$subfield}->{value_builder}, |
1796 |
name => $subfield->{value_builder}, |
1794 |
item_style => 1, |
1797 |
item_style => 1, |
1795 |
}); |
1798 |
}); |
1796 |
my $pars = { dbh => $dbh, record => undef, tagslib =>$tagslib, id => $subfield_data{id}, tabloop => undef }; |
1799 |
my $pars = { dbh => $dbh, record => undef, tagslib =>$tagslib, id => $subfield_data{id}, tabloop => undef }; |
1797 |
$plugin->build( $pars ); |
1800 |
$plugin->build( $pars ); |
1798 |
if ( $itemrecord and my $field = $itemrecord->field($tag) ) { |
1801 |
if ( $itemrecord and my $field = $itemrecord->field($tag) ) { |
1799 |
$defaultvalue = $field->subfield($subfield) || q{}; |
1802 |
$defaultvalue = $field->subfield($subfield->{subfield}) || q{}; |
1800 |
} |
1803 |
} |
1801 |
if( !$plugin->errstr ) { |
1804 |
if( !$plugin->errstr ) { |
1802 |
#TODO Move html to template; see report 12176/13397 |
1805 |
#TODO Move html to template; see report 12176/13397 |
Lines 1812-1823
sub PrepareItemrecordDisplay {
Link Here
|
1812 |
elsif ( $tag eq '' ) { # it's an hidden field |
1815 |
elsif ( $tag eq '' ) { # it's an hidden field |
1813 |
$subfield_data{marc_value} = qq(<input type="hidden" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1816 |
$subfield_data{marc_value} = qq(<input type="hidden" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1814 |
} |
1817 |
} |
1815 |
elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ? |
1818 |
elsif ( $subfield->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ? |
1816 |
$subfield_data{marc_value} = qq(<input type="text" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1819 |
$subfield_data{marc_value} = qq(<input type="text" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1817 |
} |
1820 |
} |
1818 |
elsif ( length($defaultvalue) > 100 |
1821 |
elsif ( length($defaultvalue) > 100 |
1819 |
or (C4::Context->preference("marcflavour") eq "UNIMARC" and |
1822 |
or (C4::Context->preference("marcflavour") eq "UNIMARC" and |
1820 |
300 <= $tag && $tag < 400 && $subfield eq 'a' ) |
1823 |
300 <= $tag && $tag < 400 && $subfield->{subfield} eq 'a' ) |
1821 |
or (C4::Context->preference("marcflavour") eq "MARC21" and |
1824 |
or (C4::Context->preference("marcflavour") eq "MARC21" and |
1822 |
500 <= $tag && $tag < 600 ) |
1825 |
500 <= $tag && $tag < 600 ) |
1823 |
) { |
1826 |
) { |