ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPaymentPrices Class Reference
+ Collaboration diagram for ilPaymentPrices:

Public Member Functions

 ilPaymentPrices ($a_pobject_id=0)
 getPobjectId ()
 getPrices ()
 getPrice ($a_price_id)
 setPrice ($a_price=0)
 setCurrency ($a_currency_id)
 setDuration ($a_duration)
 setUnlimitedDuration ($a_unlimited_duration)
 add ()
 update ($a_price_id)
 delete ($a_price_id)
 deleteAllPrices ()
 validate ()
 getNumberOfPrices ()
 getLowestPrice ()

Static Public Member Functions

static _getPrice ($a_price_id)
static _countPrices ($a_pobject_id)
static _getPriceString ($a_price_id)
static _formatPriceToString ($a_price)
static _getPriceStringFromAmount ($a_price)
static _getTotalAmount ($a_price_ids)
static _priceExists ($a_price_id, $a_pobject_id)

Private Member Functions

 __getPrice ()
 __getCurrency ()
 __getDuration ()
 __getUnlimitedDuration ()
 __read ()

Private Attributes

 $ilDB
 $pobject_id
 $price
 $currency
 $duration
 $unlimited_duration = 0
 $currency_conversion_rate = 1
 $prices = array()

Detailed Description

Definition at line 11 of file class.ilPaymentPrices.php.

Member Function Documentation

ilPaymentPrices::__getCurrency ( )
private

Definition at line 342 of file class.ilPaymentPrices.php.

References $currency.

Referenced by add(), and update().

