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

(-)a/C4/NCIP/CancelRequestItem.pm (-12 / +12 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::CancelRequestItem;
20
package C4::NCIP::CancelRequestItem;
21
21
(-)a/C4/NCIP/LookupItem.pm (-23 / +23 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::LookupItem;
20
package C4::NCIP::LookupItem;
21
21
Lines 150-166 sub parseItem { Link Here
150
150
151
    return 'SQL query failed' unless $result;
151
    return 'SQL query failed' unless $result;
152
152
153
    $result->{itemId}        = $itemId;
153
    $result->{itemnumber}     = $itemId;
154
    $result->{bibId}         = $bibId;
154
    $result->{biblionumber}   = $bibId;
155
    $result->{barcode}       = $item->{barcode};
155
    $result->{barcode}        = $item->{barcode};
156
    $result->{location}      = $item->{location};
156
    $result->{location}       = $item->{location};
157
    $result->{homebranch}    = $item->{homebranch};
157
    $result->{homebranch}     = $item->{homebranch};
158
    $result->{restricted}    = $item->{restricted};
158
    $result->{restricted}     = $item->{restricted};
159
    $result->{holdingbranch} = $item->{holdingbranch};
159
    $result->{holdingbranch}  = $item->{holdingbranch};
160
    $result->{mediumtype}    = $item->{itype};
160
    $result->{itype}          = $item->{itype};
161
    $result->{copynumber}    = $item->{copynumber};
161
    $result->{copynumber}     = $item->{copynumber};
162
    $result->{callnumber}    = $item->{itemcallnumber};
162
    $result->{itemcallnumber} = $item->{itemcallnumber};
163
    $result->{ccode}         = $item->{ccode};
163
    $result->{ccode}          = $item->{ccode};
164
164
165
    return C4::NCIP::NcipUtils::clearEmptyKeys($result);
165
    return C4::NCIP::NcipUtils::clearEmptyKeys($result);
166
}
166
}
(-)a/C4/NCIP/LookupItemSet.pm (-15 / +18 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::LookupItemSet;
20
package C4::NCIP::LookupItemSet;
21
21
Lines 116-123 sub lookupItemSet { Link Here
116
    }
116
    }
117
    my $desiredSomething
117
    my $desiredSomething
118
        = $holdQueueDesired
118
        = $holdQueueDesired
119
        or $itemRestrictsDesired
119
        || $itemRestrictsDesired
120
        or $circStatusDesired;
120
        || $circStatusDesired;
121
121
122
    $result->{bibInfo} = parseBiblio($bibId)
122
    $result->{bibInfo} = parseBiblio($bibId)
123
        unless $desiredSomething and defined $query->param('notBibInfo');
123
        unless $desiredSomething and defined $query->param('notBibInfo');
Lines 159-166 sub parseBiblio { Link Here
159
        WHERE biblioitems.biblionumber = ?");
159
        WHERE biblioitems.biblionumber = ?");
160
    $sth->execute($bibId);
160
    $sth->execute($bibId);
161
    my $data = C4::NCIP::NcipUtils::clearEmptyKeys($sth->fetchrow_hashref);
161
    my $data = C4::NCIP::NcipUtils::clearEmptyKeys($sth->fetchrow_hashref);
162
    return 'SQL query failed..' unless $data;
162
163
163
    return $data || 'SQL query failed..';
164
    $data->{'biblionumber'} = $bibId;
165
    return $data;
164
}
166
}
165
167
166
=head2 parseItems
168
=head2 parseItems
Lines 185-190 sub parseItems { Link Here
185
		location,
187
		location,
186
		ccode,
188
		ccode,
187
		materials,
189
		materials,
190
		itype,
188
		copynumber";
191
		copynumber";
189
    if ($circStatusDesired) {
192
    if ($circStatusDesired) {
190
        $query .= ",
193
        $query .= ",
(-)a/C4/NCIP/LookupRequest.pm (-12 / +39 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::LookupRequest;
20
package C4::NCIP::LookupRequest;
21
21
Lines 78-85 sub lookupRequest { Link Here
78
    C4::NCIP::NcipUtils::print404($query, "Request not found..")
78
    C4::NCIP::NcipUtils::print404($query, "Request not found..")
79
        unless $result;
79
        unless $result;
80
80
81
    my $onLoanUntil = parseDateDue($result->{'itemnumber'});
82
    $result->{'onloanuntil'} = $onLoanUntil if $onLoanUntil;
83
81
    C4::NCIP::NcipUtils::clearEmptyKeys($result);
84
    C4::NCIP::NcipUtils::clearEmptyKeys($result);
82
85
83
    C4::NCIP::NcipUtils::printJson($query, $result);
86
    C4::NCIP::NcipUtils::printJson($query, $result);
84
}
87
}
88
89
=head2 parseDateDue
90
91
	parseDateDue($itemnumber)
92
93
	Returns item's date_due if exists .. else undef
94
95
=cut
96
97
sub parseDateDue {
98
99
    my ($itemId) = @_;
100
    my $dbh      = C4::Context->dbh;
101
    my $sth      = $dbh->prepare("
102
        SELECT date_due
103
        FROM issues
104
        WHERE itemnumber = ?");
105
    $sth->execute($itemId);
106
107
    my $issue = $sth->fetchrow_hashref;
108
    return unless $issue;
109
110
    return $issue->{date_due};
111
}
85
1;
112
1;
(-)a/C4/NCIP/LookupUser.pm (-14 / +15 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2013 BibLibre
3
# This file is part of Koha.
4
#
4
#
5
# This file is part of Koha
5
# Copyright (C) 2015 Jiří Kozlovský
6
#
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
7
# Koha is free software; you can redistribute it and/or modify it
8
# terms of the GNU General Public License as published by the Free Software
8
# under the terms of the GNU General Public License as published by
9
# Foundation; either version 2 of the License, or (at your option) any later
9
# the Free Software Foundation; either version 3 of the License, or
10
# version.
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::LookupUser;
20
package C4::NCIP::LookupUser;
21
21
Lines 131-136 sub parseUserData { Link Here
131
		B_country,
131
		B_country,
132
		B_email,
132
		B_email,
133
		B_phone,
133
		B_phone,
134
		dateofbirth,
135
		branchcode,
134
		categorycode,
136
		categorycode,
135
		dateenrolled,
137
		dateenrolled,
136
		dateexpiry
138
		dateexpiry
Lines 178-185 sub parseUserFiscalAccount { Link Here
178
		itemnumber,
180
		itemnumber,
179
		date,
181
		date,
180
		amount,
182
		amount,
181
		description,
183
		description
182
		note
183
        FROM accountlines
184
        FROM accountlines
184
        WHERE borrowernumber = ?
185
        WHERE borrowernumber = ?
185
	ORDER BY date desc,timestamp DESC");
186
	ORDER BY date desc,timestamp DESC");
(-)a/C4/NCIP/NcipUtils.pm (-12 / +100 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::NcipUtils;
20
package C4::NCIP::NcipUtils;
21
21
Lines 38-43 C4::NCIP::NcipUtils - NCIP Common subroutines used in most of C4::NCIP modules Link Here
38
38
39
=head1 METHODS
39
=head1 METHODS
40
40
41
=cut
42
43
=head2 canBeRenewed
44
45
	canBeRenewed($cgiInput)
46
47
=cut
48
49
sub canBeRenewed {
50
    my $query  = shift;
51
    my $userId = $query->param('userId');
52
    my $itemId = $query->param('itemId');
53
    my $response;
54
55
    my ($okay, $error)
56
        = C4::Circulation::CanBookBeRenewed($userId, $itemId, '0');
57
58
    $response->{allowed} = $okay ? 'y' : 'n';
59
60
    printJson($query, $response) unless $okay;
61
62
    my $maxDateDueDesired = $query->param('maxDateDueDesired');
63
64
    if (defined $maxDateDueDesired) {
65
        my $dbh = C4::Context->dbh;
66
        # Find the issues record for this book
67
        my $sth = $dbh->prepare(
68
            "SELECT branchcode FROM issues WHERE itemnumber = ?");
69
        $sth->execute($itemId);
70
        my $issueBranchCode = $sth->fetchrow_array;
71
        unless ($issueBranchCode) {
72
            print $query->header(
73
                -type   => 'text/plain',
74
                -status => '404 Not Found'
75
            );
76
            print 'Checkout wasn\'t found .. Nothing to renew..';
77
            exit 0;
78
        }
79
80
        my $biblio = C4::Biblio::GetBiblioFromItemNumber($itemId);
81
        my $itemtype
82
            = (C4::Context->preference('item-level_itypes'))
83
            ? $biblio->{'itype'}
84
            : $biblio->{'itemtype'};
85
86
        my $now = DateTime->now(time_zone => C4::Context->tz());
87
        my $borrower = C4::Members::GetMember(borrowernumber => $userId);
88
        unless ($borrower) {
89
            print $query->header(
90
                -type   => 'text/plain',
91
                -status => '404 Not Found'
92
            );
93
            print 'User wasn\'t found ..';
94
            exit 0;
95
        }
96
97
        my $maxDateDue
98
            = C4::Circulation::CalcDateDue($now, $itemtype, $issueBranchCode,
99
            $borrower, 'is a renewal');
100
        $response->{maxDateDue}
101
            = Koha::DateUtils::format_sqldatetime($maxDateDue);
102
    }
103
    printJson($query, $response);
104
}
105
106
=head2 canBeRequested
107
108
	canBeRequested($cgiInput)
109
110
=cut
111
112
sub canBeRequested {
113
    my ($query)    = @_;
114
    my $userId     = $query->param('userId');
115
    my $itemId     = $query->param('itemId');
116
117
    my $userExists = C4::Members::GetBorrowerCategorycode($userId);
118
119
    print404($query, "User doesn't exist") unless $userExists;
120
121
    my $canReserve = C4::Reserves::CanItemBeReserved($userId, $itemId);
122
123
    my $response;
124
    $response->{allowed} = $canReserve eq 'OK' ? 'y' : 'n';
125
126
    printJson($query, $response);
127
}
128
41
=head2 clearEmptyKeys
129
=head2 clearEmptyKeys
42
130
43
	clearEmptyKeys($hashref)
131
	clearEmptyKeys($hashref)
(-)a/C4/NCIP/RenewItem.pm (-27 / +26 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::RenewItem;
20
package C4::NCIP::RenewItem;
21
21
Lines 120-147 sub renewItem { Link Here
120
        $dateDue = Koha::DateUtils::dt_from_string($dateDue);
120
        $dateDue = Koha::DateUtils::dt_from_string($dateDue);
121
        $dateDue->set_hour(23);
121
        $dateDue->set_hour(23);
122
        $dateDue->set_minute(59);
122
        $dateDue->set_minute(59);
123
        if ($dateDue > $maxDateDue) {
123
        if ($dateDue > $maxDateDue || $dateDue < $now) {
124
            $dateDue = $maxDateDue;
124
            $dateDue = $maxDateDue;    # Here is the restriction done ..
125
        }    # Here is the restriction done ..
125
        }
126
127
    }
126
    }
128
    my ($okay, $error)
127
    my ($okay, $error)
129
        = C4::Circulation::CanBookBeRenewed($userId, $itemId, '0');
128
        = C4::Circulation::CanBookBeRenewed($userId, $itemId, '0');
130
129
130
    C4::NCIP::NcipUtils::print409($query, $error) unless $okay;
131
132
    $dateDue
133
        = C4::Circulation::AddRenewal($userId, $itemId, $branch, $dateDue);
134
131
    my $result;
135
    my $result;
132
    if ($okay) {
136
    $result->{'itemId'}     = $itemId;
133
        $dateDue = C4::Circulation::AddRenewal($userId, $itemId, $branch,
137
    $result->{'userId'}     = $userId;
134
            $dateDue);
138
    $result->{'branchcode'} = $branch;
135
        $result->{'dateDue'} = Koha::DateUtils::output_pref(
136
            {dt => $dateDue, as_due_date => 1});
137
    } else {
138
        $result->{'error'} = $error;
139
    }
140
139
141
    print $query->header(-type => 'text/plain', -charset => 'utf-8',);
140
    $result->{'dateDue'}
142
    print to_json($result);
141
        = Koha::DateUtils::output_pref({dt => $dateDue, as_due_date => 1});
143
142
144
    exit 0;
143
    C4::NCIP::NcipUtils::printJson($query, $result);
145
}
144
}
146
145
147
1;
146
1;
(-)a/C4/NCIP/RequestItem.pm (-16 / +31 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
package C4::NCIP::RequestItem;
20
package C4::NCIP::RequestItem;
21
21
Lines 122-128 sub requestItem { Link Here
122
        {biblionumber => $bibId, itemnumber => $itemId, all_dates => 1});
122
        {biblionumber => $bibId, itemnumber => $itemId, all_dates => 1});
123
123
124
    foreach my $res (@$reserves) {
124
    foreach my $res (@$reserves) {
125
        C4::NCIP::NcipUtils::print403($query,
125
        C4::NCIP::NcipUtils::print409($query,
126
            "User already has item requested")
126
            "User already has item requested")
127
            if $res->{borrowernumber} eq $userId;
127
            if $res->{borrowernumber} eq $userId;
128
    }
128
    }
Lines 133-144 sub requestItem { Link Here
133
        "Loan not possible  .. holdqueuelength exists")
133
        "Loan not possible  .. holdqueuelength exists")
134
        if $requestType ne 'Hold' and $rank != 0;
134
        if $requestType ne 'Hold' and $rank != 0;
135
135
136
    my $expirationdate = $query->param('pickupExpiryDate');
136
    my $now = DateTime->now(time_zone => C4::Context->tz());
137
    my $startdate      = $query->param('earliestDateNeeded');
137
138
    my $notes          = $query->param('notes') || 'Placed by svc/ncip';
138
    my $expirationdate
139
        = Koha::DateUtils::dt_from_string($query->param('pickupExpiryDate'));
140
    $expirationdate
141
        = $expirationdate < $now ? undef : $query->param('pickupExpiryDate');
142
143
    my $startdate = Koha::DateUtils::dt_from_string(
144
        $query->param('earliestDateNeeded'));
145
    $startdate
146
        = $startdate < $now ? undef : $query->param('earliestDateNeeded');
147
148
    my $notes = $query->param('notes') || 'Placed by svc/ncip';
139
    my $pickupLocation = $query->param('pickupLocation')
149
    my $pickupLocation = $query->param('pickupLocation')
140
        || C4::Context->userenv->{'branch'};
150
        || C4::Context->userenv->{'branch'};
141
151
152
    my $branchExists = C4::Branch::GetBranchName($pickupLocation);
153
    C4::NCIP::NcipUtils::print409($query,
154
        "Specified pickup location doesn't exist")
155
        unless $branchExists;
156
142
    if ($itemLevelHold) {
157
    if ($itemLevelHold) {
143
        placeHold(
158
        placeHold(
144
            $query,          $bibId,     $itemId,         $userId,
159
            $query,          $bibId,     $itemId,         $userId,
(-)a/svc/ncip (-15 / +16 lines)
Lines 1-23 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2007 LibLime
4
# Copyright 2012 software.coop and MJ Ray
5
#
6
# This file is part of Koha.
3
# This file is part of Koha.
7
#
4
#
8
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2015 Jiří Kozlovský
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
6
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
7
# Koha is free software; you can redistribute it and/or modify it
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
8
# under the terms of the GNU General Public License as published by
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
16
#
11
#
17
# You should have received a copy of the GNU General Public License along
12
# Koha is distributed in the hope that it will be useful, but
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
20
#
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
19
22
use strict;
20
use strict;
23
use warnings;
21
use warnings;
Lines 39-45 binmode STDOUT, ':encoding(UTF-8)'; Link Here
39
my ($status, undef, undef)
37
my ($status, undef, undef)
40
    = check_api_auth($query, {editcatalogue => 'edit_catalogue'});
38
    = check_api_auth($query, {editcatalogue => 'edit_catalogue'});
41
39
42
C4::NCIP::NcipUtils::print403($query, $status)
40
C4::NCIP::NcipUtils::print403($query, "Auth failed: " . $status)
43
    unless ($status eq "ok");
41
    unless ($status eq "ok");
44
42
45
# do initial validation
43
# do initial validation
Lines 56-61 if ($query->request_method eq "GET") { Link Here
56
        C4::NCIP::LookupItemSet::lookupItemSet($query);
54
        C4::NCIP::LookupItemSet::lookupItemSet($query);
57
    } elsif ($service eq 'lookup_user') {
55
    } elsif ($service eq 'lookup_user') {
58
        C4::NCIP::LookupUser::lookupUser($query);
56
        C4::NCIP::LookupUser::lookupUser($query);
57
    } elsif ($service eq 'can_be_renewed') {
58
	C4::NCIP::NcipUtils::canBeRenewed($query);
59
    } elsif ($service eq 'can_be_requested') {
60
	C4::NCIP::NcipUtils::canBeRequested($query);
59
    } elsif ($service eq 'lookup_request') {
61
    } elsif ($service eq 'lookup_request') {
60
        C4::NCIP::LookupRequest::lookupRequest($query);
62
        C4::NCIP::LookupRequest::lookupRequest($query);
61
    } elsif ($service eq 'request_item') {
63
    } elsif ($service eq 'request_item') {
62
- 

Return to bug 13930