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

(-)a/Koha/Basket.pm (+36 lines)
Line 0 Link Here
1
package Koha::Basket;
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::Orders;
21
22
use base qw(Koha::Object);
23
24
sub _type {
25
    return 'Aqbasket';
26
}
27
28
sub orders {
29
    my ($self) = @_;
30
31
    $self->{_orders} ||= Koha::Orders->search({ basketno => $self->basketno });
32
33
    return wantarray ? $self->{_orders}->as_list : $self->{_orders};
34
}
35
36
1;
(-)a/Koha/Basketgroup.pm (+78 lines)
Line 0 Link Here
1
package Koha::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::Baskets;
23
24
use base qw(Koha::Object);
25
26
sub _type {
27
    return 'Aqbasketgroup';
28
}
29
30
sub bookseller {
31
    my ($self) = @_;
32
33
    return Koha::Booksellers->find($self->booksellerid);
34
}
35
36
sub baskets {
37
    my ($self) = @_;
38
39
    $self->{_baskets} ||= Koha::Baskets->search({ basketgroupid => $self->id });
40
41
    return wantarray ? $self->{_baskets}->as_list : $self->{_baskets};
42
}
43
44
sub baskets_count {
45
    my ($self) = @_;
46
47
    return $self->baskets->count;
48
}
49
50
sub ordered_titles_count {
51
    my ($self) = @_;
52
53
    my @biblionumbers;
54
    foreach my $basket ($self->baskets) {
55
        foreach my $order ($basket->orders) {
56
            push @biblionumbers, $order->biblionumber;
57
        }
58
    }
59
60
    return scalar uniq @biblionumbers;
61
}
62
63
sub received_titles_count {
64
    my ($self) = @_;
65
66
    my @biblionumbers;
67
    foreach my $basket ($self->baskets) {
68
        foreach my $order ($basket->orders) {
69
            if ($order->datereceived) {
70
                push @biblionumbers, $order->biblionumber;
71
            }
72
        }
73
    }
74
75
    return scalar uniq @biblionumbers;
76
}
77
78
1;
(-)a/Koha/Basketgroups.pm (+32 lines)
Line 0 Link Here
1
package Koha::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::Basketgroup;
21
22
use base qw(Koha::Objects);
23
24
sub _type {
25
    return 'Aqbasketgroup';
26
}
27
28
sub object_class {
29
    return 'Koha::Basketgroup';
30
}
31
32
1;
(-)a/Koha/Baskets.pm (+32 lines)
Line 0 Link Here
1
package Koha::Baskets;
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::Basket;
21
22
use base qw(Koha::Objects);
23
24
sub _type {
25
    return 'Aqbasket';
26
}
27
28
sub object_class {
29
    return 'Koha::Basket';
30
}
31
32
1;
(-)a/Koha/Bookseller.pm (+26 lines)
Line 0 Link Here
1
package Koha::Bookseller;
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 base qw(Koha::Object);
21
22
sub _type {
23
    return 'Aqbookseller';
24
}
25
26
1;
(-)a/Koha/Booksellers.pm (+32 lines)
Line 0 Link Here
1
package Koha::Booksellers;
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::Bookseller;
21
22
use base qw(Koha::Objects);
23
24
sub _type {
25
    return 'Aqbookseller';
26
}
27
28
sub object_class {
29
    return 'Koha::Bookseller';
30
}
31
32
1;
(-)a/Koha/Order.pm (+26 lines)
Line 0 Link Here
1
package Koha::Order;
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 base qw(Koha::Object);
21
22
sub _type {
23
    return 'Aqorder';
24
}
25
26
1;
(-)a/Koha/Orders.pm (+32 lines)
Line 0 Link Here
1
package Koha::Orders;
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::Order;
21
22
use base qw(Koha::Objects);
23
24
sub _type {
25
    return 'Aqorder';
26
}
27
28
sub object_class {
29
    return 'Koha::Order';
30
}
31
32
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 (-114 / +94 lines)
Lines 90-98 sub BasketTotal { Link Here
90
90
91
#displays all basketgroups and all closed baskets (in their respective groups)
91
#displays all basketgroups and all closed baskets (in their respective groups)
92
sub displaybasketgroups {
92
sub displaybasketgroups {
93
    my $basketgroups = shift;
93
    my ($basketgroups, $bookseller, $baskets, $template) = @_;
94
    my $bookseller = shift;
95
    my $baskets = shift;
96
    if (scalar @$basketgroups != 0) {
94
    if (scalar @$basketgroups != 0) {
97
        foreach my $basketgroup (@$basketgroups){
95
        foreach my $basketgroup (@$basketgroups){
98
            my $i = 0;
96
            my $i = 0;
Lines 126-154 sub displaybasketgroups { Link Here
126
124
127
sub printbasketgrouppdf{
125
sub printbasketgrouppdf{
128
    my ($basketgroupid) = @_;
126
    my ($basketgroupid) = @_;
129
    
127
130
    my $pdfformat = C4::Context->preference("OrderPdfFormat");
128
    my $pdfformat = C4::Context->preference("OrderPdfFormat");
131
    if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages' || $pdfformat eq 'pdfformat::layout3pagesfr'
129
    if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages' || $pdfformat eq 'pdfformat::layout3pagesfr'
132
        || $pdfformat eq 'pdfformat::layout2pagesde'){
130
        || $pdfformat eq 'pdfformat::layout2pagesde'){
133
	eval {
131
        eval {
134
        eval "require $pdfformat";
132
            my $pdfformatfile = './' . ($pdfformat =~ s,::,/,gr) . '.pm';
135
	    import $pdfformat;
133
            require $pdfformatfile;
136
	};
134
            import $pdfformat;
137
	if ($@){
135
        };
138
	}
136
        if ($@){
137
            warn $@;
138
        }
139
    }
139
    }
140
    else {
140
    else {
141
	print $input->header;  
141
        print $input->header;
142
	print $input->start_html;  # FIXME Should do a nicer page
142
        print $input->start_html;  # FIXME Should do a nicer page
143
	print "<h1>Invalid PDF Format set</h1>";
143
        print "<h1>Invalid PDF Format set</h1>";
144
	print "Please go to the systempreferences and set a valid pdfformat";
144
        print "Please go to the systempreferences and set a valid pdfformat";
145
	exit;
145
        exit;
146
    }
146
    }
147
    
147
148
    my $basketgroup = GetBasketgroup($basketgroupid);
148
    my $basketgroup = GetBasketgroup($basketgroupid);
149
    my $bookseller = Koha::Acquisition::Booksellers->find( $basketgroup->{booksellerid} );
149
    my $bookseller = Koha::Acquisition::Booksellers->find( $basketgroup->{booksellerid} );
150
    my $baskets = GetBasketsByBasketgroup($basketgroupid);
150
    my $baskets = GetBasketsByBasketgroup($basketgroupid);
151
    
151
152
    my %orders;
152
    my %orders;
153
    for my $basket (@$baskets) {
153
    for my $basket (@$baskets) {
154
        my @ba_orders;
154
        my @ba_orders;
Lines 211-217 sub printbasketgrouppdf{ Link Here
211
    );
211
    );
212
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed";
212
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed";
213
    print $pdf;
213
    print $pdf;
214
215
}
214
}
216
215
217
sub generate_edifact_orders {
216
sub generate_edifact_orders {
Lines 225-294 sub generate_edifact_orders { Link Here
225
    return;
224
    return;
226
}
225
}
227
226
228
my $op = $input->param('op') || 'display';
229
# possible values of $op :
227
# possible values of $op :
230
# - add : adds a new basketgroup, or edit an open basketgroup, or display a closed basketgroup
231
# - mod_basket : modify an individual basket of the basketgroup
228
# - mod_basket : modify an individual basket of the basketgroup
232
# - closeandprint : close and print an closed basketgroup in pdf. called by clicking on "Close and print" button in closed basketgroups list
229
# - closeandprint : close and print an closed basketgroup in pdf. called by
233
# - print : print a closed basketgroup. called by clicking on "Print" button in closed basketgroups list
230
#   clicking on "Close and print" button in closed basketgroups list
231
# - print : print a closed basketgroup. called by clicking on "Print" button in
232
#   closed basketgroups list
234
# - ediprint : generate edi order messages for the baskets in the group
233
# - ediprint : generate edi order messages for the baskets in the group
235
# - export : export in CSV a closed basketgroup. called by clicking on "Export" button in closed basketgroups list
234
# - export : export in CSV a closed basketgroup. called by clicking on "Export"
236
# - delete : delete an open basketgroup. called by clicking on "Delete" button in open basketgroups list
235
#   button in closed basketgroups list
237
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button in closed basketgroup list
236
# - delete : delete an open basketgroup. called by clicking on "Delete" button
238
# - attachbasket : save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
237
#   in open basketgroups list
239
# - display : display the list of all basketgroups for a vendor
238
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button
239
#   in closed basketgroup list
240
# - attachbasket : save a modified basketgroup, or creates a new basketgroup
241
#   when a basket is closed. called from basket page
242
my $op = $input->param('op');
240
my $booksellerid = $input->param('booksellerid');
243
my $booksellerid = $input->param('booksellerid');
241
$template->param(booksellerid => $booksellerid);
242
244
243
if ( $op eq "add" ) {
245
if ($op eq 'mod_basket') {
244
#
245
# if no param('basketgroupid') is not defined, adds a new basketgroup
246
# else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid
247
# the template will know if basketgroup must be displayed or edited, depending on the value of closed key
248
#
249
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
250
    my $basketgroupid = $input->param('basketgroupid');
251
    my $billingplace;
252
    my $deliveryplace;
253
    my $freedeliveryplace;
254
    if ( $basketgroupid ) {
255
        # Get the selected baskets in the basketgroup to display them
256
        my $selecteds = GetBasketsByBasketgroup($basketgroupid);
257
        foreach my $basket(@{$selecteds}){
258
            $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
259
        }
260
        $template->param(basketgroupid => $basketgroupid,
261
                         selectedbaskets => $selecteds);
262
263
        # Get general informations about the basket group to prefill the form
264
        my $basketgroup = GetBasketgroup($basketgroupid);
265
        $template->param(
266
            name            => $basketgroup->{name},
267
            deliverycomment => $basketgroup->{deliverycomment},
268
            freedeliveryplace => $basketgroup->{freedeliveryplace},
269
        );
270
        $billingplace  = $basketgroup->{billingplace};
271
        $deliveryplace = $basketgroup->{deliveryplace};
272
        $freedeliveryplace = $basketgroup->{freedeliveryplace};
273
        $template->param( closedbg => ($basketgroup ->{'closed'}) ? 1 : 0);
274
    } else {
275
        $template->param( closedbg => 0);
276
    }
277
    # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
278
    my $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set
279
    $billingplace  = $billingplace  || $patron->branchcode;
280
    $deliveryplace = $deliveryplace || $patron->branchcode;
281
282
    $template->param( billingplace => $billingplace );
283
    $template->param( deliveryplace => $deliveryplace );
284
    $template->param( booksellerid => $booksellerid );
285
286
    # the template will display a unique basketgroup
287
    $template->param(grouping => 1);
288
    my $basketgroups = &GetBasketgroups($booksellerid);
289
    my $baskets = &GetBasketsByBookseller($booksellerid);
290
    displaybasketgroups($basketgroups, $bookseller, $baskets);
291
} elsif ($op eq 'mod_basket') {
292
#
246
#
293
# edit an individual basket contained in this basketgroup
247
# edit an individual basket contained in this basketgroup
294
#
248
#
Lines 329-335 if ( $op eq "add" ) { Link Here
329
#
283
#
330
    my $basketgroupid = $input->param('basketgroupid');
284
    my $basketgroupid = $input->param('basketgroupid');
331
    DelBasketgroup($basketgroupid);
285
    DelBasketgroup($basketgroupid);
332
    print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid.'&amp;listclosed=1');
286
    print $input->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid);
287
    exit;
333
}elsif ( $op eq 'reopen'){
288
}elsif ( $op eq 'reopen'){
334
#
289
#
335
# reopen a closed basketgroup
290
# reopen a closed basketgroup
Lines 337-344 if ( $op eq "add" ) { Link Here
337
    my $basketgroupid   = $input->param('basketgroupid');
292
    my $basketgroupid   = $input->param('basketgroupid');
338
    my $booksellerid    = $input->param('booksellerid');
293
    my $booksellerid    = $input->param('booksellerid');
339
    ReOpenBasketgroup($basketgroupid);
294
    ReOpenBasketgroup($basketgroupid);
340
    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';
295
    my $redirectpath;
296
    my $mode = $input->param('mode');
297
    if (defined $mode && $mode eq 'singlebg') {
298
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid;
299
    } else {
300
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' .$booksellerid;
301
    }
341
    print $input->redirect($redirectpath);
302
    print $input->redirect($redirectpath);
303
    exit;
342
} elsif ( $op eq 'attachbasket') {
304
} elsif ( $op eq 'attachbasket') {
343
#
305
#
344
# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
306
# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
Lines 384-428 if ( $op eq "add" ) { Link Here
384
        };
346
        };
385
        $basketgroupid = NewBasketgroup($basketgroup);
347
        $basketgroupid = NewBasketgroup($basketgroup);
386
    }
348
    }
387
    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;
349
    my $redirectpath;
388
    $redirectpath .=  "&amp;listclosed=1" if $closedbg ;
350
    my $mode = $input->param('mode');
389
    print $input->redirect($redirectpath );
351
    if (defined $mode && $mode eq 'singlebg') {
390
    
352
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid;
353
    } else {
354
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid;
355
    }
356
    print $input->redirect($redirectpath);
357
    exit;
391
} elsif ( $op eq 'ediprint') {
358
} elsif ( $op eq 'ediprint') {
392
    my $basketgroupid = $input->param('basketgroupid');
359
    my $basketgroupid = $input->param('basketgroupid');
393
    generate_edifact_orders( $basketgroupid );
360
    generate_edifact_orders( $basketgroupid );
394
    exit;
361
    exit;
395
}else{
362
}
396
    my @booksellers;
363
397
    if ($booksellerid) {
364
# if no param('basketgroupid') is not defined, adds a new basketgroup else, edit
398
        my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
365
# (if it is open) or display (if it is close) the basketgroup basketgroupid the
399
        push @booksellers, $bookseller;
366
# template will know if basketgroup must be displayed or edited, depending on
400
        $template->param(booksellername => $booksellers[0]->{name});
367
# the value of closed key
401
    } else {
368
402
        @booksellers = Koha::Acquisition::Bookseller->search;
369
my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
403
    }
370
my $basketgroupid = $input->param('basketgroupid');
404
    foreach my $bookseller (@booksellers) {
371
my $billingplace;
405
        $bookseller->{basketgroups} = GetBasketgroups($bookseller->{id});
372
my $deliveryplace;
406
        foreach my $basketgroup (@{ $bookseller->{basketgroups} }) {
373
my $freedeliveryplace;
407
            my $baskets = GetBasketsByBasketgroup($basketgroup->{id});
374
if ( $basketgroupid ) {
408
            $basketgroup->{basketsqty} = 0;
375
    # Get the selected baskets in the basketgroup to display them
409
            my (@ordered_biblionumbers, @received_biblionumbers);
376
    my $selecteds = GetBasketsByBasketgroup($basketgroupid);
410
            foreach my $basket (@$baskets) {
377
    foreach my $basket(@{$selecteds}){
411
                $basketgroup->{basketsqty} += 1;
378
        $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
412
                my @orders = GetOrders($basket->{basketno});
413
                foreach my $order (@orders) {
414
                    push @ordered_biblionumbers, $order->{biblionumber};
415
                    if ($order->{datereceived}) {
416
                        push @received_biblionumbers, $order->{biblionumber};
417
                    }
418
                }
419
            }
420
            $basketgroup->{ordered_titles_count} = uniq @ordered_biblionumbers;
421
            $basketgroup->{received_titles_count} = uniq @received_biblionumbers;
422
        }
423
    }
379
    }
424
    $template->param(booksellers => \@booksellers);
380
    $template->param(basketgroupid => $basketgroupid,
381
                     selectedbaskets => $selecteds);
382
383
    # Get general informations about the basket group to prefill the form
384
    my $basketgroup = GetBasketgroup($basketgroupid);
385
    $template->param(
386
        name => $basketgroup->{name},
387
        billingplace => $basketgroup->{billingplace},
388
        deliveryplace => $basketgroup->{deliveryplace},
389
        deliverycomment => $basketgroup->{deliverycomment},
390
        freedeliveryplace => $basketgroup->{freedeliveryplace},
391
        closedbg => $basketgroup->{closed} ? 1 : 0
392
    );
393
} else {
394
    $template->param( closedbg => 0);
425
}
395
}
426
$template->param(listclosed => ((defined $input->param('listclosed')) && ($input->param('listclosed') eq '1'))? 1:0 );
396
# 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
397
my $borrower = Koha::Patrons->find( $loggedinuser );
398
$billingplace  = $billingplace  || $borrower->branchcode;
399
$deliveryplace = $deliveryplace || $borrower->branchcode;
400
401
$template->param( booksellerid => $booksellerid );
402
403
# the template will display a unique basketgroup
404
my $basketgroups = &GetBasketgroups($booksellerid);
405
my $baskets = &GetBasketsByBookseller($booksellerid);
406
displaybasketgroups($basketgroups, $bookseller, $baskets, $template);
407
428
output_html_with_http_headers $input, $cookie, $template->output;
408
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 (-1 / +1 lines)
Lines 4-10 Link Here
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 ) %]
6
            [% IF ( CAN_user_acquisition_group_manage ) %]
7
              <li><a href="/cgi-bin/koha/acqui/basketgroup.pl">Basket groups</a></li>
7
              <li><a href="/cgi-bin/koha/acqui/basketgroups.pl">Basket groups</a></li>
8
            [% END %]
8
            [% END %]
9
            <li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>
9
            <li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>
10
            [% IF ( suggestion ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
10
            [% IF ( suggestion ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc (+2 lines)
Lines 20-25 Link Here
20
    var MSG_DT_SEARCH = _("Search:");
20
    var MSG_DT_SEARCH = _("Search:");
21
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
21
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
22
    var MSG_DT_ALL = _("All");
22
    var MSG_DT_ALL = _("All");
23
    var MSG_DT_SORT_ASC = _(": activate to sort column ascending");
24
    var MSG_DT_SORT_DESC = _(": activate to sort column descending");
23
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
25
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
24
//]]>
26
//]]>
25
</script>
27
</script>
(-)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 %]">Baskets</a></li>[% END %]
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid %]">Baskets</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]">Basket groups</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid %]">Basket groups</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]">Contracts</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid %]">Contracts</a></li>[% END %]
7
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid %]&amp;op=do_search">Invoices</a></li>
7
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid %]&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 (-274 / +134 lines)
Lines 16-22 Link Here
16
[% Asset.js("lib/yui/container/container_core-min.js") %]
16
[% Asset.js("lib/yui/container/container_core-min.js") %]
17
[% Asset.js("lib/yui/menu/menu-min.js") %]
17
[% Asset.js("lib/yui/menu/menu-min.js") %]
18
[% Asset.js("js/basketgroup.js") %]
18
[% Asset.js("js/basketgroup.js") %]
19
[% IF ( grouping ) %]
20
[% Asset.js("lib/yui/yahoo-dom-event/yahoo-dom-event.js") %]
19
[% Asset.js("lib/yui/yahoo-dom-event/yahoo-dom-event.js") %]
21
[% Asset.js("lib/yui/animation/animation-min.js") %]
20
[% Asset.js("lib/yui/animation/animation-min.js") %]
22
[% Asset.js("lib/yui/dragdrop/dragdrop-min.js") %]
21
[% Asset.js("lib/yui/dragdrop/dragdrop-min.js") %]
Lines 92-98 fieldset.various li { Link Here
92
}
91
}
93
92
94
</style>
93
</style>
95
 [% END %]
