ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilPaymentCurrency Class Reference
+ Collaboration diagram for ilPaymentCurrency:

Public Member Functions

 ilPaymentCurrency ($a_currency_id='')
 
 setCurrencyId ($a_currency_id)
 
 getCurrencyId ()
 
 setUnit ($a_unit)
 
 getUnit ()
 
 setIsoCode ($a_iso_code)
 
 getIsoCode ()
 
 setSymbol ($a_symbol)
 
 getSymbol ()
 
 setConversionRate ($a_conversion_rate)
 
 getConversionRate ()
 
 addCurrency ()
 
 deleteCurrency ()
 
 updateCurrency ()
 

Static Public Member Functions

static _getAvailableCurrencies ()
 
static _getCurrency ($a_currency_id)
 
static _getUnit ($a_currency_id)
 
static _getSymbol ($a_currency_id)
 
static _getConversionRate ($a_currency_id)
 
static _getCurrencyBySymbol ($a_currency_symbol)
 
static _getDefaultCurrency ()
 
static _updateIsDefault ($a_currency_id)
 
static _getDecimalSeparator ()
 
static _formatPriceToString ($a_price, $a_currency_symbol=false)
 
static _isDefault ($a_currency_id)
 

Private Attributes

 $currency_id
 
 $unit
 
 $iso_code
 
 $symbol
 
 $conversion_rate
 

Detailed Description

Definition at line 15 of file class.ilPaymentCurrency.php.

Member Function Documentation

◆ _formatPriceToString()

static ilPaymentCurrency::_formatPriceToString (   $a_price,
  $a_currency_symbol = false 
)
static

Definition at line 254 of file class.ilPaymentCurrency.php.

References $_SESSION, $separator, and _getDecimalSeparator().

