just reindenting
authorPaul POULAIN <paul@koha-fr.org>
Sun, 30 Sep 2007 20:22:32 +0000 (22:22 +0200)
committerChris Cormack <crc@liblime.com>
Sun, 30 Sep 2007 21:03:23 +0000 (16:03 -0500)
Signed-off-by: Chris Cormack <crc@liblime.com>
koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tmpl
tools/overduerules.pl

index c29ec7c..7d62f19 100644 (file)
 <div id="doc3" class="yui-t2">
    
    <div id="bd">
-       <div id="yui-main">
-       <div class="yui-b">
+    <div id="yui-main">
+    <div class="yui-b">
 
-       <h1>Defining <!-- TMPL_IF NAME="branch" -->overdue notice triggers for <!-- TMPL_VAR NAME="branch" --><!-- TMPL_ELSE -->default overdue notice trigers<!-- /TMPL_IF --></h1>
-       <div class="help">
-               <p>Define up to three notices below. Specify the 'Delay' (days after item is overdue), a Notice to send, and whether to change the
-               status of the patron to 'Debarred'</p>
-               <p>Note: you must specify the delay or the entry will be ignored. Delay is measured in days</p>
-       </div>
-               <form method="post" action="/cgi-bin/koha/tools/overduerules.pl">
-               <label for="branch">Select a library :</label>
-                       <select id="branch" name="branch">
-                               <option value="">Default</option>
-                       <!-- TMPL_LOOP NAME="branchloop" -->
-                               <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
-                               <!-- TMPL_ELSE -->
-                               <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
-                               <!-- /TMPL_IF --><!-- /TMPL_LOOP --></select>
-                       <input type="submit" value="Select" />
-               </form>
-               <!--TMPL_IF Name="ERROR"-->
-               <div class="error">
-               <h3>Data error</h3>
-                       <p>The following fields have a forbidden value. Correct them and press OK again :</p><ul>
-                       <!-- TMPL_IF NAME="ERRORDELAY" -->
-                               <li>Delay <!--TMPL_VAR Name="ERRORDELAY"--> for <!--TMPL_VAR Name="bor"--> patron category has some unexpected characters. There should be only numerical characters. </li>
-                       <!-- /TMPL_IF -->
-                       <!-- TMPL_IF NAME="ERRORORDER" -->
-                               <li>Delay1 should be less than Delay2 which should be less than Delay3 for <!--TMPL_VAR Name="bor"--> patron category </li>
-               <!-- /TMPL_IF -->
-                       </ul></div>
-               <!--/TMPL_IF -->
-               <form method="post" action="/cgi-bin/koha/tools/overduerules.pl">
-                       <input type="hidden" name="op" value="save" />
-                       
-                       <table>
-                       <caption>Notice triggers for overdues: <!--TMPL_IF Name="branch"--><!-- TMPL_VAR NAME="branch" --><!--TMPL_ELSE--> default library <!--/TMPL_IF-->              <!--TMPL_IF Name="datasaved"-->
-               <br /><h3 align="center">INPUT SAVED</h3>
-               <!--/TMPL_IF -->
-                       </caption>
-                       <tr>
-                               <th>&nbsp;</th><th colspan="3" scope="col">First</th><th colspan="3" scope="col">Second</th><th colspan="3" scope="col">Third</th>
-                       </tr>
-                       <tr>
-                               <th>&nbsp;</th><th scope="col">Delay</th><th scope="col">Notice</th><th scope="col">Debar</th><th scope="col">Delay</th><th scope="col">Notice</th><th scope="col">Debar</th><th scope="col">Delay</th><th scope="col">Notice</th><th scope="col">Debar</th>
-                       </tr>
-                       <!-- TMPL_LOOP NAME="table" -->
-                               <tr>
-                                       <th><!-- TMPL_VAR NAME="line" --></th>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-                                               <input name="delay1-<!-- TMPL_VAR NAME="overduename" -->" size="5" value="<!-- TMPL_VAR NAME="delay1" -->" />
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-                                               <!--TMPL_IF Name="noletter" --><input type="text" name="letter1-<!-- TMPL_VAR NAME="overduename" -->" value="<!--TMPL_VAR Name="letter1"-->" />
-                                               <!--TMPL_ELSE -->
-                                                       <select name="letter1-<!-- TMPL_VAR NAME="overduename" -->">
-                                                               <option value="">Default</option>
-                                                               <!-- TMPL_LOOP name="letterloop1" -->
-                                                                       <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="lettername" --></option>
-                               <!-- TMPL_ELSE -->
-                               <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="lettername" --></option>
-                               <!-- /TMPL_IF -->
-                                                               <!-- /TMPL_LOOP -->
-                                                       </select>
-                                               <!--/TMPL_IF -->
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-                                               <!-- TMPL_IF NAME="debarred1" --><input type="checkbox" name="debarred1-<!-- TMPL_VAR NAME="overduename" -->" checked="checked" value="1" />
-                                               <!-- TMPL_ELSE -->
-                                               <input type="checkbox" name="debarred1-<!-- TMPL_VAR NAME="overduename" -->" value="1" />
-                                               <!-- /TMPL_IF -->
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-                                               <input name="delay2-<!-- TMPL_VAR NAME="overduename" -->" size="5" value="<!-- TMPL_VAR NAME="delay2" -->" />
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-                                               <!--TMPL_IF Name="noletter" --><input type="text" name="letter2-<!-- TMPL_VAR NAME="overduename" -->" value="<!--TMPL_VAR Name="letter2"-->" />
-                                               <!--TMPL_ELSE -->
-                                                       <select name="letter2-<!-- TMPL_VAR NAME="overduename" -->">
-                                                               <option value="">Default</option>
-                                                               <!-- TMPL_LOOP name="letterloop2" -->
-                                                                       <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="lettername" --></option>
-                               <!-- TMPL_ELSE -->
-                               <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="lettername" --></option>
-                               <!-- /TMPL_IF -->
-                                                               <!-- /TMPL_LOOP -->
-                                                       </select>
-                                               <!--/TMPL_IF -->
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-<!-- TMPL_IF NAME="debarred2" -->
-                                               <input type="checkbox" name="debarred2-<!-- TMPL_VAR NAME="overduename" -->" checked="checked" value="1" />
-<!-- TMPL_ELSE -->
-                                               <input type="checkbox" name="debarred2-<!-- TMPL_VAR NAME="overduename" -->" value="1" />
-<!-- /TMPL_IF -->
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-                                               <input name="delay3-<!-- TMPL_VAR NAME="overduename" -->" size="5" value="<!-- TMPL_VAR NAME="delay3" -->" />
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF -->
-                                               <!--TMPL_IF Name="noletter" --><input type="text" name="letter3-<!-- TMPL_VAR NAME="overduename" -->" value="<!--TMPL_VAR Name="letter3"-->" />
-                                               <!--TMPL_ELSE -->
-                                                       <select name="letter3-<!-- TMPL_VAR NAME="overduename" -->">
-                                                               <option value="">Default</option>
-                                                               <!-- TMPL_LOOP name="letterloop3" -->
-                                                                       <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="lettername" --></option>
-                               <!-- TMPL_ELSE -->
-                               <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="lettername" --></option>
-                               <!-- /TMPL_IF -->
-                                                               <!-- /TMPL_LOOP -->
-                                                       </select>
-                                               <!--/TMPL_IF -->
-                                       </td>
-                                       <!-- TMPL_IF NAME="toggle" -->
-   <td class="highlight">
-<!-- TMPL_ELSE -->
-   <td>
-<!-- /TMPL_IF --><!-- TMPL_IF NAME="debarred3" -->
-                                               <input type="checkbox" name="debarred3-<!-- TMPL_VAR NAME="overduename" -->" checked="checked" value="1" />
-                                               <!-- TMPL_ELSE -->
-                                               <input type="checkbox" name="debarred3-<!-- TMPL_VAR NAME="overduename" -->" value="1" /><!-- /TMPL_IF -->
-                                       </td>
-                               </tr>
-                       <!-- /TMPL_LOOP -->
-                       </table>
-                       
-                       <input type="submit" value="Save Changes" />
-               </form>
-
-</div>
-</div>
-<div class="yui-b">
-<!-- TMPL_INCLUDE NAME="tools-menu.inc" -->
-</div>
+        <h1>Defining <!-- TMPL_IF NAME="branch" -->overdue actions for <!-- TMPL_VAR NAME="branch" --><!-- TMPL_ELSE -->default overdue actions<!-- /TMPL_IF --></h1>
+        <div class="help">
+            <p>Delay is the number of days after an issue is due before an action is triggered. </p>
+            <p>If you want Koha to trigger an action (send a letter or debar member), delay is needed.</p>
+            <p>Columns must be filled left to right: if the first column is blank, other columns will be ignored. </p>
+        </div>
+            <form method="post" action="/cgi-bin/koha/tools/overduerules.pl">
+            <label for="branch">Select a branch :</label>
+                <select id="branch" name="branch">
+                    <option value="">Default</option>
+                    <!-- TMPL_LOOP NAME="branchloop" -->
+                        <!-- TMPL_IF NAME="selected" -->
+                            <option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
+                        <!-- TMPL_ELSE -->
+                            <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
+                        <!-- /TMPL_IF -->
+                    <!-- /TMPL_LOOP -->
+                </select>
+                <input type="submit" value="Select" />
+            </form>
+            <!--TMPL_IF Name="ERROR"-->
+            <div class="error">
+                <h3>Data error</h3>
+                <p>The following fields have a forbidden value. Correct them and press OK again :</p>
+                <ul>
+                <!-- TMPL_IF NAME="ERRORDELAY" -->
+                    <li>Delay <!--TMPL_VAR Name="ERRORDELAY"--> for <!--TMPL_VAR Name="bor"--> borrower category has some unexpected characters. There should be only numerical characters. </li>
+                <!-- /TMPL_IF -->
+                <!-- TMPL_IF NAME="ERRORORDER" -->
+                    <li>Delay1 should be less than Delay2 which should be less than Delay3 for <!--TMPL_VAR Name="bor"--> borrower category </li>
+                <!-- /TMPL_IF -->
+                </ul>
+            </div>
+            <!--/TMPL_IF -->
+            <form method="post" action="/cgi-bin/koha/tools/overduerules.pl">
+                <input type="hidden" name="op" value="save" />
+                    
+                <table>
+                    <caption>Rules for overdue actions: <!--TMPL_IF Name="branch"--><!-- TMPL_VAR NAME="branch" --><!--TMPL_ELSE--> default branch <!--/TMPL_IF-->
+                    <!--TMPL_IF Name="datasaved"-->
+                        <br /><h3 align="center">INPUT SAVED</h3>
+                    <!--/TMPL_IF -->
+                    </caption>
+                    <tr>
+                        <th>&nbsp;</th><th colspan="3" scope="col">First</th><th colspan="3" scope="col">Second</th><th colspan="3" scope="col">Third</th>
+                    </tr>
+                    <tr>
+                        <th>&nbsp;</th><th scope="col">Delay</th><th scope="col">Letter</th><th scope="col">Debar</th><th scope="col">Delay</th><th scope="col">Letter</th><th scope="col">Debar</th><th scope="col">Delay</th><th scope="col">Letter</th><th scope="col">Debar</th>
+                    </tr>
+                    <!-- TMPL_LOOP NAME="table" -->
+                        <tr>
+                            <th><!-- TMPL_VAR NAME="line" --></th>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                                <input name="delay1-<!-- TMPL_VAR NAME="overduename" -->" size="5" value="<!-- TMPL_VAR NAME="delay1" -->" />
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                            <!--TMPL_IF Name="noletter" -->
+                                <input type="text" name="letter1-<!-- TMPL_VAR NAME="overduename" -->" value="<!--TMPL_VAR Name="letter1"-->" />
+                            <!--TMPL_ELSE -->
+                                <select name="letter1-<!-- TMPL_VAR NAME="overduename" -->">
+                                    <option value="">Default</option>
+                                    <!-- TMPL_LOOP name="letterloop1" -->
+                                        <!-- TMPL_IF NAME="selected" -->
+                                            <option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="lettername" --></option>
+                                        <!-- TMPL_ELSE -->
+                                            <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="lettername" --></option>
+                                        <!-- /TMPL_IF -->
+                                    <!-- /TMPL_LOOP -->
+                                </select>
+                            <!--/TMPL_IF -->
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                                <!-- TMPL_IF NAME="debarred1" -->
+                                    <input type="checkbox" name="debarred1-<!-- TMPL_VAR NAME="overduename" -->" checked="checked" value="1" />
+                                <!-- TMPL_ELSE -->
+                                    <input type="checkbox" name="debarred1-<!-- TMPL_VAR NAME="overduename" -->" value="1" />
+                                <!-- /TMPL_IF -->
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                                <input name="delay2-<!-- TMPL_VAR NAME="overduename" -->" size="5" value="<!-- TMPL_VAR NAME="delay2" -->" />
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                            <!--TMPL_IF Name="noletter" -->
+                                <input type="text" name="letter2-<!-- TMPL_VAR NAME="overduename" -->" value="<!--TMPL_VAR Name="letter2"-->" />
+                            <!--TMPL_ELSE -->
+                                <select name="letter2-<!-- TMPL_VAR NAME="overduename" -->">
+                                    <option value="">Default</option>
+                                        <!-- TMPL_LOOP name="letterloop2" -->
+                                            <!-- TMPL_IF NAME="selected" -->
+                                                <option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="lettername" --></option>
+                                            <!-- TMPL_ELSE -->
+                                                <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="lettername" --></option>
+                                            <!-- /TMPL_IF -->
+                                        <!-- /TMPL_LOOP -->
+                                </select>
+                            <!--/TMPL_IF -->
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                                <!-- TMPL_IF NAME="debarred2" -->
+                                    <input type="checkbox" name="debarred2-<!-- TMPL_VAR NAME="overduename" -->" checked="checked" value="1" />
+                                <!-- TMPL_ELSE -->
+                                    <input type="checkbox" name="debarred2-<!-- TMPL_VAR NAME="overduename" -->" value="1" />
+                                <!-- /TMPL_IF -->
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                                <input name="delay3-<!-- TMPL_VAR NAME="overduename" -->" size="5" value="<!-- TMPL_VAR NAME="delay3" -->" />
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                            <!--TMPL_IF Name="noletter" -->
+                                <input type="text" name="letter3-<!-- TMPL_VAR NAME="overduename" -->" value="<!--TMPL_VAR Name="letter3"-->" />
+                            <!--TMPL_ELSE -->
+                                <select name="letter3-<!-- TMPL_VAR NAME="overduename" -->">
+                                    <option value="">Default</option>
+                                    <!-- TMPL_LOOP name="letterloop3" -->
+                                        <!-- TMPL_IF NAME="selected" -->
+                                            <option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="lettername" --></option>
+                                        <!-- TMPL_ELSE -->
+                                            <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="lettername" --></option>
+                                        <!-- /TMPL_IF -->
+                                    <!-- /TMPL_LOOP -->
+                                </select>
+                            <!--/TMPL_IF -->
+                            </td>
+                            <!-- TMPL_IF NAME="toggle" -->
+                                <td class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <td>
+                            <!-- /TMPL_IF -->
+                                <!-- TMPL_IF NAME="debarred3" -->
+                                    <input type="checkbox" name="debarred3-<!-- TMPL_VAR NAME="overduename" -->" checked="checked" value="1" />
+                                <!-- TMPL_ELSE -->
+                                    <input type="checkbox" name="debarred3-<!-- TMPL_VAR NAME="overduename" -->" value="1" />
+                                <!-- /TMPL_IF -->
+                            </td>
+                        </tr>
+                    <!-- /TMPL_LOOP -->
+                </table>
+                <input type="submit" value="Save Changes" />
+            </form>
+    </div>
+    </div>
+    <div class="yui-b">
+        <!-- TMPL_INCLUDE NAME="tools-menu.inc" -->
+    </div>
 </div>
 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
index 5bdec70..6749a05 100755 (executable)
@@ -140,66 +140,66 @@ my @line_loop;
 my $toggle= 1;
 # my $i=0;
 while (my $data=$sth->fetchrow_hashref){
-       if ( $toggle eq 1 ) {
-               $toggle = 0;
-       } else {
-               $toggle = 1;
-       }
-       my %row = ( overduename => $data->{'categorycode'},
-                               toggle => $toggle,
-                               line => $data->{'description'}
-                               );
-       if (%temphash){
-               for (my $i=1;$i<=3;$i++){
-                       $row{"delay$i"}=$temphash{$data->{'categorycode'}}->{"delay$i"};
-                       $row{"debarred$i"}=$temphash{$data->{'categorycode'}}->{"debarred$i"};
-                       if ($countletters){
-                               my @letterloop;
-                               foreach my $thisletter (keys %$letters) {
-                                       my $selected = 1 if $thisletter eq $temphash{$data->{'categorycode'}}->{"letter$i"};
-                                       my %letterrow =(value => $thisletter,
-                                                               selected => $selected,
-                                                               lettername => $letters->{$thisletter},
-                                                       );
-                                       push @letterloop, \%letterrow;
-                               }
-                               $row{"letterloop$i"}=\@letterloop;
-                       } else {
-                               $row{"noletter"}=1;
-                               $row{"letter$i"}=$temphash{$data->{'categorycode'}}->{"letter$i"};
-                       }
-               }
-       } else {
-       #getting values from table
-               my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? and categorycode=?");
-               $sth2->execute($branch,$data->{'categorycode'});
-               my $dat=$sth2->fetchrow_hashref;
-               for (my $i=1;$i<=3;$i++){
-                       if ($countletters){
-                               my @letterloop;
-                               foreach my $thisletter (keys %$letters) {
-                                       my $selected = 1 if $thisletter eq $dat->{"letter$i"};
-                                       my %letterrow =(value => $thisletter,
-                                                               selected => $selected,
-                                                               lettername => $letters->{$thisletter},
-                                                       );
-                                       push @letterloop, \%letterrow;
-                               }
-                               $row{"letterloop$i"}=\@letterloop;
-                       } else {
-                               $row{"noletter"}=1;
-                               if ($dat->{"letter$i"}){$row{"letter$i"}=$dat->{"letter$i"};}
-                       }
-                       if ($dat->{"delay$i"}){$row{"delay$i"}=$dat->{"delay$i"};}
-                       if ($dat->{"debarred$i"}){$row{"debarred$i"}=$dat->{"debarred$i"};}
-               }
-               $sth2->finish;
-       }
-       push @line_loop,\%row;
+    if ( $toggle eq 1 ) {
+        $toggle = 0;
+    } else {
+        $toggle = 1;
+    }
+    my %row = ( overduename => $data->{'categorycode'},
+                toggle => $toggle,
+                line => $data->{'description'}
+                );
+    if (%temphash){
+        for (my $i=1;$i<=3;$i++){
+            $row{"delay$i"}=$temphash{$data->{'categorycode'}}->{"delay$i"};
+            $row{"debarred$i"}=$temphash{$data->{'categorycode'}}->{"debarred$i"};
+            if ($countletters){
+                my @letterloop;
+                foreach my $thisletter (keys %$letters) {
+                    my $selected = 1 if $thisletter eq $temphash{$data->{'categorycode'}}->{"letter$i"};
+                    my %letterrow =(value => $thisletter,
+                                    selected => $selected,
+                                    lettername => $letters->{$thisletter},
+                                    );
+                    push @letterloop, \%letterrow;
+                }
+                $row{"letterloop$i"}=\@letterloop;
+            } else {
+                $row{"noletter"}=1;
+                $row{"letter$i"}=$temphash{$data->{'categorycode'}}->{"letter$i"};
+            }
+        }
+    } else {
+    #getting values from table
+        my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? and categorycode=?");
+        $sth2->execute($branch,$data->{'categorycode'});
+        my $dat=$sth2->fetchrow_hashref;
+        for (my $i=1;$i<=3;$i++){
+            if ($countletters){
+                my @letterloop;
+                foreach my $thisletter (keys %$letters) {
+                    my $selected = 1 if $thisletter eq $dat->{"letter$i"};
+                    my %letterrow =(value => $thisletter,
+                                    selected => $selected,
+                                    lettername => $letters->{$thisletter},
+                                    );
+                    push @letterloop, \%letterrow;
+                }
+                $row{"letterloop$i"}=\@letterloop;
+            } else {
+                $row{"noletter"}=1;
+                if ($dat->{"letter$i"}){$row{"letter$i"}=$dat->{"letter$i"};}
+            }
+            if ($dat->{"delay$i"}){$row{"delay$i"}=$dat->{"delay$i"};}
+            if ($dat->{"debarred$i"}){$row{"debarred$i"}=$dat->{"debarred$i"};}
+        }
+        $sth2->finish;
+    }
+    push @line_loop,\%row;
 }
 $sth->finish;
 
 $template->param(table=> \@line_loop,
-                                               branchloop => \@branchloop,
-                                               branch => $branch);
+                branchloop => \@branchloop,
+                branch => $branch);
 output_html_with_http_headers $input, $cookie, $template->output;