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

(-)a/C4/SIP/ILS/Transaction/Checkin.pm (-1 / +17 lines)
Lines 65-71 sub do_checkin { Link Here
65
                   . substr( $return_date, 16, 2 );
65
                   . substr( $return_date, 16, 2 );
66
66
67
    $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
67
    $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
68
    my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
68
69
    # BEG Core::Circulation OVERRIDE
70
    #my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
71
    use C4::Context;
72
    use Koha::Items;
73
    use Koha::Libraries;
74
    use Class::Load qw(load_optional_class);
75
    my $core = C4::Context->config("core_modules")->{sip} or die "Missing core_modules->sip config";
76
    my $class = load_optional_class($core) ? $core : "Core::Circulation::SIP";
77
    my $lib = Koha::Libraries->find($branch);
78
    my $item = Koha::Items->find($self->{item}->{itemnumber});
79
    my $circ = $class->new({ item => $item, library => $lib });
80
    my $return = $circ->Checkin($return_date); # SHOULD WE TRUST SIP RETURN DATE?
81
    my $messages = $circ->{messages};
82
    my $iteminformation = $circ->{iteminformation};
83
    # END Core::Circulation OVERRIDE
84
69
    $self->alert(!$return);
85
    $self->alert(!$return);
70
    # ignoring messages: NotIssued, WasLost, WasTransfered
86
    # ignoring messages: NotIssued, WasLost, WasTransfered
71
87
(-)a/C4/SIP/ILS/Transaction/Checkout.pm (-31 / +45 lines)
Lines 48-65 sub new { Link Here
48
sub do_checkout {
48
sub do_checkout {
49
	my $self = shift;
49
	my $self = shift;
50
	syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
50
	syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
51
	my $pending        = $self->{item}->pending_queue;
51
52
	my $shelf          = $self->{item}->hold_shelf;
52
    # BEG Core::Circulation OVERRIDE - Checkout
53
	my $barcode        = $self->{item}->id;
53
    # NOTE: HAD TO ADD BRANCH TO MsgType::handle_checkout and ILS::checkout SINCE THERE IS NO BRANCH CONTEXT IN SIP
54
	my $patron_barcode = $self->{patron}->id;
54
    use Koha::Items;
55
        my $overridden_duedate; # usually passed as undef to AddIssue
55
    use Koha::Libraries;
56
	$debug and warn "do_checkout: patron (" . $patron_barcode . ")";
56
    my $core = C4::Context->config("core_modules")->{sip} or die "Missing core_modules->sip config";
57
    my $patron = Koha::Patrons->find( { cardnumber => $patron_barcode } );
57
    my $class = load_optional_class($core) ? $core : "Core::Circulation::SIP";
58
    my $borrower = $patron->unblessed;
58
    my $library = Koha::Libraries->find($self->{branch});
59
	$debug and warn "do_checkout borrower: . " . Dumper $borrower;
59
    my $item = Koha::Items->find($self->{item}->{itemnumber});
60
    my ($issuingimpossible, $needsconfirmation) = _can_we_issue($patron, $barcode,
60
    my $patron = Koha::Patrons->find({cardnumber => $self->{patron}->id});
61
        C4::Context->preference("AllowItemsOnHoldCheckout")
61
    my $circ = $class->new({
62
    );
62
        item => $item,
63
        library => $library,
64
        patron => $patron,
65
    });
66
    $debug and warn "do_checkout: patron (" . $self->{patron}->id . ")";
67
    my ($issuingimpossible, $needsconfirmation, $alerts, $messages) = $circ->canItemBeIssued();
68
    my $pending        = $self->{item}->pending_queue;
69
    my $shelf          = $self->{item}->hold_shelf;
70
    my $overridden_duedate; # usually passed as undef to AddIssue
71
    #use Data::Dumper; warn Dumper($circ->{messages});
72
    #use Data::Dumper; warn Dumper($issuingimpossible);
73
    #use Data::Dumper; warn Dumper($needsconfirmation);
74
    #use Data::Dumper; warn Dumper($messages);
75
    # END Core::Circulation OVERRIDE
63
76
64
    my $noerror=1;  # If set to zero we block the issue
77
    my $noerror=1;  # If set to zero we block the issue
65
    if (keys %{$issuingimpossible}) {
78
    if (keys %{$issuingimpossible}) {
Lines 74-80 sub do_checkout { Link Here
74
            if ($confirmation eq 'RENEW_ISSUE'){
87
            if ($confirmation eq 'RENEW_ISSUE'){
75
                $self->screen_msg("Item already checked out to you: renewing item.");
88
                $self->screen_msg("Item already checked out to you: renewing item.");
76
            } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') {
89
            } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') {
77
                my $x = $self->{item}->available($patron_barcode);
90
                my $x = $self->{item}->available($self->{patron}->id);
78
                if ($x) {
91
                if ($x) {
79
                    $self->screen_msg("Item was reserved for you.");
92
                    $self->screen_msg("Item was reserved for you.");
80
                } else {
93
                } else {
Lines 90-96 sub do_checkout { Link Here
90
                $noerror = 0;
103
                $noerror = 0;
91
                last;
104
                last;
92
            } elsif ($confirmation eq 'HIGHHOLDS') {
105
            } elsif ($confirmation eq 'HIGHHOLDS') {
93
                $overridden_duedate = $needsconfirmation->{$confirmation}->{returndate};
106
                $overridden_duedate = $needsconfirmation->{HIGHHOLDS}->{returndate};
94
                $self->screen_msg('Loan period reduced for high-demand item');
107
                $self->screen_msg('Loan period reduced for high-demand item');
95
            } elsif ($confirmation eq 'RENTALCHARGE') {
108
            } elsif ($confirmation eq 'RENTALCHARGE') {
96
                if ($self->{fee_ack} ne 'Y') {
109
                if ($self->{fee_ack} ne 'Y') {
Lines 106-111 sub do_checkout { Link Here
106
            }
119
            }
107
        }
120
        }
108
    }
121
    }
122
    # TODO: THIS SHOULD NOT BE HANDLED HERE
109
    my $itemnumber = $self->{item}->{itemnumber};
123
    my $itemnumber = $self->{item}->{itemnumber};
110
    foreach (@$shelf) {
124
    foreach (@$shelf) {
111
        $debug and warn "shelf has ($_->{itemnumber} for $_->{borrowernumber}). this is ($itemnumber, $self->{patron}->{borrowernumber})";
125
        $debug and warn "shelf has ($_->{itemnumber} for $_->{borrowernumber}). this is ($itemnumber, $self->{patron}->{borrowernumber})";
Lines 116-121 sub do_checkout { Link Here
116
        $self->screen_msg("Item is on hold shelf for another patron.");
130
        $self->screen_msg("Item is on hold shelf for another patron.");
117
        $noerror = 0;
131
        $noerror = 0;
118
    }
132
    }
133
    # TODO: WE DONT USE ISSUING CHARGES
119
    my ($fee, undef) = GetIssuingCharges($itemnumber, $self->{patron}->{borrowernumber});
134
    my ($fee, undef) = GetIssuingCharges($itemnumber, $self->{patron}->{borrowernumber});
120
    if ( $fee > 0 ) {
135
    if ( $fee > 0 ) {
121
        $self->{sip_fee_type} = '06';
136
        $self->{sip_fee_type} = '06';
Lines 129-151 sub do_checkout { Link Here
129
		$self->ok(0);
144
		$self->ok(0);
130
		return $self;
145
		return $self;
131
	}
146
	}
132
    # Fill any reserves the patron had on the item.  
147
	# BEG Core::Circulation OVERRIDE - Checkout
133
    # TODO: this logic should be pulled internal to AddIssue for all Koha. 
148
    # Fill any reserves the patron had on the item.
134
    $debug and warn "pending_queue: " . (@$pending) ? Dumper($pending) : '[]';
149
    # TODO: this logic should be pulled internal to AddIssue for all Koha.
135
    foreach (grep {$_->{borrowernumber} eq $self->{patron}->{borrowernumber}} @$pending) {
150
    #$debug and warn "pending_queue: " . (@$pending) ? Dumper($pending) : '[]';
136
        $debug and warn "Filling reserve (borrowernumber,biblionumber,reservedate): "
151
    #foreach (grep {$_->{borrowernumber} eq $self->{patron}->{borrowernumber}} @$pending) {
137
            . sprintf("(%s,%s,%s)\n",$_->{borrowernumber},$_->{biblionumber},$_->{reservedate});
152
    #    $debug and warn "Filling reserve (borrowernumber,biblionumber,reservedate): "
138
        ModReserveFill($_);
153
    #        . sprintf("(%s,%s,%s)\n",$_->{borrowernumber},$_->{biblionumber},$_->{reservedate});
139
        # TODO: adjust representation in $self->item
154
    #    ModReserveFill($_);
140
    }
155
    #}
141
	# can issue
156
142
	$debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n"
157
    #my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 );
143
		# . "w/ \$borrower: " . Dumper($borrower)
158
    $circ->Checkout();
144
		. "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
159
    $self->{due} = $circ->{checkout}->date_due;
145
    my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 );
160
    # END Core::Circulation OVERRIDE
146
    $self->{due} = $self->duedatefromissue($issue, $itemnumber);
161
147
162
    $self->ok(1);
148
	$self->ok(1);
149
	return $self;
163
	return $self;
150
}
164
}
151
165
(-)a/C4/SIP/Sip/MsgType.pm (-1 / +2 lines)
Lines 514-520 sub handle_checkout { Link Here
514
514
515
        # Does the transaction date really matter for items that are
515
        # Does the transaction date really matter for items that are
516
        # checkout out while the terminal is online?  I'm guessing 'no'
516
        # checkout out while the terminal is online?  I'm guessing 'no'
517
        $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $fee_ack );
517
        my $branch = $fields->{(FID_CURRENT_LOCN)} ? $fields->{(FID_CURRENT_LOCN)} : $ils->institution;
518
        $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $fee_ack, $branch );
518
    }
519
    }
519
520
520
    $item   = $status->item;
521
    $item   = $status->item;
(-)a/circ/circulation.pl (-1 / +22 lines)
Lines 421-427 if (@$barcodes) { Link Here
421
        }
421
        }
422
        unless($confirm_required) {
422
        unless($confirm_required) {
423
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
423
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
424
            my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } );
424
425
            # BEG Core::Circulation OVERRIDE - USE Checkin
426
            # my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } );
427
            my $class;
428
            {
429
                use Class::Load qw(load_optional_class);
430
                my $core_modules = C4::Context->config("core_modules");
431
                $core_modules or warn "Missing core_modules config in koha-conf.xml, running default circulation";
432
                $core_modules->{circulation} or warn "Missing core_modules->circulation running default circulation";
433
                $class = $core_modules->{circulation} ? $core_modules->{circulation} : "Core::Community::Circulation";
434
                load_optional_class($class) or die "Failed loading $class, cannot continue";
435
            }
436
            my $library = Koha::Libraries->find($branch);
437
            my $circ = $class->new({
438
                item => $item,
439
                library => $library,
440
                patron => $patron,
441
            });
442
            $circ->Checkout( $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } );
443
            my $issue = $circ->{checkout};
444
            # END Core::Circulation OVERRIDE
445
425
            $template_params->{issue} = $issue;
446
            $template_params->{issue} = $issue;
426
            $session->clear('auto_renew');
447
            $session->clear('auto_renew');
427
            $inprocess = 1;
448
            $inprocess = 1;
(-)a/circ/renew.pl (-1 / +24 lines)
Lines 92-98 if ($barcode) { Link Here
92
                }
92
                }
