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

(-)a/admin/currency.pl (-1 / +24 lines)
Lines 156-162 sub delete_confirm { Link Here
156
    return;
156
    return;
157
}
157
}
158
158
159
sub add_form {
159
sub add_form {    
160
    my $curr = shift;
160
    my $curr = shift;
161
161
162
    $template->param( add_form => 1 );
162
    $template->param( add_form => 1 );
Lines 175-180 sub add_form { Link Here
175
        $template->param( 'timestamp' => format_date($date) );
175
        $template->param( 'timestamp' => format_date($date) );
176
    }
176
    }
177
177
178
    my $dbh   = C4::Context->dbh;
179
    my $query = "
180
        SELECT currency,timestamp,rate
181
        FROM   ex_rates where currency=?;
182
    ";
183
    my $sth = $dbh->prepare($query);
184
    $sth->execute($curr);
185
    my @results = ();
186
    while ( my $data = $sth->fetchrow_hashref ) {
187
        push( @results, $data );
188
    }
189
       $template->param(
190
        ex_result           => \@results,
191
    );
192
178
    return;
193
    return;
179
}
194
}
180
195
Lines 188-193 sub add_validate { Link Here
188
        currency => $input->param('currency'),
203
        currency => $input->param('currency'),
189
    };
204
    };
190
205
206
    $dbh->do(
207
q|INSERT INTO ex_rates (currency, rate, timestamp) VALUES (?,?,now()) |,
208
         {},
209
         $rec->{currency},
210
         $rec->{rate}
211
     ); 
212
191
    if ( $rec->{active} == 1 ) {
213
    if ( $rec->{active} == 1 ) {
192
        $dbh->do('UPDATE currency SET active = 0');
214
        $dbh->do('UPDATE currency SET active = 0');
193
    }
215
    }
Lines 204-209 q|UPDATE currency SET rate = ?, symbol = ?, active = ? WHERE currency = ? |, Link Here
204
            $rec->{active},
226
            $rec->{active},
205
            $rec->{currency}
227
            $rec->{currency}
206
        );
228
        );
229
207
    } else {
230
    } else {
208
        $dbh->do(
231
        $dbh->do(
209
q|INSERT INTO currency (currency, rate, symbol, active) VALUES (?,?,?,?) |,
232
q|INSERT INTO currency (currency, rate, symbol, active) VALUES (?,?,?,?) |,
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 5308-5313 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5308
    SetVersion ($DBversion);
5308
    SetVersion ($DBversion);
5309
}
5309
}
5310
5310
5311
$DBversion = "3.09.00.XXX";
5312
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5313
    $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));");
5314
    print "Upgrade to $DBversion done (Insert currency details into ex_rates for exchage rate history)\n";
5315
    SetVersion ($DBversion);
5316
}
5317
5311
=head1 FUNCTIONS
5318
=head1 FUNCTIONS
5312
5319
5313
=head2 TableExists($table)
5320
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt (-1 / +15 lines)
Lines 125-130 Link Here
125
    </fieldset>
125
    </fieldset>
126
    </form>
126
    </form>
127
127
128
    [% IF ( searchfield ) %]
129
        <h2>Exchange rates History [% searchfield %]  </h2>
130
        <table>
131
            <tr>
132
                <th>Date</th>
133
                <th>Rate</th>
134
            </tr>
135
            [% FOREACH loo IN ex_result %]
136
            <tr>
137
                <td>[% loo.timestamp %]</td>
138
                <td>[% loo.rate %]</td>
139
            </tr>
140
            [% END %]
141
        </table>
142
    [% END %]
128
[% END %]
143
[% END %]
129
144
130
[% IF ( delete_confirm ) %]
145
[% IF ( delete_confirm ) %]
131
- 

Return to bug 7571