private static $singleton;
/**
- * @param bool $reset whether to forcibly rebuild the entire container
- * @return \Symfony\Component\DependencyInjection\TaggedContainerInterface
+ * @param bool $reset
+ * Whether to forcibly rebuild the entire container.
+ * @return SequenceListener
*/
public static function singleton($reset = FALSE) {
if ($reset || self::$singleton === NULL) {
return self::$singleton;
}
+ /**
+ * @param \Civi\CCase\Event\CaseChangeEvent $event
+ */
public static function onCaseChange_static(\Civi\CCase\Event\CaseChangeEvent $event) {
self::singleton()->onCaseChange($event);
}
+ /**
+ * @param \Civi\CCase\Event\CaseChangeEvent $event
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @return void
+ */
public function onCaseChange(\Civi\CCase\Event\CaseChangeEvent $event) {
/** @var \Civi\CCase\Analyzer $analyzer */
$analyzer = $event->analyzer;
}
}
- // OK, the activity has completed every step in the sequence!
+ //CRM-17452 - Close the case only if all the activities are complete
+ $activities = $analyzer->getActivities();
+ foreach ($activities as $activity) {
+ if ($activity['status_id'] != $actStatuses['Completed']) {
+ return;
+ }
+ }
+
+ // OK, the all activities have completed
civicrm_api3('Case', 'create', array(
- 'id' => $analyzer->getCaseId(),
+ 'id' => $analyzer->getCaseId(),
'status_id' => 'Closed',
));
$analyzer->flush();
}
/**
- * @param Analyzer $analyzer the case being analyzed -- to which we want to add an activity
+ * @param Analyzer $analyzer
+ * The case being analyzed -- to which we want to add an activity.
* @param \SimpleXMLElement $actXML the <ActivityType> tag which describes the new activity
*/
public function createActivity(Analyzer $analyzer, \SimpleXMLElement $actXML) {
$r = civicrm_api3('Activity', 'create', $params);
$analyzer->flush();
}
-}
\ No newline at end of file
+
+}