fixes in circulation module
This commit is contained in:
parent
59ea82d93c
commit
ab39e57393
3 changed files with 88 additions and 199 deletions
|
@ -308,14 +308,6 @@ yet. The date is in YYYY-MM-DD format.
|
|||
|
||||
=back
|
||||
|
||||
=head3 loanlength
|
||||
|
||||
=over 4
|
||||
|
||||
The length of time for which the item can be borrowed, in days.
|
||||
|
||||
=back
|
||||
|
||||
=head3 notforloan
|
||||
|
||||
=over 4
|
||||
|
@ -357,7 +349,6 @@ sub getiteminformation {
|
|||
$sth=$dbh->prepare("select * from itemtypes where itemtype=?");
|
||||
$sth->execute($iteminformation->{'itemtype'});
|
||||
my $itemtype=$sth->fetchrow_hashref;
|
||||
$iteminformation->{'loanlength'}=$itemtype->{'loanlength'};
|
||||
# if specific item notforloan, don't use itemtype notforloan field.
|
||||
# otherwise, use itemtype notforloan value to see if item can be issued.
|
||||
$iteminformation->{'notforloan'}=$itemtype->{'notforloan'} unless $iteminformation->{'notforloan'};
|
||||
|
@ -599,92 +590,91 @@ if the borrower borrows to much things
|
|||
# returns an array with errors if any
|
||||
|
||||
sub TooMany ($$){
|
||||
my $borrower = shift;
|
||||
my $iteminformation = shift;
|
||||
my $cat_borrower = $borrower->{'categorycode'};
|
||||
my $branch_borrower = $borrower->{'branchcode'};
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $borrower = shift;
|
||||
my $iteminformation = shift;
|
||||
my $cat_borrower = $borrower->{'categorycode'};
|
||||
my $branch_borrower = $borrower->{'branchcode'};
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
|
||||
my $sth = $dbh->prepare('select itemtype from biblioitems where biblionumber = ?');
|
||||
$sth->execute($iteminformation->{'biblionumber'});
|
||||
my $type = $sth->fetchrow;
|
||||
my $sth = $dbh->prepare('select itemtype from biblioitems where biblionumber = ?');
|
||||
$sth->execute($iteminformation->{'biblionumber'});
|
||||
my $type = $sth->fetchrow;
|
||||
warn "checking $branch_borrower / $cat_borrower / $type";
|
||||
$sth = $dbh->prepare('select * from issuingrules where categorycode = ? and itemtype = ? and branchcode = ?');
|
||||
my $sth2 = $dbh->prepare("select COUNT(*) from issues i, biblioitems s where i.borrowernumber = ? and i.returndate is null and i.itemnumber = s.biblioitemnumber and s.itemtype like ?");
|
||||
my $sth3 = $dbh->prepare('select COUNT(*) from issues where borrowernumber = ? and returndate is null');
|
||||
my $alreadyissued;
|
||||
$sth->execute($cat_borrower, $type, $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
warn "==>".$result->{maxissueqty};
|
||||
if (defined($result)) {
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("A $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare('select * from issuingrules where categorycode = ? and itemtype = ? and branchcode = ?');
|
||||
my $sth2 = $dbh->prepare("select COUNT(i.borrowernumber) from issues i, biblioitems s where i.borrowernumber = ? and i.returndate is null and i.itemnumber = s.biblioitemnumber and s.itemtype like ?");
|
||||
my $sth3 = $dbh->prepare('select COUNT(borrowernumber) from issues where borrowernumber = ? and returndate is null');
|
||||
|
||||
$sth->execute($cat_borrower, $type, $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
|
||||
}
|
||||
$sth->execute($cat_borrower, $type, "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result)) {
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("B $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
|
||||
$sth->execute($cat_borrower, $type, "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
|
||||
}
|
||||
$sth->execute($cat_borrower, "*", $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result)) {
|
||||
$sth3->execute($borrower->{'borrowernumber'});
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("C $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
|
||||
$sth->execute($cat_borrower, "*", $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth3->execute($borrower->{'borrowernumber'});
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow);
|
||||
}
|
||||
$sth->execute("*", $type, $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result)) {
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("D $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
|
||||
$sth->execute("*", $type, $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
|
||||
}
|
||||
$sth->execute("*", "*", $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result)) {
|
||||
$sth3->execute($borrower->{'borrowernumber'});
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("E $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
|
||||
$sth->execute("*", "*", $branch_borrower);
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth3->execute($borrower->{'borrowernumber'});
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow);
|
||||
}
|
||||
$sth->execute("*", $type, "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result)) {
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("F $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
|
||||
$sth->execute("*", $type, "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
|
||||
}
|
||||
$sth->execute($cat_borrower, "*", "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result)) {
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("G $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
|
||||
$sth->execute($cat_borrower, "*", "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
|
||||
}
|
||||
|
||||
$sth->execute("*", "*", "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result))
|
||||
{
|
||||
$sth3->execute($borrower->{'borrowernumber'});
|
||||
return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow);
|
||||
}
|
||||
|
||||
return (1);
|
||||
$sth->execute("*", "*", "*");
|
||||
my $result = $sth->fetchrow_hashref;
|
||||
if (defined($result)) {
|
||||
$sth3->execute($borrower->{'borrowernumber'});
|
||||
my $alreadyissued = $sth2->fetchrow;
|
||||
return ("H $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sub canbookbeissued {
|
||||
my ($env,$borrower,$barcode,$year,$month,$day) = @_;
|
||||
warn "CHECKING CANBEISSUED for $borrower->{'borrowernumber'}, $barcode";
|
||||
my %needsconfirmation; # filled with problems that needs confirmations
|
||||
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE
|
||||
my $iteminformation = getiteminformation($env, 0, $barcode);
|
||||
|
@ -698,13 +688,13 @@ sub canbookbeissued {
|
|||
#
|
||||
# BORROWER STATUS
|
||||
#
|
||||
if ($borrower->{flags}->{'gonenoaddress'}) {
|
||||
if ($borrower->{flags}->{GNA}) {
|
||||
$issuingimpossible{GNA} = 1;
|
||||
}
|
||||
if ($borrower->{flags}->{'lost'}) {
|
||||
if ($borrower->{flags}->{'LOST'}) {
|
||||
$issuingimpossible{CARD_LOST} = 1;
|
||||
}
|
||||
if ($borrower->{flags}->{'debarred'}) {
|
||||
if ($borrower->{flags}->{'DBARRED'}) {
|
||||
$issuingimpossible{DEBARRED} = 1;
|
||||
}
|
||||
#
|
||||
|
@ -721,10 +711,8 @@ sub canbookbeissued {
|
|||
#
|
||||
# JB34 CHECKS IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS
|
||||
#
|
||||
|
||||
$needsconfirmation{TOO_MANY} = 1
|
||||
if (!TooMany($borrower, $iteminformation));
|
||||
|
||||
my $toomany = TooMany($borrower, $iteminformation);
|
||||
$needsconfirmation{TOO_MANY} = $toomany if $toomany;
|
||||
|
||||
#
|
||||
# ITEM CHECKING
|
||||
|
@ -745,7 +733,7 @@ sub canbookbeissued {
|
|||
$issuingimpossible{RESTRICTED} = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
|
||||
|
|
|
@ -73,7 +73,7 @@ if ($query->param('setcookies')) {
|
|||
$printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
|
||||
}
|
||||
|
||||
my %env; # env is used as an "environment" variable. Could be dropped probably...
|
||||
my %env; # FIXME env is used as an "environment" variable. Could be dropped probably...
|
||||
$env{'branchcode'}=$branch;
|
||||
$env{'printer'}=$printer;
|
||||
$env{'queue'}=$printer;
|
||||
|
@ -106,9 +106,8 @@ if ($findborrower) {
|
|||
# get the borrower information.....
|
||||
my $borrower;
|
||||
if ($borrowernumber) {
|
||||
$borrower = getpatroninformation(\%env,$borrowernumber,0);
|
||||
|
||||
my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
|
||||
$borrower = getpatroninformation(\%env,$borrowernumber,0);
|
||||
my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
|
||||
$template->param(overduecount => $od,
|
||||
issuecount => $issue,
|
||||
finetotal => $fines);
|
||||
|
@ -134,10 +133,8 @@ if ($barcode) {
|
|||
$barcode = cuecatbarcodedecode($barcode);
|
||||
my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
|
||||
if ($issueconfirmed) {
|
||||
warn "CONFIRMED";
|
||||
issuebook(\%env, $borrower, $barcode, $datedue);
|
||||
} else {
|
||||
# unless ($invalidduedate) {
|
||||
my ($error, $question) = canbookbeissued(\%env, $borrower, $barcode, $year, $month, $day);
|
||||
my $noerror=1;
|
||||
my $noquestion = 1;
|
||||
|
@ -152,12 +149,9 @@ if ($barcode) {
|
|||
$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.....
|
||||
|
@ -263,7 +257,6 @@ if ($borrowerslist) {
|
|||
}
|
||||
#title
|
||||
|
||||
my ($patrontable, $flaginfotable) = patrontable($borrower);
|
||||
my $amountold=$borrower->{flags}->{'CHARGES'}->{'message'};
|
||||
my @temp=split(/\$/,$amountold);
|
||||
$amountold=$temp[1];
|
||||
|
@ -275,8 +268,6 @@ $template->param(
|
|||
printer => $printer,
|
||||
branchname => $branches->{$branch}->{'branchname'},
|
||||
printername => $printers->{$printer}->{'printername'},
|
||||
# title => $iteminformation->{'title'},
|
||||
# author => $iteminformation->{'author'},
|
||||
firstname => $borrower->{'firstname'},
|
||||
surname => $borrower->{'surname'},
|
||||
categorycode => $borrower->{'categorycode'},
|
||||
|
@ -325,96 +316,6 @@ sub cuecatbarcodedecode {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
sub patrontable {
|
||||
my ($borrower) = @_;
|
||||
my $flags = $borrower->{'flags'};
|
||||
my $flaginfotable='';
|
||||
my $flaginfotext;
|
||||
#my $flaginfotext='';
|
||||
my $flag;
|
||||
my $color='';
|
||||
foreach $flag (sort keys %$flags) {
|
||||
$flags->{$flag}->{'message'}=~s/\n/<br>/g;
|
||||
if ($flags->{$flag}->{'noissues'}) {
|
||||
$template->param(
|
||||
noissues => 'true',
|
||||
color => $color,
|
||||
);
|
||||
if ($flag eq 'GNA'){
|
||||
$template->param(
|
||||
gna => 'true'
|
||||
);
|
||||
}
|
||||
if ($flag eq 'LOST'){
|
||||
$template->param(
|
||||
lost => 'true'
|
||||
);
|
||||
}
|
||||
if ($flag eq 'DBARRED'){
|
||||
$template->param(
|
||||
dbarred => 'true'
|
||||
);
|
||||
}
|
||||
if ($flag eq 'CHARGES') {
|
||||
$template->param(
|
||||
charges => 'true',
|
||||
chargesmsg => $flags->{'CHARGES'}->{'message'}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ($flag eq 'CHARGES') {
|
||||
$template->param(
|
||||
charges => 'true',
|
||||
chargesmsg => $flags->{'CHARGES'}->{'message'}
|
||||
);
|
||||
}
|
||||
if ($flag eq 'WAITING') {
|
||||
my $items=$flags->{$flag}->{'itemlist'};
|
||||
my @itemswaiting;
|
||||
foreach my $item (@$items) {
|
||||
my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
|
||||
$iteminformation->{'branchname'} = $branches->{$iteminformation->{'holdingbranch'}}->{'branchname'};
|
||||
push @itemswaiting, $iteminformation;
|
||||
}
|
||||
$template->param(
|
||||
waiting => 'true',
|
||||
waitingmsg => $flags->{'WAITING'}->{'message'},
|
||||
itemswaiting => \@itemswaiting,
|
||||
);
|
||||
}
|
||||
if ($flag eq 'ODUES') {
|
||||
$template->param(
|
||||
odues => 'true',
|
||||
oduesmsg => $flags->{'ODUES'}->{'message'}
|
||||
);
|
||||
|
||||
my $items=$flags->{$flag}->{'itemlist'};
|
||||
my $currentcolor=$color;
|
||||
{
|
||||
my $color=$currentcolor;
|
||||
my @itemswaiting;
|
||||
foreach my $item (@$items) {
|
||||
# ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
|
||||
my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
|
||||
push @itemswaiting, $iteminformation;
|
||||
}
|
||||
}
|
||||
if ($query->param('module') ne 'returns'){
|
||||
$template->param( nonreturns => 'true' );
|
||||
}
|
||||
}
|
||||
if ($flag eq 'NOTES') {
|
||||
$template->param(
|
||||
notes => 'true',
|
||||
notesmsg => $flags->{'NOTES'}->{'message'}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return($patrontable, $flaginfotext);
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# End:
|
||||
|
|
|
@ -149,19 +149,19 @@
|
|||
<h2 class="problem">Issuing impossible</h2>
|
||||
<!-- TMPL_IF NAME="INVALID_DATE" -->
|
||||
<p class="problem">The due date is invalid</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="UNKNOWN_BARCODE" -->
|
||||
<p class="problem">The barcode is unknown</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="NOT_FOR_LOAN" -->
|
||||
<p class="problem">Item not for loan</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="WTHDRAWN" -->
|
||||
<p class="problem">Item withdrawn</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="GNA" -->
|
||||
<p class="problem">Borrower is gone with no address</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="CARD_LOST" -->
|
||||
<p class="problem">Borrower's card is lost</p>
|
||||
<!-- /TMPL_IF -->
|
||||
|
@ -176,7 +176,7 @@
|
|||
<!-- TMPL_IF NAME="NEEDSCONFIRMATION" -->
|
||||
<h2 class="problem">I need confirmation before issuing</h2>
|
||||
<!-- TMPL_IF NAME="DEBT" -->
|
||||
<p>The borrower has debts</p>
|
||||
<p>The borrower has a debt of <!-- TMPL_VAR name="DEBT" --></p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="RENEW_ISSUE" -->
|
||||
<p>Not an issue but a renewal</p>
|
||||
|
@ -188,7 +188,7 @@
|
|||
<p>Item issued to <!-- TMPL_VAR NAME="ISSUED_TO_ANOTHER" -->. Return & issue?</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="TOO_MANY" -->
|
||||
<p class="problem">Too many issues!</p>
|
||||
<p class="problem">Too many issues (already issued / max : <!-- TMPL_VAR name="TOO_MANY" -->)</p>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_UNLESS name="IMPOSSIBLE" -->
|
||||
<form method="post">
|
||||
|
|
Loading…
Reference in a new issue