ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPaymentCoupons Class Reference
+ Collaboration diagram for ilPaymentCoupons:

Public Member Functions

 ilPaymentCoupons (&$user_obj, $a_vendor_view=false)
 getCoupons ()
 setId ($a_id)
 getId ()
 setCouponUser ($a_user_id)
 getCouponUser ()
 setTitle ($a_title)
 getTitle ()
 setDescription ($a_description)
 getDescription ()
 setType ($a_type)
 getType ()
 setValue ($a_value)
 getValue ()
 setFromDate ($a_from)
 getFromDate ()
 setTillDate ($a_till)
 getTillDate ()
 setFromDateEnabled ($a_from_date_enabled=0)
 getFromDateEnabled ()
 setTillDateEnabled ($a_till_date_enabled=0)
 getTillDateEnabled ()
 setChangeDate ($a_date)
 getChangeDate ()
 setUses ($a_uses)
 getUses ()
 setSearchTitleType ($a_title_type)
 getSearchTitleType ()
 setSearchTitleValue ($a_title_value)
 getSearchTitleValue ()
 setSearchType ($a_type)
 getSearchType ()
 setSearchFromDay ($a_day)
 getSearchFromDay ()
 setSearchFromMonth ($a_month)
 getSearchFromMonth ()
 setSearchFromYear ($a_year)
 getSearchFromYear ()
 setSearchTillDay ($a_day)
 getSearchTillDay ()
 setSearchTillMonth ($a_month)
 getSearchTillMonth ()
 setSearchTillYear ($a_year)
 getSearchTillYear ()
 setSearchFromDateEnabled ($a_from_enabled)
 getSearchFromDateEnabled ()
 setSearchTillDateEnabled ($a_till_enabled)
 getSearchTillDateEnabled ()
 setCurrentCoupon ($coupon=array())
 getCurrentCoupon ()
 add ()
 update ()
 delete ()
 getCouponById ($a_coupon_id)
 getCouponBonus ($a_item_price)
 getObjectsByCouponId ($a_coupon_id)
 getCodesByCouponId ($a_coupon_id)
 getUsedCouponsByCouponId ($a_coupon_id)
 getCouponByCode ($a_coupon_code)
 checkCouponValidity ()
 deleteCode ($a_code_id)
 deleteAllCodesByCouponId ($a_coupon_id)
 getCode ($a_code_id)
 addCode ($a_code, $a_coupon_id)
 addCouponForBookingId ($a_booking_id)
 addTracking ()
 isObjectAssignedToCoupon ($a_ref_id)
 Checks if an object is assigned to the current coupon.
 assignObjectToCoupon ($a_ref_id)
 Assigns an object to the current coupon.
 unassignObjectFromCoupon ($a_ref_id)
 Unassigns an object from the current coupon.

Private Member Functions

 getVendorIds ()

Private Attributes

 $db = null
 $user_obj = null
 $vendor_view = false
 $coupons = array()
 $current_coupon = array()
 $codes = array()
 $used_codes = array()
 $objects = array()

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 12 of file class.ilPaymentCoupons.php.

Member Function Documentation

ilPaymentCoupons::add ( )

Definition at line 370 of file class.ilPaymentCoupons.php.

{
$query = sprintf("INSERT INTO payment_coupons VALUES('', ".
" %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
$this->db->quote($this->getCouponUser()),
$this->db->quote($this->getTitle()),
$this->db->quote($this->getDescription()),
$this->db->quote($this->getType()),
$this->db->quote($this->getValue()),
$this->db->quote($this->getFromDate()),
$this->db->quote($this->getTillDate()),
$this->db->quote($this->getFromDateEnabled()),
$this->db->quote($this->getTillDateEnabled()),
$this->db->quote($this->getUses()),
"''",
"''"
);
$this->db->query($query);
return $this->db->getLastInsertId();
}
ilPaymentCoupons::addCode (   $a_code,
  $a_coupon_id 
)

Definition at line 652 of file class.ilPaymentCoupons.php.