93
                if ($can_renew) {
93
                if ($can_renew) {
94
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
94
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
95
                    my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode );
95
96
                    ### BEG Core::Circulation OVERRIDE - Renew
97
                    # my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode );
98
                    my $class;
99
                    {
100
                        use Class::Load qw(load_optional_class);
101
                        my $core_modules = C4::Context->config("core_modules");
102
                        $core_modules or warn "Missing core_modules config in koha-conf.xml, running default circulation";
103
                        $core_modules->{circulation} or warn "Missing core_modules->circulation running default circulation";
104
                        $class = $core_modules->{circulation} ? $core_modules->{circulation} : "Core::Community::Circulation";
105
                        load_optional_class($class) or die "Failed loading $class, cannot continue";
106
                    }
107
108
                    my $library = Koha::Libraries->find($branchcode);
109
                    my $patron = Koha::Patrons->find($borrower->borrowernumber());
110
                    my $itm = Koha::Items->find($item->itemnumber());
111
                    my $circ = $class->new({
112
                        item => $itm,
113
                        library => $library,
114
                        patron => $patron,
115
                    });
116
                    my (undef, $date_due) = $circ->Renew();
117
                    ### END Core::Circulation OVERRIDE
118
96
                    $template->param( date_due => $date_due );
119
                    $template->param( date_due => $date_due );
97
                }