96
<script type="text/javascript">
94
<script type="text/javascript">
97
//<![CDATA[
95
//<![CDATA[
98
	YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
96
	YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
Lines 155-458 function submitForm(form) { Link Here
155
[% INCLUDE 'acquisitions-search.inc' %]
153
[% INCLUDE 'acquisitions-search.inc' %]
156
154
157
<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;
155
<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;
158
[% IF ( grouping ) %]
156
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a>
159
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]">Basket groups</a> &rsaquo; Add basket group for [% booksellername |html %]
157
    &rsaquo;
160
[% ELSE %]
158
    <a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid %]">Basket groups</a>
161
  [% IF (booksellerid) %]
159
    &rsaquo;
162
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a> &rsaquo;
160
    Add basket group for [% booksellername |html %]
163
  [% END %]
164
  Basket groups
165
[% END %]
166
</div>
161
</div>
167
162
168
<div id="doc3" class="yui-t2">
163
<div id="doc3" class="yui-t2">
169
    <div id="bd">
164
    <div id="bd">
170
        <div id="yui-main">
165
        <div id="yui-main">
171
            <div class="yui-b">
166
            <div class="yui-b">
172
                [% IF ( grouping ) %]
167
                [% IF (closedbg) %]
173
                    [% IF (closedbg) %]
