2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 //---------------------------------------------------------------------------------------------
14 function update_currency($curr_abrev, $symbol, $currency, $country, $hundreds_name)
16 $sql = "UPDATE ".TB_PREF."currencies SET currency="
17 .db_escape($currency).", curr_symbol=".db_escape($symbol).",
18 country=".db_escape($country).", hundreds_name=".db_escape($hundreds_name)
19 ." WHERE curr_abrev = ".db_escape($curr_abrev);
21 db_query($sql, "could not update currency for $curr_abrev");
24 //---------------------------------------------------------------------------------------------
26 function add_currency($curr_abrev, $symbol, $currency, $country, $hundreds_name)
28 $sql = "INSERT INTO ".TB_PREF."currencies (curr_abrev, curr_symbol, currency, country, hundreds_name)
29 VALUES (".db_escape($curr_abrev).", ".db_escape($symbol).", "
30 .db_escape($currency).", ".db_escape($country).", ".db_escape($hundreds_name).")";
32 db_query($sql, "could not add currency for $curr_abrev");
35 //---------------------------------------------------------------------------------------------
37 function delete_currency($curr_code)
39 $sql="DELETE FROM ".TB_PREF."currencies WHERE curr_abrev=".db_escape($curr_code);
40 db_query($sql, "could not delete currency $curr_code");
42 $sql="DELETE FROM ".TB_PREF."exchange_rates WHERE curr_code='$curr_code'";
43 db_query($sql, "could not delete exchange rates for currency $curr_code");
46 //---------------------------------------------------------------------------------------------
48 function get_currency($curr_code)
50 $sql = "SELECT * FROM ".TB_PREF."currencies WHERE curr_abrev=".db_escape($curr_code);
51 $result = db_query($sql, "could not get currency $curr_code");
53 $row = db_fetch($result);
57 //---------------------------------------------------------------------------------------------
59 function get_currencies()
61 $sql = "SELECT * FROM ".TB_PREF."currencies";
62 return db_query($sql, "could not get currencies");
65 //---------------------------------------------------------------------------------------------