View | Details | Raw Unified | Return to bug 11708
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-6 / +2 lines)
Lines 1512-1520 sub ModReceiveOrder { Link Here
1512
        $order->{datereceived} = $datereceived;
1512
        $order->{datereceived} = $datereceived;
1513
        $order->{invoiceid} = $invoice->{invoiceid};
1513
        $order->{invoiceid} = $invoice->{invoiceid};
1514
        $order->{orderstatus} = 'complete';
1514
        $order->{orderstatus} = 'complete';
1515
        my @columns = Koha::Acquisition::Orders->columns;
1515
        $new_ordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber;
1516
        my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
1517
        $new_ordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
1518
1516
1519
        if ($received_items) {
1517
        if ($received_items) {
1520
            foreach my $itemnumber (@$received_items) {
1518
            foreach my $itemnumber (@$received_items) {
Lines 2012-2020 sub TransferOrder { Link Here
2012
    delete $order->{parent_ordernumber};
2010
    delete $order->{parent_ordernumber};
2013
    $order->{'basketno'} = $basketno;
2011
    $order->{'basketno'} = $basketno;
2014
2012
2015
    my @columns = Koha::Acquisition::Orders->columns;
2013
    my $newordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber;
2016
    my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
2017
    my $newordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
2018
2014
2019
    $query = q{
2015
    $query = q{
2020
        UPDATE aqorders_items
2016
        UPDATE aqorders_items
(-)a/Koha/Acquisition/Basketgroup.pm (-6 / +6 lines)
Lines 31-45 Koha::Acquisition::Basketgroup Link Here
31
31
32
=head2 Methods
32
=head2 Methods
33
33
34
=head3 bookseller
34
=head3 vendor
35
35
36
Returns the basketgroup's bookseller (Koha::Acquisition::Bookseller)
36
Returns the basketgroup's vendor (Koha::Acquisition::Bookseller)
37
37
38
    my $bookseller = $basketgroup->bookseller;
38
    my $vendor = $basketgroup->vendor;
39
39
40
=cut
40
=cut
41
41
42
sub bookseller {
42
sub vendor {
43
    my ($self) = @_;
43
    my ($self) = @_;
44
44
45
    return scalar Koha::Acquisition::Booksellers->find($self->booksellerid);
45
    return scalar Koha::Acquisition::Booksellers->find($self->booksellerid);
Lines 57-65 Returns the basketgroup's baskets Link Here
57
sub baskets {
57
sub baskets {
58
    my ($self) = @_;
58
    my ($self) = @_;
59
59
60
    $self->{_baskets} ||= Koha::Acquisition::Baskets->search({ basketgroupid => $self->id });
60
    my $baskets = Koha::Acquisition::Baskets->search({ basketgroupid => $self->id });
61
61
62
    return wantarray ? $self->{_baskets}->as_list : $self->{_baskets};
62
    return wantarray ? $baskets->as_list : $baskets;
63
}
63
}
64
64
65
=head3 baskets_count
65
=head3 baskets_count
(-)a/acqui/basketgroup.pl (-41 lines)
Lines 58-65 use Koha::Acquisition::Booksellers; Link Here
58
use Koha::ItemTypes;
58
use Koha::ItemTypes;
59
use Koha::Patrons;
59
use Koha::Patrons;
60
60
61
use List::MoreUtils qw/uniq/;
62
63
our $input=new CGI;
61
our $input=new CGI;
64
62
65
our ($template, $loggedinuser, $cookie)
63
our ($template, $loggedinuser, $cookie)
Lines 87-126 sub BasketTotal { Link Here
87
    return $total;
85
    return $total;
88
}
86
}
89
87
90
#displays all basketgroups and all closed baskets (in their respective groups)
91
sub displaybasketgroups {
92
    my ($basketgroups, $bookseller, $baskets, $template) = @_;
93
    if (scalar @$basketgroups != 0) {
94
        foreach my $basketgroup (@$basketgroups){
95
            my $i = 0;
96
            my $basketsqty = 0;
97
            while($i < scalar(@$baskets)){
98
                my $basket = @$baskets[$i];
99
                if($basket->{'basketgroupid'} && $basket->{'basketgroupid'} == $basketgroup->{'id'}){
100
                    $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
101
                    push(@{$basketgroup->{'baskets'}}, $basket);
102
                    splice(@$baskets, $i, 1);
103
                    ++$basketsqty;
104
                    --$i;
105
                }
106
                ++$i;
107
            }
108
            $basketgroup -> {'basketsqty'} = $basketsqty;
109
        }
110
        $template->param(basketgroups => $basketgroups);
111
    }
112
    for(my $i=0; $i < scalar @$baskets; ++$i) {
113
        if( ! @$baskets[$i]->{'closedate'} ) {
114
            splice(@$baskets, $i, 1);
115
            --$i;
116
        }else{
117
            @$baskets[$i]->{total} = BasketTotal(@$baskets[$i]->{basketno}, $bookseller);
118
        }
119
    }
120
    $template->param(baskets => $baskets);
121
    $template->param( booksellername => $bookseller->name);
122
}
123
124
sub printbasketgrouppdf{
88
sub printbasketgrouppdf{
125
    my ($basketgroupid) = @_;
89
    my ($basketgroupid) = @_;
126
90
Lines 425-433 $deliveryplace = $deliveryplace || $borrower->branchcode; Link Here
425
389
426
$template->param( booksellerid => $booksellerid );
390
$template->param( booksellerid => $booksellerid );
427
391
428
# the template will display a unique basketgroup
429
my $basketgroups = &GetBasketgroups($booksellerid);
430
my $baskets = &GetBasketsByBookseller($booksellerid);
431
displaybasketgroups($basketgroups, $bookseller, $baskets, $template);
432
433
output_html_with_http_headers $input, $cookie, $template->output;
392
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/installer/data/mysql/atomicupdate/bug_11708.perl (-1 / +8 lines)
Lines 8-16 if( CheckVersion( $DBversion ) ) { Link Here
8
    }
8
    }
9
9
10
    if (column_exists('aqbasketgroups', 'closed')) {
10
    if (column_exists('aqbasketgroups', 'closed')) {
11
        # Set basketgroup's close date to the latest close date of its baskets,
12
        # or NOW() if it has no baskets
11
        $dbh->do(q{
13
        $dbh->do(q{
12
            UPDATE aqbasketgroups
14
            UPDATE aqbasketgroups
13
            SET closeddate = CAST(NOW() AS DATE)
15
                LEFT JOIN (
16
                    SELECT basketgroupid, MAX(closedate) AS closedate
17
                    FROM aqbasket
18
                    GROUP BY basketgroupid
19
                ) AS aqbasket ON (aqbasketgroups.id = aqbasket.basketgroupid)
20
            SET aqbasketgroups.closeddate = COALESCE(aqbasket.closedate, CAST(NOW() AS DATE))
14
            WHERE closed = 1
21
            WHERE closed = 1
15
              AND closeddate IS NULL
22
              AND closeddate IS NULL
16
        });
23
        });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-1 / +1 lines)
Lines 807-813 Link Here
807
            $(document).ready(function(){
807
            $(document).ready(function(){
808
                $("#basketgroupid").change(function(){
808
                $("#basketgroupid").change(function(){
809
                    if($(this).val() == "new"){
809
                    if($(this).val() == "new"){
810
                        location.href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% booksellerid | html %]";
810
                        location.href="/cgi-bin/koha/acqui/basketgroups.pl?op=add&booksellerid=[% booksellerid | html %]";
811
                    }
811
                    }
812
                });
812
                });
813
            });
813
            });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt (-7 / +3 lines)
Lines 4-14 Link Here
4
[% USE Price %]
4
[% USE Price %]
5
[% USE KohaDates %]
5
[% USE KohaDates %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% IF booksellerid %]
7
<title>Koha &rsaquo; Basket groups for [% booksellername |html %]</title>
8
  <title>Koha &rsaquo; Basket groups for [% booksellername |html %]</title>
9
[% ELSE %]
10
  <title>Koha &rsaquo; Basket groups</title>
11
[% END %]
12
[% Asset.css("css/datatables.css") | $raw %]
8
[% Asset.css("css/datatables.css") | $raw %]
13
[% INCLUDE 'doc-head-close.inc' %]
9
[% INCLUDE 'doc-head-close.inc' %]
14
[% INCLUDE 'datatables.inc' %]
10
[% INCLUDE 'datatables.inc' %]
Lines 120-126 function submitForm(form) { Link Here
120
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;
116
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;
121
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% booksellername | html %]</a>
117
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% booksellername | html %]</a>
122
    &rsaquo;
118
    &rsaquo;
123
    <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | html %]">Basket groups</a>
119
    <a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid | html %]">Basket groups</a>
124
    &rsaquo;
120
    &rsaquo;
125
    Add basket group for [% booksellername | html %]
121
    Add basket group for [% booksellername | html %]
126
</div>
122
</div>
Lines 276-282 function submitForm(form) { Link Here
276
                                            <input type="hidden" name="basketgroupid" value="[% basketgroupid | html %]" />
272
                                            <input type="hidden" name="basketgroupid" value="[% basketgroupid | html %]" />
277
                                        [% END %]
273
                                        [% END %]
278
                                        <input type="hidden" name="op" value="attachbasket" />
274
                                        <input type="hidden" name="op" value="attachbasket" />
279
                                        <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | html %]" class="cancel">Cancel</a>
275
                                        <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid | html %]" class="cancel">Cancel</a>
280
                                    </fieldset>
276
                                    </fieldset>
281
                                [% END %]
277
                                [% END %]
282
                            </form>
278
                            </form>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt (-50 / +54 lines)
Lines 2-62 Link Here
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
4
5
[% SET footerjs = 1 %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
    [% IF bookseller %]
7
    [% IF bookseller %]
7
        <title>Koha &rsaquo; Basket groups for [% bookseller.name |html %]</title>
8
        <title>Koha &rsaquo; Basket groups for [% bookseller.name |html %]</title>
8
    [% ELSE %]
9
    [% ELSE %]
9
        <title>Koha &rsaquo; Basket groups</title>
10
        <title>Koha &rsaquo; Basket groups</title>
10
    [% END %]
11
    [% END %]
11
12
[% INCLUDE 'doc-head-close.inc' %]
12
    [% Asset.css('css/datatables.css') %]
13
[% Asset.css('css/datatables.css') %]
13
    [% INCLUDE 'doc-head-close.inc' %]
14
    [% INCLUDE 'datatables.inc' %]
15
    [% Asset.js('lib/jquery/plugins/jquery.dataTables.columnFilter.js') %]
16
    <script type="text/javascript">
17
        $(document).ready(function() {
18
            var options = {
19
                "paging": false,
20
                "autoWidth": false,
21
                "columnDefs": [
22
                    { "visible": false, "targets": 1 },
23
                    { "orderable": false, "targets": -1 }
24
                ],
25
                "orderFixed": [[ 1, 'asc' ]]
26
            };
27
            [% UNLESS bookseller %]
28
                options.drawCallback = function(settings) {
29
                    var api = this.api();
30
                    var rows = api.rows({page: 'current'}).nodes();
31
                    var last = null;
32
33
                    api.column(1, {page: 'current'}).data().each(function(group, i) {
34
                        if (last !== group) {
35
                            $(rows).eq(i).before(
36
                                '<tr><td class="group" colspan="8">' + group + '</td></tr>'
37
                            );
38
                            last = group;
39
                        }
40
                    });
41
                };
42
            [% END %]
43
            $("#basketgroups-table").kohaDataTable(options);
44
45
            $('#basketgroups-table').on('click', '.closeandprint', function(e) {
46
                e.preventDefault();
47
                var w = window.open($(this).attr('href'));
48
                var timer = setInterval(function() {
49
                    if (w.closed === true) {
50
                        clearInterval(timer);
51
                        window.location.reload(true);
52
                    }
53
                }, 1000);
54
            });
55
            $('#basketgroups-table').on('click', '.delete', function() {
56
                return confirm(_("Are you sure you want to delete this basketgroup ?"));
57
            });
58
        });
59
    </script>
60
</head>
14
</head>
61
<body id="acq_basketgroup" class="acq">
15
<body id="acq_basketgroup" class="acq">
62
    [% INCLUDE 'header.inc' %]
16
    [% INCLUDE 'header.inc' %]
Lines 113-119 Link Here
113
                                                Basket group no. [% basketgroup.id %]
67
                                                Basket group no. [% basketgroup.id %]
114
                                            [% END %]
68
                                            [% END %]
115
                                        </td>
69
                                        </td>
116
                                        <td>[% basketgroup.bookseller.name %]</td>
70
                                        <td>[% basketgroup.vendor.name %]</td>
117
                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
71
                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
118
                                        <td>
72
                                        <td>
119
                                            [% IF (basketgroup.freedeliveryplace) %]
73
                                            [% IF (basketgroup.freedeliveryplace) %]
Lines 160-163 Link Here
160
                [% INCLUDE 'acquisitions-menu.inc' %]
114
                [% INCLUDE 'acquisitions-menu.inc' %]
161
            </div>
115
            </div>
162
        </div>
116
        </div>
117
118
        [% MACRO jsinclude BLOCK %]
119
            [% INCLUDE 'datatables.inc' %]
120
            [% Asset.js('lib/jquery/plugins/jquery.dataTables.columnFilter.js') %]
121
            <script type="text/javascript">
122
                $(document).ready(function() {
123
                    var options = {
124
                        "paging": false,
125
                        "autoWidth": false,
126
                        "columnDefs": [
127
                            { "visible": false, "targets": 1 },
128
                            { "orderable": false, "targets": -1 }
129
                        ],
130
                        "orderFixed": [[ 1, 'asc' ]]
131
                    };
132
                    [% UNLESS bookseller %]
133
                        options.drawCallback = function(settings) {
134
                            var api = this.api();
135
                            var rows = api.rows({page: 'current'}).nodes();
136
                            var last = null;
137
138
                            api.column(1, {page: 'current'}).data().each(function(group, i) {
139
                                if (last !== group) {
140
                                    $(rows).eq(i).before(
141
                                        '<tr><td class="group" colspan="8">' + group + '</td></tr>'
142
                                    );
143
                                    last = group;
144
                                }
145
                            });
146
                        };
147
                    [% END %]
148
                    $("#basketgroups-table").kohaDataTable(options);
149
150
                    $('#basketgroups-table').on('click', '.closeandprint', function(e) {
151
                        e.preventDefault();
152
                        var w = window.open($(this).attr('href'));
153
                        var timer = setInterval(function() {
154
                            if (w.closed === true) {
155
                                clearInterval(timer);
156
                                window.location.reload(true);
157
                            }
158
                        }, 1000);
159
                    });
160
                    $('#basketgroups-table').on('click', '.delete', function() {
161
                        return confirm(_("Are you sure you want to delete this basketgroup ?"));
162
                    });
163
                });
164
            </script>
165
        [% END %]
166
163
    [% INCLUDE 'intranet-bottom.inc' %]
167
    [% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-3 / +2 lines)
Lines 133-139 Link Here
133
                <td class="basketfilterclass">[% loop_order.basketname | html %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno | html %]">[% loop_order.basketno | html %]</a>)</td>
133
                <td class="basketfilterclass">[% loop_order.basketname | html %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno | html %]">[% loop_order.basketno | html %]</a>)</td>
134
                <td>
134
                <td>
135
                  [% IF loop_order.basketgroupid %]
135
                  [% IF loop_order.basketgroupid %]
136
                    [% loop_order.basketgroupname | html %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% loop_order.booksellerid | html %]">[% loop_order.basketgroupid | html %]</a>)
136
                    [% loop_order.basketgroupname | html %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% loop_order.booksellerid | html %]&basketgroupid=[% loop_order.basketgroupid | html %]">[% loop_order.basketgroupid | html %]</a>)
137
                  [% ELSE %]
137
                  [% ELSE %]
138
                    No basket group
138
                    No basket group
139
                  [% END %]
139
                  [% END %]
Lines 280-286 Link Here
280
                <td>[% order.basketname | html %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | html %]">[% order.basketno | html %]</a>)</td>
280
                <td>[% order.basketname | html %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | html %]">[% order.basketno | html %]</a>)</td>
281
                <td>
281
                <td>
282
                  [% IF order.basketgroupid %]
282
                  [% IF order.basketgroupid %]
283
                    [% order.basketgroupname | html %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% order.booksellerid | html %]">[% order.basketgroupid | html %]</a>)
283
                    [% order.basketgroupname | html %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% order.booksellerid | html %]&basketgroupid=[% order.basketgroupid | html %]">[% order.basketgroupid | html %]</a>)
284
                  [% ELSE %]
284
                  [% ELSE %]
285
                    No basket group
285
                    No basket group
286
                  [% END %]
286
                  [% END %]
287
- 

Return to bug 11708