Public Member Functions | |
ilPaymentShoppingCart (&$user_obj) | |
setPobjectId ($a_pobject_id) | |
getPobjectId () | |
setPriceId ($a_price_id) | |
getPriceId () | |
getEntries () | |
setTotalAmount ($a_total_amount) | |
getTotalAmount () | |
isInShoppingCart ($a_pobject_id) | |
getEntry ($a_pobject_id) | |
add () | |
update ($a_psc_id) | |
delete ($a_psc_id) | |
emptyShoppingCart () | |
_hasEntries ($a_user_id) | |
__read () | |
getShoppingCart () | |
getTotalAmountValue () | |
getVat ($a_amount=0) | |
Data Fields | |
$user_obj = null | |
$db = null | |
$sc_entries = array() |
Definition at line 34 of file class.ilPaymentShoppingCart.php.
ilPaymentShoppingCart::__read | ( | ) |
Definition at line 182 of file class.ilPaymentShoppingCart.php.
References $query, $res, $row, ilPaymentPrices::_getTotalAmount(), ilPaymentPrices::_priceExists(), and setTotalAmount().
Referenced by add(), delete(), emptyShoppingCart(), ilPaymentShoppingCart(), and update().
{ include_once './payment/classes/class.ilPaymentPrices.php'; $this->sc_entries = array(); $query = "SELECT * FROM payment_shopping_cart ". "WHERE customer_id = '".$this->user_obj->getId()."'"; $res = $this->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->sc_entries[$row->psc_id]["psc_id"] = $row->psc_id; $this->sc_entries[$row->psc_id]["customer_id"] = $row->customer_id; $this->sc_entries[$row->psc_id]["pobject_id"] = $row->pobject_id; $this->sc_entries[$row->psc_id]["price_id"] = $row->price_id; } // Delete all entries with not valid prices or pay_method foreach($this->sc_entries as $entry) { // check if price_id exists for pobject if(!ilPaymentPrices::_priceExists($entry['price_id'],$entry['pobject_id'])) { $this->delete($entry['psc_id']); return false; } // check pay method $tmp_pobj =& new ilPaymentObject($this->user_obj,$entry['pobject_id']); if($tmp_pobj->getPayMethod() == $tmp_pobj->PAY_METHOD_BILL) { $this->delete($entry['psc_id']); return false; } // if payment is expired if($tmp_pobj->getStatus() == $tmp_pobj->STATUS_EXPIRES) { $this->delete($entry['psc_id']); return false; } $prices[] = $entry['price_id']; unset($tmp_pobj); } // set total amount $this->setTotalAmount(ilPaymentPrices::_getTotalAmount($prices ? $prices : array())); return true; }
ilPaymentShoppingCart::_hasEntries | ( | $ | a_user_id | ) |
ilPaymentShoppingCart::add | ( | ) |
Definition at line 109 of file class.ilPaymentShoppingCart.php.
References $query, and __read().
{ // Delete old entries for same pobject_id $query = "DELETE FROM payment_shopping_cart ". "WHERE customer_id = '".$this->user_obj->getId()."' ". "AND pobject_id = '".$this->getPobjectId()."'"; $this->db->query($query); $query = "INSERT INTO payment_shopping_cart ". "SET customer_id = '".$this->user_obj->getId()."', ". "pobject_id = '".$this->getPobjectId()."', ". "price_id = '".$this->getPriceId()."'"; $this->db->query($query); $this->__read(); return true; }
ilPaymentShoppingCart::delete | ( | $ | a_psc_id | ) |
ilPaymentShoppingCart::emptyShoppingCart | ( | ) |
ilPaymentShoppingCart::getEntries | ( | ) |
Definition at line 71 of file class.ilPaymentShoppingCart.php.
Referenced by getShoppingCart().
{
return $this->sc_entries ? $this->sc_entries : array();
}
ilPaymentShoppingCart::getEntry | ( | $ | a_pobject_id | ) |
Definition at line 95 of file class.ilPaymentShoppingCart.php.
References $query.
ilPaymentShoppingCart::getPobjectId | ( | ) |
Definition at line 58 of file class.ilPaymentShoppingCart.php.
{
return $this->pobject_id;
}
ilPaymentShoppingCart::getPriceId | ( | ) |
Definition at line 66 of file class.ilPaymentShoppingCart.php.
{
return $this->price_id;
}
ilPaymentShoppingCart::getShoppingCart | ( | ) |
Definition at line 234 of file class.ilPaymentShoppingCart.php.
References $counter, ilPaymentPrices::_getPrice(), getEntries(), and ilObjectFactory::getInstanceByRefId().
Referenced by getTotalAmountValue().
{ if(!count($items = $this->getEntries())) { return 0; } $counter = 0; foreach($items as $item) { $tmp_pobject =& new ilPaymentObject($this->user_obj,$item['pobject_id']); $tmp_obj =& ilObjectFactory::getInstanceByRefId($tmp_pobject->getRefId()); $f_result[$counter]["typ"] = $tmp_obj->getType(); $f_result[$counter]["buchungstext"] = $tmp_obj->getTitle(); $price_data = ilPaymentPrices::_getPrice($item['price_id']); $price = ((int) $price_data["unit_value"]) . "." . ((int) $price_data["sub_unit_value"]); $f_result[$counter]["betrag"] = (float) $price; $f_result[$counter]["dauer"] = $price_data["duration"]; unset($tmp_obj); unset($tmp_pobject); ++$counter; } return $f_result; }
ilPaymentShoppingCart::getTotalAmount | ( | ) |
Definition at line 79 of file class.ilPaymentShoppingCart.php.
{
return $this->total_amount;
}
ilPaymentShoppingCart::getTotalAmountValue | ( | ) |
Definition at line 266 of file class.ilPaymentShoppingCart.php.
References $result, and getShoppingCart().
{ $amount = 0.0; if (is_array($result = $this->getShoppingCart())) { for ($i = 0; $i < count($result); $i++) { $amount += $result[$i]["betrag"]; } } return (float) $amount; }
ilPaymentShoppingCart::getVat | ( | $ | a_amount = 0 |
) |
Definition at line 281 of file class.ilPaymentShoppingCart.php.
{ include_once './payment/classes/class.ilGeneralSettings.php'; $genSet = new ilGeneralSettings(); return (float) ($a_amount - (round(($a_amount / (1 + ($genSet->get("vat_rate") / 100.0))) * 100) / 100)); }
ilPaymentShoppingCart::ilPaymentShoppingCart | ( | &$ | user_obj | ) |
ilPaymentShoppingCart::isInShoppingCart | ( | $ | a_pobject_id | ) |
Definition at line 84 of file class.ilPaymentShoppingCart.php.
ilPaymentShoppingCart::setPobjectId | ( | $ | a_pobject_id | ) |
Definition at line 54 of file class.ilPaymentShoppingCart.php.
{ $this->pobject_id = $a_pobject_id; }
ilPaymentShoppingCart::setPriceId | ( | $ | a_price_id | ) |
Definition at line 62 of file class.ilPaymentShoppingCart.php.
{ $this->price_id = $a_price_id; }
ilPaymentShoppingCart::setTotalAmount | ( | $ | a_total_amount | ) |
Definition at line 75 of file class.ilPaymentShoppingCart.php.
Referenced by __read().
{ $this->total_amount = $a_total_amount; }
ilPaymentShoppingCart::update | ( | $ | a_psc_id | ) |
Definition at line 130 of file class.ilPaymentShoppingCart.php.
References $query, and __read().
{ $query = "UPDATE payment_shopping_cart ". "SET customer_id = '".$this->user_obj->getId()."',' ". "pobject_id = '".$this->getPobjectId()."',' ". "price_id = '".$this->getPriceId()."' ". "WHERE psc_id = '".$a_psc_id."'"; $this->db->query($query); $this->__read(); return true; }
ilPaymentShoppingCart::$db = null |
Definition at line 40 of file class.ilPaymentShoppingCart.php.
ilPaymentShoppingCart::$sc_entries = array() |
Definition at line 42 of file class.ilPaymentShoppingCart.php.
ilPaymentShoppingCart::$user_obj = null |
Definition at line 39 of file class.ilPaymentShoppingCart.php.
Referenced by ilPaymentShoppingCart().