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

(-)a/tools/overduerules.pl (-5 / +14 lines)
Lines 36-42 my @categories = @{$dbh->selectall_arrayref( Link Here
36
    { Slice => {} }
36
    { Slice => {} }
37
)};
37
)};
38
my @category_codes  = map { $_->{categorycode} } @categories;
38
my @category_codes  = map { $_->{categorycode} } @categories;
39
our @rule_params     = qw(delay letter debarred);
39
our @rule_params     = qw(delay letter debarred invoice);
40
40
41
# blank_row($category_code) - return true if the entire row is blank.
41
# blank_row($category_code) - return true if the entire row is blank.
42
sub blank_row {
42
sub blank_row {
Lines 81-92 if ($op eq 'save') { Link Here
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=?");
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, delay1,letter1,debarred1,invoice1, delay2,letter2,debarred2,invoice2, delay3,letter3,debarred3,invoice3) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
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 delay1=?, letter1=?, debarred1=?, invoice1=?, delay2=?, letter2=?, debarred2=?, invoice2=?, delay3=?, letter3=?, debarred3=?, invoice3=? WHERE branchcode=? AND categorycode=?");
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
89
            if ($key =~ /(delay|letter|debarred)([1-3])-(.*)/) {
89
            if ($key =~ /(delay|letter|debarred|invoice)([1-3])-(.*)/) {
90
                    my $type = $1; # data type
90
                    my $type = $1; # data type
91
                    my $num = $2; # From 1 to 3
91
                    my $num = $2; # From 1 to 3
92
                    my $bor = $3; # borrower category
92
                    my $bor = $3; # borrower category
Lines 100-105 if ($op eq 'save') { Link Here
100
            }
100
            }
101
    }
101
    }
102
102
103
warn "requete: ".$sth_insert;
104
103
    # figure out which rows need to be deleted
105
    # figure out which rows need to be deleted
104
    my @rows_to_delete = grep { blank_row($_) } @category_codes;
106
    my @rows_to_delete = grep { blank_row($_) } @category_codes;
105
107
Lines 145-156 if ($op eq 'save') { Link Here
145
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef),
147
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef),
146
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
148
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
147
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
149
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
150
                            ($temphash{$bor}->{"invoice1"}?$temphash{$bor}->{"invoice1"}:0),
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
                            ($temphash{$bor}->{"invoice2"}?$temphash{$bor}->{"invoice2"}:0),
151
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef),
155
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef),
152
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
156
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
153
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0),
157
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0),
158
                            ($temphash{$bor}->{"invoice3"}?$temphash{$bor}->{"invoice3"}:0),
154
                            $branch ,$bor
159
                            $branch ,$bor
155
                            );
160
                            );
156
                    } else {
161
                    } else {
Lines 158-169 if ($op eq 'save') { Link Here
158
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0),
163
                            ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0),
159
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
164
                            ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""),
160
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
165
                            ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0),
166
                            ($temphash{$bor}->{"invoice1"}?$temphash{$bor}->{"invoice1"}:0),
161
                            ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0),
167
                            ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0),
162
                            ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""),
168
                            ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""),
163
                            ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0),
169
                            ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0),
170
                            ($temphash{$bor}->{"invoice2"}?$temphash{$bor}->{"invoice2"}:0),
164
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0),
171
                            ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0),
165
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
172
                            ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""),
166
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0)
173
                            ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0),
174
                            ($temphash{$bor}->{"invoice3"}?$temphash{$bor}->{"invoice3"}:0)
167
                            );
175
                            );
168
                    }
176
                    }
169
                }
177
                }
Lines 244-249 for my $data (@categories) { Link Here
244
            }
252
            }
245
            if ($dat->{"delay$i"}){$row{"delay$i"}=$dat->{"delay$i"};}
253
            if ($dat->{"delay$i"}){$row{"delay$i"}=$dat->{"delay$i"};}
246
            if ($dat->{"debarred$i"}){$row{"debarred$i"}=$dat->{"debarred$i"};}
254
            if ($dat->{"debarred$i"}){$row{"debarred$i"}=$dat->{"debarred$i"};}
255
            if ($dat->{"invoice$i"}){$row{"invoice$i"}=$dat->{"invoice$i"};}
247
        }
256
        }
248
    }
257
    }
249
    push @line_loop,\%row;
258
    push @line_loop,\%row;

Return to bug 11092