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

(-)a/C4/Circulation.pm (-17 / +20 lines)
Lines 1195-1200 sub AddIssue { Link Here
1195
		
1195
		
1196
		# get biblioinformation for this item
1196
		# get biblioinformation for this item
1197
		my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
1197
		my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
1198
        my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblio->{'itemtype'};
1198
		
1199
		
1199
		#
1200
		#
1200
		# check if we just renew the issue.
1201
		# check if we just renew the issue.
Lines 1243-1251 sub AddIssue { Link Here
1243
                VALUES (?,?,?,?,?)"
1244
                VALUES (?,?,?,?,?)"
1244
          );
1245
          );
1245
        unless ($datedue) {
1246
        unless ($datedue) {
1246
            my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'};
1247
            $datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower );
1247
            $datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower );
1248
1249
        }
1248
        }
1250
        $datedue->truncate( to => 'minute');
1249
        $datedue->truncate( to => 'minute');
1251
        $sth->execute(
1250
        $sth->execute(
Lines 1279-1285 sub AddIssue { Link Here
1279
        ModDateLastSeen( $item->{'itemnumber'} );
1278
        ModDateLastSeen( $item->{'itemnumber'} );
1280
1279
1281
        # If it costs to borrow this book, charge it to the patron's account.
1280
        # If it costs to borrow this book, charge it to the patron's account.
1282
        my ( $charge, $itemtype ) = GetIssuingCharges(
1281
        my ( $charge, $charge_itemtype ) = GetIssuingCharges(
1283
            $item->{'itemnumber'},
1282
            $item->{'itemnumber'},
1284
            $borrower->{'borrowernumber'}
1283
            $borrower->{'borrowernumber'}
1285
        );
1284
        );
Lines 1296-1302 sub AddIssue { Link Here
1296
            C4::Context->userenv->{'branch'},
1295
            C4::Context->userenv->{'branch'},
1297
            'issue', $charge,
1296
            'issue', $charge,
1298
            ($sipmode ? "SIP-$sipmode" : ''), $item->{'itemnumber'},
1297
            ($sipmode ? "SIP-$sipmode" : ''), $item->{'itemnumber'},
1299
            $item->{'itype'}, $borrower->{'borrowernumber'}, undef, $item->{'ccode'}
1298
            $itype, $borrower->{'borrowernumber'}, undef, $item->{'ccode'}
1300
        );
1299
        );
1301
1300
1302
        # Send a checkout slip.
1301
        # Send a checkout slip.
Lines 1304-1310 sub AddIssue { Link Here
1304
        my %conditions = (
1303
        my %conditions = (
1305
            branchcode   => $branch,
1304
            branchcode   => $branch,
1306
            categorycode => $borrower->{categorycode},
1305
            categorycode => $borrower->{categorycode},
1307
            item_type    => $item->{itype},
1306
            item_type    => $itype,
1308
            notification => 'CHECKOUT',
1307
            notification => 'CHECKOUT',
1309
        );
1308
        );
1310
        if ($circulation_alert->is_enabled_for(\%conditions)) {
1309
        if ($circulation_alert->is_enabled_for(\%conditions)) {
Lines 1317-1323 sub AddIssue { Link Here
1317
        }
1316
        }
1318
    }
1317
    }
1319
1318
1320
    logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $biblio->{'itemnumber'})
1319
    logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $item->{'itemnumber'})
1321
        if C4::Context->preference("IssueLog");
1320
        if C4::Context->preference("IssueLog");
1322
  }
1321
  }
1323
  return ($datedue);	# not necessarily the same as when it came in!
1322
  return ($datedue);	# not necessarily the same as when it came in!
