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

(-)a/C4/Circulation.pm (-64 / +65 lines)
Lines 149-159 Generic filter function for barcode string. Link Here
149
Called on every circ if the System Pref itemBarcodeInputFilter is set.
149
Called on every circ if the System Pref itemBarcodeInputFilter is set.
150
Will do some manipulation of the barcode for systems that deliver a barcode
150
Will do some manipulation of the barcode for systems that deliver a barcode
151
to circulation.pl that differs from the barcode stored for the item.
151
to circulation.pl that differs from the barcode stored for the item.
152
For proper functioning of this filter, calling the function on the 
152
For proper functioning of this filter, calling the function on the
153
correct barcode string (items.barcode) should return an unaltered barcode.
153
correct barcode string (items.barcode) should return an unaltered barcode.
154
154
155
The optional $filter argument is to allow for testing or explicit 
155
The optional $filter argument is to allow for testing or explicit
156
behavior that ignores the System Pref.  Valid values are the same as the 
156
behavior that ignores the System Pref.  Valid values are the same as the
157
System Pref options.
157
System Pref options.
158
158
159
=cut
159
=cut
Lines 243-249 sub decode { Link Here
243
243
244
=head2 transferbook
244
=head2 transferbook
245
245
246
  ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, 
246
  ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch,
247
                                            $barcode, $ignore_reserves);
247
                                            $barcode, $ignore_reserves);
248
248
249
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
249
Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer.
Lines 259-265 Returns three values: Link Here
259
259
260
=over
260
=over
261
261
262
=item $dotransfer 
262
=item $dotransfer
263
263
264
is true if the transfer was successful.
264
is true if the transfer was successful.
265
265
Lines 382-391 sub TooMany { Link Here
382
	my $branch;
382
	my $branch;
383
	# Get which branchcode we need
383
	# Get which branchcode we need
384
	$branch = _GetCircControlBranch($item,$borrower);
384
	$branch = _GetCircControlBranch($item,$borrower);
385
	my $type = (C4::Context->preference('item-level_itypes')) 
385
	my $type = (C4::Context->preference('item-level_itypes'))
386
  			? $item->{'itype'}         # item-level
386
  			? $item->{'itype'}         # item-level
387
			: $item->{'itemtype'};     # biblio-level
387
			: $item->{'itemtype'};     # biblio-level
388
 
388
389
    # given branch, patron category, and item type, determine
389
    # given branch, patron category, and item type, determine
390
    # applicable issuing rule
390
    # applicable issuing rule
391
    my $issuing_rule = GetIssuingRule($cat_borrower, $type, $branch);
391
    my $issuing_rule = GetIssuingRule($cat_borrower, $type, $branch);
Lines 410-417 sub TooMany { Link Here
410
                                    AND   (categorycode = ? OR categorycode = ?)
410
                                    AND   (categorycode = ? OR categorycode = ?)
411
                                    AND   itemtype <> '*'
411
                                    AND   itemtype <> '*'
412
                                  ) ";
412
                                  ) ";
