33 $this->pobject_id = $a_pobject_id;
46 return $this->prices ? $this->prices : array();
50 return $this->prices[$a_price_id] ? $this->prices[$a_price_id] : array();
57 global
$ilDB, $ilSettings;
59 $res = $ilDB->queryf(
'
60 SELECT * FROM payment_prices
62 array(
'integer'), array($a_price_id));
64 while(
$row = $ilDB->fetchObject(
$res))
67 $price[
'unlimited_duration'] =
$row->unlimited_duration;
79 $res = $ilDB->queryf(
'
80 SELECT count(price_id) FROM payment_prices
81 WHERE pobject_id = %s',
83 array($a_pobject_id));
85 $row =
$res->fetchRow(DB_FETCHMODE_ARRAY);
92 #include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
98 return (
float)
$price[
'price'];
104 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
107 $currency_unit = $genSet->get(
'currency_unit');
109 return $a_price .
' ' . $currency_unit;
125 include_once
'./Services/Payment/classes/class.ilPaymentCurrency.php';
126 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
131 $currency_unit = $genSet->get(
"currency_unit");
135 $pr_str = number_format($a_price , 2,
",",
".");
140 return $pr_str .
" " . $currency_unit;
147 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
148 # include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
149 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
154 $currency_unit = $genSet->get(
"currency_unit");
158 if (is_array($a_price_ids))
160 for ($i = 0; $i < count($a_price_ids); $i++)
164 $price = (float) $price_data[
"price"];
165 $amount[$a_price_ids[$i][
"pay_method"]] += (float)
$price;
195 $this->price = preg_replace(
'/^0+/',
'',$a_price);
197 $this->price = $a_price;
202 $this->currency = $a_currency_id;
206 if($this->unlimited_duration ==
'1' && ($a_duration ==
'' || null))
209 $this->duration = (int)$a_duration;
214 if($a_unlimited_duration)
215 $this->unlimited_duration = (int)$a_unlimited_duration;
217 $this->unlimited_duration = 0;
222 $next_id = $this->db->nextId(
'payment_prices');
224 $res = $this->db->manipulateF(
'
225 INSERT INTO payment_prices
233 VALUES (%s, %s, %s, %s, %s, %s)',
235 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'float'),
250 $res = $this->db->manipulateF(
'
251 UPDATE payment_prices SET
254 unlimited_duration = %s,
256 WHERE price_id = %s',
258 array(
'integer',
'integer',
'integer',
'float',
'integer'),
270 public function delete($a_price_id)
272 $statement = $this->db->manipulateF(
'
273 DELETE FROM payment_prices
274 WHERE price_id = %s',
275 array(
'integer'), array($a_price_id));
283 $statement = $this->db->manipulateF(
'
284 DELETE FROM payment_prices
285 WHERE pobject_id = %s',
297 $duration_valid =
false;
298 $price_valid =
false;
300 if(preg_match(
'/^(([1-9][0-9]{0,1})|[0])?$/',$this->
__getDuration())
303 $duration_valid =
true;
312 if($duration_valid ==
true && $price_valid ==
true)
326 $res = $ilDB->queryf(
'
327 SELECT * FROM payment_prices
329 AND pobject_id = %s',
330 array(
'integer',
'integer'),
331 array($a_price_id, $a_pobject_id));
333 return $res->numRows() ?
true :
false;
345 if($this->currency == null)
360 $this->prices = array();
362 $res = $this->db->queryf(
'
363 SELECT * FROM payment_prices
364 WHERE pobject_id = %s
370 while(
$row = $this->db->fetchObject(
$res))
372 $this->prices[
$row->price_id][
'pobject_id'] =
$row->pobject_id;
373 $this->prices[
$row->price_id][
'price_id'] =
$row->price_id;
374 $this->prices[
$row->price_id][
'currency'] =
$row->currency;
375 $this->prices[
$row->price_id][
'duration'] =
$row->duration;
376 $this->prices[
$row->price_id][
'unlimited_duration'] =
$row->unlimited_duration;
377 $this->prices[
$row->price_id][
'price'] =
$row->price;
384 return count($this->prices);
389 $lowest_price_id = 0;
392 foreach ($this->prices as $price_id =>
$data)
394 $current_price =
$data[
'price'];
396 if($lowest_price == 0||
397 $lowest_price > (
float)$current_price)
399 $lowest_price = (float)$current_price;
400 $lowest_price_id = $price_id;
404 return is_array($this->prices[$lowest_price_id]) ? $this->prices[$lowest_price_id] : array();