34 $this->pobject_id = $a_pobject_id;
47 return $this->prices ? $this->prices : array();
51 return $this->prices[$a_price_id] ? $this->prices[$a_price_id] : array();
58 global
$ilDB, $ilSettings;
60 $res = $ilDB->queryf(
'
61 SELECT * FROM payment_prices
63 array(
'integer'), array($a_price_id));
65 while(
$row = $ilDB->fetchObject(
$res))
68 $price[
'unlimited_duration'] =
$row->unlimited_duration;
70 $price[
'price'] = number_format(
$row->price, 2,
'.',
'');
82 $res = $ilDB->queryf(
'
83 SELECT count(price_id) FROM payment_prices
84 WHERE pobject_id = %s',
86 array($a_pobject_id));
88 # $row = $res->fetchRow(DB_FETCHMODE_ARRAY);
107 $system_lng = $lng->getDefaultLanguage();
110 $use_comma_seperator = array(
'ar',
'bg',
'cs',
'de',
'da',
'es',
'et',
'it',
111 'fr',
'nl',
'el',
'sr',
'uk',
'ru',
'ro',
'tr',
'pl',
'lt',
'pt',
'sq',
'hu');
113 $use_point_separator = array(
'en',
'ja',
'zh',
'vi');
115 if(in_array($system_lng, $use_comma_seperator))
117 $gui_price = number_format((
float)$a_price, 2,
',',
'');
120 $gui_price = number_format((
float)$a_price, 2,
'.',
'');
127 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
130 $currency_unit = $genSet->get(
'currency_unit');
134 return $gui_price .
' ' . $currency_unit;
150 include_once
'./Services/Payment/classes/class.ilPaymentCurrency.php';
151 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
156 $currency_unit = $genSet->get(
"currency_unit");
160 $pr_str = number_format($a_price , 2,
",",
".");
165 return $pr_str .
" " . $currency_unit;
172 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
173 # include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
174 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
179 $currency_unit = $genSet->get(
"currency_unit");
183 if (is_array($a_price_ids))
185 for ($i = 0; $i < count($a_price_ids); $i++)
189 $price = (float) $price_data[
"price"];
190 $amount[$a_price_ids[$i][
"pay_method"]] += (float)
$price;
220 $this->price = preg_replace(
'/,/',
'.',$a_price);
221 $this->price = (float)$a_price;
226 $this->currency = $a_currency_id;
230 if($this->unlimited_duration ==
'1' && ($a_duration ==
'' || null))
233 $this->duration = (int)$a_duration;
238 if($a_unlimited_duration)
239 $this->unlimited_duration = (int)$a_unlimited_duration;
241 $this->unlimited_duration = 0;
247 if($this->extension ==
'1' && ($a_extension ==
'' || null))
249 $this->extension = $a_extension;
260 $next_id = $this->db->nextId(
'payment_prices');
262 $res = $this->db->insert(
'payment_prices', array(
263 'price_id' => array(
'integer', $next_id),
264 'pobject_id' => array(
'integer', $this->
getPobjectId()),
268 'price' => array(
'float', $this->
__getPrice()),
277 $this->db->update(
'payment_prices',
278 array(
'pobject_id' => array(
'integer', $this->
getPobjectId()),
282 'price' => array(
'float', $this->
__getPrice()),
283 'extension' => array(
'integer', $this->
getExtension())),
284 array(
'price_id'=> array(
'integer', $a_price_id)));
290 public function delete($a_price_id)
292 $statement = $this->db->manipulateF(
'
293 DELETE FROM payment_prices
294 WHERE price_id = %s',
295 array(
'integer'), array($a_price_id));
303 $statement = $this->db->manipulateF(
'
304 DELETE FROM payment_prices
305 WHERE pobject_id = %s',
317 $duration_valid =
false;
318 $price_valid =
false;
320 if(preg_match(
'/^(([1-9][0-9]{0,1})|[0])?$/',$this->
__getDuration())
323 $duration_valid =
true;
332 if($duration_valid ==
true && $price_valid ==
true)
345 $res = $ilDB->queryf(
'
346 SELECT * FROM payment_prices
348 AND pobject_id = %s',
349 array(
'integer',
'integer'),
350 array($a_price_id, $a_pobject_id));
352 return $res->numRows() ?
true :
false;
364 if($this->currency == null)
377 private function __read($with_extension_prices =
false)
379 $this->prices = array();
381 if(!$with_extension_prices)
383 $res = $this->db->queryf(
'
384 SELECT * FROM payment_prices
385 WHERE pobject_id = %s
388 array(
'integer',
'integer'),
394 $res = $this->db->queryf(
'
395 SELECT * FROM payment_prices
396 WHERE pobject_id = %s
402 while(
$row = $this->db->fetchObject(
$res))
404 $this->prices[
$row->price_id][
'pobject_id'] =
$row->pobject_id;
405 $this->prices[
$row->price_id][
'price_id'] =
$row->price_id;
406 $this->prices[
$row->price_id][
'currency'] =
$row->currency;
407 $this->prices[
$row->price_id][
'duration'] =
$row->duration;
408 $this->prices[
$row->price_id][
'unlimited_duration'] =
$row->unlimited_duration;
409 $this->prices[
$row->price_id][
'price'] =
$row->price;
410 $this->prices[
$row->price_id][
'extension'] =
$row->extension;
419 $res = $this->db->queryf(
'
420 SELECT * FROM payment_prices
421 WHERE pobject_id = %s
424 array(
'integer',
'integer'),
427 while(
$row = $this->db->fetchObject(
$res))
433 $prices[
$row->price_id][
'unlimited_duration'] =
$row->unlimited_duration;
442 return count($this->prices);
447 $lowest_price_id = 0;
450 foreach ($this->prices as $price_id =>
$data)
452 $current_price =
$data[
'price'];
454 if($lowest_price == 0||
455 $lowest_price > (
float)$current_price)
457 $lowest_price = (float)$current_price;
458 $lowest_price_id = $price_id;
462 return is_array($this->prices[$lowest_price_id]) ? $this->prices[$lowest_price_id] : array();