Lines 40-46
BEGIN {
Link Here
|
40 |
require Exporter; |
40 |
require Exporter; |
41 |
@ISA = qw(Exporter); |
41 |
@ISA = qw(Exporter); |
42 |
@EXPORT = qw( |
42 |
@EXPORT = qw( |
43 |
&GetShelves &GetShelfContents |
43 |
&GetShelfContents |
44 |
&ShelfPossibleAction |
44 |
&ShelfPossibleAction |
45 |
); |
45 |
); |
46 |
@EXPORT_OK = qw( |
46 |
@EXPORT_OK = qw( |
Lines 65-138
bibs to and from virtual shelves.
Link Here
|
65 |
|
65 |
|
66 |
=head1 FUNCTIONS |
66 |
=head1 FUNCTIONS |
67 |
|
67 |
|
68 |
=head2 GetShelves |
|
|
69 |
|
70 |
$shelflist = &GetShelves($category, $row_count, $offset, $owner); |
71 |
($shelfnumber, $shelfhash) = each %{$shelflist}; |
72 |
|
73 |
Returns the number of shelves specified by C<$row_count> and C<$offset> as well as the total |
74 |
number of shelves that meet the C<$owner> and C<$category> criteria. C<$category>, |
75 |
C<$row_count>, and C<$offset> are required. C<$owner> must be supplied when C<$category> == 1. |
76 |
When C<$category> is 2, supply undef as argument for C<$owner>. |
77 |
|
78 |
This function is used by shelfpage in VirtualShelves/Page.pm when listing all shelves for lists management in opac or staff client. Order is by shelfname. |
79 |
|
80 |
C<$shelflist>is a reference-to-hash. The keys are the virtualshelves numbers (C<$shelfnumber>, above), |
81 |
and the values (C<$shelfhash>, above) are themselves references-to-hash, with the following keys: |
82 |
|
83 |
=over |
84 |
|
85 |
=item C<$shelfhash-E<gt>{shelfname}> |
86 |
|
87 |
A string. The name of the shelf. |
88 |
|
89 |
=back |
90 |
|
91 |
=cut |
92 |
|
93 |
sub GetShelves { |
94 |
my ($category, $row_count, $offset, $owner) = @_; |
95 |
$offset ||= 0; |
96 |
my @params = ( $offset, $row_count ); |
97 |
my $dbh = C4::Context->dbh; |
98 |
my $query = qq{ |
99 |
SELECT vs.shelfnumber, vs.shelfname,vs.owner, |
100 |
bo.surname,bo.firstname,vs.category,vs.sortfield, |
101 |
count(vc.biblionumber) as count |
102 |
FROM virtualshelves vs |
103 |
LEFT JOIN borrowers bo ON vs.owner=bo.borrowernumber |
104 |
LEFT JOIN virtualshelfcontents vc USING (shelfnumber) }; |
105 |
if($category==1) { |
106 |
$query.= qq{ |
107 |
LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber |
108 |
AND sh.borrowernumber=? |
109 |
WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) }; |
110 |
unshift @params, ($owner) x 3; |
111 |
} |
112 |
else { |
113 |
$query.= 'WHERE category=2 '; |
114 |
} |
115 |
$query.= qq{ |
116 |
GROUP BY vs.shelfnumber |
117 |
ORDER BY vs.shelfname |
118 |
LIMIT ?, ?}; |
119 |
|
120 |
my $sth2 = $dbh->prepare($query); |
121 |
$sth2->execute(@params); |
122 |
my %shelflist; |
123 |
while( my ($shelfnumber, $shelfname, $owner, $surname, $firstname, $category, $sortfield, $count)= $sth2->fetchrow) { |
124 |
$shelflist{$shelfnumber}->{'shelfname'} = $shelfname; |
125 |
$shelflist{$shelfnumber}->{'count'} = $count; |
126 |
$shelflist{$shelfnumber}->{'single'} = $count==1; |
127 |
$shelflist{$shelfnumber}->{'sortfield'} = $sortfield; |
128 |
$shelflist{$shelfnumber}->{'category'} = $category; |
129 |
$shelflist{$shelfnumber}->{'owner'} = $owner; |
130 |
$shelflist{$shelfnumber}->{'surname'} = $surname; |
131 |
$shelflist{$shelfnumber}->{'firstname'} = $firstname; |
132 |
} |
133 |
return \%shelflist; |
134 |
} |
135 |
|
136 |
=head2 GetSomeShelfNames |
68 |
=head2 GetSomeShelfNames |
137 |
|
69 |
|
138 |
Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header. |
70 |
Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header. |