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

(-)a/C4/Overdues.pm (-7 / +8 lines)
Lines 1006-1017 C<$categorycode> contains the borrower categorycode Link Here
1006
1006
1007
sub GetOverdueDelays {
1007
sub GetOverdueDelays {
1008
    my ($category) = @_;
1008
    my ($category) = @_;
1009
    my $query      = qq|SELECT delay1,delay2,delay3
1009
    my $query      = qq|SELECT delay
1010
                FROM overduerules
1010
                FROM overduerules
1011
                WHERE categorycode=?|;
1011
                WHERE categorycode=?
1012
                ORDER BY typecode ASC|;
1012
    my $sth = C4::Context->dbh->prepare($query);
1013
    my $sth = C4::Context->dbh->prepare($query);
1013
    $sth->execute($category);
1014
    $sth->execute($category);
1014
    my (@delays) = $sth->fetchrow_array;
1015
    my (@delays) = ($sth->fetchrow_array,$sth->fetchrow_array,$sth->fetchrow_array);
1015
    return (@delays);
1016
    return (@delays);
1016
}
1017
}
1017
1018
Lines 1025-1031 returns a list of branch codes for branches with overdue rules defined. Link Here
1025
1026
1026
sub GetBranchcodesWithOverdueRules {
1027
sub GetBranchcodesWithOverdueRules {
1027
    my $dbh               = C4::Context->dbh;
1028
    my $dbh               = C4::Context->dbh;
1028
    my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> '' ORDER BY branchcode");
1029
    my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay IS NOT NULL AND branchcode <> '' ORDER BY branchcode");
1029
    $rqoverduebranches->execute;
1030
    $rqoverduebranches->execute;
1030
    my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref };
1031
    my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref };
1031
    if (!$branches[0]) {
1032
    if (!$branches[0]) {
Lines 1086-1096 C<$notify_level> contains the notify level Link Here
1086
sub GetOverduerules {
1087
sub GetOverduerules {
1087
    my ( $category, $notify_level ) = @_;
1088
    my ( $category, $notify_level ) = @_;
1088
    my $dbh   = C4::Context->dbh;
1089
    my $dbh   = C4::Context->dbh;
1089
    my $query = qq|SELECT debarred$notify_level
1090
    my $query = qq|SELECT debarred
1090
                     FROM overduerules
1091
                     FROM overduerules
1091
                    WHERE categorycode=?|;
1092
                    WHERE categorycode=? AND typecode=?|;
1092
    my $sth = $dbh->prepare($query);
1093
    my $sth = $dbh->prepare($query);
1093
    $sth->execute($category);
1094
    $sth->execute($category,$notify_level);
1094
    my ($overduerules) = $sth->fetchrow;
1095
    my ($overduerules) = $sth->fetchrow;
1095
    return ($overduerules);
1096
    return ($overduerules);
1096
}
1097
}
(-)a/installer/data/mysql/kohastructure.sql (-10 / +6 lines)
Lines 1524-1541 CREATE TABLE `opac_news` ( -- data from the news tool Link Here
1524
1524
1525
DROP TABLE IF EXISTS `overduerules`;
1525
DROP TABLE IF EXISTS `overduerules`;
1526
CREATE TABLE `overduerules` ( -- overdue notice status and triggers
1526
CREATE TABLE `overduerules` ( -- overdue notice status and triggers
1527
  `overduerules_id` mediumint NOT NULL AUTO_INCREMENT,
1528
  `delay` int(4) default NULL, -- number of days after the item is overdue that this notice is sent
1529
  `letter` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent
1530
  `debarred` varchar(1) default 0, -- is the patron restricted when this notice is sent (1 for yes, 0 for no)
1531
  `typecode` varchar(10) NOT NULL default '1', -- 1 2 3 for first second third, may be extended later
1527
  `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)
1532
  `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)
1528
  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
1533
  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
1529
  `delay1` int(4) default NULL, -- number of days after the item is overdue that the first notice is sent
1534
  PRIMARY KEY (`overduerules_id`)
1530
  `letter1` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the first notice
1531
  `debarred1` varchar(1) default 0, -- is the patron restricted when the first notice is sent (1 for yes, 0 for no)
1532
  `delay2` int(4) default NULL, -- number of days after the item is overdue that the second notice is sent
1533
  `debarred2` varchar(1) default 0, -- is the patron restricted when the second notice is sent (1 for yes, 0 for no)
1534
  `letter2` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the second notice
1535
  `delay3` int(4) default NULL, -- number of days after the item is overdue that the third notice is sent
1536
  `letter3` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the third notice
1537
  `debarred3` int(1) default 0, -- is the patron restricted when the third notice is sent (1 for yes, 0 for no)
1538
  PRIMARY KEY  (`branchcode`,`categorycode`)
1539
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1535
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1540
1536
1541
--
1537
--
(-)a/installer/data/mysql/updatedatabase.pl (+24 lines)
Lines 6438-6443 if ( CheckVersion($DBversion) ) { Link Here
6438
}
6438
}
6439
6439
6440
6440
6441
6442
$DBversion = "3.09.00.XXX";
6443
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6444
    $dbh->do("ALTER TABLE overduerules RENAME TO old_overduerules");
6445
    $dbh->do("CREATE TABLE `overduerules` ( -- overdue notice status and triggers
6446
  `overduerules_id` mediumint NOT NULL AUTO_INCREMENT,
6447
  `delay` int(4) default NULL, -- number of days after the item is overdue that this notice is sent
6448
  `letter` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent
6449
  `debarred` varchar(1) default 0, -- is the patron restricted when this notice is sent (1 for yes, 0 for no)
6450
  `typecode` varchar(10) NOT NULL default '1', -- 1 2 3 for first second third, may be extended later
6451
  `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)
6452
  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
6453
  PRIMARY KEY (`overduerules_id`)
6454
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6455
");
6456
    $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");
6457
    $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");
6458
    $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");
6459
    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";
6460
    SetVersion($DBversion);
6461
}
6462
6463
6464
6441
=head1 FUNCTIONS
6465
=head1 FUNCTIONS
6442
6466
6443
=head2 TableExists($table)
6467
=head2 TableExists($table)
(-)a/misc/cronjobs/overdue_notices.pl (-17 / +33 lines)
Lines 409-444 SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, TO_DAYS($date)-TO_DAYS Link Here
409
    AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ?
409
    AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ?
410
END_SQL
410
END_SQL
411
411
412
    my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? ";
412
    my $query = "SELECT * FROM overduerules WHERE delay IS NOT NULL AND typecode = ? AND branchcode = ? ";
413
    $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
413
    $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
414
    $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
414
    $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
415
    
415
    
416
    my $rqoverduerules =  $dbh->prepare($query);
416
    my $rqoverduerules =  $dbh->prepare($query);
417
    $rqoverduerules->execute($branchcode, @myborcat, @myborcatout);
417
    $rqoverduerules->execute(1, $branchcode, @myborcat, @myborcatout);
418
        
419
    my $trqoverduerules =  $dbh->prepare($query);
420
    $trqoverduerules->execute(2, $branchcode, @myborcat, @myborcatout);
421
    
422
    my $ttrqoverduerules =  $dbh->prepare($query);
423
    $ttrqoverduerules->execute(3, $branchcode, @myborcat, @myborcatout);
418
    
424
    
419
    # We get default rules is there is no rule for this branch
425
    # We get default rules is there is no rule for this branch
420
    if($rqoverduerules->rows == 0){
426
    if($rqoverduerules->rows == 0){
421
        $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' ";
427
        $query = "SELECT * FROM overduerules WHERE delay IS NOT NULL AND typecode = ? AND branchcode = '' ";
422
        $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
428
        $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
423
        $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
429
        $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
424
        
430
        
425
        $rqoverduerules = $dbh->prepare($query);
431
        $rqoverduerules = $dbh->prepare($query);
426
        $rqoverduerules->execute(@myborcat, @myborcatout);
432
        $rqoverduerules->execute(1, @myborcat, @myborcatout);
433
        
434
        $trqoverduerules = $dbh->prepare($query);
435
        $trqoverduerules->execute(2, @myborcat, @myborcatout);
436
        
437
        $ttrqoverduerules = $dbh->prepare($query);
438
        $ttrqoverduerules->execute(3, @myborcat, @myborcatout);
427
    }
439
    }
428
440
429
    # my $outfile = 'overdues_' . ( $mybranch || $branchcode || 'default' );
441
    # my $outfile = 'overdues_' . ( $mybranch || $branchcode || 'default' );
430
    while ( my $overdue_rules = $rqoverduerules->fetchrow_hashref ) {
442
    my @overdue_rules;
443
    while ( $overdue_rules[1] = $rqoverduerules->fetchrow_hashref ) {
444
      $overdue_rules[2] = $trqoverduerules->fetchrow_hashref;
445
      $overdue_rules[3] = $ttrqoverduerules->fetchrow_hashref;
446
431
      PERIOD: foreach my $i ( 1 .. 3 ) {
447
      PERIOD: foreach my $i ( 1 .. 3 ) {
432
448
433
            $verbose and warn "branch '$branchcode', pass $i\n";
449
            $verbose and warn "branch '$branchcode', pass $i\n";
434
            my $mindays = $overdue_rules->{"delay$i"};    # the notice will be sent after mindays days (grace period)
450
            my $mindays = $overdue_rules[$i]->{"delay"};    # the notice will be sent after mindays days (grace period)
435
            my $maxdays = (
451
            my $maxdays = (
436
                  $overdue_rules->{ "delay" . ( $i + 1 ) }
452
                  $overdue_rules[$i+1]->{ "delay" }
437
                ? $overdue_rules->{ "delay" . ( $i + 1 ) } - 1
453
                ? $overdue_rules[$i+1]->{ "delay" } - 1
438
                : ($MAX)
454
                : ($MAX)
439
            );                                            # issues being more than maxdays late are managed somewhere else. (borrower probably suspended)
455
            );                                            # issues being more than maxdays late are managed somewhere else. (borrower probably suspended)
440
456
441
            if ( !$overdue_rules->{"letter$i"} ) {
457
            if ( !$overdue_rules[$i]->{"letter"} ) {
442
                $verbose and warn "No letter$i code for branch '$branchcode'";
458
                $verbose and warn "No letter$i code for branch '$branchcode'";
443
                next PERIOD;
459
                next PERIOD;
444
            }
460
            }
Lines 460-468 END_SQL Link Here
460
                $borrower_sql .= ' AND issues.branchcode=? ';
476
                $borrower_sql .= ' AND issues.branchcode=? ';
461
                push @borrower_parameters, $branchcode;
477
                push @borrower_parameters, $branchcode;
462
            }
478
            }
463
            if ( $overdue_rules->{categorycode} ) {
479
            if ( $overdue_rules[$i]->{categorycode} ) {
464
                $borrower_sql .= ' AND borrowers.categorycode=? ';
480
                $borrower_sql .= ' AND borrowers.categorycode=? ';
465
                push @borrower_parameters, $overdue_rules->{categorycode};
481
                push @borrower_parameters, $overdue_rules[$i]->{categorycode};
466
            }
482
            }
467
            $borrower_sql .= '  AND categories.overduenoticerequired=1 ';
483
            $borrower_sql .= '  AND categories.overduenoticerequired=1 ';
468
            if($triggered) {
484
            if($triggered) {
Lines 476-482 END_SQL Link Here
476
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
492
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
477
	        my $sth = $dbh->prepare($borrower_sql);
493
	        my $sth = $dbh->prepare($borrower_sql);
478
            $sth->execute(@borrower_parameters);
494
            $sth->execute(@borrower_parameters);
479
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows";
495
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules[$i]->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows";
480
496
481
            while ( my ( $borrowernumber, $firstname, $lastname,
497
            while ( my ( $borrowernumber, $firstname, $lastname,
482
                    $address1, $address2, $city, $postcode, $country, $email
498
                    $address1, $address2, $city, $postcode, $country, $email
Lines 499-515 END_SQL Link Here
499
                    }
515
                    }
500
                }
516
                }
501
517
502
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode );
518
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules[$i]->{"letter"}, $branchcode );
503
519
504
                unless ($letter) {
520
                unless ($letter) {
505
                    $verbose and warn "Message '$overdue_rules->{letter$i}' content not found";
521
                    $verbose and warn "Message '$overdue_rules[$i]->{letter}' content not found";
506
522
507
                    # might as well skip while PERIOD, no other borrowers are going to work.
523
                    # might as well skip while PERIOD, no other borrowers are going to work.
508
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
524
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
509
                    next PERIOD;
525
                    next PERIOD;
510
                }
526
                }
511
    
527
    
512
                if ( $overdue_rules->{"debarred$i"} ) {
528
                if ( $overdue_rules[$i]->{"debarred"} ) {
513
    
529
    
514
                    #action taken is debarring
530
                    #action taken is debarring
515
                    C4::Members::DebarMember($borrowernumber, '9999-12-31');
531
                    C4::Members::DebarMember($borrowernumber, '9999-12-31');
Lines 538-544 END_SQL Link Here
538
                $sth2->finish;
554
                $sth2->finish;
539
555
540
                $letter = parse_letter(
556
                $letter = parse_letter(
541
                    {   letter_code     => $overdue_rules->{"letter$i"},
557
                    {   letter_code     => $overdue_rules[$i]->{"letter"},
542
                        borrowernumber  => $borrowernumber,
558
                        borrowernumber  => $borrowernumber,
543
                        branchcode      => $branchcode,
559
                        branchcode      => $branchcode,
544
                        items           => \@items,
560
                        items           => \@items,
Lines 550-556 END_SQL Link Here
550
                    }
566
                    }
551
                );
567
                );
552
                unless ($letter) {
568
                unless ($letter) {
553
                    $verbose and warn "Message '$overdue_rules->{letter$i}' content not found";
569
                    $verbose and warn "Message '$overdue_rules[$i]->{letter}' content not found";
554
570
555
                    # might as well skip while PERIOD, no other borrowers are going to work.
571
                    # might as well skip while PERIOD, no other borrowers are going to work.
556
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
572
                    # 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