View | Details | Raw Unified | Return to bug 9296
Collapse All | Expand All

(-)a/C4/Overdues.pm (-7 / +8 lines)
Lines 971-982 C<$categorycode> contains the borrower categorycode Link Here
971
971
972
sub GetOverdueDelays {
972
sub GetOverdueDelays {
973
    my ($category) = @_;
973
    my ($category) = @_;
974
    my $query      = qq|SELECT delay1,delay2,delay3
974
    my $query      = qq|SELECT delay
975
                FROM overduerules
975
                FROM overduerules
976
                WHERE categorycode=?|;
976
                WHERE categorycode=?
977
                ORDER BY typecode ASC|;
977
    my $sth = C4::Context->dbh->prepare($query);
978
    my $sth = C4::Context->dbh->prepare($query);
978
    $sth->execute($category);
979
    $sth->execute($category);
979
    my (@delays) = $sth->fetchrow_array;
980
    my (@delays) = ($sth->fetchrow_array,$sth->fetchrow_array,$sth->fetchrow_array);
980
    return (@delays);
981
    return (@delays);
981
}
982
}
982
983
Lines 990-996 returns a list of branch codes for branches with overdue rules defined. Link Here
990
991
991
sub GetBranchcodesWithOverdueRules {
992
sub GetBranchcodesWithOverdueRules {
992
    my $dbh               = C4::Context->dbh;
993
    my $dbh               = C4::Context->dbh;
993
    my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> '' ORDER BY branchcode");
994
    my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay IS NOT NULL AND branchcode <> '' ORDER BY branchcode");
994
    $rqoverduebranches->execute;
995
    $rqoverduebranches->execute;
995
    my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref };
996
    my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref };
996
    if (!$branches[0]) {
997
    if (!$branches[0]) {
Lines 1051-1061 C<$notify_level> contains the notify level Link Here
1051
sub GetOverduerules {
1052
sub GetOverduerules {
1052
    my ( $category, $notify_level ) = @_;
1053
    my ( $category, $notify_level ) = @_;
1053
    my $dbh   = C4::Context->dbh;
1054
    my $dbh   = C4::Context->dbh;
1054
    my $query = qq|SELECT debarred$notify_level
1055
    my $query = qq|SELECT debarred
1055
                     FROM overduerules
1056
                     FROM overduerules
1056
                    WHERE categorycode=?|;
1057
                    WHERE categorycode=? AND typecode=?|;
1057
    my $sth = $dbh->prepare($query);
1058
    my $sth = $dbh->prepare($query);
1058
    $sth->execute($category);
1059
    $sth->execute($category,$notify_level);
1059
    my ($overduerules) = $sth->fetchrow;
1060
    my ($overduerules) = $sth->fetchrow;
1060
    return ($overduerules);
1061
    return ($overduerules);
1061
}
1062
}
(-)a/installer/data/mysql/kohastructure.sql (-10 / +6 lines)
Lines 1625-1642 CREATE TABLE `opac_news` ( -- data from the news tool Link Here
1625
1625
1626
DROP TABLE IF EXISTS `overduerules`;
1626
DROP TABLE IF EXISTS `overduerules`;
1627
CREATE TABLE `overduerules` ( -- overdue notice status and triggers
1627
CREATE TABLE `overduerules` ( -- overdue notice status and triggers
1628
  `overduerules_id` mediumint NOT NULL AUTO_INCREMENT,
1629
  `delay` int(4) default NULL, -- number of days after the item is overdue that this notice is sent
1630
  `letter` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent
1631
  `debarred` varchar(1) default 0, -- is the patron restricted when this notice is sent (1 for yes, 0 for no)
1632
  `typecode` varchar(10) NOT NULL default '1', -- 1 2 3 for first second third, may be extended later
1628
  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to define which branch this rule is for (if blank it's all libraries)
1633
  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to define which branch this rule is for (if blank it's all libraries)
1629
  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
1634
  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
1630
  `delay1` int(4) default NULL, -- number of days after the item is overdue that the first notice is sent
1635
  PRIMARY KEY (`overduerules_id`)
1631
  `letter1` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the first notice
1632
  `debarred1` varchar(1) default 0, -- is the patron restricted when the first notice is sent (1 for yes, 0 for no)
1633
  `delay2` int(4) default NULL, -- number of days after the item is overdue that the second notice is sent
1634
  `debarred2` varchar(1) default 0, -- is the patron restricted when the second notice is sent (1 for yes, 0 for no)
1635
  `letter2` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the second notice
1636
  `delay3` int(4) default NULL, -- number of days after the item is overdue that the third notice is sent
1637
  `letter3` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the third notice
1638
  `debarred3` int(1) default 0, -- is the patron restricted when the third notice is sent (1 for yes, 0 for no)
1639
  PRIMARY KEY  (`branchcode`,`categorycode`)
1640
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1636
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1641
1637
1642
--
1638
--
(-)a/installer/data/mysql/updatedatabase.pl (+21 lines)
Lines 6983-6988 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
6983
    SetVersion($DBversion);
6983
    SetVersion($DBversion);
6984
}
6984
}
6985
6985
6986
$DBversion = "3.13.00.XXX";
6987
if ( CheckVersion($DBversion) ) {
6988
    $dbh->do("ALTER TABLE overduerules RENAME TO old_overduerules");
6989
    $dbh->do("CREATE TABLE `overduerules` ( -- overdue notice status and triggers
6990
  `overduerules_id` mediumint NOT NULL AUTO_INCREMENT,
6991
  `delay` int(4) default NULL, -- number of days after the item is overdue that this notice is sent
6992
  `letter` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent
6993
  `debarred` varchar(1) default 0, -- is the patron restricted when this notice is sent (1 for yes, 0 for no)
6994
  `typecode` varchar(10) NOT NULL default '1', -- 1 2 3 for first second third, may be extended later
6995
  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to define which branch this rule is for (if blank it's all libraries)
6996
  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
6997
  PRIMARY KEY (`overduerules_id`)
6998
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6999
");
7000
    $dbh->do("INSERT INTO overduerules (delay, letter, debarred, typecode, branchcode, categorycode) SELECT delay1 AS delay, letter1 AS letter, debarred1 as debarred, '1' AS typecode, branchcode, categorycode FROM old_overduerules");
7001
    $dbh->do("INSERT INTO overduerules (delay, letter, debarred, typecode, branchcode, categorycode) SELECT delay2 AS delay, letter2 AS letter, debarred2 as debarred, '2' AS typecode, branchcode, categorycode FROM old_overduerules");
7002
    $dbh->do("INSERT INTO overduerules (delay, letter, debarred, typecode, branchcode, categorycode) SELECT delay3 AS delay, letter3 AS letter, debarred3 as debarred, '3' AS typecode, branchcode, categorycode FROM old_overduerules");
7003
    print "Upgrade to $DBversion done (Restructure table overduerules for future expansion - you should check the conversion and DROP old_overduerules - that may be done automatically in a future version of Koha)\n";
7004
    SetVersion($DBversion);
7005
}
7006
6986
7007
6987
=head1 FUNCTIONS
7008
=head1 FUNCTIONS
6988
7009
(-)a/misc/cronjobs/overdue_notices.pl (-17 / +33 lines)
Lines 410-445 SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, TO_DAYS($date)-TO_DAYS Link Here
410
    AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ?
410
    AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ?
411
END_SQL
411
END_SQL
412
412
413
    my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? ";
413
    my $query = "SELECT * FROM overduerules WHERE delay IS NOT NULL AND typecode = ? AND branchcode = ? ";
414
    $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
414
    $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
415
    $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
415
    $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
416
    
416
    
417
    my $rqoverduerules =  $dbh->prepare($query);
417
    my $rqoverduerules =  $dbh->prepare($query);
418
    $rqoverduerules->execute($branchcode, @myborcat, @myborcatout);
418
    $rqoverduerules->execute(1, $branchcode, @myborcat, @myborcatout);
419
420
    my $trqoverduerules =  $dbh->prepare($query);
421
    $trqoverduerules->execute(2, $branchcode, @myborcat, @myborcatout);
422
423
    my $ttrqoverduerules =  $dbh->prepare($query);
424
    $ttrqoverduerules->execute(3, $branchcode, @myborcat, @myborcatout);
419
    
425
    
420
    # We get default rules is there is no rule for this branch
426
    # We get default rules is there is no rule for this branch
421
    if($rqoverduerules->rows == 0){
427
    if($rqoverduerules->rows == 0){
422
        $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' ";
428
        $query = "SELECT * FROM overduerules WHERE delay IS NOT NULL AND typecode = ? AND branchcode = '' ";
423
        $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
429
        $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
424
        $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
430
        $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
425
        
431
        
426
        $rqoverduerules = $dbh->prepare($query);
432
        $rqoverduerules = $dbh->prepare($query);
427
        $rqoverduerules->execute(@myborcat, @myborcatout);
433
        $rqoverduerules->execute(1, @myborcat, @myborcatout);
434
435
        $trqoverduerules = $dbh->prepare($query);
436
        $trqoverduerules->execute(2, @myborcat, @myborcatout);
437
438
        $ttrqoverduerules = $dbh->prepare($query);
439
        $ttrqoverduerules->execute(3, @myborcat, @myborcatout);
428
    }
440
    }
429
441
430
    # my $outfile = 'overdues_' . ( $mybranch || $branchcode || 'default' );
442
    # my $outfile = 'overdues_' . ( $mybranch || $branchcode || 'default' );
431
    while ( my $overdue_rules = $rqoverduerules->fetchrow_hashref ) {
443
    my @overdue_rules;
444
    while ( $overdue_rules[1] = $rqoverduerules->fetchrow_hashref ) {
445
      $overdue_rules[2] = $trqoverduerules->fetchrow_hashref;
446
      $overdue_rules[3] = $ttrqoverduerules->fetchrow_hashref;
447
432
      PERIOD: foreach my $i ( 1 .. 3 ) {
448
      PERIOD: foreach my $i ( 1 .. 3 ) {
433
449
434
            $verbose and warn "branch '$branchcode', pass $i\n";
450
            $verbose and warn "branch '$branchcode', pass $i\n";
435
            my $mindays = $overdue_rules->{"delay$i"};    # the notice will be sent after mindays days (grace period)
451
            my $mindays = $overdue_rules[$i]->{"delay"};    # the notice will be sent after mindays days (grace period)
436
            my $maxdays = (
452
            my $maxdays = (
437
                  $overdue_rules->{ "delay" . ( $i + 1 ) }
453
                  $overdue_rules[$i+1]->{ "delay" }
438
                ? $overdue_rules->{ "delay" . ( $i + 1 ) } - 1
454
                ? $overdue_rules[$i+1]->{ "delay" } - 1
439
                : ($MAX)
455
                : ($MAX)
440
            );                                            # issues being more than maxdays late are managed somewhere else. (borrower probably suspended)
456
            );                                            # issues being more than maxdays late are managed somewhere else. (borrower probably suspended)
441
457
442
            if ( !$overdue_rules->{"letter$i"} ) {
458
            if ( !$overdue_rules[$i]->{"letter"} ) {
443
                $verbose and warn "No letter$i code for branch '$branchcode'";
459
                $verbose and warn "No letter$i code for branch '$branchcode'";
444
                next PERIOD;
460
                next PERIOD;
445
            }
461
            }
Lines 461-469 END_SQL Link Here
461
                $borrower_sql .= ' AND issues.branchcode=? ';
477
                $borrower_sql .= ' AND issues.branchcode=? ';
462
                push @borrower_parameters, $branchcode;
478
                push @borrower_parameters, $branchcode;
463
            }
479
            }
464
            if ( $overdue_rules->{categorycode} ) {
480
            if ( $overdue_rules[$i]->{categorycode} ) {
465
                $borrower_sql .= ' AND borrowers.categorycode=? ';
481
                $borrower_sql .= ' AND borrowers.categorycode=? ';
466
                push @borrower_parameters, $overdue_rules->{categorycode};
482
                push @borrower_parameters, $overdue_rules[$i]->{categorycode};
467
            }
483
            }
468
            $borrower_sql .= '  AND categories.overduenoticerequired=1 ';
484
            $borrower_sql .= '  AND categories.overduenoticerequired=1 ';
469
            if($triggered) {
485
            if($triggered) {
Lines 477-483 END_SQL Link Here
477
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
493
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
478
	        my $sth = $dbh->prepare($borrower_sql);
494
	        my $sth = $dbh->prepare($borrower_sql);
479
            $sth->execute(@borrower_parameters);
495
            $sth->execute(@borrower_parameters);
480
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows";
496
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules[$i]->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows";
481
497
482
            while ( my $data = $sth->fetchrow_hashref ) {
498
            while ( my $data = $sth->fetchrow_hashref ) {
483
                my $borrowernumber = $data->{'borrowernumber'};
499
                my $borrowernumber = $data->{'borrowernumber'};
Lines 502-518 END_SQL Link Here
502
                    }
518
                    }
503
                }
519
                }
504
520
505
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode );
521
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules[$i]->{"letter"}, $branchcode );
506
522
507
                unless ($letter) {
523
                unless ($letter) {
508
                    $verbose and warn "Message '$overdue_rules->{letter$i}' content not found";
524
                    $verbose and warn "Message '$overdue_rules[$i]->{letter}' content not found";
509
525
510
                    # might as well skip while PERIOD, no other borrowers are going to work.
526
                    # might as well skip while PERIOD, no other borrowers are going to work.
511
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
527
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
512
                    next PERIOD;
528
                    next PERIOD;
513
                }
529
                }
514
    
530
    
515
                if ( $overdue_rules->{"debarred$i"} ) {
531
                if ( $overdue_rules[$i]->{"debarred"} ) {
516
    
532
    
517
                    #action taken is debarring
533
                    #action taken is debarring
518
                    C4::Members::DebarMember($borrowernumber, '9999-12-31');
534
                    C4::Members::DebarMember($borrowernumber, '9999-12-31');
Lines 541-547 END_SQL Link Here
541
                $sth2->finish;
557
                $sth2->finish;
542
558
543
                $letter = parse_letter(
559
                $letter = parse_letter(
544
                    {   letter_code     => $overdue_rules->{"letter$i"},
560
                    {   letter_code     => $overdue_rules[$i]->{"letter"},
545
                        borrowernumber  => $borrowernumber,
561
                        borrowernumber  => $borrowernumber,
546
                        branchcode      => $branchcode,
562
                        branchcode      => $branchcode,
547
                        items           => \@items,
563
                        items           => \@items,
Lines 553-559 END_SQL Link Here
553
                    }
569
                    }
554
                );
570
                );
555
                unless ($letter) {
571
                unless ($letter) {
556
                    $verbose and warn "Message '$overdue_rules->{letter$i}' content not found";
572
                    $verbose and warn "Message '$overdue_rules[$i]->{letter}' content not found";
557
573
558
                    # might as well skip while PERIOD, no other borrowers are going to work.
574
                    # might as well skip while PERIOD, no other borrowers are going to work.
559
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
575
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
(-)a/tools/overduerules.pl (-13 / +20 lines)
Lines 79-88 my %temphash; Link Here
79
my $input_saved = 0;
79
my $input_saved = 0;
80
if ($op eq 'save') {
80
if ($op eq 'save') {
81
    my @names=$input->param();
81
    my @names=$input->param();
82
    my $sth_search = $dbh->prepare("SELECT count(*) AS total FROM overduerules WHERE branchcode=? AND categorycode=?");
82
    my $sth_search = $dbh->prepare("SELECT count(*) AS total FROM overduerules WHERE branchcode=? AND categorycode=? AND typecode = '1'");
83
83
84
    my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
84
    my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay,letter,debarred, typecode) VALUES (?,?,?,?,?,'1'),(?,?,?,?,?,'2'),(?,?,?,?,?,'3')");
85
    my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, delay2=?, letter2=?, debarred2=?, delay3=?, letter3=?, debarred3=? WHERE branchcode=? AND categorycode=?");
85
    my $sth_update=$dbh->prepare("UPDATE overduerules SET delay=?, letter=?, debarred=? WHERE branchcode=? AND categorycode=? AND typecode=?");
86
    my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?");
86
    my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?");
87
    foreach my $key (@names){
87
    foreach my $key (@names){
88
            # ISSUES
88
            # ISSUES
Lines 145-166 if ($op eq 'save') { Link Here
145
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef),
145
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef),
146
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
146
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
147
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
147
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
148
                            $branch ,$bor, '1'
149
                            );
150
                        $sth_update->execute(
148
                            ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:undef),
151
                            ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:undef),
149
                            ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""),
152
                            ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""),
150
                            ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0),
153
                            ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0),
154
                            $branch ,$bor, '2'
155
                            );
156
                        $sth_update->execute(
151
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef),
157
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef),
152
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
158
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
153
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0),
159
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0),
154
                            $branch ,$bor
160
                            $branch ,$bor, '3'
155
                            );
161
                            );
156
                    } else {
162
                    } else {
157
                        $sth_insert->execute($branch,$bor,
163
                        $sth_insert->execute($branch,$bor,
158
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0),
164
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0),
159
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
165
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
160
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
166
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
167
                            $branch,$bor,
161
                            ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0),