255  {
256  if(!$a_currency_symbol)
257  {
258  $currency_obj = $_SESSION['payment_currency'];
259  $currency_symbol = $currency_obj['symbol'];
260  }
261  else $currency_symbol = $a_currency_symbol;
263 
264  $price_string = number_format($a_price,'2',$separator,'');
265 
266  return $price_string . ' ' . $currency_symbol;
267  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
$separator
+ Here is the call graph for this function:

◆ _getAvailableCurrencies()

static ilPaymentCurrency::_getAvailableCurrencies ( )
static

Definition at line 109 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

Referenced by ilObjPaymentSettingsGUI\currenciesObject(), and ilPaymentObjectGUI\performAddPrice().

110  {
111  global $ilDB;
112 
113  $res = $ilDB->query('SELECT * FROM payment_currencies');
114 
115 
116  while($row = $ilDB->fetchAssoc($res))
117  {
118  $currencies[$row['currency_id']] = $row;
119 /* $currencies[$row->currency_id]['currency_id'] = $row->currency_id;
120  $currencies[$row->currency_id]['unit'] = $row->unit;
121  $currencies[$row->currency_id]['iso_code'] = $row->subunit;
122  */
123  }
124  return $currencies ? $currencies : array();
125  }
global $ilDB
+ Here is the caller graph for this function:

◆ _getConversionRate()

static ilPaymentCurrency::_getConversionRate (   $a_currency_id)
static

Definition at line 179 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

180  {
181  global $ilDB;
182 
183  $res = $ilDB->queryF('
184  SELECT conversion_rate FROM payment_currencies WHERE currency_id = %s',
185  array('integer'), array($a_currency_id));
186 
187  while($row = $ilDB->fetchObject($res))
188  {
189  return (float)$row->conversion_rate;
190  }
191  return false;
192  }
global $ilDB

◆ _getCurrency()

static ilPaymentCurrency::_getCurrency (   $a_currency_id)
static

Definition at line 127 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

Referenced by ilObjPaymentSettingsGUI\editCurrencyObject().

128  {
129  global $ilDB;
130 
131  $res = $ilDB->queryf('
132  SELECT * FROM payment_currencies WHERE currency_id = %s',
133  array('integer'), array($a_currency_id));
134 
135 
136  while($row = $ilDB->fetchAssoc($res))
137  {
138  $currencies[$row['currency_id']] = $row;
139 
140  /* while($row = $ilDB->fetchObject($res))
141  {
142  $currencies['currency_id'] = $row->currency_id;
143  $currencies['unit'] = $row->unit;
144  $currencies['subunit'] = $row->subunit;*/
145  }
146  return $currencies;
147  }
global $ilDB
+ Here is the caller graph for this function:

◆ _getCurrencyBySymbol()

static ilPaymentCurrency::_getCurrencyBySymbol (   $a_currency_symbol)
static

Definition at line 193 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

194  {
195  global $ilDB;
196 
197  $res = $ilDB->queryF('SELECT * FROM payment_currencies WHERE symbol = %s',
198  array('text'), array($a_currency_symbol));
199  $row = $ilDB->fetchAssoc($res);
200 
201  return $row;
202  }
global $ilDB

◆ _getDecimalSeparator()

static ilPaymentCurrency::_getDecimalSeparator ( )
static

Definition at line 237 of file class.ilPaymentCurrency.php.

References $ilUser, and $separator.

Referenced by _formatPriceToString().

238  {
239  global $ilUser;
240 
241  $user_lang = $ilUser->getLanguage();
242 
243  // look for ISO 639-1
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');
248 
249  in_array($user_lang, $comma_countries) ? $separator = ',' : $separator = '.';
250 
251  return $separator;
252  }
$separator
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ _getDefaultCurrency()

static ilPaymentCurrency::_getDefaultCurrency ( )
static

Definition at line 204 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

205  {
206  global $ilDB;
207 
208  $res = $ilDB->query('SELECT * FROM payment_currencies WHERE is_default = 1');
209  $row = $ilDB->fetchAssoc($res);
210 
211  return $row;
212  }
global $ilDB

◆ _getSymbol()

static ilPaymentCurrency::_getSymbol (   $a_currency_id)
static

Definition at line 164 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

165  {
166  global $ilDB;
167 
168  $res = $ilDB->queryf('
169  SELECT symbol FROM payment_currencies WHERE currency_id = %s',
170  array('integer'), array($a_currency_id));
171 
172  while($row = $ilDB->fetchObject($res))
173  {
174  return $row->symbol;
175  }
176  return false;
177  }
global $ilDB

◆ _getUnit()

static ilPaymentCurrency::_getUnit (   $a_currency_id)
static

Definition at line 149 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

Referenced by ilObjPaymentSettingsGUI\deleteCurrencyObject().

150  {
151  global $ilDB;
152 
153  $res = $ilDB->queryf('
154  SELECT unit FROM payment_currencies WHERE currency_id = %s',
155  array('integer'), array($a_currency_id));
156 
157  while($row = $ilDB->fetchObject($res))
158  {
159  return $row->unit;
160  }
161  return false;
162  }
global $ilDB
+ Here is the caller graph for this function:

◆ _isDefault()

static ilPaymentCurrency::_isDefault (   $a_currency_id)
static

Definition at line 269 of file class.ilPaymentCurrency.php.

References $ilDB, $res, and $row.

Referenced by ilObjPaymentSettingsGUI\deleteCurrencyObject().

270  {
271  global $ilDB;
272 
273  $res = $ilDB->queryF('SELECT is_default FROM payment_currencies WHERE currency_id = %s',
274  array('integer'), array((int)$a_currency_id));
275 
276  $row = $ilDB->fetchAssoc($res);
277 
278  if($row['is_default'] == '1') {
279  return true;
280  }else
281  return false;
282 
283  }
global $ilDB
+ Here is the caller graph for this function:

◆ _updateIsDefault()

static ilPaymentCurrency::_updateIsDefault (   $a_currency_id)
static

Definition at line 214 of file class.ilPaymentCurrency.php.

References $conversion_rate, and $ilDB.

Referenced by ilObjPaymentSettingsGUI\updateDefaultCurrencyObject().

215  {
216  global $ilDB;
217 
218  // calculate other currencies to default_currency
219  $conversion_rate = self::_getConversionRate($a_currency_id);
220  $currencies = self::_getAvailableCurrencies();
221 
222  foreach ($currencies as $tmp_cur)
223  {
224  //calculate conversion rates
225  $con_result = round((float)$tmp_cur['conversion_rate'] / (float)$conversion_rate, 4);
226 
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'])));
231  }
232  $new_default = $ilDB->update('payment_currencies',
233  array( 'is_default' => array('integer', 1)),
234  array('currency_id' => array('integer', $a_currency_id)));
235  }
global $ilDB
+ Here is the caller graph for this function:

◆ addCurrency()

ilPaymentCurrency::addCurrency ( )

Definition at line 78 of file class.ilPaymentCurrency.php.

References getConversionRate(), getIsoCode(), getSymbol(), and getUnit().

79  {
80  $nextId = $this->db->nextID('payment_currencies');
81 
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'),
86  array($nextId, $this->getUnit(), $this->getIsoCode(), $this->getSymbol(), $this->getConversionRate()));
87  return true;
88  }
+ Here is the call graph for this function:

◆ deleteCurrency()

ilPaymentCurrency::deleteCurrency ( )

Definition at line 90 of file class.ilPaymentCurrency.php.

References getCurrencyId().

91  {
92  $this->db->manipulateF('DELETE FROM payment_currencies WHERE currency_id = %s',
93  array('integer'), array($this->getCurrencyId()));
94 
95  }
+ Here is the call graph for this function:

◆ getConversionRate()

ilPaymentCurrency::getConversionRate ( )

Definition at line 73 of file class.ilPaymentCurrency.php.

References $conversion_rate.

Referenced by addCurrency(), and updateCurrency().

+ Here is the caller graph for this function:

◆ getCurrencyId()

ilPaymentCurrency::getCurrencyId ( )

Definition at line 39 of file class.ilPaymentCurrency.php.

References $currency_id.

Referenced by deleteCurrency(), and updateCurrency().

40  {
41  return $this->currency_id;
42  }
+ Here is the caller graph for this function:

◆ getIsoCode()

ilPaymentCurrency::getIsoCode ( )

Definition at line 56 of file class.ilPaymentCurrency.php.

References $iso_code.

Referenced by addCurrency(), and updateCurrency().

57  {
58  return $this->iso_code;
59  }
+ Here is the caller graph for this function:

◆ getSymbol()

ilPaymentCurrency::getSymbol ( )

Definition at line 65 of file class.ilPaymentCurrency.php.

References $symbol.

Referenced by addCurrency(), and updateCurrency().

66  {
67  return $this->symbol;
68  }
+ Here is the caller graph for this function:

◆ getUnit()

ilPaymentCurrency::getUnit ( )

Definition at line 48 of file class.ilPaymentCurrency.php.

References $unit.

Referenced by addCurrency(), and updateCurrency().

49  {
50  return $this->unit;
51  }
+ Here is the caller graph for this function:

◆ ilPaymentCurrency()

ilPaymentCurrency::ilPaymentCurrency (   $a_currency_id = '')

Definition at line 24 of file class.ilPaymentCurrency.php.

References $ilDB.

25  {
26  global $ilDB;
27 
28  $this->db = $ilDB;
29 
30  $this->currency_id = $a_currency_id;
31 
32  }
global $ilDB

◆ setConversionRate()

ilPaymentCurrency::setConversionRate (   $a_conversion_rate)

Definition at line 69 of file class.ilPaymentCurrency.php.

70  {
71  $this->conversion_rate = (float)$a_conversion_rate;
72  }

◆ setCurrencyId()

ilPaymentCurrency::setCurrencyId (   $a_currency_id)

Definition at line 35 of file class.ilPaymentCurrency.php.

36  {
37  $this->currency_id = $a_currency_id;
38  }

◆ setIsoCode()

ilPaymentCurrency::setIsoCode (   $a_iso_code)

Definition at line 52 of file class.ilPaymentCurrency.php.

53  {
54  $this->iso_code = $a_iso_code;
55  }

◆ setSymbol()

ilPaymentCurrency::setSymbol (   $a_symbol)

Definition at line 61 of file class.ilPaymentCurrency.php.

62  {
63  $this->symbol = $a_symbol;
64  }

◆ setUnit()

ilPaymentCurrency::setUnit (   $a_unit)

Definition at line 44 of file class.ilPaymentCurrency.php.

45  {
46  $this->unit = $a_unit;
47  }

◆ updateCurrency()

ilPaymentCurrency::updateCurrency ( )

Definition at line 96 of file class.ilPaymentCurrency.php.

References getConversionRate(), getCurrencyId(), getIsoCode(), getSymbol(), and getUnit().

97  {
98  $this->db->manipulateF('UPDATE payment_currencies
99  SET unit = %s,
100  iso_code = %s,
101  symbol = %s,
102  conversion_rate = %s
103  WHERE currency_id = %s',
104  array('text','text','text','float','integer'),
105  array($this->getUnit(), $this->getIsoCode(), $this->getSymbol(),
106  $this->getConversionRate(), $this->getCurrencyId()));
107  }
+ Here is the call graph for this function:

Field Documentation

◆ $conversion_rate

ilPaymentCurrency::$conversion_rate
private

Definition at line 22 of file class.ilPaymentCurrency.php.

Referenced by _updateIsDefault(), and getConversionRate().

◆ $currency_id

ilPaymentCurrency::$currency_id
private

Definition at line 18 of file class.ilPaymentCurrency.php.

Referenced by getCurrencyId().

◆ $iso_code

ilPaymentCurrency::$iso_code
private

Definition at line 20 of file class.ilPaymentCurrency.php.

Referenced by getIsoCode().

◆ $symbol

ilPaymentCurrency::$symbol
private

Definition at line 21 of file class.ilPaymentCurrency.php.

Referenced by getSymbol().

◆ $unit

ilPaymentCurrency::$unit
private

Definition at line 19 of file class.ilPaymentCurrency.php.

Referenced by getUnit().


The documentation for this class was generated from the following file: