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

(-)a/C4/Acquisition.pm (-2 / +6 lines)
Lines 1510-1516 sub ModReceiveOrder { Link Here
1510
        $order->{datereceived} = $datereceived;
1510
        $order->{datereceived} = $datereceived;
1511
        $order->{invoiceid} = $invoice->{invoiceid};
1511
        $order->{invoiceid} = $invoice->{invoiceid};
1512
        $order->{orderstatus} = 'complete';
1512
        $order->{orderstatus} = 'complete';
1513
        $new_ordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber; # TODO What if the store fails?
1513
        my @columns = Koha::Acquisition::Orders->columns;
1514
        my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
1515
        $new_ordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
1514
1516
1515
        if ($received_items) {
1517
        if ($received_items) {
1516
            foreach my $itemnumber (@$received_items) {
1518
            foreach my $itemnumber (@$received_items) {
Lines 2008-2014 sub TransferOrder { Link Here
2008
    delete $order->{parent_ordernumber};
2010
    delete $order->{parent_ordernumber};
2009
    $order->{'basketno'} = $basketno;
2011
    $order->{'basketno'} = $basketno;
2010
2012
2011
    my $newordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber;
2013
    my @columns = Koha::Acquisition::Orders->columns;
2014
    my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
2015
    my $newordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
2012
2016
2013
    $query = q{
2017
    $query = q{
2014
        UPDATE aqorders_items
2018
        UPDATE aqorders_items
(-)a/Koha/Acquisition/Basket.pm (+22 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Acquisition::BasketGroups;
23
use Koha::Acquisition::BasketGroups;
24
use Koha::Acquisition::Orders;
24
25
25
use base qw( Koha::Object );
26
use base qw( Koha::Object );
26
27
Lines 71-76 sub effective_create_items { Link Here
71
    return $self->create_items || C4::Context->preference('AcqCreateItem');
72
    return $self->create_items || C4::Context->preference('AcqCreateItem');
72
}
73
}
73
74
75
=head3 orders
76
77
Returns basket's orders
78
79
    # As an arrayref
80
    my $orders = $basket->orders;
81
82
    # As an array
83
    my @orders = $basket->orders;
84
85
=cut
86
87
sub orders {
88
    my ($self) = @_;
89
90
    $self->{_orders} ||= Koha::Acquisition::Orders->search({ basketno => $self->basketno });
91
92
    return wantarray ? $self->{_orders}->as_list : $self->{_orders};
93
}
94
95
74
=head2 Internal methods
96
=head2 Internal methods
75
97
76
=head3 _type
98
=head3 _type
(-)a/Koha/Acquisition/Basketgroup.pm (+133 lines)
Line 0 Link Here
1
package Koha::Acquisition::Basketgroup;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use List::MoreUtils qw/uniq/;
21
22
use Koha::Acquisition::Baskets;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Acquisition::Basketgroup
29
30
=head1 API
31
32
=head2 Methods
33
34
=head3 bookseller
35
36
Returns the basketgroup's bookseller (Koha::Acquisition::Bookseller)
37
38
    my $bookseller = $basketgroup->bookseller;
39
40
=cut
41
42
sub bookseller {
43
    my ($self) = @_;
44
45
    return scalar Koha::Acquisition::Booksellers->find($self->booksellerid);
46
}
47
48
=head3 baskets
49
50
Returns the basketgroup's baskets
51
52
    my $baskets = $basketgroup->baskets;    # Koha::Acquisition::Baskets
53
    my @baskets = $basketgroup->baskets;    # array of Koha::Acquisition::Basket
54
55
=cut
56
57
sub baskets {
58
    my ($self) = @_;
59
60
    $self->{_baskets} ||= Koha::Acquisition::Baskets->search({ basketgroupid => $self->id });
61
62
    return wantarray ? $self->{_baskets}->as_list : $self->{_baskets};
63
}
64
65
=head3 baskets_count
66
67
Returns the number of baskets contained in a basket group
68
69
    my $count = $basketgroup->baskets_count;
70
71
=cut
72
73
sub baskets_count {
74
    my ($self) = @_;
75
76
    return $self->baskets->count;
77
}
78
79
=head3 ordered_titles_count
80
81
Returns the number of ordered titles contained in a basket group
82
83
    my $count = $basketgroup->ordered_titles_count;
84
85
=cut
86
87
sub ordered_titles_count {
88
    my ($self) = @_;
89
90
    my @biblionumbers;
91
    foreach my $basket ($self->baskets) {
92
        foreach my $order ($basket->orders) {
93
            push @biblionumbers, $order->biblionumber;
94
        }
95
    }
96
97
    return scalar uniq @biblionumbers;
98
}
99
100
=head3 received_titles_count
101
102
Returns the number of received titles contained in a basket group
103
104
    my $count = $basketgroup->ordered_titles_count;
105
106
=cut
107
108
sub received_titles_count {
109
    my ($self) = @_;
110
111
    my @biblionumbers;
112
    foreach my $basket ($self->baskets) {
113
        foreach my $order ($basket->orders) {
114
            if ($order->datereceived) {
115
                push @biblionumbers, $order->biblionumber;
116
            }
117
        }
118
    }
119
120
    return scalar uniq @biblionumbers;
121
}
122
123
=head2 Internal Methods
124
125
=head3 _type
126
127
=cut
128
129
sub _type {
130
    return 'Aqbasketgroup';
131
}
132
133
1;
(-)a/Koha/Acquisition/Basketgroups.pm (+50 lines)
Line 0 Link Here
1
package Koha::Acquisition::Basketgroups;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Acquisition::Basketgroup;
21
22
use base qw(Koha::Objects);
23
24
=head1 NAME
25
26
Koha::Acquisition::Basketgroups
27
28
=head1 API
29
30
=head2 Internal methods
31
32
=cut
33
34
=head3 _type
35
36
=cut
37
38
sub _type {
39
    return 'Aqbasketgroup';
40
}
41
42
=head3 object_class
43
44
=cut
45
46
sub object_class {
47
    return 'Koha::Acquisition::Basketgroup';
48
}
49
50
1;
(-)a/acqui/basket.pl (-2 / +2 lines)
Lines 207-213 if ( $op eq 'delete_confirm' ) { Link Here
207
                            });
207
                            });
208
            ModBasket( { basketno => $basketno,
208
            ModBasket( { basketno => $basketno,
209
                         basketgroupid => $basketgroupid } );
209
                         basketgroupid => $basketgroupid } );
210
            print $query->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid='.$booksellerid.'&closed=1');
210
            print $query->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid='.$booksellerid);
211
        } else {
211
        } else {
212
            print $query->redirect('/cgi-bin/koha/acqui/booksellers.pl?booksellerid=' . $booksellerid);
212
            print $query->redirect('/cgi-bin/koha/acqui/booksellers.pl?booksellerid=' . $booksellerid);
213
        }
213
        }
Lines 554-560 sub edi_close_and_order { Link Here
554
                }
554
                }
555
            );
555
            );
