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

(-)a/C4/Acquisition.pm (-9 / +13 lines)
Lines 186-192 sub GetBasket { Link Here
186
=head3 NewBasket
186
=head3 NewBasket
187
187
188
  $basket = &NewBasket( $booksellerid, $authorizedby, $basketname,
188
  $basket = &NewBasket( $booksellerid, $authorizedby, $basketname,
189
      $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing );
189
      $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing, $create_items );
190
190
191
Create a new basket in aqbasket table
191
Create a new basket in aqbasket table
192
192
Lines 205-211 The other parameters are optional, see ModBasketHeader for more info on them. Link Here
205
sub NewBasket {
205
sub NewBasket {
206
    my ( $booksellerid, $authorisedby, $basketname, $basketnote,
206
    my ( $booksellerid, $authorisedby, $basketname, $basketnote,
207
        $basketbooksellernote, $basketcontractnumber, $deliveryplace,
207
        $basketbooksellernote, $basketcontractnumber, $deliveryplace,
208
        $billingplace, $is_standing ) = @_;
208
        $billingplace, $is_standing, $create_items ) = @_;
209
    my $dbh = C4::Context->dbh;
209
    my $dbh = C4::Context->dbh;
210
    my $query =
210
    my $query =
211
        'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) '
211
        'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) '
Lines 217-223 sub NewBasket { Link Here
217
    $basketnote           ||= q{};
217
    $basketnote           ||= q{};
218
    $basketbooksellernote ||= q{};
218
    $basketbooksellernote ||= q{};
219
    ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote,
219
    ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote,
220
        $basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing );
220
        $basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items );
221
    return $basket;
221
    return $basket;
222
}
222
}
223
223
Lines 532-537 Modifies a basket's header. Link Here
532
532
533
=item C<$is_standing> is the "is_standing" field in the aqbasket table.
533
=item C<$is_standing> is the "is_standing" field in the aqbasket table.
534
534
535
=item C<$create_items> should be set to 'ordering', 'receiving' or 'cataloguing' (or undef, in which
536
case the AcqCreateItem syspref takes precedence).
537
535
=back
538
=back
536
539
537
=cut
540
=cut
Lines 540-552 sub ModBasketHeader { Link Here
540
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_;
543
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_;
541
    my $query = qq{
544
    my $query = qq{
542
        UPDATE aqbasket
545
        UPDATE aqbasket
543
        SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=?
546
        SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=?, create_items=?
544
        WHERE basketno=?
547
        WHERE basketno=?
545
    };
548
    };
546
549
547
    my $dbh = C4::Context->dbh;
550
    my $dbh = C4::Context->dbh;
548
    my $sth = $dbh->prepare($query);
551
    my $sth = $dbh->prepare($query);
549
    $sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno);
552
    $sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items || undef, $basketno);
550
553
551
    if ( $contractnumber ) {
554
    if ( $contractnumber ) {
552
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
555
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
Lines 1498-1503 sub CancelReceipt { Link Here
1498
    my $parent_ordernumber = $order->{'parent_ordernumber'};
1501
    my $parent_ordernumber = $order->{'parent_ordernumber'};
1499
1502
1500
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1503
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1504
    my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket;
1501
1505
1502
    if($parent_ordernumber == $ordernumber || not $parent_ordernumber) {
1506
    if($parent_ordernumber == $ordernumber || not $parent_ordernumber) {
1503
        # The order line has no parent, just mark it as not received
1507
        # The order line has no parent, just mark it as not received
Lines 1548-1554 sub CancelReceipt { Link Here
1548
                " receipt";
1552
                " receipt";
1549
            return;
1553
            return;
1550
        }
1554
        }
1551
        _cancel_items_receipt( $ordernumber, $parent_ordernumber );
1555
        _cancel_items_receipt( $basket->effective_create_items, $ordernumber, $parent_ordernumber );
1552
        # Delete order line
1556
        # Delete order line
1553
        $query = qq{
1557
        $query = qq{
1554
            DELETE FROM aqorders
1558
            DELETE FROM aqorders
Lines 1559-1565 sub CancelReceipt { Link Here
1559
1563
1560
    }
1564
    }
1561
1565
1562
    if(C4::Context->preference('AcqCreateItem') eq 'ordering') {
1566
    if( $basket->effective_create_items eq 'ordering' ) {
1563
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled");
1567
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled");
1564
        if ( @affects ) {
1568
        if ( @affects ) {
1565
            for my $in ( @itemnumbers ) {
1569
            for my $in ( @itemnumbers ) {
Lines 1582-1592 sub CancelReceipt { Link Here
1582
}
1586
}
1583
1587
1584
sub _cancel_items_receipt {
1588
sub _cancel_items_receipt {
1585
    my ( $ordernumber, $parent_ordernumber ) = @_;
1589
    my ( $effective_create_items, $ordernumber, $parent_ordernumber ) = @_;
1586
    $parent_ordernumber ||= $ordernumber;
1590
    $parent_ordernumber ||= $ordernumber;
1587
1591
1588
    my @itemnumbers = GetItemnumbersFromOrder($ordernumber);
1592
    my @itemnumbers = GetItemnumbersFromOrder($ordernumber);
1589
    if(C4::Context->preference('AcqCreateItem') eq 'receiving') {
1593
    if ( $effective_create_items eq 'receiving' ) {
1590
        # Remove items that were created at receipt
1594
        # Remove items that were created at receipt
1591
        my $query = qq{
1595
        my $query = qq{
1592
            DELETE FROM items, aqorders_items
1596
            DELETE FROM items, aqorders_items
(-)a/Koha/Acquisition/Basket.pm (+54 lines)
Line 0 Link Here
1
package Koha::Acquisition::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 Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Acquisition::Basket - Koha Basket Object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=head3 effective_create_items
35
36
Returns C<create_items> for this basket, falling back to C<AcqCreateItem> if unset.
37
38
=cut
39
40
sub effective_create_items {
41
    my ( $self ) = @_;
42
43
    return $self->create_items || C4::Context->preference('AcqCreateItem');
44
}
45
46
=head3 type
47
48
=cut
49
50
sub type {
51
    return 'Aqbasket';
52
}
53
54
1;
(-)a/Koha/Acquisition/Baskets.pm (+51 lines)
Line 0 Link Here
1
package Koha::Acquisition::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 Carp;
21
22
use C4::Context;
23
use Koha::Database;
24
25
use Koha::Acquisition::Basket;
26
27
use base qw(Koha::Objects);
28
29
=head1 NAME
30
31
Koha::Acquisition::Baskets - Koha Basket Object set class
32
33
=head1 API
34
35
=head2 Class Methods
36
37
=cut
38
39
=head3 type
40
41
=cut
42
43
sub type {
44
    return 'Aqbasket';
45
}
46
47
sub object_class {
48
    return 'Koha::Acquisition::Basket';
49
}
50
51
1;
(-)a/Koha/Acquisition/Order.pm (+6 lines)
Lines 2-7 package Koha::Acquisition::Order; Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Koha::Acquisition::Baskets;
5
use Koha::Database;
6
use Koha::Database;
6
use Koha::DateUtils qw( dt_from_string output_pref );
7
use Koha::DateUtils qw( dt_from_string output_pref );
7
8
Lines 68-73 sub add_item { Link Here
68
    $rs->create({ ordernumber => $self->{ordernumber}, itemnumber => $itemnumber });
69
    $rs->create({ ordernumber => $self->{ordernumber}, itemnumber => $itemnumber });
69
}
70
}
70
71
72
sub basket {
73
    my ( $self )  = @_;
74
    return Koha::Acquisition::Baskets->find( $self->{basketno} );
75
}
76
71
# TODO Move code from ModItemOrder
77
# TODO Move code from ModItemOrder
72
sub update_item {
78
sub update_item {
73
    die "not implemented yet";
79
    die "not implemented yet";
(-)a/acqui/addorder.pl (-1 / +3 lines)
Lines 232-237 my $basketno=$$orderinfo{basketno}; Link Here
232
my $basket = GetBasket($basketno);
232
my $basket = GetBasket($basketno);
233
233
234
my $user = $input->remote_user;
234
my $user = $input->remote_user;
235
my $basketno=$$orderinfo{basketno};
236
my $basket = Koha::Acquisition::Baskets->find( $basketno );
235
237
236
# create, modify or delete biblio
238
# create, modify or delete biblio
237
# create if $quantity>0 and $existing='no'
239
# create if $quantity>0 and $existing='no'
Lines 281-287 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
281
    }
283
    }
282
284
283
    # now, add items if applicable
285
    # now, add items if applicable
284
    if (C4::Context->preference('AcqCreateItem') eq 'ordering') {
286
    if ($basket->effective_create_items eq 'ordering') {
285
287
286
        my @tags         = $input->multi_param('tag');
288
        my @tags         = $input->multi_param('tag');
287
        my @subfields    = $input->multi_param('subfield');
289
        my @subfields    = $input->multi_param('subfield');
(-)a/acqui/addorderiso2709.pl (-1 / +13 lines)
Lines 44-49 use C4::Members; Link Here
44
44
45
use Koha::Number::Price;
45
use Koha::Number::Price;
46
use Koha::Acquisition::Currencies;
46
use Koha::Acquisition::Currencies;
47
use Koha::Acquisition::Baskets;
47
use Koha::Acquisition::Order;
48
use Koha::Acquisition::Order;
48
use Koha::Acquisition::Bookseller;
49
use Koha::Acquisition::Bookseller;
49
50
Lines 76-81 if ($cgiparams->{'import_batch_id'} && $op eq ""){ Link Here
76
if (! $cgiparams->{'basketno'}){
77
if (! $cgiparams->{'basketno'}){
77
    die "Basketnumber required to order from iso2709 file import";
78
    die "Basketnumber required to order from iso2709 file import";
78
}
79
}
80
my $basket = Koha::Acquisition::Baskets->find( $cgiparams->{basketno} );
79
81
80
#
82
#
81
# 1st step = choose the file to import into acquisition
83
# 1st step = choose the file to import into acquisition
Lines 100-106 if ($op eq ""){ Link Here
100
                     );
102
                     );
101
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
103
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
102
    my $basket = GetBasket($cgiparams->{basketno});
104
    my $basket = GetBasket($cgiparams->{basketno});
103
    if ( C4::Context->preference('AcqCreateItem') eq 'ordering' && !$basket->{is_standing} ) {
105
    if ( $basket->effective_create_items eq 'ordering' && !$basket->{is_standing} ) {
104
        # prepare empty item form
106
        # prepare empty item form
105
        my $cell = PrepareItemrecordDisplay( '', '', '', 'ACQ' );
107
        my $cell = PrepareItemrecordDisplay( '', '', '', 'ACQ' );
106
108
Lines 239-244 if ($op eq ""){ Link Here
239
        # 4th, add items if applicable
241
        # 4th, add items if applicable
240
        # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
242
        # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
241
        # this is not optimised, but it's working !
243
        # this is not optimised, but it's working !
244
<<<<<<< HEAD
242
        my $basket = GetBasket($cgiparams->{basketno});
245
        my $basket = GetBasket($cgiparams->{basketno});
243
        if ( C4::Context->preference('AcqCreateItem') eq 'ordering' && !$basket->{is_standing} ) {
246
        if ( C4::Context->preference('AcqCreateItem') eq 'ordering' && !$basket->{is_standing} ) {
244
            my @tags         = $input->multi_param('tag');
247
            my @tags         = $input->multi_param('tag');
Lines 247-252 if ($op eq ""){ Link Here
247
            my @serials      = $input->multi_param('serial');
250
            my @serials      = $input->multi_param('serial');
248
            my @ind_tag   = $input->multi_param('ind_tag');
251
            my @ind_tag   = $input->multi_param('ind_tag');
249
            my @indicator = $input->multi_param('indicator');
252
            my @indicator = $input->multi_param('indicator');
253
=======
254
        if ( $basket->effective_create_items eq 'ordering' ) {
255
            my @tags         = $input->param('tag');
256
            my @subfields    = $input->param('subfield');
257
            my @field_values = $input->param('field_value');
258
            my @serials      = $input->param('serial');
259
            my @ind_tag   = $input->param('ind_tag');
260
            my @indicator = $input->param('indicator');
261
>>>>>>> Bug 15685: Allow creation of items (AcqCreateItem) to be customizable per-basket
250
            my $item;
262
            my $item;
251
            push @{ $item->{tags} },         $tags[0];
263
            push @{ $item->{tags} },         $tags[0];
252
            push @{ $item->{subfields} },    $subfields[0];
264
            push @{ $item->{subfields} },    $subfields[0];
(-)a/acqui/basket.pl (+1 lines)
Lines 365-370 elsif ( $op eq 'ediorder' ) { Link Here
365
    }
365
    }
366
366
367
    $template->param(
367
    $template->param(
368
        basket               => $basket,
368
        basketno             => $basketno,
369
        basketno             => $basketno,
369
        basket               => $basket,
370
        basket               => $basket,
370
        basketname           => $basket->{'basketname'},
371
        basketname           => $basket->{'basketname'},
(-)a/acqui/basketheader.pl (+2 lines)
Lines 150-155 if ( $op eq 'add_form' ) { Link Here
150
            $input->param('deliveryplace'),
150
            $input->param('deliveryplace'),
151
            $input->param('billingplace'),
151
            $input->param('billingplace'),
152
            $input->param('is_standing') ? 1 : undef,
152
            $input->param('is_standing') ? 1 : undef,
153
            $input->param('create_items'),
153
        );
154
        );
154
    } else { #New basket
155
    } else { #New basket
155
        $basketno = NewBasket(
156
        $basketno = NewBasket(
Lines 162-167 if ( $op eq 'add_form' ) { Link Here
162
            $input->param('deliveryplace'),
163
            $input->param('deliveryplace'),
163
            $input->param('billingplace'),
164
            $input->param('billingplace'),
164
            $input->param('is_standing') ? 1 : undef,
165
            $input->param('is_standing') ? 1 : undef,
166
            $input->param('create_items'),
165
        );
167
        );
166
    }
168
    }
167
    print $input->redirect('basket.pl?basketno='.$basketno);
169
    print $input->redirect('basket.pl?basketno='.$basketno);
(-)a/acqui/finishreceive.pl (-3 / +6 lines)
Lines 33-38 use C4::Items; Link Here
33
use C4::Search;
33
use C4::Search;
34
34
35
use Koha::Acquisition::Bookseller;
35
use Koha::Acquisition::Bookseller;
36
use Koha::Acquisition::Order;
36
37
37
use List::MoreUtils qw/any/;
38
use List::MoreUtils qw/any/;
38
39
Lines 61-71 my $bookfund = $input->param("bookfund"); Link Here
61
my $order            = GetOrder($ordernumber);
62
my $order            = GetOrder($ordernumber);
62
my $new_ordernumber  = $ordernumber;
63
my $new_ordernumber  = $ordernumber;
63
64
65
my $basket = Koha::Acquisition::Order->find($ordernumber)->basket;
66
64
#need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME
67
#need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME
65
if ($quantityrec > $origquantityrec ) {
68
if ($quantityrec > $origquantityrec ) {
66
    my @received_items = ();
69
    my @received_items = ();
67
    if(C4::Context->preference('AcqCreateItem') eq 'ordering') {
70
    if ($basket->effective_create_items eq 'ordering') {
68
        @received_items = $input->multi_param('items_to_receive');
71
        @received_items = $input->param('items_to_receive');
69
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceived");
72
        my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceived");
70
        if ( @affects ) {
73
        if ( @affects ) {
71
            my $frameworkcode = GetFrameworkCode($biblionumber);
74
            my $frameworkcode = GetFrameworkCode($biblionumber);
Lines 120-126 if ($quantityrec > $origquantityrec ) { Link Here
120
    }
123
    }
121
124
122
    # now, add items if applicable
125
    # now, add items if applicable
123
    if (C4::Context->preference('AcqCreateItem') eq 'receiving') {
126
    if ($basket->effective_create_items eq 'receiving') {
124
127
125
        my @tags         = $input->multi_param('tag');
128
        my @tags         = $input->multi_param('tag');
126
        my @subfields    = $input->multi_param('subfield');
129
        my @subfields    = $input->multi_param('subfield');
(-)a/acqui/neworderempty.pl (-2 / +3 lines)
Lines 130-135 if(!$basketno) { Link Here
130
}
130
}
131
131
132
our $basket = GetBasket($basketno);
132
our $basket = GetBasket($basketno);
133
my $basketobj = Koha::Acquisition::Baskets->find( $basketno );
133
$booksellerid = $basket->{booksellerid} unless $booksellerid;
134
$booksellerid = $basket->{booksellerid} unless $booksellerid;
134
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
135
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
135
136
Lines 263-269 if ($close) { Link Here
263
$template->param( sort1 => $data->{'sort1'} );
264
$template->param( sort1 => $data->{'sort1'} );
264
$template->param( sort2 => $data->{'sort2'} );
265
$template->param( sort2 => $data->{'sort2'} );
265
266
266
if (C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber) {
267
if ($basketobj->effective_create_items eq 'ordering' && !$ordernumber) {
267
    # Check if ACQ framework exists
268
    # Check if ACQ framework exists
268
    my $marc = GetMarcStructure(1, 'ACQ');
269
    my $marc = GetMarcStructure(1, 'ACQ');
269
    unless($marc) {
270
    unless($marc) {
Lines 378-384 $template->param( Link Here
378
    barcode_subfield => $barcode_subfield,
379
    barcode_subfield => $barcode_subfield,
379
    import_batch_id  => $import_batch_id,
380
    import_batch_id  => $import_batch_id,
380
    subscriptionid   => $subscriptionid,
381
    subscriptionid   => $subscriptionid,
381
    acqcreate        => C4::Context->preference("AcqCreateItem") eq "ordering" ? 1 : "",
382
    acqcreate        => $basketobj->effective_create_items eq "ordering" ? 1 : "",
382
    users_ids        => join(':', @order_user_ids),
383
    users_ids        => join(':', @order_user_ids),
383
    users            => \@order_users,
384
    users            => \@order_users,
384
    (uc(C4::Context->preference("marcflavour"))) => 1
385
    (uc(C4::Context->preference("marcflavour"))) => 1
(-)a/acqui/orderreceive.pl (-1 / +2 lines)
Lines 110-115 unless ( $results and @$results) { Link Here
110
110
111
# prepare the form for receiving
111
# prepare the form for receiving
112
my $order = $results->[0];
112
my $order = $results->[0];
113
my $basket = Koha::Acquisition::Order->find($ordernumber)->basket;
113
114
114
# Check if ACQ framework exists
115
# Check if ACQ framework exists
115
my $acq_fw = GetMarcStructure(1, 'ACQ');
116
my $acq_fw = GetMarcStructure(1, 'ACQ');
Lines 117-123 unless($acq_fw) { Link Here
117
    $template->param('NoACQframework' => 1);
118
    $template->param('NoACQframework' => 1);
118
}
119
}
119
120
120
my $AcqCreateItem = C4::Context->preference('AcqCreateItem');
121
my $AcqCreateItem = $basket->effective_create_items;
121
if ($AcqCreateItem eq 'receiving') {
122
if ($AcqCreateItem eq 'receiving') {
122
    $template->param(
123
    $template->param(
123
        AcqCreateItemReceiving => 1,
124
        AcqCreateItemReceiving => 1,
(-)a/acqui/parcel.pl (+2 lines)
Lines 67-72 use C4::Output; Link Here
67
use C4::Suggestions;
67
use C4::Suggestions;
68
use C4::Reserves qw/GetReservesFromBiblionumber/;
68
use C4::Reserves qw/GetReservesFromBiblionumber/;
69
69
70
use Koha::Acquisition::Baskets;
70
use Koha::Acquisition::Bookseller;
71
use Koha::Acquisition::Bookseller;
71
use Koha::DateUtils;
72
use Koha::DateUtils;
72
73
Lines 265-270 unless( defined $invoice->{closedate} ) { Link Here
265
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
266
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
266
        $line{holds}                = $holds;
267
        $line{holds}                = $holds;
267
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
268
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
269
        $line{basket}               = Koha::Acquisition::Baskets->find( $line{basketno} );
268
270
269
        my $budget_name = GetBudgetName( $line{budget_id} );
271
        my $budget_name = GetBudgetName( $line{budget_id} );
270
        $line{budget_name} = $budget_name;
272
        $line{budget_name} = $budget_name;
(-)a/acqui/uncertainprice.pl (+3 lines)
Lines 54-59 use C4::Bookseller::Contact; Link Here
54
use C4::Acquisition qw/SearchOrders GetOrder ModOrder/;
54
use C4::Acquisition qw/SearchOrders GetOrder ModOrder/;
55
use C4::Biblio qw/GetBiblioData/;
55
use C4::Biblio qw/GetBiblioData/;
56
56
57
use Koha::Acquisition::Baskets;
57
use Koha::Acquisition::Bookseller;
58
use Koha::Acquisition::Bookseller;
58
59
59
my $input=new CGI;
60
my $input=new CGI;
Lines 73-78 my $op = $input->param('op'); Link Here
73
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
74
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
74
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
75
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
75
76
77
$template->param( basket => Koha::Acquisition::Baskets->find($basketno) );
78
76
#show all orders that have uncertain price for the bookseller
79
#show all orders that have uncertain price for the bookseller
77
my $pendingorders = SearchOrders({
80
my $pendingorders = SearchOrders({
78
    booksellerid => $booksellerid,
81
    booksellerid => $booksellerid,
(-)a/installer/data/mysql/atomicupdate/bug_15685-add_create_items_to_aqbasket.sql (+1 lines)
Line 0 Link Here
1
ALTER TABLE aqbasket ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') DEFAULT NULL;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2943-2948 CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions Link Here
2943
  `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
2943
  `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
2944
  `deliveryplace` varchar(10) default NULL, -- basket delivery place
2944
  `deliveryplace` varchar(10) default NULL, -- basket delivery place
2945
  `billingplace` varchar(10) default NULL, -- basket billing place
2945
  `billingplace` varchar(10) default NULL, -- basket billing place
2946
  create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL; -- when items should be created for orders in this basket
2946
  branch varchar(10) default NULL, -- basket branch
2947
  branch varchar(10) default NULL, -- basket branch
2947
  is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
2948
  is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
2948
  PRIMARY KEY  (`basketno`),
2949
  PRIMARY KEY  (`basketno`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-1 / +10 lines)
Lines 352-360 Link Here
352
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
352
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
353
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %]
353
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %]
354
                [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates  %]</li>[% END %]
354
                [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates  %]</li>[% END %]
355
                [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates  %]</li>[% END %]
356
                <li><span class="label">Orders are standing:</span> [% IF is_standing %]Yes[% ELSE %]No[% END %]</li>
355
                <li><span class="label">Orders are standing:</span> [% IF is_standing %]Yes[% ELSE %]No[% END %]</li>
357
356
357
                [% IF basket.create_items %]
358
                    <li>
359
                        <span class="label">Create items when:</span>
360
                        [% SWITCH basket.create_items %]
361
                            [% CASE 'receiving' %]Receiving items
362
                            [% CASE 'cataloguing' %]Cataloguing items
363
                            [% CASE %]Placing orders
364
                        [% END %]
365
                    </li>
366
                [% END %]
358
367
359
                </ol>
368
                </ol>
360
                </div>
369
                </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt (-1 / +16 lines)
Lines 41-47 Link Here
41
                [% IF ( basketno ) %]
41
                [% IF ( basketno ) %]
42
                    <li>
42
                    <li>
43
                        <input type="hidden" name="basketno" value="[% basketno %]" />
43
                        <input type="hidden" name="basketno" value="[% basketno %]" />
44
                        <input type="hidden" name="is_an_edit" value="1" />
44
                        <input type="hidden" name="rs_an_edit" value="1" />
45
                    </li>
45
                    </li>
46
                [% END %]
46
                [% END %]
47
                <li>
47
                <li>
Lines 122-127 Link Here
122
                    [% END %]
122
                    [% END %]
123
                    <div class="hint">Standing orders do not close when received.</div>
123
                    <div class="hint">Standing orders do not close when received.</div>
124
                </li>
124
                </li>
125
                [% UNLESS basketno %]
126
                 <li>
127
                    <label for="create_items">Create items when:</label>
128
                    <select name="create_items" id="create_items">
129
                        [% SWITCH Koha.Preference('AcqCreateItem') %]
130
                            [% CASE 'receiving' %]<option value="">use default (receiving an order).</option>
131
                            [% CASE 'cataloguing' %]<option value="">use default (cataloging the record).</option>
132
                            [% CASE %]<option value="">use default (placing an order).</option>
133
                        [% END %]
134
                        <option value="ordering">placing an order.</option>
135
                        <option value="receiving">receiving an order.</option>
136
                        <option value="cataloguing">cataloging the record.</option>
137
                    </select>
138
                </li>
139
                [% END %]
125
            </ol>
140
            </ol>
126
        </fieldset>
141
        </fieldset>
127
        <fieldset class="action">
142
        <fieldset class="action">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-1 / +1 lines)
Lines 431-437 Link Here
431
                <td>[% order.unitprice | $Price %]</td>
431
                <td>[% order.unitprice | $Price %]</td>
432
                <td>[% order.total | $Price %]</td>
432
                <td>[% order.total | $Price %]</td>
433
                <td>
433
                <td>
434
                    [% IF loop_receive.cannot_cancel or ( Koha.Preference("AcqCreateItem") == "receiving" and loop_receive.holds > 0 ) %]
434
                    [% IF loop_receive.cannot_cancel or ( order.basket.effective_create_items == "receiving" and loop_receive.holds > 0 ) %]
435
                      [% IF loop_receive.cannot_cancel %]
435
                      [% IF loop_receive.cannot_cancel %]
436
                        [% span_title = BLOCK %]
436
                        [% span_title = BLOCK %]
437
                            Cannot cancel receipt of this order line because it
437
                            Cannot cancel receipt of this order line because it
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt (-1 / +1 lines)
Lines 127-133 function check(form) { Link Here
127
	    </td>
127
	    </td>
128
	    <td>
128
	    <td>
129
	        
129
	        
130
        [% IF Koha.Preference('AcqCreateItem') == 'ordering' %]
130
        [% IF basket.effective_create_items == 'ordering' %]
131
            [% uncertainpriceorder.quantity %]
131
            [% uncertainpriceorder.quantity %]
132
            <input type="hidden" name="qty[% uncertainpriceorder.ordernumber %]" value="[% uncertainpriceorder.quantity %]" />
132
            <input type="hidden" name="qty[% uncertainpriceorder.ordernumber %]" value="[% uncertainpriceorder.quantity %]" />
133
        [% ELSE %]
133
        [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (+1 lines)
Lines 8-13 Acquisitions: Link Here
8
                  ordering: placing an order.
8
                  ordering: placing an order.
9
                  receiving: receiving an order.
9
                  receiving: receiving an order.
10
                  cataloguing: cataloging the record.
10
                  cataloguing: cataloging the record.
11
            - This is only the default behavior, and can be changed per-basket.
11
        -
12
        -
12
            - "The following <a href='http://schema.koha-community.org/tables/items.html' target='blank'>database columns</a> should be unique in an item:"
13
            - "The following <a href='http://schema.koha-community.org/tables/items.html' target='blank'>database columns</a> should be unique in an item:"
13
            - pref: UniqueItemFields
14
            - pref: UniqueItemFields
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-2 / +2 lines)
Lines 641-647 Link Here
641
                            <p>This record has many physical items ([% items_count %]). <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]&amp;viewallitems=1">Click here to view them all.</a></p>
641
                            <p>This record has many physical items ([% items_count %]). <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]&amp;viewallitems=1">Click here to view them all.</a></p>
642
                        [% ELSIF ( itemloop.size ) %]
642
                        [% ELSIF ( itemloop.size ) %]
643
                            [% INCLUDE items_table items=itemloop tab="holdings" %]
643
                            [% INCLUDE items_table items=itemloop tab="holdings" %]
644
                            [% IF Koha.Preference('OPACAcquisitionDetails') and Koha.Preference('AcqCreateItem') != 'ordering' and acquisition_details.total_quantity > 0 %]
644
                            [% IF Koha.Preference('OPACAcquisitionDetails') and acquisition_details.total_quantity > 0 %]
645
                              [% IF acquisition_details.total_quantity == 1 %]
645
                              [% IF acquisition_details.total_quantity == 1 %]
646
                                1 item is on order.
646
                                1 item is on order.
647
                              [% ELSE %]
647
                              [% ELSE %]
Lines 668-674 Link Here
668
                                    <div id="alternateholdings"><span class="holdings_label">Holdings:</span> [% ALTERNATEHOLDING.holding %]</div>
668
                                    <div id="alternateholdings"><span class="holdings_label">Holdings:</span> [% ALTERNATEHOLDING.holding %]</div>
669
                                [% END %]
669
                                [% END %]
670
                            [% ELSE %]
670
                            [% ELSE %]
671
                                [% IF Koha.Preference('OPACAcquisitionDetails') and Koha.Preference('AcqCreateItem') != 'ordering' and acquisition_details.total_quantity > 0 %]
671
                                [% IF Koha.Preference('OPACAcquisitionDetails') and acquisition_details.total_quantity > 0 %]
672
                                  [% IF acquisition_details.total_quantity == 1 %]
672
                                  [% IF acquisition_details.total_quantity == 1 %]
673
                                    1 item is on order.
673
                                    1 item is on order.
674
                                  [% ELSE %]
674
                                  [% ELSE %]
(-)a/opac/opac-detail.pl (-5 / +4 lines)
Lines 51-56 use Koha::DateUtils; Link Here
51
use C4::HTML5Media;
51
use C4::HTML5Media;
52
use C4::CourseReserves qw(GetItemCourseReservesInfo);
52
use C4::CourseReserves qw(GetItemCourseReservesInfo);
53
53
54
use Koha::Acquisition::Order;
54
use Koha::Virtualshelves;
55
use Koha::Virtualshelves;
55
56
56
BEGIN {
57
BEGIN {
Lines 610-616 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { Link Here
610
    });
611
    });
611
    my $total_quantity = 0;
612
    my $total_quantity = 0;
612
    for my $order ( @$orders ) {
613
    for my $order ( @$orders ) {
613
        if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
614
        my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket;
615
        if ( $basket->effective_create_items eq 'ordering' ) {
614
            for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) {
616
            for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) {
615
                push @itemnumbers_on_order, $itemnumber;
617
                push @itemnumbers_on_order, $itemnumber;
616
            }
618
            }
Lines 671-679 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
671
        $itm->{transfertto}   = $branches->{$transfertto}{branchname};
673
        $itm->{transfertto}   = $branches->{$transfertto}{branchname};
672
     }
674
     }
673
    
675
    
674
    if (    C4::Context->preference('OPACAcquisitionDetails')
676
    if ( C4::Context->preference('OPACAcquisitionDetails') ) {
675
        and C4::Context->preference('AcqCreateItem') eq 'ordering' )
676
    {
677
        $itm->{on_order} = 1
677
        $itm->{on_order} = 1
678
          if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
678
          if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
679
    }
679
    }
680
- 

Return to bug 15685