示例#1
0
 public function actionAddElementTypeToWorkflowStep()
 {
     $et_exam = \EventType::model()->find('class_name=?', array('OphCiExamination'));
     if (!($element_type = \ElementType::model()->find('event_type_id = ? and id = ?', array($et_exam->id, @$_POST['element_type_id'])))) {
         throw new \Exception('Unknown examination element type: ' . @$_POST['element_type_id']);
     }
     if (!($step = models\OphCiExamination_ElementSet::model()->findByPk(@$_POST['step_id']))) {
         throw new \Exception('Unknown element set: ' . @$_POST['step_id']);
     }
     if (!models\OphCiExamination_ElementSetItem::model()->find('set_id=? and element_type_id=?', array($step->id, $element_type->id))) {
         $item = new models\OphCiExamination_ElementSetItem();
         $item->set_id = $step->id;
         $item->element_type_id = $element_type->id;
         if (!$item->save()) {
             throw new \Exception('Unable to save element set item: ' . print_r($item->getErrors(), true));
         }
     }
     echo '1';
 }