120
                }
98
            }
121
            }
(-)a/circ/returns.pl (-3 / +22 lines)
Lines 301-310 if ($barcode) { Link Here
301
        barcode => $barcode,
301
        barcode => $barcode,
302
    );
302
    );
303
303
304
    # BEG Core::Circulation OVERRIDE - Return
304
305
305
    # do the return
306
    # do the return
306
    ( $returned, $messages, $issue, $borrower ) =
307
    #( $returned, $messages, $issue, $borrower ) =
307
      AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate );
308
    #  AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate );
309
    my $class;
310
    {
311
        use Class::Load qw(load_optional_class);
312
        my $core_modules = C4::Context->config("core_modules");
313
        $core_modules or warn "Missing core_modules config in koha-conf.xml, running default circulation";
314
        $core_modules->{circulation} or warn "Missing core_modules->circulation running default circulation";
315
        $class = $core_modules->{circulation} ? $core_modules->{circulation} : "Core::Community::Circulation";
316
        load_optional_class($class) or die "Failed loading $class, cannot continue";
317
    }
318
    my $lib = Koha::Libraries->find($returnbranch);
319
    my $circ = $class->new({ item => $item, library => $lib });
320
    $circ->Checkin( $exemptfine, $dropboxmode, $return_date_override, $dropboxdate );
321
    use Data::Dumper; warn Dumper($circ->{messages});
322
    # TODO: Needs to decide if $self->{checkout} should be emptied upon checkout or not
323
    my $messages = $circ->{messages};
324
    my $issue = $circ->{checkout};
325
    my $borrower = $circ->{patron} ? $circ->{patron}->unblessed : undef;
326
    my $returned = $circ->{error} ? 0 : 1;
327
    # END Core::Circulation OVERRIDE
308
328
309
    if ($returned) {
329
    if ($returned) {
310
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
330
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
311
- 

Return to bug 21327