X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;ds=sidebyside;f=admin%2Fsmart-rules.pl;h=3c77f9389315b7f3b9278076b775b5be2f9b83e7;hb=c0655aabe47cfe21e7846b7a8956db92c1e5b5d2;hp=d015ec2a0079533ca6d0a526188764a307b9dd10;hpb=4735e296cf99dea4dd5217193460f8585d6cf25d;p=koha_fer diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index d015ec2a00..3c77f93893 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# vim: et ts=4 sw=4 # Copyright 2000-2002 Katipo Communications +# copyright 2010 BibLibre # # This file is part of Koha. # @@ -26,6 +26,7 @@ use C4::Auth; use C4::Koha; use C4::Debug; use C4::Branch; # GetBranches +use C4::Dates qw/format_date format_date_in_iso/; my $input = new CGI; my $dbh = C4::Context->dbh; @@ -100,8 +101,8 @@ elsif ($op eq 'delete-branch-item') { # save the values entered elsif ($op eq 'add') { my $sth_search = $dbh->prepare("SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?"); - my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, issuelength, fine, finedays, firstremind, chargeperiod,rentaldiscount) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"); - my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, reservesallowed=?, issuelength=?, rentaldiscount=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); + my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, issuelength, hardduedate, hardduedatecompare, fine, finedays, firstremind, chargeperiod,rentaldiscount) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); + my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, reservesallowed=?, issuelength=?, hardduedate=?, hardduedatecompare=?, rentaldiscount=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); my $br = $branch; # branch my $bor = $input->param('categorycode'); # borrower category @@ -116,15 +117,18 @@ elsif ($op eq 'add') { $maxissueqty =~ s/\s//g; $maxissueqty = undef if $maxissueqty !~ /^\d+/; my $issuelength = $input->param('issuelength'); + my $hardduedate = $input->param('hardduedate'); + $hardduedate = format_date_in_iso($hardduedate); + my $hardduedatecompare = $input->param('hardduedatecompare'); my $rentaldiscount = $input->param('rentaldiscount'); $debug and warn "Adding $br, $bor, $cat, $fine, $maxissueqty"; $sth_search->execute($br,$bor,$cat); my $res = $sth_search->fetchrow_hashref(); if ($res->{total}) { - $sth_update->execute($fine, $finedays,$firstremind, $chargeperiod, $maxissueqty, $renewalsallowed,$reservesallowed, $issuelength,$rentaldiscount, $br,$bor,$cat); + $sth_update->execute($fine, $finedays,$firstremind, $chargeperiod, $maxissueqty, $renewalsallowed,$reservesallowed, $issuelength,$hardduedate,$hardduedatecompare,$rentaldiscount, $br,$bor,$cat); } else { - $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount); + $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$hardduedate,$hardduedatecompare,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount); } } elsif ($op eq "set-branch-defaults") { @@ -377,6 +381,14 @@ while (my $row = $sth2->fetchrow_hashref) { $row->{'humancategorycode'} ||= $row->{'categorycode'}; $row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*'; $row->{'fine'} = sprintf('%.2f', $row->{'fine'}); + if ($row->{'hardduedate'} ne '0000-00-00') { + $row->{'hardduedate'} = format_date( $row->{'hardduedate'}); + $row->{'hardduedatebefore'} = 1 if ($row->{'hardduedatecompare'} == -1); + $row->{'hardduedateexact'} = 1 if ($row->{'hardduedatecompare'} == 0); + $row->{'hardduedateafter'} = 1 if ($row->{'hardduedatecompare'} == 1); + } else { + $row->{'hardduedate'} = 0; + } push @row_loop, $row; } $sth->finish;