556
            print $query->redirect(
556
            print $query->redirect(
557
"/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=$booksellerid&closed=1"
557
                "/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=$booksellerid"
558
            );
558
            );
559
        }
559
        }
560
        else {
560
        else {
(-)a/acqui/basketgroup.pl (-91 / +96 lines)
Lines 58-63 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
61
our $input=new CGI;
63
our $input=new CGI;
62
64
63
our ($template, $loggedinuser, $cookie)
65
our ($template, $loggedinuser, $cookie)
Lines 87-95 sub BasketTotal { Link Here
87
89
88
#displays all basketgroups and all closed baskets (in their respective groups)
90
#displays all basketgroups and all closed baskets (in their respective groups)
89
sub displaybasketgroups {
91
sub displaybasketgroups {
90
    my $basketgroups = shift;
92
    my ($basketgroups, $bookseller, $baskets, $template) = @_;
91
    my $bookseller = shift;
92
    my $baskets = shift;
93
    if (scalar @$basketgroups != 0) {
93
    if (scalar @$basketgroups != 0) {
94
        foreach my $basketgroup (@$basketgroups){
94
        foreach my $basketgroup (@$basketgroups){
95
            my $i = 0;
95
            my $i = 0;
Lines 123-151 sub displaybasketgroups { Link Here
123
123
124
sub printbasketgrouppdf{
124
sub printbasketgrouppdf{
125
    my ($basketgroupid) = @_;
125
    my ($basketgroupid) = @_;
126
    
126
127
    my $pdfformat = C4::Context->preference("OrderPdfFormat");
127
    my $pdfformat = C4::Context->preference("OrderPdfFormat");
128
    if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages' || $pdfformat eq 'pdfformat::layout3pagesfr'
128
    if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages' || $pdfformat eq 'pdfformat::layout3pagesfr'
129
        || $pdfformat eq 'pdfformat::layout2pagesde'){
129
        || $pdfformat eq 'pdfformat::layout2pagesde'){
130
	eval {
130
        eval {
131
        eval "require $pdfformat";
131
            my $pdfformatfile = './' . ($pdfformat =~ s,::,/,gr) . '.pm';
132
	    import $pdfformat;
132
            require $pdfformatfile;
133
	};
133
            import $pdfformat;
134
	if ($@){
134
        };
135
	}
135
        if ($@){
136
            warn $@;
137
        }
136
    }
138
    }
137
    else {
139
    else {
138
	print $input->header;  
140
        print $input->header;
139
	print $input->start_html;  # FIXME Should do a nicer page
141
        print $input->start_html;  # FIXME Should do a nicer page
140
	print "<h1>Invalid PDF Format set</h1>";
142
        print "<h1>Invalid PDF Format set</h1>";
141
	print "Please go to the systempreferences and set a valid pdfformat";
143
        print "Please go to the systempreferences and set a valid pdfformat";
142
	exit;
144
        exit;
143
    }
145
    }
144
    
146
145
    my $basketgroup = GetBasketgroup($basketgroupid);
147
    my $basketgroup = GetBasketgroup($basketgroupid);
146
    my $bookseller = Koha::Acquisition::Booksellers->find( $basketgroup->{booksellerid} );
148
    my $bookseller = Koha::Acquisition::Booksellers->find( $basketgroup->{booksellerid} );
147
    my $baskets = GetBasketsByBasketgroup($basketgroupid);
149
    my $baskets = GetBasketsByBasketgroup($basketgroupid);
148
    
150
149
    my %orders;
151
    my %orders;
150
    for my $basket (@$baskets) {
152
    for my $basket (@$baskets) {
151
        my @ba_orders;
153
        my @ba_orders;
Lines 212-218 sub printbasketgrouppdf{ Link Here
212
    );
214
    );
213
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed";
215
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed";
214
    print $pdf;
216
    print $pdf;
215
216
}
217
}
217
218
218
sub generate_edifact_orders {
219
sub generate_edifact_orders {
Lines 226-295 sub generate_edifact_orders { Link Here
226
    return;
227
    return;
227
}
228
}
228
229
229
my $op = $input->param('op') || 'display';
230
# possible values of $op :
230
# possible values of $op :
231
# - add : adds a new basketgroup, or edit an open basketgroup, or display a closed basketgroup
232
# - mod_basket : modify an individual basket of the basketgroup
231
# - mod_basket : modify an individual basket of the basketgroup
233
# - closeandprint : close and print an closed basketgroup in pdf. called by clicking on "Close and print" button in closed basketgroups list
232
# - closeandprint : close and print an closed basketgroup in pdf. called by
234
# - print : print a closed basketgroup. called by clicking on "Print" button in closed basketgroups list
233
#   clicking on "Close and print" button in closed basketgroups list
234
# - print : print a closed basketgroup. called by clicking on "Print" button in
235
#   closed basketgroups list
235
# - ediprint : generate edi order messages for the baskets in the group
236
# - ediprint : generate edi order messages for the baskets in the group
236
# - export : export in CSV a closed basketgroup. called by clicking on "Export" button in closed basketgroups list
237
# - export : export in CSV a closed basketgroup. called by clicking on "Export"
237
# - delete : delete an open basketgroup. called by clicking on "Delete" button in open basketgroups list
238
#   button in closed basketgroups list
238
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button in closed basketgroup list
239
# - delete : delete an open basketgroup. called by clicking on "Delete" button
239
# - attachbasket : save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
240
#   in open basketgroups list
240
# - display : display the list of all basketgroups for a vendor
241
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button
242
#   in closed basketgroup list
243
# - attachbasket : save a modified basketgroup, or creates a new basketgroup
244
#   when a basket is closed. called from basket page
245
my $op = $input->param('op');
241
my $booksellerid = $input->param('booksellerid');
246
my $booksellerid = $input->param('booksellerid');
242
$template->param(booksellerid => $booksellerid);
243
247
244
if ( $op eq "add" ) {
248
if ($op eq 'mod_basket') {
245
#
246
# if no param('basketgroupid') is not defined, adds a new basketgroup
247
# else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid
248
# the template will know if basketgroup must be displayed or edited, depending on the value of closed key
249
#
250
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
251
    my $basketgroupid = $input->param('basketgroupid');
252
    my $billingplace;
253
    my $deliveryplace;
254
    my $freedeliveryplace;
255
    if ( $basketgroupid ) {
256
        # Get the selected baskets in the basketgroup to display them
257
        my $selecteds = GetBasketsByBasketgroup($basketgroupid);
258
        foreach my $basket(@{$selecteds}){
259
            $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
260
        }
261
        $template->param(basketgroupid => $basketgroupid,
262
                         selectedbaskets => $selecteds);
263
264
        # Get general informations about the basket group to prefill the form
265
        my $basketgroup = GetBasketgroup($basketgroupid);
266
        $template->param(
267
            name            => $basketgroup->{name},
268
            deliverycomment => $basketgroup->{deliverycomment},
269
            freedeliveryplace => $basketgroup->{freedeliveryplace},
270
        );
271
        $billingplace  = $basketgroup->{billingplace};
272
        $deliveryplace = $basketgroup->{deliveryplace};
273
        $freedeliveryplace = $basketgroup->{freedeliveryplace};
274
        $template->param( closedbg => ($basketgroup ->{'closed'}) ? 1 : 0);
275
    } else {
276
        $template->param( closedbg => 0);
277
    }
278
    # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
279
    my $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set
280
    $billingplace  = $billingplace  || $patron->branchcode;
281
    $deliveryplace = $deliveryplace || $patron->branchcode;
282
283
    $template->param( billingplace => $billingplace );
284
    $template->param( deliveryplace => $deliveryplace );
285
    $template->param( booksellerid => $booksellerid );
286
287
    # the template will display a unique basketgroup
288
    $template->param(grouping => 1);
289
    my $basketgroups = &GetBasketgroups($booksellerid);
290
    my $baskets = &GetBasketsByBookseller($booksellerid);
291
    displaybasketgroups($basketgroups, $bookseller, $baskets);
292
} elsif ($op eq 'mod_basket') {
293
#
249
#
294
# edit an individual basket contained in this basketgroup
250
# edit an individual basket contained in this basketgroup
295
#
251
#
Lines 330-336 if ( $op eq "add" ) { Link Here
330
#
286
#
331
    my $basketgroupid = $input->param('basketgroupid');
287
    my $basketgroupid = $input->param('basketgroupid');
332
    DelBasketgroup($basketgroupid);
288
    DelBasketgroup($basketgroupid);
333
    print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid.'&amp;listclosed=1');
289
    print $input->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid);
290
    exit;
334
}elsif ( $op eq 'reopen'){
291
}elsif ( $op eq 'reopen'){
335
#
292
#
336
# reopen a closed basketgroup
293
# reopen a closed basketgroup
Lines 338-345 if ( $op eq "add" ) { Link Here
338
    my $basketgroupid   = $input->param('basketgroupid');
295
    my $basketgroupid   = $input->param('basketgroupid');
339
    my $booksellerid    = $input->param('booksellerid');
296
    my $booksellerid    = $input->param('booksellerid');
340
    ReOpenBasketgroup($basketgroupid);
297
    ReOpenBasketgroup($basketgroupid);
341
    my $redirectpath = ((defined $input->param('mode'))&& ($input->param('mode') eq 'singlebg')) ?'/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid : '/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' .$booksellerid.'&amp;listclosed=1';
298
    my $redirectpath;
299
    my $mode = $input->param('mode');
300
    if (defined $mode && $mode eq 'singlebg') {
301
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid;
302
    } else {
303
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' .$booksellerid;
304
    }
342
    print $input->redirect($redirectpath);
305
    print $input->redirect($redirectpath);
306
    exit;
343
} elsif ( $op eq 'attachbasket') {
307
} elsif ( $op eq 'attachbasket') {
344
#
308
#
345
# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
309
# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
Lines 385-406 if ( $op eq "add" ) { Link Here
385
        };
349
        };
386
        $basketgroupid = NewBasketgroup($basketgroup);
350
        $basketgroupid = NewBasketgroup($basketgroup);
387
    }
351
    }
388
    my $redirectpath = ((defined $input->param('mode')) && ($input->param('mode') eq 'singlebg')) ?'/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid : '/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid;
352
    my $redirectpath;
389
    $redirectpath .=  "&amp;listclosed=1" if $closedbg ;
353
    my $mode = $input->param('mode');
390
    print $input->redirect($redirectpath );
354
    if (defined $mode && $mode eq 'singlebg') {
391
    
355
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid;
356
    } else {
357
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid;
358
    }
359
    print $input->redirect($redirectpath);
360
    exit;
392
} elsif ( $op eq 'ediprint') {
361
} elsif ( $op eq 'ediprint') {
393
    my $basketgroupid = $input->param('basketgroupid');
362
    my $basketgroupid = $input->param('basketgroupid');
394
    generate_edifact_orders( $basketgroupid );
363
    generate_edifact_orders( $basketgroupid );
395
    exit;
364
    exit;
396
}else{
365
}
397
# no param : display the list of all basketgroups for a given vendor
398
    my $basketgroups = &GetBasketgroups($booksellerid);
399
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
400
    my $baskets = &GetBasketsByBookseller($booksellerid);
401
366
402
    displaybasketgroups($basketgroups, $bookseller, $baskets);
367
# if no param('basketgroupid') is not defined, adds a new basketgroup else, edit
368
# (if it is open) or display (if it is close) the basketgroup basketgroupid the
369
# template will know if basketgroup must be displayed or edited, depending on
370
# the value of closed key
371
372
my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
373
my $basketgroupid = $input->param('basketgroupid');
374
my $billingplace;
375
my $deliveryplace;
376
my $freedeliveryplace;
377
if ( $basketgroupid ) {
378
    # Get the selected baskets in the basketgroup to display them
379
    my $selecteds = GetBasketsByBasketgroup($basketgroupid);
380
    foreach my $basket(@{$selecteds}){
381
        $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
382
    }
383
    $template->param(basketgroupid => $basketgroupid,
384
                     selectedbaskets => $selecteds);
385
386
    # Get general informations about the basket group to prefill the form
387
    my $basketgroup = GetBasketgroup($basketgroupid);
388
    $template->param(
389
        name => $basketgroup->{name},
390
        billingplace => $basketgroup->{billingplace},
391
        deliveryplace => $basketgroup->{deliveryplace},
392
        deliverycomment => $basketgroup->{deliverycomment},
393
        freedeliveryplace => $basketgroup->{freedeliveryplace},
394
        closedbg => $basketgroup->{closed} ? 1 : 0
395
    );
396
} else {
397
    $template->param( closedbg => 0);
403
}
398
}
404
$template->param(listclosed => ((defined $input->param('listclosed')) && ($input->param('listclosed') eq '1'))? 1:0 );
399
# determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
405
#prolly won't use all these, maybe just use print, the rest can be done inside validate
400
my $borrower = Koha::Patrons->find( $loggedinuser );
401
$billingplace  = $billingplace  || $borrower->branchcode;
402
$deliveryplace = $deliveryplace || $borrower->branchcode;
403
404
$template->param( booksellerid => $booksellerid );
405
406
# the template will display a unique basketgroup
407
my $basketgroups = &GetBasketgroups($booksellerid);
408
my $baskets = &GetBasketsByBookseller($booksellerid);
409
displaybasketgroups($basketgroups, $bookseller, $baskets, $template);
410
406
output_html_with_http_headers $input, $cookie, $template->output;
411
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/basketgroups.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use CGI qw(-utf8);
21
22
use C4::Auth;
23
use C4::Output;
24
25
use Koha::Acquisition::Basketgroups;
26
use Koha::Acquisition::Booksellers;
27
28
my $cgi = new CGI;
29
30
my ($template, $loggedinuser, $cookie) = get_template_and_user({
31
    template_name => 'acqui/basketgroups.tt',
32
    query => $cgi,
33
    type => 'intranet',
34
    flagsrequired => { acquisition => 'group_manage' },
35
});
36
37
my $booksellerid = $cgi->param('booksellerid');
38
39
my $params = {};
40
if ($booksellerid) {
41
    $params->{booksellerid} = $booksellerid;
42
    my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
43
    $template->param(bookseller => $bookseller);
44
}
45
46
my @basketgroups = Koha::Acquisition::Basketgroups->search($params);
47
48
$template->param(
49
    basketgroups => \@basketgroups,
50
);
51
52
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc (+3 lines)
Lines 3-8 Link Here
3
        <h5>Acquisitions</h5>
3
        <h5>Acquisitions</h5>
4
        <ul>
4
        <ul>
5
            <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions home</a></li>
5
            <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions home</a></li>
6
            [% IF ( CAN_user_acquisition_group_manage ) %]
7
              <li><a href="/cgi-bin/koha/acqui/basketgroups.pl">Basket groups</a></li>
8
            [% END %]
6
            [% IF ( CAN_user_acquisition_order_receive ) %]<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>[% END %]
9
            [% IF ( CAN_user_acquisition_order_receive ) %]<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>[% END %]
7
            [% IF ( suggestion && CAN_user_acquisition_suggestions_manage ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
10
            [% IF ( suggestion && CAN_user_acquisition_suggestions_manage ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
8
            <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
11
            <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc (+2 lines)
Lines 24-29 Link Here
24
    var MSG_DT_SEARCH = _("Search:");
24
    var MSG_DT_SEARCH = _("Search:");
25
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
25
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
26
    var MSG_DT_ALL = _("All");
26
    var MSG_DT_ALL = _("All");
27
    var MSG_DT_SORT_ASC = _(": activate to sort column ascending");
28
    var MSG_DT_SORT_DESC = _(": activate to sort column descending");
27
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
29
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
28
    var MSG_DT_COPY_TITLE = _("Copy to clipboard");
30
    var MSG_DT_COPY_TITLE = _("Copy to clipboard");
29
    var MSG_DT_COPY_KEYS = _("Press ctrl or ⌘ + C to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.");
31
    var MSG_DT_COPY_KEYS = _("Press ctrl or ⌘ + C to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.");
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc (-1 / +1 lines)
Lines 2-8 Link Here
2
<div id="menu">
2
<div id="menu">
3
    <ul>
3
    <ul>
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | html %]">Baskets</a></li>[% END %]
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | html %]">Baskets</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | html %]">Basket groups</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid | html %]">Basket groups</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | html %]">Contracts</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | html %]">Contracts</a></li>[% END %]
7
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid | html %]&amp;op=do_search">Invoices</a></li>
7
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid | html %]&amp;op=do_search">Invoices</a></li>
8
        [% IF ( CAN_user_acquisition_order_manage ) %][% IF ( basketno ) %]
8
        [% IF ( CAN_user_acquisition_order_manage ) %][% IF ( basketno ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt (-119 / +13 lines)
Lines 2-9 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE Price %]
4
[% USE Price %]
5
[% USE KohaDates %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Basket grouping for [% booksellername | html %]</title>
7
[% IF booksellerid %]
8
  <title>Koha &rsaquo; Basket groups for [% booksellername |html %]</title>
9
[% ELSE %]
10
  <title>Koha &rsaquo; Basket groups</title>
11
[% END %]
7
[% Asset.css("css/datatables.css") | $raw %]
12
[% Asset.css("css/datatables.css") | $raw %]
8
[% INCLUDE 'doc-head-close.inc' %]
13
[% INCLUDE 'doc-head-close.inc' %]
9
[% INCLUDE 'datatables.inc' %]
14
[% INCLUDE 'datatables.inc' %]
Lines 12-18 Link Here
12
[% Asset.js("lib/yui/container/container_core-min.js") | $raw %]
17
[% Asset.js("lib/yui/container/container_core-min.js") | $raw %]
13
[% Asset.js("lib/yui/menu/menu-min.js") | $raw %]
18
[% Asset.js("lib/yui/menu/menu-min.js") | $raw %]
14
[% Asset.js("js/basketgroup.js") | $raw %]
19
[% Asset.js("js/basketgroup.js") | $raw %]
15
[% IF ( grouping ) %]
16
[% Asset.js("lib/yui/yahoo-dom-event/yahoo-dom-event.js") | $raw %]
20
[% Asset.js("lib/yui/yahoo-dom-event/yahoo-dom-event.js") | $raw %]
17
[% Asset.js("lib/yui/animation/animation-min.js") | $raw %]
21
[% Asset.js("lib/yui/animation/animation-min.js") | $raw %]
18
[% Asset.js("lib/yui/dragdrop/dragdrop-min.js") | $raw %]
22
[% Asset.js("lib/yui/dragdrop/dragdrop-min.js") | $raw %]
Lines 86-92 fieldset.various li { Link Here
86
}
90
}
87
91
88
</style>
92
</style>
89
 [% END %]
90
<script type="text/javascript">
93
<script type="text/javascript">
91
//<![CDATA[
94
//<![CDATA[
92
	YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
95
	YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
Lines 107-126 function submitForm(form) { Link Here
107
    }
110
    }
108
}
111
}
109
112
110
 $(document).ready(function() {
111
    $("#basket_groups").tabs();
112
113
    $("table").dataTable($.extend(true, {}, dataTablesDefaults, {
114
        "aoColumnDefs": [
115
            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
116
        ],
117
        "bAutoWidth": false,
118
        "sPaginationType": "four_button"
119
    } ));
120
121
 });
122
123
124
//]]>
113
//]]>
125
</script>
114
</script>
126
</head>
115
</head>
Lines 129-139 function submitForm(form) { Link Here
129
[% INCLUDE 'acquisitions-search.inc' %]
118
[% INCLUDE 'acquisitions-search.inc' %]
130
119
131
<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;
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;
132
[% IF ( grouping ) %]
121
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% booksellername | html %]</a>
133
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% booksellername | html %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | html %]">Basket grouping</a> &rsaquo; Add basket group for [% booksellername | html %]</div>
122
    &rsaquo;
134
[% ELSE %]
123
    <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | html %]">Basket groups</a>
135
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% booksellername | html %]</a> &rsaquo; Basket grouping</div>
124
    &rsaquo;