413
            } else { 
413
            } else {
414
                $count_query .= " JOIN  biblioitems USING (biblionumber) 
414
                $count_query .= " JOIN  biblioitems USING (biblionumber)
415
                                  WHERE biblioitems.itemtype NOT IN (
415
                                  WHERE biblioitems.itemtype NOT IN (
416
                                    SELECT itemtype FROM issuingrules
416
                                    SELECT itemtype FROM issuingrules
417
                                    WHERE branchcode = ?
417
                                    WHERE branchcode = ?
Lines 427-434 sub TooMany { Link Here
427
            # specific item type
427
            # specific item type
428
            if (C4::Context->preference('item-level_itypes')) {
428
            if (C4::Context->preference('item-level_itypes')) {
429
                $count_query .= " WHERE items.itype = ? ";
429
                $count_query .= " WHERE items.itype = ? ";
430
            } else { 
430
            } else {
431
                $count_query .= " JOIN  biblioitems USING (biblionumber) 
431
                $count_query .= " JOIN  biblioitems USING (biblionumber)
432
                                  WHERE biblioitems.itemtype= ? ";
432
                                  WHERE biblioitems.itemtype= ? ";
433
            }
433
            }
434
            push @bind_params, $type;
434
            push @bind_params, $type;
Lines 601-607 sub itemissues { Link Here
601
601
602
=head2 CanBookBeIssued
602
=head2 CanBookBeIssued
603
603
604
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
604
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower,
605
                      $barcode, $duedatespec, $inprocess, $ignore_reserves );
605
                      $barcode, $duedatespec, $inprocess, $ignore_reserves );
606
606
607
Check if a book can be issued.
607
Check if a book can be issued.
Lines 630-636 Possible values are : Link Here
630
630
631
=back
631
=back
632
632
633
=head3 INVALID_DATE 
633
=head3 INVALID_DATE
634
634
635
sticky due date is invalid
635
sticky due date is invalid
636
636
Lines 662-668 item withdrawn. Link Here
662
662
663
item is restricted (set by ??)
663
item is restricted (set by ??)
664
664
665
C<$needsconfirmation> a reference to a hash. It contains reasons why the loan 
665
C<$needsconfirmation> a reference to a hash. It contains reasons why the loan
666
could be prevented, but ones that can be overriden by the operator.
666
could be prevented, but ones that can be overriden by the operator.
667
667
668
Possible values are :
668
Possible values are :
Lines 702-708 sub CanBookBeIssued { Link Here
702
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
702
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
703
    my $issue = GetItemIssue($item->{itemnumber});
703
    my $issue = GetItemIssue($item->{itemnumber});
704
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
704
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
705
	$item->{'itemtype'}=$item->{'itype'}; 
705
	$item->{'itemtype'}=$item->{'itype'};
706
    my $dbh             = C4::Context->dbh;
706
    my $dbh             = C4::Context->dbh;
707
707
708
    # MANDATORY CHECKS - unless item exists, nothing else matters
708
    # MANDATORY CHECKS - unless item exists, nothing else matters
Lines 741-747 sub CanBookBeIssued { Link Here
741
    #
741
    #
742
    # BORROWER STATUS
742
    # BORROWER STATUS
743
    #
743
    #
744
    if ( $borrower->{'category_type'} eq 'X' && (  $item->{barcode}  )) { 
744
    if ( $borrower->{'category_type'} eq 'X' && (  $item->{barcode}  )) {
745
    	# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
745
    	# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
746
        &UpdateStats({
746
        &UpdateStats({
747
                     branch => C4::Context->userenv->{'branch'},
747
                     branch => C4::Context->userenv->{'branch'},
Lines 1210-1222 sub AddIssue { Link Here
1210
		# find which item we issue
1210
		# find which item we issue
1211
		my $item = GetItem('', $barcode) or return;	# if we don't get an Item, abort.
1211
		my $item = GetItem('', $barcode) or return;	# if we don't get an Item, abort.
1212
		my $branch = _GetCircControlBranch($item,$borrower);
1212
		my $branch = _GetCircControlBranch($item,$borrower);
1213
		
1213
1214
		# get actual issuing if there is one
1214
		# get actual issuing if there is one
1215
		my $actualissue = GetItemIssue( $item->{itemnumber});
1215
		my $actualissue = GetItemIssue( $item->{itemnumber});
1216
		
1216
1217
		# get biblioinformation for this item
1217
		# get biblioinformation for this item
1218
		my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
1218
		my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
1219
		
1219
1220
		#
1220
		#
1221
		# check if we just renew the issue.
1221
		# check if we just renew the issue.
1222
		#
1222
		#
Lines 1247-1253 sub AddIssue { Link Here
1247
        # 	updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....)
1247
        # 	updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....)
1248
                my $sth =
1248
                my $sth =
1249
                    $dbh->prepare(
1249
                    $dbh->prepare(
1250
                    "UPDATE branchtransfers 
1250
                    "UPDATE branchtransfers
1251
                        SET datearrived = now(),
1251
                        SET datearrived = now(),
1252
                        tobranch = ?,
1252
                        tobranch = ?,
1253
                        comments = 'Forced branchtransfer'
1253
                        comments = 'Forced branchtransfer'
Lines 1457-1463 sub GetHardDueDate { Link Here
1457
  my $irule = &GetIssuingRule($borrowertype,$itemtype,branchcode)
1457
  my $irule = &GetIssuingRule($borrowertype,$itemtype,branchcode)
1458
1458
1459
FIXME - This is a copy-paste of GetLoanLength
1459
FIXME - This is a copy-paste of GetLoanLength
1460
as a stop-gap.  Do not wish to change API for GetLoanLength 
1460
as a stop-gap.  Do not wish to change API for GetLoanLength
1461
this close to release.
1461
this close to release.
1462
1462
1463
Get the issuing rule for an itemtype, a borrower type and a branch
1463
Get the issuing rule for an itemtype, a borrower type and a branch
Lines 1512-1518 sub GetIssuingRule { Link Here
1512
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode);
1512
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode);
1513
1513
1514
Retrieves circulation rule attributes that apply to the given
1514
Retrieves circulation rule attributes that apply to the given
1515
branch and patron category, regardless of item type.  
1515
branch and patron category, regardless of item type.
1516
The return value is a hashref containing the following key:
1516
The return value is a hashref containing the following key:
1517
1517
1518
maxissueqty - maximum number of loans that a
1518
maxissueqty - maximum number of loans that a
Lines 1520-1530 patron of the given category can have at the given Link Here
1520
branch.  If the value is undef, no limit.
1520
branch.  If the value is undef, no limit.
1521
1521
1522
This will first check for a specific branch and
1522
This will first check for a specific branch and
1523
category match from branch_borrower_circ_rules. 
1523
category match from branch_borrower_circ_rules.
1524
1524
1525
If no rule is found, it will then check default_branch_circ_rules
1525
If no rule is found, it will then check default_branch_circ_rules
1526
(same branch, default category).  If no rule is found,
1526
(same branch, default category).  If no rule is found,
1527
it will then check default_borrower_circ_rules (default 
1527
it will then check default_borrower_circ_rules (default
1528
branch, same category), then failing that, default_circ_rules
1528
branch, same category), then failing that, default_circ_rules
1529
(default branch, default category).
1529
(default branch, default category).
1530
1530
Lines 1574-1580 sub GetBranchBorrowerCircRule { Link Here
1574
    if ($result = $sth->fetchrow_hashref()) {
1574
    if ($result = $sth->fetchrow_hashref()) {
1575
        return $result;
1575
        return $result;
1576
    }
1576
    }
1577
  
1577
1578
    # try default branch, default borrower category
1578
    # try default branch, default borrower category
1579
    my $default_query = "SELECT maxissueqty
1579
    my $default_query = "SELECT maxissueqty
1580
                          FROM default_circ_rules";
1580
                          FROM default_circ_rules";
Lines 1583-1589 sub GetBranchBorrowerCircRule { Link Here
1583
    if ($result = $sth->fetchrow_hashref()) {
1583
    if ($result = $sth->fetchrow_hashref()) {
1584
        return $result;
1584
        return $result;
1585
    }
1585
    }
1586
    
1586
1587
    # built-in default circulation rule
1587
    # built-in default circulation rule
1588
    return {
1588
    return {
1589
        maxissueqty => undef,
1589
        maxissueqty => undef,
Lines 1650-1656 sub GetBranchItemRule { Link Here
1650
        $result->{'holdallowed'}  = $search_result->{'holdallowed'}  unless ( defined $result->{'holdallowed'} );
1650
        $result->{'holdallowed'}  = $search_result->{'holdallowed'}  unless ( defined $result->{'holdallowed'} );
1651
        $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} );
1651
        $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} );
1652
    }
1652
    }
1653
    
1653
1654
    # built-in default circulation rule
1654
    # built-in default circulation rule
1655
    $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} );
1655
    $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} );
1656
    $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} );
1656
    $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} );
Lines 1737-1742 patron who last borrowed the book. Link Here
1737
1737
1738
sub AddReturn {
1738
sub AddReturn {
1739
    my ( $barcode, $branch, $exemptfine, $dropbox, $return_date ) = @_;
1739
    my ( $barcode, $branch, $exemptfine, $dropbox, $return_date ) = @_;
1740
    warn "AddReturn( $barcode, $branch, $exemptfine, $dropbox, $return_date )";
1740
1741
1741
    if ($branch and not GetBranchDetail($branch)) {
1742
    if ($branch and not GetBranchDetail($branch)) {
1742
        warn "AddReturn error: branch '$branch' not found.  Reverting to " . C4::Context->userenv->{'branch'};
1743
        warn "AddReturn error: branch '$branch' not found.  Reverting to " . C4::Context->userenv->{'branch'};
Lines 1947-1953 sub AddReturn { Link Here
1947
    if ($borrowernumber) {
1948
    if ($borrowernumber) {
1948
        my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox);
1949
        my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox);
1949
        defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!";  # zero is OK, check defined
1950
        defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!";  # zero is OK, check defined
1950
        
1951
1951
        if ( $issue->{overdue} && $issue->{date_due} ) {
1952
        if ( $issue->{overdue} && $issue->{date_due} ) {
1952
        # fix fine days
1953
        # fix fine days
1953
            my ($debardate,$reminder) = _debar_user_on_return( $borrower, $item, $issue->{date_due}, $today );
1954
            my ($debardate,$reminder) = _debar_user_on_return( $borrower, $item, $issue->{date_due}, $today );
Lines 2008-2017 sub AddReturn { Link Here
2008
            branch   => $branch,
2009
            branch   => $branch,
2009
        });
2010
        });
2010
    }
2011
    }
2011
    
2012
2012
    logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
2013
    logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
2013
        if C4::Context->preference("ReturnLog");
2014
        if C4::Context->preference("ReturnLog");
2014
    
2015
2015
    # Remove any OVERDUES related debarment if the borrower has no overdues
2016
    # Remove any OVERDUES related debarment if the borrower has no overdues
2016
    if ( $borrowernumber
2017
    if ( $borrowernumber
2017
      && $borrower->{'debarred'}
2018
      && $borrower->{'debarred'}
Lines 2051-2057 Unconditionally marks an issue as being returned by Link Here
2051
moving the C<issues> row to C<old_issues> and
2052
moving the C<issues> row to C<old_issues> and
2052
setting C<returndate> to the current date, or
2053
setting C<returndate> to the current date, or
2053
the last non-holiday date of the branccode specified in
2054
the last non-holiday date of the branccode specified in
2054
C<dropbox_branch> .  Assumes you've already checked that 
2055
C<dropbox_branch> .  Assumes you've already checked that
2055
it's safe to do this, i.e. last non-holiday > issuedate.
2056
it's safe to do this, i.e. last non-holiday > issuedate.
2056
2057
2057
if C<$returndate> is specified (in iso format), it is used as the date
2058
if C<$returndate> is specified (in iso format), it is used as the date
Lines 2061-2067 C<$privacy> contains the privacy parameter. If the patron has set privacy to 2, Link Here
2061
the old_issue is immediately anonymised
2062
the old_issue is immediately anonymised
2062
2063
2063
Ideally, this function would be internal to C<C4::Circulation>,
2064
Ideally, this function would be internal to C<C4::Circulation>,
2064
not exported, but it is currently needed by one 
2065
not exported, but it is currently needed by one
2065
routine in C<C4::Accounts>.
2066
routine in C<C4::Accounts>.
2066
2067
2067
=cut
2068
=cut
Lines 2193-2199 C<$brn> borrowernumber Link Here
2193
2194
2194
C<$itm> itemnumber
2195
C<$itm> itemnumber
2195
2196
2196
C<$exemptfine> BOOL -- remove overdue charge associated with this issue. 
2197
C<$exemptfine> BOOL -- remove overdue charge associated with this issue.
2197
C<$dropboxmode> BOOL -- remove lastincrement on overdue charge associated with this issue.
2198
C<$dropboxmode> BOOL -- remove lastincrement on overdue charge associated with this issue.
2198
2199
2199
Internal function, called only by AddReturn
2200
Internal function, called only by AddReturn
Lines 2340-2346 sub _FixAccountForLostAndReturned { Link Here
2340
2341
2341
   my $circ_control_branch = _GetCircControlBranch($iteminfos, $borrower);
2342
   my $circ_control_branch = _GetCircControlBranch($iteminfos, $borrower);
2342
2343
2343
Internal function : 
2344
Internal function :
2344
2345
2345
Return the library code to be used to determine which circulation
2346
Return the library code to be used to determine which circulation
2346
policy applies to a transaction.  Looks up the CircControl and
2347
policy applies to a transaction.  Looks up the CircControl and
Lines 2425-2431 Returns a hashref Link Here
2425
sub GetOpenIssue {
2426
sub GetOpenIssue {
2426
  my ( $itemnumber ) = @_;
2427
  my ( $itemnumber ) = @_;
2427
  return unless $itemnumber;
2428
  return unless $itemnumber;
2428
  my $dbh = C4::Context->dbh;  
2429
  my $dbh = C4::Context->dbh;
2429
  my $sth = $dbh->prepare( "SELECT * FROM issues WHERE itemnumber = ? AND returndate IS NULL" );
2430
  my $sth = $dbh->prepare( "SELECT * FROM issues WHERE itemnumber = ? AND returndate IS NULL" );
2430
  $sth->execute( $itemnumber );
2431
  $sth->execute( $itemnumber );
2431
  return $sth->fetchrow_hashref();
2432
  return $sth->fetchrow_hashref();
Lines 2515-2521 Returns reference to an array of hashes Link Here
2515
2516
2516
sub GetItemIssues {
2517
sub GetItemIssues {
2517
    my ( $itemnumber, $history ) = @_;
2518
    my ( $itemnumber, $history ) = @_;
2518
    
2519
2519
    my $today = DateTime->now( time_zome => C4::Context->tz);  # get today date
2520
    my $today = DateTime->now( time_zome => C4::Context->tz);  # get today date
2520
    $today->truncate( to => 'minute' );
2521
    $today->truncate( to => 'minute' );
2521
    my $sql = "SELECT * FROM issues
2522
    my $sql = "SELECT * FROM issues
Lines 2604-2610 sub GetUpcomingDueIssues { Link Here
2604
2605
2605
    my $statement = <<END_SQL;
2606
    my $statement = <<END_SQL;
2606
SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail
2607
SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail
2607
FROM issues 
2608
FROM issues
2608
LEFT JOIN items USING (itemnumber)
2609
LEFT JOIN items USING (itemnumber)
2609
LEFT OUTER JOIN branches USING (branchcode)
2610
LEFT OUTER JOIN branches USING (branchcode)
2610
WHERE returndate is NULL
2611
WHERE returndate is NULL
Lines 2612-2618 HAVING days_until_due >= 0 AND days_until_due <= ? Link Here
2612
END_SQL
2613
END_SQL
2613
2614
2614
    my @bind_parameters = ( $params->{'days_in_advance'} );
2615
    my @bind_parameters = ( $params->{'days_in_advance'} );
2615
    
2616
2616
    my $sth = $dbh->prepare( $statement );
2617
    my $sth = $dbh->prepare( $statement );
2617
    $sth->execute( @bind_parameters );
2618
    $sth->execute( @bind_parameters );
2618
    my $upcoming_dues = $sth->fetchall_arrayref({});
2619
    my $upcoming_dues = $sth->fetchall_arrayref({});
Lines 2813-2819 sub AddRenewal { Link Here
2813
    # of how many times it has been renewed.
2814
    # of how many times it has been renewed.
2814
    my $renews = $issuedata->{'renewals'} + 1;
2815
    my $renews = $issuedata->{'renewals'} + 1;
2815
    $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ?
2816
    $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ?
2816
                            WHERE borrowernumber=? 
2817
                            WHERE borrowernumber=?
2817
                            AND itemnumber=?"
2818
                            AND itemnumber=?"
2818
    );
2819
    );
2819
2820
Lines 2829-2835 sub AddRenewal { Link Here
2829
        my $accountno = getnextacctno( $borrowernumber );
2830
        my $accountno = getnextacctno( $borrowernumber );
2830
        my $item = GetBiblioFromItemNumber($itemnumber);
2831
        my $item = GetBiblioFromItemNumber($itemnumber);
2831
        my $manager_id = 0;
2832
        my $manager_id = 0;
2832
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
2833
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
2833
        $sth = $dbh->prepare(
2834
        $sth = $dbh->prepare(
2834
                "INSERT INTO accountlines
2835
                "INSERT INTO accountlines
2835
                    (date, borrowernumber, accountno, amount, manager_id,
2836
                    (date, borrowernumber, accountno, amount, manager_id,
Lines 2892-2898 sub GetRenewCount { Link Here
2892
    my $renewsleft    = 0;
2893
    my $renewsleft    = 0;
2893
2894
2894
    my $borrower = C4::Members::GetMember( borrowernumber => $bornum);
2895
    my $borrower = C4::Members::GetMember( borrowernumber => $bornum);
2895
    my $item     = GetItem($itemno); 
2896
    my $item     = GetItem($itemno);
2896
2897
2897
    # Look in the issues table for this item, lent to this borrower,
2898
    # Look in the issues table for this item, lent to this borrower,
2898
    # and not yet returned.
2899
    # and not yet returned.
Lines 2908-2916 sub GetRenewCount { Link Here
2908
    $renewcount = $data->{'renewals'} if $data->{'renewals'};
2909
    $renewcount = $data->{'renewals'} if $data->{'renewals'};
2909
    # $item and $borrower should be calculated
2910
    # $item and $borrower should be calculated
2910
    my $branchcode = _GetCircControlBranch($item, $borrower);
2911
    my $branchcode = _GetCircControlBranch($item, $borrower);
2911
    
2912
2912
    my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode);
2913
    my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode);
2913
    
2914
2914
    $renewsallowed = $issuingrule->{'renewalsallowed'};
2915
    $renewsallowed = $issuingrule->{'renewalsallowed'};
2915
    $renewsleft    = $renewsallowed - $renewcount;
2916
    $renewsleft    = $renewsallowed - $renewcount;
2916
    if($renewsleft < 0){ $renewsleft = 0; }
2917
    if($renewsleft < 0){ $renewsleft = 0; }
Lines 3286-3298 sub SendCirculationAlert { Link Here
3286
3287
3287
  $items = updateWrongTransfer($itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary);
3288
  $items = updateWrongTransfer($itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary);
3288
3289
3289
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 
3290
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
3290
3291
3291
=cut
3292
=cut
3292
3293
3293
sub updateWrongTransfer {
3294
sub updateWrongTransfer {
3294
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3295
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3295
	my $dbh = C4::Context->dbh;	
3296
	my $dbh = C4::Context->dbh;
3296
# first step validate the actual line of transfert .
3297
# first step validate the actual line of transfert .
3297
	my $sth =
3298
	my $sth =
3298
        	$dbh->prepare(
3299
        	$dbh->prepare(
Lines 3428-3442 This function checks if the date due is a repeatable holiday Link Here
3428
3429
3429
C<$date_due>   = returndate calculate with no day check
3430
C<$date_due>   = returndate calculate with no day check
3430
C<$itemnumber>  = itemnumber
3431
C<$itemnumber>  = itemnumber
3431
C<$branchcode>  = localisation of issue 
3432
C<$branchcode>  = localisation of issue
3432
3433
3433
=cut
3434
=cut
3434
3435
3435
sub CheckRepeatableHolidays{
3436
sub CheckRepeatableHolidays{
3436
my($itemnumber,$week_day,$branchcode)=@_;
3437
my($itemnumber,$week_day,$branchcode)=@_;
3437
my $dbh = C4::Context->dbh;
3438
my $dbh = C4::Context->dbh;
3438
my $query = qq|SELECT count(*)  
3439
my $query = qq|SELECT count(*)
3439
	FROM repeatable_holidays 
3440
	FROM repeatable_holidays
3440
	WHERE branchcode=?
3441
	WHERE branchcode=?
3441
	AND weekday=?|;
3442
	AND weekday=?|;
3442
my $sth = $dbh->prepare($query);
3443
my $sth = $dbh->prepare($query);
Lines 3456-3469 C<$years> = the years of datedue Link Here
3456
C<$month>   = the month of datedue
3457
C<$month>   = the month of datedue
3457
C<$day>     = the day of datedue
3458
C<$day>     = the day of datedue
3458
C<$itemnumber>  = itemnumber
3459
C<$itemnumber>  = itemnumber
3459
C<$branchcode>  = localisation of issue 
3460
C<$branchcode>  = localisation of issue
3460
3461
3461
=cut
3462
=cut
3462
3463
3463
sub CheckSpecialHolidays{
3464
sub CheckSpecialHolidays{
3464
my ($years,$month,$day,$itemnumber,$branchcode) = @_;
3465
my ($years,$month,$day,$itemnumber,$branchcode) = @_;
3465
my $dbh = C4::Context->dbh;
3466
my $dbh = C4::Context->dbh;
3466
my $query=qq|SELECT count(*) 
3467
my $query=qq|SELECT count(*)
3467
	     FROM `special_holidays`
3468
	     FROM `special_holidays`
3468
	     WHERE year=?
3469
	     WHERE year=?
3469
	     AND month=?
3470
	     AND month=?
Lines 3485-3498 This function check if the date is a repeatble special holidays Link Here
3485
C<$month>   = the month of datedue
3486
C<$month>   = the month of datedue
3486
C<$day>     = the day of datedue
3487
C<$day>     = the day of datedue
3487
C<$itemnumber>  = itemnumber
3488
C<$itemnumber>  = itemnumber
3488
C<$branchcode>  = localisation of issue 
3489
C<$branchcode>  = localisation of issue
3489
3490
3490
=cut
3491
=cut
3491
3492
3492
sub CheckRepeatableSpecialHolidays{
3493
sub CheckRepeatableSpecialHolidays{
3493
my ($month,$day,$itemnumber,$branchcode) = @_;
3494
my ($month,$day,$itemnumber,$branchcode) = @_;
3494
my $dbh = C4::Context->dbh;
3495
my $dbh = C4::Context->dbh;
3495
my $query=qq|SELECT count(*) 
3496
my $query=qq|SELECT count(*)
3496
	     FROM `repeatable_holidays`
3497
	     FROM `repeatable_holidays`
3497
	     WHERE month=?
3498
	     WHERE month=?
3498
	     AND day=?
3499
	     AND day=?
Lines 3509-3516 return $countspecial; Link Here
3509
sub CheckValidBarcode{
3510
sub CheckValidBarcode{
3510
my ($barcode) = @_;
3511
my ($barcode) = @_;
3511
my $dbh = C4::Context->dbh;
3512
my $dbh = C4::Context->dbh;
3512
my $query=qq|SELECT count(*) 
3513
my $query=qq|SELECT count(*)
3513
	     FROM items 
3514
	     FROM items
3514
             WHERE barcode=?
3515
             WHERE barcode=?
3515
	    |;
3516
	    |;
3516
my $sth = $dbh->prepare($query);
3517
my $sth = $dbh->prepare($query);
Lines 3531-3551 sub IsBranchTransferAllowed { Link Here
3531
	my ( $toBranch, $fromBranch, $code ) = @_;
3532
	my ( $toBranch, $fromBranch, $code ) = @_;
3532
3533
3533
	if ( $toBranch eq $fromBranch ) { return 1; } ## Short circuit for speed.
3534
	if ( $toBranch eq $fromBranch ) { return 1; } ## Short circuit for speed.
3534
        
3535
3535
	my $limitType = C4::Context->preference("BranchTransferLimitsType");   
3536
	my $limitType = C4::Context->preference("BranchTransferLimitsType");
3536
	my $dbh = C4::Context->dbh;
3537
	my $dbh = C4::Context->dbh;
3537
            
3538
3538
	my $sth = $dbh->prepare("SELECT * FROM branch_transfer_limits WHERE toBranch = ? AND fromBranch = ? AND $limitType = ?");
3539
	my $sth = $dbh->prepare("SELECT * FROM branch_transfer_limits WHERE toBranch = ? AND fromBranch = ? AND $limitType = ?");
3539
	$sth->execute( $toBranch, $fromBranch, $code );
3540
	$sth->execute( $toBranch, $fromBranch, $code );
3540
	my $limit = $sth->fetchrow_hashref();
3541
	my $limit = $sth->fetchrow_hashref();
3541
                        
3542
3542
	## If a row is found, then that combination is not allowed, if no matching row is found, then the combination *is allowed*
3543
	## If a row is found, then that combination is not allowed, if no matching row is found, then the combination *is allowed*
3543
	if ( $limit->{'limitId'} ) {
3544
	if ( $limit->{'limitId'} ) {
3544
		return 0;
3545
		return 0;
3545
	} else {
3546
	} else {
3546
		return 1;
3547
		return 1;
3547
	}
3548
	}
3548
}                                                        
3549
}
3549
3550
3550
=head2 CreateBranchTransferLimit
3551
=head2 CreateBranchTransferLimit
3551
3552
Lines 3559-3567 sub CreateBranchTransferLimit { Link Here
3559
   my ( $toBranch, $fromBranch, $code ) = @_;
3560
   my ( $toBranch, $fromBranch, $code ) = @_;
3560
   return unless defined($toBranch) && defined($fromBranch);
3561
   return unless defined($toBranch) && defined($fromBranch);
3561
   my $limitType = C4::Context->preference("BranchTransferLimitsType");
3562
   my $limitType = C4::Context->preference("BranchTransferLimitsType");
3562
   
3563
3563
   my $dbh = C4::Context->dbh;
3564
   my $dbh = C4::Context->dbh;
3564
   
3565
3565
   my $sth = $dbh->prepare("INSERT INTO branch_transfer_limits ( $limitType, toBranch, fromBranch ) VALUES ( ?, ?, ? )");
3566
   my $sth = $dbh->prepare("INSERT INTO branch_transfer_limits ( $limitType, toBranch, fromBranch ) VALUES ( ?, ?, ? )");
3566
   return $sth->execute( $code, $toBranch, $fromBranch );
3567
   return $sth->execute( $code, $toBranch, $fromBranch );
3567
}
3568
}
Lines 3602-3610 sub LostItem{ Link Here
3602
    my ($itemnumber, $mark_returned) = @_;
3603
    my ($itemnumber, $mark_returned) = @_;
3603
3604
3604
    my $dbh = C4::Context->dbh();
3605
    my $dbh = C4::Context->dbh();
3605
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title 
3606
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title
3606
                           FROM issues 
3607
                           FROM issues
3607
                           JOIN items USING (itemnumber) 
3608
                           JOIN items USING (itemnumber)
3608
                           JOIN biblio USING (biblionumber)
3609
                           JOIN biblio USING (biblionumber)
3609
                           WHERE issues.itemnumber=?");
3610
                           WHERE issues.itemnumber=?");
3610
    $sth->execute($itemnumber);
3611
    $sth->execute($itemnumber);
(-)a/svc/checkin (-1 / +4 lines)
Lines 47-52 my $exempt_fine = $input->param('exempt_fine'); Link Here
47
my $branchcode     = $input->param('branchcode')
47
my $branchcode     = $input->param('branchcode')
48
  || C4::Context->userenv->{'branch'};
48
  || C4::Context->userenv->{'branch'};
49
49
50
# Expect these inputs to come in as JSON boolean values
51
$override_limit = $override_limit ? $override_limit eq 'true' : undef;
52
$exempt_fine    = $exempt_fine    ? $exempt_fine eq 'true'    : undef;
53
50
my $barcode = GetBarcodeFromItemnumber($itemnumber);
54
my $barcode = GetBarcodeFromItemnumber($itemnumber);
51
55
52
my $data;
56
my $data;
53
- 

Return to bug 13330