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 => "This is the first cut of a \ncirculations system using Curses::UI\n".
76 "Use the menus (or the keyboard\nshortcuts) to choose issues or \nreturns");
78 $cui->set_binding( sub { $menu->focus() }, "\cX" );
79 $cui->set_binding( \&exit_dialog, "\cQ" );
80 $cui->set_binding( \&issues, "\cI" );
81 $cui->set_binding( \&returns, "\cR" );
87 my $return = $cui->dialog(
88 -message => "Do you really want to quit?",
89 -title => "Are you sure???",
90 -buttons => [ 'yes', 'no' ],
98 my $barcode = $cui->question(
100 -question => 'Barcode'
105 my ( $returned, $messages, $iteminformation, $borrower ) =
106 returnbook( $barcode, $branch );
107 if ( $borrower && $borrower->{'borrowernumber'} ) {
109 getpatroninformation( \%env, $borrower->{'borrowernumber'}, 0 );
110 $win1->delete('borrowerdata');
111 my $borrowerdata = $win1->add( 'borrowerdata', 'TextViewer',
112 -text => "Cardnumber: $borrower->{'cardnumber'}\n"
113 . "Name: $borrower->{'title'} $borrower->{'firstname'} $borrower->{'surname'}"
116 $borrowerdata->focus();
119 $cui->error( -message => 'That item isnt on loan' );
126 # this routine does the actual issuing
132 # the librarian can overide system issue date, need to fetch values from them
138 $win1->delete('text');
140 # get a cardnumber or a name
141 my $cardnumber = $cui->question(
143 -question => 'Cardnumber'
146 # search for that borrower
147 my ( $count, $borrowers ) =
148 BornameSearch( \%env, $cardnumber, 'cardnumber', 'web' );
149 my @borrowers = @$borrowers;
150 if ( $#borrowers == -1 ) {
151 $cui->error( -message =>
152 'No borrowers match that name or cardnumber please try again.' );
154 elsif ( $#borrowers == 0 ) {
155 $borrowernumber = $borrowers[0]->{'borrowernumber'};
158 $borrowerlist = \@borrowers;
161 if ($borrowernumber) {
163 # if we have one single borrower, we can start issuing
164 my $borrower = getpatroninformation( \%env, $borrowernumber, 0 );
165 $win1->delete('borrowerdata');
166 my $borrowerdata = $win1->add( 'borrowerdata', 'TextViewer',
167 -text => "Cardnumber: $borrower->{'cardnumber'}\n"
168 . "Name: $borrower->{'title'} $borrower->{'firstname'} $borrower->{'surname'}"
171 $borrowerdata->focus();
173 $win3->delete('pastissues');
174 my $issueslist = getissues($borrower);
176 foreach my $it ( keys %$issueslist ) {
178 $issueslist->{$it}->{'barcode'}
179 . " $issueslist->{$it}->{'title'} $issueslist->{$it}->{'date_due'}\n";
184 $win3->add( 'pastissues', 'TextViewer', -text => $oldissues, );
185 $pastissues->focus();
187 $win2->delete('currentissues');
189 $win2->add( 'currentissues', 'TextViewer',
190 -text => "Todays issues go here", );
191 $currentissues->focus();
193 # go into a loop issuing until a blank barcode is given
194 while ( my $barcode = $cui->question( -question => 'Barcode' ) ) {
196 my ( $error, $question ) =
197 canbookbeissued( \%env, $borrower, $barcode, $year, $month,
201 foreach my $impossible ( keys %$error ) {
202 $cui->error( -message => $impossible );
206 foreach my $needsconfirmation ( keys %$question ) {
208 $issueconfirmed = $cui->dialog(
209 -message => $needsconfirmation,
210 -title => "Confirmation",
211 -buttons => [ 'yes', 'no' ],
216 if ( $noerror && ( $noquestion || $issueconfirmed ) ) {
217 issuebook( \%env, $borrower, $barcode, $datedue );
223 elsif ($borrowerlist) {
224 my $listbox = $win1->add(
227 -values => [ 1, 2, 3 ],
237 my $selected = $listbox->get();