{
if ($a_code && $a_coupon_id)
{
$query = sprintf("INSERT INTO payment_coupons_codes VALUES('', ".
" %s, %s)",
$this->db->quote($a_coupon_id),
$this->db->quote($a_code)
);
$this->db->query($query);
return $this->db->getLastInsertId();
}
return false;
}
ilPaymentCoupons::addCouponForBookingId (   $a_booking_id)

Definition at line 669 of file class.ilPaymentCoupons.php.

References $current_coupon, and getCurrentCoupon().

{
if ($a_booking_id && is_array($current_coupon))
{
$query = sprintf("INSERT INTO payment_statistic_coupons VALUES(%s, %s, %s)",
$this->db->quote($a_booking_id),
$this->db->quote($current_coupon["pc_pk"]),
$this->db->quote($current_coupon["pcc_pk"])
);
$this->db->query($query);
return $this->db->getLastInsertId();
}
return false;
}

+ Here is the call graph for this function:

ilPaymentCoupons::addTracking ( )

Definition at line 689 of file class.ilPaymentCoupons.php.

References $current_coupon, and getCurrentCoupon().

{
if (is_array($current_coupon))
{
$query = "INSERT INTO payment_coupons_tracking "
."SET "
."pct_pcc_fk = ".$this->db->quote($current_coupon["pcc_pk"]). ", "
."usr_id = ".$this->db->quote($this->user_obj->getId()). ", "
."pct_date = ".$this->db->quote(date("Y-m-d H:i:s")). " ";
$this->db->query($query);
return $this->db->getLastInsertId();
}
return false;
}

+ Here is the call graph for this function:

ilPaymentCoupons::assignObjectToCoupon (   $a_ref_id)

Assigns an object to the current coupon.

public

Returns
bool

Definition at line 739 of file class.ilPaymentCoupons.php.

References getId().

{
if ($a_ref_id && is_numeric($this->getId()))
{
$query = sprintf("INSERT INTO payment_coupons_objects VALUES(%s, %s)",
$this->db->quote($this->getId()),
$this->db->quote($a_ref_id)
);
$this->db->query($query);
return true;
}
return false;
}

+ Here is the call graph for this function:

ilPaymentCoupons::checkCouponValidity ( )

Definition at line 562 of file class.ilPaymentCoupons.php.

References $res, DB_FETCHMODE_OBJECT, and getCurrentCoupon().

{
$coupon = $this->getCurrentCoupon();
if (empty($coupon)) return $this->COUPON_NOT_FOUND;
$current_date = date("Y-m-d");
if ($coupon["pc_from"] != "0000-00-00" && $coupon["pc_from_enabled"] == '1' &&
$coupon["pc_till"] != "0000-00-00" && $coupon["pc_till_enabled"] == '1'
)
{
if (! ($coupon["pc_from"] <= $current_date && $current_date <= $coupon["pc_till"]))
{
return $this->COUPON_OUT_OF_DATE;
}
}
else if ($coupon["pc_from"] != "0000-00-00" && $coupon["pc_from_enabled"] == '1')
{
if ($coupon["pc_from"] > $current_date)
{
return $this->COUPON_OUT_OF_DATE;
}
}
else if ($coupon["pc_till"] != "0000-00-00" && $coupon["pc_till_enabled"] == '1')
{
if ($coupon["pc_till"] < $current_date)
{
return $this->COUPON_OUT_OF_DATE;
}
}
if (is_numeric($coupon["pc_uses"]) && $coupon["pc_uses"] > 0)
{
$query = "SELECT COUNT(*) AS used_coupons
FROM payment_coupons_tracking
WHERE pct_pcc_fk = ".$this->db->quote($coupon["pcc_pk"])." ";
$this->db->query($query);
$res = $this->db->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
if ($row->used_coupons >= $coupon["pc_uses"]) return $this->COUPON_TOO_MUCH_USED;
}
return $this->COUPON_VALID;
}

+ Here is the call graph for this function:

ilPaymentCoupons::delete ( )

Definition at line 418 of file class.ilPaymentCoupons.php.

References getId().

{
if ($this->getId())
{
$query = "DELETE FROM payment_coupons WHERE pc_pk = ".$this->db->quote($this->getId())." ";
$this->db->query($query);
return true;
}
return false;
}

+ Here is the call graph for this function:

ilPaymentCoupons::deleteAllCodesByCouponId (   $a_coupon_id)

Definition at line 622 of file class.ilPaymentCoupons.php.

{
if ($a_coupon_id)
{
$query = "DELETE FROM payment_coupons_codes WHERE pcc_pc_fk = ".$this->db->quote($a_coupon_id)." ";
$this->db->query($query);
return true;
}
return false;
}
ilPaymentCoupons::deleteCode (   $a_code_id)

Definition at line 609 of file class.ilPaymentCoupons.php.

{
if ($a_code_id)
{
$query = "DELETE FROM payment_coupons_codes WHERE pcc_pk = ".$this->db->quote($a_code_id)." ";
$this->db->query($query);
return true;
}
return false;
}
ilPaymentCoupons::getChangeDate ( )

Definition at line 257 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->change_date;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getCode (   $a_code_id)

Definition at line 635 of file class.ilPaymentCoupons.php.

References $res, and DB_FETCHMODE_OBJECT.

{
$query = "SELECT *
FROM payment_coupons_codes
WHERE 1
AND pcc_pk = ".$this->db->quote($a_code_id)." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$code['pcc_pk'] = $row->pcc_pk;
$code['pcc_pc_fk'] = $row->pcc_pc_fk;
$code['pcc_code'] = $row->pcc_code;
}
return $code ? $code : array();
}
ilPaymentCoupons::getCodesByCouponId (   $a_coupon_id)

Definition at line 487 of file class.ilPaymentCoupons.php.

References $codes, $res, and DB_FETCHMODE_OBJECT.

Referenced by getCoupons().

{
$this->codes = array();
$query = "SELECT payment_coupons_codes.*, COUNT(pct_pcc_fk) AS pcc_used
FROM payment_coupons_codes
LEFT JOIN payment_coupons_tracking ON pct_pcc_fk = pcc_pk
WHERE 1 AND pcc_pc_fk = ".$this->db->quote($a_coupon_id)."
GROUP BY pcc_pk";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->codes[$row->pcc_pk]['pcc_pk'] = $row->pcc_pk;
$this->codes[$row->pcc_pk]['pcc_code'] = $row->pcc_code;
$this->codes[$row->pcc_pk]['pcc_used'] = $row->pcc_used;
}
return $this->codes;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getCouponBonus (   $a_item_price)

Definition at line 456 of file class.ilPaymentCoupons.php.

References getCurrentCoupon().

{
if (is_array($coupon = $this->getCurrentCoupon()))
{
switch ($coupon["pc_type"])
{
case "fix":
return (float) $coupon["pc_value"];
case "percent":
return (float) $a_item_price * ($coupon["pc_value"] / 100);
}
}
return 0;
}

+ Here is the call graph for this function:

ilPaymentCoupons::getCouponByCode (   $a_coupon_code)

Definition at line 531 of file class.ilPaymentCoupons.php.

References $res, DB_FETCHMODE_OBJECT, getObjectsByCouponId(), setCurrentCoupon(), and setId().

{
$query = "SELECT *
FROM payment_coupons_codes
INNER JOIN payment_coupons ON pc_pk = pcc_pc_fk
WHERE 1
AND pcc_code = ".$this->db->quote($a_coupon_code). " ";
$res = $this->db->query($query);
if (is_object($row = $res->fetchRow(DB_FETCHMODE_OBJECT)))
{
$coupon['pc_pk'] = $row->pc_pk;
$coupon['pc_title'] = $row->pc_title;
$coupon['pc_description'] = $row->pc_description;
$coupon['pc_type'] = $row->pc_type;
$coupon['pc_value'] = $row->pc_value;
$coupon['pc_type'] = $row->pc_type;
$coupon['pc_from'] = $row->pc_from;
$coupon['pc_till'] = $row->pc_till;
$coupon['pc_uses'] = $row->pc_uses;
$coupon['pcc_pk'] = $row->pcc_pk;
$coupon['pcc_code'] = $row->pcc_code;
$coupon['objects'] = $this->getObjectsByCouponId($row->pc_pk);
}
$this->setId($coupon['pc_pk']);
$this->setCurrentCoupon($coupon);
return $coupon ? $coupon : array();
}