136
[% END %]
125
    Add basket group for [% booksellername | html %]
126
</div>
137
127
138
128
139
<div class="main container-fluid">
129
<div class="main container-fluid">
Lines 141-147 function submitForm(form) { Link Here
141
        <div class="col-sm-10 col-sm-push-2">
131
        <div class="col-sm-10 col-sm-push-2">
142
            <main>
132
            <main>
143
133
144
                [% IF ( grouping ) %]
145
                    [% IF (closedbg) %]
134
                    [% IF (closedbg) %]
146
                        <div id="toolbar" class="btn-toolbar">
135
                        <div id="toolbar" class="btn-toolbar">
147
                            <div class="btn-group"><a href="[% script_name | html %]?op=reopen&amp;basketgroupid=[% basketgroupid | html %]&amp;booksellerid=[% booksellerid | html %]&amp;mode=singlebg" class="btn btn-default btn-sm" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div>
136
                            <div class="btn-group"><a href="[% script_name | html %]?op=reopen&amp;basketgroupid=[% basketgroupid | html %]&amp;booksellerid=[% booksellerid | html %]&amp;mode=singlebg" class="btn btn-default btn-sm" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div>
Lines 291-397 function submitForm(form) { Link Here
291
                            </form>
280
                            </form>
292
                        </div>
281
                        </div>
293
                    </div>
282
                    </div>
294
                [% ELSE %]
295
                    <div id="toolbar" class="btn-toolbar">
296
                        <div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% booksellerid | html %]" class="btn btn-default btn-sm" id="newbasketgroup"><i class="fa fa-plus"></i> New basket group</a></div>
297
                    </div>
298
                    <h1>Basket grouping for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% booksellername | html %]</a></h1>
