OEModule\OphCiExamination\controllers\AdminController::actionSetNoTreatmentReasonStatus PHP 메소드

actionSetNoTreatmentReasonStatus() 공개 메소드

Update the enabled status of the given reason.
    public function actionSetNoTreatmentReasonStatus()
    {
        if ($model = models\OphCiExamination_InjectionManagementComplex_NoTreatmentReason::model()->findByPk((int) @$_POST['id'])) {
            if (!array_key_exists('enabled', $_POST)) {
                throw new \Exception('cannot determine status for reason');
            }
            if ($_POST['enabled']) {
                $model->active = true;
            } else {
                $model->active = false;
            }
            if (!$model->save()) {
                throw new \Exception('Unable to set reason status: ' . print_r($model->getErrors(), true));
            }
            Audit::add('admin', 'set-reason-status', @$_POST['id'], null, array('module' => 'OphCiExamination', 'model' => 'OphCiExamination_InjectionManagementComplex_NoTreatmentReason'));
        } else {
            throw new \Exception('Cannot find reason with id' . @$_POST['id']);
        }
    }