Ejemplo n.º 1
0
 /**
  * Determine in which discount set the registration date falls
  *
  * @param  integer  $entityId      entity id to be searched
  * @param  string   $entityTable   entity table to be searched
  *
  * @return integer  $dao->id       discount id of the set which matches
  *                                 the date criteria
  */
 static function findSet($entityID, $entityTable)
 {
     if (empty($entityID) || empty($entityTable)) {
         // adding this here, to trap errors if values are not sent
         CRM_Core_Error::fatal();
         return NULL;
     }
     $dao = new CRM_Core_DAO_Discount();
     $dao->entity_id = $entityID;
     $dao->entity_table = $entityTable;
     $dao->find();
     while ($dao->fetch()) {
         $endDate = $dao->end_date;
         // if end date is not we consider current date as end date
         if (!$endDate) {
             $endDate = date('Ymd');
         }
         $falls = CRM_Utils_Date::getRange($dao->start_date, $endDate);
         if ($falls == TRUE) {
             return $dao->id;
         }
     }
     return FALSE;
 }
Ejemplo n.º 2
0
 /**
  * Determine in which discount set the registration date falls
  *
  * @param  integer  $entityId      entity id to be searched 
  * @param  string   $entityTable   entity table to be searched 
  *
  * @return integer  $dao->id       discount id of the set which matches
  *                                 the date criteria
  */
 static function findSet($entityID, $entityTable)
 {
     if (empty($entityID) || empty($entityTable)) {
         // adding this here, to trap errors if values are not sent
         CRM_Core_Error::fatal();
         return null;
     }
     require_once 'CRM/Core/DAO/Discount.php';
     $dao = new CRM_Core_DAO_Discount();
     $dao->entity_id = $entityID;
     $dao->entity_table = $entityTable;
     $dao->find();
     require_once "CRM/Utils/Date.php";
     while ($dao->fetch()) {
         $endDate = $dao->end_date;
         // if end date is not we consider current date as end date
         if (!$endDate) {
             $endDate = date('Ymd');
         }
         $falls = CRM_Utils_Date::getRange($dao->start_date, $endDate);
         if ($falls == true) {
             return $dao->id;
         }
     }
     return false;
 }