From f2159b1dea90a2e5280d1cc10d79c00ae3872499 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 8 Jan 2014 12:08:50 +0100 Subject: [PATCH] Bug 11708: basketgroup.pl can now display basketgroups for all suppliers This happens when no booksellerid is given. This patch also adds 4 columns: - No. of ordered titles - No. of received titles - Ordered amount - Charged amount (amount of received orders) Add filters to basketgroup tables columns Show closed date in closed basketgroups tables --- acqui/basketgroup.pl | 42 ++- koha-tmpl/intranet-tmpl/prog/en/css/datatables.css | 3 + .../prog/en/includes/acquisitions-menu.inc | 1 + .../prog/en/modules/acqui/basketgroup.tt | 272 +++++++++++++------- 4 files changed, 216 insertions(+), 102 deletions(-) diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 2051eaa..14656cf 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -52,13 +52,15 @@ use C4::Auth; use C4::Output; use CGI; -use C4::Bookseller qw/GetBookSellerFromId/; +use C4::Bookseller qw/GetBookSellerFromId GetBookSeller/; use C4::Budgets qw/ConvertCurrency/; use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/; use C4::Bookseller qw/GetBookSellerFromId/; use C4::Branch qw/GetBranches/; use C4::Members qw/GetMember/; +use List::MoreUtils qw/uniq/; + our $input=new CGI; our ($template, $loggedinuser, $cookie) @@ -415,12 +417,38 @@ if ( $op eq "add" ) { print $input->redirect($redirectpath ); }else{ -# no param : display the list of all basketgroups for a given vendor - my $basketgroups = &GetBasketgroups($booksellerid); - my $bookseller = &GetBookSellerFromId($booksellerid); - my $baskets = &GetBasketsByBookseller($booksellerid); - - displaybasketgroups($basketgroups, $bookseller, $baskets); + my @booksellers; + if ($booksellerid) { + push @booksellers, GetBookSellerFromId($booksellerid); + $template->param(booksellername => $booksellers[0]->{name}); + } else { + @booksellers = GetBookSeller(''); + } + foreach my $bookseller (@booksellers) { + $bookseller->{basketgroups} = GetBasketgroups($bookseller->{id}); + foreach my $basketgroup (@{ $bookseller->{basketgroups} }) { + my $baskets = GetBasketsByBasketgroup($basketgroup->{id}); + $basketgroup->{basketsqty} = 0; + $basketgroup->{ordered_amount} = 0.0; + $basketgroup->{charged_amount} = 0.0; + my (@ordered_biblionumbers, @received_biblionumbers); + foreach my $basket (@$baskets) { + $basketgroup->{basketsqty} += 1; + my @orders = GetOrders($basket->{basketno}); + foreach my $order (@orders) { + push @ordered_biblionumbers, $order->{biblionumber}; + $basketgroup->{ordered_amount} += $order->{ecost} * $order->{quantity}; + if ($order->{datereceived}) { + push @received_biblionumbers, $order->{biblionumber}; + $basketgroup->{charged_amount} += $order->{ecost} * $order->{quantity}; + } + } + } + $basketgroup->{ordered_titles_count} = uniq @ordered_biblionumbers; + $basketgroup->{received_titles_count} = uniq @received_biblionumbers; + } + } + $template->param(booksellers => \@booksellers); } $template->param(listclosed => ((defined $input->param('listclosed')) && ($input->param('listclosed') eq '1'))? 1:0 ); #prolly won't use all these, maybe just use print, the rest can be done inside validate diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css b/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css index 92e1768..efdbf10 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/datatables.css @@ -227,6 +227,9 @@ tr.even.selected td { /* ColumnFilter */ span.filter_column > input.text_filter { + box-sizing: border-box; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; font-size: 80%; width: 100%; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc index 439118d..20a7ad8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc @@ -2,6 +2,7 @@
  • Late orders
  • [% IF ( suggestion ) %]
  • Suggestions
  • [% ELSE %][% END %]
  • Invoices
  • +
  • Basket groups
  • [% IF ( CAN_user_acquisition_budget_manage ) %]
  • Budgets
  • Funds
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt index 6aff7da..50448ef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -1,9 +1,15 @@ [% USE Branches %] +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] -Koha › Basket grouping for [% booksellername |html %] +[% IF booksellerid %] + Koha › Basket grouping for [% booksellername |html %] +[% ELSE %] + Koha › Basket grouping +[% END %] [% INCLUDE 'doc-head-close.inc' %] [% INCLUDE 'datatables.inc' %] + @@ -107,15 +113,37 @@ function submitForm(form) { } $(document).ready(function() { - $("#basket_groups").tabs(); + $(".basket_groups").tabs(); - $("table").dataTable($.extend(true, {}, dataTablesDefaults, { - "aoColumnDefs": [ - { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, - ], - sDom: 't', - "bAutoWidth": false - } )); + $("table").each(function () { + var column_filter_options = { + sPlaceHolder: "head:after", + aoColumns: [ + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + null, + null, + null + ] + }; + if ($(this).hasClass('basket_group_closed')) { + // There is one more column in closed basketgroups tables + column_filter_options.aoColumns.unshift({ type: "text" }); + } + $(this).dataTable($.extend(true, {}, dataTablesDefaults, { + "aoColumnDefs": [ + { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, + ], + sDom: 't', + "bAutoWidth": false + } )) + .columnFilter(column_filter_options); + }); }); @@ -129,10 +157,14 @@ function submitForm(form) { + [% booksellername |html %]Basket grouping › Add basket group for [% booksellername |html %] [% ELSE %] - [% booksellername |html %] › Basket grouping + [% IF (booksellerid) %] + [% booksellername |html %] › + [% END %] + Basket grouping [% END %] +
    @@ -300,94 +332,144 @@ function submitForm(form) {
    [% ELSE %] -
    - -
    -

    Basket grouping for [% booksellername |html %]

    -
    - -
    - - - - - - - - - - - - - [% FOREACH basketgroup IN basketgroups %] - [% UNLESS ( basketgroup.closed ) %] + [% IF booksellerid %] + + [% END %] + [% FOREACH bookseller IN booksellers %] + [% IF bookseller.basketgroups.size > 0 %] +

    Basket grouping for [% booksellername |html %]

    +
    +
      + [% UNLESS ( listclosed ) %]
    • Open
    • + [% ELSE%]
    • Open
    • [% END %] + [% IF ( listclosed ) %]
    • Closed
    • + [% ELSE %]
    • Closed
    • [% END %] +
    +
    +
    NameNumberBilling placeDelivery placeNumber of basketsAction
    + - - - - - - + + + + + + + + + + - [% END %] - [% END %] - -
    [% IF ( basketgroup.name ) %] - [% basketgroup.name %] - [% ELSE %] - Basket group no. [% basketgroup.id %] - [% END %] - [% basketgroup.id %][% Branches.GetName( basketgroup.billingplace ) %][% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) %][% END %][% basketgroup.basketsqty %] - -
    -
    -
    Search nameSearch no.Search billing placeSearch delivery placeSearch no. of basketsSearch no. of ordered titlesSearch no. of received titles
    -
    -
    - - - - - - - - - - - - - [% FOREACH basketgroup IN basketgroups %] - [% IF ( basketgroup.closed ) %] - - - - - - + + + + + + + + + + - [% END %] - [% END %] - -
    NameNumberBilling placeDelivery placeNumber of basketsAction
    - [% IF ( basketgroup.name ) %] - [% basketgroup.name %] - [% ELSE %] - Basket group no. [% basketgroup.id %] - [% END %] - [% basketgroup.id %][% Branches.GetName( basketgroup.billingplace ) %][% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) %][% END %][% basketgroup.basketsqty %] -
    -
    -
    -
    -
    NameNo.Billing placeDelivery placeNo. of basketsNo. of ordered titlesNo. of received titlesOrdered amountCharged amountAction
    -
    -
    + + + [% FOREACH basketgroup IN bookseller.basketgroups %] + [% UNLESS ( basketgroup.closed ) %] + + + [% IF ( basketgroup.name ) %] + [% basketgroup.name %] + [% ELSE %] + Basket group no. [% basketgroup.id %] + [% END %] + + [% basketgroup.id %] + [% Branches.GetName(basketgroup.billingplace) %] + [% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %] + [% basketgroup.basketsqty %] + [% basketgroup.ordered_titles_count %] + [% basketgroup.received_titles_count %] + [% basketgroup.ordered_amount %] + [% basketgroup.charged_amount %] + + +
    +
    + + + [% END %] + [% END %] + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [% FOREACH basketgroup IN bookseller.basketgroups %] + [% IF ( basketgroup.closed ) %] + + + + + + + + + + + + + + [% END %] + [% END %] + +
    Search nameSearch no.Search date closedSearch billing placeSearch delivery placeSearch no. of basketsSearch no. of ordered titlesSearch no. of received titles
    NameNo.Date closedBilling placeDelivery placeNo. of basketsNo. of ordered titlesNo. of received titlesOrdered amountCharged amountAction
    + [% IF ( basketgroup.name ) %] + [% basketgroup.name %] + [% ELSE %] + Basket group no. [% basketgroup.id %] + [% END %] + [% basketgroup.id %][% basketgroup.closeddate |$KohaDates %][% Branches.GetName(basketgroup.billingplace) %][% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %][% basketgroup.basketsqty %][% basketgroup.ordered_titles_count %][% basketgroup.received_titles_count %][% basketgroup.ordered_amount %][% basketgroup.charged_amount %] +
    +
    +
    +
    +
    +
    + + [% END %] + [% END %] [% END %] -- 1.7.10.4