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

(-)a/Koha/Acquisition/Basket.pm (+37 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Acquisition::BasketGroups;
23
use Koha::Acquisition::BasketGroups;
24
use Koha::Acquisition::Orders;
24
25
25
use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields );
26
use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields );
26
27
Lines 71-76 sub effective_create_items { Link Here
71
    return $self->create_items || C4::Context->preference('AcqCreateItem');
72
    return $self->create_items || C4::Context->preference('AcqCreateItem');
72
}
73
}
73
74
75
=head3 orders
76
77
Returns basket's orders
78
79
    # As an arrayref
80
    my $orders = $basket->orders;
81
82
    # As an array
83
    my @orders = $basket->orders;
84
85
=cut
86
87
sub orders {
88
    my ($self) = @_;
89
90
    $self->{_orders} ||= Koha::Acquisition::Orders->search({ basketno => $self->basketno });
91
92
    return wantarray ? $self->{_orders}->as_list : $self->{_orders};
93
}
94
95
sub total {
96
    my ($self) = @_;
97
98
    my $total = 0;
99
    for my $order ($self->orders){
100
        # FIXME The following is wrong
101
        if ( $self->bookseller->listincgst ) {
102
            $total = $total + ( $order->ecost_tax_included * $order->quantity );
103
        } else {
104
            $total = $total + ( $order->ecost_tax_excluded * $order->quantity );
105
        }
106
    }
107
    return $total;
108
}
109
110
74
=head2 Internal methods
111
=head2 Internal methods
75
112
76
=head3 _type
113
=head3 _type
(-)a/Koha/Acquisition/BasketGroup.pm (-1 / +91 lines)
Lines 17-23 package Koha::Acquisition::BasketGroup; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use List::MoreUtils qw/uniq/;
21
20
use Koha::Database;
22
use Koha::Database;
23
use Koha::Acquisition::Baskets;
21
24
22
use base qw( Koha::Object );
25
use base qw( Koha::Object );
23
26
Lines 27-36 Koha::Acquisition::BasketGroup - Koha Basket group Object class Link Here
27
30
28
=head1 API
31
=head1 API
29
32
30
=head2 Class Methods
33
=head2 Methods
34
35
=head3 vendor
36
37
Returns the basketgroup's vendor (Koha::Acquisition::Bookseller)
38
39
    my $vendor = $basketgroup->vendor;
40
41
=cut
42
43
sub vendor {
44
    my ($self) = @_;
45
46
    return scalar Koha::Acquisition::Booksellers->find($self->booksellerid);
47
}
48
49
=head3 baskets
50
51
Returns the basketgroup's baskets
52
53
    my $baskets = $basketgroup->baskets;    # Koha::Acquisition::Baskets
54
    my @baskets = $basketgroup->baskets;    # array of Koha::Acquisition::Basket
55
56
=cut
57
58
sub baskets {
59
    my ($self) = @_;
60
61
    my $baskets = Koha::Acquisition::Baskets->search({ basketgroupid => $self->id });
62
63
    return wantarray ? $baskets->as_list : $baskets;
64
}
65
66
=head3 baskets_count
67
68
Returns the number of baskets contained in a basket group
69
70
    my $count = $basketgroup->baskets_count;
31
71
32
=cut
72
=cut
33
73
74
sub baskets_count {
75
    my ($self) = @_;
76
77
    return $self->baskets->count;
78
}
79
80
=head3 ordered_titles_count
81
82
Returns the number of ordered titles contained in a basket group
83
84
    my $count = $basketgroup->ordered_titles_count;
85
86
=cut
87
88
sub ordered_titles_count {
89
    my ($self) = @_;
90
91
    my @biblionumbers;
92
    foreach my $basket ($self->baskets) {
93
        foreach my $order ($basket->orders) {
94
            push @biblionumbers, $order->biblionumber;
95
        }
96
    }
97
98
    return scalar uniq @biblionumbers;
99
}
100
101
=head3 received_titles_count
102
103
Returns the number of received titles contained in a basket group
104
105
    my $count = $basketgroup->ordered_titles_count;
106
107
=cut
108
109
sub received_titles_count {
110
    my ($self) = @_;
111
112
    my @biblionumbers;
113
    foreach my $basket ($self->baskets) {
114
        foreach my $order ($basket->orders) {
115
            if ($order->datereceived) {
116
                push @biblionumbers, $order->biblionumber;
117
            }
118
        }
119
    }
120
121
    return scalar uniq @biblionumbers;
122
}
123
34
=head2 Internal methods
124
=head2 Internal methods
35
125
36
=head3 _type
126
=head3 _type
(-)a/acqui/basket.pl (-2 / +2 lines)
Lines 211-217 if ( $op eq 'delete_confirm' ) { Link Here
211
                            });
211
                            });
212
            ModBasket( { basketno => $basketno,
212
            ModBasket( { basketno => $basketno,
213
                         basketgroupid => $basketgroupid } );
213
                         basketgroupid => $basketgroupid } );
214
            print $query->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid='.$booksellerid.'&closed=1');
214
            print $query->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid='.$booksellerid);
215
        } else {
215
        } else {
216
            print $query->redirect('/cgi-bin/koha/acqui/booksellers.pl?booksellerid=' . $booksellerid);
216
            print $query->redirect('/cgi-bin/koha/acqui/booksellers.pl?booksellerid=' . $booksellerid);
217
        }
217
        }
Lines 563-569 sub edi_close_and_order { Link Here
563
                }
563
                }
564
            );
564
            );
565
            print $query->redirect(
565
            print $query->redirect(
566
"/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=$booksellerid&closed=1"
566
                "/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=$booksellerid"
567
            );
567
            );
568
        }
568
        }