+ Here is the call graph for this function:

ilPaymentCoupons::getCouponById (   $a_coupon_id)

Definition at line 431 of file class.ilPaymentCoupons.php.

References $res, DB_FETCHMODE_OBJECT, setChangeDate(), setCouponUser(), setDescription(), setFromDate(), setFromDateEnabled(), setId(), setTillDate(), setTillDateEnabled(), setTitle(), setType(), setUses(), and setValue().

{
$query = "SELECT *
FROM payment_coupons
WHERE 1
AND pc_pk = ".$this->db->quote($a_coupon_id)." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setId($row->pc_pk);
$this->setCouponUser($row->usr_id);
$this->setTitle($row->pc_title);
$this->setDescription($row->pc_description);
$this->setType($row->pc_type);
$this->setValue($row->pc_value);
$this->setFromDate($row->pc_from);
$this->setTillDate($row->pc_till);
$this->setFromDateEnabled($row->pc_from_enabled);
$this->setTillDateEnabled($row->pc_till_enabled);
$this->setUses($row->pc_uses);
$this->setChangeDate(date("Y-m-h H:i:s"));
}
}

+ Here is the call graph for this function:

ilPaymentCoupons::getCoupons ( )

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

References $coupons, $in, $res, DB_FETCHMODE_OBJECT, getCodesByCouponId(), getObjectsByCouponId(), getSearchFromDateEnabled(), getSearchFromDay(), getSearchFromMonth(), getSearchFromYear(), getSearchTillDateEnabled(), getSearchTillDay(), getSearchTillMonth(), getSearchTillYear(), getSearchTitleType(), getSearchTitleValue(), getSearchType(), getUsedCouponsByCouponId(), and getVendorIds().

