ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPaymentPrices Class Reference
+ Collaboration diagram for ilPaymentPrices:

Public Member Functions

 __construct ($a_pobject_id=0)
 setPriceType ($a_price_type)
 getPriceType ()
 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 ()
 Validates a price before database manipulations.
 getExtensionPrices ()
 getNumberOfPrices ()
 getLowestPrice ()
 setDurationFrom ($a_duration_from)
 setDurationUntil ($a_duration_until)
 setDescription ($a_description)

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)

Data Fields

const TYPE_DURATION_MONTH = 1
const TYPE_DURATION_DATE = 2
const TYPE_UNLIMITED_DURATION = 3
 $price_type = self::TYPE_DURATION_MONTH

Private Member Functions

 __getPrice ()
 __getCurrency ()
 __getDuration ()
 __getUnlimitedDuration ()
 __read ($with_extension_prices=false)
 __getDurationFrom ()
 __getDurationUntil ()
 __getDescription ()

Private Attributes

 $pobject_id
 $price
 $currency
 $duration = 0
 $unlimited_duration = 0
 $extension = 0
 $duration_from
 $duration_until
 $description
 $prices = array()

Detailed Description

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

Constructor & Destructor Documentation

ilPaymentPrices::__construct (   $a_pobject_id = 0)

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

References __read().

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

+ Here is the call graph for this function:

Member Function Documentation

ilPaymentPrices::__getCurrency ( )
private

Definition at line 391 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::__getDescription ( )
private

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

References $description.

Referenced by add(), and update().

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getDuration ( )
private

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

References $duration.

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

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getDurationFrom ( )
private

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

References $duration_from.

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

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getDurationUntil ( )
private

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

References $duration_until.

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

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getPrice ( )
private

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

References $unlimited_duration.

Referenced by add(), and update().

+ Here is the caller graph for this function:

ilPaymentPrices::__read (   $with_extension_prices = false)
private

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

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

Referenced by __construct(), add(), delete(), deleteAllPrices(), 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;
$this->prices[$row->price_id]['duration_from'] = $row->duration_from;
$this->prices[$row->price_id]['duration_until'] = $row->duration_until;
$this->prices[$row->price_id]['description'] = $row->description;
$this->prices[$row->price_id]['price_type'] = $row->price_type;
}
}

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

References $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 = $ilDB->fetchAssoc($res);
return ($row[0]);
}
static ilPaymentPrices::_formatPriceToString (   $a_price)
static

Definition at line 149 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 127 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 79 of file class.ilPaymentPrices.php.

References $price, $res, and $row.

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

{
global $ilDB;
$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['duration_from'] = $row->duration_from;
$price['duration_until'] = $row->duration_until;
$price['description'] = $row->description;
$price['unlimited_duration'] = $row->unlimited_duration;
$price['currency'] = $row->currency;
$price['price'] = number_format($row->price, 2, '.', '');
$price['extension'] = $row->extension;
$price['price_type'] = $row->price_type;
}
return count($price) ? $price : array();
}

+ Here is the caller graph for this function:

static ilPaymentPrices::_getPriceString (   $a_price_id)
static

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

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

Referenced by ilShopShoppingCartGUI\addBookings(), ilPaymentStatisticGUI\addCustomer(), ilObjPaymentSettingsGUI\addCustomerObject(), ilPaymentShoppingCart\getShoppingCart(), 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 172 of file class.ilPaymentPrices.php.

References ilPaymentSettings\_getInstance().

{
include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
include_once './Services/Payment/classes/class.ilPaymentSettings.php';
$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 190 of file class.ilPaymentPrices.php.

References $price, and _getPrice().

Referenced by ilPaymentShoppingCart\__read().

{
include_once './Services/Payment/classes/class.ilPaymentPrices.php';
$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;
}
}
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 371 of file class.ilPaymentPrices.php.

References $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 248 of file class.ilPaymentPrices.php.

References $res, __getCurrency(), __getDescription(), __getDuration(), __getDurationFrom(), __getDurationUntil(), __getPrice(), __getUnlimitedDuration(), __read(), getExtension(), getPobjectId(), and getPriceType().

{
$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()),
'duration_from' => array('date', $this->__getDurationFrom()),
'duration_until' => array('date', $this->__getDurationUntil()),
'description' => array('text', $this->__getDescription()),
'price_type' => array('integer', $this->getPriceType())
));
$this->__read(true);
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::delete (   $a_price_id)

Definition at line 289 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 300 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 242 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 448 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;
$prices[$row->price_id]['duration_from'] = $row->duration_from;
$prices[$row->price_id]['duration_until'] = $row->duration_until;
$prices[$row->price_id]['description'] = $row->description;
$prices[$row->price_id]['price_type'] = $row->price_type;
}
return $prices;
}