299
                    <div id="basket_groups" class="toptabs">
300
                        <ul class="ui-tabs-nav">
301
                            [% UNLESS ( listclosed) %]<li class="ui-tabs-active"><a href="#opened">Open</a></li>
302
                            [% ELSE%]<li><a href="#opened">Open</a></li>[% END %]
303
                            [% IF ( listclosed) %]<li class="ui-tabs-active"><a href="#closed">Closed</a></li>
304
                            [% ELSE %]<li><a href="#closed">Closed</a></li>[% END %]
305
                        </ul>
306
                        <div id="opened">
307
                            <table id="basket_group_opened">
308
                                <thead>
309
                                    <tr>
310
                                        <th>Name</th>
311
                                        <th>Number</th>
312
                                        <th>Billing place</th>
313
                                        <th>Delivery place</th>
314
                                        <th>Number of baskets</th>
315
                                        <th>Action</th>
316
                                    </tr>
317
                                </thead>
318
                                <tbody>
319
                                    [% FOREACH basketgroup IN basketgroups %]
320
                                        [% UNLESS ( basketgroup.closed ) %]
321
                                            <tr>
322
                                                <td>[% IF ( basketgroup.name ) %]
323
                                                    [% basketgroup.name | html %]
324
                                                    [% ELSE %]