{
$this->coupons = array();
$query = "SELECT * FROM payment_coupons WHERE 1 ";
if ($this->getSearchFromDay() != "" &&
$this->getSearchFromMonth() != "" &&
$this->getSearchFromYear() != "" &&
)
{
$from = mktime(0, 0, 0, $this->getSearchFromMonth(), $this->getSearchFromDay(), $this->getSearchFromYear());
}
if ($this->getSearchTillDay() != "" &&
$this->getSearchTillMonth() != "" &&
$this->getSearchTillYear() != "" &&
)
{
$till = mktime(23, 59, 59, $this->getSearchTillMonth(), $this->getSearchTillDay(), $this->getSearchTillYear());
}
if ($from && $till)
{
$query .= " AND ((pc_from != '0000-00-00' AND pc_till != '0000-00-00' AND pc_from_enabled = '1' AND pc_till_enabled = '1' AND
(UNIX_TIMESTAMP(pc_from) >= " . $this->db->quote($from). " AND UNIX_TIMESTAMP(pc_till) <= " . $this->db->quote($till). "
OR UNIX_TIMESTAMP(pc_till) >= " . $this->db->quote($from). " AND UNIX_TIMESTAMP(pc_till) <= " . $this->db->quote($till). "
OR UNIX_TIMESTAMP(pc_from) >= " . $this->db->quote($from). " AND UNIX_TIMESTAMP(pc_from) <= " . $this->db->quote($till). "
OR UNIX_TIMESTAMP(pc_from) <= " . $this->db->quote($from). " AND UNIX_TIMESTAMP(pc_till) >= " . $this->db->quote($till). "
))
OR (pc_from != '0000-00-00' AND pc_from_enabled = '1' AND UNIX_TIMESTAMP(pc_from) <= " . $this->db->quote($till). ")
OR (pc_till != '0000-00-00' AND pc_till_enabled = '1' AND UNIX_TIMESTAMP(pc_till) >= " . $this->db->quote($from). ")
)";
}
else if ($from)
{
$query .= " AND ((pc_till != '0000-00-00' AND pc_till_enabled = '1' AND UNIX_TIMESTAMP(pc_till) >= " . $this->db->quote($from). ") OR (pc_from != '0000-00-00' AND pc_till = '0000-00-00')) ";
}
else if ($till)
{
$query .= " AND ((pc_from != '0000-00-00' AND pc_from_enabled = '1' AND UNIX_TIMESTAMP(pc_from) <= " . $this->db->quote($till). ") OR (pc_from = '0000-00-00' AND pc_till != '0000-00-00')) ";
}
if ($this->getSearchTitleValue() != "")
{
if ($this->getSearchTitleType() == 0)
{
$query .= " AND pc_title LIKE '" . $this->getSearchTitleValue() . "%' ";
}
else if ($this->getSearchTitleType() == 1)
{
$query .= " AND pc_title LIKE '%" . $this->getSearchTitleValue() . "' ";
}
}
if ($this->getSearchType() != "")
{
$query .= " AND pc_type = " . $this->db->quote($this->getSearchType()) . " ";
}
$vendors = $this->getVendorIds();
if (is_array($vendors) &&
count($vendors) > 0)
{
$in = 'usr_id IN (';
$in .= implode(',',$vendors);
$in .= ')';
$query .= " AND ".$in." ";
}
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->coupons[$row->pc_pk]['pc_pk'] = $row->pc_pk;
$this->coupons[$row->pc_pk]['usr_id'] = $row->usr_id;
$this->coupons[$row->pc_pk]['pc_title'] = $row->pc_title;
$this->coupons[$row->pc_pk]['pc_description'] = $row->pc_description;
$this->coupons[$row->pc_pk]['pc_type'] = $row->pc_type;
$this->coupons[$row->pc_pk]['pc_value'] = $row->pc_value;
$this->coupons[$row->pc_pk]['pc_from'] = $row->pc_from;
$this->coupons[$row->pc_pk]['pc_till'] = $row->pc_till;
$this->coupons[$row->pc_pk]['pc_from_enabled'] = $row->pc_from_enabled;
$this->coupons[$row->pc_pk]['pc_till_enabled'] = $row->pc_till_enabled;
$this->coupons[$row->pc_pk]['pc_uses'] = $row->pc_uses;
$this->coupons[$row->pc_pk]['pc_last_change_usr_id'] = $row->pc_last_change_usr_id;
$this->coupons[$row->pc_pk]['pc_last_changed'] = $row->pc_last_changed;
$this->coupons[$row->pc_pk]['number_of_codes'] = count($this->getCodesByCouponId($row->pc_pk));
$this->coupons[$row->pc_pk]['usage_of_codes'] = count($this->getUsedCouponsByCouponId($row->pc_pk));
$this->coupons[$row->pc_pk]['objects'] = $this->getObjectsByCouponId($row->pc_pk);
}
}

+ Here is the call graph for this function:

ilPaymentCoupons::getCouponUser ( )

Definition at line 185 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->coupon_user;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getCurrentCoupon ( )

Definition at line 365 of file class.ilPaymentCoupons.php.

References $current_coupon.

Referenced by addCouponForBookingId(), addTracking(), checkCouponValidity(), and getCouponBonus().

