[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/circ circulation.pl,1.68,1.69 returns.pl,1.36,1.37
From: |
Paul POULAIN |
Subject: |
[Koha-cvs] CVS: koha/circ circulation.pl,1.68,1.69 returns.pl,1.36,1.37 |
Date: |
Mon, 03 May 2004 02:02:17 -0700 |
Update of /cvsroot/koha/koha/circ
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32369/circ
Modified Files:
circulation.pl returns.pl
Log Message:
CIRCULATION : the big rewrite...
This 1st commit reorders deeply the circulation module.
The goal is to :
* have something 100% templated/translatable.
* have something easy to read & modify, to say to customers/users : you can
define your circulation rules as you want if you accept to look in
C4/Circ/Circ2.pm
The circulation now works :
1=> ask for the borrower barcode (as previously)
2=> ask for the item barcode.
3=> check "canbookbeissued". This new sub returns 2 arrays :
- IMPOSSIBLE : if something is here, then the issue is not possible and is not
done.
- TOBECONFIRMED : if something is here, then the issue can be donc if the user
confirms it.
4=> if TOBECONFIRMED is set : ask for confirmation, loop. if neither are set
or confirmation flag is set (2nd pass of the loop), then issue.
The IMPOSSIBLE & TOBECONFIRMED hashs contains :
* the reason of the line. always in capitals, with words separated by _ :
BARCODE_UNKNOWN, DEBTS ... as key of the hash
* more information, as value of the hash ( TOBECONFIRMED{ALREADY_ISSUED} =
"previous_borrower_name", for example)
This commit :
* compiles
* works on certain situations, not on other
* does NOT issue (the line is # )
* does not check issuing rules depending of # of books allowed / already issued
The next step is :
- check issuing rule.
- extend issuing rule to have a 3D array : for each branch / itemtype /
borrowertype = issuing number and issuing length.
Index: circulation.pl
===================================================================
RCS file: /cvsroot/koha/koha/circ/circulation.pl,v
retrieving revision 1.68
retrieving revision 1.69
diff -C2 -r1.68 -r1.69
*** circulation.pl 25 Feb 2004 18:09:29 -0000 1.68
--- circulation.pl 3 May 2004 09:02:13 -0000 1.69
***************
*** 36,42 ****
use C4::Date;
my $query=new CGI;
- #my ($loggedinuser, $sessioncookie, $sessionID) = checkauth
- # ($query, 0, { circulate => 1 });
my ($template, $loggedinuser, $cookie) = get_template_and_user
--- 36,43 ----
use C4::Date;
+ #
+ # PARAMETERS READING
+ #
my $query=new CGI;
my ($template, $loggedinuser, $cookie) = get_template_and_user
***************
*** 48,63 ****
flagsrequired => { circulate => 1 },
});
-
-
- my %env;
- my $linecolor1='#ffffcc';
- my $linecolor2='white';
-
my $branches = getbranches();
! my $printers = getprinters(\%env);
!
my $branch = getbranch($query, $branches);
my $printer = getprinter($query, $printers);
#set up cookie.....
--- 49,67 ----
flagsrequired => { circulate => 1 },
});
my $branches = getbranches();
! my $printers = getprinters();
my $branch = getbranch($query, $branches);
my $printer = getprinter($query, $printers);
+ my $findborrower = $query->param('findborrower');
+ my $borrowernumber = $query->param('borrnumber');
+ my $print=$query->param('print');
+ my $barcode = $query->param('barcode');
+ my $year=$query->param('year');
+ my $month=$query->param('month');
+ my $day=$query->param('day');
+ my $stickyduedate=$query->param('stickyduedate');
+ my $issueconfirmed = $query->param('issueconfirmed');
+
#set up cookie.....
***************
*** 69,72 ****
--- 73,77 ----
}
+ my %env; # env is used as an "environment" variable. Could be dropped
probably...
$env{'branchcode'}=$branch;
$env{'printer'}=$printer;
***************
*** 76,86 ****
# FIXME - Could just use POSIX::strftime("%Y%m%d", localtime);
my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d",
($datearr[4]+1)).sprintf ("%0.2d", ($datearr[3]));
- #warn $todaysdate;
! my $message;
! my $borrowerslist;
# if there is a list of find borrowers....
! my $findborrower = $query->param('findborrower');
if ($findborrower) {
my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'web');
--- 81,98 ----
# FIXME - Could just use POSIX::strftime("%Y%m%d", localtime);
my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d",
($datearr[4]+1)).sprintf ("%0.2d", ($datearr[3]));
+ # get the borrower information.....
+ my $borrower;
+ if ($borrowernumber) {
+ $borrower = getpatroninformation(\%env,$borrowernumber,0);
+ }
! # my $message;
!
! #
! # STEP 2 : FIND BORROWER
# if there is a list of find borrowers....
! #
! my $borrowerslist;
if ($findborrower) {
my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'web');
***************
*** 88,92 ****
if ($#borrowers == -1) {
$query->param('findborrower', '');
- $message = "'$findborrower'";
} elsif ($#borrowers == 0) {
$query->param('borrnumber', $borrowers[0]->{'borrowernumber'});
--- 100,103 ----
***************
*** 97,208 ****
}
! my $borrowernumber = $query->param('borrnumber');
! my $bornum = $query->param('borrnumber');
! # check and see if we should print
! my $print=$query->param('print');
! my $barcode = $query->param('barcode');
! if ($barcode eq '' && $print eq 'maybe'){
! $print = 'yes';
! }
! if ($print eq 'yes' && $borrowernumber ne ''){
! printslip(\%env,$borrowernumber);
! $query->param('borrnumber','');
! $borrowernumber='';
! }
!
! # get the borrower information.....
! my $borrower;
! my $flags;
! if ($borrowernumber) {
! ($borrower, $flags) = getpatroninformation(\%env,$borrowernumber,0);
! }
!
! # get the responses to any questions.....
! my %responses;
! foreach (sort $query->param) {
! if ($_ =~ /response-(\d*)/) {
! $responses{$1} = $query->param($_);
! }
! }
! if (my $qnumber = $query->param('questionnumber')) {
! $responses{$qnumber} = $query->param('answer');
! }
!
! my ($iteminformation, $duedate, $rejected, $question, $questionnumber,
$defaultanswer);
! my $year=$query->param('year');
! my $month=$query->param('month');
! my $day=$query->param('day');
- # if the barcode is set
if ($barcode) {
$barcode = cuecatbarcodedecode($barcode);
my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
! unless ($invalidduedate) {
! $env{'datedue'}=$datedue;
! my @time=localtime(time);
! my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3];
! ($iteminformation, $duedate, $rejected, $question,
$questionnumber, $defaultanswer, $message)
! = issuebook(\%env, $borrower, $barcode,
\%responses, $date);
! }
}
# reload the borrower info for the sake of reseting the flags.....
if ($borrowernumber) {
! ($borrower, $flags) = getpatroninformation(\%env,$borrowernumber,0);
}
-
##################################################################################
- # HTML code....
-
- my %responseform;
- my @responsearray;
- foreach (keys %responses) {
- # $responsesform.="<input type=hidden name=response-$_
value=$responses{$_}>\n";
- $responseform{'name'}=$_;
- $responseform{'value'}=$responses{$_};
- push @responsearray,\%responseform;
- }
- my $questionform;
- my $stickyduedate;
- if ($question) {
- $stickyduedate=$query->param('stickyduedate');
- }
-
-
- # Barcode entry box, with hidden inputs attached....
-
- # FIXME - How can we move this HTML into the template? Can we create
- # arrays of the months, dates, etc and use <TMPL_LOOP> in the template to
- # output the data that's getting built here?
- my $counter = 1;
- my $dayoptions = '';
- my $monthoptions = '';
- my $yearoptions = '';
- for (my $i=1; $i<32; $i++) {
- my $selected='';
- if (($query->param('stickyduedate')) && ($day==$i)) {
- $selected='selected';
- }
- $dayoptions.="<option value=$i $selected>$i";
- }
- foreach (('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec')) {
- my $selected='';
- if (($query->param('stickyduedate')) && ($month==$counter)) {
- $selected='selected';
- }
- $monthoptions.="<option value=$counter $selected>$_";
- $counter++;
- }
- for (my $i=$datearr[5]+1900; $i<$datearr[5]+1905; $i++) {
- my $selected='';
- if (($query->param('stickyduedate')) && ($year==$i)) {
- $selected='selected';
- }
- $yearoptions.="<option value=$i $selected>$i";
- }
- my $selected='';
- ($query->param('stickyduedate')) && ($selected='checked');
# make the issued books table.....
--- 108,161 ----
}
! #
! # STEP 3 : ISSUING
! #
! #
! # check and see if we should print
! # if ($barcode eq '' && $print eq 'maybe'){
! # $print = 'yes';
! # }
! # if ($print eq 'yes' && $borrowernumber ne ''){
! # printslip(\%env,$borrowernumber);
! # $query->param('borrnumber','');
! # $borrowernumber='';
! # }
if ($barcode) {
$barcode = cuecatbarcodedecode($barcode);
my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
! # unless ($invalidduedate) {
! my ($error, $question) = canbookbeissued(\%env, $borrower,
$barcode, $year, $month, $day);
! my $noerror=1;
! my $noquestion = 1;
! foreach my $impossible (keys %$error) {
! warn "Impossible : $impossible :
";#.%$error->{$impossible};
! $template->param($impossible => 1,
! IMPOSSIBLE => 1);
! $noerror = 0;
! }
! foreach my $needsconfirmation (keys %$question) {
! warn "needsconfirmation : $needsconfirmation : ";
#.%$error->{$needsconfirmation};
! $template->param($needsconfirmation => 1,
! NEEDSCONFIRMATION => 1);
! $noquestion = 0;
! }
! if ($noerror && ($noquestion || $issueconfirmed)) {
! warn "NO ERROR";
! # issuebook(\%env, $borrower, $barcode, $datedue);
! }
!
! # }
}
# reload the borrower info for the sake of reseting the flags.....
if ($borrowernumber) {
! $borrower = getpatroninformation(\%env,$borrowernumber,0);
}
+
##################################################################################
+ # BUILD HTML
# make the issued books table.....
***************
*** 212,234 ****
my @realprevissues;
my $allowborrow;
- my $hash;
if ($borrower) {
! ($borrower, $flags,$hash) = getpatroninformation(\%env,$borrowernumber,0);
! $allowborrow= $hash->{'borrow'};
! my @todaysissues;
! my @previousissues;
! my $issueslist = getissues($borrower);
! foreach my $it (keys %$issueslist) {
! my $issuedate = $issueslist->{$it}->{'timestamp'};
! $issuedate = substr($issuedate, 0, 8);
! if ($todaysdate == $issuedate) {
! push @todaysissues, $issueslist->{$it};
! } else {
! push @previousissues, $issueslist->{$it};
! }
}
! my $tcolor = '';
! my $pcolor = '';
! my $od = '';
foreach my $book (sort {$b->{'timestamp'} <=> $a->{'timestamp'}}
@todaysissues){
my $dd = $book->{'date_due'};
--- 165,186 ----
my @realprevissues;
my $allowborrow;
if ($borrower) {
! # get each issue of the borrower & separate them in todayissues & previous
issues
! my @todaysissues;
! my @previousissues;
! my $issueslist = getissues($borrower);
! # split in 2 arrays for today & previous
! foreach my $it (keys %$issueslist) {
! my $issuedate = $issueslist->{$it}->{'timestamp'};
! $issuedate = substr($issuedate, 0, 8);
! if ($todaysdate == $issuedate) {
! push @todaysissues, $issueslist->{$it};
! } else {
! push @previousissues, $issueslist->{$it};
! }
}
! my $od; # overdues
! my $togglecolor;
! # parses today & build Template array
foreach my $book (sort {$b->{'timestamp'} <=> $a->{'timestamp'}}
@todaysissues){
my $dd = $book->{'date_due'};
***************
*** 237,284 ****
$datedue=~s/-//g;
if ($datedue < $todaysdate) {
! $od = 'true';
! $dd="$dd\n";
}
- ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) :
($tcolor=$linecolor1);
$book->{'od'}=$od;
$book->{'dd'}=$dd;
! $book->{'tcolor'}=$tcolor;
! if ($book->{'author'} eq ''){
! $book->{'author'}=' ';
}
push @realtodayissues,$book;
}
!
! # FIXME - For small and private libraries, it'd be nice if this
! # table included a "Return" link next to each book, so that you
! # don't have to remember the book's bar code and type it in on the
! # "Returns" page.
!
! # This is in the template now, so its possible for a small library to
make that link in their
! # template
!
foreach my $book (sort {$a->{'date_due'} cmp $b->{'date_due'}}
@previousissues){
! my $dd = $book->{'date_due'};
! my $datedue = $book->{'date_due'};
! $dd=format_date($dd);
! my $pcolor = '';
! my $od = '';
! $datedue=~s/-//g;
! if ($datedue < $todaysdate) {
! $od = 'true';
! $dd="$dd\n";
}
- ($pcolor eq $linecolor1) ? ($pcolor=$linecolor2) :
($pcolor=$linecolor1);
- $book->{'dd'}=$dd;
- $book->{'od'}=$od;
- $book->{'tcolor'}=$pcolor;
- if ($book->{'author'} eq ''){
- $book->{'author'}=' ';
- }
- push @realprevissues,$book
- }
}
my @values;
my %labels;
--- 189,240 ----
$datedue=~s/-//g;
if ($datedue < $todaysdate) {
! $od = 1;
! } else {
! $od=0;
}
$book->{'od'}=$od;
$book->{'dd'}=$dd;
! $book->{'tcolor'}=$togglecolor;
! if ($togglecolor) {
! $togglecolor=0;
! } else {
! $togglecolor=1;
! }
! if ($book->{'author'} eq ''){
! $book->{'author'}=' ';
}
push @realtodayissues,$book;
}
! # parses previous & build Template array
foreach my $book (sort {$a->{'date_due'} cmp $b->{'date_due'}}
@previousissues){
! my $dd = $book->{'date_due'};
! my $datedue = $book->{'date_due'};
! $dd=format_date($dd);
! my $pcolor = '';
! my $od = '';
! $datedue=~s/-//g;
! if ($datedue < $todaysdate) {
! $od = 1;
! } else {
! $od = 0;
! }
! $book->{'tcolor'}=$togglecolor;
! if ($togglecolor) {
! $togglecolor=0;
! } else {
! $togglecolor=1;
! }
! $book->{'dd'}=$dd;
! $book->{'od'}=$od;
! $book->{'tcolor'}=$pcolor;
! if ($book->{'author'} eq ''){
! $book->{'author'}=' ';
! }
! push @realprevissues,$book
}
}
+
my @values;
my %labels;
***************
*** 298,302 ****
my ($patrontable, $flaginfotable) = patrontable($borrower);
! my $amountold=$flags->{'CHARGES'}->{'message'};
my @temp=split(/\$/,$amountold);
$amountold=$temp[1];
--- 254,258 ----
my ($patrontable, $flaginfotable) = patrontable($borrower);
! my $amountold=$borrower->{flags}->{'CHARGES'}->{'message'};
my @temp=split(/\$/,$amountold);
$amountold=$temp[1];
***************
*** 309,317 ****
branchname => $branches->{$branch}->{'branchname'},
printername => $printers->{$printer}->{'printername'},
! allowborrow =>$allowborrow,
! #question form
! question => $question,
! title => $iteminformation->{'title'},
! author => $iteminformation->{'author'},
firstname => $borrower->{'firstname'},
surname => $borrower->{'surname'},
--- 265,270 ----
branchname => $branches->{$branch}->{'branchname'},
printername => $printers->{$printer}->{'printername'},
! # title => $iteminformation->{'title'},
! # author => $iteminformation->{'author'},
firstname => $borrower->{'firstname'},
surname => $borrower->{'surname'},
***************
*** 321,343 ****
phone => $borrower->{'phone'},
cardnumber => $borrower->{'cardnumber'},
! question => $question,
barcode => $barcode,
- questionnumber => $questionnumber,
- dayoptions => $dayoptions,
- monthoptions => $monthoptions,
- yearoptions => $yearoptions,
stickyduedate => $stickyduedate,
- rejected => $rejected,
- message => $message,
CGIselectborrower => $CGIselectborrower,
- amountold => $amountold,
todayissues => address@hidden,
previssues => address@hidden,
- responseloop => address@hidden,
- month=>$month,
- day=>$day,
- year=>$year
-
);
if ($branchcookie) {
--- 274,296 ----
phone => $borrower->{'phone'},
cardnumber => $borrower->{'cardnumber'},
! amountold => $amountold,
barcode => $barcode,
stickyduedate => $stickyduedate,
CGIselectborrower => $CGIselectborrower,
todayissues => address@hidden,
previssues => address@hidden,
);
+ # set return date if stickyduedate
+ if ($stickyduedate) {
+ my $t_year = "year".$year;
+ my $t_month = "month".$month;
+ my $t_day = "day".$day;
+ $template->param(
+ $t_year => 1,
+ $t_month => 1,
+ $t_day => 1,
+ );
+ }
+
if ($branchcookie) {
***************
*** 362,396 ****
}
- sub fixdate {
- my ($year, $month, $day) = @_;
- my $invalidduedate;
- my $date;
- if (($year eq 0) && ($month eq 0) && ($year eq 0)) {
- $env{'datedue'}='';
- } else {
-
- # FIXME - Can we set two flags here, one that says 'invalidduedate', so that
- # the template can check for it, and then one for a particular message?
- # Ex: <TMPL_IF NAME="invalidduedate"> <TMPL_IF NAME="daysinFeb">
- # Invalid Due Date Specified. Book was not issued. Never that many days
- # in February! </TMPL_IF> </TMPL_IF>
-
- if (($year eq 0) || ($month eq 0) || ($year eq 0)) {
- $invalidduedate="Invalid Due Date Specified. Book was not
issued.<p>\n";
- } else {
- if (($day>30) && (($month==4) || ($month==6) || ($month==9) ||
($month==11))) {
- $invalidduedate = "Invalid Due Date Specified. Book was not
issued. Only 30 days in $month month.<p>\n";
- } elsif (($day > 29) && ($month == 2)) {
- $invalidduedate="Invalid Due Date Specified. Book was not
issued. Never that many days in February!<p>\n";
- } elsif (($month == 2) && ($day > 28) && (($year%4) &&
((!($year%100) || ($year%400))))) {
- $invalidduedate="Invalid Due Date Specified. Book was not
issued. $year is not a leap year.<p>\n";
- } else {
- $date="$year-$month-$day";
- }
- }
- }
- return ($date, $invalidduedate);
- }
-
sub patrontable {
--- 315,318 ----
***************
*** 403,409 ****
my $color='';
foreach $flag (sort keys %$flags) {
- warn $flag;
- # my @itemswaiting='';
- ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
$flags->{$flag}->{'message'}=~s/\n/<br>/g;
if ($flags->{$flag}->{'noissues'}) {
--- 325,328 ----
***************
*** 466,470 ****
my @itemswaiting;
foreach my $item (@$items) {
! ($color eq $linecolor1) ? ($color=$linecolor2)
: ($color=$linecolor1);
my ($iteminformation) =
getiteminformation(\%env, $item->{'itemnumber'}, 0);
push @itemswaiting, $iteminformation;
--- 385,389 ----
my @itemswaiting;
foreach my $item (@$items) {
! # ($color eq $linecolor1) ? ($color=$linecolor2)
: ($color=$linecolor1);
my ($iteminformation) =
getiteminformation(\%env, $item->{'itemnumber'}, 0);
push @itemswaiting, $iteminformation;
***************
*** 486,523 ****
}
-
- # FIXME - This clashes with &C4::Print::printslip
- sub printslip {
- my ($env,$borrowernumber)address@hidden;
- my ($borrower, $flags) = getpatroninformation($env,$borrowernumber,0);
- $env->{'todaysissues'}=1;
- my ($borrowerissues) = currentissues($env, $borrower);
- $env->{'nottodaysissues'}=1;
- $env->{'todaysissues'}=0;
- my ($borroweriss2)=currentissues($env, $borrower);
- $env->{'nottodaysissues'}=0;
- my $i=0;
- my @issues;
- foreach (sort {$a <=> $b} keys %$borrowerissues) {
- $issues[$i]=$borrowerissues->{$_};
- my $dd=$issues[$i]->{'date_due'};
- #convert to nz style dates
- #this should be set with some kinda config variable
- my @tempdate=split(/-/,$dd);
- $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
- $i++;
- }
- foreach (sort {$a <=> $b} keys %$borroweriss2) {
- $issues[$i]=$borroweriss2->{$_};
- my $dd=$issues[$i]->{'date_due'};
- #convert to nz style dates
- #this should be set with some kinda config variable
- my @tempdate=split(/-/,$dd);
- $issues[$i]->{'date_due'}="$tempdate[2]/$tempdate[1]/$tempdate[0]";
- $i++;
- }
- remoteprint($env,address@hidden,$borrower);
- }
-
# Local Variables:
# tab-width: 8
--- 405,408 ----
Index: returns.pl
===================================================================
RCS file: /cvsroot/koha/koha/circ/returns.pl,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** returns.pl 15 Mar 2004 23:41:20 -0000 1.36
--- returns.pl 3 May 2004 09:02:14 -0000 1.37
***************
*** 118,122 ****
$borr->{'surname'} . " " . $borr->{'title'} . " " .
$borr->{'firstname'};
my $slip = $query->param('resslip');
! printslip( \%env, $slip );
if ( $tobranchcd ne $branch ) {
--- 118,122 ----
$borr->{'surname'} . " " . $borr->{'title'} . " " .
$borr->{'firstname'};
my $slip = $query->param('resslip');
! # printslip( \%env, $slip ); #removed by paul
if ( $tobranchcd ne $branch ) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/circ circulation.pl,1.68,1.69 returns.pl,1.36,1.37,
Paul POULAIN <=