+ Here is the call graph for this function:

ilPaymentPrices::getLowestPrice ( )

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

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

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

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

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

{
return $this->prices ? $this->prices : array();
}
ilPaymentPrices::getPriceType ( )

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

References $price_type.

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

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::setCurrency (   $a_currency_id)

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

{
$this->currency = $a_currency_id;
}
ilPaymentPrices::setDescription (   $a_description)

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

{
$this->description = $a_description;
}
ilPaymentPrices::setDuration (   $a_duration)

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

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

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

{
// $a_duration_from = "dd.mm.YYYY HH:ii:ss"
$this->duration_from = $a_duration_from;
}
ilPaymentPrices::setDurationUntil (   $a_duration_until)

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

{
$this->duration_until = $a_duration_until;
}
ilPaymentPrices::setExtension (   $a_extension)

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

{
$this->extension = (int)$a_extension;
}
ilPaymentPrices::setPrice (   $a_price = 0)

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

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

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

{
$this->price_type = $a_price_type;
return $this;
}
ilPaymentPrices::setUnlimitedDuration (   $a_unlimited_duration)

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

References __getCurrency(), __getDescription(), __getDuration(), __getDurationFrom(), __getDurationUntil(), __getPrice(), __getUnlimitedDuration(), __read(), getExtension(), getPobjectId(), and getPriceType().

{
$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()),
'duration_from' => array('date', $this->__getDurationFrom()),
'duration_until' => array('date', $this->__getDurationUntil()),
'description' => array('text', $this->__getDescription()),
'price_type' => array('integer', $this->getPriceType())
),
array('price_id'=> array('integer', $a_price_id)));
$this->__read(true);
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::validate ( )

Validates a price before database manipulations.

public

Exceptions
ilShopException

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

References $lng, __getDuration(), __getDurationFrom(), __getDurationUntil(), __getPrice(), and getPriceType().

{
global $lng;
include_once 'Services/Payment/exceptions/class.ilShopException.php';
switch($this->getPriceType())
{
case self::TYPE_DURATION_MONTH:
if(!preg_match('/^[1-9][0-9]{0,1}$/', $this->__getDuration()))
throw new ilShopException($lng->txt('paya_price_not_valid'));
break;
case self::TYPE_DURATION_DATE:
if(!preg_match('/^[0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}$/', $this->__getDurationFrom()))
throw new ilShopException($lng->txt('payment_price_invalid_date_from'));
$from_date = explode('-', $this->__getDurationFrom());
if(!checkdate($from_date[1], $from_date[2], $from_date[0]))
throw new ilShopException($lng->txt('payment_price_invalid_date_from'));
if(!preg_match('/^[0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}$/', $this->__getDurationUntil()))
throw new ilShopException($lng->txt('payment_price_invalid_date_until'));
$till_date = explode('-', $this->__getDurationUntil());
if(!checkdate($till_date[1], $till_date[2], $till_date[0]))
throw new ilShopException($lng->txt('payment_price_invalid_date_until'));
$from = mktime(12, 12, 12, $from_date[1], $from_date[2], $from_date[0]);
$till = mktime(12, 12, 12, $till_date[1], $till_date[2], $till_date[0]);
if($from >= $till)
throw new ilShopException($lng->txt('payment_price_invalid_date_from_gt_until'));
break;
case self::TYPE_UNLIMITED_DURATION:
return true;
break;
default:
throw new ilShopException($lng->txt('payment_no_price_type_selected_sdf'));
break;
}
if(preg_match('/[0-9]/',$this->__getPrice()))
{
return true;
}
throw new ilShopException($lng->txt('payment_price_invalid_price'));
}

+ Here is the call graph for this function:

Field Documentation

ilPaymentPrices::$currency
private

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

Referenced by __getCurrency().

ilPaymentPrices::$description
private

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

Referenced by __getDescription().

ilPaymentPrices::$duration = 0
private

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

Referenced by __getDuration().

ilPaymentPrices::$duration_from
private

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

Referenced by __getDurationFrom().

ilPaymentPrices::$duration_until
private

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

Referenced by __getDurationUntil().

ilPaymentPrices::$extension = 0
private

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

Referenced by getExtension().

ilPaymentPrices::$pobject_id
private

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

Referenced by getPobjectId().

ilPaymentPrices::$price
private

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

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

ilPaymentPrices::$price_type = self::TYPE_DURATION_MONTH

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

Referenced by getPriceType().

ilPaymentPrices::$prices = array()
private

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

Referenced by getExtensionPrices().

ilPaymentPrices::$unlimited_duration = 0
private

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

Referenced by __getUnlimitedDuration().


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