Bug 14544: Move HandleDelBorrower to C4::Members
[srvgit] / C4 / VirtualShelves.pm
1 package C4::VirtualShelves;
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use strict;
21 use warnings;
22
23 use Carp;
24 use C4::Context;
25 use C4::Debug;
26 use C4::Members;
27
28 use constant SHELVES_MASTHEAD_MAX => 10; #number under Lists button in masthead
29 use constant SHELVES_COMBO_MAX => 10; #add to combo in search
30 use constant SHELVES_MGRPAGE_MAX => 20; #managing page
31 use constant SHELVES_POPUP_MAX => 40; #addbybiblio popup
32
33 use constant SHARE_INVITATION_EXPIRY_DAYS => 14; #two weeks to accept
34
35 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
36
37 BEGIN {
38     # set the version for version checking
39     $VERSION = 3.07.00.049;
40     require Exporter;
41     @ISA    = qw(Exporter);
42     @EXPORT = qw(
43     );
44         @EXPORT_OK = qw(
45             &ShelvesMax
46         );
47 }
48
49
50 =head1 NAME
51
52 C4::VirtualShelves - Functions for manipulating Koha virtual shelves
53
54 =head1 SYNOPSIS
55
56   use C4::VirtualShelves;
57
58 =head1 DESCRIPTION
59
60 This module provides functions for manipulating virtual shelves,
61 including creating and deleting virtual shelves, and adding and removing
62 bibs to and from virtual shelves.
63
64 =head1 FUNCTIONS
65
66 =head2 ShelvesMax
67
68     $howmany= ShelvesMax($context);
69
70 Tells how much shelves are shown in which context.
71 POPUP refers to addbybiblionumber popup, MGRPAGE is managing page (in opac or
72 staff), COMBO refers to the Add to-combo of search results. MASTHEAD is the
73 main Koha toolbar with Lists button.
74
75 =cut
76
77 sub ShelvesMax {
78     my $which= shift;
79     return SHELVES_POPUP_MAX if $which eq 'POPUP';
80     return SHELVES_MGRPAGE_MAX if $which eq 'MGRPAGE';
81     return SHELVES_COMBO_MAX if $which eq 'COMBO';
82     return SHELVES_MASTHEAD_MAX if $which eq 'MASTHEAD';
83     return SHELVES_MASTHEAD_MAX;
84 }
85
86 sub GetShelfCount {
87     my ($owner, $category) = @_;
88     my @params;
89     # Find out how many shelves total meet the submitted criteria...
90
91     my $dbh = C4::Context->dbh;
92     my $query = "SELECT count(*) FROM virtualshelves vs ";
93     if($category==1) {
94         $query.= qq{
95             LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
96             AND sh.borrowernumber=?
97         WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
98         @params= ($owner, $owner, $owner);
99     }
100     else {
101         $query.='WHERE category=2';
102         @params= ();
103     }
104     my $sth = $dbh->prepare($query);
105     $sth->execute(@params);
106     my ($total)= $sth->fetchrow;
107     return $total;
108 }
109
110 1;
111
112 __END__
113
114 =head1 AUTHOR
115
116 Koha Development Team <http://koha-community.org/>
117
118 =head1 SEE ALSO
119
120 C4::Circulation::Circ2(3)
121
122 =cut