From 251e2c4d748db6808a1e47ba986e374b14f29918 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 14 Mar 2011 21:08:57 -0500 Subject: [PATCH] Fix for Bug 3659, Add place hold option from patron checkout tab Adds a button on patron-related pages, "Search to hold" Clicking search to hold sets a cookie with the patron's borrowernumber and sends the user to the search page. On subsequent search results pages the user will have the option to place holds specifically for the remembered patron. This works on the search results page (single and multiple hold) and on the detail page. The saved cookie will time out after 10 minutes or be erased when a new patron is loaded by circulation.pl New jQuery plugin added: jquery.cookie.min.js Revision fixes some markup and corrects an error that would lead to the hold being initiated for the remembered patron when this was not intended. Signed-off-by: Liz Rea Signed-off-by: Chris Cormack --- catalogue/ISBDdetail.pl | 11 +++ catalogue/MARCdetail.pl | 11 +++ catalogue/detail.pl | 12 ++- catalogue/labeledMARCdetail.pl | 11 +++ catalogue/moredetail.pl | 11 +++ catalogue/search.pl | 11 +++ .../prog/en/css/staff-global.css | 11 ++- .../prog/en/includes/cat-toolbar.inc | 26 +++++ .../prog/en/includes/circ-toolbar.inc | 30 +++--- .../prog/en/includes/doc-head-close.inc | 1 + .../prog/en/includes/members-toolbar.inc | 24 +++-- .../lib/jquery/plugins/jquery.cookie.min.js | 1 + .../prog/en/modules/catalogue/results.tmpl | 98 +++++++++++++------ .../prog/en/modules/circ/circulation.tmpl | 1 + 14 files changed, 209 insertions(+), 50 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl index 7ebe8e0c01..df84a3ae26 100755 --- a/catalogue/ISBDdetail.pl +++ b/catalogue/ISBDdetail.pl @@ -43,6 +43,7 @@ use CGI; use C4::Koha; use C4::Biblio; use C4::Items; +use C4::Members; # to use GetMember use C4::Branch; # GetBranchDetail use C4::Serials; # CountSubscriptionFromBiblionumber use C4::Search; # enabled_staff_search_views @@ -66,6 +67,16 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +if($query->cookie("holdfor")){ + my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor")); + $template->param( + holdfor => $query->cookie("holdfor"), + holdfor_surname => $holdfor_patron->{'surname'}, + holdfor_firstname => $holdfor_patron->{'firstname'}, + holdfor_cardnumber => $holdfor_patron->{'cardnumber'}, + ); +} + # my @blocs = split /\@/,$ISBD; # my @fields = $record->fields(); my $res = GetISBDView($biblionumber, "intranet"); diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl index 2dc7b1d5e7..89dd2ac12e 100755 --- a/catalogue/MARCdetail.pl +++ b/catalogue/MARCdetail.pl @@ -54,6 +54,7 @@ use MARC::Record; use C4::Biblio; use C4::Items; use C4::Acquisition; +use C4::Members; # to use GetMember use C4::Serials; #uses getsubscriptionsfrombiblionumber GetSubscriptionsFromBiblionumber use C4::Search; # enabled_staff_search_views @@ -84,6 +85,16 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +if($query->cookie("holdfor")){ + my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor")); + $template->param( + holdfor => $query->cookie("holdfor"), + holdfor_surname => $holdfor_patron->{'surname'}, + holdfor_firstname => $holdfor_patron->{'firstname'}, + holdfor_cardnumber => $holdfor_patron->{'cardnumber'}, + ); +} + #count of item linked my $itemcount = GetItemsCount($biblionumber); $template->param( count => $itemcount, diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 6ee79e62ed..3d42326fc3 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -30,7 +30,7 @@ use C4::Items; use C4::Circulation; use C4::Branch; use C4::Reserves; -use C4::Members; +use C4::Members; # to use GetMember use C4::Serials; use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn); use C4::External::Amazon; @@ -51,6 +51,16 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +if($query->cookie("holdfor")){ + my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor")); + $template->param( + holdfor => $query->cookie("holdfor"), + holdfor_surname => $holdfor_patron->{'surname'}, + holdfor_firstname => $holdfor_patron->{'firstname'}, + holdfor_cardnumber => $holdfor_patron->{'cardnumber'}, + ); +} + my $biblionumber = $query->param('biblionumber'); my $fw = GetFrameworkCode($biblionumber); diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl index e72a6d115d..8faecfce38 100755 --- a/catalogue/labeledMARCdetail.pl +++ b/catalogue/labeledMARCdetail.pl @@ -26,6 +26,7 @@ use C4::Context; use C4::Output; use C4::Biblio; use C4::Items; +use C4::Members; # to use GetMember use C4::Search; # enabled_staff_search_views my $query = new CGI; @@ -52,6 +53,16 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +if($query->cookie("holdfor")){ + my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor")); + $template->param( + holdfor => $query->cookie("holdfor"), + holdfor_surname => $holdfor_patron->{'surname'}, + holdfor_firstname => $holdfor_patron->{'firstname'}, + holdfor_cardnumber => $holdfor_patron->{'cardnumber'}, + ); +} + #count of item linked my $itemcount = GetItemsCount($biblionumber); $template->param( count => $itemcount, diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index d790c41987..b5e6963411 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -31,6 +31,7 @@ use C4::Auth; use C4::Serials; use C4::Dates qw/format_date/; use C4::Circulation; # to use itemissues +use C4::Members; # to use GetMember use C4::Search; # enabled_staff_search_views my $query=new CGI; @@ -48,6 +49,16 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({ flagsrequired => {catalogue => 1}, }); +if($query->cookie("holdfor")){ + my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor")); + $template->param( + holdfor => $query->cookie("holdfor"), + holdfor_surname => $holdfor_patron->{'surname'}, + holdfor_firstname => $holdfor_patron->{'firstname'}, + holdfor_cardnumber => $holdfor_patron->{'cardnumber'}, + ); +} + # get variables my $biblionumber=$query->param('biblionumber'); diff --git a/catalogue/search.pl b/catalogue/search.pl index 8cb737d323..791bba187a 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -145,6 +145,7 @@ use C4::Auth qw(:DEFAULT get_session); use C4::Search; use C4::Languages qw(getAllLanguages); use C4::Koha; +use C4::Members qw(GetMember); use C4::VirtualShelves qw(GetRecentShelves); use POSIX qw(ceil floor); use C4::Branch; # GetBranches @@ -181,6 +182,16 @@ if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { $template->param('UNIMARC' => 1); } +if($cgi->cookie("holdfor")){ + my $holdfor_patron = GetMember('borrowernumber' => $cgi->cookie("holdfor")); + $template->param( + holdfor => $cgi->cookie("holdfor"), + holdfor_surname => $holdfor_patron->{'surname'}, + holdfor_firstname => $holdfor_patron->{'firstname'}, + holdfor_cardnumber => $holdfor_patron->{'cardnumber'}, + ); +} + ## URI Re-Writing # Deprecated, but preserved because it's interesting :-) # The same thing can be accomplished with mod_rewrite in diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index b6d439d1dd..5a09fb6cca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -439,6 +439,7 @@ ul.toolbar { ul.toolbar button { padding-bottom : 2px; + font-family: arial, verdana, helvetica, sans-serif; } .yui-menu-button { @@ -927,13 +928,16 @@ fieldset.rows .inputnote { } #placehold a, -#placehold button { +#placehold button, +#holdfor .first-child { padding-left : 34px; background-image: url("../../img/toolbar-hold.gif"); background-position : center left; background-repeat : no-repeat; } +#holdfor .first-child { padding-left : 17px; } + #editmenuc .first-child, #deleteshelf .first-child,#newmenuc .first-child, #addbiblio .first-child, #z3950search .first-child, #printmenuc .first-child, #newsupplier .first-child, #savemenuc .first-child, #budgets_menuc .first-child, #periods_menuc .first-child { padding-left : 15px; } @@ -1413,6 +1417,11 @@ li.email { padding : .1em 0 .1em 1em; } +/* Hack just for Firefox */ +html>/**/body #searchheader button, x:-moz-any-link, x:default { + padding-bottom : 3px; +} + #searchheader h3 { } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 8d4e02e024..af31769ec9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -148,7 +148,31 @@ function confirm_items_deletion() { container: this, onclick: {fn: printBiblio } }); + + + // Create an array of YAHOO.widget.MenuItem configuration properties + var onButtonClick = function () { + location.href="/cgi-bin/koha/reserve/request.pl?biblionumber="; + } + var HoldForButtonMenu = [ + { text: "Place hold", url: "/cgi-bin/koha/reserve/request.pl?biblionumber=" }, + { text: "Place hold for ()", url: "/cgi-bin/koha/reserve/request.pl?biblionumber=&findborrower=" } + ]; + // Instantiate a Split Button using the array of YAHOO.widget.MenuItem + // configuration properties as the value for the "menu" + // configuration attribute. + + var HoldForButton = new YAHOO.widget.Button({ + id: "holdfor", + type: "split", + label: "Place hold", + name: "holdfor", + menu: HoldForButtonMenu, + container: this, + onclick: { fn: onButtonClick } + }); + new YAHOO.widget.Button({ id: "placehold", type: "link", @@ -156,6 +180,8 @@ function confirm_items_deletion() { container: this, href: "/cgi-bin/koha/reserve/request.pl?biblionumber=" }); + + new YAHOO.widget.Button({ id: "z3950search", diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc index 976de151d1..e14590d9c4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc @@ -36,11 +36,8 @@ function update_child() { // prepare DOM for YUI Toolbar $(document).ready(function() { - $("#printslip").parent().remove(); - $("#patronflags").parent().remove(); - $("#deletepatron").parent().remove(); - $("#moremenuc").empty(); - $("#printmenuc").empty(); + $("#printslip,#patronflags,#deletepatron").parent().remove(); + $("#moremenuc,#printmenuc,#searchtoholdc").empty(); yuiToolbar(); }); @@ -49,7 +46,12 @@ function update_child() { window.open("/cgi-bin/koha/members/moremember.pl?borrowernumber=&print=" + print_type, "printwindow"); return false; } - + function searchToHold(){ + var date = new Date(); + date.setTime(date.getTime() + (10 * 60 * 1000)); + $.cookie("holdfor", "", { path: "/", expires: date }); + location.href="/cgi-bin/koha/catalogue/search.pl"; + } function yuiToolbar() { var printmenu = [ @@ -76,8 +78,14 @@ function update_child() { name: "printmenubutton", menu: printmenu, container: "printmenuc" - }); - + }); + new YAHOO.widget.Button({ + id: "searchtohold", + type: "button", + label: _("Search to hold"), + container: "searchtoholdc", + onclick: {fn: searchToHold } + }); new YAHOO.widget.Button({ type: "menu", label: _("More"), @@ -85,7 +93,7 @@ function update_child() { menu: moremenu, container: "moremenuc" }); - + new YAHOO.widget.Button("addchild"); new YAHOO.widget.Button("editpatron"); new YAHOO.widget.Button("addnote"); @@ -93,7 +101,7 @@ function update_child() { new YAHOO.widget.Button("changepassword"); new YAHOO.widget.Button("printslip"); new YAHOO.widget.Button("printpage"); - new YAHOO.widget.Button("renewpatron"); + new YAHOO.widget.Button("renewpatron"); @@ -127,12 +135,12 @@ function update_child() {
  • &category_type=C">Add child
  • -">Add Note -->
  • ">Change Password
  • ">Change Password
  • &print=page">Print Page
  • &print=slip">Print Slip
  • +
  • Search to hold
  • ">Renew Account
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index 42f9df2d7c..39be3215bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -30,6 +30,7 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 6f22d4649e..18a7a699a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -34,11 +34,8 @@ function update_child() { // prepare DOM for YUI Toolbar $(document).ready(function() { - $("#printslip").parent().remove(); - $("#patronflags").parent().remove(); - $("#deletepatron").parent().remove(); - $("#moremenuc").empty(); - $("#printmenuc").empty(); + $("#printslip,#patronflags,#deletepatron").parent().remove(); + $("#moremenuc,#printmenuc,#searchtoholdc").empty(); yuiToolbar(); }); @@ -47,7 +44,12 @@ function update_child() { window.open("/cgi-bin/koha/members/moremember.pl?borrowernumber=&print=" + print_type, "printwindow"); return false; } - + function searchToHold(){ + var date = new Date(); + date.setTime(date.getTime() + (10 * 60 * 1000)); + $.cookie("holdfor", "", { path: "/", expires: date }); + location.href="/cgi-bin/koha/catalogue/search.pl"; + } function yuiToolbar() { var printmenu = [ { text: _("Print Page"), onclick: {fn: function(){printx_window("page")}} }, @@ -70,6 +72,14 @@ function update_child() { container: "printmenuc" }); + new YAHOO.widget.Button({ + id: "searchtohold", + type: "button", + label: _("Search to hold"), + container: "searchtoholdc", + onclick: {fn: searchToHold } + }); + new YAHOO.widget.Button({ type: "menu", label: _("More"), @@ -108,9 +118,9 @@ function update_child() {
  • &category_type=C">Add child
  • -">Add Note -->
  • ">Change Password
  • &print=page">Print Page
  • &print=slip">Print Slip
  • +
  • Search to hold
  • ">Renew Account
  • ">Set Permissions
  • Delete
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js new file mode 100644 index 0000000000..eb129db969 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js @@ -0,0 +1 @@ +jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h // // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html function verify_images() { @@ -21,7 +22,6 @@ function verify_images() { } }); } -var q_array = new Array(); // will hold search terms, if present $(window).load(function() { verify_images(); @@ -30,13 +30,33 @@ $(window).load(function() { function Dopop(link) { newin=window.open(link,'popup','width=500,height=500,toolbar=false,scrollbars=yes,resizeable=yes'); } +function cartList(){ + if($("#addto").find("option:selected").attr("value") == "addtolist"){ + var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s",""); + if (vShelfAdd()) { + Dopop('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vShelfAdd()); + } + return false; + } else if($("#addto").find("option:selected").attr("value") == "newlist"){ + if (vShelfAdd()) { + Dopop('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vShelfAdd()); + } + return false; + } + if($("#addto").find("option:selected").attr("value") == "addtocart"){ + addMultiple(); + return false; + } +} +$(window).load(function() { + new YAHOO.widget.Button("cartsubmit", { onclick: { fn: cartList }}); +}); $(document).ready(function() { +$("#placeholdc").empty(); $('#sortbyform').find("input:submit").hide(); $('#sort_by').change(function() { $('#sortbyform').submit(); }); - - $(".addtocart").show(); var param1 = "