static function getExpiryTimeOfSubscription($obj, $addPeriod = 0) { $date = $obj->getStartDate(); for ($i = 0; $i < $obj->getNoOfPeriodPaid() + $addPeriod; $i++) { if ($obj->getPeriod()) { $newTime = strtotime($date . ' + ' . $obj->getPeriod()); if ($newTime) { $date = Helper_Date::formatSqlDatetime($newTime); } } } $expiryTime = strtotime($date); return $expiryTime; }
static function getLastConfirmedOrdersOfMember($controller, $member, $startTs = NULL, $limit = NULL) { $orders = array(); if ($member) { $memberFilter = new SearchFilter(Order::$FIELD_META_MEMBER, SearchFilter::$EQUAL, $member->getId()); $statusFilter = new SearchFilter(Order::$FIELD_META_ORDER_STATUS, SearchFilter::$NOT_EQUAL, 'Pending'); $filters = array($memberFilter, $statusFilter); if ($startTs) { $timeFilter = new SearchFilter(Order::$FIELD_META_ORDER_DATE, SearchFilter::$GREATER_THAN_EQUAL, Helper_Date::formatSqlDatetime($startTs)); $filters[] = $timeFilter; } $sortField = Order::$FIELD_META_ORDER_DATE; $orders = $controller->getObjects('orders', 'getOrders', array(NULL, $filters, $sortField, TRUE, $limit)); } return $orders; }
static function _createBirthdayCoupon($controller, $member, $couponConf) { $coupon = new Coupon(); $coupon->setCouponType('product'); $coupon->setDiscountPercentage($couponConf['discount_percentage']); $coupon->setIsAllProducts(TRUE); $startDate = Helper_Date::formatSqlDatetime(strtotime(date('F Y', $controller->now))); $endDate = Helper_Date::formatSqlDatetime(strtotime(date('F Y', $controller->now) . ' +1 month')); $coupon->setStartDate($startDate); $coupon->setExpiryDate($endDate); $coupon->setNumOfUsage(1); $curYear = date('Y', $controller->now); $couponCode = 'BIRTHDAY-' . $member->getEmail() . "-{$curYear}"; $coupon->setCouponCode($couponCode); $name = $member->getFirstName(); $nyears = $curYear - date('Y', strtotime($member->getDateOfBirth())); $th = Helper_Math::getTh($nyears); $coupon->setTitle("{$name}'s {$nyears}{$th} Birthday"); return $coupon; }