protected function applyRespondentRelation(\MUtil_Model_ModelAbstract $model, array &$itemData)
    {
        $model->set('gro_id_survey', 'onchange', 'this.form.submit();');
        if (!empty($itemData['gro_id_survey']) && $model->has('gro_id_relationfield')) {
            $forStaff = $this->tracker->getSurvey($itemData['gro_id_survey'])->isTakenByStaff();
            if (!$forStaff) {
                $empty = array('-1' => $this->_('Patient'));

                $relations = $this->getRespondentRelationFields();
                if (!empty($relations)) {
                    $relations = $empty + $relations;
                    $model->set('gro_id_relationfield', 'label', $this->_('Assigned to'), 'multiOptions', $relations, 'order', 25);
                }
                $model->del('ggp_name');
            } else {
                $model->set('ggp_name', 'label', $this->translateAdapter->_('Assigned to'), 'elementClass', 'Exhibitor', 'order', 25);
                $model->set('gro_id_relationfield', 'elementClass', 'hidden');

                $itemData['ggp_name'] = $this->db->fetchOne('select ggp_name from gems__groups join gems__surveys on ggp_id_group = gsu_id_primary_group and gsu_id_survey = ?', $itemData['gro_id_survey']);
                if (!is_null($itemData['gro_id_relationfield'])) {
                    $itemData['gro_id_relationfield'] = null;
                }
            }
        } else {
            $model->del('gro_id_relationfield', 'label');
            $model->del('ggp_name');
            if ($model->has('gro_id_relationfield')) {
                $itemData['gro_id_relationfield'] = null;
            }
        }
    }
protected function applyRespondentRelation(\MUtil_Model_ModelAbstract $model, array &$itemData)
    {
        $model->set('gro_id_survey', 'onchange', 'this.form.submit();');
        if (!empty($itemData['gro_id_survey']) && $model->has('gro_id_relationfield')) {
            $forStaff = $this->tracker->getSurvey($itemData['gro_id_survey'])->isTakenByStaff();
            if (!$forStaff) {
                $empty = array('-1' => $this->_('Patient'));

                $relations = $this->getRespondentRelationFields();
                if (!empty($relations)) {
                    $relations = $empty + $relations;
                    $model->set('gro_id_relationfield', 'label', $this->_('Assigned to'), 'multiOptions', $relations, 'order', 25);
                }
                $model->del('ggp_name');
            } else {
                $model->set('ggp_name', 'label', $this->translateAdapter->_('Assigned to'), 'elementClass', 'Exhibitor', 'order', 25);
                $model->set('gro_id_relationfield', 'elementClass', 'hidden');

                $itemData['ggp_name'] = $this->db->fetchOne('select ggp_name from gems__groups join gems__surveys on ggp_id_group = gsu_id_primary_group and gsu_id_survey = ?', $itemData['gro_id_survey']);
                if (!is_null($itemData['gro_id_relationfield'])) {
                    $itemData['gro_id_relationfield'] = null;
                }
            }
        } else {
            $model->del('gro_id_relationfield', 'label');
            $model->del('ggp_name');
            if ($model->has('gro_id_relationfield')) {
                $itemData['gro_id_relationfield'] = null;
            }
        }
    }
protected function applyRespondentRelation ( \ MUtil_Model_ModelAbstract $ model , array & $ itemData ) { $ model -> set ( 'gro_id_survey' , 'onchange' , 'this.form.submit();' ) ; if ( ! empty ( $ itemData [ 'gro_id_survey' ] ) && $ model -> has ( 'gro_id_relationfield' ) ) { $ forStaff = $ this -> tracker -> getSurvey ( $ itemData [ 'gro_id_survey' ] ) -> isTakenByStaff ( ) ; if ( ! $ forStaff ) { $ empty = array ( '-1' => $ this -> _ ( 'Patient' ) ) ; $ relations = $ this -> getRespondentRelationFields ( ) ; if ( ! empty ( $ relations ) ) { $ relations = $ empty + $ relations ; $ model -> set ( 'gro_id_relationfield' , 'label' , $ this -> _ ( 'Assigned to' ) , 'multiOptions' , $ relations , 'order' , 25 ) ; } $ model -> del ( 'ggp_name' ) ; } else { $ model -> set ( 'ggp_name' , 'label' , $ this -> translateAdapter -> _ ( 'Assigned to' ) , 'elementClass' , 'Exhibitor' , 'order' , 25 ) ; $ model -> set ( 'gro_id_relationfield' , 'elementClass' , 'hidden' ) ; $ itemData [ 'ggp_name' ] = $ this -> db -> fetchOne ( 'select ggp_name from gems__groups join gems__surveys on ggp_id_group = gsu_id_primary_group and gsu_id_survey = ?' , $ itemData [ 'gro_id_survey' ] ) ; if ( ! is_null ( $ itemData [ 'gro_id_relationfield' ] ) ) { $ itemData [ 'gro_id_relationfield' ] = null ; } } } else { $ model -> del ( 'gro_id_relationfield' , 'label' ) ; $ model -> del ( 'ggp_name' ) ; if ( $ model -> has ( 'gro_id_relationfield' ) ) { $ itemData [ 'gro_id_relationfield' ] = null ; } } }
Apply respondent relation settings to the round model

For respondent surveys, we allow to set a relation, with possible choices:

null => the respondent
0    => undefined (specifiy when assigning)
>0   => the id of the track field of type relation to use

@param \MUtil_Model_ModelAbstract $model The round model
@param array $itemData    The current items data

@return boolean True if the update changed values (usually by changed selection lists).
Apply respondent relation settings to the round model