Public Member Functions | Data Fields

ilPaymentPrices Class Reference

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)
 _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 ()

Data Fields

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

Detailed Description

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


Member Function Documentation

ilPaymentPrices::__getCurrency (  ) 

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

        {
                return $this->currency;
        }

ilPaymentPrices::__getDuration (  ) 

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

Referenced by validate().

        {
                return $this->duration;
        }

Here is the caller graph for this function:

ilPaymentPrices::__getSubUnitValue (  ) 

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

Referenced by validate().

        {
                return $this->sub_unit_value;
        }

Here is the caller graph for this function:

ilPaymentPrices::__getUnitValue (  ) 

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

Referenced by validate().

        {
                return $this->unit_value;
        }

Here is the caller graph for this function:

ilPaymentPrices::__read (  ) 

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

References $query, $res, and $row.

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 $query, $res, and $row.

        {
                $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]);
        }

ilPaymentPrices::_getPrice ( a_price_id  ) 

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

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

Referenced by ilPurchaseBMFGUI::__addBookings(), ilPurchaseBMFGUI::__showShoppingCart(), _getPriceString(), _getTotalAmount(), ilPaymentShoppingCart::getShoppingCart(), ilPaymentStatisticGUI::saveCustomer(), ilObjPaymentSettingsGUI::saveCustomerObject(), and ilPaymentShoppingCartGUI::showItems().

        {
                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::_getPriceString ( a_price_id  ) 

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

References $lng, and _getPrice().

Referenced by ilPurchaseBMFGUI::__addBookings(), ilPurchaseBMFGUI::__showShoppingCart(), ilPaymentStatisticGUI::addCustomer(), ilObjPaymentSettingsGUI::addCustomerObject(), ilPaymentShoppingCart::getShoppingCart(), ilPaymentStatisticGUI::saveCustomer(), ilObjPaymentSettingsGUI::saveCustomerObject(), ilPaymentPurchaseGUI::showDetails(), and ilPaymentShoppingCartGUI::showItems().

        {
                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 = '';
                $price = ilPaymentPrices::_getPrice($a_price_id);

                $pr_str = number_format( ((int) $price["unit_value"]) . "." . ((int) $price["sub_unit_value"]) , 2, ",", ".");
                return $pr_str . " " . $unit_string;

/*              $unit_string = $lng->txt('currency_'.ilPaymentCurrency::_getUnit($price['currency']));
                $subunit_string = $lng->txt('currency_'.ilPaymentCurrency::_getSubUnit($price['currency']));

                if((int) $price['unit_value'])
                {
                        $pr_str .= $price['unit_value'].' '.$unit_string.' ';
                }
                if((int) $price['sub_unit_value'])
                {
                        $pr_str .= $price['sub_unit_value'].' '.$subunit_string;
                }
                return $pr_str; */
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilPaymentPrices::_getTotalAmount ( a_price_ids  ) 

Definition at line 130 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"]) . "." . ((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 288 of file class.ilPaymentPrices.php.

References $ilDB, $query, 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 210 of file class.ilPaymentPrices.php.

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

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

References $query, $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::getPobjectId (  ) 

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

        {
                return $this->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 201 of file class.ilPaymentPrices.php.

        {
                $this->currency = $a_currency_id;
        }

ilPaymentPrices::setDuration ( a_duration  ) 

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

        {
                $this->duration = $a_duration;
        }

ilPaymentPrices::setSubUnitValue ( a_value = 0  ) 

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

        {
                $this->sub_unit_value = $a_value;
        }

ilPaymentPrices::setUnitValue ( a_value = 0  ) 

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

References $query, $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 265 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.

ilPaymentPrices::$duration

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

ilPaymentPrices::$ilDB
ilPaymentPrices::$pobject_id

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

ilPaymentPrices::$prices

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

ilPaymentPrices::$sub_unit_value

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

ilPaymentPrices::$unit_value

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


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