$template->param( sessionID => $sessionID );
if ( $in->{'type'} eq 'opac' ) {
- require C4::VirtualShelves;
- my ( $total, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $borrowernumber, 'MASTHEAD' );
+ require Koha::Virtualshelves;
+ my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ borrowernumber => $borrowernumber,
+ category => 1,
+ }
+ );
+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ category => 2,
+ }
+ );
$template->param(
- pubshelves => $total->{pubtotal},
- pubshelvesloop => $pubshelves,
- barshelves => $total->{bartotal},
- barshelvesloop => $barshelves,
+ some_private_shelves => $some_private_shelves,
+ some_public_shelves => $some_public_shelves,
);
}
$template->param( sessionID => $sessionID );
if ( $in->{'type'} eq 'opac' ){
- require C4::VirtualShelves;
- my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' );
+ require Koha::Virtualshelves;
+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ category => 2,
+ }
+ );
$template->param(
- pubshelves => $total->{pubtotal},
- pubshelvesloop => $pubshelves,
+ some_public_shelves => $some_public_shelves,
);
}
}
# state variables
my $loggedin = 0;
my %info;
- my ( $userid, $cookie, $sessionID, $flags, $barshelves, $pubshelves );
+ my ( $userid, $cookie, $sessionID, $flags );
my $logout = $query->param('logout.x');
my $anon_search_history;
$template->param( loginprompt => 1 ) unless $info{'nopermission'};
if ( $type eq 'opac' ) {
- require C4::VirtualShelves;
- my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' );
+ require Koha::Virtualshelves;
+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ category => 2,
+ }
+ );
$template->param(
- pubshelves => $total->{pubtotal},
- pubshelvesloop => $pubshelves,
+ some_public_shelves => $some_public_shelves,
);
}
=head1 FUNCTIONS
-=head2 GetSomeShelfNames
-
-Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header.
-
-=cut
-
-sub GetSomeShelfNames {
- my ($owner, $purpose, $adding_allowed)= @_;
- my ($bar, $pub, @params);
- my $dbh = C4::Context->dbh;
-
- my $bquery = 'SELECT vs.shelfnumber, vs.shelfname FROM virtualshelves vs ';
- my $limit= ShelvesMax($purpose);
-
- my $qry1= $bquery."WHERE vs.category=2 ";
- $qry1.= "AND (allow_add=1 OR owner=?) " if $adding_allowed;
- push @params, $owner||0 if $adding_allowed;
- $qry1.= "ORDER BY vs.lastmodified DESC LIMIT $limit";
-
- unless($adding_allowed && (!defined($owner) || $owner<=0)) {
- #if adding items, user should be known
- $pub= $dbh->selectall_arrayref($qry1,{Slice=>{}},@params);
- }
-
- if($owner) {
- my $qry2= $bquery. qq{
- LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber AND sh.borrowernumber=?
- WHERE vs.category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
- @params=($owner,$owner,$owner);
- $qry2.= "AND (allow_add=1 OR owner=?) " if $adding_allowed;
- push @params, $owner if $adding_allowed;
- $qry2.= "ORDER BY vs.lastmodified DESC ";
- $qry2.= "LIMIT $limit";
- $bar= $dbh->selectall_arrayref($qry2,{Slice=>{}},@params);
- }
-
- return ( { bartotal => $bar? scalar @$bar: 0, pubtotal => $pub? scalar @$pub: 0}, $pub, $bar);
-}
-
=head2 ShelvesMax
$howmany= ShelvesMax($context);
);
}
+sub get_some_shelves {
+ my ( $self, $params ) = @_;
+ my $borrowernumber = $params->{borrowernumber} || 0;
+ my $category = $params->{category} || 1;
+ my $add_allowed = $params->{add_allowed};
+
+ my @conditions;
+ if ( $add_allowed ) {
+ push @conditions, {
+ -or =>
+ {
+ "me.allow_add" => 1,
+ "me.owner" => $borrowernumber,
+ }
+ };
+ }
+ if ( $category == 1 ) {
+ push @conditions, {
+ -or =>
+ {
+ "virtualshelfshares.borrowernumber" => $borrowernumber,
+ "me.owner" => $borrowernumber,
+ }
+ };
+ }
+
+ $self->search(
+ {
+ category => $category,
+ ( @conditions ? ( -and => \@conditions ) : () ),
+ },
+ {
+ join => [ 'virtualshelfshares' ],
+ group_by => 'shelfnumber',
+ order_by => 'lastmodified desc',
+ }
+ );
+}
+
sub type {
return 'Virtualshelve';
}
use C4::Branch; # GetBranches
use C4::Search::History;
+use Koha::Virtualshelves;
+
use URI::Escape;
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
# VI. BUILD THE TEMPLATE
-# Build drop-down list for 'Add To:' menu...
-my ($totalref, $pubshelves, $barshelves)=
- C4::VirtualShelves::GetSomeShelfNames($borrowernumber,'COMBO',1);
+my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ borrowernumber => $borrowernumber,
+ add_allowed => 1,
+ category => 1,
+ }
+);
+my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ borrowernumber => $borrowernumber,
+ add_allowed => 1,
+ category => 2,
+ }
+);
+
+
$template->param(
- addbarshelves => $totalref->{bartotal},
- addbarshelvesloop => $barshelves,
- addpubshelves => $totalref->{pubtotal},
- addpubshelvesloop => $pubshelves,
- );
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
+);
output_html_with_http_headers $cgi, $cookie, $template->output;
`allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
`allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
PRIMARY KEY (`shelfnumber`),
- CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
+ CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
KEY `biblionumber` (`biblionumber`),
CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
+ CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
`invitekey` varchar(10), -- temporary string used in accepting the invitation to access thist list; not-empty means that the invitation has not been accepted yet
`sharedate` datetime, -- date of invitation or acceptance of invitation
CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
+ CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
});
var param1 = "<label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
[% IF ( intranetbookbag ) %] param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>"; [% END %]
- [% IF ( virtualshelves ) %][% IF ( addbarshelves ) %]
- param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %]
- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %]
- param1 += "<\/optgroup>";[% END %]
- [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %]
- param1 += "<\/optgroup>";[% END %]
- [% IF ( ( addbarshelvesloop && addbarshelvesloop.size>9 ) || (addpubshelvesloop && addpubshelvesloop.size>9 )) %]
- param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
- [% END %]
- param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
+
+ [% IF Koha.Preference('virtualshelves') %]
+ [% IF add_to_some_private_shelves.count %]
+ param1 += "<optgroup label=\""+_("Your lists:")+"\">";
+ [% SET number_of_private_shelves = 0 %]
+ [% FOREACH s IN add_to_some_private_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
+ [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
+ [% END %]
+ [% END %]
+ param1 += "<\/optgroup>";
+ [% END %]
+ [% IF add_to_some_public_shelves.count %]
+ param1 += "<optgroup label=\""+_("Public lists:")+"\">";
+ [% SET number_of_public_shelves = 0 %]
+ [% FOREACH s IN add_to_some_public_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
+ [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
+ [% END %]
+ [% END %]
+ param1 += "<\/optgroup>";
+ [% END %]
+ [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
+ param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
+ [% END %]
+ param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
[% END %]
+
param1 += "<\/select> <input id=\"cartsubmit\" type=\"submit\" class=\"submit\" value=\""+_("Save")+"\" />";
$('#sortsubmit').hide();
$("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
[% IF ( intranetbookbag ) %]
param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
[% END %]
- [% IF ( virtualshelves ) %]
- [% IF ( addbarshelves ) %]
+ [% IF Koha.Preference('virtualshelves') %]
+ [% IF add_to_some_private_shelves.count %]
param1 += "<optgroup label=\""+_("Your lists:")+"\">";
- [% FOREACH addbarshelvesloo IN addbarshelvesloop %]
- [% IF ( shelfnumber != addbarshelvesloo.shelfnumber ) %]
- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";
+ [% SET number_of_private_shelves = 0 %]
+ [% FOREACH s IN add_to_some_private_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
+ [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
[% END %]
[% END %]
param1 += "<\/optgroup>";
[% END %]
- [% IF ( addpubshelves ) %]
+ [% IF add_to_some_public_shelves.count %]
param1 += "<optgroup label=\""+_("Public lists:")+"\">";
- [% FOREACH addpubshelvesloo IN addpubshelvesloop %]
- [% IF ( shelfnumber != addpubshelvesloo.shelfnumber ) %]
- param1 += "<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>";
+ [% SET number_of_public_shelves = 0 %]
+ [% FOREACH s IN add_to_some_public_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
+ [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
[% END %]
[% END %]
param1 += "<\/optgroup>";
[% END %]
- [% IF ( ( addbarshelvesloop && addbarshelvesloop.size > 9 ) || (addpubshelvesloop && addpubshelvesloop.size > 9 )) %]
+ [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
[% END %]
param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
<li class="dropdown">
<a href="#" title="Show lists" class="dropdown-toggle" id="listsmenu" data-toggle="dropdown" role="button"><i class="icon-list icon-white"></i> <span class="listslabel">Lists</span> <b class="caret"></b></a>
<ul aria-labelledby="listsmenu" role="menu" class="dropdown-menu">
- [% IF ( pubshelves ) %]
- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem"><strong>Public lists</strong></a></li>
- [% FOREACH pubshelvesloo IN pubshelvesloop %]
- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% pubshelvesloo.shelfnumber %]&sortfield=[% pubshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% pubshelvesloo.shelfname |html %]</a></li>
- [% END %]
- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li>
- [% ELSE %]
- <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No public lists</a></li>
+ [% IF some_public_shelves.count %]
+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem"><strong>Public lists</strong></a></li>
+ [% SET number_of_public_shelves = 0 %]
+ [% FOREACH s IN some_public_shelves %]
+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% s.shelfnumber %]&sortfield=[% s.sortfield %]" tabindex="-1" role="menuitem">[% s.shelfname |html %]</a></li>
+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
+ [% IF number_of_public_shelves >= 10 %][% LAST %][% END %]
[% END %]
- <li class="divider" role="presentation"></li>
- [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem"><strong>Your lists</strong></a></li>
- [% IF ( loggedinusername ) %]
- [% IF ( barshelves ) %]
- [% FOREACH barshelvesloo IN barshelvesloop %]
- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% barshelvesloo.shelfnumber %]&sortfield=[% barshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% barshelvesloo.shelfname |html %]</a></li>
- [% END %]
- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">View all</a></li>
- [% ELSE %]
- <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No private lists</a></li>
- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">New list</a></li>
+ [% IF some_public_shelves > 10 %]
+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li>
+ [% END %]
+ [% ELSE %]
+ <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No public lists</a></li>
+ [% END %]
+ <li class="divider" role="presentation"></li>
+ [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem"><strong>Your lists</strong></a></li>
+ [% IF loggedinusername %]
+ [% IF some_private_shelves.count %]
+ [% SET number_of_private_shelves = 0 %]
+ [% FOREACH s IN some_private_shelves %]
+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% s.shelfnumber %]&sortfield=[% s.sortfield %]" tabindex="-1" role="menuitem">[% s.shelfname |html %]</a></li>
+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
+ [% IF number_of_private_shelves >= 10 %][% LAST %][% END %]
+ [% END %]
+ [% IF some_private_shelves > 10 %]
+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li>
[% END %]
[% ELSE %]
- <li role="presentation"><a href="/cgi-bin/koha/opac-user.pl" tabindex="-1" class="menu-inactive loginModal-trigger" role="menuitem">Log in to create your own lists</a></li>
- [% END # / IF loggedinusername %]
- [% END # / IF opacuserlogin %]
+ <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No private lists</a></li>
+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">New list</a></li>
+ [% END %]
+ [% ELSE %]
+ <li role="presentation"><a href="/cgi-bin/koha/opac-user.pl" tabindex="-1" class="menu-inactive loginModal-trigger" role="menuitem">Log in to create your own lists</a></li>
+ [% END # / IF loggedinusername %]
+ [% END # / IF opacuserlogin %]
</ul> <!-- / .dropdown-menu -->
</li> <!-- / .dropdown -->
[% END # / IF virtualshelves %]
param1 += "<span id=\"selections\">"+_("Select titles to: ")+"</span>";
[% END %]
-[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
- [% IF Koha.Preference( 'virtualshelves' ) == 1 %]
+[% IF Koha.Preference( 'opacbookbag' ) == 1 OR Koha.Preference('virtualshelves') %]
param1 += "<select class=\"disabled\" name=\"addto\" id=\"addto\"><option>"+_("Add to...")+"</option>";
- [% IF Koha.Preference( 'opacbookbag' ) == 1 %] param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
- [% END %][% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %][% IF ( addbarshelves ) %]
- param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %]
- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %]
- param1 += "<\/optgroup>";[% END %]
- [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %];
- param1 += "<\/optgroup>";[% END %]
- [% IF (( addbarshelvesloop && addbarshelvesloop.size>9) || (addpubshelvesloop && addpubshelvesloop.size>9 )) %]
- param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
- [% END %]
- param1 += "<option value=\"newlist\">[ "+_("New list")+" ]<\/option>";
+
+ [% IF Koha.Preference( 'opacbookbag' ) == 1 %]
+ param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
[% END %]
+ [% IF Koha.Preference('virtualshelves') %]
+ [% IF loggedinusername AND add_to_some_private_shelves.count %]
+ param1 += "<optgroup label=\""+_("Your lists:")+"\">";
+ [% SET number_of_private_shelves = 0 %]
+ [% FOREACH s IN add_to_some_private_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
+ [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
+ [% END %]
+ [% END %]
+ param1 += "<\/optgroup>";
+ [% END %]
+ [% IF add_to_some_public_shelves.count %]
+ param1 += "<optgroup label=\""+_("Public lists:")+"\">";
+ [% SET number_of_public_shelves = 0 %]
+ [% FOREACH s IN add_to_some_public_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
+ [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
+ [% END %]
+ [% END %]
+ param1 += "<\/optgroup>";
+ [% END %]
+ [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
+ param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
+ [% END %]
+ param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
[% END %]
param1 += "<\/select> <input type=\"submit\" class=\"btn btn-small\" value=\""+_("Save")+"\" />";
- [% ELSE %]
- param1 += "<a id=\"addto\" class=\"addtocart\" href=\"#\">" + _("Add to cart") + "<\/a>";
- [% END %]
-[% ELSE %]
- param1 += "<select name=\"addto\" id=\"addto\"><option value=\"\">"+_("Add to list: ")+"<\/option>";
-[% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %][% IF ( addbarshelves ) %]
- param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %]
- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %]
- param1 += "<\/optgroup>";[% END %]
- [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %][% END %]
- param1 +="<\/optgroup><option value=\"newlist\">[ "+_("New list")+" ]<\/option>"
- [% END %]
- [% END %]
- param1 += "<\/select> <input type=\"submit\" class=\"btn btn-small disabled\" value=\""+_("Save")+"\" />";
[% END %]
$('#sortsubmit').hide();
use C4::Auth;
use C4::Members;
use C4::Branch; # GetBranches
-use C4::VirtualShelves (); #no import
use Module::Load;
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
} else {
MoveMemberToDeleted($member);
- C4::VirtualShelves::HandleDelBorrower($member);
+ C4::Members::HandleDelBorrower($member);
DelMember($member);
print $input->redirect("/cgi-bin/koha/members/members-home.pl");
}
use Getopt::Long;
use C4::Members;
-use C4::VirtualShelves;
use Koha::DateUtils;
use C4::Log;
next;
}
eval {
- C4::VirtualShelves::HandleDelBorrower( $borrowernumber )
+ C4::Members::HandleDelBorrower( $borrowernumber )
if $confirm;
};
if ($@) {
}
# VI. BUILD THE TEMPLATE
-# Build drop-down list for 'Add To:' menu...
-my ($totalref, $pubshelves, $barshelves)=
- C4::VirtualShelves::GetSomeShelfNames($borrowernumber,'COMBO',1);
+my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ borrowernumber => $borrowernumber,
+ add_allowed => 1,
+ category => 1,
+ }
+);
+my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ borrowernumber => $borrowernumber,
+ add_allowed => 1,
+ category => 2,
+ }
+);
+while(my$s = $some_public_shelves->next){warn $s->shelfnumber;};
+
$template->param(
- addbarshelves => $totalref->{bartotal},
- addbarshelvesloop => $barshelves,
- addpubshelves => $totalref->{pubtotal},
- addpubshelvesloop => $pubshelves,
- );
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
+);
my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
push @items, $this_item;
}
- # Build drop-down list for 'Add To:' menu...
- my ( $totalref, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $loggedinuser, 'COMBO', 1 );
$template->param(
- addbarshelves => $totalref->{bartotal},
- addbarshelvesloop => $barshelves,
- addpubshelves => $totalref->{pubtotal},
- addpubshelvesloop => $pubshelves,
can_manage_shelf => $shelf->can_be_managed($loggedinuser),
can_delete_shelf => $shelf->can_be_deleted($loggedinuser),
can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser),
use C4::Output;
use C4::Members; # GetBorrowersWhoHavexxxBorrowed.
use C4::Circulation; # AnonymiseIssueHistory.
-use C4::VirtualShelves (); #no import
use Koha::DateUtils qw( dt_from_string output_pref );
use Date::Calc qw/Today Add_Delta_YM/;
$radio eq 'testrun' && last;
my $borrowernumber = $membersToDelete->[$i]->{'borrowernumber'};
$radio eq 'trash' && MoveMemberToDeleted( $borrowernumber );
- C4::VirtualShelves::HandleDelBorrower( $borrowernumber );
+ C4::Members::HandleDelBorrower( $borrowernumber );
DelMember( $borrowernumber );
}
$template->param(
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ( $shelf ) {
if ( $shelf->can_be_viewed( $loggedinuser ) ) {
- my $sortfield = $query->param('sortfield') || $shelf->sortfield; # Passed in sorting overrides default sorting
+ my $sortfield = $query->param('sortfield') || $shelf->sortfield || 'title'; # Passed in sorting overrides default sorting
my $direction = $query->param('direction') || 'asc';
my ( $rows, $page );
unless ( $query->param('print') ) {
push @items, $this_item;
}
- # Build drop-down list for 'Add To:' menu...
- my ( $totalref, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $loggedinuser, 'COMBO', 1 );
+ my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ borrowernumber => $loggedinuser,
+ add_allowed => 1,
+ category => 1,
+ }
+ );
+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+ {
+ borrowernumber => $loggedinuser,
+ add_allowed => 1,
+ category => 2,
+ }
+ );
+
$template->param(
- addbarshelves => $totalref->{bartotal},
- addbarshelvesloop => $barshelves,
- addpubshelves => $totalref->{pubtotal},
- addpubshelvesloop => $pubshelves,
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
can_manage_shelf => $shelf->can_be_managed($loggedinuser),
can_remove_shelf => $shelf->can_be_deleted($loggedinuser),
can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser),