49 $this->pobject_id = $a_pobject_id;
62 return $this->prices ? $this->prices : array();
66 return $this->prices[$a_price_id] ? $this->prices[$a_price_id] : array();
74 $query =
"SELECT * FROM payment_prices ".
75 "WHERE price_id = '".$a_price_id.
"'";
77 $res = $ilDB->query($query);
81 $price[
'duration'] = $row->duration;
82 $price[
'currency'] = $row->currency;
83 $price[
'unit_value'] = $row->unit_value;
84 $price[
'sub_unit_value'] = $row->sub_unit_value;
86 return count($price) ? $price : array();
91 $query =
"SELECT count(price_id) FROM payment_prices ".
92 "WHERE pobject_id = '".$a_pobject_id.
"'";
94 $res = $this->db->query($query);
95 $row =
$res->fetchRow(DB_FETCHMODE_ARRAY);
102 include_once
'./payment/classes/class.ilPaymentCurrency.php';
113 include_once
'./payment/classes/class.ilGeneralSettings.php';
116 $unit_string = $genSet->get(
'currency_unit');
118 $pr_str = number_format( ((
int)
$unit_value) .
'.' . sprintf(
'%02d', ((
int) $subunit_value)), 2,
',',
'.');
119 return $pr_str .
' ' . $unit_string;
124 return (
float) number_format(((
int)
$unit_value).
'.'.sprintf(
'%02d', ((
int) $subunit_value)), 2,
'.',
'');
129 include_once
'./payment/classes/class.ilPaymentCurrency.php';
130 include_once
'./payment/classes/class.ilGeneralSettings.php';
135 $unit_string = $genSet->get(
"currency_unit");
139 $pr_str = number_format($a_price , 2,
",",
".");
140 return $pr_str .
" " . $unit_string;
145 return (
float) (((int) $a_price[
"unit_value"]) .
"." . sprintf(
"%02d", ((
int) $a_price[
"sub_unit_value"])));
150 include_once
'./payment/classes/class.ilPaymentPrices.php';
151 # include_once './payment/classes/class.ilPaymentCurrency.php';
152 include_once
'./payment/classes/class.ilGeneralSettings.php';
157 $unit_string = $genSet->get(
"currency_unit");
161 if (is_array($a_price_ids))
163 for ($i = 0; $i < count($a_price_ids); $i++)
167 $price = ((int) $price_data[
"unit_value"]) .
"." . sprintf(
"%02d", ((
int) $price_data[
"sub_unit_value"]));
168 $amount[$a_price_ids[$i][
"pay_method"]] += (float) $price;
213 $this->unit_value = preg_replace(
'/^0+/',
'',$a_value);
217 $this->sub_unit_value = $a_value;
221 $this->currency = $a_currency_id;
225 $this->duration = $a_duration;
230 $query =
"INSERT INTO payment_prices SET ".
231 "pobject_id = '".$this->getPobjectId().
"', ".
232 "currency = '".$this->__getCurrency().
"', ".
233 "duration = '".$this->__getDuration().
"', ".
234 "unit_value = '".$this->__getUnitValue().
"', ".
235 "sub_unit_value = '".$this->__getSubUnitValue().
"'";
237 $res = $this->db->query($query);
246 $query =
"UPDATE payment_prices SET ".
247 "currency = '".$this->__getCurrency().
"', ".
248 "duration = '".$this->__getDuration().
"', ".
249 "unit_value = '".$this->__getUnitValue().
"', ".
250 "sub_unit_value = '".$this->__getSubUnitValue().
"' ".
251 "WHERE price_id = '".$a_price_id.
"'";
253 $res = $this->db->query($query);
259 function delete($a_price_id)
261 $query =
"DELETE FROM payment_prices ".
262 "WHERE price_id = '".$a_price_id.
"'";
264 $res = $this->db->query($query);
273 $query =
"DELETE FROM payment_prices ".
274 "WHERE pobject_id = '".$this->getPobjectId().
"'";
276 $res = $this->db->query($query);
285 $duration_valid =
false;
286 $price_valid =
false;
290 $duration_valid =
true;
303 return $duration_valid and $price_valid;
310 $query =
"SELECT * FROM payment_prices ".
311 "WHERE price_id = '".$a_price_id.
"' ".
312 "AND pobject_id = '".$a_pobject_id.
"'";
314 $res = $ilDB->query($query);
316 return $res->numRows() ?
true :
false;
341 $this->prices = array();
343 $query =
"SELECT * FROM payment_prices ".
344 "WHERE pobject_id = '".$this->getPobjectId().
"' ".
347 $res = $this->db->query($query);
350 $this->prices[$row->price_id][
'pobject_id'] = $row->pobject_id;
351 $this->prices[$row->price_id][
'price_id'] = $row->price_id;
352 $this->prices[$row->price_id][
'currency'] = $row->currency;
353 $this->prices[$row->price_id][
'duration'] = $row->duration;
354 $this->prices[$row->price_id][
'unit_value'] = $row->unit_value;
355 $this->prices[$row->price_id][
'sub_unit_value'] = $row->sub_unit_value;
361 return count($this->prices);
366 $lowest_price_id = 0;
369 foreach ($this->prices as $price_id =>
$data)
373 if($lowest_price == 0||
374 $lowest_price > (
float)$current_price)
376 $lowest_price = (float)$current_price;
377 $lowest_price_id = $price_id;
381 return is_array($this->prices[$lowest_price_id]) ? $this->prices[$lowest_price_id] : array();