ILIAS  Release_4_2_x_branch Revision 61807
 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)
 setExtension ($a_extension)
 getExtension ()
 add ()
 update ($a_price_id)
 delete ($a_price_id)
 deleteAllPrices ()
 validate ()
 getExtensionPrices ()
 getNumberOfPrices ()
 getLowestPrice ()

Static Public Member Functions

static _getPrice ($a_price_id)
static _countPrices ($a_pobject_id)
static _getPriceString ($a_price_id)
static _getGUIPrice ($a_price)
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 ($with_extension_prices=false)

Private Attributes

 $ilDB
 $pobject_id
 $price
 $currency
 $duration
 $unlimited_duration = 0
 $extension = 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 361 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 368 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 357 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 372 of file class.ilPaymentPrices.php.

References $unlimited_duration.

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

+ Here is the caller graph for this function:

ilPaymentPrices::__read (   $with_extension_prices = false)
private

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

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

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

{
$this->prices = array();
if(!$with_extension_prices)
{
$res = $this->db->queryf('
SELECT * FROM payment_prices
WHERE pobject_id = %s
AND extension = %s
ORDER BY duration',
array('integer','integer'),
array($this->getPobjectId(), 0));
}
else
{
// needed for administration view
$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;
$this->prices[$row->price_id]['extension'] = $row->extension;
//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 78 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);
$row = $ilDB->fetchAssoc($res);
return ($row[0]);
}
static ilPaymentPrices::_formatPriceToString (   $a_price)
static

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

References _getGUIPrice(), and ilPaymentSettings\_getInstance().

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

{
include_once './Services/Payment/classes/class.ilPaymentSettings.php';
$currency_unit = $genSet->get('currency_unit');
$gui_price = self::_getGUIPrice($a_price);
return $gui_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 call graph for this function:

+ Here is the caller graph for this function:

static ilPaymentPrices::_getGUIPrice (   $a_price)
static

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

References $lng.

Referenced by _formatPriceToString(), _getPriceString(), and ilShopShoppingCartGUI\showItems().

{
global $lng;
$system_lng = $lng->getDefaultLanguage();
// CODES: ISO 639
$use_comma_seperator = array('ar','bg','cs','de','da','es','et','it',
'fr','nl','el','sr','uk','ru','ro','tr','pl','lt','pt','sq','hu');
$use_point_separator = array('en','ja','zh','vi');
if(in_array($system_lng, $use_comma_seperator))
{
$gui_price = number_format((float)$a_price, 2, ',', '');
}
else
$gui_price = number_format((float)$a_price, 2, '.', '');
return $gui_price;
}

+ Here is the caller graph for this function:

static ilPaymentPrices::_getPrice (   $a_price_id)
static

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

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

Referenced by ilPurchaseBaseGUI\__getShoppingCart(), ilPurchaseBaseGUI\__showItemsTable(), ilPurchaseBaseGUI\__showShoppingCart(), _getPriceString(), _getTotalAmount(), ilShopShoppingCartGUI\addBookings(), 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'] = number_format($row->price, 2, '.', '');
$price['extension'] = $row->extension;
}
return count($price) ? $price : array();
}

+ Here is the caller graph for this function:

static ilPaymentPrices::_getPriceString (   $a_price_id)
static

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

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

Referenced by ilShopShoppingCartGUI\addBookings(), ilPaymentShoppingCart\getShoppingCart(), ilPaymentStatisticGUI\saveCustomer(), and ilShopShoppingCartGUI\showItems().

{
$gui_price = self::_getGUIPrice($price['price']);
return $gui_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 148 of file class.ilPaymentPrices.php.

References $lng, and ilPaymentSettings\_getInstance().

{
include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
include_once './Services/Payment/classes/class.ilPaymentSettings.php';
global $lng;
$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;
}

+ Here is the call graph for this function:

static ilPaymentPrices::_getTotalAmount (   $a_price_ids)
static

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

References $ilDB, $lng, $price, ilPaymentSettings\_getInstance(), 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.ilPaymentSettings.php';
global $ilDB, $lng;
$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 341 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 258 of file class.ilPaymentPrices.php.

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

{
$next_id = $this->db->nextId('payment_prices');
$res = $this->db->insert('payment_prices', array(
'price_id' => array('integer', $next_id),
'pobject_id' => array('integer', $this->getPobjectId()),
'currency' => array('integer', $this->__getCurrency()),
'duration' => array('integer', $this->__getDuration()),
'unlimited_duration'=> array('integer', $this->__getUnlimitedDuration()),
'price' => array('float', $this->__getPrice()),
'extension' => array('integer', $this->getExtension())
));
$this->__read(true);
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::delete (   $a_price_id)

Definition at line 290 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(true);
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::deleteAllPrices ( )

Definition at line 301 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(true);
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::getExtension ( )

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

References $extension.

Referenced by add(), and update().

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::getExtensionPrices ( )

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

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

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

+ Here is the call graph for this function:

ilPaymentPrices::getLowestPrice ( )

Definition at line 445 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 440 of file class.ilPaymentPrices.php.

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

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

References $pobject_id.

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

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::getPrice (   $a_price_id)

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

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

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

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

Definition at line 28 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 224 of file class.ilPaymentPrices.php.

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

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

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

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

{
if($this->extension == '1' && ($a_extension == '' || null))
$a_extension = 0;
$this->extension = $a_extension;
}
ilPaymentPrices::setPrice (   $a_price = 0)

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

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

Definition at line 236 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 275 of file class.ilPaymentPrices.php.

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

{
$this->db->update('payment_prices',
array( 'pobject_id' => array('integer', $this->getPobjectId()),
'currency' => array('integer', $this->__getCurrency()),
'duration' => array('integer', $this->__getDuration()),
'unlimited_duration'=> array('integer', $this->__getUnlimitedDuration()),
'price' => array('float', $this->__getPrice()),
'extension' => array('integer', $this->getExtension())),
array('price_id'=> array('integer', $a_price_id)));
$this->__read(true);
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::validate ( )

Definition at line 314 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 24 of file class.ilPaymentPrices.php.

ilPaymentPrices::$duration
private

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

Referenced by __getDuration().

ilPaymentPrices::$extension = 0
private

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

Referenced by getExtension().

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 26 of file class.ilPaymentPrices.php.

Referenced by getExtensionPrices().

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: