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

(-)a/C4/Acquisition.pm (-8 / +5 lines)
Lines 824-830 sub CanUserManageBasket { Link Here
824
    my $bool = CanUserReceiveOrder($borrowernumber, $orderno[, $userflags]);
824
    my $bool = CanUserReceiveOrder($borrowernumber, $orderno[, $userflags]);
825
825
826
Check if a borrower can receive a order, according to user permissions, current
826
Check if a borrower can receive a order, according to user permissions, current
827
working branch and order and basket branches.
827
working branch and basket branches.
828
828
829
First parameter can be either a borrowernumber or a hashref as returned by
829
First parameter can be either a borrowernumber or a hashref as returned by
830
C4::Members::GetMember.
830
C4::Members::GetMember.
Lines 871-888 sub CanUserReceiveOrder { Link Here
871
        if (!ref $userflags->{acquisition} && !$userflags->{acquisition}) {
871
        if (!ref $userflags->{acquisition} && !$userflags->{acquisition}) {
872
            return 0;
872
            return 0;
873
        }
873
        }
874
874
        if (ref $userflags->{acquisition} && !$userflags->{acquisition}->{order_receive}) {
875
        if (ref $userflags->{acquisition} && !$userflags->{acquisition}->{order_receive}) {
875
            return 0;
876
            return 0;
876
        }
877
        }
877
        if (defined $order->{branch} && $order->{branch} ne $branch) {
878
879
        my $basket = GetBasket($order->{basketno});
880
        if (!$basket || (defined $basket->{branch} && $basket->{branch} ne $branch)) {
878
            return 0;
881
            return 0;
879
        }
882
        }
880
        if (!defined $order->{branch}) {
881
            my $basket = GetBasket($order->{basketno});
882
            if (!$basket || (defined $basket->{branch} && $basket->{branch} ne $branch)) {
883
                return 0;
884
            }
885
        }
886
    }
883
    }
887
884
888
    return 1;
885
    return 1;
(-)a/acqui/addorder.pl (-1 lines)
Lines 226-232 my $orderinfo = $input->Vars; Link Here
226
$orderinfo->{'list_price'}    ||=  0;
226
$orderinfo->{'list_price'}    ||=  0;
227
$orderinfo->{'uncertainprice'} ||= 0;
227
$orderinfo->{'uncertainprice'} ||= 0;
228
$orderinfo->{subscriptionid} ||= undef;
228
$orderinfo->{subscriptionid} ||= undef;
229
$orderinfo->{branch} = undef if (defined $orderinfo->{branch} and $orderinfo->{branch} eq '');
230
229
231
my $user = $input->remote_user;
230
my $user = $input->remote_user;
232
231
(-)a/installer/data/mysql/kohastructure.sql (-3 lines)
Lines 3024-3041 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
3024
  `claimed_date` date default NULL, -- last date a claim was generated
3024
  `claimed_date` date default NULL, -- last date a claim was generated
3025
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
3025
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
3026
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
3026
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
3027
  branch varchar(10) default NULL, -- order line branch
3028
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
3027
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
3029
  PRIMARY KEY  (`ordernumber`),
3028
  PRIMARY KEY  (`ordernumber`),
3030
  KEY `basketno` (`basketno`),
3029
  KEY `basketno` (`basketno`),
3031
  KEY `biblionumber` (`biblionumber`),
3030
  KEY `biblionumber` (`biblionumber`),
3032
  KEY `budget_id` (`budget_id`),
3031
  KEY `budget_id` (`budget_id`),
3033
  KEY branch (branch),
3034
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3032
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3035
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3033
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3036
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
3034
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
3037
  CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
3035
  CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
3038
  CONSTRAINT aqorders_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL
3039
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3036
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3040
3037
3041
3038
(-)a/installer/data/mysql/updatedatabase.pl (-6 lines)
Lines 8474-8485 if ( CheckVersion($DBversion) ) { Link Here
8474
$DBversion = "XXX";
8474
$DBversion = "XXX";
8475
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8475
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8476
    $dbh->do("
8476
    $dbh->do("
8477
        ALTER TABLE aqorders
8478
          ADD COLUMN branch VARCHAR(10) DEFAULT NULL,
8479
          ADD CONSTRAINT aqorders_branch FOREIGN KEY (branch)
8480
            REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL
8481
    ");
8482
    $dbh->do("
8483
        INSERT INTO permissions (module_bit, code, description)
8477
        INSERT INTO permissions (module_bit, code, description)
8484
          VALUES (11, 'order_receive_all', 'Receive all orders')
8478
          VALUES (11, 'order_receive_all', 'Receive all orders')
8485
    ");
8479
    ");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-19 lines)
Lines 228-252 $(document).ready(function() Link Here
228
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
228
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
229
229
230
<fieldset class="rows">
230
<fieldset class="rows">
231
    <legend>Order details</legend>
232
    <ol>
233
        <li>
234
            <span class="label">Branch:</span>
235
            <select name="branch">
236
                <option value="">&nbsp;</option>
237
                [% FOREACH branch IN branchloop %]
238
                    [% IF branch.selected %]
239
                        <option selected="selected" value="[% branch.value %]">[% branch.branchname %]</option>
240
                    [% ELSE %]
241
                        <option value="[% branch.value %]">[% branch.branchname %]</option>
242
                    [% END %]
243
                [% END %]
244
            </select>
245
        </li>
246
    </ol>
247
</fieldset>
248
249
<fieldset class="rows">
250
        <legend>
231
        <legend>
251
            Catalog details
232
            Catalog details
252
            [% IF ( biblionumber ) %]
233
            [% IF ( biblionumber ) %]
(-)a/t/Acquisition/CanUserReceiveBasket.t (-40 / +2 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::MockModule;
4
use Test::MockModule;
5
use Test::More tests => 30;
5
use Test::More tests => 18;
6
6
7
use C4::Acquisition;
7
use C4::Acquisition;
8
8
Lines 29-63 my $order1 = { Link Here
29
    basketno => 1
29
    basketno => 1
30
};
30
};
31
my $order2 = {
31
my $order2 = {
32
    basketno => 1,
33
    branch => 'B1'
34
};
35
my $order3 = {
36
    basketno => 1,
37
    branch => 'B2'
38
};
39
my $order4 = {
40
    basketno => 2
32
    basketno => 2
41
};
33
};
42
my $order5 = {
34
my $order3 = {
43
    basketno => 2,
44
    branch => 'B1'
45
};
46
my $order6 = {
47
    basketno => 2,
48
    branch => 'B2'
49
};
50
my $order7 = {
51
    basketno => 3
35
    basketno => 3
52
};
36
};
53
my $order8 = {
54
    basketno => 3,
55
    branch => 'B1'
56
};
57
my $order9 = {
58
    basketno => 3,
59
    branch => 'B2'
60
};
61
37
62
$userenv->{branch} = 'B1';
38
$userenv->{branch} = 'B1';
63
39
Lines 72-84 ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive Link Here
72
ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) );
48
ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) );
73
ok( CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) );
49
ok( CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) );
74
ok( not CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) );
50
ok( not CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) );
75
ok( CanUserReceiveOrder($borrower, $order4, {acquisition => { order_receive => 1 }}) );
76
ok( CanUserReceiveOrder($borrower, $order5, {acquisition => { order_receive => 1 }}) );
77
ok( not CanUserReceiveOrder($borrower, $order6, {acquisition => { order_receive => 1 }}) );
78
ok( not CanUserReceiveOrder($borrower, $order7, {acquisition => { order_receive => 1 }}) );
79
ok( CanUserReceiveOrder($borrower, $order8, {acquisition => { order_receive => 1 }}) );
80
ok( not CanUserReceiveOrder($borrower, $order9, {acquisition => { order_receive => 1 }}) );
81
82
51
83
$userenv->{branch} = 'B2';
52
$userenv->{branch} = 'B2';
84
53
Lines 93-104 ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive Link Here
93
ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) );
62
ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) );
94
ok( not CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) );
63
ok( not CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) );
95
ok( CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) );
64
ok( CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) );
96
ok( not CanUserReceiveOrder($borrower, $order4, {acquisition => { order_receive => 1 }}) );
97
ok( not CanUserReceiveOrder($borrower, $order5, {acquisition => { order_receive => 1 }}) );
98
ok( CanUserReceiveOrder($borrower, $order6, {acquisition => { order_receive => 1 }}) );
99
ok( CanUserReceiveOrder($borrower, $order7, {acquisition => { order_receive => 1 }}) );
100
ok( not CanUserReceiveOrder($borrower, $order8, {acquisition => { order_receive => 1 }}) );
101
ok( CanUserReceiveOrder($borrower, $order9, {acquisition => { order_receive => 1 }}) );
102
65
103
sub Mock_GetBasket {
66
sub Mock_GetBasket {
104
    my ($basketno) = @_;
67
    my ($basketno) = @_;
105
- 

Return to bug 7290