325
                                                        Basket group no. [% basketgroup.id | html %]
326
                                                    [% END %]
327
                                                </td>
328
                                                <td>[% basketgroup.id | html %]</td>
329
                                                <td>[% Branches.GetName( basketgroup.billingplace ) | html %]</td>
330
                                                <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) | html %][% END %]</td>
331
                                                <td>[% basketgroup.basketsqty | html %]</td>
332
                                                <td>
333
                                                    <input type="button" onclick="closeandprint('[% basketgroup.id | html %]');" value="Close and export as PDF" />
334
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="add" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Edit" /></form>
335
                                                    [% UNLESS basketgroup.basketsqty %]
336
                                                        <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="delete" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Delete" /></form>
337
                                                    [% END %]
338
                                                </td>
339
                                            </tr>
340
                                        [% END %]
341
                                    [% END %]
342
                                </tbody>
343
                            </table>
344
                        </div>
345
                        <div id="closed">
346
                            <table id="basket_group_closed">
347
                                <thead>
348
                                    <tr>
349
                                        <th>Name</th>
350
                                        <th>Number</th>
351
                                        <th>Billing place</th>
352
                                        <th>Delivery place</th>
353
                                        <th>Number of baskets</th>
354
                                        <th>Action</th>
355
                                    </tr>
