|
Lines 68-74
BEGIN {
Link Here
|
| 68 |
|
68 |
|
| 69 |
CheckItemPreSave |
69 |
CheckItemPreSave |
| 70 |
|
70 |
|
| 71 |
GetItemLocation |
|
|
| 72 |
GetLostItems |
71 |
GetLostItems |
| 73 |
GetItemsForInventory |
72 |
GetItemsForInventory |
| 74 |
GetItemInfosOf |
73 |
GetItemInfosOf |
|
Lines 776-866
has copy-and-paste work.
Link Here
|
| 776 |
|
775 |
|
| 777 |
=cut |
776 |
=cut |
| 778 |
|
777 |
|
| 779 |
=head2 GetItemLocation |
|
|
| 780 |
|
| 781 |
$itemlochash = GetItemLocation($fwk); |
| 782 |
|
| 783 |
Returns a list of valid values for the |
| 784 |
C<items.location> field. |
| 785 |
|
| 786 |
NOTE: does B<not> return an individual item's |
| 787 |
location. |
| 788 |
|
| 789 |
where fwk stands for an optional framework code. |
| 790 |
Create a location selector with the following code |
| 791 |
|
| 792 |
=head3 in PERL SCRIPT |
| 793 |
|
| 794 |
my $itemlochash = getitemlocation; |
| 795 |
my @itemlocloop; |
| 796 |
foreach my $thisloc (keys %$itemlochash) { |
| 797 |
my $selected = 1 if $thisbranch eq $branch; |
| 798 |
my %row =(locval => $thisloc, |
| 799 |
selected => $selected, |
| 800 |
locname => $itemlochash->{$thisloc}, |
| 801 |
); |
| 802 |
push @itemlocloop, \%row; |
| 803 |
} |
| 804 |
$template->param(itemlocationloop => \@itemlocloop); |
| 805 |
|
| 806 |
=head3 in TEMPLATE |
| 807 |
|
| 808 |
<select name="location"> |
| 809 |
<option value="">Default</option> |
| 810 |
<!-- TMPL_LOOP name="itemlocationloop" --> |
| 811 |
<option value="<!-- TMPL_VAR name="locval" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="locname" --></option> |
| 812 |
<!-- /TMPL_LOOP --> |
| 813 |
</select> |
| 814 |
|
| 815 |
=cut |
| 816 |
|
| 817 |
sub GetItemLocation { |
| 818 |
|
| 819 |
# returns a reference to a hash of references to location... |
| 820 |
my ($fwk) = @_; |
| 821 |
my %itemlocation; |
| 822 |
my $dbh = C4::Context->dbh; |
| 823 |
my $sth; |
| 824 |
$fwk = '' unless ($fwk); |
| 825 |
my ( $tag, $subfield ) = |
| 826 |
GetMarcFromKohaField( "items.location", $fwk ); |
| 827 |
if ( $tag and $subfield ) { |
| 828 |
my $sth = |
| 829 |
$dbh->prepare( |
| 830 |
"SELECT authorised_value |
| 831 |
FROM marc_subfield_structure |
| 832 |
WHERE tagfield=? |
| 833 |
AND tagsubfield=? |
| 834 |
AND frameworkcode=?" |
| 835 |
); |
| 836 |
$sth->execute( $tag, $subfield, $fwk ); |
| 837 |
if ( my ($authorisedvaluecat) = $sth->fetchrow ) { |
| 838 |
my $authvalsth = |
| 839 |
$dbh->prepare( |
| 840 |
"SELECT authorised_value,lib |
| 841 |
FROM authorised_values |
| 842 |
WHERE category=? |
| 843 |
ORDER BY lib" |
| 844 |
); |
| 845 |
$authvalsth->execute($authorisedvaluecat); |
| 846 |
while ( my ( $authorisedvalue, $lib ) = $authvalsth->fetchrow ) { |
| 847 |
$itemlocation{$authorisedvalue} = $lib; |
| 848 |
} |
| 849 |
return \%itemlocation; |
| 850 |
} |
| 851 |
else { |
| 852 |
|
| 853 |
#No authvalue list |
| 854 |
# build default |
| 855 |
} |
| 856 |
} |
| 857 |
|
| 858 |
#No authvalue list |
| 859 |
#build default |
| 860 |
$itemlocation{"1"} = "Not For Loan"; |
| 861 |
return \%itemlocation; |
| 862 |
} |
| 863 |
|
| 864 |
=head2 GetLostItems |
778 |
=head2 GetLostItems |
| 865 |
|
779 |
|
| 866 |
$items = GetLostItems( $where ); |
780 |
$items = GetLostItems( $where ); |
| 867 |
- |
|
|