/**
  * Set those values needed for editing
  *
  * @param boolean $create True when creating
  * @return \Gems_Model_RespondentModel
  */
 public function applyEditSettings($create = false)
 {
     $this->applyDetailSettings();
     $this->copyKeys();
     // The user can edit the keys.
     $translated = $this->util->getTranslated();
     $ucfirst = new \Zend_Filter_Callback('ucfirst');
     if ($this->hashSsn !== self::SSN_HIDE) {
         $onblur = new \MUtil_Html_JavascriptArrayAttribute('onblur');
         $onblur->addSubmitOnChange('this.value');
         $this->set('grs_ssn', 'onblur', $onblur->render($this->view), 'validator[]', $this->createUniqueValidator('grs_ssn'));
     }
     $this->set('gr2o_id_organization', 'default', $this->currentUser->getCurrentOrganizationId());
     $this->setIfExists('gr2o_patient_nr', 'size', 15, 'minlength', 4, 'validator', $this->createUniqueValidator(array('gr2o_patient_nr', 'gr2o_id_organization'), array('gr2o_id_user' => 'grs_id_user', 'gr2o_id_organization')));
     $this->set('grs_id_user');
     $this->set('grs_email', 'required', true, 'autoInsertNotEmptyValidator', false, 'size', 30, 'validator', 'SimpleEmail');
     $this->addColumn('CASE WHEN grs_email IS NULL OR LENGTH(TRIM(grs_email)) = 0 THEN 1 ELSE 0 END', 'calc_email');
     $this->set('calc_email', 'label', $this->_('Respondent has no e-mail'), 'elementClass', 'Checkbox', 'required', true, 'order', $this->getOrder('grs_email') + 1, 'validator', new \Gems_Validate_OneOf($this->_('Respondent has no e-mail'), 'grs_email', $this->get('grs_email', 'label')));
     $this->set('gr2o_mailable', 'label', $this->_('May be mailed'), 'elementClass', 'radio', 'multiOptions', $translated->getYesNo(), 'separator', ' ');
     $this->setIfExists('grs_first_name', 'filter', $ucfirst);
     $this->setIfExists('grs_last_name', 'filter', $ucfirst, 'required', true);
     $this->setIfExists('grs_partner_last_name', 'filter', new \Zend_Filter_Callback('ucfirst'));
     $this->setIfExists('grs_gender', 'elementClass', 'Radio', 'separator', '', 'multiOptions', $translated->getGenders(), 'tab', $this->_('Medical data'));
     $this->setIfExists('grs_birthday', 'jQueryParams', array('defaultDate' => '-30y', 'maxDate' => 0, 'yearRange' => 'c-130:c0'), 'elementClass', 'Date', 'validator', new \MUtil_Validate_Date_DateBefore());
     $this->setIfExists('gr2o_treatment', 'size', 30);
     $this->setIfExists('gr2o_comments', 'elementClass', 'Textarea', 'rows', 4, 'cols', 60);
     $this->setIfExists('grs_address_1', 'size', 40, 'description', $this->_('With housenumber'), 'filter', $ucfirst);
     $this->setIfExists('grs_address_2', 'size', 40);
     $this->setIfExists('grs_city', 'filter', $ucfirst);
     $this->setIfExists('grs_phone_1', 'size', 15);
     $this->setIfExists('grs_phone_2', 'size', 15);
     $this->setIfExists('grs_phone_3', 'size', 15);
     $this->setIfExists('grs_phone_4', 'size', 15);
     $this->setIfExists('gr2o_consent', 'default', $this->util->getDefaultConsent(), 'elementClass', 'Radio', 'separator', ' ', 'required', true);
     $this->setMulti(array('name', 'row_class', 'resp_deleted'), 'elementClass', 'None');
     $this->setMulti($this->getItemsFor('table', 'gems__reception_codes'), 'elementClass', 'None');
     if ($create) {
         $this->setIfExists('gr2o_changed', 'elementClass', 'None');
         $this->setIfExists('gr2o_changed_by', 'elementClass', 'None');
         $this->setIfExists('gr2o_created', 'elementClass', 'None');
         $this->setIfExists('gr2o_created_by', 'elementClass', 'None');
     } else {
         $this->setIfExists('gr2o_changed', 'elementClass', 'Exhibitor');
         $this->setIfExists('gr2o_changed_by', 'elementClass', 'Exhibitor');
         $this->setIfExists('gr2o_created', 'elementClass', 'Exhibitor');
         $this->setIfExists('gr2o_created_by', 'elementClass', 'Exhibitor');
     }
     return $this;
 }
Пример #2
0
 /**
  * Load project specific respondent model or general Gems model otherwise
  *
  * @param boolean $detail When true more information needed for individual item display is added to the model.
  * @return \Gems_Model_RespondentModel
  */
 public function getRespondentModel($detailed)
 {
     static $model;
     static $is_detailed;
     if ($model && $is_detailed === $detailed) {
         return $model;
     }
     $model = $this->createRespondentModel();
     $translated = $this->util->getTranslated();
     $model->setIfExists('gr2o_patient_nr', 'label', $this->translate->_('Respondent nr'));
     if (!$detailed && $model->isMultiOrganization()) {
         $model->addTable('gems__organizations', array('gr2o_id_organization' => 'gor_id_organization'));
         $model->setIfExists('gor_name', 'label', $this->translate->_('Organization'));
     }
     $model->setIfExists('gr2o_opened', 'label', $this->translate->_('Opened'), 'formatFunction', $translated->formatDateTime);
     $model->setIfExists('gr2o_consent', 'label', $this->translate->_('Consent'), 'multiOptions', $this->util->getDbLookup()->getUserConsents, 'default', $this->util->getDefaultConsent());
     $model->setIfExists('grs_email', 'label', $this->translate->_('E-Mail'));
     $model->setIfExists('gr2o_mailable', 'label', $this->translate->_('May be mailed'), 'elementClass', 'radio', 'separator', ' ', 'multiOptions', array('1' => $this->translate->_('Yes'), '0' => $this->translate->_('No')));
     if ($detailed) {
         $model->copyKeys();
         // The user can edit the keys.
         $model->setIfExists('grs_gender', 'label', $this->translate->_('Gender'), 'multiOptions', $translated->getGenderHello());
         $model->setIfExists('grs_first_name', 'label', $this->translate->_('First name'));
         $model->setIfExists('grs_surname_prefix', 'label', $this->translate->_('Surname prefix'));
         $model->setIfExists('grs_last_name', 'label', $this->translate->_('Last name'));
     }
     $model->set('name', 'label', $this->translate->_('Name'), 'column_expression', new \Zend_Db_Expr("CONCAT(COALESCE(CONCAT(grs_last_name, ', '), '-, '), COALESCE(CONCAT(grs_first_name, ' '), ''), COALESCE(grs_surname_prefix, ''))"), 'fieldlist', array('grs_last_name', 'grs_first_name', 'grs_surname_prefix'));
     $model->setIfExists('grs_address_1', 'label', $this->translate->_('Street'));
     $model->setIfExists('grs_address_2', 'label', ' ');
     $model->setIfExists('grs_zipcode', 'label', $this->translate->_('Zipcode'));
     $model->setIfExists('grs_city', 'label', $this->translate->_('City'));
     $model->setIfExists('grs_phone_1', 'label', $this->translate->_('Phone'));
     $model->setIfExists('grs_birthday', 'label', $this->translate->_('Birthday'), 'dateFormat', \Zend_Date::DATE_MEDIUM);
     $model->setIfExists('grs_iso_lang', 'default', 'nl');
     return $model;
 }