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 19-24 Link Here
19
    var MSG_DT_SEARCH = _("Search:");
19
    var MSG_DT_SEARCH = _("Search:");
20
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
20
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
21
    var MSG_DT_ALL = _("All");
21
    var MSG_DT_ALL = _("All");
22
    var MSG_DT_SORT_ASC = _(": activate to sort column ascending");
23
    var MSG_DT_SORT_DESC = _(": activate to sort column descending");
22
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
24
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
23
//]]>
25
//]]>
24
</script>
26
</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 15-21 Link Here
15
<script type="text/javascript" src="[% interface %]/lib/yui/container/container_core-min.js"></script>
15
<script type="text/javascript" src="[% interface %]/lib/yui/container/container_core-min.js"></script>
16
<script type="text/javascript" src="[% interface %]/lib/yui/menu/menu-min.js"></script>
16
<script type="text/javascript" src="[% interface %]/lib/yui/menu/menu-min.js"></script>
17
<script type="text/javascript" src="[% interface %]/[% theme %]/js/basketgroup.js"></script>
17
<script type="text/javascript" src="[% interface %]/[% theme %]/js/basketgroup.js"></script>
18
[% IF ( grouping ) %]
19
<script type="text/javascript" src="[% interface %]/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
18
<script type="text/javascript" src="[% interface %]/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
20
<script type="text/javascript" src="[% interface %]/lib/yui/animation/animation-min.js"></script>
19
<script type="text/javascript" src="[% interface %]/lib/yui/animation/animation-min.js"></script>
21
<script type="text/javascript" src="[% interface %]/lib/yui/dragdrop/dragdrop-min.js"></script>
20
<script type="text/javascript" src="[% interface %]/lib/yui/dragdrop/dragdrop-min.js"></script>
Lines 91-97 fieldset.various li { Link Here
91
}
90
}
92
91
93
</style>
92
</style>
94
 [% END %]
95
<script type="text/javascript">
93
<script type="text/javascript">
96
//<![CDATA[
94
//<![CDATA[
97
	YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
95
	YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
Lines 154-457 function submitForm(form) { Link Here
154
[% INCLUDE 'acquisitions-search.inc' %]
152
[% INCLUDE 'acquisitions-search.inc' %]
155
153
156
<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;
154
<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;
157
[% IF ( grouping ) %]
155
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a>
158
    <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 %]
156
    &rsaquo;
159
[% ELSE %]
157
    <a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid %]">Basket groups</a>
160
  [% IF (booksellerid) %]
158
    &rsaquo;
161
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a> &rsaquo;
159
    Add basket group for [% booksellername |html %]
162
  [% END %]
163
  Basket groups
164
[% END %]
165
</div>
160
</div>
166
161
167
<div id="doc3" class="yui-t2">
162
<div id="doc3" class="yui-t2">
168
    <div id="bd">
163
    <div id="bd">
169
        <div id="yui-main">
164
        <div id="yui-main">
170
            <div class="yui-b">
165
            <div class="yui-b">
171
                [% IF ( grouping ) %]
166
                [% IF (closedbg) %]
172
                    [% IF (closedbg) %]
167
                    <div id="toolbar" class="btn-toolbar">
173
                        <div id="toolbar" class="btn-toolbar">
168
                        <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>
174
                            <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>
169
                        <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>
175
                            <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>
170
                        <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>
176
                            <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>
171
                        <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>
177
                            <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>
172
                    </div>
173
                [% END %]
174
                [% IF (name && closedbg) %]
175
                    <h1>Basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
176
                [% ELSIF (name) %]
177
                    <h1>Edit basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
178
                [% ELSE %]
179
                    <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
180
                [% END %]
181
                <div id="basketgroupcolumns" class="yui-g">
182
                    [% UNLESS (closedbg) %]
183
                        <div class="yui-u">
184
                            <form action="[% scriptname %]" method="post" name="basketgroups" id="basketgroups">
185
                                <div id="groups">
186
                                    <fieldset class="brief">
187
                                        <div class="workarea_alt" >
188
                                            <h3>Ungrouped baskets</h3>
189
                                            <ul id="ungrouped" class="draglist_alt">
190
                                                [% IF ( baskets ) %]
191
                                                    [% FOREACH basket IN baskets %]
192
                                                        <li class="ungrouped" id="b-[% basket.basketno %]" >
193
                                                            <a href="basket.pl?basketno=[% basket.basketno %]">
