51 $this->pobject_id = $a_pobject_id;
64 return $this->prices ? $this->prices : array();
68 return $this->prices[$a_price_id] ? $this->prices[$a_price_id] : array();
75 global
$ilDB, $ilSettings;
77 $res = $ilDB->queryf(
'
78 SELECT * FROM payment_prices
80 array(
'integer'), array($a_price_id));
82 while(
$row = $ilDB->fetchObject(
$res))
85 $price[
'unlimited_duration'] =
$row->unlimited_duration;
97 $res = $ilDB->queryf(
'
98 SELECT count(price_id) FROM payment_prices
99 WHERE pobject_id = %s',
101 array($a_pobject_id));
103 $row =
$res->fetchRow(DB_FETCHMODE_ARRAY);
110 include_once
'./payment/classes/class.ilPaymentCurrency.php';
125 include_once
'./payment/classes/class.ilGeneralSettings.php';
128 $currency_unit = $genSet->get(
'currency_unit');
130 return $a_price .
' ' . $currency_unit;
136 include_once
'./payment/classes/class.ilPaymentCurrency.php';
137 include_once
'./payment/classes/class.ilGeneralSettings.php';
142 $currency_unit = $genSet->get(
"currency_unit");
146 $pr_str = number_format($a_price , 2,
",",
".");
147 return $pr_str .
" " . $currency_unit;
154 include_once
'./payment/classes/class.ilPaymentPrices.php';
155 # include_once './payment/classes/class.ilPaymentCurrency.php';
156 include_once
'./payment/classes/class.ilGeneralSettings.php';
161 $currency_unit = $genSet->get(
"currency_unit");
165 if (is_array($a_price_ids))
167 for ($i = 0; $i < count($a_price_ids); $i++)
171 $price = (float) $price_data[
"price"];
172 $amount[$a_price_ids[$i][
"pay_method"]] += (float)
$price;
192 $this->price = preg_replace(
'/^0+/',
'',$a_price);
194 $this->price = $a_price;
199 $this->currency = $a_currency_id;
203 if($this->unlimited_duration ==
'1' && ($a_duration ==
'' || null))
206 $this->duration = (int)$a_duration;
211 if($a_unlimited_duration)
212 $this->unlimited_duration = (int)$a_unlimited_duration;
214 $this->unlimited_duration = 0;
219 $next_id = $this->db->nextId(
'payment_prices');
221 $res = $this->db->manipulateF(
'
222 INSERT INTO payment_prices
230 VALUES (%s, %s, %s, %s, %s, %s)',
232 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'float'),
247 $res = $this->db->manipulateF(
'
248 UPDATE payment_prices SET
251 unlimited_duration = %s,
253 WHERE price_id = %s',
255 array(
'integer',
'integer',
'integer',
'float',
'integer'),
267 function delete($a_price_id)
269 $statement = $this->db->manipulateF(
'
270 DELETE FROM payment_prices
271 WHERE price_id = %s',
272 array(
'integer'), array($a_price_id));
280 $statement = $this->db->manipulateF(
'
281 DELETE FROM payment_prices
282 WHERE pobject_id = %s',
294 $duration_valid =
false;
295 $price_valid =
false;
297 if(preg_match(
'/^(([1-9][0-9]{0,1})|[0])?$/',$this->
__getDuration())
300 $duration_valid =
true;
309 if($duration_valid ==
true && $price_valid ==
true)
323 $res = $ilDB->queryf(
'
324 SELECT * FROM payment_prices
326 AND pobject_id = %s',
327 array(
'integer',
'integer'),
328 array($a_price_id, $a_pobject_id));
330 return $res->numRows() ?
true :
false;
354 $this->prices = array();
356 $res = $this->db->queryf(
'
357 SELECT * FROM payment_prices
358 WHERE pobject_id = %s
364 while(
$row = $this->db->fetchObject(
$res))
366 $this->prices[
$row->price_id][
'pobject_id'] =
$row->pobject_id;
367 $this->prices[
$row->price_id][
'price_id'] =
$row->price_id;
368 $this->prices[
$row->price_id][
'currency'] =
$row->currency;
369 $this->prices[
$row->price_id][
'duration'] =
$row->duration;
370 $this->prices[
$row->price_id][
'unlimited_duration'] =
$row->unlimited_duration;
371 $this->prices[
$row->price_id][
'price'] =
$row->price;
377 return count($this->prices);
382 $lowest_price_id = 0;
385 foreach ($this->prices as $price_id =>
$data)
387 $current_price =
$data[
'price'];
389 if($lowest_price == 0||
390 $lowest_price > (
float)$current_price)
392 $lowest_price = (float)$current_price;
393 $lowest_price_id = $price_id;
397 return is_array($this->prices[$lowest_price_id]) ? $this->prices[$lowest_price_id] : array();