5 # Copyright 2005 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
23 use lib '/usr/local/koha/intranet/modules';
25 use C4::Circulation::Circ2;
28 my $cui = new Curses::UI( -color_support => 1 );
34 { -label => 'Issues ^I', -value => \&issues },
35 { -label => 'Returns ^R', -value => \&returns },
36 { -label => 'Exit ^Q', -value => \&exit_dialog }
74 $win1->add( "text", "TextEditor",
75 -text => "Here is some text\n" . "And some more" );
77 $cui->set_binding( sub { $menu->focus() }, "\cX" );
78 $cui->set_binding( \&exit_dialog, "\cQ" );
79 $cui->set_binding( \&issues, "\cI" );
80 $cui->set_binding( \&returns, "\cR" );
86 my $return = $cui->dialog(
87 -message => "Do you really want to quit?",
88 -title => "Are you sure???",
89 -buttons => [ 'yes', 'no' ],
97 my $barcode = $cui->question(
99 -question => 'Barcode'
104 my ( $returned, $messages, $iteminformation, $borrower ) =
105 returnbook( $barcode, $branch );
106 if ( $borrower && $borrower->{'borrowernumber'} ) {
108 getpatroninformation( \%env, $borrower->{'borrowernumber'}, 0 );
109 $win1->delete('borrowerdata');
110 my $borrowerdata = $win1->add( 'borrowerdata', 'TextViewer',
111 -text => "Cardnumber: $borrower->{'cardnumber'}\n"
112 . "Name: $borrower->{'title'} $borrower->{'firstname'} $borrower->{'surname'}"
115 $borrowerdata->focus();
118 $cui->error( -message => 'That item isnt on loan' );
125 # this routine does the actual issuing
131 # the librarian can overide system issue date, need to fetch values from them
137 $win1->delete('text');
139 # get a cardnumber or a name
140 my $cardnumber = $cui->question(
142 -question => 'Cardnumber'
145 # search for that borrower
146 my ( $count, $borrowers ) =
147 BornameSearch( \%env, $cardnumber, 'cardnumber', 'web' );
148 my @borrowers = @$borrowers;
149 if ( $#borrowers == -1 ) {
150 $cui->error( -message =>
151 'No borrowers match that name or cardnumber please try again.' );
153 elsif ( $#borrowers == 0 ) {
154 $borrowernumber = $borrowers[0]->{'borrowernumber'};
157 $borrowerlist = \@borrowers;
160 if ($borrowernumber) {
162 # if we have one single borrower, we can start issuing
163 my $borrower = getpatroninformation( \%env, $borrowernumber, 0 );
164 $win1->delete('borrowerdata');
165 my $borrowerdata = $win1->add( 'borrowerdata', 'TextViewer',
166 -text => "Cardnumber: $borrower->{'cardnumber'}\n"
167 . "Name: $borrower->{'title'} $borrower->{'firstname'} $borrower->{'surname'}"
170 $borrowerdata->focus();
172 $win3->delete('pastissues');
173 my $issueslist = getissues($borrower);
175 foreach my $it ( keys %$issueslist ) {
177 $issueslist->{$it}->{'barcode'}
178 . " $issueslist->{$it}->{'title'} $issueslist->{$it}->{'date_due'}\n";
183 $win3->add( 'pastissues', 'TextViewer', -text => $oldissues, );
184 $pastissues->focus();
186 $win2->delete('currentissues');
188 $win2->add( 'currentissues', 'TextViewer',
189 -text => "Todays issues go here", );
190 $currentissues->focus();
192 # go into a loop issuing until a blank barcode is given
193 while ( my $barcode = $cui->question( -question => 'Barcode' ) ) {
195 my ( $error, $question ) =
196 canbookbeissued( \%env, $borrower, $barcode, $year, $month,
200 foreach my $impossible ( keys %$error ) {
201 $cui->error( -message => $impossible );
205 foreach my $needsconfirmation ( keys %$question ) {
207 $issueconfirmed = $cui->dialog(
208 -message => $needsconfirmation,
209 -title => "Confirmation",
210 -buttons => [ 'yes', 'no' ],
215 if ( $noerror && ( $noquestion || $issueconfirmed ) ) {
216 issuebook( \%env, $borrower, $barcode, $datedue );
222 elsif ($borrowerlist) {
223 my $listbox = $win1->add(
226 -values => [ 1, 2, 3 ],
236 my $selected = $listbox->get();