/**
  * @param RuleCriteriaType $ruleCriteriaType
  * @return RuleCriteria
  */
 function build($ruleCriteriaType, $value, $methodDetail)
 {
     $method = $ruleCriteriaType->method;
     $criteria = new RuleCriteriaAge($method == 'age_max' ? 'max' : 'min', $value, TimeUnit::from($methodDetail));
     $criteria->value = $value;
     return $criteria;
 }
Пример #2
0
 function _action_submit_intervals()
 {
     // parse results from response
     $ruleId = _post('id');
     $rule = $this->getRuleManager()->getRule($ruleId);
     // new intervals object
     $intervals = new ReminderIntervals();
     $change = false;
     foreach (ReminderIntervalType::values() as $type) {
         foreach (ReminderIntervalRange::values() as $range) {
             $amtKey = $type->code . "-" . $range->code;
             $timeKey = $amtKey . "-timeunit";
             $amt = _post($amtKey);
             $timeUnit = TimeUnit::from(_post($timeKey));
             if ($amt && $timeUnit) {
                 $detail = new ReminderIntervalDetail($type, $range, $amt, $timeUnit);
                 $intervals->addDetail($detail);
                 $change = true;
             }
         }
     }
     if ($change) {
         $this->getRuleManager()->updateIntervals($rule, $intervals);
     }
     $this->redirect("index.php?action=detail!view&id={$ruleId}");
 }
 /**
  *
  * @param string $ruleId
  * @param RuleCriteriaType $criteriaType
  */
 function buildNewInstance($ruleId, $criteriaType)
 {
     $criteria = parent::buildNewInstance($ruleId, $criteriaType);
     $criteria->interval = 1;
     $criteria->intervalType = TimeUnit::from(TimeUnit::Month);
     return $criteria;
 }
Пример #4
0
 function updateFromRequest()
 {
     parent::updateFromRequest();
     $age = _post("fld_value");
     $timeUnit = TimeUnit::from(_post("fld_timeunit"));
     $this->value = $age;
     $this->timeUnit = $timeUnit;
 }
Пример #5
0
 function updateFromRequest()
 {
     parent::updateFromRequest();
     $age = _post("fld_value");
     $timeUnit = TimeUnit::from(_post("fld_timeunit"));
     if ($timeUnit == null) {
         $timeUnit = TimeUnit::from(_post("fld_target_interval_type"));
     }
     $this->value = $age;
     $this->timeUnit = $timeUnit;
 }
Пример #6
0
 /**
  * Creates a ReminderIntervals object from rows in the rule_reminder table,
  * and sets it in the supplied Rule.
  * @param Rule $rule
  */
 private function fillRuleReminderIntervals($rule)
 {
     $stmt = sqlStatement(self::SQL_RULE_REMINDER_INTERVAL, array($rule->id));
     $reminderInterval = new ReminderIntervals();
     for ($iter = 0; $row = sqlFetchArray($stmt); $iter++) {
         $amount = $row['value'];
         $unit = TimeUnit::from($row['method_detail']);
         $methodParts = explode('_', $row['method']);
         $type = ReminderIntervalType::from($methodParts[0]);
         $range = ReminderIntervalRange::from($methodParts[2]);
         if (!is_null($type) && !is_null($range) && !is_null($unit)) {
             $detail = new ReminderIntervalDetail($type, $range, $amount, $unit);
             $reminderInterval->addDetail($detail);
         }
     }
     $rule->setReminderIntervals($reminderInterval);
 }
Пример #7
0
 function updateFromRequest()
 {
     $inclusion = "yes" == _post("fld_inclusion");
     $optional = "yes" == _post("fld_optional");
     $groupId = _post("group_id");
     $interval = _post("fld_target_interval");
     $intervalType = TimeUnit::from(_post("fld_target_interval_type"));
     $this->groupId = $groupId;
     $this->optional = $optional;
     $this->inclusion = $inclusion;
     $this->interval = $interval;
     $this->intervalType = $intervalType;
 }