168
                    <div id="toolbar" class="btn-toolbar">
174
                        <div id="toolbar" class="btn-toolbar">
169
                        <div class="btn-group"><a href="[% script_name %]?op=reopen&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]&amp;mode=singlebg" class="btn btn-default btn-sm" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div>
175
                            <div class="btn-group"><a href="[% script_name %]?op=reopen&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]&amp;mode=singlebg" class="btn btn-default btn-sm" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div>
170
                        <div class="btn-group"><a href="[% script_name %]?op=export&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="exportbutton"><i class="fa fa-download"></i> Export this basket group as CSV</a></div>
176
                            <div class="btn-group"><a href="[% script_name %]?op=export&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="exportbutton"><i class="fa fa-download"></i> Export this basket group as CSV</a></div>
171
                        <div class="btn-group"><a href="[% script_name %]?op=print&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Print this basket group in PDF</a></div>
177
                            <div class="btn-group"><a href="[% script_name %]?op=print&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Print this basket group in PDF</a></div>
172
                        <div class="btn-group"><a href="[% script_name %]?op=ediprint&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div>
178
                            <div class="btn-group"><a href="[% script_name %]?op=ediprint&amp;basketgroupid=[% basketgroupid %]&amp;booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div>
173
                    </div>
174
                [% END %]