194
                                                                [% IF ( basket.basketname ) %]
195
                                                                    [% basket.basketname %]
196
                                                                [% ELSE %]
197
                                                                    No name, basketnumber: [% basket.basketno %]
198
                                                                [% END %]
199
                                                            </a>, <br />
200
                                                            Total: [% basket.total %]
201
                                                            <input type="hidden" class="basket" name="basket" value="[% basket.basketno %]" />
202
                                                        </li>
203
                                                    [% END %]
204
                                                [% END %]
205
                                            </ul>
206
                                        </div>
207
                                    </fieldset>
208
                                </div>
209
                            </form>
178
                        </div>
210
                        </div>
179
                    [% END %]
211
                    [% END %]
180
                    [% IF (name && closedbg) %]
212
                    <div class="yui-u first">
181
                        <h1>Basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
213
                        <form action="" method="post" id="groupingform" onsubmit="return submitForm(this)">
182
                    [% ELSIF (name) %]
214
                            <fieldset id="various" class="brief">
183
                        <h1>Edit basket group [% name %] ([% basketgroupid %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
215
                                <ol>
184
                    [% ELSE %]
216
                                    [% UNLESS (closedbg) %]
185
                        <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername |html %]</a></h1>
217
                                        <li>
186
                    [% END %]
218
                                            <label for="basketgroupname">Basket group name:</label>
187
                    <div id="basketgroupcolumns" class="yui-g">
219
                                            <input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" class="focus" />
188
                        [% UNLESS (closedbg) %]
220
                                        </li>
189
                            <div class="yui-u">
221
                                    [% ELSE %]
190
                                <form action="[% scriptname %]" method="post" name="basketgroups" id="basketgroups">
222
                                        <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% name %]" />
191
                                    <div id="groups">
223
                                    [% END %]
192
                                        <fieldset class="brief">
224
                                    <li>
193
                                            <div class="workarea_alt" >
194
                                                <h3>Ungrouped baskets</h3>
195
                                                <ul id="ungrouped" class="draglist_alt">
196
                                                    [% IF ( baskets ) %]
197
                                                        [% FOREACH basket IN baskets %]
198
                                                            <li class="ungrouped" id="b-[% basket.basketno %]" >
199
                                                                <a href="basket.pl?basketno=[% basket.basketno %]">
200
                                                                    [% IF ( basket.basketname ) %]
201
                                                                        [% basket.basketname %]
202
                                                                    [% ELSE %]
203
                                                                        No name, basketnumber: [% basket.basketno %]
204
                                                                    [% END %]
205
                                                                </a>, <br />
206
                                                                Total: [% basket.total %]
207
                                                                <input type="hidden" class="basket" name="basket" value="[% basket.basketno %]" />
208
                                                            </li>
209
                                                        [% END %]
210
                                                    [% END %]
211
                                                </ul>
212
                                            </div>
213
                                        </fieldset>
214
                                    </div>
215
                                </form>
216
                            </div>
217
                        [% END %]
218
                        <div class="yui-u first">
219
                            <form action="" method="post" id="groupingform" onsubmit="return submitForm(this)">
220
                                <fieldset id="various" class="brief">
221
                                    <ol>
222
                                        [% UNLESS (closedbg) %]
225
                                        [% UNLESS (closedbg) %]
223
                                            <li>
226
                                            <label for="billingplace">Billing place:</label>
224
                                                <label for="basketgroupname">Basket group name:</label>
227
                                            <select name="billingplace" id="billingplace" style="width:13em;">
225
                                                <input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" class="focus" />
228
                                                <option value="">--</option>
226
                                            </li>
229
                                                [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %]
230
                                            </select>
227
                                        [% ELSE %]
231
                                        [% ELSE %]
228
                                            <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% name %]" />
232
                                            <span class="label">Billing place:</span>
233
                                            <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace %]" />[% Branches.GetName( billingplace ) %]
229
                                        [% END %]
234
                                        [% END %]
235
                                    </li>
236
                                    [% UNLESS (closedbg) %]
230
                                        <li>
237
                                        <li>
231
                                            [% UNLESS (closedbg) %]
238
                                            <label for="deliveryplace">Delivery place:</label>
232
                                                <label for="billingplace">Billing place:</label>
239
                                            <select name="deliveryplace" id="deliveryplace" style="width:13em;">
233
                                                <select name="billingplace" id="billingplace" style="width:13em;">
