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

(-)a/admin/currency.pl (+23 lines)
Lines 169-174 sub add_form { Link Here
169
        }
169
        }
170
    }
170
    }
171
171
172
    my $dbh   = C4::Context->dbh;
173
    my $query = "
174
        SELECT currency,timestamp,rate
175
        FROM   ex_rates where currency=?;
176
    ";
177
    my $sth = $dbh->prepare($query);
178
    $sth->execute($curr);
179
    my @results = ();
180
    while ( my $data = $sth->fetchrow_hashref ) {
181
        push( @results, $data );
182
    }
183
       $template->param(
184
        ex_result           => \@results,
185
    );
186
172
    return;
187
    return;
173
}
188
}
174
189
Lines 183-188 sub add_validate { Link Here
183
        currency => $input->param('currency'),
198
        currency => $input->param('currency'),
184
    };
199
    };
185
200
201
    $dbh->do(
202
q|INSERT INTO ex_rates (currency, rate, timestamp) VALUES (?,?,now()) |,
203
         {},
204
         $rec->{currency},
205
         $rec->{rate}
206
     );
207
186
    if ( $rec->{active} == 1 ) {
208
    if ( $rec->{active} == 1 ) {
187
        $dbh->do('UPDATE currency SET active = 0');
209
        $dbh->do('UPDATE currency SET active = 0');
188
    }
210
    }
Lines 200-205 q|UPDATE currency SET rate = ?, symbol = ?, isocode = ?, active = ? WHERE curren Link Here
200
            $rec->{active},
222
            $rec->{active},
201
            $rec->{currency}
223
            $rec->{currency}
202
        );
224
        );
225
203
    } else {
226
    } else {
204
        $dbh->do(
227
        $dbh->do(
205
q|INSERT INTO currency (currency, rate, symbol, isocode, active) VALUES (?,?,?,?,?) |,
228
q|INSERT INTO currency (currency, rate, symbol, isocode, active) VALUES (?,?,?,?,?) |,
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 10425-10430 if ( CheckVersion($DBversion) ) { Link Here
10425
    SetVersion ($DBversion);
10425
    SetVersion ($DBversion);
10426
}
10426
}
10427
10427
10428
$DBversion = "3.19.00.XXX";
10429
if ( CheckVersion($DBversion) ) {
10430
    $dbh->do("create table ex_rates(currency varchar(10) not null REFERENCES currency(currency) ON UPDATE CASCADE ON DELETE CASCADE,rate float(15,5) default null,timestamp timestamp not null,UNIQUE(currency,timestamp));");
10431
    print "Upgrade to $DBversion done (Insert currency details into ex_rates for exchage rate history)\n";
10432
    SetVersion ($DBversion);
10433
}
10434
10428
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10435
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10429
# SEE bug 13068
10436
# SEE bug 13068
10430
# if there is anything in the atomicupdate, read and execute it.
10437
# if there is anything in the atomicupdate, read and execute it.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt (-1 / +15 lines)
Lines 122-127 Link Here
122
    </fieldset>
122
    </fieldset>
123
    </form>
123
    </form>
124
124
125
    [% IF ( searchfield ) %]
126
        <h2>Exchange rates History [% searchfield %]  </h2>
127
        <table>
128
            <tr>
129
                <th>Date</th>
130
                <th>Rate</th>
131
            </tr>
132
            [% FOREACH loo IN ex_result %]
133
            <tr>
134
                <td>[% loo.timestamp %]</td>
135
                <td>[% loo.rate %]</td>
136
            </tr>
137
            [% END %]
138
        </table>
139
    [% END %]
125
[% END %]
140
[% END %]
126
141
127
[% IF ( delete_confirm ) %]
142
[% IF ( delete_confirm ) %]
128
- 

Return to bug 7571