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

(-)a/C4/Acquisition.pm (-2 / +6 lines)
Lines 1512-1518 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
        $new_ordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber; # TODO What if the store fails?
1515
        my @columns = Koha::Acquisition::Orders->columns;
1516
        my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
1517
        $new_ordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
1516
1518
1517
        if ($received_items) {
1519
        if ($received_items) {
1518
            foreach my $itemnumber (@$received_items) {
1520
            foreach my $itemnumber (@$received_items) {
Lines 2010-2016 sub TransferOrder { Link Here
2010
    delete $order->{parent_ordernumber};
2012
    delete $order->{parent_ordernumber};
2011
    $order->{'basketno'} = $basketno;
2013
    $order->{'basketno'} = $basketno;
2012
2014
2013
    my $newordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber;
2015
    my @columns = Koha::Acquisition::Orders->columns;
2016
    my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
2017
    my $newordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
2014
2018
2015
    $query = q{
2019
    $query = q{
2016
        UPDATE aqorders_items
2020
        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 233-252 sub generate_edifact_orders { Link Here
233
    return;
234
    return;
234
}
235
}
235
236
236
my $op = $input->param('op') || 'display';
237
# possible values of $op :
237
# possible values of $op :
238
# - add : adds a new basketgroup, or edit an open basketgroup, or display a closed basketgroup
239
# - mod_basket : modify an individual basket of the basketgroup
238
# - mod_basket : modify an individual basket of the basketgroup
240
# - closeandprint : close and print an closed basketgroup in pdf. called by clicking on "Close and print" button in closed basketgroups list
239
# - closeandprint : close and print an closed basketgroup in pdf. called by
241
# - print : print a closed basketgroup. called by clicking on "Print" button in closed basketgroups list
240
#   clicking on "Close and print" button in closed basketgroups list
241
# - print : print a closed basketgroup. called by clicking on "Print" button in
242
#   closed basketgroups list
242
# - ediprint : generate edi order messages for the baskets in the group
243
# - ediprint : generate edi order messages for the baskets in the group
243
# - export : export in CSV a closed basketgroup. called by clicking on "Export" button in closed basketgroups list
244
# - export : export in CSV a closed basketgroup. called by clicking on "Export"
244
# - delete : delete an open basketgroup. called by clicking on "Delete" button in open basketgroups list
245
#   button in closed basketgroups list
245
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button in closed basketgroup list
246
# - delete : delete an open basketgroup. called by clicking on "Delete" button
246
# - attachbasket : save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
247
#   in open basketgroups list
247
# - display : display the list of all basketgroups for a vendor
248
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button
249
#   in closed basketgroup list
250
# - attachbasket : save a modified basketgroup, or creates a new basketgroup
251
#   when a basket is closed. called from basket page
252
my $op = $input->param('op');
248
my $booksellerid = $input->param('booksellerid');
253
my $booksellerid = $input->param('booksellerid');
249
$template->param(booksellerid => $booksellerid);
250
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
254
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
251
255
252
my $schema = Koha::Database->new()->schema();
256
my $schema = Koha::Database->new()->schema();
Lines 254-308 my $rs = $schema->resultset('VendorEdiAccount')->search( Link Here
254
    { vendor_id => $booksellerid, } );
258
    { vendor_id => $booksellerid, } );
255
$template->param( ediaccount => ($rs->count > 0));
259
$template->param( ediaccount => ($rs->count > 0));
256
260
257
if ( $op eq "add" ) {
261
if ($op eq 'mod_basket') {
258
#
259
# if no param('basketgroupid') is not defined, adds a new basketgroup
260
# else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid
261
# the template will know if basketgroup must be displayed or edited, depending on the value of closed key
262
#
263
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
264
    my $basketgroupid = $input->param('basketgroupid');
265
    my $billingplace;
266
    my $deliveryplace;
267
    my $freedeliveryplace;
268
    if ( $basketgroupid ) {
269
        # Get the selected baskets in the basketgroup to display them
270
        my $selecteds = GetBasketsByBasketgroup($basketgroupid);
271
        foreach my $basket(@{$selecteds}){
272
            $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
273
        }
274
        $template->param(basketgroupid => $basketgroupid,
275
                         selectedbaskets => $selecteds);
276
277
        # Get general informations about the basket group to prefill the form
278
        my $basketgroup = GetBasketgroup($basketgroupid);
279
        $template->param(
280
            name            => $basketgroup->{name},
281
            deliverycomment => $basketgroup->{deliverycomment},
282
            freedeliveryplace => $basketgroup->{freedeliveryplace},
283
        );
284
        $billingplace  = $basketgroup->{billingplace};
285
        $deliveryplace = $basketgroup->{deliveryplace};
286
        $freedeliveryplace = $basketgroup->{freedeliveryplace};
287
        $template->param( closedbg => ($basketgroup ->{'closed'}) ? 1 : 0);
288
    } else {
289
        $template->param( closedbg => 0);
290
    }
291
    # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
292
    my $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set
293
    $billingplace  = $billingplace  || $patron->branchcode;
294
    $deliveryplace = $deliveryplace || $patron->branchcode;
295
296
    $template->param( billingplace => $billingplace );
297
    $template->param( deliveryplace => $deliveryplace );
298
    $template->param( booksellerid => $booksellerid );
299
300
    # the template will display a unique basketgroup
301
    $template->param(grouping => 1);
302
    my $basketgroups = &GetBasketgroups($booksellerid);
303
    my $baskets = &GetBasketsByBookseller($booksellerid);
304
    displaybasketgroups($basketgroups, $bookseller, $baskets);
305
} elsif ($op eq 'mod_basket') {
306
#
262
#
307
# edit an individual basket contained in this basketgroup
263
# edit an individual basket contained in this basketgroup
308
#
264
#
Lines 343-349 if ( $op eq "add" ) { Link Here
343
#
299
#
344
    my $basketgroupid = $input->param('basketgroupid');
300
    my $basketgroupid = $input->param('basketgroupid');
345
    DelBasketgroup($basketgroupid);
301
    DelBasketgroup($basketgroupid);
346
    print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid.'&amp;listclosed=1');
302
    print $input->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid);
303
    exit;
347
}elsif ( $op eq 'reopen'){
304
}elsif ( $op eq 'reopen'){
348
#
305
#
349
# reopen a closed basketgroup
306
# reopen a closed basketgroup
Lines 351-358 if ( $op eq "add" ) { Link Here
351
    my $basketgroupid   = $input->param('basketgroupid');
308
    my $basketgroupid   = $input->param('basketgroupid');
352
    my $booksellerid    = $input->param('booksellerid');
309
    my $booksellerid    = $input->param('booksellerid');
353
    ReOpenBasketgroup($basketgroupid);
310
    ReOpenBasketgroup($basketgroupid);
354
    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';
311
    my $redirectpath;
312
    my $mode = $input->param('mode');
313
    if (defined $mode && $mode eq 'singlebg') {
314
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid;
315
    } else {
316
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' .$booksellerid;
317
    }
355
    print $input->redirect($redirectpath);
318
    print $input->redirect($redirectpath);
319
    exit;
356
} elsif ( $op eq 'attachbasket') {
320
} elsif ( $op eq 'attachbasket') {
357
#
321
#
358
# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
322
# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
Lines 398-407 if ( $op eq "add" ) { Link Here
398
        };
362
        };
399
        $basketgroupid = NewBasketgroup($basketgroup);
363
        $basketgroupid = NewBasketgroup($basketgroup);
400
    }
364
    }
401
    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;
365
    my $redirectpath;
402
    $redirectpath .=  "&amp;listclosed=1" if $closedbg ;
366
    my $mode = $input->param('mode');
403
    print $input->redirect($redirectpath );
367
    if (defined $mode && $mode eq 'singlebg') {
404
    
368
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid;
369
    } else {
370
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid;
371
    }
372
    print $input->redirect($redirectpath);
373
    exit;
405
} elsif ( $op eq 'ediprint') {
374
} elsif ( $op eq 'ediprint') {
406
    my $basketgroupid = $input->param('basketgroupid');
375
    my $basketgroupid = $input->param('basketgroupid');
407
    if ($template->param( 'ediaccount' )) {
376
    if ($template->param( 'ediaccount' )) {
Lines 415-428 if ( $op eq "add" ) { Link Here
415
384
416
        displaybasketgroups($basketgroups, $bookseller, $baskets);
385
        displaybasketgroups($basketgroups, $bookseller, $baskets);
417
    }
386
    }
418
}else{
387
}
419
# no param : display the list of all basketgroups for a given vendor
420
    my $basketgroups = &GetBasketgroups($booksellerid);
421
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
422
    my $baskets = &GetBasketsByBookseller($booksellerid);
423
388
424
    displaybasketgroups($basketgroups, $bookseller, $baskets);
389
# if no param('basketgroupid') is not defined, adds a new basketgroup else, edit
390
# (if it is open) or display (if it is close) the basketgroup basketgroupid the
391
# template will know if basketgroup must be displayed or edited, depending on
392
# the value of closed key
393
394
my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
395
my $basketgroupid = $input->param('basketgroupid');
396
my $billingplace;
397
my $deliveryplace;
398
my $freedeliveryplace;
399
if ( $basketgroupid ) {
400
    # Get the selected baskets in the basketgroup to display them
401
    my $selecteds = GetBasketsByBasketgroup($basketgroupid);
402
    foreach my $basket(@{$selecteds}){
403
        $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
404
    }
405
    $template->param(basketgroupid => $basketgroupid,
406
                     selectedbaskets => $selecteds);
407
408
    # Get general informations about the basket group to prefill the form
409
    my $basketgroup = GetBasketgroup($basketgroupid);
410
    $template->param(
411
        name => $basketgroup->{name},
412
        billingplace => $basketgroup->{billingplace},
413
        deliveryplace => $basketgroup->{deliveryplace},
414
        deliverycomment => $basketgroup->{deliverycomment},
415
        freedeliveryplace => $basketgroup->{freedeliveryplace},
416
        closedbg => $basketgroup->{closed} ? 1 : 0
417
    );
418
} else {
419
    $template->param( closedbg => 0);
425
}
420
}
426
$template->param(listclosed => ((defined $input->param('listclosed')) && ($input->param('listclosed') eq '1'))? 1:0 );
421
# determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
427
#prolly won't use all these, maybe just use print, the rest can be done inside validate
422
my $borrower = Koha::Patrons->find( $loggedinuser );
423
$billingplace  = $billingplace  || $borrower->branchcode;
424
$deliveryplace = $deliveryplace || $borrower->branchcode;
425
426
$template->param( booksellerid => $booksellerid );
427
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
428
output_html_with_http_headers $input, $cookie, $template->output;
433
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 (-124 / +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 | uri %]?op=reopen&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]&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 | uri %]?op=reopen&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;mode=singlebg" class="btn btn-default btn-sm" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div>
Lines 293-404 function submitForm(form) { Link Here
293
                            </form>
282
                            </form>
294
                        </div>
283
                        </div>
295
                    </div>
284
                    </div>
296
                [% ELSE %]
297
                    <div id="toolbar" class="btn-toolbar">
298
                        <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>
299
                    </div>
300
                    <h1>Basket grouping for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a></h1>
301
                    [% IF (NoEDIMessage) %]<div><strong>No EDIFACT configuration for [% booksellername | html %]</strong></div>[% END %]
302
                    <div id="basket_groups" class="toptabs">
303
                        <ul class="ui-tabs-nav">
304
                            [% UNLESS ( listclosed) %]<li class="ui-tabs-active"><a href="#opened">Open</a></li>
305
                            [% ELSE%]<li><a href="#opened">Open</a></li>[% END %]
306
                            [% IF ( listclosed) %]<li class="ui-tabs-active"><a href="#closed">Closed</a></li>
307
                            [% ELSE %]<li><a href="#closed">Closed</a></li>[% END %]
308
                        </ul>
309
                        <div id="opened">
310
                            <table id="basket_group_opened">
311
                                <thead>
312
                                    <tr>
313
                                        <th>Name</th>
314
                                        <th>Number</th>
315
                                        <th>Billing place</th>
316
                                        <th>Delivery place</th>
317
                                        <th>Number of baskets</th>
318
                                        <th>Action</th>
319
                                    </tr>
320
                                </thead>
321
                                <tbody>
322
                                    [% FOREACH basketgroup IN basketgroups %]
323
                                        [% UNLESS ( basketgroup.closed ) %]
324
                                            <tr>
325
                                                <td>[% IF ( basketgroup.name ) %]
326
                                                    [% basketgroup.name | html %]
327
                                                    [% ELSE %]
328
                                                        Basket group no. [% basketgroup.id | html %]
329
                                                    [% END %]
330
                                                </td>
331
                                                <td>[% basketgroup.id | html %]</td>
332
                                                <td>[% Branches.GetName( basketgroup.billingplace ) | html %]</td>
333
                                                <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) | html %][% END %]</td>