240
                                                <option value="">--</option>
234
                                                    <option value="">--</option>
241
                                                [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %]
235
                                                    [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %]
242
                                            <select>
236
                                                </select>
237
                                            [% ELSE %]
238
                                                <span class="label">Billing place:</span>
239
                                                <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace %]" />[% Branches.GetName( billingplace ) %]
240
                                            [% END %]
241
                                        </li>
243
                                        </li>
242
                                        [% UNLESS (closedbg) %]
244
                                        <li><p>or</p></li>
243
                                            <li>
245
                                        <li>
244
                                                <label for="deliveryplace">Delivery place:</label>
246
                                            <label for="freedeliveryplace">Delivery place:</label>
245
                                                <select name="deliveryplace" id="deliveryplace" style="width:13em;">
247
                                            <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% freedeliveryplace %]</textarea>
246
                                                    <option value="">--</option>
248
                                        </li>
247
                                                    [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %]
249
                                        [% ELSE %]
248
                                                <select>
249
                                            </li>
250
                                            <li><p>or</p></li>
251
                                            <li>
252
                                                <label for="freedeliveryplace">Delivery place:</label>
253
                                                <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% freedeliveryplace %]</textarea>
254
                                            </li>
255
                                            [% ELSE %]
256
                                                <li>
257
                                                    <span class="label">Delivery place:</span>
258
                                                    [% IF (freedeliveryplace) %]
259
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% freedeliveryplace %]" />[% freedeliveryplace %]
260
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" />
261
                                                    [% ELSE %]
262
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% deliveryplace %]" />[% Branches.GetName( deliveryplace ) %]
263
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" />
264
                                                    [% END %]
265
                                                </li>
266
                                            [% END %]
267
                                            <li>
250
                                            <li>
268
                                                [% UNLESS (closedbg) %]
251
                                                <span class="label">Delivery place:</span>
269
                                                    <label for="deliverycomment">Delivery comment:</label>
252
                                                [% IF (freedeliveryplace) %]
270
                                                    <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% deliverycomment %]</textarea>
253
                                                    <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% freedeliveryplace %]" />[% freedeliveryplace %]
254
                                                    <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" />
271
                                                [% ELSE %]
255
                                                [% ELSE %]
272
                                                    <span class="label">Delivery comment:</span>[% deliverycomment %]
256
                                                    <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% deliveryplace %]" />[% Branches.GetName( deliveryplace ) %]
273
                                                    <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% deliverycomment %]" />
257
                                                    <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" />
274
                                                [% END %]
258
                                                [% END %]
275
                                            </li>
259
                                            </li>
276
                                            <li>
260
                                        [% END %]
277
                                                <span class="label">Baskets in this group:</span>
261
                                        <li>
278
                                                [% UNLESS (closedbg) %]
262
                                            [% UNLESS (closedbg) %]
279
                                                    <ul class="draglist" id="bg">
263
                                                <label for="deliverycomment">Delivery comment:</label>
280
                                                [% ELSE %]
264
                                                <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% deliverycomment %]</textarea>
281
                                                    <ul>
265
                                            [% ELSE %]
282
                                                [% END %]
266
                                                <span class="label">Delivery comment:</span>[% deliverycomment %]
283
                                                [% FOREACH selectedbasket IN selectedbaskets %]
267
                                                <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% deliverycomment %]" />
284
                                                    <li class="grouped" id="b-[% selectedbasket.basketno %]" >
268
                                            [% END %]
285
                                                        <a href="basket.pl?basketno=[% selectedbasket.basketno %]">
286
                                                            [% IF ( selectedbasket.basketname ) %]
287
                                                                [% selectedbasket.basketname %]
288
                                                            [% ELSE %]
289
                                                                No name, basketnumber: [% selectedbasket.basketno %]
290
                                                            [% END %]
291
                                                        </a>, <br />
292
                                                        Total: [% selectedbasket.total %]
293
                                                        <input type="hidden" class="basket" name="basket" value="[% selectedbasket.basketno %]" />
294
                                                    </li>
295
                                                [% END %]
296
                                            </ul>
297
                                        </li>
269
                                        </li>
270
                                        <li>
271
                                            <span class="label">Baskets in this group:</span>
298
                                            [% UNLESS (closedbg) %]
272
                                            [% UNLESS (closedbg) %]
299
                                                <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li>
273
                                                <ul class="draglist" id="bg">
