Пример #1
0
 /**
  * If userID is set, then return valid user coupons count, else unused valid coupons count
  * @param $userID
  * @return $count
  */
 public function getValidCouponsCount($userID = null) {
     $select = $this->createCouponsSelect($userID);
     $select->select->addAll(Pap_Db_Table_Coupons::getInstance());
     $coupon = new Pap_Db_Coupon();
     $coupons = $coupon->loadCollectionFromRecordset($select->getAllRows());
     $validCouponsCount = 0;
     foreach ($coupons as $coupon) {
         if($coupon->isValid()) {
             $validCouponsCount++;
         }
     }
     return $validCouponsCount;
 }