334
                                                <td>[% basketgroup.basketsqty | html %]</td>
335
                                                <td>
336
                                                    <input type="button" onclick="closeandprint('[% basketgroup.id | html %]');" value="Close and export as PDF" />
337
                                                    <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>
338
                                                    [% UNLESS basketgroup.basketsqty %]
339
                                                        <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>
340
                                                    [% END %]
341
                                                </td>
342
                                            </tr>
343
                                        [% END %]
344
                                    [% END %]
345
                                </tbody>
346
                            </table>
347
                        </div>
348
                        <div id="closed">
349
                            <table id="basket_group_closed">
350
                                <thead>
351
                                    <tr>
352
                                        <th>Name</th>
353
                                        <th>Number</th>
354
                                        <th>Billing place</th>
355
                                        <th>Delivery place</th>
356
                                        <th>Number of baskets</th>
357
                                        <th>Action</th>
358
                                    </tr>
359
                                </thead>
360
                                <tbody>
361
                                    [% FOREACH basketgroup IN basketgroups %]
362
                                        [% IF ( basketgroup.closed ) %]
363
                                            <tr>
364
                                                <td>
365
                                                    [% IF ( basketgroup.name ) %]
366
                                                        [% basketgroup.name | html %]
367
                                                        [% ELSE %]
