From fc79d5b0b7c980ae7f3bcf03534a1e569a33d3ca Mon Sep 17 00:00:00 2001
From: Owen Leonard
Date: Thu, 15 Aug 2013 12:09:33 -0400
Subject: [PATCH] Bug 10737 [Revised] Add "Add to basket" link on vendor
search results page
Content-Type: text/plain; charset="utf-8"
This patch adds an "add to basket" link to the vendor search results
page for each open basket associated with each vendor. Clicking it
triggers a modal window with the "add to basket" choices for that vendor
and basket.
Other changes in this patch:
- The add-to-basket include has been modified in order to make it more
useful in this context.
- booksellers.pl has been modified to check for an existing budget so
that the add-to-basket include can properly display a warning if there
are none.
- "New basket" and "Receive shipment" buttons associated with each
vendor search result have been converted to Bootstrap-styled buttons.
- Basket closed date has been moved into its own column so that the
table can be sorted by that value.
- Table columns containing dates now use the "title-string" sort option,
eliminating the need for a special date sorting algorithm.
- Converted some &'s to &'s
To test, apply the patch and search for a vendor. For each vendor in
your search results baskets which are open should include an "add to
basket" link. Clicking it should open a modal dialog with the same "add
to basket" options offered on the basket page. The correct vendor ID and
basket number should be associated with each link.
The newly-styled "new basket" and "receive shipment" buttons should work
correctly. Table sorting should work correctly, including the new
"closed" column.
Since the add-to-basket include file was modified, the "add to basket"
button on the basket view page should also be tested (acqui/basket.pl).
---
acqui/booksellers.pl | 16 ++++++-
.../en/includes/acquisitions-add-to-basket.inc | 11 +++--
.../intranet-tmpl/prog/en/modules/acqui/basket.tt | 2 +-
.../prog/en/modules/acqui/booksellers.tt | 50 +++++++++++++-------
4 files changed, 57 insertions(+), 22 deletions(-)
diff --git a/acqui/booksellers.pl b/acqui/booksellers.pl
index 6db0bad..bb65dbc 100755
--- a/acqui/booksellers.pl
+++ b/acqui/booksellers.pl
@@ -53,6 +53,7 @@ use strict;
use warnings;
use C4::Auth;
use C4::Biblio;
+use C4::Budgets;
use C4::Output;
use CGI;
@@ -62,7 +63,7 @@ use C4::Members qw/GetMember/;
use C4::Context;
my $query = CGI->new;
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
{ template_name => 'acqui/booksellers.tmpl',
query => $query,
type => 'intranet',
@@ -103,6 +104,18 @@ my $viewbaskets = C4::Context->preference('AcqViewBaskets');
my $userbranch = $userenv->{branch};
+my $budgets = GetBudgetHierarchy;
+my $has_budgets = 0;
+foreach my $r (@{$budgets}) {
+ if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
+ next;
+ }
+ next unless (CanUserUseBudget($loggedinuser, $r, $userflags));
+
+ $has_budgets = 1;
+ last;
+}
+
#build result page
my $loop_suppliers = [];
@@ -150,6 +163,7 @@ $template->param(
loop_suppliers => $loop_suppliers,
supplier => ( $booksellerid || $supplier ),
count => $supplier_count,
+ has_budgets => $has_budgets,
);
$template->{VARS}->{'allbaskets'} = $allbaskets;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc
index 01ecec9..46f8400 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc
@@ -1,13 +1,14 @@
-