175
                [% IF (name && closedbg) %]
176
                    <h1>Basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
177
                [% ELSIF (name) %]
178
                    <h1>Edit basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
179
                [% ELSE %]
180
                    <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
181
                [% END %]
182
                <div id="basketgroupcolumns" class="yui-g">
183
                    [% UNLESS (closedbg) %]
184
                        <div class="yui-u">
185
                            <form action="[% scriptname %]" method="post" name="basketgroups" id="basketgroups">
186
                                <div id="groups">
187
                                    <fieldset class="brief">
188
                                        <div class="workarea_alt" >
189
                                            <h3>Ungrouped baskets</h3>
190
                                            <ul id="ungrouped" class="draglist_alt">
191
                                                [% IF ( baskets ) %]
192
                                                    [% FOREACH basket IN baskets %]
193
                                                        <li class="ungrouped" id="b-[% basket.basketno %]" >
194
                                                            <a href="basket.pl?basketno=[% basket.basketno %]">
195
                                                                [% IF ( basket.basketname ) %]
196
                                                                    [% basket.basketname %]
197
                                                                [% ELSE %]
198
                                                                    No name, basketnumber: [% basket.basketno %]
199
                                                                [% END %]
200
                                                            </a>, <br />
201
                                                            Total: [% basket.total %]
202
                                                            <input type="hidden" class="basket" name="basket" value="[% basket.basketno %]" />
203
                                                        </li>
204
                                                    [% END %]
205
                                                [% END %]
206
                                            </ul>
207
                                        </div>
208
                                    </fieldset>
209
                                </div>
210
                            </form>
179
                        </div>
211
                        </div>
180
                    [% END %]
212
                    [% END %]
181
                    [% IF (name && closedbg) %]
213
                    <div class="yui-u first">
182
                        <h1>Basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
214
                        <form action="" method="post" id="groupingform" onsubmit="return submitForm(this)">
183
                    [% ELSIF (name) %]
215
                            <fieldset id="various" class="brief">
184
                        <h1>Edit basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
216
                                <ol>
185
                    [% ELSE %]
217
                                    [% UNLESS (closedbg) %]
186
                        <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
218
                                        <li>
187
                    [% END %]
219
                                            <label for="basketgroupname">Basket group name:</label>
188
                    <div id="basketgroupcolumns" class="yui-g">
220
                                            <input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" class="focus" />
189
                        [% UNLESS (closedbg) %]
221
                                        </li>