368
                                                            Basket group no. [% basketgroup.id | html %]
369
                                                        [% END %]
370
                                                </td>
371
                                                <td>[% basketgroup.id | html %]</td>
372
                                                <td>[% Branches.GetName( basketgroup.billingplace ) | html %]</td>
373
                                                <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) | html %][% END %]</td>
374
                                                <td>[% basketgroup.basketsqty | html %]</td>
375
                                                <td>
376
                                                    <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>
377
                                                    <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>
378
                                                    <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>
379
                                                    <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>
380
                                            [% IF (ediaccount) %]
381
                                                    <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>
382
                                            [% ELSE %]
383
                                                    <div>No EDIFACT configuration for [% booksellername | html %]</div>
384
                                            [% END %]
385
                                                </td>
386
                                            </tr>
387
                                        [% END %]
388
                                    [% END %]
389
                                </tbody>
390
                            </table>
391
                        </div>
392
                    </div>
393
                [% END %]
394
            </main>
285
            </main>
395
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
286
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
396
287
397
        <div class="col-sm-2 col-sm-pull-10">
288
        <div class="col-sm-2 col-sm-pull-10">
398
            <aside>
289
            <aside>
399
                [% IF ( booksellerid ) %]
290
                [% INCLUDE 'vendor-menu.inc' %]
400
                    [% INCLUDE 'vendor-menu.inc' %]
401
                [% END %]
402
                [% INCLUDE 'acquisitions-menu.inc' %]
291
                [% INCLUDE 'acquisitions-menu.inc' %]
403
            </aside>
292
            </aside>
404
        </div>
293
        </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