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

(-)a/C4/Budgets.pm (-17 / +19 lines)
Lines 342-348 sub GetBudgetSpent { Link Here
342
            datecancellationprinted IS NULL
342
            datecancellationprinted IS NULL
343
    |);
343
    |);
344
	$sth->execute($budget_id);
344
	$sth->execute($budget_id);
345
    my $sum = 0 + $sth->fetchrow_array;
345
    my $sum = ( $sth->fetchrow_array || 0 ) + 0;
346
346
347
    $sth = $dbh->prepare(qq|
347
    $sth = $dbh->prepare(qq|
348
        SELECT SUM(shipmentcost) AS sum
348
        SELECT SUM(shipmentcost) AS sum
Lines 352-358 sub GetBudgetSpent { Link Here
352
352
353
    $sth->execute($budget_id);
353
    $sth->execute($budget_id);
354
    my ($shipmentcost_sum) = $sth->fetchrow_array;
354
    my ($shipmentcost_sum) = $sth->fetchrow_array;
355
    $sum += $shipmentcost_sum;
355
    $sum += ( $shipmentcost_sum || 0 ) + 0;
356
356
357
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, closedate => { '!=' => undef } },{ join => 'invoiceid' });
357
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, closedate => { '!=' => undef } },{ join => 'invoiceid' });
358
    while ( my $adj = $adjustments->next ){
358
    while ( my $adj = $adjustments->next ){
Lines 373-379 sub GetBudgetOrdered { Link Here
373
            datecancellationprinted IS NULL
373
            datecancellationprinted IS NULL
374
    |);
374
    |);
375
	$sth->execute($budget_id);
375
	$sth->execute($budget_id);
376
    my $sum =  0 + $sth->fetchrow_array;
376
    my $sum =  ( $sth->fetchrow_array || 0 ) + 0;
377
377
378
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
378
    my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
379
    while ( my $adj = $adjustments->next ){
379
    while ( my $adj = $adjustments->next ){
Lines 606-617 sub _recursiveAdd { Link Here
606
        _recursiveAdd($child, $budget, $hr_budget_spent, $hr_budget_spent_shipment, $hr_budget_ordered, $hr_budget_ordered_shipment, $hr_budget_spent_adjustment, $hr_budget_ordered_adjustment );
606
        _recursiveAdd($child, $budget, $hr_budget_spent, $hr_budget_spent_shipment, $hr_budget_ordered, $hr_budget_ordered_shipment, $hr_budget_spent_adjustment, $hr_budget_ordered_adjustment );
607
    }
607
    }
608
608
609
    $budget->{budget_spent} += $hr_budget_spent->{$budget->{budget_id}}->{budget_spent};
609
    $budget->{budget_spent} += $hr_budget_spent->{$budget->{budget_id}}->{budget_spent}               || 0;
610
    $budget->{budget_spent} += $hr_budget_spent_shipment->{$budget->{budget_id}}->{shipmentcost};
610
    $budget->{budget_spent} += $hr_budget_spent_shipment->{$budget->{budget_id}}->{shipmentcost}      || 0;
611
    $budget->{budget_spent} += $hr_budget_spent_adjustment->{$budget->{budget_id}}->{adjustments};
611
    $budget->{budget_spent} += $hr_budget_spent_adjustment->{$budget->{budget_id}}->{adjustments}     || 0;
612
    $budget->{budget_ordered} += $hr_budget_ordered->{$budget->{budget_id}}->{budget_ordered};
612
    $budget->{budget_ordered} += $hr_budget_ordered->{$budget->{budget_id}}->{budget_ordered}         || 0;
613
    $budget->{budget_ordered} += $hr_budget_ordered_shipment->{$budget->{budget_id}}->{shipmentcost};
613
    $budget->{budget_ordered} += $hr_budget_ordered_shipment->{$budget->{budget_id}}->{shipmentcost}  || 0;
614
    $budget->{budget_ordered} += $hr_budget_ordered_adjustment->{$budget->{budget_id}}->{adjustments};
614
    $budget->{budget_ordered} += $hr_budget_ordered_adjustment->{$budget->{budget_id}}->{adjustments} || 0;
615
615
616
    $budget->{total_spent} += $budget->{budget_spent};
616
    $budget->{total_spent} += $budget->{budget_spent};
617
    $budget->{total_ordered} += $budget->{budget_ordered};
617
    $budget->{total_ordered} += $budget->{budget_ordered};
Lines 636-665 sub _add_budget_children { Link Here
636
}
636
}
637
637
638
# -------------------------------------------------------------------
638
# -------------------------------------------------------------------
639
639
# FIXME Must be replaced by Koha::Acquisition::Fund->store
640
sub AddBudget {
640
sub AddBudget {
641
    my ($budget) = @_;
641
    my ($budget) = @_;
642
    return unless ($budget);
642
    return unless ($budget);
643
643
644
    undef $budget->{budget_encumb} if $budget->{budget_encumb} eq '';
644
    undef $budget->{budget_encumb}   if defined $budget->{budget_encumb}   && $budget->{budget_encumb}   eq '';
645
    undef $budget->{budget_owner_id} if $budget->{budget_owner_id} eq '';
645
    undef $budget->{budget_owner_id} if defined $budget->{budget_owner_id} && $budget->{budget_owner_id} eq '';
646
    my $resultset = Koha::Database->new()->schema->resultset('Aqbudget');
646
    my $resultset = Koha::Database->new()->schema->resultset('Aqbudget');
647
    return $resultset->create($budget)->id;
647
    return $resultset->create($budget)->id;
648
}
648
}
649
649
650
# -------------------------------------------------------------------
650
# -------------------------------------------------------------------
651
# FIXME Must be replaced by Koha::Acquisition::Fund->store
651
sub ModBudget {
652
sub ModBudget {
652
    my ($budget) = @_;
653
    my ($budget) = @_;
653
    my $result = Koha::Database->new()->schema->resultset('Aqbudget')->find($budget);
654
    my $result = Koha::Database->new()->schema->resultset('Aqbudget')->find($budget);
654
    return unless($result);
655
    return unless($result);
655
656
656
    undef $budget->{budget_encumb} if $budget->{budget_encumb} eq '';
657
    undef $budget->{budget_encumb}   if defined $budget->{budget_encumb}   && $budget->{budget_encumb}   eq '';
657
    undef $budget->{budget_owner_id} if $budget->{budget_owner_id} eq '';
658
    undef $budget->{budget_owner_id} if defined $budget->{budget_owner_id} && $budget->{budget_owner_id} eq '';
658
    $result = $result->update($budget);
659
    $result = $result->update($budget);
659
    return $result->in_storage;
660
    return $result->in_storage;
660
}
661
}
661
662
662
# -------------------------------------------------------------------
663
# -------------------------------------------------------------------
664
# FIXME Must be replaced by Koha::Acquisition::Fund->delete
663
sub DelBudget {
665
sub DelBudget {
664
	my ($budget_id) = @_;
666
	my ($budget_id) = @_;
665
	my $dbh         = C4::Context->dbh;
667
	my $dbh         = C4::Context->dbh;
Lines 809-822 sub GetBudgetsReport { Link Here
809
        ON bp.budget_period_id = b.budget_period_id
811
        ON bp.budget_period_id = b.budget_period_id
810
        INNER JOIN aqorders o
812
        INNER JOIN aqorders o
811
        ON b.budget_id = o.budget_id ';
813
        ON b.budget_id = o.budget_id ';
812
    if($activity ne ''){
814
    if ( $activity && $activity ne '' ) {
813
        $query .= 'WHERE  bp.budget_period_active=? ';
815
        $query .= 'WHERE  bp.budget_period_active=? ';
814
    }
816
    }
815
    $query .= 'AND (o.orderstatus != "cancelled")
817
    $query .= 'AND (o.orderstatus != "cancelled")
816
               ORDER BY b.budget_name';
818
               ORDER BY b.budget_name';
817
819
818
    my $sth = $dbh->prepare($query);
820
    my $sth = $dbh->prepare($query);
819
    if($activity ne ''){
821
    if ( $activity && $activity ne '' ) {
820
        $sth->execute($activity);
822
        $sth->execute($activity);
821
    }
823
    }
822
    else{
824
    else{
Lines 1221-1227 sub CloneBudgetHierarchy { Link Here
1221
    my @first_level_budgets =
1223
    my @first_level_budgets =
1222
      ( not defined $children_of )
1224
      ( not defined $children_of )
1223
      ? map { ( not $_->{budget_parent_id} )             ? $_ : () } @$budgets
1225
      ? map { ( not $_->{budget_parent_id} )             ? $_ : () } @$budgets
1224
      : map { ( $_->{budget_parent_id} == $children_of ) ? $_ : () } @$budgets;
1226
      : map { ( defined $_->{budget_parent_id} && $_->{budget_parent_id} == $children_of ) ? $_ : () } @$budgets;
1225
1227
1226
    # get only the columns of aqbudgets
1228
    # get only the columns of aqbudgets
1227
    my @columns = Koha::Database->new()->schema->source('Aqbudget')->columns;
1229
    my @columns = Koha::Database->new()->schema->source('Aqbudget')->columns;
(-)a/C4/Circulation.pm (-10 / +11 lines)
Lines 748-758 sub CanBookBeIssued { Link Here
748
        return( { STATS => 1 }, {});
748
        return( { STATS => 1 }, {});
749
    }
749
    }
750
750
751
    if ( $patron->gonenoaddress == 1 ) {
751
    if ( $patron->gonenoaddress && $patron->gonenoaddress == 1 ) {
752
        $issuingimpossible{GNA} = 1;
752
        $issuingimpossible{GNA} = 1;
753
    }
753
    }
754
754
755
    if ( $patron->lost == 1 ) {
755
    if ( $patron->lost && $patron->lost == 1 ) {
756
        $issuingimpossible{CARD_LOST} = 1;
756
        $issuingimpossible{CARD_LOST} = 1;
757
    }
757
    }
758
    if ( $patron->is_debarred ) {
758
    if ( $patron->is_debarred ) {
Lines 1430-1436 sub AddIssue { Link Here
1430
                    }
1430
                    }
1431
                )->store;
1431
                )->store;
1432
            }
1432
            }
1433
            if ( $item_object->location eq 'CART' && $item_object->permanent_location ne 'CART'  ) {
1433
            if ( $item_object->location && $item_object->location eq 'CART'
1434
                && ( !$item_object->permanent_location || $item_object->permanent_location ne 'CART' ) ) {
1434
            ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1435
            ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1435
                CartToShelf( $item_object->itemnumber );
1436
                CartToShelf( $item_object->itemnumber );
1436
            }
1437
            }
Lines 1458-1464 sub AddIssue { Link Here
1458
1459
1459
            ModItem(
1460
            ModItem(
1460
                {
1461
                {
1461
                    issues        => $item_object->issues + 1,
1462
                    issues        => ( $item_object->issues || 0 ) + 1,
1462
                    holdingbranch => C4::Context->userenv->{'branch'},
1463
                    holdingbranch => C4::Context->userenv->{'branch'},
1463
                    itemlost      => 0,
1464
                    itemlost      => 0,
1464
                    onloan        => $datedue->ymd(),
1465
                    onloan        => $datedue->ymd(),
Lines 1472-1478 sub AddIssue { Link Here
1472
1473
1473
            # If it costs to borrow this book, charge it to the patron's account.
1474
            # If it costs to borrow this book, charge it to the patron's account.
1474
            my ( $charge, $itemtype ) = GetIssuingCharges( $item_object->itemnumber, $borrower->{'borrowernumber'} );
1475
            my ( $charge, $itemtype ) = GetIssuingCharges( $item_object->itemnumber, $borrower->{'borrowernumber'} );
1475
            if ( $charge > 0 ) {
1476
            if ( $charge && $charge > 0 ) {
1476
                AddIssuingCharge( $issue, $charge, 'RENT' );
1477
                AddIssuingCharge( $issue, $charge, 'RENT' );
1477
            }
1478
            }
1478
1479
Lines 2168-2174 sub MarkIssueReturned { Link Here
2168
    my $issue_id = $issue->issue_id;
2169
    my $issue_id = $issue->issue_id;
2169
2170
2170
    my $anonymouspatron;
2171
    my $anonymouspatron;
2171
    if ( $privacy == 2 ) {
2172
    if ( $privacy && $privacy == 2 ) {
2172
        # The default of 0 will not work due to foreign key constraints
2173
        # The default of 0 will not work due to foreign key constraints
2173
        # The anonymisation will fail if AnonymousPatron is not a valid entry
2174
        # The anonymisation will fail if AnonymousPatron is not a valid entry
2174
        # We need to check if the anonymous patron exist, Koha will fail loudly if it does not
2175
        # We need to check if the anonymous patron exist, Koha will fail loudly if it does not
Lines 2195-2201 sub MarkIssueReturned { Link Here
2195
        my $old_checkout = Koha::Old::Checkout->new($issue->unblessed)->store;
2196
        my $old_checkout = Koha::Old::Checkout->new($issue->unblessed)->store;
2196
2197
2197
        # anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber
2198
        # anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber
2198
        if ( $privacy == 2) {
2199
        if ( $privacy && $privacy == 2) {
2199
            $old_checkout->borrowernumber($anonymouspatron)->store;
2200
            $old_checkout->borrowernumber($anonymouspatron)->store;
2200
        }
2201
        }
2201
2202
Lines 2327-2333 sub _debar_user_on_return { Link Here
2327
    # if borrower was already debarred but does not get an extra debarment
2328
    # if borrower was already debarred but does not get an extra debarment
2328
    my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
2329
    my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
2329
    my ($new_debarment_str, $is_a_reminder);
2330
    my ($new_debarment_str, $is_a_reminder);
2330
    if ( $borrower->{debarred} eq $patron->is_debarred ) {
2331
    if ( $borrower->{debarred} && $borrower->{debarred} eq $patron->is_debarred ) {
2331
        $is_a_reminder = 1;
2332
        $is_a_reminder = 1;
2332
        $new_debarment_str = $borrower->{debarred};
2333
        $new_debarment_str = $borrower->{debarred};
2333
    } else {
2334
    } else {
Lines 2927-2933 sub AddRenewal { Link Here
2927
2928
2928
        # Update the issues record to have the new due date, and a new count
2929
        # Update the issues record to have the new due date, and a new count
2929
        # of how many times it has been renewed.
2930
        # of how many times it has been renewed.
2930
        my $renews = $issue->renewals + 1;
2931
        my $renews = ( $issue->renewals || 0 ) + 1;
2931
        my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ?
2932
        my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ?
2932
                                WHERE borrowernumber=?
2933
                                WHERE borrowernumber=?
2933
                                AND itemnumber=?"
2934
                                AND itemnumber=?"
Lines 2936-2942 sub AddRenewal { Link Here
2936
        $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber );
2937
        $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber );
2937
2938
2938
        # Update the renewal count on the item, and tell zebra to reindex
2939
        # Update the renewal count on the item, and tell zebra to reindex
2939
        $renews = $item_object->renewals + 1;
2940
        $renews = ( $item_object->renewals || 0 ) + 1;
2940
        ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item_object->biblionumber, $itemnumber, { log_action => 0 } );
2941
        ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item_object->biblionumber, $itemnumber, { log_action => 0 } );
2941
2942
2942
        # Charge a new rental fee, if applicable
2943
        # Charge a new rental fee, if applicable
(-)a/C4/Items.pm (-7 / +9 lines)
Lines 552-558 sub ModItemTransfer { Link Here
552
    my $item = Koha::Items->find( $itemnumber );
552
    my $item = Koha::Items->find( $itemnumber );
553
553
554
    # Remove the 'shelving cart' location status if it is being used.
554
    # Remove the 'shelving cart' location status if it is being used.
555
    CartToShelf( $itemnumber ) if ( $item->location eq 'CART' && $item->permanent_location ne 'CART' );
555
    CartToShelf( $itemnumber ) if $item->location && $item->location eq 'CART' && ( !$item->permanent_location || $item->permanent_location ne 'CART' );
556
556
557
    $dbh->do("UPDATE branchtransfers SET datearrived = NOW(), comments = ? WHERE itemnumber = ? AND datearrived IS NULL", undef, "Canceled, new transfer from $frombranch to $tobranch created", $itemnumber);
557
    $dbh->do("UPDATE branchtransfers SET datearrived = NOW(), comments = ? WHERE itemnumber = ? AND datearrived IS NULL", undef, "Canceled, new transfer from $frombranch to $tobranch created", $itemnumber);
558
558
Lines 1445-1455 sub _do_column_fixes_for_mod { Link Here
1445
        (not defined $item->{'withdrawn'} or $item->{'withdrawn'} eq '')) {
1445
        (not defined $item->{'withdrawn'} or $item->{'withdrawn'} eq '')) {
1446
        $item->{'withdrawn'} = 0;
1446
        $item->{'withdrawn'} = 0;
1447
    }
1447
    }
1448
    if (exists $item->{location}
1448
    if (
1449
        and $item->{location} ne 'CART'
1449
        exists $item->{location}
1450
        and $item->{location} ne 'PROC'
1450
        and ( !defined $item->{location}
1451
            || ( $item->{location} ne 'CART' and $item->{location} ne 'PROC' ) )
1451
        and not $item->{permanent_location}
1452
        and not $item->{permanent_location}
1452
    ) {
1453
      )
1454
    {
1453
        $item->{'permanent_location'} = $item->{'location'};
1455
        $item->{'permanent_location'} = $item->{'location'};
1454
    }
1456
    }
1455
    if (exists $item->{'timestamp'}) {
1457
    if (exists $item->{'timestamp'}) {
Lines 2515-2521 sub PrepareItemrecordDisplay { Link Here
2515
                    $subfield_data{marc_value} = {
2517
                    $subfield_data{marc_value} = {
2516
                        type    => 'select',
2518
                        type    => 'select',
2517
                        values  => \@authorised_values,
2519
                        values  => \@authorised_values,
2518
                        default => "$defaultvalue",
2520
                        default => $defaultvalue // q{},
2519
                        labels  => \%authorised_lib,
2521
                        labels  => \%authorised_lib,
2520
                    };
2522
                    };
2521
                } elsif ( $tagslib->{$tag}->{$subfield}->{value_builder} ) {
2523
                } elsif ( $tagslib->{$tag}->{$subfield}->{value_builder} ) {
Lines 2528-2534 sub PrepareItemrecordDisplay { Link Here
2528
                    my $pars = { dbh => $dbh, record => undef, tagslib =>$tagslib, id => $subfield_data{id}, tabloop => undef };
2530
                    my $pars = { dbh => $dbh, record => undef, tagslib =>$tagslib, id => $subfield_data{id}, tabloop => undef };
2529
                    $plugin->build( $pars );
2531
                    $plugin->build( $pars );
2530
                    if ( $itemrecord and my $field = $itemrecord->field($tag) ) {
2532
                    if ( $itemrecord and my $field = $itemrecord->field($tag) ) {
2531
                        $defaultvalue = $field->subfield($subfield);
2533
                        $defaultvalue = $field->subfield($subfield) || q{};
2532
                    }
2534
                    }
2533
                    if( !$plugin->errstr ) {
2535
                    if( !$plugin->errstr ) {
2534
                        #TODO Move html to template; see report 12176/13397
2536
                        #TODO Move html to template; see report 12176/13397
(-)a/C4/Koha.pm (-1 / +1 lines)
Lines 846-852 sub NormalizeISBN { Link Here
846
846
847
    my $string        = $params->{isbn};
847
    my $string        = $params->{isbn};
848
    my $strip_hyphens = $params->{strip_hyphens};
848
    my $strip_hyphens = $params->{strip_hyphens};
849
    my $format        = $params->{format};
849
    my $format        = $params->{format} || q{};
850
    my $return_invalid = $params->{return_invalid};
850
    my $return_invalid = $params->{return_invalid};
851
851
852
    return unless $string;
852
    return unless $string;
(-)a/C4/Overdues.pm (-3 / +3 lines)
Lines 247-253 sub CalcFine { Link Here
247
    my $fine_unit = $issuing_rule->lengthunit || 'days';
247
    my $fine_unit = $issuing_rule->lengthunit || 'days';
248
248
249
    my $chargeable_units = get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode);
249
    my $chargeable_units = get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode);
250
    my $units_minus_grace = $chargeable_units - $issuing_rule->firstremind;
250
    my $units_minus_grace = $chargeable_units - ($issuing_rule->firstremind || 0);
251
    my $amount = 0;
251
    my $amount = 0;
252
    if ( $issuing_rule->chargeperiod && ( $units_minus_grace > 0 ) ) {
252
    if ( $issuing_rule->chargeperiod && ( $units_minus_grace > 0 ) ) {
253
        my $units = C4::Context->preference('FinesIncludeGracePeriod') ? $chargeable_units : $units_minus_grace;
253
        my $units = C4::Context->preference('FinesIncludeGracePeriod') ? $chargeable_units : $units_minus_grace;
Lines 261-269 sub CalcFine { Link Here
261
    $amount = $issuing_rule->overduefinescap if $issuing_rule->overduefinescap && $amount > $issuing_rule->overduefinescap;
261
    $amount = $issuing_rule->overduefinescap if $issuing_rule->overduefinescap && $amount > $issuing_rule->overduefinescap;
262
262
263
    # This must be moved to Koha::Item (see also similar code in C4::Accounts::chargelostitem
263
    # This must be moved to Koha::Item (see also similar code in C4::Accounts::chargelostitem
264
    $item->{replacementprice} ||= $itemtype->defaultreplacecost
264
    $item->{replacementprice} //= $itemtype->defaultreplacecost
265
      if $itemtype
265
      if $itemtype
266
      && $item->{replacementprice} == 0
266
      && ( ! defined $item->{replacementprice} || $item->{replacementprice} == 0 )
267
      && C4::Context->preference("useDefaultReplacementCost");
267
      && C4::Context->preference("useDefaultReplacementCost");
268
268
269
    $amount = $item->{replacementprice} if ( $issuing_rule->cap_fine_to_replacement_price && $item->{replacementprice} && $amount > $item->{replacementprice} );
269
    $amount = $item->{replacementprice} if ( $issuing_rule->cap_fine_to_replacement_price && $item->{replacementprice} && $amount > $item->{replacementprice} );
(-)a/C4/Record.pm (-3 / +3 lines)
Lines 80-86 Returns an ISO-2709 scalar Link Here
80
sub marc2marc {
80
sub marc2marc {
81
	my ($marc,$to_flavour,$from_flavour,$encoding) = @_;
81
	my ($marc,$to_flavour,$from_flavour,$encoding) = @_;
82
	my $error;
82
	my $error;
83
    if ($to_flavour =~ m/marcstd/) {
83
    if ($to_flavour && $to_flavour =~ m/marcstd/) {
84
        my $marc_record_obj;
84
        my $marc_record_obj;
85
        if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object
85
        if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object
86
            $marc_record_obj = $marc;
86
            $marc_record_obj = $marc;
Lines 427-438 sub marc2csv { Link Here
427
        for my $itemnumber ( @$itemnumbers) {
427
        for my $itemnumber ( @$itemnumbers) {
428
            my $item = Koha::Items->find( $itemnumber );
428
            my $item = Koha::Items->find( $itemnumber );
429
            my $biblionumber = $item->biblio->biblionumber;
429
            my $biblionumber = $item->biblio->biblionumber;
430
            $output .= marcrecord2csv( $biblionumber, $id, $firstpass, $csv, $fieldprocessing, [$itemnumber] );
430
            $output .= marcrecord2csv( $biblionumber, $id, $firstpass, $csv, $fieldprocessing, [$itemnumber] ) // '';
431
            $firstpass = 0;
431
            $firstpass = 0;
432
        }
432
        }
433
    } else {
433
    } else {
434
        foreach my $biblio (@$biblios) {
434
        foreach my $biblio (@$biblios) {
435
            $output .= marcrecord2csv( $biblio, $id, $firstpass, $csv, $fieldprocessing );
435
            $output .= marcrecord2csv( $biblio, $id, $firstpass, $csv, $fieldprocessing ) // '';
436
            $firstpass = 0;
436
            $firstpass = 0;
437
        }
437
        }
438
    }
438
    }
(-)a/C4/Reserves.pm (-6 / +10 lines)
Lines 204-210 sub AddReserve { Link Here
204
    my $waitingdate;
204
    my $waitingdate;
205
205
206
    # If the reserv had the waiting status, we had the value of the resdate
206
    # If the reserv had the waiting status, we had the value of the resdate
207
    if ( $found eq 'W' ) {
207
    if ( $found && $found eq 'W' ) {
208
        $waitingdate = $resdate;
208
        $waitingdate = $resdate;
209
    }
209
    }
210
210
Lines 228-234 sub AddReserve { Link Here
228
            item_level_hold => $checkitem ? 1 : 0,
228
            item_level_hold => $checkitem ? 1 : 0,
229
        }
229
        }
230
    )->store();
230
    )->store();
231
    $hold->set_waiting() if $found eq 'W';
231
    $hold->set_waiting() if $found && $found eq 'W';
232
232
233
    logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) )
233
    logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) )
234
        if C4::Context->preference('HoldsLog');
234
        if C4::Context->preference('HoldsLog');
Lines 1067-1073 sub ModReserveStatus { Link Here
1067
    $sth_set->execute( $newstatus, $itemnumber );
1067
    $sth_set->execute( $newstatus, $itemnumber );
1068
1068
1069
    my $item = Koha::Items->find($itemnumber);
1069
    my $item = Koha::Items->find($itemnumber);
1070
    if ( ( $item->location eq 'CART' && $item->permanent_location ne 'CART'  ) && $newstatus ) {
1070
    if ( $item->location && $item->location eq 'CART'
1071
        && ( !$item->permanent_location || $item->permanent_location ne 'CART' )
1072
        && $newstatus ) {
1071
      CartToShelf( $itemnumber );
1073
      CartToShelf( $itemnumber );
1072
    }
1074
    }
1073
}
1075
}
Lines 1120-1126 sub ModReserveAffect { Link Here
1120
1122
1121
    _FixPriority( { biblionumber => $biblionumber } );
1123
    _FixPriority( { biblionumber => $biblionumber } );
1122
    my $item = Koha::Items->find($itemnumber);
1124
    my $item = Koha::Items->find($itemnumber);
1123
    if ( ( $item->location eq 'CART' && $item->permanent_location ne 'CART'  ) ) {
1125
    if ( $item->location && $item->location eq 'CART'
1126
        && ( !$item->permanent_location || $item->permanent_location ne 'CART' ) ) {
1124
      CartToShelf( $itemnumber );
1127
      CartToShelf( $itemnumber );
1125
    }
1128
    }
1126
1129
Lines 1472-1478 sub _FixPriority { Link Here
1472
    if ( $rank eq "del" ) { # FIXME will crash if called without $hold
1475
    if ( $rank eq "del" ) { # FIXME will crash if called without $hold
1473
        $hold->cancel;
1476
        $hold->cancel;
1474
    }
1477
    }
1475
    elsif ( $rank eq "W" || $rank eq "0" ) {
1478
    elsif ( $reserve_id && ( $rank eq "W" || $rank eq "0" ) ) {
1476
1479
1477
        # make sure priority for waiting or in-transit items is 0
1480
        # make sure priority for waiting or in-transit items is 0
1478
        my $query = "
1481
        my $query = "
Lines 1500-1510 sub _FixPriority { Link Here
1500
        push( @priority,     $line );
1503
        push( @priority,     $line );
1501
    }
1504
    }
1502
1505
1506
    # FIXME This whole sub must be rewritten, especially to highlight what is done when reserve_id is not given
1503
    # To find the matching index
1507
    # To find the matching index
1504
    my $i;
1508
    my $i;
1505
    my $key = -1;    # to allow for 0 to be a valid result
1509
    my $key = -1;    # to allow for 0 to be a valid result
1506
    for ( $i = 0 ; $i < @priority ; $i++ ) {
1510
    for ( $i = 0 ; $i < @priority ; $i++ ) {
1507
        if ( $reserve_id == $priority[$i]->{'reserve_id'} ) {
1511
        if ( $reserve_id && $reserve_id == $priority[$i]->{'reserve_id'} ) {
1508
            $key = $i;    # save the index
1512
            $key = $i;    # save the index
1509
            last;
1513
            last;
1510
        }
1514
        }
(-)a/C4/Serials.pm (-1 / +1 lines)
Lines 2144-2150 sub abouttoexpire { Link Here
2144
            }
2144
            }
2145
        }
2145
        }
2146
2146
2147
    } elsif ($subscription->{numberlength}>0) {
2147
    } elsif ( $subscription->{numberlength} && $subscription->{numberlength}>0) {
2148
        return (countissuesfrom($subscriptionid,$subscription->{'startdate'}) >=$subscription->{numberlength}-1);
2148
        return (countissuesfrom($subscriptionid,$subscription->{'startdate'}) >=$subscription->{numberlength}-1);
2149
    }
2149
    }
2150
2150
(-)a/Koha/Plugins/Base.pm (-2 / +1 lines)
Lines 179-185 sub get_metadata { Link Here
179
179
180
    #FIXME: Why another encoding issue? For metadata containing non latin characters.
180
    #FIXME: Why another encoding issue? For metadata containing non latin characters.
181
    my $metadata = $self->{metadata};
181
    my $metadata = $self->{metadata};
182
    utf8::decode($metadata->{$_}) for keys %$metadata;
182
    $metadata->{$_} && utf8::decode($metadata->{$_}) for keys %$metadata;
183
    return $metadata;
183
    return $metadata;
184
}
184
}
185
185
186
- 

Return to bug 24361