190
                            <div class="yui-u">
222
                                    [% ELSE %]
191
                                <form action="[% scriptname %]" method="post" name="basketgroups" id="basketgroups">
223
                                        <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% name %]" />
192
                                    <div id="groups">
224
                                    [% END %]
193
                                        <fieldset class="brief">
225
                                    <li>
194
                                            <div class="workarea_alt" >
195
                                                <h3>Ungrouped baskets</h3>
196
                                                <ul id="ungrouped" class="draglist_alt">
197
                                                    [% IF ( baskets ) %]
198
                                                        [% FOREACH basket IN baskets %]
199
                                                            <li class="ungrouped" id="b-[% basket.basketno %]" >
200
                                                                <a href="basket.pl?basketno=[% basket.basketno %]">
201
                                                                    [% IF ( basket.basketname ) %]
202
                                                                        [% basket.basketname %]
203
                                                                    [% ELSE %]
204
                                                                        No name, basketnumber: [% basket.basketno %]
205
                                                                    [% END %]
206
                                                                </a>, <br />
207
                                                                Total: [% basket.total %]
208
                                                                <input type="hidden" class="basket" name="basket" value="[% basket.basketno %]" />
209
                                                            </li>
210
                                                        [% END %]
211
                                                    [% END %]
212
                                                </ul>
213
                                            </div>
214
                                        </fieldset>
215
                                    </div>
216
                                </form>
217
                            </div>
218
                        [% END %]
219
                        <div class="yui-u first">
220
                            <form action="" method="post" id="groupingform" onsubmit="return submitForm(this)">
221
                                <fieldset id="various" class="brief">
222
                                    <ol>
223
                                        [% UNLESS (closedbg) %]
226
                                        [% UNLESS (closedbg) %]
224
                                            <li>
227
                                            <label for="billingplace">Billing place:</label>
225
                                                <label for="basketgroupname">Basket group name:</label>
228
                                            <select name="billingplace" id="billingplace" style="width:13em;">
226
                                                <input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" class="focus" />
229
                                                <option value="">--</option>
227
                                            </li>
230
                                                [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %]
231
                                            </select>
228
                                        [% ELSE %]
232
                                        [% ELSE %]
229
                                            <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% name %]" />
233
                                            <span class="label">Billing place:</span>
234
                                            <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace %]" />[% Branches.GetName( billingplace ) %]
230
                                        [% END %]
235
                                        [% END %]
236
                                    </li>
237
                                    [% UNLESS (closedbg) %]
231
                                        <li>
238
                                        <li>
232
                                            [% UNLESS (closedbg) %]
239
                                            <label for="deliveryplace">Delivery place:</label>
233
                                                <label for="billingplace">Billing place:</label>
240
                                            <select name="deliveryplace" id="deliveryplace" style="width:13em;">
234
                                                <select name="billingplace" id="billingplace" style="width:13em;">
241
                                                <option value="">--</option>
235
                                                    <option value="">--</option>
242
                                                [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %]
236
                                                    [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %]
243
                                            <select>
237
                                                </select>
238
                                            [% ELSE %]
239
                                                <span class="label">Billing place:</span>
240
                                                <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace %]" />[% Branches.GetName( billingplace ) %]
241
                                            [% END %]
242
                                        </li>
244
                                        </li>
243
                                        [% UNLESS (closedbg) %]
245
                                        <li><p>or</p></li>
244
                                            <li>
246
                                        <li>
245
                                                <label for="deliveryplace">Delivery place:</label>
247
                                            <label for="freedeliveryplace">Delivery place:</label>
246
                                                <select name="deliveryplace" id="deliveryplace" style="width:13em;">
248
                                            <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% freedeliveryplace %]</textarea>
247
                                                    <option value="">--</option>
249
                                        </li>
248
                                                    [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %]
250
                                        [% ELSE %]
249
                                                <select>
250
                                            </li>
251
                                            <li><p>or</p></li>
252
                                            <li>
253
                                                <label for="freedeliveryplace">Delivery place:</label>
254
                                                <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% freedeliveryplace %]</textarea>
255
                                            </li>
256
                                            [% ELSE %]
257
                                                <li>
258
                                                    <span class="label">Delivery place:</span>
259
                                                    [% IF (freedeliveryplace) %]
260
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% freedeliveryplace %]" />[% freedeliveryplace %]
261
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" />
262
                                                    [% ELSE %]
263
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% deliveryplace %]" />[% Branches.GetName( deliveryplace ) %]
264
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" />
265
                                                    [% END %]
266
                                                </li>
267
                                            [% END %]
268
                                            <li>
251
                                            <li>
269
                                                [% UNLESS (closedbg) %]
252
                                                <span class="label">Delivery place:</span>
270
                                                    <label for="deliverycomment">Delivery comment:</label>
253
                                                [% IF (freedeliveryplace) %]
271
                                                    <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% deliverycomment %]</textarea>
254
                                                    <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% freedeliveryplace %]" />[% freedeliveryplace %]
255
                                                    <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" />
272
                                                [% ELSE %]
256
                                                [% ELSE %]
273
                                                    <span class="label">Delivery comment:</span>[% deliverycomment %]
257
                                                    <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% deliveryplace %]" />[% Branches.GetName( deliveryplace ) %]
274
                                                    <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% deliverycomment %]" />
258
                                                    <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" />
275
                                                [% END %]
259
                                                [% END %]
276
                                            </li>
260
                                            </li>
277
                                            <li>
261
                                        [% END %]
278
                                                <span class="label">Baskets in this group:</span>
262
                                        <li>
279
                                                [% UNLESS (closedbg) %]
263
                                            [% UNLESS (closedbg) %]
280
                                                    <ul class="draglist" id="bg">
264
                                                <label for="deliverycomment">Delivery comment:</label>
281
                                                [% ELSE %]
265
                                                <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% deliverycomment %]</textarea>
282
                                                    <ul>
266
                                            [% ELSE %]
283
                                                [% END %]
267
                                                <span class="label">Delivery comment:</span>[% deliverycomment %]
284
                                                [% FOREACH selectedbasket IN selectedbaskets %]
268
                                                <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% deliverycomment %]" />
285
                                                    <li class="grouped" id="b-[% selectedbasket.basketno %]" >
269
                                            [% END %]
286
                                                        <a href="basket.pl?basketno=[% selectedbasket.basketno %]">