300
                                            [% ELSE %]
274
                                            [% ELSE %]
301
                                                <input type="hidden" id="closedbg" name="closedbg" value ="1"/>
275
                                                <ul>
302
                                            [% END %]
276
                                            [% END %]
303
                                    </ol>
277
                                            [% FOREACH selectedbasket IN selectedbaskets %]
304
                                </fieldset>
278
                                                <li class="grouped" id="b-[% selectedbasket.basketno %]" >
305
                                [% UNLESS (closedbg) %]
279
                                                    <a href="basket.pl?basketno=[% selectedbasket.basketno %]">
306
                                    <fieldset class="action"><input type="hidden" name="booksellerid" value="[% booksellerid %]" />
280
                                                        [% IF ( selectedbasket.basketname ) %]
307
                                        [% IF ( basketgroupid ) %]
281
                                                            [% selectedbasket.basketname %]
308
                                            <input type="hidden" name="basketgroupid" value="[% basketgroupid %]" />
282
                                                        [% ELSE %]
283
                                                            No name, basketnumber: [% selectedbasket.basketno %]
284
                                                        [% END %]
285
                                                    </a>, <br />
286
                                                    Total: [% selectedbasket.total %]
287
                                                    <input type="hidden" class="basket" name="basket" value="[% selectedbasket.basketno %]" />
288
                                                </li>
289
                                            [% END %]
290
                                        </ul>
291
                                    </li>
292
                                        [% UNLESS (closedbg) %]
293
                                            <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li>
294
                                        [% ELSE %]
295
                                            <input type="hidden" id="closedbg" name="closedbg" value ="1"/>
309
                                        [% END %]
296
                                        [% END %]
310
                                        <input type="hidden" name="op" value="attachbasket" />
297
                                </ol>
311
                                        <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]" class="cancel">Cancel</a>
298
                            </fieldset>
312
                                    </fieldset>
299
                            [% UNLESS (closedbg) %]
313
                                [% END %]
300
                                <fieldset class="action"><input type="hidden" name="booksellerid" value="[% booksellerid %]" />
314
                            </form>
301
                                    [% IF ( basketgroupid ) %]
315
                        </div>
302
                                        <input type="hidden" name="basketgroupid" value="[% basketgroupid %]" />
303
                                    [% END %]
304
                                    <input type="hidden" name="op" value="attachbasket" />
305
                                    <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]" class="cancel">Cancel</a>
306
                                </fieldset>
307
                            [% END %]
308
                        </form>
316
                    </div>
309
                    </div>
317
                [% ELSE %]
310
                </div>
318
                    [% IF booksellerid %]
319
                        <div id="toolbar" class="btn-toolbar">
320
                            <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>
321
                        </div>
322
                    [% END %]
323
324
                    [% FOREACH bookseller IN booksellers %]
325
                        [% IF bookseller.basketgroups.size > 0 %]
326
                            <h1>Basket groups for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name |html %]</a></h1>
327
                            <div class="basket_groups toptabs">
328
                                <ul class="ui-tabs-nav">
329
                                    [% UNLESS ( listclosed) %]<li class="ui-tabs-active"><a href="#opened[% bookseller.id %]">Open</a></li>
330
                                    [% ELSE%]<li><a href="#opened[% bookseller.id %]">Open</a></li>[% END %]
331
                                    [% IF ( listclosed) %]<li class="ui-tabs-active"><a href="#closed[% bookseller.id %]">Closed</a></li>
332
                                    [% ELSE %]<li><a href="#closed[% bookseller.id %]">Closed</a></li>[% END %]
333
                                </ul>
334
                                <div id="opened[% bookseller.id %]">
335
                                    <table id="basket_group_opened">
336
                                        <thead>
337
                                            <tr>
338
                                                <th>Search name</th>
339
                                                <th>Search no.</th>
340
                                                <th>Search billing place</th>
341
                                                <th>Search delivery place</th>
342
                                                <th>Search no. of baskets</th>
343
                                                <th>Search no. of ordered titles</th>
344
                                                <th>Search no. of received titles</th>
345
                                                <th></th>
346
                                            </tr>
347
                                            <tr>
348
                                                <th>Name</th>
349
                                                <th>No.</th>
350
                                                <th>Billing place</th>
351
                                                <th>Delivery place</th>
352
                                                <th>No. of baskets</th>
353
                                                <th>No. of ordered titles</th>