356
                                </thead>
357
                                <tbody>
358
                                    [% FOREACH basketgroup IN basketgroups %]
359
                                        [% IF ( basketgroup.closed ) %]
360
                                            <tr>
361
                                                <td>
362
                                                    [% IF ( basketgroup.name ) %]
363
                                                        [% basketgroup.name | html %]
364
                                                        [% ELSE %]
365
                                                            Basket group no. [% basketgroup.id | html %]
366
                                                        [% END %]
367
                                                </td>
368
                                                <td>[% basketgroup.id | html %]</td>
369
                                                <td>[% Branches.GetName( basketgroup.billingplace ) | html %]</td>
370
                                                <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) | html %][% END %]</td>
371
                                                <td>[% basketgroup.basketsqty | html %]</td>
372
                                                <td>
373
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="add" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="View" /></form>
374
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="reopen" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Reopen" /></form>
375
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="print" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Export as PDF" /></form>
376
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="export" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Export as CSV" /></form>
377
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="ediprint" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Generate EDIFACT order" /></form>
378
                                                </td>
379
                                            </tr>
380
                                        [% END %]
381
                                    [% END %]
382
                                </tbody>
383
                            </table>
384
                        </div>
385
                    </div>
386
                [% END %]
387
            </main>
283
            </main>
388
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
284
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
389
285
390
        <div class="col-sm-2 col-sm-pull-10">
286
        <div class="col-sm-2 col-sm-pull-10">
391
            <aside>
287
            <aside>
392
                [% IF ( booksellerid ) %]
288
                [% INCLUDE 'vendor-menu.inc' %]
393
                    [% INCLUDE 'vendor-menu.inc' %]
394
                [% END %]
395
                [% INCLUDE 'acquisitions-menu.inc' %]
289
                [% INCLUDE 'acquisitions-menu.inc' %]
396
            </aside>
290
            </aside>
397
        </div>
291
        </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt (+163 lines)
Line 0 Link Here
1
[% USE Asset %]
2
[% USE Branches %]
3
[% USE KohaDates %]
4
5
[% INCLUDE 'doc-head-open.inc' %]
6
    [% IF bookseller %]
7
        <title>Koha &rsaquo; Basket groups for [% bookseller.name |html %]</title>
8
    [% ELSE %]
9
        <title>Koha &rsaquo; Basket groups</title>
10
    [% END %]
11
12
    [% 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>
61
<body id="acq_basketgroup" class="acq">
62
    [% INCLUDE 'header.inc' %]
63
    [% INCLUDE 'acquisitions-search.inc' %]
64
65
    <div id="breadcrumbs">
66
        <a href="/cgi-bin/koha/mainpage.pl">Home</a>
67
        &rsaquo;
68
        <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
69
        &rsaquo;
70
        [% IF (bookseller) %]
71
            <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name |html %]</a>
72
            &rsaquo;
73
        [% END %]
74
        Basket groups
75
    </div>
