ILIAS  Release_3_10_x_branch Revision 61812
 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)
 _getPrice ($a_price_id)
 _countPrices ($a_pobject_id)
 _getPriceString ($a_price_id)
 _getPriceStringFromAmount ($a_price)
 _getPriceFromArray ($a_price)
 _getTotalAmount ($a_price_ids)
 setUnitValue ($a_value=0)
 setSubUnitValue ($a_value=0)
 setCurrency ($a_currency_id)
 setDuration ($a_duration)
 add ()
 update ($a_price_id)
 delete ($a_price_id)
 deleteAllPrices ()
 validate ()
 _priceExists ($a_price_id, $a_pobject_id)
 __getUnitValue ()
 __getSubUnitValue ()
 __getCurrency ()
 __getDuration ()
 __read ()
 getNumberOfPrices ()
 getLowestPrice ()

Static Public Member Functions

static _formatPriceToString ($unit_value, $subunit_value)
static _formatPriceToFloat ($unit_value, $subunit_value)

Data Fields

 $ilDB
 $pobject_id
 $unit_value
 $sub_unit_value
 $currency
 $duration

Private Attributes

 $prices = array()

Detailed Description

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

Member Function Documentation

ilPaymentPrices::__getCurrency ( )

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

References $currency.

{
}
ilPaymentPrices::__getDuration ( )

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

References $duration.

Referenced by validate().

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getSubUnitValue ( )

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

References $sub_unit_value.

Referenced by validate().

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__getUnitValue ( )

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

References $unit_value.

Referenced by validate().

{
}

+ Here is the caller graph for this function:

ilPaymentPrices::__read ( )

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

References $res, and DB_FETCHMODE_OBJECT.

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

{
$this->prices = array();
$query = "SELECT * FROM payment_prices ".
"WHERE pobject_id = '".$this->getPobjectId()."' ".
"ORDER BY duration";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$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]['unit_value'] = $row->unit_value;
$this->prices[$row->price_id]['sub_unit_value'] = $row->sub_unit_value;
}
}

+ Here is the caller graph for this function:

ilPaymentPrices::_countPrices (   $a_pobject_id)

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

References $res.

{
$query = "SELECT count(price_id) FROM payment_prices ".
"WHERE pobject_id = '".$a_pobject_id."'";
$res = $this->db->query($query);
$row = $res->fetchRow(DB_FETCHMODE_ARRAY);
return ($row[0]);
}
static ilPaymentPrices::_formatPriceToFloat (   $unit_value,
  $subunit_value 
)
static

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

References $unit_value.

Referenced by getLowestPrice(), and ilShopResultPresentationGUI\renderItems().

{
return (float) number_format(((int) $unit_value).'.'.sprintf('%02d', ((int) $subunit_value)), 2, '.', '');
}

+ Here is the caller graph for this function:

static ilPaymentPrices::_formatPriceToString (   $unit_value,
  $subunit_value 
)
static

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

References $unit_value.

Referenced by _getPriceString(), and ilShopResultPresentationGUI\renderItems().

{
include_once './payment/classes/class.ilGeneralSettings.php';
$genSet = new ilGeneralSettings();
$unit_string = $genSet->get('currency_unit');
$pr_str = number_format( ((int) $unit_value) . '.' . sprintf('%02d', ((int) $subunit_value)), 2, ',', '.');
return $pr_str . ' ' . $unit_string;
}

+ Here is the caller graph for this function:

ilPaymentPrices::_getPrice (   $a_price_id)

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

References $ilDB, $res, and DB_FETCHMODE_OBJECT.

Referenced by ilPurchaseBMFGUI\__addBookings(), ilPaymentShoppingCartGUI\__showItemsTable(), ilPurchaseBMFGUI\__showItemsTable(), ilPurchaseBMFGUI\__showShoppingCart(), _getPriceString(), _getTotalAmount(), ilPaymentShoppingCartGUI\addBookings(), ilShopShoppingCartGUI\addBookings(), ilPaymentShoppingCart\getShoppingCart(), ilPaymentStatisticGUI\saveCustomer(), ilObjPaymentSettingsGUI\saveCustomerObject(), ilPaymentShoppingCartGUI\showItems(), ilShopShoppingCartGUI\showItems(), and ilShopShoppingCartGUI\showItemsTable().

{
global $ilDB;
$query = "SELECT * FROM payment_prices ".
"WHERE price_id = '".$a_price_id."'";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$price['duration'] = $row->duration;
$price['currency'] = $row->currency;
$price['unit_value'] = $row->unit_value;
$price['sub_unit_value'] = $row->sub_unit_value;
}
return count($price) ? $price : array();
}

+ Here is the caller graph for this function:

ilPaymentPrices::_getPriceFromArray (   $a_price)

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

Referenced by ilPurchaseBMFGUI\__addBookings(), ilPaymentShoppingCartGUI\addBookings(), and ilShopShoppingCartGUI\addBookings().

{
return (float) (((int) $a_price["unit_value"]) . "." . sprintf("%02d", ((int) $a_price["sub_unit_value"])));
}

+ Here is the caller graph for this function:

ilPaymentPrices::_getPriceStringFromAmount (   $a_price)

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

References $lng.

Referenced by ilPurchaseBMFGUI\__addBookings(), ilPurchasePaypal\__saveTransaction(), ilPaymentShoppingCartGUI\addBookings(), and ilShopShoppingCartGUI\addBookings().

{
include_once './payment/classes/class.ilPaymentCurrency.php';
include_once './payment/classes/class.ilGeneralSettings.php';
global $lng;
$genSet = new ilGeneralSettings();
$unit_string = $genSet->get("currency_unit");
$pr_str = '';
$pr_str = number_format($a_price , 2, ",", ".");
return $pr_str . " " . $unit_string;
}

