From 1ca202ce2f488230c34df68c0ba70e6d4e287dba 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 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). Signed-off-by: Campbell Reid-Tait --- 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 @@ -
+
Add order to basket [% IF has_budgets %]
  • -
    + -
  • @@ -18,6 +19,8 @@
  • From a staged file
[% ELSE %] - You can't create any orders unless you first define a budget and a fund. +
+

You can't create any orders unless you first define a budget and a fund.

+
[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index 8cbc46e..5da0b29 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -30,7 +30,7 @@ updateColumnsVisibility(false); [% UNLESS ( closedate ) %] $('#addtoBasket').on('show', function () { - $(this).find(".modal-body").html($("#acqui_basket_add")[0].outerHTML); + $(this).find(".modal-body").html($(".acqui_basket_add")[0].outerHTML); }); [% END %] }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt index 525ea66..782bed1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt @@ -14,23 +14,28 @@ @@ -63,9 +68,9 @@ $(document).ready(function() {

[% END %] [% IF ( allbaskets ) %] -

Show active baskets only

+

Show active baskets only

[% ELSE %] -

Show all baskets

+

Show all baskets

[% END %]
[% FOREACH supplier IN loop_suppliers %] @@ -80,12 +85,12 @@ $(document).ready(function() { [% IF ( CAN_user_acquisition_order_manage ) %] [% IF ( supplier.active ) %] - + New basket [% ELSE %] (inactive) [% END %] [% END %] - + Receive shipment
[% IF ( supplier.loop_basket.size ) %] @@ -99,6 +104,7 @@ $(document).ready(function() { Items expected Created by Date + Closed   @@ -118,23 +124,35 @@ $(document).ready(function() { [% basket.authorisedby_firstname %] [% basket.authorisedby_surname %] - [% basket.creationdate | $KohaDates %] + [% basket.creationdate | $KohaDates %] [% IF ( basket.closedate ) %] - closed on [% basket.closedate | $KohaDates %] - View + [% basket.closedate | $KohaDates %] [% ELSE %] - [% IF ( basket.active ) %] - Modify - [% ELSE %] - View - [% END %] + + [% END %] + + + View + + [% UNLESS ( basket.closedate ) %] + | Add to basket + + [% END %] [% END %][%# FOREACH basket IN supplier.loop_basket %] + [% ELSE %]

No pending baskets

[% END %][%# IF ( supplier.loop_basket.size ) %] -- 1.7.10.4