use Koha::Biblios;
use Koha::Patrons;
use Koha::RecordProcessor;
+use Koha::Virtualshelves;
my $query = CGI->new;
);
}
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("intranet_bib_list")){
+ my $cart_list = $query->cookie("intranet_bib_list");
+ @cart_list = split(/\//, $cart_list);
+ if ( grep {$_ eq $biblionumber} @cart_list) {
+ $template->param( incart => 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(
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
+);
+
$template->param (
ISBD => $res,
biblionumber => $biblionumber,
use Koha::BiblioFrameworks;
use Koha::Patrons;
use Koha::DateUtils;
+use Koha::Virtualshelves;
use List::MoreUtils qw( uniq );
);
}
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("intranet_bib_list")){
+ my $cart_list = $query->cookie("intranet_bib_list");
+ @cart_list = split(/\//, $cart_list);
+ if ( grep {$_ eq $biblionumber} @cart_list) {
+ $template->param( incart => 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(
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
+);
+
$template->param (
item_loop => \@item_loop,
item_header_loop => \@item_header_loop,
C4::Search::enabled_staff_search_views,
searchid => scalar $query->param('searchid'),
biblio => $biblio_object,
+ loggedinuser => $loggedinuser,
);
$template->param( holdcount => $biblio_object->holds->count );
}
}
+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(
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
+);
+
$template->param(
MARCNOTES => $marcnotesarray,
itemdata_ccode => $itemfields{ccode},
}
}
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("intranet_bib_list")){
+ my $cart_list = $query->cookie("intranet_bib_list");
+ @cart_list = split(/\//, $cart_list);
+ if ( grep {$_ eq $biblionumber} @cart_list) {
+ $template->param( incart => 1 );
+ }
+}
+
$template->param(biblio => $biblio);
output_html_with_http_headers $query, $cookie, $template->output;
use Koha::Biblios;
use Koha::BiblioFrameworks;
use Koha::Patrons;
+use Koha::Virtualshelves;
my $query = CGI->new;
my $dbh = C4::Context->dbh;
};
}
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("intranet_bib_list")){
+ my $cart_list = $query->cookie("intranet_bib_list");
+ @cart_list = split(/\//, $cart_list);
+ if ( grep {$_ eq $biblionumber} @cart_list) {
+ $template->param( incart => 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(
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
+);
+
$template->param (
marc_data => \@marc_data,
biblionumber => $biblionumber,
C4::Search::enabled_staff_search_views,
);
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("intranet_bib_list")){
+ my $cart_list = $query->cookie("intranet_bib_list");
+ @cart_list = split(/\//, $cart_list);
+ if ( grep {$_ eq $biblionumber} @cart_list) {
+ $template->param( incart => 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(
+ add_to_some_private_shelves => $some_private_shelves,
+ add_to_some_public_shelves => $some_public_shelves,
+);
+
$template->param(
ITEM_DATA => \@items,
moredetailview => 1,
margin-top: 0;
z-index: 300;
}
+
+ a.addtocart {
+ display: block;
+ }
+
+ a.cartRemove {
+ padding: 6px 12px;
+ font-size: 12px;
+ display: none;
+ }
+
+ a.addtocart.incart {
+ display: none;
+ }
+
+ a.cartRemove.incart {
+ display: block;
+ }
}
#disabled {
</ul>
</div>
-[% IF ( virtualshelves && intranetbookbag ) %]
- <div class="btn-group">
- <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Add to <span class="caret"></span></button>
- <ul class="dropdown-menu">
- <li><a href="#" id="addtocart">Cart</a></li>
- <li><a href="#" id="addtoshelf">List</a></li>
- </ul>
- </div>
-[% ELSIF ( virtualshelves ) %]
- <div class="btn-group"><a id="addtoshelf" class="btn btn-default"><i class="fa fa-list"></i> Add to list</a> </div>
-[% ELSIF ( intranetbookbag ) %]
- <div class="btn-group"><a id="addtocart" class="btn btn-default"><i class="fa fa-shopping-cart"></i> Add to cart</a> </div>
-[% END %]
+ [% IF ( intranetbookbag ) %]
+ [% IF ( incart ) %]
+ <div class="btn-group">
+ <a id="cart[% biblionumber | html %]" class="btn btn-default addtocart incart" href="#"><i class="fa fa-shopping-cart"></i> Add to cart</a>
+ </div>
+ <div class="btn-group">
+ <a id="cartR[% biblionumber | html %]" class="btn btn-default cartRemove incart" href="#"><i class="fa fa-shopping-cart"></i> Remove from cart</a>
+ </div>
+ [% ELSE %]
+ <div class="btn-group">
+ <a id="cart[% biblionumber | html %]" class="btn btn-default addtocart" href="#"><i class="fa fa-shopping-cart"></i> Add to cart</a>
+ </div>
+ <div class="btn-group">
+ <a id="cartR[% biblionumber | html %]" class="btn btn-default cartRemove" href="#"><i class="fa fa-shopping-cart"></i> Remove from cart</a>
+ </div>
+ [% END %]
+ [% END %]
+
+ [% IF Koha.Preference('virtualshelves') %]
+ <div class="btn-group">
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <i class="fa fa-list"></i> Add to list <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ [% IF add_to_some_private_shelves.count %]
+ <li class="dropdown-header">Your lists</li>
+ [% SET number_of_private_shelves = 0 %]
+ [% FOREACH s IN add_to_some_private_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ <li>
+ <a href="#" class="addtolist" data-shelfnumber="[% s.shelfnumber | html %]">[% s.shelfname | html %]</a>
+ </li>
+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
+ [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
+ [% END %]
+ [% END %]
+ [% END %]
+ [% IF add_to_some_public_shelves.count %]
+ <li class="dropdown-header">Public lists</li>
+ [% SET number_of_public_shelves = 0 %]
+ [% FOREACH s IN add_to_some_public_shelves %]
+ [% IF shelfnumber != s.shelfnumber %]
+ <li>
+ <a href="#" data-shelfnumber="[% s.shelfnumber | html %]" class="addtolist">[% s.shelfname | html %]</a>
+ </li>
+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
+ [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
+ [% END %]
+ [% END %]
+ [% END %]
+ <li role="separator" class="divider"></li>
+ [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
+ <li>
+ <a href="#" class="addtolist morelists">More lists</a>
+ </li>
+ [% END %]
+ <li>
+ <a href="#" class="addtolist newlist">New list</a>
+ </li>
+ </ul>
+ </div>
+ [% END # /IF virtualshelves %]
<div class="btn-group"><a id="printbiblio" class="btn btn-default"><i class="fa fa-print"></i> Print</a></div>
[% USE raw %]
+[% USE Koha %]
[% USE Asset %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
[% USE raw %]
+[% USE Koha %]
[% USE Asset %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
[% USE raw %]
+[% USE Koha %]
[% USE Asset %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
var cartR = target ? target.$("#cartR" + val) : $("#cartR" + val);
if(op == "add"){
- cart.html(__("In your cart")).addClass("incart");
+ if( cart.hasClass("btn") ){
+ /* Cart link is a button with an icon */
+ cart.html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart")).addClass("incart");
+ cart.hide();
+ } else {
+ cart.html( __("In your cart") ).addClass("incart");
+ }
cartR.show();
} else {
- cart.html(__("Add to cart")).removeClass("incart").addClass("addtocart");
+ if (cart.hasClass("btn")) {
+ cart.html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart")).addClass("addtocart");
+ cart.show();
+ } else {
+ cart.html(__("Add to cart")).addClass("addtocart");
+ }
cartR.hide();
}
}
function updateAllLinks(target){
- if(target){
- target.$("a.incart").html(__("Add to cart")).removeClass("incart").addClass("addtocart");
- target.$(".cartRemove").hide();
+ var cart = target ? target.$("a.incart") : $("a.incart");
+ var cartR = target ? target.$(".cartRemove") : $(".cartRemove");
+ if( cart.hasClass("btn") ){
+ /* Cart link is a button with an icon */
+ cart.html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart")).addClass("incart");
+ cartR.hide();
} else {
- $("a.incart").html(__("Add to cart")).removeClass("incart").addClass("addtocart");
- $(".cartRemove").hide();
+ cart.html( __("In your cart") ).addClass("incart");
}
+ cart.show();
}
$(document).ready(function(){
-/* global __ biblionumber count holdcount countorders countdeletedorders searchid addRecord */
+/* global __ biblionumber count holdcount countorders countdeletedorders searchid addRecord delSingleRecord */
/* exported GetZ3950Terms PopupZ3950Confirmed */
/* IF ( CAN_user_editcatalogue_edit_catalogue ) */
/* this function open a popup to search on z3950 server. */
}
/* END IF( CAN_user_editcatalogue_edit_catalogue ) */
-function addToCart() { addRecord( biblionumber ); }
+function addToCart(){
+ addRecord( biblionumber );
+}
+
function addToShelf() { window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=' + biblionumber,'Add_to_virtualshelf','width=500,height=400,toolbar=false,scrollbars=yes');
}
function printBiblio() {window.print(); }
printBiblio();
return false;
});
- $("#addtocart").click(function(){
- addToCart();
- $(".btn-group").removeClass("open");
- return false;
+
+ $(".addtocart").on("click", function (e) {
+ e.preventDefault();
+ var selection_id = this.id;
+ var biblionumber = selection_id.replace("cart", "");
+ addRecord(biblionumber);
+ });
+
+ $(".cartRemove").on("click", function (e) {
+ e.preventDefault();
+ var selection_id = this.id;
+ var biblionumber = selection_id.replace("cartR", "");
+ delSingleRecord(biblionumber);
+ $(".addtocart").html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart"));
});
+
$("#addtoshelf").click(function(){
addToShelf();
$(".btn-group").removeClass("open");
alertNoItems();
})
.tooltip();
+
+ $(".addtolist").on("click", function (e) {
+ e.preventDefault();
+ var shelfnumber = $(this).data("shelfnumber");
+ if ($(this).hasClass("morelists")) {
+ openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=' + biblionumber);
+ } else if ($(this).hasClass("newlist")) {
+ openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&biblionumber=' + biblionumber);
+ } else {
+ openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber=' + shelfnumber + '&confirm=1&biblionumber=' + biblionumber);
+ }
+ });
+
});