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

(-)a/C4/Acquisition.pm (-8 / +5 lines)
Lines 805-811 sub CanUserManageBasket { Link Here
805
    my $bool = CanUserReceiveOrder($borrowernumber, $orderno[, $userflags]);
805
    my $bool = CanUserReceiveOrder($borrowernumber, $orderno[, $userflags]);
806
806
807
Check if a borrower can receive a order, according to user permissions, current
807
Check if a borrower can receive a order, according to user permissions, current
808
working branch and order and basket branches.
808
working branch and basket branches.
809
809
810
First parameter can be either a borrowernumber or a hashref as returned by
810
First parameter can be either a borrowernumber or a hashref as returned by
811
C4::Members::GetMember.
811
C4::Members::GetMember.
Lines 852-869 sub CanUserReceiveOrder { Link Here
852
        if (!ref $userflags->{acquisition} && !$userflags->{acquisition}) {
852
        if (!ref $userflags->{acquisition} && !$userflags->{acquisition}) {
853
            return 0;
853
            return 0;
854
        }
854
        }
855
855
        if (ref $userflags->{acquisition} && !$userflags->{acquisition}->{order_receive}) {
856
        if (ref $userflags->{acquisition} && !$userflags->{acquisition}->{order_receive}) {
856
            return 0;
857
            return 0;
857
        }
858
        }
858
        if (defined $order->{branch} && $order->{branch} ne $branch) {
859
860
        my $basket = GetBasket($order->{basketno});
861
        if (!$basket || (defined $basket->{branch} && $basket->{branch} ne $branch)) {
859
            return 0;
862
            return 0;
860
        }
863
        }
861
        if (!defined $order->{branch}) {
862
            my $basket = GetBasket($order->{basketno});
863
            if (!$basket || (defined $basket->{branch} && $basket->{branch} ne $branch)) {
864
                return 0;
865
            }
866
        }
867
    }
864
    }
868
865
869
    return 1;
866
    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 2996-3013 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2996
  `claimed_date` date default NULL, -- last date a claim was generated
2996
  `claimed_date` date default NULL, -- last date a claim was generated
2997
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
2997
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
2998
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
2998
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
2999
  branch varchar(10) default NULL, -- order line branch
3000
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
2999
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
3001
  PRIMARY KEY  (`ordernumber`),
3000
  PRIMARY KEY  (`ordernumber`),
3002
  KEY `basketno` (`basketno`),
3001
  KEY `basketno` (`basketno`),
3003
  KEY `biblionumber` (`biblionumber`),
3002
  KEY `biblionumber` (`biblionumber`),
3004
  KEY `budget_id` (`budget_id`),
3003
  KEY `budget_id` (`budget_id`),
3005
  KEY branch (branch),
3006
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3004
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
3007
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3005
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3008
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
3006
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
3009
  CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
3007
  CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
3010
  CONSTRAINT aqorders_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL
3011
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3008
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3012
3009
3013
3010
(-)a/installer/data/mysql/updatedatabase.pl (-6 lines)
Lines 8086-8097 if ( CheckVersion($DBversion) ) { Link Here
8086
$DBversion = "XXX";
8086
$DBversion = "XXX";
8087
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8087
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8088
    $dbh->do("
8088
    $dbh->do("
8089
        ALTER TABLE aqorders
8090
          ADD COLUMN branch VARCHAR(10) DEFAULT NULL,
8091
          ADD CONSTRAINT aqorders_branch FOREIGN KEY (branch)
8092
            REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL
8093
    ");
8094
    $dbh->do("
8095
        INSERT INTO permissions (module_bit, code, description)
8089
        INSERT INTO permissions (module_bit, code, description)
8096
          VALUES (11, 'order_receive_all', 'Receive all orders')
8090
          VALUES (11, 'order_receive_all', 'Receive all orders')
8097
    ");
8091
    ");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-19 lines)
Lines 210-234 $(document).ready(function() Link Here
210
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
210
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
211
211
212
<fieldset class="rows">
212
<fieldset class="rows">
213
    <legend>Order details</legend>
214
    <ol>
215
        <li>
216
            <span class="label">Branch:</span>
217
            <select name="branch">
218
                <option value="">&nbsp;</option>
219
                [% FOREACH branch IN branchloop %]
220
                    [% IF branch.selected %]
221
                        <option selected="selected" value="[% branch.value %]">[% branch.branchname %]</option>
222
                    [% ELSE %]
223
                        <option value="[% branch.value %]">[% branch.branchname %]</option>
224
                    [% END %]
225
                [% END %]
226
            </select>
227
        </li>
228
    </ol>
229
</fieldset>
230
231
<fieldset class="rows">
232
        <legend>
213
        <legend>
233
            Catalog details
214
            Catalog details
234
            [% IF ( biblionumber ) %]
215
            [% 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