569
        else {
569
        else {
(-)a/acqui/basketgroup.pl (-184 / +85 lines)
Lines 56-126 use Koha::EDI qw/create_edi_order get_edifact_ean/; Link Here
56
56
57
use Koha::Biblioitems;
57
use Koha::Biblioitems;
58
use Koha::Acquisition::Booksellers;
58
use Koha::Acquisition::Booksellers;
59
use Koha::Acquisition::BasketGroups;
59
use Koha::ItemTypes;
60
use Koha::ItemTypes;
60
use Koha::Patrons;
61
use Koha::Patrons;
61
62
62
our $input=new CGI;
63
my $input = new CGI;
63
64
our ($template, $loggedinuser, $cookie)
65
    = get_template_and_user({template_name => "acqui/basketgroup.tt",
66
			     query => $input,
67
			     type => "intranet",
68
			     authnotrequired => 0,
69
			     flagsrequired => {acquisition => 'group_manage'},
70
			     debug => 1,
71
                });
72
73
sub BasketTotal {
74
    my $basketno = shift;
75
    my $bookseller = shift;
76
    my $total = 0;
77
    my @orders = GetOrders($basketno);
78
    for my $order (@orders){
79
        # FIXME The following is wrong
80
        if ( $bookseller->listincgst ) {
81
            $total = $total + ( get_rounded_price($order->{ecost_tax_included}) * $order->{quantity} );
82
        } else {
83
            $total = $total + ( get_rounded_price($order->{ecost_tax_excluded}) * $order->{quantity} );
84
        }
85
    }
86
    return $total;
87
}
88
64
89
#displays all basketgroups and all closed baskets (in their respective groups)
65
our ($template, $loggedinuser, $cookie) = get_template_and_user({
90
sub displaybasketgroups {
66
    template_name => "acqui/basketgroup.tt",
91
    my $basketgroups = shift;
67
    query => $input,
92
    my $bookseller = shift;
68
    type => "intranet",
93
    my $baskets = shift;
69
    authnotrequired => 0,
94
    if (scalar @$basketgroups != 0) {
70
    flagsrequired => {acquisition => 'group_manage'},
95
        foreach my $basketgroup (@$basketgroups){
71
    debug => 1,
96
            my $i = 0;
72
});
97
            my $basketsqty = 0;
98
            while($i < scalar(@$baskets)){
99
                my $basket = @$baskets[$i];
100
                if($basket->{'basketgroupid'} && $basket->{'basketgroupid'} == $basketgroup->{'id'}){
101
                    $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
102
                    push(@{$basketgroup->{'baskets'}}, $basket);
103
                    splice(@$baskets, $i, 1);
104
                    ++$basketsqty;
105
                    --$i;
106
                }
107
                ++$i;
108
            }
109
            $basketgroup -> {'basketsqty'} = $basketsqty;
110
        }
111
        $template->param(basketgroups => $basketgroups);
112
    }
113
    for(my $i=0; $i < scalar @$baskets; ++$i) {
114
        if( ! @$baskets[$i]->{'closedate'} ) {
115
            splice(@$baskets, $i, 1);
116
            --$i;
117
        }else{
118
            @$baskets[$i]->{total} = BasketTotal(@$baskets[$i]->{basketno}, $bookseller);
119
        }
120
    }
121
    $template->param(baskets => $baskets);
122
    $template->param( booksellername => $bookseller->name);
123
}
124
73
125
sub printbasketgrouppdf{
74
sub printbasketgrouppdf{
126
    my ($basketgroupid) = @_;
75
    my ($basketgroupid) = @_;
Lines 211-217 sub printbasketgrouppdf{ Link Here
211
    );
160
    );
212
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed";
161
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed";
213
    print $pdf;
162
    print $pdf;
214
215
}
163
}
216
164
217
sub generate_edifact_orders {
165
sub generate_edifact_orders {
Lines 232-335 sub generate_edifact_orders { Link Here
232
    return;
180
    return;
233
}
181
}
234
182
235
my $op = $input->param('op') || 'display';
236
# possible values of $op :
183
# possible values of $op :
237
# - add : adds a new basketgroup, or edit an open basketgroup, or display a closed basketgroup
238
# - mod_basket : modify an individual basket of the basketgroup
184
# - mod_basket : modify an individual basket of the basketgroup
239
# - closeandprint : close and print an closed basketgroup in pdf. called by clicking on "Close and print" button in closed basketgroups list
185
# - closeandprint : close and print an closed basketgroup in pdf. called by
240
# - print : print a closed basketgroup. called by clicking on "Print" button in closed basketgroups list
186
#   clicking on "Close and print" button in closed basketgroups list
187
# - print : print a closed basketgroup. called by clicking on "Print" button in
188
#   closed basketgroups list
241
# - ediprint : generate edi order messages for the baskets in the group
189
# - ediprint : generate edi order messages for the baskets in the group
242
# - export : export in CSV a closed basketgroup. called by clicking on "Export" button in closed basketgroups list
190
# - export : export in CSV a closed basketgroup. called by clicking on "Export"
243
# - delete : delete an open basketgroup. called by clicking on "Delete" button in open basketgroups list
191
#   button in closed basketgroups list
244
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button in closed basketgroup list
192
# - delete : delete an open basketgroup. called by clicking on "Delete" button
245
# - attachbasket : save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
193
#   in open basketgroups list
246
# - display : display the list of all basketgroups for a vendor
194
# - reopen : reopen a closed basketgroup. called by clicking on "Reopen" button
195
#   in closed basketgroup list
196
# - attachbasket : save a modified basketgroup, or creates a new basketgroup
197
#   when a basket is closed. called from basket page
198
my $op = $input->param('op');
199
my $basketgroupid = $input->param('basketgroupid');
247
my $booksellerid = $input->param('booksellerid');
200
my $booksellerid = $input->param('booksellerid');
248
$template->param(booksellerid => $booksellerid);
201
249
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
202
my $basketgroup;
203
my $bookseller;
204
if ($basketgroupid) {
205
    $basketgroup = Koha::Acquisition::BasketGroups->find($basketgroupid);
206
    $bookseller = $basketgroup->vendor;
207
} elsif ($booksellerid) {
208
    $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
209
}
250
210
251
my $schema = Koha::Database->new()->schema();
211
my $schema = Koha::Database->new()->schema();
252
my $rs = $schema->resultset('VendorEdiAccount')->search(
212
my $rs = $schema->resultset('VendorEdiAccount')->search(
253
    { vendor_id => $booksellerid, } );
213
    { vendor_id => $booksellerid, } );
254
$template->param( ediaccount => ($rs->count > 0));
214
$template->param( ediaccount => ($rs->count > 0));
255
215
256
if ( $op eq "add" ) {
216
if ($op eq 'mod_basket') {
257
#
217
    # edit an individual basket contained in this basketgroup
258
# if no param('basketgroupid') is not defined, adds a new basketgroup
218
259
# else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid
219
    my $basketno=$input->param('basketno');
260
# the template will know if basketgroup must be displayed or edited, depending on the value of closed key
220
    ModBasket( { basketno => $basketno,
261
#
221
                           basketgroupid => $basketgroupid } );
262
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
222
    print $input->redirect("basket.pl?basketno=" . $basketno);
263
    my $basketgroupid = $input->param('basketgroupid');
264
    my $billingplace;
265
    my $deliveryplace;
266
    my $freedeliveryplace;
267
    if ( $basketgroupid ) {
268
        # Get the selected baskets in the basketgroup to display them
269
        my $selecteds = GetBasketsByBasketgroup($basketgroupid);
270
        foreach my $basket(@{$selecteds}){
271
            $basket->{total} = BasketTotal($basket->{basketno}, $bookseller);
272
        }
273
        $template->param(basketgroupid => $basketgroupid,
274
                         selectedbaskets => $selecteds);
275
276
        # Get general informations about the basket group to prefill the form
277
        my $basketgroup = GetBasketgroup($basketgroupid);
278
        $template->param(
279
            name            => $basketgroup->{name},
280
            deliverycomment => $basketgroup->{deliverycomment},
281
            freedeliveryplace => $basketgroup->{freedeliveryplace},
282
        );
283
        $billingplace  = $basketgroup->{billingplace};
284
        $deliveryplace = $basketgroup->{deliveryplace};
285
        $freedeliveryplace = $basketgroup->{freedeliveryplace};
286
        $template->param( closedbg => ($basketgroup ->{'closed'}) ? 1 : 0);
287
    } else {
288
        $template->param( closedbg => 0);
289
    }
290
    # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
291
    my $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set
292
    $billingplace  = $billingplace  || $patron->branchcode;
293
    $deliveryplace = $deliveryplace || $patron->branchcode;
294
295
    $template->param( billingplace => $billingplace );
296
    $template->param( deliveryplace => $deliveryplace );
297
    $template->param( booksellerid => $booksellerid );
298
299
    # the template will display a unique basketgroup
300
    $template->param(grouping => 1);
301
    my $basketgroups = &GetBasketgroups($booksellerid);
302
    my $baskets = &GetBasketsByBookseller($booksellerid);
303
    displaybasketgroups($basketgroups, $bookseller, $baskets);
304
} elsif ($op eq 'mod_basket') {
305
#
306
# edit an individual basket contained in this basketgroup
307
#
308
  my $basketno=$input->param('basketno');
309
  my $basketgroupid=$input->param('basketgroupid');
310
  ModBasket( { basketno => $basketno,
311
                         basketgroupid => $basketgroupid } );
312
  print $input->redirect("basket.pl?basketno=" . $basketno);
313
} elsif ( $op eq 'closeandprint') {
223
} elsif ( $op eq 'closeandprint') {
314
#
224
    # close an open basketgroup and generates a pdf
315
# close an open basketgroup and generates a pdf
225
316
#
317
    my $basketgroupid = $input->param('basketgroupid');
318
    CloseBasketgroup($basketgroupid);
226
    CloseBasketgroup($basketgroupid);
319
    printbasketgrouppdf($basketgroupid);
227
    printbasketgrouppdf($basketgroupid);
320
    exit;
228
    exit;
321
}elsif ($op eq 'print'){
229
}elsif ($op eq 'print'){
322
#
230
    # print a closed basketgroup
323
# print a closed basketgroup
231
324
#
325
    my $basketgroupid = $input->param('basketgroupid');
326
    printbasketgrouppdf($basketgroupid);
232
    printbasketgrouppdf($basketgroupid);
327
    exit;
233
    exit;
328
}elsif ( $op eq "export" ) {
234
}elsif ( $op eq "export" ) {
329
#
235
    # export a closed basketgroup in csv
330
# export a closed basketgroup in csv
236
331
#
332
    my $basketgroupid = $input->param('basketgroupid');
333
    print $input->header(
237
    print $input->header(
334
        -type       => 'text/csv',
238
        -type       => 'text/csv',
335
        -attachment => 'basketgroup' . $basketgroupid . '.csv',
239
        -attachment => 'basketgroup' . $basketgroupid . '.csv',
Lines 337-365 if ( $op eq "add" ) { Link Here
337
    print GetBasketGroupAsCSV( $basketgroupid, $input );
241
    print GetBasketGroupAsCSV( $basketgroupid, $input );
338
    exit;
242
    exit;
339
}elsif( $op eq "delete"){
243
}elsif( $op eq "delete"){
340
#
244
    # delete an closed basketgroup
341
# delete an closed basketgroup
245
342
#
343
    my $basketgroupid = $input->param('basketgroupid');
344
    DelBasketgroup($basketgroupid);
246
    DelBasketgroup($basketgroupid);
345
    print $input->redirect('/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=' . $booksellerid.'&amp;listclosed=1');
247
    print $input->redirect('/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $bookseller->id);
248
    exit;
346
}elsif ( $op eq 'reopen'){
249
}elsif ( $op eq 'reopen'){
347
#
250
    # reopen a closed basketgroup
348
# reopen a closed basketgroup
251
349
#
350
    my $basketgroupid   = $input->param('basketgroupid');
351
    my $booksellerid    = $input->param('booksellerid');
352
    ReOpenBasketgroup($basketgroupid);
252
    ReOpenBasketgroup($basketgroupid);
353
    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';
253
    my $redirectpath;
254
    my $mode = $input->param('mode');
255
    if (defined $mode && $mode eq 'singlebg') {
256
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$bookseller->id;
257
    } else {
258
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' .$bookseller->id;
259
    }
354
    print $input->redirect($redirectpath);
260
    print $input->redirect($redirectpath);
261
    exit;
355
} elsif ( $op eq 'attachbasket') {
262
} elsif ( $op eq 'attachbasket') {
356
#
263
    # save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
357
# save a modified basketgroup, or creates a new basketgroup when a basket is closed. called from basket page
264
358
#
359
    # Getting parameters
360
    my $basketgroup       = {};
265
    my $basketgroup       = {};
361
    my @baskets           = $input->multi_param('basket');
266
    my @baskets           = $input->multi_param('basket');
362
    my $basketgroupid     = $input->param('basketgroupid');
363
    my $basketgroupname   = $input->param('basketgroupname');
267
    my $basketgroupname   = $input->param('basketgroupname');
364
    my $booksellerid      = $input->param('booksellerid');
268
    my $booksellerid      = $input->param('booksellerid');
365
    my $billingplace      = $input->param('billingplace');
269
    my $billingplace      = $input->param('billingplace');
Lines 368-374 if ( $op eq "add" ) { Link Here
368
    my $deliverycomment   = $input->param('deliverycomment');
272
    my $deliverycomment   = $input->param('deliverycomment');
369
    my $closedbg          = $input->param('closedbg') ? 1 : 0;
273
    my $closedbg          = $input->param('closedbg') ? 1 : 0;
370
    if ($basketgroupid) {
274
    if ($basketgroupid) {
371
    # If we have a basketgroupid we edit the basketgroup
275
        # If we have a basketgroupid we edit the basketgroup
372
        $basketgroup = {
276
        $basketgroup = {
373
              name              => $basketgroupname,
277
              name              => $basketgroupname,
374
              id                => $basketgroupid,
278
              id                => $basketgroupid,
Lines 380-393 if ( $op eq "add" ) { Link Here
380
              closed            => $closedbg,
284
              closed            => $closedbg,
381
        };
285
        };
382
        ModBasketgroup($basketgroup);
286
        ModBasketgroup($basketgroup);
383
        if($closedbg){
287
    } else {
384
# FIXME
288
        # we create a new basketgroup (with a closed basket)
385
        }
386
    }else{
387
    # we create a new basketgroup (with a closed basket)
388
        $basketgroup = {
289
        $basketgroup = {
389
            name              => $basketgroupname,
290
            name              => $basketgroupname,
390
            booksellerid      => $booksellerid,
291
            booksellerid      => $bookseller->id,
391
            basketlist        => \@baskets,
292
            basketlist        => \@baskets,
392
            billingplace      => $billingplace,
293
            billingplace      => $billingplace,
393
            deliveryplace     => $deliveryplace,
294
            deliveryplace     => $deliveryplace,
Lines 397-427 if ( $op eq "add" ) { Link Here
397
        };
298
        };
398
        $basketgroupid = NewBasketgroup($basketgroup);
299
        $basketgroupid = NewBasketgroup($basketgroup);
399
    }
300
    }
400
    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;
301
    my $redirectpath;
401
    $redirectpath .=  "&amp;listclosed=1" if $closedbg ;
302
    my $mode = $input->param('mode');
402
    print $input->redirect($redirectpath );
303
    if (defined $mode && $mode eq 'singlebg') {
403
    
304
        $redirectpath = '/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;basketgroupid='.$basketgroupid.'&amp;booksellerid='.$booksellerid;
305
    } else {
306
        $redirectpath = '/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=' . $booksellerid;
307
    }
308
    print $input->redirect($redirectpath);
309
    exit;
404
} elsif ( $op eq 'ediprint') {
310
} elsif ( $op eq 'ediprint') {
405
    my $basketgroupid = $input->param('basketgroupid');
406
    if ($template->param( 'ediaccount' )) {
311
    if ($template->param( 'ediaccount' )) {
407
        generate_edifact_orders( $basketgroupid );
312
        generate_edifact_orders( $basketgroupid );
408
        exit;
313
        exit;
409
    } else {
314
    } else {
410
        $template->param('NoEDIMessage' => 1);
315
        $template->param('NoEDIMessage' => 1);
411
        my $basketgroups = &GetBasketgroups($booksellerid);
412
        my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
413
        my $baskets = &GetBasketsByBookseller($booksellerid);
414
415
        displaybasketgroups($basketgroups, $bookseller, $baskets);
416
    }
316
    }
417
}else{
418
# no param : display the list of all basketgroups for a given vendor
419
    my $basketgroups = &GetBasketgroups($booksellerid);
420
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
421
    my $baskets = &GetBasketsByBookseller($booksellerid);
422
423
    displaybasketgroups($basketgroups, $bookseller, $baskets);
424
}
317
}
425
$template->param(listclosed => ((defined $input->param('listclosed')) && ($input->param('listclosed') eq '1'))? 1:0 );
318
426
#prolly won't use all these, maybe just use print, the rest can be done inside validate
319
my $borrower = Koha::Patrons->find( $loggedinuser );
320
$template->param(
321
    bookseller => $bookseller,
322
    basketgroup => $basketgroup,
323
    billingplace => $basketgroup ? $basketgroup->billingplace : $borrower->branchcode,
324
    deliveryplace => $basketgroup ? $basketgroup->deliveryplace : $borrower->branchcode,
325
    baskets => [ Koha::Acquisition::Baskets->search({booksellerid => $bookseller->id, basketgroupid => undef}) ],
326
);
327
427
output_html_with_http_headers $input, $cookie, $template->output;
328
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/basketgroups.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use CGI qw(-utf8);
21
22
use C4::Auth;
23
use C4::Output;
24
25
use Koha::Acquisition::BasketGroups;
26
use Koha::Acquisition::Booksellers;
27
28
my $cgi = new CGI;
29
30
my ($template, $loggedinuser, $cookie) = get_template_and_user({
31
    template_name => 'acqui/basketgroups.tt',
32
    query => $cgi,
33
    type => 'intranet',
34
    flagsrequired => { acquisition => 'group_manage' },
35
});
36
37
my $booksellerid = $cgi->param('booksellerid');
38
39
my $params = {};
40
if ($booksellerid) {
41
    $params->{booksellerid} = $booksellerid;
42
    my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
43
    $template->param(bookseller => $bookseller);
44
}
45
46
my @basketgroups = Koha::Acquisition::BasketGroups->search($params);
47
48
$template->param(
49
    basketgroups => \@basketgroups,
50
);
51
52
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc (+3 lines)
Lines 3-8 Link Here
3
        <h5>Acquisitions</h5>
3
        <h5>Acquisitions</h5>
4
        <ul>
4
        <ul>
5
            <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions home</a></li>
5
            <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions home</a></li>
6
            [% IF ( CAN_user_acquisition_group_manage ) %]
7
              <li><a href="/cgi-bin/koha/acqui/basketgroups.pl">Basket groups</a></li>
8
            [% END %]
6
            [% IF ( CAN_user_acquisition_order_receive ) %]<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>[% END %]
9
            [% IF ( CAN_user_acquisition_order_receive ) %]<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>[% END %]
7
            [% IF ( suggestion && CAN_user_acquisition_suggestions_manage ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
10
            [% IF ( suggestion && CAN_user_acquisition_suggestions_manage ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% END %]
8
            <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
11
            <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc (+2 lines)
Lines 17-22 Link Here
17
    var MSG_DT_SEARCH = _("Search:");
17
    var MSG_DT_SEARCH = _("Search:");
18
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
18
    var MSG_DT_ZERO_RECORDS = _("No matching records found");
19
    var MSG_DT_ALL = _("All");
19
    var MSG_DT_ALL = _("All");
20
    var MSG_DT_SORT_ASC = _(": activate to sort column ascending");
21
    var MSG_DT_SORT_DESC = _(": activate to sort column descending");
20
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
22
    var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the");
21
    var MSG_DT_COPY_TITLE = _("Copy to clipboard");
23
    var MSG_DT_COPY_TITLE = _("Copy to clipboard");
22
    var MSG_DT_COPY_KEYS = _("Press ctrl or ⌘ + C to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.");
24
    var MSG_DT_COPY_KEYS = _("Press ctrl or ⌘ + C to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.");
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc (-1 / +1 lines)
Lines 2-8 Link Here
2
<div id="menu">
2
<div id="menu">
3
    <ul>
3
    <ul>
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | uri %]">Baskets</a></li>[% END %]
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | uri %]">Baskets</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
7
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid | uri %]&amp;op=do_search">Invoices</a></li>
7
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid | uri %]&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/basket.tt (-1 / +1 lines)
Lines 881-887 Link Here
881
            $(document).ready(function(){
881
            $(document).ready(function(){
882
                $("#basketgroupid").change(function(){
882
                $("#basketgroupid").change(function(){
883
                    if($(this).val() == "new"){
883
                    if($(this).val() == "new"){
884
                        location.href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% booksellerid | html %]";
884
                        location.href="/cgi-bin/koha/acqui/basketgroups.pl?op=add&booksellerid=[% booksellerid | html %]";
885
                    } else {
885
                    } else {
886
                        $(this).parent().submit();
886
                        $(this).parent().submit();
887
                    }
887
                    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt (-166 / +45 lines)
Lines 2-9 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE Price %]
4
[% USE Price %]
5
[% USE KohaDates %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Basket grouping for [% booksellername | html %]</title>
7
<title>Koha &rsaquo; Basket groups for [% booksellername | html %]</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'datatables.inc' %]
9
[% INCLUDE 'datatables.inc' %]
9
[% Asset.js("lib/yui/utilities/utilities.js") | $raw %]
10
[% Asset.js("lib/yui/utilities/utilities.js") | $raw %]
Lines 11-17 Link Here
11
[% Asset.js("lib/yui/container/container_core-min.js") | $raw %]
12
[% Asset.js("lib/yui/container/container_core-min.js") | $raw %]
12
[% Asset.js("lib/yui/menu/menu-min.js") | $raw %]
13
[% Asset.js("lib/yui/menu/menu-min.js") | $raw %]
13
[% Asset.js("js/basketgroup.js") | $raw %]
14
[% Asset.js("js/basketgroup.js") | $raw %]
14
[% IF ( grouping ) %]
15
[% Asset.js("lib/yui/yahoo-dom-event/yahoo-dom-event.js") | $raw %]
15
[% Asset.js("lib/yui/yahoo-dom-event/yahoo-dom-event.js") | $raw %]
16
[% Asset.js("lib/yui/animation/animation-min.js") | $raw %]
16
[% Asset.js("lib/yui/animation/animation-min.js") | $raw %]
17
[% Asset.js("lib/yui/dragdrop/dragdrop-min.js") | $raw %]
17
[% Asset.js("lib/yui/dragdrop/dragdrop-min.js") | $raw %]
Lines 85-91 fieldset.various li { Link Here
85
}
85
}
86
86
87
</style>
87
</style>
88
 [% END %]
89
<script>
88
<script>
90
    YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
89
    YAHOO.util.Event.onDOMReady(DDApp.init, DDApp, true);
91
90
Lines 95-121 fieldset.various li { Link Here
95
    var MSG_REOPEN_BASKETGROUP = _("reopen basketgroup");
94
    var MSG_REOPEN_BASKETGROUP = _("reopen basketgroup");
96
    var MSG_FILE_DOWNLOAD_ERROR = _("Error downloading the file");
95
    var MSG_FILE_DOWNLOAD_ERROR = _("Error downloading the file");
97
96
98
    function submitForm(form) {
99
        if (form.close.checked == true) {
100
            var input = document.createElement("input");
101
            input.setAttribute("type", "hidden");
102
            input.setAttribute("name", "closed");
103
            input.setAttribute("value", "1");
104
            form.appendChild(input);
105
        }
106
    }
107
108
    $(document).ready(function() {
109
        $("#basket_groups").tabs();
110
111
        $("table").dataTable($.extend(true, {}, dataTablesDefaults, {
112
            "aoColumnDefs": [
113
                { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
114
            ],
115
            "bAutoWidth": false,
116
            "sPaginationType": "full"
117
        } ));
118
    });
119
</script>
97
</script>
120
98
121
</head>
99
</head>
Lines 124-134 fieldset.various li { Link Here
124
[% INCLUDE 'acquisitions-search.inc' %]
102
[% INCLUDE 'acquisitions-search.inc' %]
125
103
126
<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;
104
<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;
127
[% IF ( grouping ) %]
105
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | uri %]">[% bookseller.name | html %]</a>
128
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | html %]">Basket grouping</a> &rsaquo; Add basket group for [% booksellername | html %]</div>
106
    &rsaquo;
129
[% ELSE %]
107
    <a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% bookseller.id | uri %]">Basket groups</a>
130
    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a> &rsaquo; Basket grouping</div>
108
    &rsaquo;
131
[% END %]
109
    Add basket group for [% bookseller.name | html %]
110
</div>
132
111
133
112
134
<div class="main container-fluid">
113
<div class="main container-fluid">
Lines 136-161 fieldset.various li { Link Here
136
        <div class="col-sm-10 col-sm-push-2">
115
        <div class="col-sm-10 col-sm-push-2">
137
            <main>
116
            <main>
138
117
139
                [% IF ( grouping ) %]
118
                    [% IF (basketgroup.closeddate) %]
140
                    [% IF (closedbg) %]
141
                        <div id="toolbar" class="btn-toolbar">
119
                        <div id="toolbar" class="btn-toolbar">
142
                            <div class="btn-group"><a href="[% script_name | url %]?op=reopen&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;mode=singlebg" class="btn btn-default" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div>
120
                            <div class="btn-group"><a href="[% script_name | url %]?op=reopen&amp;basketgroupid=[% basketgroup.id | uri %]&amp;booksellerid=[% bookseller.id | uri %]&amp;mode=singlebg" class="btn btn-default" id="reopenbutton"><i class="fa fa-download"></i> Reopen this basket group</a></div>
143
                            <div class="btn-group"><a href="[% script_name | url %]?op=export&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="exportbutton"><i class="fa fa-download"></i> Export this basket group as CSV</a></div>
121
                            <div class="btn-group"><a href="[% script_name | url %]?op=export&amp;basketgroupid=[% basketgroup.id | uri %]&amp;booksellerid=[% bookseller.id | uri %]" class="btn btn-default" id="exportbutton"><i class="fa fa-download"></i> Export this basket group as CSV</a></div>
144
                            <div class="btn-group"><a href="[% script_name | url %]?op=print&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Print this basket group in PDF</a></div>
122
                            <div class="btn-group"><a href="[% script_name | url %]?op=print&amp;basketgroupid=[% basketgroup.id | uri %]&amp;booksellerid=[% bookseller.id | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Print this basket group in PDF</a></div>
145
                        [% IF (ediaccount) %]
123
                        [% IF (ediaccount) %]
146
                            <div class="btn-group"><a href="[% script_name | url %]?op=ediprint&amp;basketgroupid=[% basketgroupid | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div>
124
                            <div class="btn-group"><a href="[% script_name | url %]?op=ediprint&amp;basketgroupid=[% basketgroup.id | uri %]&amp;booksellerid=[% bookseller.id | uri %]" class="btn btn-default" id="printbutton"><i class="fa fa-download"></i> Generate EDIFACT order</a></div>
147
                        [% END %]
125
                        [% END %]
148
                        </div>
126
                        </div>
149
                    [% END %]
127
                    [% END %]
150
                    [% IF (name && closedbg) %]
128
                    [% IF (basketgroup && basketgroup.closeddate) %]
151
                        <h1>Basket group [% name | html %] ([% basketgroupid | html %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a></h1>
129
                        <h1>Basket group [% basketgroup.name | html %] ([% basketgroup.id | html %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | uri %]">[% bookseller.name | html %]</a></h1>
152
                    [% ELSIF (name) %]
130
                    [% ELSIF (basketgroup) %]
153
                        <h1>Edit basket group [% name | html %] ([% basketgroupid | html %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a></h1>
131
                        <h1>Edit basket group [% basketgroup.name | html %] ([% basketgroup.id | html %]) for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | uri %]">[% bookseller.name | html %]</a></h1>
154
                    [% ELSE %]
132
                    [% ELSE %]
155
                        <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a></h1>
133
                        <h1>Add basket group for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | uri %]">[% bookseller.name | html %]</a></h1>
156
                    [% END %]
134
                    [% END %]
135
                    [% IF NoEDIMessage %]<div><strong>No EDIFACT configuration for [% bookseller.name | html %]</strong></div>[% END %]
157
                    <div id="basketgroupcolumns" class="row">
136
                    <div id="basketgroupcolumns" class="row">
158
                        [% UNLESS (closedbg) %]
137
                        [% UNLESS (basketgroup.closeddate) %]
159
                            <div class="col-xs-6 col-xs-push-6">
138
                            <div class="col-xs-6 col-xs-push-6">
160
                                <form action="[% scriptname | html %]" method="post" name="basketgroups" id="basketgroups">
139
                                <form action="[% scriptname | html %]" method="post" name="basketgroups" id="basketgroups">
161
                                    <div id="groups">
140
                                    <div id="groups">
Lines 185-208 fieldset.various li { Link Here
185
                                </form>
164
                                </form>
186
                            </div>
165
                            </div>
187
                        [% END %]
166
                        [% END %]
188
                        [% IF ( closedbg ) %]
167
                        [% IF ( basketgroup.closeddate ) %]
189
                            <div class="col-xs-12">
168
                            <div class="col-xs-12">
190
                        [% ELSE %]
169
                        [% ELSE %]
191
                            <div class="col-xs-6 col-xs-pull-6">
170
                            <div class="col-xs-6 col-xs-pull-6">
192
                        [% END %]
171
                        [% END %]
193
                            <form action="" method="post" id="groupingform" onsubmit="return submitForm(this)">
172
                            <form action="" method="post" id="groupingform">
194
                                <fieldset id="various" class="brief">
173
                                <fieldset id="various" class="brief">
195
                                    <ol>
174
                                    <ol>
196
                                        [% UNLESS (closedbg) %]
175
                                        [% UNLESS (basketgroup.closeddate) %]
197
                                            <li>
176
                                            <li>
198
                                                <label for="basketgroupname">Basket group name:</label>
177
                                                <label for="basketgroupname">Basket group name:</label>
199
                                                <input type="text" name="basketgroupname" id="basketgroupname" value="[% name | html %]" class="focus" />
178
                                                <input type="text" name="basketgroupname" id="basketgroupname" value="[% basketgroup.name | html %]" class="focus" />
200
                                            </li>
179
                                            </li>
201
                                        [% ELSE %]
180
                                        [% ELSE %]
202
                                            <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% name | html %]" />
181
                                            <input type="hidden" name="basketgroupname" id="basketgroupname" value="[% basketgroup.name | html %]" />
203
                                        [% END %]
182
                                        [% END %]
204
                                        <li>
183
                                        <li>
205
                                            [% UNLESS (closedbg) %]
184
                                            [% UNLESS (basketgroup.closeddate) %]
206
                                                <label for="billingplace">Billing place:</label>
185
                                                <label for="billingplace">Billing place:</label>
207
                                                <select name="billingplace" id="billingplace">
186
                                                <select name="billingplace" id="billingplace">
208
                                                    <option value="">--</option>
187
                                                    <option value="">--</option>
Lines 210-219 fieldset.various li { Link Here
210
                                                </select>
189
                                                </select>
211
                                            [% ELSE %]
190
                                            [% ELSE %]
212
                                                <span class="label">Billing place:</span>
191
                                                <span class="label">Billing place:</span>
213
                                                <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace | html %]" />[% Branches.GetName( billingplace ) | html %]
192
                                                <input name="billingplace" id="billingplace" type ="hidden" value="[% billingplace | html %]" />[% Branches.GetName( basketgroup.billingplace ) | html %]
214
                                            [% END %]
193
                                            [% END %]
215
                                        </li>
194
                                        </li>
216
                                        [% UNLESS (closedbg) %]
195
                                        [% UNLESS (basketgroup.closeddate) %]
217
                                            <li>
196
                                            <li>
218
                                                <label for="deliveryplace">Delivery place:</label>
197
                                                <label for="deliveryplace">Delivery place:</label>
219
                                                <select name="deliveryplace" id="deliveryplace">
198
                                                <select name="deliveryplace" id="deliveryplace">
Lines 224-260 fieldset.various li { Link Here
224
                                            <li><p>or</p></li>
203
                                            <li><p>or</p></li>
225
                                            <li>
204
                                            <li>
226
                                                <label for="freedeliveryplace">Delivery place:</label>
205
                                                <label for="freedeliveryplace">Delivery place:</label>
227
                                                <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% freedeliveryplace | html %]</textarea>
206
                                                <textarea cols="26" rows="3" name="freedeliveryplace" id="freedeliveryplace">[% basketgroup.freedeliveryplace | html %]</textarea>
228
                                            </li>
207
                                            </li>
229
                                            [% ELSE %]
208
                                            [% ELSE %]
230
                                                <li>
209
                                                <li>
231
                                                    <span class="label">Delivery place:</span>
210
                                                    <span class="label">Delivery place:</span>
232
                                                    [% IF (freedeliveryplace) %]
211
                                                    [% IF (basketgroup.freedeliveryplace) %]
233
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% freedeliveryplace | html %]" />[% freedeliveryplace | html %]
212
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="[% basketgroup.freedeliveryplace | html %]" />[% basketgroup.freedeliveryplace | html %]
234
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" />
213
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="" />
235
                                                    [% ELSE %]
214
                                                    [% ELSE %]
236
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% deliveryplace | html %]" />[% Branches.GetName( deliveryplace ) | html %]
215
                                                        <input name="deliveryplace" id="deliveryplace" type ="hidden" value="[% basketgroup.deliveryplace | html %]" />[% Branches.GetName( basketgroup.deliveryplace ) | html %]
237
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" />
216
                                                        <input name="freedeliveryplace" id="freedeliveryplace" type ="hidden" value="" />
238
                                                    [% END %]
217
                                                    [% END %]
239
                                                </li>
218
                                                </li>
240
                                            [% END %]
219
                                            [% END %]
241
                                            <li>
220
                                            <li>
242
                                                [% UNLESS (closedbg) %]
221
                                                [% UNLESS (basketgroup.closeddate) %]
243
                                                    <label for="deliverycomment">Delivery comment:</label>
222
                                                    <label for="deliverycomment">Delivery comment:</label>
244
                                                    <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% deliverycomment | html %]</textarea>
223
                                                    <textarea cols="26" rows="3" name="deliverycomment" id="deliverycomment">[% basketgroup.deliverycomment | html %]</textarea>
245
                                                [% ELSE %]
224
                                                [% ELSE %]
246
                                                    <span class="label">Delivery comment:</span>[% deliverycomment | html %]
225
                                                    <span class="label">Delivery comment:</span>[% basketgroup.deliverycomment | html %]
247
                                                    <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% deliverycomment | html %]" />
226
                                                    <input name="deliverycomment" id="deliverycomment" type="hidden" value = "[% basketgroup.deliverycomment | html %]" />
248
                                                [% END %]
227
                                                [% END %]
249
                                            </li>
228
                                            </li>
250
                                            <li>
229
                                            <li>
251
                                                <span class="label">Baskets in this group:</span>
230
                                                <span class="label">Baskets in this group:</span>
252
                                                [% UNLESS (closedbg) %]
231
                                                [% UNLESS (basketgroup.closeddate) %]
253
                                                    <ul class="draglist" id="bg">
232
                                                    <ul class="draglist" id="bg">
254
                                                [% ELSE %]
233
                                                [% ELSE %]
255
                                                    <ul>
234
                                                    <ul>
256
                                                [% END %]
235
                                                [% END %]
257
                                                [% FOREACH selectedbasket IN selectedbaskets %]
236
                                                [% FOREACH selectedbasket IN basketgroup.baskets %]
258
                                                    <li class="grouped" id="b-[% selectedbasket.basketno | html %]" >
237
                                                    <li class="grouped" id="b-[% selectedbasket.basketno | html %]" >
259
                                                        <a href="basket.pl?basketno=[% selectedbasket.basketno | uri %]">
238
                                                        <a href="basket.pl?basketno=[% selectedbasket.basketno | uri %]">
260
                                                            [% IF ( selectedbasket.basketname ) %]
239
                                                            [% IF ( selectedbasket.basketname ) %]
Lines 269-399 fieldset.various li { Link Here
269
                                                [% END %]
248
                                                [% END %]
270
                                            </ul>
249
                                            </ul>
271
                                        </li>
250
                                        </li>
272
                                            [% UNLESS (closedbg) %]
251
                                            [% UNLESS (basketgroup.closeddate) %]
273
                                                <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li>
252
                                                <li><label><input type="checkbox" id="closedbg" name="closedbg" />Close basket group</label></li>
274
                                            [% ELSE %]
253
                                            [% ELSE %]
275
                                                <input type="hidden" id="closedbg" name="closedbg" value ="1"/>
254
                                                <input type="hidden" id="closedbg" name="closedbg" value ="1"/>
276
                                            [% END %]
255
                                            [% END %]
277
                                    </ol>
256
                                    </ol>
278
                                </fieldset>
257
                                </fieldset>
279
                                [% UNLESS (closedbg) %]
258
                                [% UNLESS (basketgroup.closeddate) %]
280
                                    <fieldset class="action"><input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
259
                                    <fieldset class="action"><input type="hidden" name="booksellerid" value="[% bookseller.id | html %]" />
281
                                        [% IF ( basketgroupid ) %]
260
                                        [% IF ( basketgroup ) %]
282
                                            <input type="hidden" name="basketgroupid" value="[% basketgroupid | html %]" />
261
                                            <input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" />
283
                                        [% END %]
262
                                        [% END %]
284
                                        <input type="hidden" name="op" value="attachbasket" />
263
                                        <input type="hidden" name="op" value="attachbasket" />
285
                                        <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]" class="cancel">Cancel</a>
264
                                        <input type="submit" value="Save" /> <a href="/cgi-bin/koha/acqui/basketgroups.pl?booksellerid=[% bookseller.id | uri %]" class="cancel">Cancel</a>
286
                                    </fieldset>
265
                                    </fieldset>
287
                                [% END %]
266
                                [% END %]
288
                            </form>
267
                            </form>
289
                        </div>
268
                        </div>
290
                    </div>
269
                    </div>
291
                [% ELSE %]
292
                    <div id="toolbar" class="btn-toolbar">
293
                        <div class="btn-group"><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="newbasketgroup"><i class="fa fa-plus"></i> New basket group</a></div>
294
                    </div>
295
                    <h1>Basket grouping for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a></h1>
296
                    [% IF (NoEDIMessage) %]<div><strong>No EDIFACT configuration for [% booksellername | html %]</strong></div>[% END %]
297
                    <div id="basket_groups" class="toptabs">
298
                        <ul class="ui-tabs-nav">
299
                            [% UNLESS ( listclosed) %]<li class="ui-tabs-active"><a href="#opened">Open</a></li>
300
                            [% ELSE%]<li><a href="#opened">Open</a></li>[% END %]
301
                            [% IF ( listclosed) %]<li class="ui-tabs-active"><a href="#closed">Closed</a></li>
302
                            [% ELSE %]<li><a href="#closed">Closed</a></li>[% END %]
303
                        </ul>
304
                        <div id="opened">
305
                            <table id="basket_group_opened">
306
                                <thead>
307
                                    <tr>
308
                                        <th>Name</th>
309
                                        <th>Number</th>
310
                                        <th>Billing place</th>
311
                                        <th>Delivery place</th>
312
                                        <th>Number of baskets</th>
313
                                        <th>Action</th>
314
                                    </tr>
315
                                </thead>
316
                                <tbody>
317
                                    [% FOREACH basketgroup IN basketgroups %]
318
                                        [% UNLESS ( basketgroup.closed ) %]
319
                                            <tr>
320
                                                <td>[% IF ( basketgroup.name ) %]
321
                                                    [% basketgroup.name | html %]
322
                                                    [% ELSE %]
323
                                                        Basket group no. [% basketgroup.id | html %]
324
                                                    [% END %]
325
                                                </td>
326
                                                <td>[% basketgroup.id | html %]</td>
327
                                                <td>[% Branches.GetName( basketgroup.billingplace ) | html %]</td>
328
                                                <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) | html %][% END %]</td>
329
                                                <td>[% basketgroup.basketsqty | html %]</td>
330
                                                <td>
331
                                                    <input type="button" onclick="closeandprint('[% basketgroup.id | html %]');" value="Close and export as PDF" />
332
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="add" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Edit" /></form>
333
                                                    [% UNLESS basketgroup.basketsqty %]
334
                                                        <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="delete" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Delete" /></form>
335
                                                    [% END %]
336
                                                </td>
337
                                            </tr>
338
                                        [% END %]
339
                                    [% END %]
340
                                </tbody>
341
                            </table>
342
                        </div>
343
                        <div id="closed">
344
                            <table id="basket_group_closed">
345
                                <thead>
346
                                    <tr>
347
                                        <th>Name</th>
348
                                        <th>Number</th>
349
                                        <th>Billing place</th>
350
                                        <th>Delivery place</th>
351
                                        <th>Number of baskets</th>
352
                                        <th>Action</th>
353
                                    </tr>
354
                                </thead>
355
                                <tbody>
356
                                    [% FOREACH basketgroup IN basketgroups %]
357
                                        [% IF ( basketgroup.closed ) %]
358
                                            <tr>
359
                                                <td>
360
                                                    [% IF ( basketgroup.name ) %]
361
                                                        [% basketgroup.name | html %]
362
                                                        [% ELSE %]
363
                                                            Basket group no. [% basketgroup.id | html %]
364
                                                        [% END %]
365
                                                </td>
366
                                                <td>[% basketgroup.id | html %]</td>
367
                                                <td>[% Branches.GetName( basketgroup.billingplace ) | html %]</td>
368
                                                <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) | html %][% END %]</td>
369
                                                <td>[% basketgroup.basketsqty | html %]</td>
370
                                                <td>
371
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="add" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="View" /></form>
372
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="reopen" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Reopen" /></form>
373
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="print" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Export as PDF" /></form>
374
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="export" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Export as CSV" /></form>
375
                                            [% IF (ediaccount) %]
376
                                                    <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="ediprint" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" value="Generate EDIFACT order" /></form>
377
                                            [% ELSE %]
378
                                                    <div>No EDIFACT configuration for [% booksellername | html %]</div>
379
                                            [% END %]
380
                                                </td>
381
                                            </tr>
382
                                        [% END %]
383
                                    [% END %]
384
                                </tbody>
385
                            </table>
386
                        </div>
387
                    </div>
388
                [% END %]
389
            </main>
270
            </main>
390
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
271
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
391
272
392
        <div class="col-sm-2 col-sm-pull-10">
273
        <div class="col-sm-2 col-sm-pull-10">
393
            <aside>
274
            <aside>
394
                [% IF ( booksellerid ) %]
275
                [% INCLUDE 'vendor-menu.inc' %]
395
                    [% INCLUDE 'vendor-menu.inc' %]
396
                [% END %]
397
                [% INCLUDE 'acquisitions-menu.inc' %]
276
                [% INCLUDE 'acquisitions-menu.inc' %]
398
            </aside>
277
            </aside>
399
        </div>
278
        </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroups.tt (+168 lines)
Line 0 Link Here
1
[% USE Asset %]
2
[% USE Branches %]
3
[% USE KohaDates %]
4
[% USE raw %]
5
6
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
    [% IF bookseller %]
9
        <title>Koha &rsaquo; Basket groups for [% bookseller.name |html %]</title>
10
    [% ELSE %]
11
        <title>Koha &rsaquo; Basket groups</title>
12
    [% END %]
13
[% INCLUDE 'doc-head-close.inc' %]
14
[% Asset.css('css/datatables.css') | $raw %]
15
</head>
16
<body id="acq_basketgroup" class="acq">
17
    [% INCLUDE 'header.inc' %]
18
    [% INCLUDE 'acquisitions-search.inc' %]
19
20
    <div id="breadcrumbs">
21
        <a href="/cgi-bin/koha/mainpage.pl">Home</a>
22
        &rsaquo;
23
        <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
24
        &rsaquo;
25
        [% IF (bookseller) %]
26
            <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | $raw %]">[% bookseller.name | html %]</a>
27
            &rsaquo;
28
        [% END %]
29
        Basket groups
30
    </div>
31
32
    <div id="doc3" class="yui-t2">
33
        <div id="bd">
34
            <div id="yui-main">
35
                <div class="yui-b">
36
                    [% IF bookseller %]
37
                        <div id="toolbar" class="btn-toolbar">
38
                            <div class="btn-group">
39
                                <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% bookseller.id | $raw %]" class="btn btn-default btn-sm" id="newbasketgroup"><i class="fa fa-plus"></i> New basket group</a>
40
                            </div>
41
                        </div>
42
43
                        <h1>Basket groups for <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | $raw %]">[% bookseller.name | html %]</a></h1>
44
                    [% END %]
45
46
                    [% IF basketgroups.size > 0 %]
47
                        <table id="basketgroups-table" class="group">
48
                            <thead>
49
                                <tr>
50
                                    <th>Name</th>
51
                                    <th>Vendor</th>
52
                                    <th>Billing place</th>
53
                                    <th>Delivery place</th>
54
                                    <th>No. of baskets</th>
55
                                    <th>No. of ordered titles</th>
56
                                    <th>No. of received titles</th>
57
                                    <th>Date closed</th>
58
                                    <th>Action</th>
59
                                </tr>
60
                            </thead>
61
                            <tbody>
62
                                [% FOREACH basketgroup IN basketgroups %]
63
                                    <tr>
64
                                        <td>
65
                                            [% IF ( basketgroup.name ) %]
66
                                                [% basketgroup.name | html %]
67
                                            [% ELSE %]
68
                                                Basket group no. [% basketgroup.id | $raw %]
69
                                            [% END %]
70
                                        </td>
71
                                        <td>[% basketgroup.vendor.name | html %]</td>
72
                                        <td>[% Branches.GetName(basketgroup.billingplace) | html %]</td>
73
                                        <td>
74
                                            [% IF (basketgroup.freedeliveryplace) %]
75
                                                [% basketgroup.freedeliveryplace | html %]
76
                                            [% ELSE %]
77
                                                [% Branches.GetName(basketgroup.deliveryplace) | html %]
78
                                            [% END %]
79
                                        </td>
80
                                        <td>[% basketgroup.baskets_count | $raw %]</td>
81
                                        <td>[% basketgroup.ordered_titles_count | $raw %]</td>
82
                                        <td>[% basketgroup.received_titles_count | $raw %]</td>
83
                                        <td>[% basketgroup.closeddate | $KohaDates %]</td>
84
                                        <td>
85
                                            <div class="dropdown">
86
                                            <a class="btn btn-default btn-xs dropdown-toggle" id="actions-[% basketgroup.id | $raw %]" role="button" data-toggle="dropdown">Actions <b class="caret"></b></a>
87
                                            <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="actions-[% basketgroup.id | $raw %]">
88
                                            [% IF basketgroup.closeddate %]
89
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% basketgroup.booksellerid | $raw %]&basketgroupid=[% basketgroup.id | $raw %]"><i class="fa fa-eye"></i> View</a></li>
90
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=reopen&booksellerid=[% basketgroup.booksellerid | $raw %]&basketgroupid=[% basketgroup.id | $raw %]"><i class="fa fa-folder-open"></i> Reopen</a></li>
91
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=print&basketgroupid=[% basketgroup.id | $raw %]"><i class="fa fa-print"></i> Export as PDF</a></li>
92
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=export&basketgroupid=[% basketgroup.id | $raw %]"><i class="fa fa-file-text"></i> Export as CSV</a></li>
93
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=ediprint&booksellerid=[% basketgroup.booksellerid | $raw %]&basketgroupid=[% basketgroup.id | $raw %]">Generate EDIFACT order</a></li>
94
                                            [% ELSE %]
95
                                                <li><a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% basketgroup.booksellerid | $raw %]&basketgroupid=[% basketgroup.id | $raw %]"><i class="fa fa-pencil"></i> Edit</a></li>
96
                                                <li><a class="closeandprint" href="/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=[% basketgroup.id | $raw %]"><i class="fa fa-print"></i> Close and export as PDF</a></li>
97
                                                [% UNLESS basketgroup.baskets_count %]
98
                                                    <li><a class="delete" href="/cgi-bin/koha/acqui/basketgroup.pl?op=delete&booksellerid=[% basketgroup.booksellerid | $raw %]&basketgroupid=[% basketgroup.id | $raw %]"><i class="fa fa-trash"></i> Delete</a></li>
99
                                                [% END %]
100
                                            [% END %]
101
                                            </ul>
102
                                            </div>
103
                                        </td>
104
                                    </tr>
105
                                [% END %]
106
                            </tbody>
107
                        </table>
108
                    [% END %]
109
                </div>
110
            </div>
111
            <div class="yui-b">
112
                [% IF bookseller %]
113
                    [% INCLUDE 'vendor-menu.inc' booksellerid = bookseller.id %]
114
                [% END %]
115
                [% INCLUDE 'acquisitions-menu.inc' %]
116
            </div>
117
        </div>
118
119
        [% MACRO jsinclude BLOCK %]
120
            [% INCLUDE 'datatables.inc' %]
121
            [% Asset.js('lib/jquery/plugins/jquery.dataTables.columnFilter.js') | $raw %]
122
            <script type="text/javascript">
123
                $(document).ready(function() {
124
                    var options = {
125
                        "paging": false,
126
                        "autoWidth": false,
127
                        "columnDefs": [
128
                            { "visible": false, "targets": 1 },
129
                            { "orderable": false, "targets": -1 }
130
                        ],
131
                        "orderFixed": [[ 1, 'asc' ]]
132
                    };
133
                    [% UNLESS bookseller %]
134
                        options.drawCallback = function(settings) {
135
                            var api = this.api();
136
                            var rows = api.rows({page: 'current'}).nodes();
137
                            var last = null;
138
139
                            api.column(1, {page: 'current'}).data().each(function(group, i) {
140
                                if (last !== group) {
141
                                    $(rows).eq(i).before(
142
                                        '<tr><td class="group" colspan="8">' + group + '</td></tr>'
143
                                    );
144
                                    last = group;
145
                                }
146
                            });
147
                        };
148
                    [% END %]
149
                    $("#basketgroups-table").kohaDataTable(options);
150
151
                    $('#basketgroups-table').on('click', '.closeandprint', function(e) {
152
                        e.preventDefault();
153
                        var w = window.open($(this).attr('href'));
154
                        var timer = setInterval(function() {
155
                            if (w.closed === true) {
156
                                clearInterval(timer);
157
                                window.location.reload(true);
158
                            }
159
                        }, 1000);
160
                    });
161
                    $('#basketgroups-table').on('click', '.delete', function() {
162
                        return confirm(_("Are you sure you want to delete this basketgroup ?"));
163
                    });
164
                });
165
            </script>
166
        [% END %]
167
168
    [% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-1 / +1 lines)
Lines 278-284 Link Here
278
                <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | uri %]"> [% order.basketname | html %] ([% order.basketno | html %])</a></td>
278
                <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | uri %]"> [% order.basketname | html %] ([% order.basketno | html %])</a></td>
279
                <td>
279
                <td>
280
                  [% IF order.basketgroupid %]
280
                  [% IF order.basketgroupid %]
281
                  <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% booksellerid | uri %]">[% order.basketgroupname | html %] ([% order.basketgroupid | html %])</a>
281
                  <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% booksellerid | uri %]&amp;basketgroupid=[% order.basketgroupid | uri %]">[% order.basketgroupname | html %] ([% order.basketgroupid | html %])</a>
282
                  [% ELSE %]
282
                  [% ELSE %]
283
                    No basket group
283
                    No basket group
284
                  [% END %]
284
                  [% END %]
(-)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 (-26 / +75 lines)
Lines 1-33 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
var dataTablesDefaults = {
8
//   $('#table_id').kohaDataTable({ ... });
9
    "oLanguage": {
9
//
10
        "oPaginate": {
10
// To use the older API, write:
11
            "sFirst"    : window.MSG_DT_FIRST || "First",
11
//
12
            "sLast"     : window.MSG_DT_LAST || "Last",
12
//   $("#table_id").dataTable($.extend(true, {}, dataTablesDefaults, { ... });
13
            "sNext"     : window.MSG_DT_NEXT || "Next",
13
14
            "sPrevious" : window.MSG_DT_PREVIOUS || "Previous"
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"
15
        },
30
        },
16
        "sEmptyTable"       : window.MSG_DT_EMPTY_TABLE || "No data available in table",
31
        "aria": {
17
        "sInfo"             : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries",
32
            "sortAscending":  window.MSG_DT_SORT_ASC || ": activate to sort column ascending",
18
        "sInfoEmpty"        : window.MSG_DT_INFO_EMPTY || "No entries to show",
33
            "sortDescending": window.MSG_DT_SORT_DESC || ": activate to sort column descending"
19
        "sInfoFiltered"     : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)",
34
        },
20
        "sLengthMenu"       : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries",
35
        "buttons": {
21
        "sLoadingRecords"   : window.MSG_DT_LOADING_RECORDS || "Loading...",
22
        "sProcessing"       : window.MSG_DT_PROCESSING || "Processing...",
23
        "sSearch"           : window.MSG_DT_SEARCH || "Search:",
24
        "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found",
25
        buttons: {
26
            "copyTitle"     : window.MSG_DT_COPY_TITLE || "Copy to clipboard",
36
            "copyTitle"     : window.MSG_DT_COPY_TITLE || "Copy to clipboard",
27
            "copyKeys"      : window.MSG_DT_COPY_KEYS || "Press <i>ctrl</i> or <i>⌘</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.",
37
            "copyKeys"      : window.MSG_DT_COPY_KEYS || "Press <i>ctrl</i> or <i>⌘</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.",
28
            "copySuccess": {
38
            "copySuccess": {
29
                _: window.MSG_DT_COPY_SUCCESS_X || "Copied %d rows to clipboard",
39
                "_": window.MSG_DT_COPY_SUCCESS_X || "Copied %d rows to clipboard",
30
                1: window.MSG_DT_COPY_SUCCESS_ONE || "Copied one row to clipboard"
40
                "1": window.MSG_DT_COPY_SUCCESS_ONE || "Copied one row to clipboard"
31
            }
41
            }
32
        }
42
        }
33
    },
