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