168
                            ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0),
162
                            ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""),
169
                            ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""),
163
                            ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0),
170
                            ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0),
171
                            $branch,$bor,
164
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0),
172
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0),
165
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
173
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
166
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0)
174
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0)
Lines 220-234 for my $data (@categories) { Link Here
220
        }
228
        }
221
    } else {
229
    } else {
222
    #getting values from table
230
    #getting values from table
223
        my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? AND categorycode=?");
231
        my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? AND categorycode=? AND typecode=?");
224
        $sth2->execute($branch,$data->{'categorycode'});
232
       foreach my $i (1,2,3) {
225
        my $dat=$sth2->fetchrow_hashref;
233
            $sth2->execute($branch,$data->{'categorycode'},$i);
226
        for (my $i=1;$i<=3;$i++){
234
            my $dat=$sth2->fetchrow_hashref;
227
            if ($countletters){
235
            if ($countletters){
228
                my @letterloop;
236
                my @letterloop;
229
                foreach my $thisletter (sort { $letters->{$a} cmp $letters->{$b} } keys %$letters) {
237
                foreach my $thisletter (sort { $letters->{$a} cmp $letters->{$b} } keys %$letters) {
230
                    my $selected;
238
                    my $selected;
231
                    if ($dat->{"letter$i"} && $thisletter eq $dat->{"letter$i"}) {
239
                    if ($dat->{"letter"} && $thisletter eq $dat->{"letter"}) {
232
                        $selected = 1;
240
                        $selected = 1;
233
                    }
241
                    }
234
                    my %letterrow =(value => $thisletter,
242
                    my %letterrow =(value => $thisletter,
Lines 240-249 for my $data (@categories) { Link Here
240
                $row{"letterloop$i"}=\@letterloop;
248
                $row{"letterloop$i"}=\@letterloop;
241
            } else {
249
            } else {
242
                $row{"noletter"}=1;
250
                $row{"noletter"}=1;
243
                if ($dat->{"letter$i"}){$row{"letter$i"}=$dat->{"letter$i"};}
251
                if ($dat->{"letter"}){$row{"letter$i"}=$dat->{"letter"};}
244
            }
252
            }
245
            if ($dat->{"delay$i"}){$row{"delay$i"}=$dat->{"delay$i"};}
253
            if ($dat->{"delay"}){$row{"delay$i"}=$dat->{"delay"};}
246
            if ($dat->{"debarred$i"}){$row{"debarred$i"}=$dat->{"debarred$i"};}
254
            if ($dat->{"debarred"}){$row{"debarred$i"}=$dat->{"debarred"};}
247
        }
255
        }
248
    }
256
    }
249
    push @line_loop,\%row;
257
    push @line_loop,\%row;
250
- 

Return to bug 9296