43
    },
Lines 49-56 var dataTablesDefaults = { Link Here
49
            node.addClass("disabled");
59
            node.addClass("disabled");
50
        }
60
        }
51
    }],
61
    }],
52
    "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
62
    "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
53
    "iDisplayLength": 20,
63
    "pageLength": 20,
54
    initComplete: function( settings) {
64
    initComplete: function( settings) {
55
        var tableId = settings.nTable.id
65
        var tableId = settings.nTable.id
56
        // When the DataTables search function is triggered,
66
        // When the DataTables search function is triggered,
Lines 63-71 var dataTablesDefaults = { Link Here
63
                $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
73
                $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
64
            }
74
            }
65
        });
75
        });
66
    }
76
    },
77
};
78
79
var dataTablesDefaults = {
80
    "oLanguage": {
81
        "oPaginate": {
82
            "sFirst"    : DataTableDefaults.language.paginate.first,
83
            "sLast"     : DataTableDefaults.language.paginate.last,
84
            "sNext"     : DataTableDefaults.language.paginate.next,
85
            "sPrevious" : DataTableDefaults.language.paginate.previous,
86
        },
87
        "sEmptyTable"       : DataTableDefaults.language.emptyTable,
88
        "sInfo"             : DataTableDefaults.language.info,
89
        "sInfoEmpty"        : DataTableDefaults.language.infoEmpty,
90
        "sInfoFiltered"     : DataTableDefaults.language.infoFiltered,
91
        "sLengthMenu"       : DataTableDefaults.language.lengthMenu,
92
        "sLoadingRecords"   : DataTableDefaults.language.loadingRecords,
93
        "sProcessing"       : DataTableDefaults.language.processing,
94
        "sSearch"           : DataTableDefaults.language.search,
95
        "sZeroRecords"      : DataTableDefaults.language.zeroRecords,
96
        "buttons": {
97
            "copyTitle"     : DataTableDefaults.language.buttons.copyTitle,
98
            "copyKeys"      : DataTableDefaults.language.buttons.copyKeys,
99
            "copySuccess": {
100
                "_": DataTableDefaults.language.buttons.copySuccess["_"],
101
                "1": DataTableDefaults.language.buttons.copySuccess["1"]
102
            }
103
        }
104
    },
105
    "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
106
    "buttons": DataTableDefaults.buttons,
107
    "aLengthMenu": DataTableDefaults.lengthMenu,
108
    "iDisplayLength": DataTableDefaults.pageLength,
109
    initComplete: DataTableDefaults.initComplete,
67
};
110
};
68
111
112
(function($) {
113
    $.fn.kohaDataTable = function(options) {
114
        return this.DataTable($.extend(true, {}, DataTableDefaults, options));
115
    };
116
})(jQuery);
117
69
118
70
// Return an array of string containing the values of a particular column
119
// Return an array of string containing the values of a particular column
71
$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
120
$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
(-)a/t/db_dependent/Koha/Acquisition/Basket.t (-2 / +45 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
25
Lines 107-109 subtest 'basket_group' => sub { Link Here
107
107
108
    $schema->storage->txn_rollback;
108
    $schema->storage->txn_rollback;
109
};
109
};
110
- 
110
111
subtest 'total' => sub {
112
    plan tests => 2;
113
114
    $schema->storage->txn_begin;
115
    my $bookseller = $builder->build_object({
116
        class => 'Koha::Acquisition::Booksellers',
117
        value => {
118
            listincgst => 0,
119
        },
120
    });
121
    my $basket = $builder->build_object({
122
        class => 'Koha::Acquisition::Baskets',
123
        value => {
124
            booksellerid => $bookseller->id,
125
        },
126
    });
127
    my $order1 = $builder->build_object({
128
        class => 'Koha::Acquisition::Orders',
129
        value => {
130
            basketno => $basket->basketno,
131
            ecost_tax_excluded => 1.5,
132
            ecost_tax_included => 2,
133
            quantity => 2,
134
        }
135
    });
136
    my $order2 = $builder->build_object({
137
        class => 'Koha::Acquisition::Orders',
138
        value => {
139
            basketno => $basket->basketno,
140
            ecost_tax_excluded => 1.5,
141
            ecost_tax_included => 2,
142
            quantity => 2,
143
        }
144
    });
145
146
    is ($basket->total, 6);
147
148
    $bookseller->listincgst(1)->store();
149
    $basket = Koha::Acquisition::Baskets->find($basket->basketno);
150
    is ($basket->total, 8);
151
152
    $schema->storage->txn_rollback;
153
};

Return to bug 11708