354
                                                <th>No. of received titles</th>
355
                                                <th>Action</th>
356
                                            </tr>
357
                                        </thead>
358
                                        <tbody>
359
                                            [% FOREACH basketgroup IN bookseller.basketgroups %]
360
                                                [% UNLESS ( basketgroup.closed ) %]
361
                                                    <tr>
362
                                                        <td>
363
                                                            [% IF ( basketgroup.name ) %]
364
                                                                [% basketgroup.name %]
365
                                                            [% ELSE %]
366
                                                                Basket group no. [% basketgroup.id %]
367
                                                            [% END %]
368
                                                        </td>
369
                                                        <td>[% basketgroup.id %]</td>
370
                                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
371
                                                        <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %]</td>
372
                                                        <td>[% basketgroup.basketsqty %]</td>
373
                                                        <td>[% basketgroup.ordered_titles_count %]</td>
374
                                                        <td>[% basketgroup.received_titles_count %]</td>
375
                                                        <td>
376
                                                            <input type="button" onclick="closeandprint('[% basketgroup.id %]');" value="Close and export as PDF" />
377
                                                            <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>
378
                                                            [% UNLESS basketgroup.basketsqty %]
379
                                                                <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>
380
                                                            [% END %]
381
                                                        </td>
382
                                                    </tr>
383
                                                [% END %]
384
                                            [% END %]
385
                                        </tbody>
386
                                    </table>
387
                                </div>
388
                                <div id="closed[% bookseller.id %]">
389
                                    <table class="basket_group_closed">
390
                                        <thead>
391
                                            <tr>
392
                                                <th>Search name</th>
393
                                                <th>Search no.</th>
394
                                                <th>Search date closed</th>
395
                                                <th>Search billing place</th>
396
                                                <th>Search delivery place</th>
397
                                                <th>Search no. of baskets</th>
398
                                                <th>Search no. of ordered titles</th>
399
                                                <th>Search no. of received titles</th>
400
                                                <th></th>
401
                                            </tr>
402
                                            <tr>
403
                                                <th>Name</th>
404
                                                <th>No.</th>
405
                                                <th>Date closed</th>
406
                                                <th>Billing place</th>
407
                                                <th>Delivery place</th>
408
                                                <th>No. of baskets</th>
409
                                                <th>No. of ordered titles</th>
410
                                                <th>No. of received titles</th>
411
                                                <th>Action</th>
412
                                            </tr>
413
                                        </thead>
414
                                        <tbody>
415
                                            [% FOREACH basketgroup IN bookseller.basketgroups %]
416
                                                [% IF ( basketgroup.closed ) %]
417
                                                    <tr>
418
                                                        <td>
419
                                                            [% IF ( basketgroup.name ) %]
420
                                                                [% basketgroup.name %]
421
                                                            [% ELSE %]
422
                                                                Basket group no. [% basketgroup.id %]
423
                                                            [% END %]
424
                                                        </td>
425
                                                        <td>[% basketgroup.id %]</td>
426
                                                        <td>[% basketgroup.closeddate |$KohaDates %]</td>
427
                                                        <td>[% Branches.GetName(basketgroup.billingplace) %]</td>
428
                                                        <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName(basketgroup.deliveryplace) %][% END %]</td>
429
                                                        <td>[% basketgroup.basketsqty %]</td>
430
                                                        <td>[% basketgroup.ordered_titles_count %]</td>
431
                                                        <td>[% basketgroup.received_titles_count %]</td>
432
                                                        <td>
433
                                                            <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>
434
                                                            <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>
435
                                                            <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>
436
                                                            <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>
437
                                                            <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>
438
                                                        </td>
439
                                                    </tr>
440
                                                [% END %]
441
                                            [% END %]
442
                                        </tbody>
443
                                    </table>
444
                                </div>
445
                            </div>
446
                        [% END %]
447
                    [% END %]
448
                [% END %]
449
            </div>
311
            </div>
450
        </div>
312
        </div>
451
        <div class="yui-b">
313
        <div class="yui-b">
452
            [% IF ( booksellerid ) %]
314
            [% INCLUDE 'vendor-menu.inc' %]
453
                [% INCLUDE 'vendor-menu.inc' %]
454
            [% END %]
455
            [% INCLUDE 'acquisitions-menu.inc' %]
315
            [% INCLUDE 'acquisitions-menu.inc' %]
456
        </div>
316
        </div>
457
    </div>
317
    </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