Lines 1708-1714 sub AddReturn { Link Here
1708
    $branch = C4::Context->userenv->{'branch'} unless $branch;  # we trust userenv to be a safe fallback/default
1707
    $branch = C4::Context->userenv->{'branch'} unless $branch;  # we trust userenv to be a safe fallback/default
1709
    my $messages;
1708
    my $messages;
1710
    my $borrower;
1709
    my $borrower;
1711
    my $biblio;
1712
    my $doreturn       = 1;
1710
    my $doreturn       = 1;
1713
    my $validTransfert = 0;
1711
    my $validTransfert = 0;
1714
    my $stat_type = 'return';    
1712
    my $stat_type = 'return';    
Lines 1739-1745 sub AddReturn { Link Here
1739
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1737
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1740
        # full item data, but no borrowernumber or checkout info (no issue)
1738
        # full item data, but no borrowernumber or checkout info (no issue)
1741
        # we know GetItem should work because GetItemnumberFromBarcode worked
1739
        # we know GetItem should work because GetItemnumberFromBarcode worked
1742
    my $hbr      = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1740
1741
    # get biblioinformation for this item
1742
    my $biblio = GetBiblioFromItemNumber($item->{'itemnumber'});
1743
    my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblio->{'itemtype'};
1744
        
1745
    my $hbr      = GetBranchItemRule($item->{'homebranch'}, $itype)->{'returnbranch'} || "homebranch";
1743
        # get the proper branch to which to return the item
1746
        # get the proper branch to which to return the item
1744
    $hbr = $item->{$hbr} || $branch ;
1747
    $hbr = $item->{$hbr} || $branch ;
1745
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
1748
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
Lines 1887-1893 sub AddReturn { Link Here
1887
    UpdateStats(
1890
    UpdateStats(
1888
        $branch, $stat_type, '0', '',
1891
        $branch, $stat_type, '0', '',
1889
        $item->{'itemnumber'},
1892
        $item->{'itemnumber'},
1890
        $biblio->{'itemtype'},
1893
        $itype,
1891
        $borrowernumber, undef, $item->{'ccode'}
1894
        $borrowernumber, undef, $item->{'ccode'}
1892
    );
1895
    );
1893
1896
Lines 1896-1902 sub AddReturn { Link Here
1896
    my %conditions = (
1899
    my %conditions = (
1897
        branchcode   => $branch,
1900
        branchcode   => $branch,
1898
        categorycode => $borrower->{categorycode},
1901
        categorycode => $borrower->{categorycode},
1899
        item_type    => $item->{itype},
1902
        item_type    => $itype,
1900
        notification => 'CHECKIN',
1903
        notification => 'CHECKIN',
1901
    );
1904
    );
1902
    if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
1905
    if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
Lines 2517-2524 sub AddRenewal { Link Here
2517
    my $branch          = shift;
2520
    my $branch          = shift;
2518
    my $datedue         = shift;
2521
    my $datedue         = shift;
2519
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd();
2522
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd();
2523
2520
    my $item   = GetItem($itemnumber) or return;
2524
    my $item   = GetItem($itemnumber) or return;
2521
    my $biblio = GetBiblioFromItemNumber($itemnumber) or return;
2525
    my $biblio = GetBiblioFromItemNumber($itemnumber) or return;
2526
    my $itype = (C4::Context->preference('item-level_itypes')) ? $item->{'itype'} : $biblio->{'itemtype'};
2522
2527
2523
    my $dbh = C4::Context->dbh;
2528
    my $dbh = C4::Context->dbh;
2524
    # Find the issues record for this book
2529
    # Find the issues record for this book
Lines 2540-2551 sub AddRenewal { Link Here
2540
    unless ($datedue) {
2545
    unless ($datedue) {
2541
2546
2542
        my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return;
2547
        my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return;
2543
        my $itemtype = (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'};
2544
2548
2545
        $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2549
        $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
2546
                                        dt_from_string( $issuedata->{date_due} ) :
2550
                                        dt_from_string( $issuedata->{date_due} ) :
2547
                                        DateTime->now( time_zone => C4::Context->tz());
2551
                                        DateTime->now( time_zone => C4::Context->tz());
2548
        $datedue =  CalcDateDue($datedue, $itemtype, $issuedata->{'branchcode'}, $borrower, 'is a renewal');
2552
        $datedue =  CalcDateDue($datedue, $itype, $issuedata->{'branchcode'}, $borrower, 'is a renewal');
2549
    }
2553
    }
2550
2554
2551
    # Update the issues record to have the new due date, and a new count
2555
    # Update the issues record to have the new due date, and a new count
Lines 2560-2567 sub AddRenewal { Link Here
2560
    $sth->finish;
2564
    $sth->finish;
2561
2565
2562
    # Update the renewal count on the item, and tell zebra to reindex
2566
    # Update the renewal count on the item, and tell zebra to reindex
2563
    $renews = $biblio->{'renewals'} + 1;
2567
    $renews = $item->{'renewals'} + 1;
2564
    ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $biblio->{'biblionumber'}, $itemnumber);
2568
    ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{'biblionumber'}, $itemnumber);
2565
2569
2566
    # Charge a new rental fee, if applicable?
2570
    # Charge a new rental fee, if applicable?
2567
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2571
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
Lines 2588-2594 sub AddRenewal { Link Here
2588
	my %conditions = (
2592
	my %conditions = (
2589
		branchcode   => $branch,
2593
		branchcode   => $branch,
2590
		categorycode => $borrower->{categorycode},
2594
		categorycode => $borrower->{categorycode},
2591
		item_type    => $item->{itype},
2595
		item_type    => $itype,
2592
		notification => 'CHECKOUT',
2596
		notification => 'CHECKOUT',
2593
	);
2597
	);
2594
	if ($circulation_alert->is_enabled_for(\%conditions)) {
2598
	if ($circulation_alert->is_enabled_for(\%conditions)) {
Lines 2602-2608 sub AddRenewal { Link Here
2602
    }
2606
    }
2603
2607
2604
    # Log the renewal
2608
    # Log the renewal
2605
    UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'});
2609
    UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $itype, $borrowernumber, undef, $item->{'ccode'});
2606
	return $datedue;
2610
	return $datedue;
2607
}
2611
}
2608
2612
2609
- 

Return to bug 9351