287
                                                            [% IF ( selectedbasket.basketname ) %]
288
                                                                [% selectedbasket.basketname %]
289
                                                            [% ELSE %]
290
                                                                No name, basketnumber: [% selectedbasket.basketno %]
291
                                                            [% END %]
292
                                                        </a>, <br />
293
                                                        Total: [% selectedbasket.total %]
294
                                                        <input type="hidden" class="basket" name="basket" value="[% selectedbasket.basketno %]" />
295
                                                    </li>
296
                                                [% END %]
297
                                            </ul>
298
                                        </li>
270
                                        </li>
271
                                        <li>
272
                                            <span class="label">Baskets in this group:</span>
299
                                            [% UNLESS (closedbg) %]
273
                                            [% UNLESS (closedbg) %]
300
                                                <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li>
274
                                                <ul class="draglist" id="bg">
301
                                            [% ELSE %]
275
                                            [% ELSE %]
302
                                                <input type="hidden" id="closedbg" name="closedbg" value ="1"/>
276
                                                <ul>
303
                                            [% END %]
277
                                            [% END %]
304
                                    </ol>
278
                                            [% FOREACH selectedbasket IN selectedbaskets %]
305
                                </fieldset>
279
                                                <li class="grouped" id="b-[% selectedbasket.basketno %]" >
306
                                [% UNLESS (closedbg) %]
280
                                                    <a href="basket.pl?basketno=[% selectedbasket.basketno %]">
307
                                    <fieldset class="action"><input type="hidden" name="booksellerid" value="[% booksellerid %]" />
281
                                                        [% IF ( selectedbasket.basketname ) %]
308
                                        [% IF ( basketgroupid ) %]
282
                                                            [% selectedbasket.basketname %]
309
                                            <input type="hidden" name="basketgroupid" value="[% basketgroupid %]" />
283
                                                        [% ELSE %]
284
                                                            No name, basketnumber: [% selectedbasket.basketno %]
285
                                                        [% END %]
286
                                                    </a>, <br />
287
                                                    Total: [% selectedbasket.total %]
288
                                                    <input type="hidden" class="basket" name="basket" value="[% selectedbasket.basketno %]" />
289
                                                </li>
290
                                            [% END %]
291
                                        </ul>
292
                                    </li>
293
                                        [% UNLESS (closedbg) %]
294
                                            <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li>
295
                                        [% ELSE %]
296
                                            <input type="hidden" id="closedbg" name="closedbg" value ="1"/>
310
                                        [% END %]
297
                                        [% END %]
311
                                        <input type="hidden" name="op" value="attachbasket" />
298
                                </ol>
312
                                        <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]" class="cancel">Cancel</a>
299
                            </fieldset>
313
                                    </fieldset>
300
                            [% UNLESS (closedbg) %]
314
                                [% END %]
301
                                <fieldset class="action"><input type="hidden" name="booksellerid" value="[% booksellerid %]" />
315
                            </form>
302
                                    [% IF ( basketgroupid ) %]
316
                        </div>
303
                                        <input type="hidden" name="basketgroupid" value="[% basketgroupid %]" />
304
                                    [% END %]
305
                                    <input type="hidden" name="op" value="attachbasket" />
306
                                    <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]" class="cancel">Cancel</a>
307
                                </fieldset>
308
                            [% END %]
309
                        </form>
317
                    </div>
310
                    </div>
318
                [% ELSE %]
311
                </div>
319
                    [% IF booksellerid %]
320
                        <div id="toolbar" class="btn-toolbar">
321
                            <div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% booksellerid %]" class="btn btn-default btn-sm" id="newbasketgroup"><i class="fa fa-plus"></i> New basket group</a></div>
322
                        </div>
323
                    [% END %]
324
325
                    [% FOREACH bookseller IN booksellers %]
326
                        [% IF bookseller.basketgroups.size > 0 %]
327
                            <h1>Basket groups for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name |html %]</a></h1>
328
                            <div class="basket_groups toptabs">
329
                                <ul class="ui-tabs-nav">
330
                                    [% UNLESS ( listclosed) %]<li class="ui-tabs-active"><a href="#opened[% bookseller.id %]">Open</a></li>
331
                                    [% ELSE%]<li><a href="#opened[% bookseller.id %]">Open</a></li>[% END %]
332
                                    [% IF ( listclosed) %]<li class="ui-tabs-active"><a href="#closed[% bookseller.id %]">Closed</a></li>
333
                                    [% ELSE %]<li><a href="#closed[% bookseller.id %]">Closed</a></li>[% END %]
334
                                </ul>
335
                                <div id="opened[% bookseller.id %]">
336
                                    <table id="basket_group_opened">
337
                                        <thead>
338
                                            <tr>
339
                                                <th>Search name</th>
340
                                                <th>Search no.</th>
341
                                                <th>Search billing place</th>
342
                                                <th>Search delivery place</th>
343
                                                <th>Search no. of baskets</th>
344
                                                <th>Search no. of ordered titles</th>
345
                                                <th>Search no. of received titles</th>
346
                                                <th></th>
347
                                            </tr>
348
                                            <tr>
349
                                                <th>Name</th>
350
                                                <th>No.</th>
351
                                                <th>Billing place</th>
352
                                                <th>Delivery place</th>
353
                                                <th>No. of baskets</th>
354
                                                <th>No. of ordered titles</th>
355
                                                <th>No. of received titles</th>
356
                                                <th>Action</th>
357
                                            </tr>
358
                                        </thead>
359
                                        <tbody>
360
                                            [% FOREACH basketgroup IN bookseller.basketgroups %]
361
                                                [% UNLESS ( basketgroup.closed ) %]
362
                                                    <tr>
363
                                                        <td>
364
                                                            [% IF ( basketgroup.name ) %]
365
                                                                [% basketgroup.name %]
366
                                                            [% ELSE %]
367
                                                                Basket group no. [% basketgroup.id %]
368
                                                            [% END %]
369
                                                        </td>
370
                                                        <td>[% basketgroup.id %]</td>
371
                                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
372
                                                        <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %]</td>
373
                                                        <td>[% basketgroup.basketsqty %]</td>
374
                                                        <td>[% basketgroup.ordered_titles_count %]</td>
375
                                                        <td>[% basketgroup.received_titles_count %]</td>
376
                                                        <td>
