Lines 831-837
Item's itemcallnumber
Link Here
|
831 |
Item's call number normalized for sorting |
831 |
Item's call number normalized for sorting |
832 |
|
832 |
|
833 |
=back |
833 |
=back |
834 |
|
834 |
|
835 |
=cut |
835 |
=cut |
836 |
|
836 |
|
837 |
sub GetItemsLocationInfo { |
837 |
sub GetItemsLocationInfo { |
Lines 1610-1638
sub PrepareItemrecordDisplay {
Link Here
|
1610 |
|
1610 |
|
1611 |
# loop through each subfield |
1611 |
# loop through each subfield |
1612 |
my $cntsubf; |
1612 |
my $cntsubf; |
1613 |
foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) { |
1613 |
foreach my $subfield ( |
1614 |
next if IsMarcStructureInternal($tagslib->{$tag}{$subfield}); |
1614 |
sort { $a->{display_order} <=> $b->{display_order} || $a->{subfield} cmp $b->{subfield} } |
1615 |
next unless ( $tagslib->{$tag}->{$subfield}->{'tab'} ); |
1615 |
grep { ref($_) && %$_ } # Not a subfield (values for "important", "lib", "mandatory", etc.) or empty |
1616 |
next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" ); |
1616 |
values %{ $tagslib->{$tag} } ) |
|
|
1617 |
{ |
1618 |
next unless ( $subfield->{'tab'} ); |
1619 |
next if ( $subfield->{'tab'} ne "10" ); |
1617 |
my %subfield_data; |
1620 |
my %subfield_data; |
1618 |
$subfield_data{tag} = $tag; |
1621 |
$subfield_data{tag} = $tag; |
1619 |
$subfield_data{subfield} = $subfield; |
1622 |
$subfield_data{subfield} = $subfield->{subfield}; |
1620 |
$subfield_data{countsubfield} = $cntsubf++; |
1623 |
$subfield_data{countsubfield} = $cntsubf++; |
1621 |
$subfield_data{kohafield} = $tagslib->{$tag}->{$subfield}->{'kohafield'}; |
1624 |
$subfield_data{kohafield} = $subfield->{kohafield}; |
1622 |
$subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".int(rand(1000000)); |
1625 |
$subfield_data{id} = "tag_".$tag."_subfield_".$subfield->{subfield}."_".int(rand(1000000)); |
1623 |
|
1626 |
|
1624 |
# $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; |
1627 |
# $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; |
1625 |
$subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib}; |
1628 |
$subfield_data{marc_lib} = $subfield->{lib}; |
1626 |
$subfield_data{mandatory} = $tagslib->{$tag}->{$subfield}->{mandatory}; |
1629 |
$subfield_data{mandatory} = $subfield->{mandatory}; |
1627 |
$subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable}; |
1630 |
$subfield_data{repeatable} = $subfield->{repeatable}; |
1628 |
$subfield_data{hidden} = "display:none" |
1631 |
$subfield_data{hidden} = "display:none" |
1629 |
if ( ( $tagslib->{$tag}->{$subfield}->{hidden} > 4 ) |
1632 |
if ( ( $subfield->{hidden} > 4 ) |
1630 |
|| ( $tagslib->{$tag}->{$subfield}->{hidden} < -4 ) ); |
1633 |
|| ( $subfield->{hidden} < -4 ) ); |
1631 |
my ( $x, $defaultvalue ); |
1634 |
my ( $x, $defaultvalue ); |
1632 |
if ($itemrecord) { |
1635 |
if ($itemrecord) { |
1633 |
( $x, $defaultvalue ) = _find_value( $tag, $subfield, $itemrecord ); |
1636 |
( $x, $defaultvalue ) = _find_value( $tag, $subfield->{subfield}, $itemrecord ); |
1634 |
} |
1637 |
} |
1635 |
$defaultvalue = $tagslib->{$tag}->{$subfield}->{defaultvalue} unless $defaultvalue; |
1638 |
$defaultvalue = $subfield->{defaultvalue} unless $defaultvalue; |
1636 |
if ( !defined $defaultvalue ) { |
1639 |
if ( !defined $defaultvalue ) { |
1637 |
$defaultvalue = q||; |
1640 |
$defaultvalue = q||; |
1638 |
} else { |
1641 |
} else { |
Lines 1656-1665
sub PrepareItemrecordDisplay {
Link Here
|
1656 |
$defaultvalue =~ s/<<USER>>/$username/g; |
1659 |
$defaultvalue =~ s/<<USER>>/$username/g; |
1657 |
} |
1660 |
} |
1658 |
|
1661 |
|
1659 |
my $maxlength = $tagslib->{$tag}->{$subfield}->{maxlength}; |
1662 |
my $maxlength = $subfield->{maxlength}; |
1660 |
|
1663 |
|
1661 |
# search for itemcallnumber if applicable |
1664 |
# search for itemcallnumber if applicable |
1662 |
if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' |
1665 |
if ( $subfield->{kohafield} eq 'items.itemcallnumber' |
1663 |
&& C4::Context->preference('itemcallnumber') && $itemrecord) { |
1666 |
&& C4::Context->preference('itemcallnumber') && $itemrecord) { |
1664 |
foreach my $itemcn_pref (split(/,/,C4::Context->preference('itemcallnumber'))){ |
1667 |
foreach my $itemcn_pref (split(/,/,C4::Context->preference('itemcallnumber'))){ |
1665 |
my $CNtag = substr( $itemcn_pref, 0, 3 ); |
1668 |
my $CNtag = substr( $itemcn_pref, 0, 3 ); |
Lines 1669-1678
sub PrepareItemrecordDisplay {
Link Here
|
1669 |
last if $defaultvalue; |
1672 |
last if $defaultvalue; |
1670 |
} |
1673 |
} |
1671 |
} |
1674 |
} |
1672 |
if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' |
1675 |
if ( $subfield->{kohafield} eq 'items.itemcallnumber' |
1673 |
&& $defaultvalues |
1676 |
&& $defaultvalues |
1674 |
&& $defaultvalues->{'callnumber'} ) { |
1677 |
&& $defaultvalues->{'callnumber'} ) { |
1675 |
if( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ){ |
1678 |
if( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield->{subfield}) ){ |
1676 |
# if the item record exists, only use default value if the item has no callnumber |
1679 |
# if the item record exists, only use default value if the item has no callnumber |
1677 |
$defaultvalue = $defaultvalues->{callnumber}; |
1680 |
$defaultvalue = $defaultvalues->{callnumber}; |
1678 |
} elsif ( !$itemrecord and $defaultvalues ) { |
1681 |
} elsif ( !$itemrecord and $defaultvalues ) { |
Lines 1680-1697
sub PrepareItemrecordDisplay {
Link Here
|
1680 |
$defaultvalue = $defaultvalues->{callnumber}; |
1683 |
$defaultvalue = $defaultvalues->{callnumber}; |
1681 |
} |
1684 |
} |
1682 |
} |
1685 |
} |
1683 |
if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.holdingbranch' || $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.homebranch' ) |
1686 |
if ( ( $subfield->{kohafield} eq 'items.holdingbranch' || $subfield->{kohafield} eq 'items.homebranch' ) |
1684 |
&& $defaultvalues |
1687 |
&& $defaultvalues |
1685 |
&& $defaultvalues->{'branchcode'} ) { |
1688 |
&& $defaultvalues->{'branchcode'} ) { |
1686 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ) { |
1689 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ) { |
1687 |
$defaultvalue = $defaultvalues->{branchcode}; |
1690 |
$defaultvalue = $defaultvalues->{branchcode}; |
1688 |
} |
1691 |
} |
1689 |
} |
1692 |
} |
1690 |
if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.location' ) |
1693 |
if ( ( $subfield->{kohafield} eq 'items.location' ) |
1691 |
&& $defaultvalues |
1694 |
&& $defaultvalues |
1692 |
&& $defaultvalues->{'location'} ) { |
1695 |
&& $defaultvalues->{'location'} ) { |
1693 |
|
1696 |
|
1694 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ) { |
1697 |
if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield->{subfield}) ) { |
1695 |
# if the item record exists, only use default value if the item has no locationr |
1698 |
# if the item record exists, only use default value if the item has no locationr |
1696 |
$defaultvalue = $defaultvalues->{location}; |
1699 |
$defaultvalue = $defaultvalues->{location}; |
1697 |
} elsif ( !$itemrecord and $defaultvalues ) { |
1700 |
} elsif ( !$itemrecord and $defaultvalues ) { |
Lines 1699-1717
sub PrepareItemrecordDisplay {
Link Here
|
1699 |
$defaultvalue = $defaultvalues->{location}; |
1702 |
$defaultvalue = $defaultvalues->{location}; |
1700 |
} |
1703 |
} |
1701 |
} |
1704 |
} |
1702 |
if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { |
1705 |
if ( $subfield->{authorised_value} ) { |
1703 |
my @authorised_values; |
1706 |
my @authorised_values; |
1704 |
my %authorised_lib; |
1707 |
my %authorised_lib; |
1705 |
|
1708 |
|
1706 |
# builds list, depending on authorised value... |
1709 |
# builds list, depending on authorised value... |
1707 |
#---- branch |
1710 |
#---- branch |
1708 |
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { |
1711 |
if ( $subfield->{'authorised_value'} eq "branches" ) { |
1709 |
if ( ( C4::Context->preference("IndependentBranches") ) |
1712 |
if ( ( C4::Context->preference("IndependentBranches") ) |
1710 |
&& !C4::Context->IsSuperLibrarian() ) { |
1713 |
&& !C4::Context->IsSuperLibrarian() ) { |
1711 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" ); |
1714 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" ); |
1712 |
$sth->execute( C4::Context->userenv->{branch} ); |
1715 |
$sth->execute( C4::Context->userenv->{branch} ); |
1713 |
push @authorised_values, "" |
1716 |
push @authorised_values, "" |
1714 |
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
1717 |
unless ( $subfield->{mandatory} ); |
1715 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1718 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1716 |
push @authorised_values, $branchcode; |
1719 |
push @authorised_values, $branchcode; |
1717 |
$authorised_lib{$branchcode} = $branchname; |
1720 |
$authorised_lib{$branchcode} = $branchname; |
Lines 1720-1726
sub PrepareItemrecordDisplay {
Link Here
|
1720 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches ORDER BY branchname" ); |
1723 |
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches ORDER BY branchname" ); |
1721 |
$sth->execute; |
1724 |
$sth->execute; |
1722 |
push @authorised_values, "" |
1725 |
push @authorised_values, "" |
1723 |
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
1726 |
unless ( $subfield->{mandatory} ); |
1724 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1727 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
1725 |
push @authorised_values, $branchcode; |
1728 |
push @authorised_values, $branchcode; |
1726 |
$authorised_lib{$branchcode} = $branchname; |
1729 |
$authorised_lib{$branchcode} = $branchname; |
Lines 1733-1739
sub PrepareItemrecordDisplay {
Link Here
|
1733 |
} |
1736 |
} |
1734 |
|
1737 |
|
1735 |
#----- itemtypes |
1738 |
#----- itemtypes |
1736 |
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { |
1739 |
} elsif ( $subfield->{authorised_value} eq "itemtypes" ) { |
1737 |
my $itemtypes = Koha::ItemTypes->search_with_localization; |
1740 |
my $itemtypes = Koha::ItemTypes->search_with_localization; |
1738 |
push @authorised_values, ""; |
1741 |
push @authorised_values, ""; |
1739 |
while ( my $itemtype = $itemtypes->next ) { |
1742 |
while ( my $itemtype = $itemtypes->next ) { |
Lines 1745-1751
sub PrepareItemrecordDisplay {
Link Here
|
1745 |
} |
1748 |
} |
1746 |
|
1749 |
|
1747 |
#---- class_sources |
1750 |
#---- class_sources |
1748 |
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) { |
1751 |
} elsif ( $subfield->{authorised_value} eq "cn_source" ) { |
1749 |
push @authorised_values, ""; |
1752 |
push @authorised_values, ""; |
1750 |
|
1753 |
|
1751 |
my $class_sources = GetClassSources(); |
1754 |
my $class_sources = GetClassSources(); |
Lines 1763-1769
sub PrepareItemrecordDisplay {
Link Here
|
1763 |
#---- "true" authorised value |
1766 |
#---- "true" authorised value |
1764 |
} else { |
1767 |
} else { |
1765 |
$authorised_values_sth->execute( |
1768 |
$authorised_values_sth->execute( |
1766 |
$tagslib->{$tag}->{$subfield}->{authorised_value}, |
1769 |
$subfield->{authorised_value}, |
1767 |
$branch_limit ? $branch_limit : () |
1770 |
$branch_limit ? $branch_limit : () |
1768 |
); |
1771 |
); |
1769 |
push @authorised_values, ""; |
1772 |
push @authorised_values, ""; |
Lines 1778-1794
sub PrepareItemrecordDisplay {
Link Here
|
1778 |
default => $defaultvalue // q{}, |
1781 |
default => $defaultvalue // q{}, |
1779 |
labels => \%authorised_lib, |
1782 |
labels => \%authorised_lib, |
1780 |
}; |
1783 |
}; |
1781 |
} elsif ( $tagslib->{$tag}->{$subfield}->{value_builder} ) { |
1784 |
} elsif ( $subfield->{value_builder} ) { |
1782 |
# it is a plugin |
1785 |
# it is a plugin |
1783 |
require Koha::FrameworkPlugin; |
1786 |
require Koha::FrameworkPlugin; |
1784 |
my $plugin = Koha::FrameworkPlugin->new({ |
1787 |
my $plugin = Koha::FrameworkPlugin->new({ |
1785 |
name => $tagslib->{$tag}->{$subfield}->{value_builder}, |
1788 |
name => $subfield->{value_builder}, |
1786 |
item_style => 1, |
1789 |
item_style => 1, |
1787 |
}); |
1790 |
}); |
1788 |
my $pars = { dbh => $dbh, record => undef, tagslib =>$tagslib, id => $subfield_data{id}, tabloop => undef }; |
1791 |
my $pars = { dbh => $dbh, record => undef, tagslib =>$tagslib, id => $subfield_data{id}, tabloop => undef }; |
1789 |
$plugin->build( $pars ); |
1792 |
$plugin->build( $pars ); |
1790 |
if ( $itemrecord and my $field = $itemrecord->field($tag) ) { |
1793 |
if ( $itemrecord and my $field = $itemrecord->field($tag) ) { |
1791 |
$defaultvalue = $field->subfield($subfield) || q{}; |
1794 |
$defaultvalue = $field->subfield($subfield->{subfield}) || q{}; |
1792 |
} |
1795 |
} |
1793 |
if( !$plugin->errstr ) { |
1796 |
if( !$plugin->errstr ) { |
1794 |
#TODO Move html to template; see report 12176/13397 |
1797 |
#TODO Move html to template; see report 12176/13397 |
Lines 1804-1815
sub PrepareItemrecordDisplay {
Link Here
|
1804 |
elsif ( $tag eq '' ) { # it's an hidden field |
1807 |
elsif ( $tag eq '' ) { # it's an hidden field |
1805 |
$subfield_data{marc_value} = qq(<input type="hidden" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1808 |
$subfield_data{marc_value} = qq(<input type="hidden" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1806 |
} |
1809 |
} |
1807 |
elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ? |
1810 |
elsif ( $subfield->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ? |
1808 |
$subfield_data{marc_value} = qq(<input type="text" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1811 |
$subfield_data{marc_value} = qq(<input type="text" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$maxlength" value="$defaultvalue" />); |
1809 |
} |
1812 |
} |
1810 |
elsif ( length($defaultvalue) > 100 |
1813 |
elsif ( length($defaultvalue) > 100 |
1811 |
or (C4::Context->preference("marcflavour") eq "UNIMARC" and |
1814 |
or (C4::Context->preference("marcflavour") eq "UNIMARC" and |
1812 |
300 <= $tag && $tag < 400 && $subfield eq 'a' ) |
1815 |
300 <= $tag && $tag < 400 && $subfield->{subfield} eq 'a' ) |
1813 |
or (C4::Context->preference("marcflavour") eq "MARC21" and |
1816 |
or (C4::Context->preference("marcflavour") eq "MARC21" and |
1814 |
500 <= $tag && $tag < 600 ) |
1817 |
500 <= $tag && $tag < 600 ) |
1815 |
) { |
1818 |
) { |