30 $this->currency_id = $a_currency_id;
37 $this->currency_id = $a_currency_id;
46 $this->unit = $a_unit;
54 $this->iso_code = $a_iso_code;
63 $this->symbol = $a_symbol;
71 $this->conversion_rate = (float)$a_conversion_rate;
80 $nextId = $this->db->nextID(
'payment_currencies');
82 $this->db->manipulateF(
'INSERT INTO payment_currencies
83 (currency_id, unit, iso_code, symbol, conversion_rate)
84 VALUES (%s, %s, %s, %s, %s)',
85 array(
'integer',
'text',
'text',
'text',
'float'),
92 $this->db->manipulateF(
'DELETE FROM payment_currencies WHERE currency_id = %s',
98 $this->db->manipulateF(
'UPDATE payment_currencies
103 WHERE currency_id = %s',
104 array(
'text',
'text',
'text',
'float',
'integer'),
113 $res = $ilDB->query(
'SELECT * FROM payment_currencies');
116 while(
$row = $ilDB->fetchAssoc(
$res))
118 $currencies[
$row[
'currency_id']] =
$row;
124 return $currencies ? $currencies : array();
131 $res = $ilDB->queryf(
'
132 SELECT * FROM payment_currencies WHERE currency_id = %s',
133 array(
'integer'), array($a_currency_id));
136 while(
$row = $ilDB->fetchAssoc(
$res))
138 $currencies[
$row[
'currency_id']] =
$row;
153 $res = $ilDB->queryf(
'
154 SELECT unit FROM payment_currencies WHERE currency_id = %s',
155 array(
'integer'), array($a_currency_id));
157 while(
$row = $ilDB->fetchObject(
$res))
168 $res = $ilDB->queryf(
'
169 SELECT symbol FROM payment_currencies WHERE currency_id = %s',
170 array(
'integer'), array($a_currency_id));
172 while(
$row = $ilDB->fetchObject(
$res))
183 $res = $ilDB->queryF(
'
184 SELECT conversion_rate FROM payment_currencies WHERE currency_id = %s',
185 array(
'integer'), array($a_currency_id));
187 while(
$row = $ilDB->fetchObject(
$res))
189 return (
float)
$row->conversion_rate;
197 $res = $ilDB->queryF(
'SELECT * FROM payment_currencies WHERE symbol = %s',
198 array(
'text'), array($a_currency_symbol));
208 $res = $ilDB->query(
'SELECT * FROM payment_currencies WHERE is_default = 1');
222 foreach ($currencies as $tmp_cur)
225 $con_result = round((
float)$tmp_cur[
'conversion_rate'] / (
float)
$conversion_rate, 4);
227 $upd = $ilDB->update(
'payment_currencies',
228 array(
'conversion_rate' => array(
'float', $con_result),
229 'is_default' => array(
'integer', 0)),
230 array(
'currency_id' => array(
'integer', $tmp_cur[
'currency_id'])));
232 $new_default = $ilDB->update(
'payment_currencies',
233 array(
'is_default' => array(
'integer', 1)),
234 array(
'currency_id' => array(
'integer', $a_currency_id)));
241 $user_lang = $ilUser->getLanguage();
244 $comma_countries = array(
245 'sq',
'es',
'fr',
'pt',
'bg',
'de',
'da',
'et',
'fo',
'fi',
'el',
'id',
'is',
'it',
246 'hr',
'lv',
'lt',
'lb',
'mk',
'mo',
'nl',
'no',
'pl',
'pt',
'ro',
'ru',
'sv',
'sr',
247 'sk',
'sl',
'af',
'ce',
'cs',
'tr',
'uk',
'hu');
256 if(!$a_currency_symbol)
258 $currency_obj =
$_SESSION[
'payment_currency'];
259 $currency_symbol = $currency_obj[
'symbol'];
261 else $currency_symbol = $a_currency_symbol;
264 $price_string = number_format($a_price,
'2',
$separator,
'');
266 return $price_string .
' ' . $currency_symbol;
273 $res = $ilDB->queryF(
'SELECT is_default FROM payment_currencies WHERE currency_id = %s',
274 array(
'integer'), array((
int)$a_currency_id));
278 if(
$row[
'is_default'] ==
'1') {