+ Here is the caller graph for this function:

ilPaymentPrices::_getTotalAmount (   $a_price_ids)

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

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

Referenced by ilPaymentShoppingCart\__read().

{
include_once './payment/classes/class.ilPaymentPrices.php';
# include_once './payment/classes/class.ilPaymentCurrency.php';
include_once './payment/classes/class.ilGeneralSettings.php';
global $ilDB,$lng;
$genSet = new ilGeneralSettings();
$unit_string = $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 = ((int) $price_data["unit_value"]) . "." . sprintf("%02d", ((int) $price_data["sub_unit_value"]));
$amount[$a_price_ids[$i]["pay_method"]] += (float) $price;
}
}
return $amount;
/* foreach($a_price_ids as $id)
{
$price_data = ilPaymentPrices::_getPrice($id);
$price_arr["$price_data[currency]"]['unit'] += (int) $price_data['unit_value'];
$price_arr["$price_data[currency]"]['subunit'] += (int) $price_data['sub_unit_value'];
}
if(is_array($price_arr))
{
foreach($price_arr as $key => $value)
{
// CHECK cent bigger 100
$value['unit'] += (int) ($value['subunit'] / 100);
$value['subunit'] = (int) ($value['subunit'] % 100);
$unit_string = $lng->txt('currency_'.ilPaymentCurrency::_getUnit($key));
$subunit_string = $lng->txt('currency_'.ilPaymentCurrency::_getSubUnit($key));
if((int) $value['unit'])
{
$pr_str .= $value['unit'].' '.$unit_string.' ';
}
if((int) $value['subunit'])
{
$pr_str .= $value['subunit'].' '.$subunit_string;
}
// in the moment only one price
return $pr_str;
}
}
return 0;*/
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPaymentPrices::_priceExists (   $a_price_id,
  $a_pobject_id 
)

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

References $ilDB, and $res.

Referenced by ilPaymentShoppingCart\__read().

{
global $ilDB;
$query = "SELECT * FROM payment_prices ".
"WHERE price_id = '".$a_price_id."' ".
"AND pobject_id = '".$a_pobject_id."'";
$res = $ilDB->query($query);
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

ilPaymentPrices::add ( )

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

References $res, and __read().

{
$query = "INSERT INTO payment_prices SET ".
"pobject_id = '".$this->getPobjectId()."', ".
"currency = '".$this->__getCurrency()."', ".
"duration = '".$this->__getDuration()."', ".
"unit_value = '".$this->__getUnitValue()."', ".
"sub_unit_value = '".$this->__getSubUnitValue()."'";
$res = $this->db->query($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::delete (   $a_price_id)

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

References $res, and __read().

{
$query = "DELETE FROM payment_prices ".
"WHERE price_id = '".$a_price_id."'";
$res = $this->db->query($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::deleteAllPrices ( )

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

References $res, and __read().

{
$query = "DELETE FROM payment_prices ".
"WHERE pobject_id = '".$this->getPobjectId()."'";
$res = $this->db->query($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::getLowestPrice ( )

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

References $data, and _formatPriceToFloat().

Referenced by ilShopResultPresentationGUI\renderItems().

{
$lowest_price_id = 0;
$lowest_price = 0;
foreach ($this->prices as $price_id => $data)
{
$current_price = self::_formatPriceToFloat($data['unit_value'], $data['sub_unit_value']);
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 call graph for this function:

+ Here is the caller graph for this function:

ilPaymentPrices::getNumberOfPrices ( )

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

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

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

References $pobject_id.

{
}
ilPaymentPrices::getPrice (   $a_price_id)

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

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

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

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

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

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

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

{
$this->duration = $a_duration;
}
ilPaymentPrices::setSubUnitValue (   $a_value = 0)

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

{
$this->sub_unit_value = $a_value;
}
ilPaymentPrices::setUnitValue (   $a_value = 0)

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

{
// substitute leading zeros with ''
$this->unit_value = preg_replace('/^0+/','',$a_value);
}
ilPaymentPrices::update (   $a_price_id)

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

References $res, and __read().

{
$query = "UPDATE payment_prices SET ".
"currency = '".$this->__getCurrency()."', ".
"duration = '".$this->__getDuration()."', ".
"unit_value = '".$this->__getUnitValue()."', ".
"sub_unit_value = '".$this->__getSubUnitValue()."' ".
"WHERE price_id = '".$a_price_id."'";
$res = $this->db->query($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilPaymentPrices::validate ( )

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

References __getDuration(), __getSubUnitValue(), and __getUnitValue().

{
$duration_valid = false;
$price_valid = false;
if(preg_match('/^[1-9][0-9]{0,1}$/',$this->__getDuration()))
{
$duration_valid = true;
}
if(preg_match('/^[1-9]\d{0,4}$/',$this->__getUnitValue()) and
preg_match('/^\d{0,2}$/',$this->__getSubUnitValue()))
{
$price_valid = true;
}
else if(preg_match('/^\d{0,5}$/',$this->__getUnitValue()) and
preg_match('/[1-9]/',$this->__getSubUnitValue()))
{
return true;
}
return $duration_valid and $price_valid;
}

+ Here is the call graph for this function:

Field Documentation

ilPaymentPrices::$currency

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

Referenced by __getCurrency().

ilPaymentPrices::$duration

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

Referenced by __getDuration().

ilPaymentPrices::$ilDB
ilPaymentPrices::$pobject_id

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

Referenced by getPobjectId().

ilPaymentPrices::$prices = array()
private

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

ilPaymentPrices::$sub_unit_value

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

Referenced by __getSubUnitValue().

ilPaymentPrices::$unit_value

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