76
77
    <div id="doc3" class="yui-t2">
78
        <div id="bd">
79
            <div id="yui-main">
80
                <div class="yui-b">
81
                    [% IF bookseller %]
82
                        <div id="toolbar" class="btn-toolbar">
83
                            <div class="btn-group">
84
                                <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% bookseller.id %]" class="btn btn-default btn-sm" id="newbasketgroup"><i class="fa fa-plus"></i> New basket group</a>
85
                            </div>
86
                        </div>
87
88
                        <h1>Basket groups for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a></h1>
89
                    [% END %]
90
91
                    [% IF basketgroups.size > 0 %]
92
                        <table id="basketgroups-table" class="group">
93
                            <thead>
94
                                <tr>
95
                                    <th>Name</th>
96
                                    <th>Vendor</th>
97
                                    <th>Billing place</th>
98
                                    <th>Delivery place</th>
99
                                    <th>No. of baskets</th>
100
                                    <th>No. of ordered titles</th>
101
                                    <th>No. of received titles</th>
102
                                    <th>Date closed</th>
103
                                    <th>Action</th>
104
                                </tr>
105
                            </thead>
106
                            <tbody>
107
                                [% FOREACH basketgroup IN basketgroups %]
108
                                    <tr>
109
                                        <td>
110
                                            [% IF ( basketgroup.name ) %]
111
                                                [% basketgroup.name %]
112
                                            [% ELSE %]
113
                                                Basket group no. [% basketgroup.id %]
114
                                            [% END %]
115
                                        </td>
116
                                        <td>[% basketgroup.bookseller.name %]</td>
117
                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
118
                                        <td>
119
                                            [% IF (basketgroup.freedeliveryplace) %]
120
                                                [% basketgroup.freedeliveryplace %]
121
                                            [% ELSE %]
122
                                                [% Branches.GetName(basketgroup.deliveryplace) %]
123
                                            [% END %]
124
                                        </td>
125
                                        <td>[% basketgroup.baskets_count %]</td>
126
                                        <td>[% basketgroup.ordered_titles_count %]</td>
127
                                        <td>[% basketgroup.received_titles_count %]</td>
128
                                        <td>[% basketgroup.closeddate | $KohaDates %]</td>
129
                                        <td>
130
                                            <div class="dropdown">
131
                                            <a class="btn btn-default btn-xs dropdown-toggle" id="actions-[% basketgroup.id %]" role="button" data-toggle="dropdown">Actions <b class="caret"></b></a>
132
                                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="actions-[% basketgroup.id %]">
133
                                            [% IF basketgroup.closeddate %]
134
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-eye"></i> View</a></li>
135
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=reopen&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-folder-open"></i> Reopen</a></li>
136
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=print&basketgroupid=[% basketgroup.id %]"><i class="fa fa-print"></i> Export as PDF</a></li>
137
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=export&basketgroupid=[% basketgroup.id %]"><i class="fa fa-file-text"></i> Export as CSV</a></li>
138
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=ediprint&baskegroupid=[% basketgroup.id %]">Generate EDIFACT order</a></li>
139
                                            [% ELSE %]
140
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-pencil"></i> Edit</a></li>
141
                                                <li><a class="closeandprint" href="/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=[% basketgroup.id %]"><i class="fa fa-print"></i> Close and export as PDF</a></li>
142
                                                [% UNLESS basketgroup.baskets_count %]
143
                                                    <li><a class="delete" href="/cgi-bin/koha/acqui/basketgroup.pl?op=delete&booksellerid=[% basketgroup.booksellerid %]&basketgroupid=[% basketgroup.id %]"><i class="fa fa-trash"></i> Delete</a></li>
144
                                                [% END %]
145
                                            [% END %]
146
                                            </ul>
147
                                            </div>
148
                                        </td>
149
                                    </tr>
150
                                [% END %]
151
                            </tbody>
152
                        </table>
153
                    [% END %]
154
                </div>
155
            </div>
156
            <div class="yui-b">
157
                [% IF bookseller %]
158
                    [% INCLUDE 'vendor-menu.inc' booksellerid = bookseller.id %]
159
                [% END %]
160
                [% INCLUDE 'acquisitions-menu.inc' %]
161
            </div>
162
        </div>
163
    [% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/basketgroup.js (-8 lines)
Lines 233-246 function closebasketgroup(bgid) { Link Here
233
    div.appendChild(unclosegroup);
233
    div.appendChild(unclosegroup);
234
}
234
}
235
235
236
function closeandprint(bg){
237
    if(document.location = '/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&amp;basketgroupid=' + bg ){
238
        setTimeout("window.location.reload();",3000);
239
    }else{
240
        alert(MSG_FILE_DOWNLOAD_ERROR);
241
    }
242
}
243
244
//function that lets the user unclose a basketgroup
236
//function that lets the user unclose a basketgroup
245
//as long as they haven't submitted the changes to the page.
237
//as long as they haven't submitted the changes to the page.
246
function unclosegroup(bgid){
238
function unclosegroup(bgid){
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-25 / +71 lines)
Lines 1-42 Link Here
1
// These default options are for translation but can be used
1
// These default options are for translation but can be used
2
// for any other datatables settings
2
// for any other datatables settings
3
// MSG_DT_* variables comes from datatables.inc
3
// MSG_DT_* variables comes from datatables.inc
4
// To use it, write:
4
// Since version 1.10, DataTables has a new API while still providing the older
5
//  $("#table_id").dataTable($.extend(true, {}, dataTableDefaults, {
5
// one.
6
//      // other settings
6
// You can use the new API with these defaults by writing:
7
//  } ) );
7
//
8
//   $('#table_id').kohaDataTable({ ... });
9
//
10
// To use the older API, write:
11
//
12
//   $("#table_id").dataTable($.extend(true, {}, dataTablesDefaults, { ... });
13
14
var DataTableDefaults = {
15
    "language": {
16
        "emptyTable":     window.MSG_DT_EMPTY_TABLE || "No data available in table",
17
        "info":           window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries",
18
        "infoEmpty":      window.MSG_DT_INFO_EMPTY || "No entries to show",
19
        "infoFiltered":   window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)",
20
        "lengthMenu":     window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries",
21
        "loadingRecords": window.MSG_DT_LOADING_RECORDS || "Loading...",
22
        "processing":     window.MSG_DT_PROCESSING || "Processing...",
23
        "search":         window.MSG_DT_SEARCH || "Search:",
24
        "zeroRecords":    window.MSG_DT_ZERO_RECORDS || "No matching records found",
25
        "paginate": {
26
            "first":      window.MSG_DT_FIRST || "First",
27
            "last":       window.MSG_DT_LAST || "Last",
28
            "next":       window.MSG_DT_NEXT || "Next",
29
            "previous":   window.MSG_DT_PREVIOUS || "Previous"
30
        },
31
        "aria": {
32
            "sortAscending":  window.MSG_DT_SORT_ASC || ": activate to sort column ascending",
33
            "sortDescending": window.MSG_DT_SORT_DESC || ": activate to sort column descending"
34
        },
35
        "buttons": {
36
            "copyTitle"     : window.MSG_DT_COPY_TITLE || "Copy to clipboard",
37
            "copyKeys"      : window.MSG_DT_COPY_KEYS || "Press <i>ctrl</i> or <i>⌘</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.",
38
            "copySuccess": {
39
                "_": window.MSG_DT_COPY_SUCCESS_X || "Copied %d rows to clipboard",
40
                "1": window.MSG_DT_COPY_SUCCESS_ONE || "Copied one row to clipboard"
41
            }
42
        }
43
    },
44
    "dom": '<"top pager"ilpf>tr<"bottom pager"ip>',
45
    "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
46
    "pageLength": 20
47
};
48
8
var dataTablesDefaults = {
49
var dataTablesDefaults = {
9
    "oLanguage": {
50
    "oLanguage": {
10
        "oPaginate": {
51
        "oPaginate": {
11
            "sFirst"    : window.MSG_DT_FIRST || "First",
52
            "sFirst"    : DataTableDefaults.language.paginate.first,
12
            "sLast"     : window.MSG_DT_LAST || "Last",
53
            "sLast"     : DataTableDefaults.language.paginate.last,
13
            "sNext"     : window.MSG_DT_NEXT || "Next",
54
            "sNext"     : DataTableDefaults.language.paginate.next,
14
            "sPrevious" : window.MSG_DT_PREVIOUS || "Previous"
55
            "sPrevious" : DataTableDefaults.language.paginate.previous,
15
        },
56
        },
16
        "sEmptyTable"       : window.MSG_DT_EMPTY_TABLE || "No data available in table",
57
        "sEmptyTable"       : DataTableDefaults.language.emptyTable,
17
        "sInfo"             : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries",
58
        "sInfo"             : DataTableDefaults.language.info,
18
        "sInfoEmpty"        : window.MSG_DT_INFO_EMPTY || "No entries to show",
59
        "sInfoEmpty"        : DataTableDefaults.language.infoEmpty,
19
        "sInfoFiltered"     : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)",
60
        "sInfoFiltered"     : DataTableDefaults.language.infoFiltered,
20
        "sLengthMenu"       : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries",
61
        "sLengthMenu"       : DataTableDefaults.language.lengthMenu,
21
        "sLoadingRecords"   : window.MSG_DT_LOADING_RECORDS || "Loading...",
62
        "sLoadingRecords"   : DataTableDefaults.language.loadingRecords,
22
        "sProcessing"       : window.MSG_DT_PROCESSING || "Processing...",
63
        "sProcessing"       : DataTableDefaults.language.processing,
23
        "sSearch"           : window.MSG_DT_SEARCH || "Search:",
64
        "sSearch"           : DataTableDefaults.language.search,
24
        "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found",
65
        "sZeroRecords"      : DataTableDefaults.language.zeroRecords,
25
        buttons: {
66
        "buttons": {
26
            "copyTitle"     : window.MSG_DT_COPY_TITLE || "Copy to clipboard",
67
            "copyTitle"     : DataTableDefaults.language.buttons.copyTitle,
27
            "copyKeys"      : window.MSG_DT_COPY_KEYS || "Press <i>ctrl</i> or <i>⌘</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.",
68
            "copyKeys"      : DataTableDefaults.language.buttons.copyKeys,
28
            "copySuccess": {
69
            "copySuccess": {
29
                _: window.MSG_DT_COPY_SUCCESS_X || "Copied %d rows to clipboard",
70
                "_": DataTableDefaults.language.buttons.copySuccess["_"],
30
                1: window.MSG_DT_COPY_SUCCESS_ONE || "Copied one row to clipboard"
71
                "1": DataTableDefaults.language.buttons.copySuccess["1"]
31
            }
72
            }
32
        }
73
        }
33
    },
74
    },
34
    "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
75
    "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
35
    "buttons": [],
76
    "buttons": [],
36
    "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
77
    "aLengthMenu": DataTableDefaults.lengthMenu,
37
    "iDisplayLength": 20
78
    "iDisplayLength": DataTableDefaults.pageLength
38
};
79
};
39
80
81
(function($) {
82
    $.fn.kohaDataTable = function(options) {
83
        return this.DataTable($.extend(true, {}, DataTableDefaults, options));
84
    };
85
})(jQuery);
86
40
87
41
// Return an array of string containing the values of a particular column
88
// Return an array of string containing the values of a particular column
42
$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
89
$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
43
- 

Return to bug 11708