|
Lines 42-48
use Data::Dumper;
Link Here
|
| 42 |
use Koha::Account; |
42 |
use Koha::Account; |
| 43 |
use Koha::AuthorisedValues; |
43 |
use Koha::AuthorisedValues; |
| 44 |
use Koha::DateUtils; |
44 |
use Koha::DateUtils; |
| 45 |
use Koha::Calendar; |
45 |
use Koha::DiscreteCalendar; |
| 46 |
use Koha::Checkouts; |
46 |
use Koha::Checkouts; |
| 47 |
use Koha::IssuingRules; |
47 |
use Koha::IssuingRules; |
| 48 |
use Koha::Items; |
48 |
use Koha::Items; |
|
Lines 153-163
Generic filter function for barcode string.
Link Here
|
| 153 |
Called on every circ if the System Pref itemBarcodeInputFilter is set. |
153 |
Called on every circ if the System Pref itemBarcodeInputFilter is set. |
| 154 |
Will do some manipulation of the barcode for systems that deliver a barcode |
154 |
Will do some manipulation of the barcode for systems that deliver a barcode |
| 155 |
to circulation.pl that differs from the barcode stored for the item. |
155 |
to circulation.pl that differs from the barcode stored for the item. |
| 156 |
For proper functioning of this filter, calling the function on the |
156 |
For proper functioning of this filter, calling the function on the |
| 157 |
correct barcode string (items.barcode) should return an unaltered barcode. |
157 |
correct barcode string (items.barcode) should return an unaltered barcode. |
| 158 |
|
158 |
|
| 159 |
The optional $filter argument is to allow for testing or explicit |
159 |
The optional $filter argument is to allow for testing or explicit |
| 160 |
behavior that ignores the System Pref. Valid values are the same as the |
160 |
behavior that ignores the System Pref. Valid values are the same as the |
| 161 |
System Pref options. |
161 |
System Pref options. |
| 162 |
|
162 |
|
| 163 |
=cut |
163 |
=cut |
|
Lines 247-253
sub decode {
Link Here
|
| 247 |
|
247 |
|
| 248 |
=head2 transferbook |
248 |
=head2 transferbook |
| 249 |
|
249 |
|
| 250 |
($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, |
250 |
($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, |
| 251 |
$barcode, $ignore_reserves); |
251 |
$barcode, $ignore_reserves); |
| 252 |
|
252 |
|
| 253 |
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer. |
253 |
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer. |
|
Lines 263-269
Returns three values:
Link Here
|
| 263 |
|
263 |
|
| 264 |
=over |
264 |
=over |
| 265 |
|
265 |
|
| 266 |
=item $dotransfer |
266 |
=item $dotransfer |
| 267 |
|
267 |
|
| 268 |
is true if the transfer was successful. |
268 |
is true if the transfer was successful. |
| 269 |
|
269 |
|
|
Lines 391-400
sub TooMany {
Link Here
|
| 391 |
my $branch; |
391 |
my $branch; |
| 392 |
# Get which branchcode we need |
392 |
# Get which branchcode we need |
| 393 |
$branch = _GetCircControlBranch($item,$borrower); |
393 |
$branch = _GetCircControlBranch($item,$borrower); |
| 394 |
my $type = (C4::Context->preference('item-level_itypes')) |
394 |
my $type = (C4::Context->preference('item-level_itypes')) |
| 395 |
? $item->{'itype'} # item-level |
395 |
? $item->{'itype'} # item-level |
| 396 |
: $item->{'itemtype'}; # biblio-level |
396 |
: $item->{'itemtype'}; # biblio-level |
| 397 |
|
397 |
|
| 398 |
# given branch, patron category, and item type, determine |
398 |
# given branch, patron category, and item type, determine |
| 399 |
# applicable issuing rule |
399 |
# applicable issuing rule |
| 400 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
400 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
|
Lines 428-435
sub TooMany {
Link Here
|
| 428 |
AND (categorycode = ? OR categorycode = ?) |
428 |
AND (categorycode = ? OR categorycode = ?) |
| 429 |
AND itemtype <> '*' |
429 |
AND itemtype <> '*' |
| 430 |
) "; |
430 |
) "; |
| 431 |
} else { |
431 |
} else { |
| 432 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
432 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
| 433 |
WHERE biblioitems.itemtype NOT IN ( |
433 |
WHERE biblioitems.itemtype NOT IN ( |
| 434 |
SELECT itemtype FROM issuingrules |
434 |
SELECT itemtype FROM issuingrules |
| 435 |
WHERE branchcode = ? |
435 |
WHERE branchcode = ? |
|
Lines 445-452
sub TooMany {
Link Here
|
| 445 |
# specific item type |
445 |
# specific item type |
| 446 |
if (C4::Context->preference('item-level_itypes')) { |
446 |
if (C4::Context->preference('item-level_itypes')) { |
| 447 |
$count_query .= " WHERE items.itype = ? "; |
447 |
$count_query .= " WHERE items.itype = ? "; |
| 448 |
} else { |
448 |
} else { |
| 449 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
449 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
| 450 |
WHERE biblioitems.itemtype= ? "; |
450 |
WHERE biblioitems.itemtype= ? "; |
| 451 |
} |
451 |
} |
| 452 |
push @bind_params, $type; |
452 |
push @bind_params, $type; |
|
Lines 561-567
sub TooMany {
Link Here
|
| 561 |
|
561 |
|
| 562 |
=head2 CanBookBeIssued |
562 |
=head2 CanBookBeIssued |
| 563 |
|
563 |
|
| 564 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, |
564 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, |
| 565 |
$barcode, $duedate, $inprocess, $ignore_reserves, $params ); |
565 |
$barcode, $duedate, $inprocess, $ignore_reserves, $params ); |
| 566 |
|
566 |
|
| 567 |
Check if a book can be issued. |
567 |
Check if a book can be issued. |
|
Lines 597-603
Possible values are :
Link Here
|
| 597 |
|
597 |
|
| 598 |
=back |
598 |
=back |
| 599 |
|
599 |
|
| 600 |
=head3 INVALID_DATE |
600 |
=head3 INVALID_DATE |
| 601 |
|
601 |
|
| 602 |
sticky due date is invalid |
602 |
sticky due date is invalid |
| 603 |
|
603 |
|
|
Lines 629-635
item withdrawn.
Link Here
|
| 629 |
|
629 |
|
| 630 |
item is restricted (set by ??) |
630 |
item is restricted (set by ??) |
| 631 |
|
631 |
|
| 632 |
C<$needsconfirmation> a reference to a hash. It contains reasons why the loan |
632 |
C<$needsconfirmation> a reference to a hash. It contains reasons why the loan |
| 633 |
could be prevented, but ones that can be overriden by the operator. |
633 |
could be prevented, but ones that can be overriden by the operator. |
| 634 |
|
634 |
|
| 635 |
Possible values are : |
635 |
Possible values are : |
|
Lines 673-679
sub CanBookBeIssued {
Link Here
|
| 673 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
673 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
| 674 |
my $issue = GetItemIssue($item->{itemnumber}); |
674 |
my $issue = GetItemIssue($item->{itemnumber}); |
| 675 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
675 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
| 676 |
$item->{'itemtype'}=$item->{'itype'}; |
676 |
$item->{'itemtype'}=$item->{'itype'}; |
| 677 |
my $dbh = C4::Context->dbh; |
677 |
my $dbh = C4::Context->dbh; |
| 678 |
|
678 |
|
| 679 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
679 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
|
Lines 712-718
sub CanBookBeIssued {
Link Here
|
| 712 |
# |
712 |
# |
| 713 |
# BORROWER STATUS |
713 |
# BORROWER STATUS |
| 714 |
# |
714 |
# |
| 715 |
if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { |
715 |
if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { |
| 716 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
716 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
| 717 |
&UpdateStats({ |
717 |
&UpdateStats({ |
| 718 |
branch => C4::Context->userenv->{'branch'}, |
718 |
branch => C4::Context->userenv->{'branch'}, |
|
Lines 1203-1209
sub checkHighHolds {
Link Here
|
| 1203 |
|
1203 |
|
| 1204 |
my $issuedate = DateTime->now( time_zone => C4::Context->tz() ); |
1204 |
my $issuedate = DateTime->now( time_zone => C4::Context->tz() ); |
| 1205 |
|
1205 |
|
| 1206 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
1206 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); |
| 1207 |
|
1207 |
|
| 1208 |
my $itype = |
1208 |
my $itype = |
| 1209 |
( C4::Context->preference('item-level_itypes') ) |
1209 |
( C4::Context->preference('item-level_itypes') ) |
|
Lines 1333-1339
sub AddIssue {
Link Here
|
| 1333 |
if ($datesent) { |
1333 |
if ($datesent) { |
| 1334 |
# updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) |
1334 |
# updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) |
| 1335 |
my $sth = $dbh->prepare( |
1335 |
my $sth = $dbh->prepare( |
| 1336 |
"UPDATE branchtransfers |
1336 |
"UPDATE branchtransfers |
| 1337 |
SET datearrived = now(), |
1337 |
SET datearrived = now(), |
| 1338 |
tobranch = ?, |
1338 |
tobranch = ?, |
| 1339 |
comments = 'Forced branchtransfer' |
1339 |
comments = 'Forced branchtransfer' |
|
Lines 1573-1579
sub GetHardDueDate {
Link Here
|
| 1573 |
my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode); |
1573 |
my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode); |
| 1574 |
|
1574 |
|
| 1575 |
Retrieves circulation rule attributes that apply to the given |
1575 |
Retrieves circulation rule attributes that apply to the given |
| 1576 |
branch and patron category, regardless of item type. |
1576 |
branch and patron category, regardless of item type. |
| 1577 |
The return value is a hashref containing the following key: |
1577 |
The return value is a hashref containing the following key: |
| 1578 |
|
1578 |
|
| 1579 |
maxissueqty - maximum number of loans that a |
1579 |
maxissueqty - maximum number of loans that a |
|
Lines 1585-1595
patron of the given category can have at the given
Link Here
|
| 1585 |
branch. If the value is undef, no limit. |
1585 |
branch. If the value is undef, no limit. |
| 1586 |
|
1586 |
|
| 1587 |
This will first check for a specific branch and |
1587 |
This will first check for a specific branch and |
| 1588 |
category match from branch_borrower_circ_rules. |
1588 |
category match from branch_borrower_circ_rules. |
| 1589 |
|
1589 |
|
| 1590 |
If no rule is found, it will then check default_branch_circ_rules |
1590 |
If no rule is found, it will then check default_branch_circ_rules |
| 1591 |
(same branch, default category). If no rule is found, |
1591 |
(same branch, default category). If no rule is found, |
| 1592 |
it will then check default_borrower_circ_rules (default |
1592 |
it will then check default_borrower_circ_rules (default |
| 1593 |
branch, same category), then failing that, default_circ_rules |
1593 |
branch, same category), then failing that, default_circ_rules |
| 1594 |
(default branch, default category). |
1594 |
(default branch, default category). |
| 1595 |
|
1595 |
|
|
Lines 1710-1716
sub GetBranchItemRule {
Link Here
|
| 1710 |
$result->{'hold_fulfillment_policy'} = $search_result->{'hold_fulfillment_policy'} unless ( defined $result->{'hold_fulfillment_policy'} ); |
1710 |
$result->{'hold_fulfillment_policy'} = $search_result->{'hold_fulfillment_policy'} unless ( defined $result->{'hold_fulfillment_policy'} ); |
| 1711 |
$result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} ); |
1711 |
$result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} ); |
| 1712 |
} |
1712 |
} |
| 1713 |
|
1713 |
|
| 1714 |
# built-in default circulation rule |
1714 |
# built-in default circulation rule |
| 1715 |
$result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} ); |
1715 |
$result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} ); |
| 1716 |
$result->{'hold_fulfillment_policy'} = 'any' unless ( defined $result->{'hold_fulfillment_policy'} ); |
1716 |
$result->{'hold_fulfillment_policy'} = 'any' unless ( defined $result->{'hold_fulfillment_policy'} ); |
|
Lines 2011-2017
sub AddReturn {
Link Here
|
| 2011 |
if ($borrowernumber) { |
2011 |
if ($borrowernumber) { |
| 2012 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); |
2012 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); |
| 2013 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined |
2013 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined |
| 2014 |
|
2014 |
|
| 2015 |
if ( $issue->{overdue} && $issue->{date_due} ) { |
2015 |
if ( $issue->{overdue} && $issue->{date_due} ) { |
| 2016 |
# fix fine days |
2016 |
# fix fine days |
| 2017 |
$today = $dropboxdate if $dropbox; |
2017 |
$today = $dropboxdate if $dropbox; |
|
Lines 2072-2081
sub AddReturn {
Link Here
|
| 2072 |
branch => $branch, |
2072 |
branch => $branch, |
| 2073 |
}); |
2073 |
}); |
| 2074 |
} |
2074 |
} |
| 2075 |
|
2075 |
|
| 2076 |
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) |
2076 |
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) |
| 2077 |
if C4::Context->preference("ReturnLog"); |
2077 |
if C4::Context->preference("ReturnLog"); |
| 2078 |
|
2078 |
|
| 2079 |
# Remove any OVERDUES related debarment if the borrower has no overdues |
2079 |
# Remove any OVERDUES related debarment if the borrower has no overdues |
| 2080 |
if ( $borrowernumber |
2080 |
if ( $borrowernumber |
| 2081 |
&& $borrower->{'debarred'} |
2081 |
&& $borrower->{'debarred'} |
|
Lines 2112-2118
Unconditionally marks an issue as being returned by
Link Here
|
| 2112 |
moving the C<issues> row to C<old_issues> and |
2112 |
moving the C<issues> row to C<old_issues> and |
| 2113 |
setting C<returndate> to the current date, or |
2113 |
setting C<returndate> to the current date, or |
| 2114 |
the last non-holiday date of the branccode specified in |
2114 |
the last non-holiday date of the branccode specified in |
| 2115 |
C<dropbox_branch> . Assumes you've already checked that |
2115 |
C<dropbox_branch> . Assumes you've already checked that |
| 2116 |
it's safe to do this, i.e. last non-holiday > issuedate. |
2116 |
it's safe to do this, i.e. last non-holiday > issuedate. |
| 2117 |
|
2117 |
|
| 2118 |
if C<$returndate> is specified (in iso format), it is used as the date |
2118 |
if C<$returndate> is specified (in iso format), it is used as the date |
|
Lines 2122-2128
C<$privacy> contains the privacy parameter. If the patron has set privacy to 2,
Link Here
|
| 2122 |
the old_issue is immediately anonymised |
2122 |
the old_issue is immediately anonymised |
| 2123 |
|
2123 |
|
| 2124 |
Ideally, this function would be internal to C<C4::Circulation>, |
2124 |
Ideally, this function would be internal to C<C4::Circulation>, |
| 2125 |
not exported, but it is currently needed by one |
2125 |
not exported, but it is currently needed by one |
| 2126 |
routine in C<C4::Accounts>. |
2126 |
routine in C<C4::Accounts>. |
| 2127 |
|
2127 |
|
| 2128 |
=cut |
2128 |
=cut |
|
Lines 2144-2150
sub MarkIssueReturned {
Link Here
|
| 2144 |
my $query = 'UPDATE issues SET returndate='; |
2144 |
my $query = 'UPDATE issues SET returndate='; |
| 2145 |
my @bind; |
2145 |
my @bind; |
| 2146 |
if ($dropbox_branch) { |
2146 |
if ($dropbox_branch) { |
| 2147 |
my $calendar = Koha::Calendar->new( branchcode => $dropbox_branch ); |
2147 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $dropbox_branch ); |
| 2148 |
my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 ); |
2148 |
my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 ); |
| 2149 |
$query .= ' ? '; |
2149 |
$query .= ' ? '; |
| 2150 |
push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M'); |
2150 |
push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M'); |
|
Lines 2271-2277
C<$brn> borrowernumber
Link Here
|
| 2271 |
|
2271 |
|
| 2272 |
C<$itm> itemnumber |
2272 |
C<$itm> itemnumber |
| 2273 |
|
2273 |
|
| 2274 |
C<$exemptfine> BOOL -- remove overdue charge associated with this issue. |
2274 |
C<$exemptfine> BOOL -- remove overdue charge associated with this issue. |
| 2275 |
C<$dropboxmode> BOOL -- remove lastincrement on overdue charge associated with this issue. |
2275 |
C<$dropboxmode> BOOL -- remove lastincrement on overdue charge associated with this issue. |
| 2276 |
|
2276 |
|
| 2277 |
Internal function, called only by AddReturn |
2277 |
Internal function, called only by AddReturn |
|
Lines 2418-2424
sub _FixAccountForLostAndReturned {
Link Here
|
| 2418 |
|
2418 |
|
| 2419 |
my $circ_control_branch = _GetCircControlBranch($iteminfos, $borrower); |
2419 |
my $circ_control_branch = _GetCircControlBranch($iteminfos, $borrower); |
| 2420 |
|
2420 |
|
| 2421 |
Internal function : |
2421 |
Internal function : |
| 2422 |
|
2422 |
|
| 2423 |
Return the library code to be used to determine which circulation |
2423 |
Return the library code to be used to determine which circulation |
| 2424 |
policy applies to a transaction. Looks up the CircControl and |
2424 |
policy applies to a transaction. Looks up the CircControl and |
|
Lines 2505-2511
Returns a hashref
Link Here
|
| 2505 |
sub GetOpenIssue { |
2505 |
sub GetOpenIssue { |
| 2506 |
my ( $itemnumber ) = @_; |
2506 |
my ( $itemnumber ) = @_; |
| 2507 |
return unless $itemnumber; |
2507 |
return unless $itemnumber; |
| 2508 |
my $dbh = C4::Context->dbh; |
2508 |
my $dbh = C4::Context->dbh; |
| 2509 |
my $sth = $dbh->prepare( "SELECT * FROM issues WHERE itemnumber = ? AND returndate IS NULL" ); |
2509 |
my $sth = $dbh->prepare( "SELECT * FROM issues WHERE itemnumber = ? AND returndate IS NULL" ); |
| 2510 |
$sth->execute( $itemnumber ); |
2510 |
$sth->execute( $itemnumber ); |
| 2511 |
return $sth->fetchrow_hashref(); |
2511 |
return $sth->fetchrow_hashref(); |
|
Lines 2570-2576
sub GetUpcomingDueIssues {
Link Here
|
| 2570 |
|
2570 |
|
| 2571 |
my $statement = <<END_SQL; |
2571 |
my $statement = <<END_SQL; |
| 2572 |
SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail |
2572 |
SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail |
| 2573 |
FROM issues |
2573 |
FROM issues |
| 2574 |
LEFT JOIN items USING (itemnumber) |
2574 |
LEFT JOIN items USING (itemnumber) |
| 2575 |
LEFT OUTER JOIN branches USING (branchcode) |
2575 |
LEFT OUTER JOIN branches USING (branchcode) |
| 2576 |
WHERE returndate is NULL |
2576 |
WHERE returndate is NULL |
|
Lines 2578-2584
HAVING days_until_due >= 0 AND days_until_due <= ?
Link Here
|
| 2578 |
END_SQL |
2578 |
END_SQL |
| 2579 |
|
2579 |
|
| 2580 |
my @bind_parameters = ( $params->{'days_in_advance'} ); |
2580 |
my @bind_parameters = ( $params->{'days_in_advance'} ); |
| 2581 |
|
2581 |
|
| 2582 |
my $sth = $dbh->prepare( $statement ); |
2582 |
my $sth = $dbh->prepare( $statement ); |
| 2583 |
$sth->execute( @bind_parameters ); |
2583 |
$sth->execute( @bind_parameters ); |
| 2584 |
my $upcoming_dues = $sth->fetchall_arrayref({}); |
2584 |
my $upcoming_dues = $sth->fetchall_arrayref({}); |
|
Lines 2844-2850
sub AddRenewal {
Link Here
|
| 2844 |
# of how many times it has been renewed. |
2844 |
# of how many times it has been renewed. |
| 2845 |
my $renews = $issuedata->{'renewals'} + 1; |
2845 |
my $renews = $issuedata->{'renewals'} + 1; |
| 2846 |
my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? |
2846 |
my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? |
| 2847 |
WHERE borrowernumber=? |
2847 |
WHERE borrowernumber=? |
| 2848 |
AND itemnumber=?" |
2848 |
AND itemnumber=?" |
| 2849 |
); |
2849 |
); |
| 2850 |
|
2850 |
|
|
Lines 2860-2866
sub AddRenewal {
Link Here
|
| 2860 |
my $accountno = getnextacctno( $borrowernumber ); |
2860 |
my $accountno = getnextacctno( $borrowernumber ); |
| 2861 |
my $item = GetBiblioFromItemNumber($itemnumber); |
2861 |
my $item = GetBiblioFromItemNumber($itemnumber); |
| 2862 |
my $manager_id = 0; |
2862 |
my $manager_id = 0; |
| 2863 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2863 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
| 2864 |
$sth = $dbh->prepare( |
2864 |
$sth = $dbh->prepare( |
| 2865 |
"INSERT INTO accountlines |
2865 |
"INSERT INTO accountlines |
| 2866 |
(date, borrowernumber, accountno, amount, manager_id, |
2866 |
(date, borrowernumber, accountno, amount, manager_id, |
|
Lines 2929-2935
sub GetRenewCount {
Link Here
|
| 2929 |
my $renewsleft = 0; |
2929 |
my $renewsleft = 0; |
| 2930 |
|
2930 |
|
| 2931 |
my $borrower = C4::Members::GetMember( borrowernumber => $bornum); |
2931 |
my $borrower = C4::Members::GetMember( borrowernumber => $bornum); |
| 2932 |
my $item = GetItem($itemno); |
2932 |
my $item = GetItem($itemno); |
| 2933 |
|
2933 |
|
| 2934 |
# Look in the issues table for this item, lent to this borrower, |
2934 |
# Look in the issues table for this item, lent to this borrower, |
| 2935 |
# and not yet returned. |
2935 |
# and not yet returned. |
|
Lines 3409-3421
sub SendCirculationAlert {
Link Here
|
| 3409 |
|
3409 |
|
| 3410 |
$items = updateWrongTransfer($itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary); |
3410 |
$items = updateWrongTransfer($itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary); |
| 3411 |
|
3411 |
|
| 3412 |
This function validate the line of brachtransfer but with the wrong destination (mistake from a librarian ...), and create a new line in branchtransfer from the actual library to the original library of reservation |
3412 |
This function validate the line of brachtransfer but with the wrong destination (mistake from a librarian ...), and create a new line in branchtransfer from the actual library to the original library of reservation |
| 3413 |
|
3413 |
|
| 3414 |
=cut |
3414 |
=cut |
| 3415 |
|
3415 |
|
| 3416 |
sub updateWrongTransfer { |
3416 |
sub updateWrongTransfer { |
| 3417 |
my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_; |
3417 |
my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_; |
| 3418 |
my $dbh = C4::Context->dbh; |
3418 |
my $dbh = C4::Context->dbh; |
| 3419 |
# first step validate the actual line of transfert . |
3419 |
# first step validate the actual line of transfert . |
| 3420 |
my $sth = |
3420 |
my $sth = |
| 3421 |
$dbh->prepare( |
3421 |
$dbh->prepare( |
|
Lines 3502-3508
sub CalcDateDue {
Link Here
|
| 3502 |
else { # days |
3502 |
else { # days |
| 3503 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3503 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
| 3504 |
} |
3504 |
} |
| 3505 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3505 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); |
| 3506 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3506 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
| 3507 |
if ($loanlength->{lengthunit} eq 'days') { |
3507 |
if ($loanlength->{lengthunit} eq 'days') { |
| 3508 |
$datedue->set_hour(23); |
3508 |
$datedue->set_hour(23); |
|
Lines 3549-3556
sub CalcDateDue {
Link Here
|
| 3549 |
sub CheckValidBarcode{ |
3549 |
sub CheckValidBarcode{ |
| 3550 |
my ($barcode) = @_; |
3550 |
my ($barcode) = @_; |
| 3551 |
my $dbh = C4::Context->dbh; |
3551 |
my $dbh = C4::Context->dbh; |
| 3552 |
my $query=qq|SELECT count(*) |
3552 |
my $query=qq|SELECT count(*) |
| 3553 |
FROM items |
3553 |
FROM items |
| 3554 |
WHERE barcode=? |
3554 |
WHERE barcode=? |
| 3555 |
|; |
3555 |
|; |
| 3556 |
my $sth = $dbh->prepare($query); |
3556 |
my $sth = $dbh->prepare($query); |
|
Lines 3571-3591
sub IsBranchTransferAllowed {
Link Here
|
| 3571 |
my ( $toBranch, $fromBranch, $code ) = @_; |
3571 |
my ( $toBranch, $fromBranch, $code ) = @_; |
| 3572 |
|
3572 |
|
| 3573 |
if ( $toBranch eq $fromBranch ) { return 1; } ## Short circuit for speed. |
3573 |
if ( $toBranch eq $fromBranch ) { return 1; } ## Short circuit for speed. |
| 3574 |
|
3574 |
|
| 3575 |
my $limitType = C4::Context->preference("BranchTransferLimitsType"); |
3575 |
my $limitType = C4::Context->preference("BranchTransferLimitsType"); |
| 3576 |
my $dbh = C4::Context->dbh; |
3576 |
my $dbh = C4::Context->dbh; |
| 3577 |
|
3577 |
|
| 3578 |
my $sth = $dbh->prepare("SELECT * FROM branch_transfer_limits WHERE toBranch = ? AND fromBranch = ? AND $limitType = ?"); |
3578 |
my $sth = $dbh->prepare("SELECT * FROM branch_transfer_limits WHERE toBranch = ? AND fromBranch = ? AND $limitType = ?"); |
| 3579 |
$sth->execute( $toBranch, $fromBranch, $code ); |
3579 |
$sth->execute( $toBranch, $fromBranch, $code ); |
| 3580 |
my $limit = $sth->fetchrow_hashref(); |
3580 |
my $limit = $sth->fetchrow_hashref(); |
| 3581 |
|
3581 |
|
| 3582 |
## If a row is found, then that combination is not allowed, if no matching row is found, then the combination *is allowed* |
3582 |
## If a row is found, then that combination is not allowed, if no matching row is found, then the combination *is allowed* |
| 3583 |
if ( $limit->{'limitId'} ) { |
3583 |
if ( $limit->{'limitId'} ) { |
| 3584 |
return 0; |
3584 |
return 0; |
| 3585 |
} else { |
3585 |
} else { |
| 3586 |
return 1; |
3586 |
return 1; |
| 3587 |
} |
3587 |
} |
| 3588 |
} |
3588 |
} |
| 3589 |
|
3589 |
|
| 3590 |
=head2 CreateBranchTransferLimit |
3590 |
=head2 CreateBranchTransferLimit |
| 3591 |
|
3591 |
|
|
Lines 3599-3607
sub CreateBranchTransferLimit {
Link Here
|
| 3599 |
my ( $toBranch, $fromBranch, $code ) = @_; |
3599 |
my ( $toBranch, $fromBranch, $code ) = @_; |
| 3600 |
return unless defined($toBranch) && defined($fromBranch); |
3600 |
return unless defined($toBranch) && defined($fromBranch); |
| 3601 |
my $limitType = C4::Context->preference("BranchTransferLimitsType"); |
3601 |
my $limitType = C4::Context->preference("BranchTransferLimitsType"); |
| 3602 |
|
3602 |
|
| 3603 |
my $dbh = C4::Context->dbh; |
3603 |
my $dbh = C4::Context->dbh; |
| 3604 |
|
3604 |
|
| 3605 |
my $sth = $dbh->prepare("INSERT INTO branch_transfer_limits ( $limitType, toBranch, fromBranch ) VALUES ( ?, ?, ? )"); |
3605 |
my $sth = $dbh->prepare("INSERT INTO branch_transfer_limits ( $limitType, toBranch, fromBranch ) VALUES ( ?, ?, ? )"); |
| 3606 |
return $sth->execute( $code, $toBranch, $fromBranch ); |
3606 |
return $sth->execute( $code, $toBranch, $fromBranch ); |
| 3607 |
} |
3607 |
} |
|
Lines 3642-3650
sub LostItem{
Link Here
|
| 3642 |
my ($itemnumber, $mark_returned) = @_; |
3642 |
my ($itemnumber, $mark_returned) = @_; |
| 3643 |
|
3643 |
|
| 3644 |
my $dbh = C4::Context->dbh(); |
3644 |
my $dbh = C4::Context->dbh(); |
| 3645 |
my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title |
3645 |
my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title |
| 3646 |
FROM issues |
3646 |
FROM issues |
| 3647 |
JOIN items USING (itemnumber) |
3647 |
JOIN items USING (itemnumber) |
| 3648 |
JOIN biblio USING (biblionumber) |
3648 |
JOIN biblio USING (biblionumber) |
| 3649 |
WHERE issues.itemnumber=?"); |
3649 |
WHERE issues.itemnumber=?"); |
| 3650 |
$sth->execute($itemnumber); |
3650 |
$sth->execute($itemnumber); |