{
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getDescription ( )

Definition at line 201 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->description;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getFromDate ( )

Definition at line 225 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->from;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getFromDateEnabled ( )

Definition at line 241 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->from_date_enabled;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getId ( )

Definition at line 177 of file class.ilPaymentCoupons.php.

Referenced by assignObjectToCoupon(), delete(), isObjectAssignedToCoupon(), unassignObjectFromCoupon(), and update().

{
return $this->id;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getObjectsByCouponId (   $a_coupon_id)

Definition at line 472 of file class.ilPaymentCoupons.php.

References $objects, $res, and DB_FETCHMODE_OBJECT.

Referenced by getCouponByCode(), and getCoupons().

{
$this->objects = array();
$query = "SELECT * FROM payment_coupons_objects WHERE 1 AND pco_pc_fk = ".$this->db->quote($a_coupon_id);
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->objects[] = $row->ref_id;
}
return $this->objects;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchFromDateEnabled ( )

Definition at line 347 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_from_enabled;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchFromDay ( )

Definition at line 299 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_from_day;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchFromMonth ( )

Definition at line 307 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_from_month;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchFromYear ( )

Definition at line 315 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_from_year;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchTillDateEnabled ( )

Definition at line 355 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_till_enabled;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchTillDay ( )

Definition at line 323 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_till_day;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchTillMonth ( )

Definition at line 331 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_till_month;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchTillYear ( )

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

Referenced by getCoupons().

{
return $this->search_till_year;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchTitleType ( )

Definition at line 275 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_title_type;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchTitleValue ( )

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

Referenced by getCoupons().

{
return $this->search_title_value;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getSearchType ( )

Definition at line 291 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

{
return $this->search_type;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getTillDate ( )

Definition at line 233 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->till;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getTillDateEnabled ( )

Definition at line 249 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->till_date_enabled;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getTitle ( )

Definition at line 193 of file class.ilPaymentCoupons.php.

References $title.

Referenced by update().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getType ( )

Definition at line 209 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->type;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getUsedCouponsByCouponId (   $a_coupon_id)

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

References $res, $used_codes, and DB_FETCHMODE_OBJECT.

Referenced by getCoupons().

{
$this->used_codes = array();
$query = "SELECT *
FROM payment_coupons_tracking
INNER JOIN payment_coupons_codes ON pcc_pk = pct_pcc_fk
WHERE 1
AND pcc_pc_fk = ".$this->db->quote($a_coupon_id);
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->used_codes[$row->pct_pk]['pct_pk'] = $row->pct_pk;
$this->used_codes[$row->pct_pk]['pcc_code'] = $row->pcc_code;
$this->used_codes[$row->pct_pk]['usr_id'] = $row->usr_id;
$this->used_codes[$row->pct_pk]['pct_date'] = $row->pct_date;
$this->used_codes[$row->pct_pk]['pct_ps_fk'] = $row->pct_ps_fk;
}
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getUses ( )

Definition at line 265 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->uses;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getValue ( )

Definition at line 217 of file class.ilPaymentCoupons.php.

Referenced by update().

{
return $this->value;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::getVendorIds ( )
private

Definition at line 136 of file class.ilPaymentCoupons.php.

References $t, ilPaymentTrustees\_getTrusteesForCouponsByVendorId(), ilPaymentTrustees\_getVendorsForCouponsByTrusteeId(), and ilPaymentVendors\_isVendor().

Referenced by getCoupons().

{
$vendors[] = $this->user_obj->getId();
if (ilPaymentVendors::_isVendor($this->user_obj->getId()))
{
$ptObj = new ilPaymentTrustees($this->user_obj);
if ($trustees = $ptObj->getTrustees())
{
foreach ($trustees as $trustee)
{
if ((bool) $trustee["perm_coupons"])
{
$vendors[] = $trustee["trustee_id"];
}
}
}
}
if ($vend = ilPaymentTrustees::_getVendorsForCouponsByTrusteeId($this->user_obj->getId()))
{
foreach ($vend as $v)
{
$vendors[] = $v;
{
foreach ($trustees as $t)
{
$vendors[] = $t;
}
}
}
}
return $vendors ? $vendors : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPaymentCoupons::ilPaymentCoupons ( $user_obj,
  $a_vendor_view = false 
)

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

References $user_obj.

{
global $ilDB;
$this->db =& $ilDB;
$this->vendor_view = $a_vendor_view;
$this->user_obj =& $user_obj;
$this->COUPON_VALID = 0;
$this->COUPON_OUT_OF_DATE = 1;
$this->COUPON_TOO_MUCH_USED = 2;
$this->COUPON_NOT_FOUND = 3;
}
ilPaymentCoupons::isObjectAssignedToCoupon (   $a_ref_id)

Checks if an object is assigned to the current coupon.

public

Returns
bool

Definition at line 714 of file class.ilPaymentCoupons.php.

References $res, and getId().

{
if ($a_ref_id && is_numeric($this->getId()))
{
$query = "SELECT *
FROM payment_coupons_objects
WHERE 1
AND ref_id = ".$this->db->quote($a_ref_id)."
AND pco_pc_fk = ".$this->db->quote($this->getId())." ";
$res = $this->db->query($query);
if ($res->numRows()) return true;
return false;
}
return false;
}

+ Here is the call graph for this function:

ilPaymentCoupons::setChangeDate (   $a_date)

Definition at line 253 of file class.ilPaymentCoupons.php.

Referenced by getCouponById().

{
$this->change_date = $a_date;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setCouponUser (   $a_user_id)

Definition at line 181 of file class.ilPaymentCoupons.php.

Referenced by getCouponById().

{
$this->coupon_user = $a_user_id;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setCurrentCoupon (   $coupon = array())

Definition at line 361 of file class.ilPaymentCoupons.php.

Referenced by getCouponByCode().

{
$this->current_coupon = $coupon;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setDescription (   $a_description)

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

Referenced by getCouponById().

{
$this->description = $a_description;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setFromDate (   $a_from)

Definition at line 221 of file class.ilPaymentCoupons.php.

Referenced by getCouponById().

{
$this->from = $a_from;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setFromDateEnabled (   $a_from_date_enabled = 0)

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

Referenced by getCouponById().

{
$this->from_date_enabled = $a_from_date_enabled;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setId (   $a_id)

Definition at line 173 of file class.ilPaymentCoupons.php.

Referenced by getCouponByCode(), and getCouponById().

{
return $this->id = $a_id;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setSearchFromDateEnabled (   $a_from_enabled)

Definition at line 343 of file class.ilPaymentCoupons.php.

{
$this->search_from_enabled = $a_from_enabled;
}
ilPaymentCoupons::setSearchFromDay (   $a_day)

Definition at line 295 of file class.ilPaymentCoupons.php.

{
$this->search_from_day = $a_day;
}
ilPaymentCoupons::setSearchFromMonth (   $a_month)

Definition at line 303 of file class.ilPaymentCoupons.php.

{
$this->search_from_month = $a_month;
}
ilPaymentCoupons::setSearchFromYear (   $a_year)

Definition at line 311 of file class.ilPaymentCoupons.php.

{
$this->search_from_year = $a_year;
}
ilPaymentCoupons::setSearchTillDateEnabled (   $a_till_enabled)

Definition at line 351 of file class.ilPaymentCoupons.php.

{
$this->search_till_enabled = $a_till_enabled;
}
ilPaymentCoupons::setSearchTillDay (   $a_day)

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

{
$this->search_till_day = $a_day;
}
ilPaymentCoupons::setSearchTillMonth (   $a_month)

Definition at line 327 of file class.ilPaymentCoupons.php.

{
$this->search_till_month = $a_month;
}
ilPaymentCoupons::setSearchTillYear (   $a_year)

Definition at line 335 of file class.ilPaymentCoupons.php.

{
$this->search_till_year = $a_year;
}
ilPaymentCoupons::setSearchTitleType (   $a_title_type)

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

{
$this->search_title_type = $a_title_type;
}
ilPaymentCoupons::setSearchTitleValue (   $a_title_value)

Definition at line 279 of file class.ilPaymentCoupons.php.

{
$this->search_title_value = $a_title_value;
}
ilPaymentCoupons::setSearchType (   $a_type)

Definition at line 287 of file class.ilPaymentCoupons.php.

{
$this->search_type = $a_type;
}
ilPaymentCoupons::setTillDate (   $a_till)

Definition at line 229 of file class.ilPaymentCoupons.php.

Referenced by getCouponById().

{
$this->till = $a_till;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setTillDateEnabled (   $a_till_date_enabled = 0)

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

Referenced by getCouponById().

{
$this->till_date_enabled = $a_till_date_enabled;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setTitle (   $a_title)

Definition at line 189 of file class.ilPaymentCoupons.php.

Referenced by getCouponById().

{
$this->title = $a_title;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setType (   $a_type)

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

Referenced by getCouponById().

{
$this->type = $a_type;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setUses (   $a_uses)

Definition at line 261 of file class.ilPaymentCoupons.php.

Referenced by getCouponById().

{
$this->uses = $a_uses;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::setValue (   $a_value)

Definition at line 213 of file class.ilPaymentCoupons.php.

Referenced by getCouponById().

{
$this->value = $a_value;
}

+ Here is the caller graph for this function:

ilPaymentCoupons::unassignObjectFromCoupon (   $a_ref_id)

Unassigns an object from the current coupon.

public

Returns
bool

Definition at line 761 of file class.ilPaymentCoupons.php.

References getId().

{
if ($a_ref_id && is_numeric($this->getId()))
{
$query = "DELETE
FROM payment_coupons_objects
WHERE 1
AND ref_id = ".$this->db->quote($a_ref_id)."
AND pco_pc_fk = ".$this->db->quote($this->getId())." ";
$this->db->query($query);
return true;
}
return false;
}

+ Here is the call graph for this function:

ilPaymentCoupons::update ( )

Definition at line 393 of file class.ilPaymentCoupons.php.

References getChangeDate(), getCouponUser(), getDescription(), getFromDate(), getFromDateEnabled(), getId(), getTillDate(), getTillDateEnabled(), getTitle(), getType(), getUses(), and getValue().

{
if ($this->getId())
{
$query = "UPDATE payment_coupons
SET
pc_title = ".$this->db->quote($this->getTitle()).",
pc_description = ".$this->db->quote($this->getDescription()).",
pc_type = ".$this->db->quote($this->getType()).",
pc_value = ".$this->db->quote($this->getValue()).",
pc_from = ".$this->db->quote($this->getFromDate()).",
pc_till = ".$this->db->quote($this->getTillDate()).",
pc_from_enabled = ".$this->db->quote($this->getFromDateEnabled()).",
pc_till_enabled = ".$this->db->quote($this->getTillDateEnabled()).",
pc_uses = ".$this->db->quote($this->getUses()).",
pc_last_change_usr_id = ".$this->db->quote($this->getCouponUser()).",
pc_last_changed = ".$this->db->quote($this->getChangeDate())."
WHERE pc_pk = ".$this->db->quote($this->getId())." ";
$this->db->query($query);
return true;
}
return false;
}

+ Here is the call graph for this function:

Field Documentation

ilPaymentCoupons::$codes = array()
private

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

Referenced by getCodesByCouponId().

ilPaymentCoupons::$coupons = array()
private

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

Referenced by getCoupons().

ilPaymentCoupons::$current_coupon = array()
private

Definition at line 20 of file class.ilPaymentCoupons.php.

Referenced by addCouponForBookingId(), addTracking(), and getCurrentCoupon().

ilPaymentCoupons::$db = null
private

Definition at line 14 of file class.ilPaymentCoupons.php.

ilPaymentCoupons::$objects = array()
private

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

Referenced by getObjectsByCouponId().

ilPaymentCoupons::$used_codes = array()
private

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

Referenced by getUsedCouponsByCouponId().

ilPaymentCoupons::$user_obj = null
private

Definition at line 16 of file class.ilPaymentCoupons.php.

Referenced by ilPaymentCoupons().

ilPaymentCoupons::$vendor_view = false
private

Definition at line 17 of file class.ilPaymentCoupons.php.


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