{
/*TODO: CURRENCY not finished yet -> return 1 as default */
if($this->currency == null)
$this->currency = 1;
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getDuration ( )
private

Definition at line 349 of file class.ilPaymentPrices.php.

References $duration.

Referenced by add(), update(), and validate().

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getPrice ( )
private

Definition at line 338 of file class.ilPaymentPrices.php.

References $price.

Referenced by add(), update(), and validate().

{
return $this->price;
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getUnlimitedDuration ( )
private

Definition at line 353 of file class.ilPaymentPrices.php.

References $unlimited_duration.

Referenced by add(), update(), and validate().

+ Here is the caller graph for this function:

ilPaymentPrices::__read ( )
private

Definition at line 358 of file class.ilPaymentPrices.php.

References $res, $row, and getPobjectId().

Referenced by add(), delete(), deleteAllPrices(), ilPaymentPrices(), and update().

{
$this->prices = array();
$res = $this->db->queryf('
SELECT * FROM payment_prices
WHERE pobject_id = %s
ORDER BY duration',
array('integer'),
array($this->getPobjectId()));
while($row = $this->db->fetchObject($res))
{
$this->prices[$row->price_id]['pobject_id'] = $row->pobject_id;
$this->prices[$row->price_id]['price_id'] = $row->price_id;
$this->prices[$row->price_id]['currency'] = $row->currency;
$this->prices[$row->price_id]['duration'] = $row->duration;
$this->prices[$row->price_id]['unlimited_duration'] = $row->unlimited_duration;
$this->prices[$row->price_id]['price'] = $row->price;
//TODO: CURRENCY $this->prices[$row->price_id]['price'] = $row->price * $this->getCurrencyConversionRate();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPaymentPrices::_countPrices (   $a_pobject_id)
static

Definition at line 75 of file class.ilPaymentPrices.php.

References $ilDB, $res, and $row.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT count(price_id) FROM payment_prices
WHERE pobject_id = %s',
array('integer'),
array($a_pobject_id));
$row = $res->fetchRow(DB_FETCHMODE_ARRAY);
return ($row[0]);
}
static ilPaymentPrices::_formatPriceToString (   $a_price)
static

Definition at line 102 of file class.ilPaymentPrices.php.

Referenced by ilShopResultPresentationGUI\renderItems(), and ilShopPurchaseGUI\showDetails().

{
include_once './Services/Payment/classes/class.ilGeneralSettings.php';
$genSet = new ilGeneralSettings();
$currency_unit = $genSet->get('currency_unit');
return $a_price . ' ' . $currency_unit;
/* TODO: after currency implementation is finished -> replace whole function
* include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
$separator= ilPaymentCurrency::_getDecimalSeparator();
$currency_symbol = ilPaymentCurrency::_getSymbol($a_currency_id);
$price_string = number_format($a_price,'2',$separator,'');
return $price_string . ' ' . $currency_symbol;
*/
}

+ Here is the caller graph for this function:

static ilPaymentPrices::_getPrice (   $a_price_id)
static

Definition at line 55 of file class.ilPaymentPrices.php.

References $ilDB, $price, $res, and $row.

Referenced by ilPurchaseBaseGUI\__getShoppingCart(), ilPurchaseBaseGUI\__showItemsTable(), ilPurchaseBaseGUI\__showShoppingCart(), _getPriceString(), _getTotalAmount(), ilShopShoppingCartGUI\addBookings(), ilObjPaymentSettingsGUI\addCustomerObject(), ilPaymentShoppingCart\getShoppingCart(), ilPaymentStatisticGUI\saveCustomer(), ilObjPaymentSettingsGUI\saveCustomerObject(), ilShopShoppingCartGUI\showItems(), and ilShopShoppingCartGUI\showItemsTable().

{
global $ilDB, $ilSettings;
$res = $ilDB->queryf('
SELECT * FROM payment_prices
WHERE price_id = %s',
array('integer'), array($a_price_id));
while($row = $ilDB->fetchObject($res))
{
$price['duration'] = $row->duration;
$price['unlimited_duration'] = $row->unlimited_duration;
$price['currency'] = $row->currency;
$price['price'] = $row->price;
}
return count($price) ? $price : array();
}

+ Here is the caller graph for this function:

static ilPaymentPrices::_getPriceString (   $a_price_id)
static

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

References $lng, $price, and _getPrice().

Referenced by ilPurchaseBaseGUI\__showShoppingCart(), ilShopShoppingCartGUI\addBookings(), ilPaymentShoppingCart\getShoppingCart(), ilPaymentStatisticGUI\saveCustomer(), ilShopPurchaseGUI\showDetails(), and ilShopShoppingCartGUI\showItems().

{
#include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
global $lng;
return (float)$price['price'];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPaymentPrices::_getPriceStringFromAmount (   $a_price)
static

Definition at line 123 of file class.ilPaymentPrices.php.

References $lng.

{
include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
include_once './Services/Payment/classes/class.ilGeneralSettings.php';
global $lng;
$genSet = new ilGeneralSettings();
$currency_unit = $genSet->get("currency_unit");
$pr_str = '';
$pr_str = number_format($a_price , 2, ",", ".");
/* TODO: CURRENCY $pr_str = number_format($a_price * $this->getCurrencyConversionRate() , 2, ",", ".");
* remove genset
* */
return $pr_str . " " . $currency_unit;
}
static ilPaymentPrices::_getTotalAmount (   $a_price_ids)
static

Definition at line 144 of file class.ilPaymentPrices.php.

References $ilDB, $lng, $price, and _getPrice().

Referenced by ilPaymentShoppingCart\__read().

{
include_once './Services/Payment/classes/class.ilPaymentPrices.php';
# include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
include_once './Services/Payment/classes/class.ilGeneralSettings.php';
global $ilDB, $lng;
$genSet = new ilGeneralSettings();
$currency_unit = $genSet->get("currency_unit");
$amount = array();
if (is_array($a_price_ids))
{
for ($i = 0; $i < count($a_price_ids); $i++)
{
$price_data = ilPaymentPrices::_getPrice($a_price_ids[$i]["id"]);
$price = (float) $price_data["price"];
$amount[$a_price_ids[$i]["pay_method"]] += (float) $price;
}
}
/* TODO: CURRENCY replace 'if' & remove genset
if (is_array($a_price_ids))
{
$default_currency = ilPaymentCurrency::_getDefaultcurrency();
for ($i = 0; $i < count($a_price_ids); $i++)
{
$price_data = ilPaymentPrices::_getPrice($a_price_ids[$i]["id"]);
if($price_data['currency'] != $default_currency['currency_id'])
{
$conversion_rate = ilPaymentCurrency::_getConversionRate($price_data['currency']);
$price = round(((float) $price_data['price'] * $conversion_rate),2);
}
else
$price = (float) $price_data["price"];
$amount[$a_price_ids[$i]["pay_method"]] += (float) $price;
}
}
*/
return $amount;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPaymentPrices::_priceExists (   $a_price_id,
  $a_pobject_id 
)
static

Definition at line 322 of file class.ilPaymentPrices.php.

References $ilDB, and $res.

Referenced by ilPaymentShoppingCart\__read().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM payment_prices
WHERE price_id = %s
AND pobject_id = %s',
array('integer', 'integer'),
array($a_price_id, $a_pobject_id));
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

ilPaymentPrices::add ( )

Definition at line 220 of file class.ilPaymentPrices.php.

References $res, __getCurrency(), __getDuration(), __getPrice(), __getUnlimitedDuration(), __read(), and getPobjectId().

{
$next_id = $this->db->nextId('payment_prices');
$res = $this->db->manipulateF('
INSERT INTO payment_prices
( price_id,
pobject_id,
currency,
duration,
unlimited_duration,
price
)
VALUES (%s, %s, %s, %s, %s, %s)',
array('integer','integer', 'integer', 'integer', 'integer', 'float'),
array( $next_id,
$this->getPobjectId(),
$this->__getCurrency(),
$this->__getDuration(),
$this->__getPrice()
));
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::delete (   $a_price_id)

Definition at line 270 of file class.ilPaymentPrices.php.

References __read().

{
$statement = $this->db->manipulateF('
DELETE FROM payment_prices
WHERE price_id = %s',
array('integer'), array($a_price_id));
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::deleteAllPrices ( )

Definition at line 281 of file class.ilPaymentPrices.php.

References __read(), and getPobjectId().

{
$statement = $this->db->manipulateF('
DELETE FROM payment_prices
WHERE pobject_id = %s',
array('integer'),
array($this->getPobjectId()));
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::getLowestPrice ( )

Definition at line 387 of file class.ilPaymentPrices.php.

References $data.

Referenced by ilShopResultPresentationGUI\renderItems().

{
$lowest_price_id = 0;
$lowest_price = 0;
foreach ($this->prices as $price_id => $data)
{
$current_price = $data['price'];
if($lowest_price == 0||
$lowest_price > (float)$current_price)
{
$lowest_price = (float)$current_price;
$lowest_price_id = $price_id;
}
}
return is_array($this->prices[$lowest_price_id]) ? $this->prices[$lowest_price_id] : array();
}

+ Here is the caller graph for this function:

ilPaymentPrices::getNumberOfPrices ( )

Definition at line 382 of file class.ilPaymentPrices.php.

{
return count($this->prices);
}
ilPaymentPrices::getPobjectId ( )

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

References $pobject_id.

Referenced by __read(), add(), and deleteAllPrices().

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::getPrice (   $a_price_id)

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

{
return $this->prices[$a_price_id] ? $this->prices[$a_price_id] : array();
}
ilPaymentPrices::getPrices ( )

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

{
return $this->prices ? $this->prices : array();
}
ilPaymentPrices::ilPaymentPrices (   $a_pobject_id = 0)

Definition at line 27 of file class.ilPaymentPrices.php.

References $ilDB, and __read().

{
global $ilDB;
$this->db = $ilDB;
$this->pobject_id = $a_pobject_id;
$this->__read();
}

+ Here is the call graph for this function:

ilPaymentPrices::setCurrency (   $a_currency_id)

Definition at line 200 of file class.ilPaymentPrices.php.

{
$this->currency = $a_currency_id;
}
ilPaymentPrices::setDuration (   $a_duration)

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

{
if($this->unlimited_duration == '1' && ($a_duration == '' || null))
$a_duration = 0;
$this->duration = (int)$a_duration;
}
ilPaymentPrices::setPrice (   $a_price = 0)

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

{
$this->price = preg_replace('/^0+/','',$a_price);
$this->price = $a_price;
}
ilPaymentPrices::setUnlimitedDuration (   $a_unlimited_duration)

Definition at line 212 of file class.ilPaymentPrices.php.

{
if($a_unlimited_duration)
$this->unlimited_duration = (int)$a_unlimited_duration;
else
$this->unlimited_duration = 0;
}
ilPaymentPrices::update (   $a_price_id)

Definition at line 248 of file class.ilPaymentPrices.php.

References $res, __getCurrency(), __getDuration(), __getPrice(), __getUnlimitedDuration(), and __read().

{
$res = $this->db->manipulateF('
UPDATE payment_prices SET
currency = %s,
duration = %s,
unlimited_duration = %s,
price = %s
WHERE price_id = %s',
array('integer', 'integer','integer', 'float', 'integer'),
array( $this->__getCurrency(),
$this->__getDuration(),
$this->__getPrice(),
$a_price_id
));
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::validate ( )

Definition at line 294 of file class.ilPaymentPrices.php.

References __getDuration(), __getPrice(), and __getUnlimitedDuration().

{
$duration_valid = false;
$price_valid = false;
if(preg_match('/^(([1-9][0-9]{0,1})|[0])?$/',$this->__getDuration())
|| ((int)$this->__getDuration() == 0 && $this->__getUnlimitedDuration() == 1))
{
$duration_valid = true;
}
if(preg_match('/[0-9]/',$this->__getPrice()))
{
$price_valid = true;
}
if($duration_valid == true && $price_valid == true)
{
return true;
}
else return false;
}

+ Here is the call graph for this function:

Field Documentation

ilPaymentPrices::$currency
private

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

Referenced by __getCurrency().

ilPaymentPrices::$currency_conversion_rate = 1
private

Definition at line 23 of file class.ilPaymentPrices.php.

ilPaymentPrices::$duration
private

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

Referenced by __getDuration().

ilPaymentPrices::$ilDB
private
ilPaymentPrices::$pobject_id
private

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

Referenced by getPobjectId().

ilPaymentPrices::$price
private

Definition at line 17 of file class.ilPaymentPrices.php.

Referenced by __getPrice(), _getPrice(), _getPriceString(), and _getTotalAmount().

ilPaymentPrices::$prices = array()
private

Definition at line 25 of file class.ilPaymentPrices.php.

ilPaymentPrices::$unlimited_duration = 0
private

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

Referenced by __getUnlimitedDuration().


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