377
                                                            <input type="button" onclick="closeandprint('[% basketgroup.id %]');" value="Close and export as PDF" />
378
                                                            <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 %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Edit" /></form>
379
                                                            [% UNLESS basketgroup.basketsqty %]
380
                                                                <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 %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Delete" /></form>
381
                                                            [% END %]
382
                                                        </td>
383
                                                    </tr>
384
                                                [% END %]
385
                                            [% END %]
386
                                        </tbody>
387
                                    </table>
388
                                </div>
389
                                <div id="closed[% bookseller.id %]">
390
                                    <table class="basket_group_closed">
391
                                        <thead>
392
                                            <tr>
393
                                                <th>Search name</th>
394
                                                <th>Search no.</th>
395
                                                <th>Search date closed</th>
396
                                                <th>Search billing place</th>
397
                                                <th>Search delivery place</th>
398
                                                <th>Search no. of baskets</th>
399
                                                <th>Search no. of ordered titles</th>
400
                                                <th>Search no. of received titles</th>
401
                                                <th></th>
402
                                            </tr>
403
                                            <tr>
404
                                                <th>Name</th>
405
                                                <th>No.</th>
406
                                                <th>Date closed</th>
407
                                                <th>Billing place</th>
408
                                                <th>Delivery place</th>
409
                                                <th>No. of baskets</th>
410
                                                <th>No. of ordered titles</th>
411
                                                <th>No. of received titles</th>
412
                                                <th>Action</th>
413
                                            </tr>
414
                                        </thead>
415
                                        <tbody>
416
                                            [% FOREACH basketgroup IN bookseller.basketgroups %]
417
                                                [% IF ( basketgroup.closed ) %]
418
                                                    <tr>
419
                                                        <td>
420
                                                            [% IF ( basketgroup.name ) %]
421
                                                                [% basketgroup.name %]
422
                                                            [% ELSE %]
423
                                                                Basket group no. [% basketgroup.id %]
424
                                                            [% END %]
425
                                                        </td>
426
                                                        <td>[% basketgroup.id %]</td>
427
                                                        <td>[% basketgroup.closeddate |$KohaDates %]</td>
428
                                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
429
                                                        <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %]</td>
430
                                                        <td>[% basketgroup.basketsqty %]</td>
431
                                                        <td>[% basketgroup.ordered_titles_count %]</td>
432
                                                        <td>[% basketgroup.received_titles_count %]</td>
433
                                                        <td>
434
                                                            <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 %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="View" /></form>
435
                                                            <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 %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Reopen" /></form>
436
                                                            <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 %]" /><input type="submit" value="Export as PDF" /></form>
437
                                                            <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 %]" /><input type="submit" value="Export as CSV" /></form>
438
                                                            <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 %]" /><input type="submit" value="Generate EDIFACT order" /></form>
439
                                                        </td>
440
                                                    </tr>
441
                                                [% END %]
442
                                            [% END %]
443
                                        </tbody>
444
                                    </table>
445
                                </div>
446
                            </div>
447
                        [% END %]
448
                    [% END %]
449
                [% END %]
450
            </div>
312
            </div>
451
        </div>
313
        </div>
452
        <div class="yui-b">
314
        <div class="yui-b">
453
            [% IF ( booksellerid ) %]
315
            [% INCLUDE 'vendor-menu.inc' %]
454
                [% INCLUDE 'vendor-menu.inc' %]
455
            [% END %]
456
            [% INCLUDE 'acquisitions-menu.inc' %]
316
            [% INCLUDE 'acquisitions-menu.inc' %]
457
        </div>
317
        </div>
458
    </div>
318
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt (+162 lines)
Line 0 Link Here
1
[% USE Branches %]
2
[% USE KohaDates %]
3
4
[% INCLUDE 'doc-head-open.inc' %]
5
    [% IF bookseller %]
6
        <title>Koha &rsaquo; Basket groups for [% bookseller.name |html %]</title>
7
    [% ELSE %]
8
        <title>Koha &rsaquo; Basket groups</title>
9
    [% END %]
10
11
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
12
    [% INCLUDE 'doc-head-close.inc' %]
13
    [% INCLUDE 'datatables.inc' %]
14
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
15
    <script type="text/javascript">
16
        $(document).ready(function() {
17
            var options = {
18
                "paging": false,
19
                "autoWidth": false,
20
                "columnDefs": [
21
                    { "visible": false, "targets": 1 },
22
                    { "orderable": false, "targets": -1 }
23
                ],
24
                "orderFixed": [[ 1, 'asc' ]]
25
            };
26
            [% UNLESS bookseller %]
27
                options.drawCallback = function(settings) {
28
                    var api = this.api();
29
                    var rows = api.rows({page: 'current'}).nodes();
30
                    var last = null;
31
32
                    api.column(1, {page: 'current'}).data().each(function(group, i) {
33
                        if (last !== group) {
34
                            $(rows).eq(i).before(
35
                                '<tr><td class="group" colspan="8">' + group + '</td></tr>'
36
                            );
37
                            last = group;
38
                        }
39
                    });
40
                };
41
            [% END %]
42
            $("#basketgroups-table").kohaDataTable(options);
43
44
            $('#basketgroups-table').on('click', '.closeandprint', function(e) {
45
                e.preventDefault();
46
                var w = window.open($(this).attr('href'));
47
                var timer = setInterval(function() {
48
                    if (w.closed === true) {
49
                        clearInterval(timer);
50
                        window.location.reload(true);
51
                    }
52
                }, 1000);
53
            });
54
            $('#basketgroups-table').on('click', '.delete', function() {
55
                return confirm(_("Are you sure you want to delete this basketgroup ?"));
56
            });
57
        });
58
    </script>
59
</head>
60
<body id="acq_basketgroup" class="acq">
61
    [% INCLUDE 'header.inc' %]
62
    [% INCLUDE 'acquisitions-search.inc' %]
63
64
    <div id="breadcrumbs">
65
        <a href="/cgi-bin/koha/mainpage.pl">Home</a>
66
        &rsaquo;
67
        <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
68
        &rsaquo;
69
        [% IF (bookseller) %]
70
            <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name |html %]</a>
71
            &rsaquo;
72
        [% END %]
73
        Basket groups
74
    </div>
75
76
    <div id="doc3" class="yui-t2">
77
        <div id="bd">
78
            <div id="yui-main">
79
                <div class="yui-b">
80
                    [% IF bookseller %]
81
                        <div id="toolbar" class="btn-toolbar">
82
                            <div class="btn-group">
83
                                <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>
84
                            </div>
85
                        </div>
86
87
                        <h1>Basket groups for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a></h1>
88
                    [% END %]
89
90
                    [% IF basketgroups.size > 0 %]
91
                        <table id="basketgroups-table" class="group">
92
                            <thead>
93
                                <tr>
94
                                    <th>Name</th>
95
                                    <th>Bookseller</th>
96
                                    <th>Billing place</th>
97
                                    <th>Delivery place</th>
98
                                    <th>No. of baskets</th>
99
                                    <th>No. of ordered titles</th>
100
                                    <th>No. of received titles</th>
101
                                    <th>Date closed</th>
102
                                    <th>Action</th>
103
                                </tr>
104
                            </thead>
105
                            <tbody>
106
                                [% FOREACH basketgroup IN basketgroups %]
107
                                    <tr>
108
                                        <td>
109
                                            [% IF ( basketgroup.name ) %]
110
                                                [% basketgroup.name %]
111
                                            [% ELSE %]
112
                                                Basket group no. [% basketgroup.id %]
113
                                            [% END %]
114
                                        </td>
115
                                        <td>[% basketgroup.bookseller.name %]</td>
116
                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
117
                                        <td>
118
                                            [% IF (basketgroup.freedeliveryplace) %]
119
                                                [% basketgroup.freedeliveryplace %]
120
                                            [% ELSE %]
121
                                                [% Branches.GetName(basketgroup.deliveryplace) %]
122
                                            [% END %]
123
                                        </td>
124
                                        <td>[% basketgroup.baskets_count %]</td>
125
                                        <td>[% basketgroup.ordered_titles_count %]</td>
126
                                        <td>[% basketgroup.received_titles_count %]</td>
127
                                        <td>[% basketgroup.closeddate | $KohaDates %]</td>
128
                                        <td>
129
                                            <div class="dropdown">
130
                                            <a class="btn btn-default btn-xs dropdown-toggle" id="actions-[% basketgroup.id %]" role="button" data-toggle="dropdown">Actions <b class="caret"></b></a>
131
                                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="actions-[% basketgroup.id %]">
132
                                            [% IF basketgroup.closeddate %]
133
                                                <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>
134
                                                <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>
135
                                                <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>
136
                                                <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>
137
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=ediprint&baskegroupid=[% basketgroup.id %]">Generate EDIFACT Order</a></li>
138
                                            [% ELSE %]
139
                                                <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>
140
                                                <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>
141
                                                [% UNLESS basketgroup.baskets_count %]
142
                                                    <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>
143
                                                [% END %]
144
                                            [% END %]
145
                                            </ul>
146
                                            </div>
147
                                        </td>
148
                                    </tr>
149
                                [% END %]
150
                            </tbody>
151
                        </table>
152
                    [% END %]
153
                </div>
154
            </div>
155
            <div class="yui-b">
156
                [% IF bookseller %]
157
                    [% INCLUDE 'vendor-menu.inc' booksellerid = bookseller.id %]
158
                [% END %]
159
                [% INCLUDE 'acquisitions-menu.inc' %]
160
            </div>
161
        </div>
162
    [% 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 (-20 / +58 lines)
Lines 1-34 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
    },
36
    "dom": '<"top pager"ilpf>tr<"bottom pager"ip>',
37
    "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
38
    "pageLength": 20
39
};
40
8
var dataTablesDefaults = {
41
var dataTablesDefaults = {
9
    "oLanguage": {
42
    "oLanguage": {
10
        "oPaginate": {
43
        "oPaginate": {
11
            "sFirst"    : window.MSG_DT_FIRST || "First",
44
            "sFirst"    : DataTableDefaults.language.paginate.first,
12
            "sLast"     : window.MSG_DT_LAST || "Last",
45
            "sLast"     : DataTableDefaults.language.paginate.last,
13
            "sNext"     : window.MSG_DT_NEXT || "Next",
46
            "sNext"     : DataTableDefaults.language.paginate.next,
14
            "sPrevious" : window.MSG_DT_PREVIOUS || "Previous"
47
            "sPrevious" : DataTableDefaults.language.paginate.previous,
15
        },
48
        },
16
        "sEmptyTable"       : window.MSG_DT_EMPTY_TABLE || "No data available in table",
49
        "sEmptyTable"       : DataTableDefaults.language.emptyTable,
17
        "sInfo"             : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries",
50
        "sInfo"             : DataTableDefaults.language.info,
18
        "sInfoEmpty"        : window.MSG_DT_INFO_EMPTY || "No entries to show",
51
        "sInfoEmpty"        : DataTableDefaults.language.infoEmpty,
19
        "sInfoFiltered"     : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)",
52
        "sInfoFiltered"     : DataTableDefaults.language.infoFiltered,
20
        "sLengthMenu"       : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries",
53
        "sLengthMenu"       : DataTableDefaults.language.lengthMenu,
21
        "sLoadingRecords"   : window.MSG_DT_LOADING_RECORDS || "Loading...",
54
        "sLoadingRecords"   : DataTableDefaults.language.loadingRecords,
22
        "sProcessing"       : window.MSG_DT_PROCESSING || "Processing...",
55
        "sProcessing"       : DataTableDefaults.language.processing,
23
        "sSearch"           : window.MSG_DT_SEARCH || "Search:",
56
        "sSearch"           : DataTableDefaults.language.search,
24
        "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found"
57
        "sZeroRecords"      : DataTableDefaults.language.zeroRecords,
25
    },
58
    },
26
    "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
59
    "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
27
    "buttons": [],
60
    "buttons": [],
28
    "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
61
    "aLengthMenu": DataTableDefaults.lengthMenu,
29
    "iDisplayLength": 20
62
    "iDisplayLength": DataTableDefaults.pageLength
30
};
63
};
31
64
65
(function($) {
66
    $.fn.kohaDataTable = function(options) {
67
        return this.DataTable($.extend(true, {}, DataTableDefaults, options));
68
    };
69
})(jQuery);
70
32
71
33
// Return an array of string containing the values of a particular column
72
// Return an array of string containing the values of a particular column
34
$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
73
$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
35
- 

Return to bug 11708