View | Details | Raw Unified | Return to bug 18274
Collapse All | Expand All

(-)a/C4/Items.pm (-93 lines)
Lines 67-73 BEGIN { Link Here
67
    
67
    
68
        CheckItemPreSave
68
        CheckItemPreSave
69
    
69
    
70
        GetItemStatus
71
        GetItemLocation
70
        GetItemLocation
72
        GetLostItems
71
        GetLostItems
73
        GetItemsForInventory
72
        GetItemsForInventory
Lines 780-876 has copy-and-paste work. Link Here
780
779
781
=cut
780
=cut
782
781
783
=head2 GetItemStatus
784
785
  $itemstatushash = GetItemStatus($fwkcode);
786
787
Returns a list of valid values for the
788
C<items.notforloan> field.
789
790
NOTE: does B<not> return an individual item's
791
status.
792
793
Can be MARC dependent.
794
fwkcode is optional.
795
But basically could be can be loan or not
796
Create a status selector with the following code
797
798
=head3 in PERL SCRIPT
799
800
 my $itemstatushash = getitemstatus;
801
 my @itemstatusloop;
802
 foreach my $thisstatus (keys %$itemstatushash) {
803
     my %row =(value => $thisstatus,
804
                 statusname => $itemstatushash->{$thisstatus}->{'statusname'},
805
             );
806
     push @itemstatusloop, \%row;
807
 }
808
 $template->param(statusloop=>\@itemstatusloop);
809
810
=head3 in TEMPLATE
811
812
<select name="statusloop" id="statusloop">
813
    <option value="">Default</option>
814
    [% FOREACH statusloo IN statusloop %]
815
        [% IF ( statusloo.selected ) %]
816
            <option value="[% statusloo.value %]" selected="selected">[% statusloo.statusname %]</option>
817
        [% ELSE %]
818
            <option value="[% statusloo.value %]">[% statusloo.statusname %]</option>
819
        [% END %]
820
    [% END %]
821
</select>
822
823
=cut
824
825
sub GetItemStatus {
826
827
    # returns a reference to a hash of references to status...
828
    my ($fwk) = @_;
829
    my %itemstatus;
830
    my $dbh = C4::Context->dbh;
831
    my $sth;
832
    $fwk = '' unless ($fwk);
833
    my ( $tag, $subfield ) =
834
      GetMarcFromKohaField( "items.notforloan", $fwk );
835
    if ( $tag and $subfield ) {
836
        my $sth =
837
          $dbh->prepare(
838
            "SELECT authorised_value
839
            FROM marc_subfield_structure
840
            WHERE tagfield=?
841
                AND tagsubfield=?
842
                AND frameworkcode=?
843
            "
844
          );
845
        $sth->execute( $tag, $subfield, $fwk );
846
        if ( my ($authorisedvaluecat) = $sth->fetchrow ) {
847
            my $authvalsth =
848
              $dbh->prepare(
849
                "SELECT authorised_value,lib
850
                FROM authorised_values 
851
                WHERE category=? 
852
                ORDER BY lib
853
                "
854
              );
855
            $authvalsth->execute($authorisedvaluecat);
856
            while ( my ( $authorisedvalue, $lib ) = $authvalsth->fetchrow ) {
857
                $itemstatus{$authorisedvalue} = $lib;
858
            }
859
            return \%itemstatus;
860
        }
861
        else {
862
863
            #No authvalue list
864
            # build default
865
        }
866
    }
867
868
    #No authvalue list
869
    #build default
870
    $itemstatus{"1"} = "Not For Loan";
871
    return \%itemstatus;
872
}
873
874
=head2 GetItemLocation
782
=head2 GetItemLocation
875
783
876
  $itemlochash = GetItemLocation($fwk);
784
  $itemlochash = GetItemLocation($fwk);
877
- 

Return to bug 18274