From d09e428a7dc9854c6f4e45f3caade3c8e141b79d Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 13 Jan 2012 12:11:49 +0100 Subject: [PATCH] Bug 7169: Change booksellers search results display - Replace vendor table by a div (avoid table in a table) - Add two columns in basket tables: biblio count and expected (not received) items) - Replace tablesorter by datatables - Add a list of all returned bookseller names in top of the page (easier to find a bookseller in a large list of results) --- C4/Acquisition.pm | 34 ++++ acqui/booksellers.pl | 35 ++-- .../prog/en/css/staff-global.css | 20 ++ .../prog/en/modules/acqui/booksellers.tt | 177 +++++++++--------- 4 files changed, 163 insertions(+), 103 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 15a68eaa33..4fd5cc2722 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -44,6 +44,7 @@ BEGIN { &GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket &GetBasketAsCSV &GetBasketsByBookseller &GetBasketsByBasketgroup + &GetBasketsInfosByBookseller &ModBasketHeader @@ -464,6 +465,39 @@ sub GetBasketsByBookseller { return $results } +=head3 GetBasketsInfosByBookseller + + my $baskets = GetBasketsInfosByBookseller($supplierid); + +Returns in a arrayref of hashref all about booksellers baskets, plus: + total_biblios: Number of distinct biblios in basket + total_items: Number of items in basket + expected_items: Number of non-received items in basket + +=cut + +sub GetBasketsInfosByBookseller { + my ($supplierid) = @_; + + return unless $supplierid; + + my $dbh = C4::Context->dbh; + my $query = qq{ + SELECT aqbasket.*, + SUM(aqorders.quantity) AS total_items, + COUNT(DISTINCT aqorders.biblionumber) AS total_biblios, + SUM(IF(aqorders.datereceived IS NULL, aqorders.quantity, 0)) AS expected_items + FROM aqbasket + LEFT JOIN aqorders ON aqorders.basketno = aqbasket.basketno + WHERE booksellerid = ? + GROUP BY aqbasket.basketno + }; + my $sth = $dbh->prepare($query); + $sth->execute($supplierid); + return $sth->fetchall_arrayref({}); +} + + #------------------------------------------------------------# =head3 GetBasketsByBasketgroup diff --git a/acqui/booksellers.pl b/acqui/booksellers.pl index ac3c557c5e..f1fa9f314d 100755 --- a/acqui/booksellers.pl +++ b/acqui/booksellers.pl @@ -57,6 +57,7 @@ use C4::Output; use CGI; use C4::Dates qw/format_date/; +use C4::Acquisition qw/ GetBasketsInfosByBookseller /; use C4::Bookseller qw/ GetBookSellerFromId GetBookSeller /; use C4::Members qw/GetMember/; use C4::Context; @@ -105,13 +106,18 @@ my $userbranch = $userenv->{branch}; my $loop_suppliers = []; for my $vendor (@suppliers) { - my $baskets = get_vendors_baskets( $vendor->{id} ); + my $baskets = GetBasketsInfosByBookseller( $vendor->{id} ); my $loop_basket = []; - + for my $basket ( @{$baskets} ) { my $authorisedby = $basket->{authorisedby}; - + my $basketbranch = ''; # set a blank branch to start with + my $member = GetMember( borrowernumber => $authorisedby ); + if ( $member ) { + $basketbranch = $member->{branchcode}; + } + if ($userenv->{'flags'} & 1 || #user is superlibrarian (haspermission( $uid, { acquisition => q{*} } ) && #user has acq permissions and ($viewbaskets eq 'all' || #user is allowed to see all baskets @@ -125,6 +131,13 @@ for my $vendor (@suppliers) { $basket->{$date_field} = format_date( $basket->{$date_field} ); } } + foreach (qw(total_items total_biblios expected_items)) { + $basket->{$_} ||= 0; + } + if($member) { + $basket->{authorisedby_firstname} = $member->{firstname}; + $basket->{authorisedby_surname} = $member->{surname}; + } push @{$loop_basket}, $basket; } } @@ -141,21 +154,7 @@ $template->param( loop_suppliers => $loop_suppliers, supplier => ( $booksellerid || $supplier ), count => $supplier_count, + dateformat => C4::Context->preference('dateformat'), ); output_html_with_http_headers $query, $cookie, $template->output; - -sub get_vendors_baskets { - my $supplier_id = shift; - my $dbh = C4::Context->dbh; - my $sql = <<'ENDSQL'; -select aqbasket.*, count(*) as total, borrowers.firstname, borrowers.surname -from aqbasket left join aqorders on aqorders.basketno = aqbasket.basketno -left join borrowers on aqbasket.authorisedby = borrowers.borrowernumber -where booksellerid = ? -AND ( aqorders.quantity > aqorders.quantityreceived OR quantityreceived IS NULL) -AND datecancellationprinted IS NULL -group by basketno -ENDSQL - return $dbh->selectall_arrayref( $sql, { Slice => {} }, $supplier_id ); -} 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 78dd4f9d61..469f631b84 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -2164,3 +2164,23 @@ a.localimage img { div.pager p { margin: 0; } + +div#acqui_order_supplierlist > div.supplier { + border: 1px solid #EEEEEE; + margin: 0.5em; + padding: 1em; +} + +div#acqui_order_supplierlist > div.supplier > span.suppliername { + display: inline; + font-size: 1.7em; + margin-bottom: 0.5em; +} + +div#acqui_order_supplierlist > div.supplier > span.action { + margin-left: 5em; +} + +div#acqui_order_supplierlist > div.supplier > div.baskets { + margin-top: 0.5em; +} 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 16162610b9..26c15fcaa8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt @@ -6,19 +6,26 @@ vertical-align: top; } - + + +[% INCLUDE 'datatables-strings.inc' %] + @@ -40,88 +47,88 @@ [% ELSE %]

You searched on vendor [% supplier %], [% count %] results found

[% END %] -[% IF ( loop_suppliers ) %] +[% IF ( loop_suppliers.size ) %] + [% UNLESS (count == 1) %] + + [% END %]
- - - - - - - - - - - [% FOREACH loop_supplier IN loop_suppliers %] - [% UNLESS ( loop.odd ) %] - - [% ELSE %] - - [% END %] - - - [% IF ( loop_supplier.name ) %] - - [% ELSE %] - - [% END %] - - - [% END %] - -
OrderOrder receiveVendor 
[% IF ( CAN_user_acquisition_order_manage ) %] - [% IF ( loop_supplier.active ) %] - New basket + [% FOREACH supplier IN loop_suppliers %] +
+ + [% IF (supplier.name) %] + [% supplier.name %] [% ELSE %] - Inactive + NO NAME [% END %] + + + [% IF ( CAN_user_acquisition_order_manage ) %] + [% IF ( supplier.active ) %] + + [% ELSE %] + (inactive) + [% END %] [% END %] -
Receive shipment - [% loop_supplier.name %]NO NAME - [% IF ( loop_supplier.loop_basket ) %] - - - - - - - - [% FOREACH loop_baske IN loop_supplier.loop_basket %] - [% IF ( loop_baske.uncertainprices ) %] - - [% ELSE %] - [% UNLESS ( loop.odd ) %] - - [% ELSE %] + + +
+ [% IF ( supplier.loop_basket.size ) %] +
Basket (#)ItemsCreated byDate 
+ - [% END %] - [% END %] - - - - - + + + + + + + + + + [% FOREACH basket IN supplier.loop_basket %] + [% IF ( basket.uncertainprices ) %] + + [% ELSE %] + + [% END %] + + + + + + + - - [% END %] - [% ELSE %] - - [% END %] + + + [% END %][%# FOREACH basket IN supplier.loop_basket %] +
[% loop_baske.basketname %] (#[% loop_baske.basketno %])[% loop_baske.total %] [% loop_baske.firstname %] - [% loop_baske.surname %] - [% loop_baske.creationdate %] [% IF ( loop_baske.closedate ) %] - closed on [% loop_baske.closedate %] - View - [% ELSE %] - [% IF ( loop_baske.active ) %] - modify + Basket (#)BibliosItemsExpected itemsCreated byDate 
[% basket.basketname %] (#[% basket.basketno %])[% basket.total_biblios %][% basket.total_items %][% basket.expected_items %] + [% basket.authorisedby_firstname %] + [% basket.authorisedby_surname %] + [% basket.creationdate %] + [% IF ( basket.closedate ) %] + closed on [% basket.closedate %] + View [% ELSE %] - View + [% IF ( basket.active ) %] + Modify + [% ELSE %] + View + [% END %] [% END %] - [% END %] -
No pending baskets
-
-
- [% END %] + [% ELSE %] +

No pending baskets

+ [% END %][%# IF ( supplier.loop_basket.size ) %] + + + [% END %][%# FOREACH supplier IN loop_suppliers %] + +[% END %][%# IF ( loop_suppliers.size ) %]
-- 2.39.5