/** * Add the model settings like the elementClass for this field. * * elementClass is overwritten when this field is read only, unless you override it again in getDataModelSettings() * * @param array $settings The settings set so far */ protected function addModelSettings(array &$settings) { $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $multi = explode(parent::FIELD_SEP, $this->_fieldDefinition['gtf_field_values']); $settings['elementClass'] = 'Select'; $settings['multiOptions'] = $empty + array_combine($multi, $multi); }
/** * Place to set the data to display * * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge * @return void */ protected function addTableCells(\MUtil_Model_Bridge_VerticalTableBridge $bridge) { $bridge->setColumnCount(1); $HTML = \MUtil_Html::create(); $bridge->tdh($this->getCaption(), array('colspan' => 2)); // Caption for tracks $trackLabel = $this->_('Assigned tracks'); if ($menuItem = $this->findMenuItem('track', 'index')) { $href = $menuItem->toHRefAttribute($this->request, $bridge); $bridge->tdh(array('class' => 'linked'))->a($href, $trackLabel); } else { $bridge->tdh($trackLabel, array('class' => 'linked')); } $bridge->tr(); // ROW 1 $bridge->addItem($bridge->gr2o_patient_nr, $this->_('Respondent nr: ')); $rowspan = 10; // Column for tracks $tracksModel = $this->model->getRespondentTracksModel(); $tracksData = \MUtil_Lazy::repeat($tracksModel->load(array('gr2o_patient_nr' => $this->repeater->gr2o_patient_nr, 'gr2o_id_organization' => $this->repeater->gr2o_id_organization), array('gr2t_created' => SORT_DESC))); $tracksList = $HTML->div($tracksData, array('class' => 'tracksList')); $tracksList->setOnEmpty($this->_('No tracks')); if ($menuItem = $this->findMenuItem('track', 'show-track')) { $href = $menuItem->toHRefAttribute($tracksData, array('gr2o_patient_nr' => $this->repeater->gr2o_patient_nr)); $tracksTarget = $tracksList->p()->a($href); } else { $tracksTarget = $tracksList->p(); } $tracksTarget->strong($tracksData->gtr_track_name); $tracksTarget[] = ' '; $tracksTarget->em($tracksData->gr2t_track_info, array('renderWithoutContent' => false)); $tracksTarget[] = ' '; $tracksTarget[] = \MUtil_Lazy::call($this->util->getTranslated()->formatDate, $tracksData->gr2t_created); $bridge->td($tracksList, array('rowspan' => $rowspan, 'class' => 'linked tracksList')); // OTHER ROWS $bridge->addItem($HTML->spaced($bridge->itemIf('grs_last_name', array($bridge->grs_last_name, ',')), $bridge->grs_first_name, $bridge->grs_surname_prefix), $this->_('Respondent')); $bridge->addItem('grs_gender'); $bridge->addItem('grs_birthday'); $bridge->addItem('grs_email'); $bridge->addItem('gr2o_created'); $bridge->addItem('gr2o_created_by'); if ($this->onclick) { // TODO: can we not use $repeater? $href = array('location.href=\'', $this->onclick, '\';'); foreach ($bridge->tbody() as $tr) { foreach ($tr as $td) { if (strpos($td->class, 'linked') === false) { $td->onclick = $href; } else { $td->onclick = 'event.cancelBubble=true;'; } } } $bridge->tbody()->onclick = '// Dummy for CSS'; } }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { $model = $this->loader->getTracker()->getRespondentTrackModel(); $model->addColumn('CONCAT(gr2t_completed, \'' . $this->_(' of ') . '\', gr2t_count)', 'progress'); $model->resetOrder(); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gr2t_track_info', 'label', $this->_('Description')); $model->set('gr2t_start_date', 'label', $this->_('Start'), 'formatFunction', $this->util->getTranslated()->formatDate, 'default', \MUtil_Date::format(new \Zend_Date(), 'dd-MM-yyyy')); $model->set('gr2t_reception_code'); $model->set('progress', 'label', $this->_('Progress')); // , 'tdClass', 'rightAlign', 'thClass', 'rightAlign'); $model->set('assigned_by', 'label', $this->_('Assigned by')); return $model; }
/** * Called after the check that all required registry values * have been set correctly has run. * * @return void * / public function afterRegistry() { parent::afterRegistry(); } /** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if (!$this->importModel instanceof \MUtil_Model_ModelAbstract) { $surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID); if ($surveyId) { $this->formData['survey'] = $surveyId; $this->_survey = $this->loader->getTracker()->getSurvey($surveyId); $surveys[$surveyId] = $this->_survey->getName(); $elementClass = 'Exhibitor'; $tracks = $this->util->getTranslated()->getEmptyDropdownArray() + $this->util->getTrackData()->getTracksBySurvey($surveyId); } else { $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $trackData = $this->util->getTrackData(); $surveys = $empty + $trackData->getActiveSurveys(); $tracks = $empty + $trackData->getAllTracks(); $elementClass = 'Select'; } parent::createModel(); $order = $this->importModel->getOrder('trans') - 5; $this->importModel->set('survey', 'label', $this->_('Survey'), 'elementClass', $elementClass, 'multiOptions', $surveys, 'onchange', 'this.form.submit();', 'order', $order, 'required', true); $this->importModel->set('track', 'label', $this->_('Track'), 'description', $this->_('Optionally assign answers only within a single track'), 'multiOptions', $tracks); $this->importModel->set('skipUnknownPatients', 'label', $this->_('Skip unknowns'), 'default', 0, 'description', $this->_('What to do when the respondent does not exist'), 'elementClass', 'Checkbox', 'multiOptions', $this->util->getTranslated()->getYesNo()); $tokenCompleted = array(\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_OVERWRITE => $this->_('Delete old token and create new'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_DOUBLE => $this->_('Create new extra set of answers'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR => $this->_('Abort the import'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_SKIP => $this->_('Skip the token')); $this->importModel->set('tokenCompleted', 'label', $this->_('When token completed'), 'default', \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR, 'description', $this->_('What to do when an imported token has already been completed'), 'elementClass', 'Radio', 'multiOptions', $tokenCompleted); $tokenTreatments = array(\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR => $this->_('Abort the import'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_SKIP => $this->_('Skip the token')); $this->importModel->set('noToken', 'label', $this->_('Token does not exist'), 'default', \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR, 'description', $this->_('What to do when no token exist to import to'), 'elementClass', 'Radio', 'multiOptions', $tokenTreatments); if (\MUtil_Bootstrap::enabled()) { $this->importModel->set('tokenCompleted', 'separator', ''); } else { $this->importModel->set('trans', 'separator', '<br/>'); } } return $this->importModel; }
/** * Sets the labels, format functions, etc... * * @return \Gems_Tracker_Model_StandardTokenModel */ public function applyFormatting() { $this->resetOrder(); $dbLookup = $this->util->getDbLookup(); $translated = $this->util->getTranslated(); // Token id & respondent $this->set('gto_id_token', 'label', $this->_('Token'), 'elementClass', 'Exhibitor', 'formatFunction', 'strtoupper'); $this->set('gr2o_patient_nr', 'label', $this->_('Respondent nr'), 'elementClass', 'Exhibitor'); $this->set('respondent_name', 'label', $this->_('Respondent name'), 'elementClass', 'Exhibitor'); $this->set('gto_id_organization', 'label', $this->_('Organization'), 'elementClass', 'Exhibitor', 'multiOptions', $dbLookup->getOrganizationsWithRespondents()); // Track, round & survey $this->set('gtr_track_name', 'label', $this->_('Track'), 'elementClass', 'Exhibitor'); $this->set('gr2t_track_info', 'label', $this->_('Description'), 'elementClass', 'Exhibitor'); $this->set('gto_round_description', 'label', $this->_('Round'), 'elementClass', 'Exhibitor'); $this->set('gsu_survey_name', 'label', $this->_('Survey'), 'elementClass', 'Exhibitor'); $this->set('ggp_name', 'label', $this->_('Assigned to'), 'elementClass', 'Exhibitor'); // Token, editable part $manual = $translated->getDateCalculationOptions(); $this->set('gto_valid_from_manual', 'label', $this->_('Set valid from'), 'description', $this->_('Manually set dates are fixed an will never be (re)calculated.'), 'elementClass', 'Radio', 'multiOptions', $manual, 'separator', ' '); $this->set('gto_valid_from', 'label', $this->_('Valid from'), 'elementClass', 'Date', 'formatFunction', $translated->formatDateNever, 'tdClass', 'date'); $this->set('gto_valid_until_manual', 'label', $this->_('Set valid until'), 'description', $this->_('Manually set dates are fixed an will never be (re)calculated.'), 'elementClass', 'Radio', 'multiOptions', $manual, 'separator', ' '); $this->set('gto_valid_until', 'label', $this->_('Valid until'), 'elementClass', 'Date', 'formatFunction', $translated->formatDateForever, 'tdClass', 'date'); $this->set('gto_comment', 'label', $this->_('Comments'), 'cols', 50, 'elementClass', 'Textarea', 'rows', 3, 'tdClass', 'pre'); // Token, display part $this->set('gto_mail_sent_date', 'label', $this->_('Last contact'), 'elementClass', 'Exhibitor', 'formatFunction', $translated->formatDateNever, 'tdClass', 'date'); $this->set('gto_mail_sent_num', 'label', $this->_('Number of contact moments'), 'elementClass', 'Exhibitor'); $this->set('gto_completion_time', 'label', $this->_('Completed'), 'elementClass', 'Exhibitor', 'formatFunction', $translated->formatDateNa, 'tdClass', 'date'); $this->set('gto_duration_in_sec', 'label', $this->_('Duration in seconds'), 'elementClass', 'Exhibitor'); $this->set('gto_result', 'label', $this->_('Score'), 'elementClass', 'Exhibitor'); $this->set('grc_description', 'label', $this->_('Reception code'), 'formatFunction', array($this->translate, '_'), 'elementClass', 'Exhibitor'); $this->set('gto_changed', 'label', $this->_('Changed on'), 'elementClass', 'Exhibitor', 'formatFunction', $translated->formatDateUnknown); $this->set('assigned_by', 'label', $this->_('Assigned by'), 'elementClass', 'Exhibitor'); return $this; }
/** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed * parameter was added, because the most common use of action is a split between detailed * and summarized actions. * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return \MUtil_Model_ModelAbstract */ protected function createModel($detailed, $action) { $model = new \MUtil_Model_TableModel('gems__locations'); $yesNo = $this->util->getTranslated()->getYesNo(); \Gems_Model::setChangeFieldsByPrefix($model, 'glo'); $model->setDeleteValues('glo_active', 0); $model->set('glo_name', 'label', $this->_('Location'), 'required', true); $model->set('glo_organizations', 'label', $this->_('Organizations'), 'description', $this->_('Checked organizations see this organizations respondents.'), 'elementClass', 'MultiCheckbox', 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'noSort', true); $tp = new \MUtil_Model_Type_ConcatenatedRow(':', ', '); $tp->apply($model, 'glo_organizations'); $model->setIfExists('glo_match_to', 'label', $this->_('Import matches'), 'description', $this->_("Split multiple import matches using '|'.")); $model->setIfExists('glo_code', 'label', $this->_('Location code'), 'size', 10, 'description', $this->_('Optional code name to link the location to program code.')); $model->setIfExists('glo_url', 'label', $this->_('Location url'), 'description', $this->_('Complete url for location: http://www.domain.etc'), 'validator', 'Url'); $model->setIfExists('glo_url_route', 'label', $this->_('Location route url'), 'description', $this->_('Complete url for route to location: http://www.domain.etc'), 'validator', 'Url'); $model->setIfExists('glo_address_1', 'label', $this->_('Street')); $model->setIfExists('glo_address_2', 'label', ' '); $model->setIfExists('glo_zipcode', 'label', $this->_('Zipcode'), 'size', 7, 'description', $this->_('E.g.: 0000 AA'), 'filter', new \Gems_Filter_DutchZipcode()); $model->setIfExists('glo_city', 'label', $this->_('City')); $model->setIfExists('glo_region', 'label', $this->_('Region')); $model->setIfExists('glo_iso_country', 'label', $this->_('Country'), 'multiOptions', $this->util->getLocalized()->getCountries()); $model->setIfExists('glo_phone_1', 'label', $this->_('Phone')); $model->setIfExists('glo_phone_2', 'label', $this->_('Phone 2')); $model->setIfExists('glo_phone_3', 'label', $this->_('Phone 3')); $model->setIfExists('glo_phone_4', 'label', $this->_('Phone 4')); $model->setIfExists('glo_active', 'label', $this->_('Active'), 'description', $this->_('Inactive means assignable only through automatich processes.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo); $model->setIfExists('glo_filter', 'label', $this->_('Filter'), 'description', $this->_('When checked appointments with these locations are not imported.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo); $model->addColumn("CASE WHEN glo_active = 1 THEN '' ELSE 'deleted' END", 'row_class'); return $model; }
/** * * @param boolean $detailed True when the current action is not in $summarizedActions. */ public function applySetting($detailed = true) { if ($detailed) { $this->addLeftTable('gems__comm_templates', array('grco_id_message' => 'gct_id_template')); } $this->resetOrder(); $this->set('grco_created', 'label', $this->_('Date sent')); if ($detailed) { $this->set('grco_created', 'formatFunction', $this->util->getTranslated()->formatDate); } $this->set('gr2o_patient_nr', 'label', $this->_('Respondent nr')); $this->set('respondent_name', 'label', $this->_('Receiver')); $this->set('grco_address', 'label', $this->_('To address'), 'itemDisplay', array('MUtil_Html_AElement', 'ifmail')); $this->set('assigned_by', 'label', $this->_('Sender')); $this->set('grco_sender', 'label', $this->_('From address'), 'itemDisplay', array('MUtil_Html_AElement', 'ifmail')); $this->set('grco_id_token', 'label', $this->_('Token'), 'itemDisplay', array($this, 'displayToken')); $this->set('grco_topic', 'label', $this->_('Subject')); $this->set('gtr_track_name', 'label', $this->_('Track')); $this->set('gsu_survey_name', 'label', $this->_('Survey')); $this->set('filler', 'label', $this->_('Fill out by')); $this->set('status', 'label', $this->_('Status'), 'formatFunction', array($this->util->getTokenData(), 'getStatusDescription')); if ($detailed) { $this->set('gct_name', 'label', $this->_('Template')); } }
/** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed * parameter was added, because the most common use of action is a split between detailed * and summarized actions. * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return \MUtil_Model_ModelAbstract */ protected function createModel($detailed, $action) { $translated = $this->util->getTranslated(); $model = new \MUtil_Model_TableModel('gems__agenda_activities'); \Gems_Model::setChangeFieldsByPrefix($model, 'gaa'); $model->setDeleteValues('gaa_active', 0); $model->set('gaa_name', 'label', $this->_('Activity'), 'description', $this->_('An activity is a high level description about an appointment: e.g. consult, check-up, diet, operation, physiotherapy or other.'), 'required', true); $model->setIfExists('gaa_id_organization', 'label', $this->_('Organization'), 'description', $this->_('Optional, an import match with an organization has priority over those without.'), 'multiOptions', $translated->getEmptyDropdownArray() + $this->util->getDbLookup()->getOrganizations()); $model->setIfExists('gaa_name_for_resp', 'label', $this->_('Respondent explanation'), 'description', $this->_('Alternative description to use with respondents.')); $model->setIfExists('gaa_match_to', 'label', $this->_('Import matches'), 'description', $this->_("Split multiple import matches using '|'.")); $model->setIfExists('gaa_code', 'label', $this->_('Activity code'), 'size', 10, 'description', $this->_('Optional code name to link the activity to program code.')); $model->setIfExists('gaa_active', 'label', $this->_('Active'), 'description', $this->_('Inactive means assignable only through automatich processes.'), 'elementClass', 'Checkbox', 'multiOptions', $translated->getYesNo()); $model->setIfExists('gaa_filter', 'label', $this->_('Filter'), 'description', $this->_('When checked appointments with these activities are not imported.'), 'elementClass', 'Checkbox', 'multiOptions', $translated->getYesNo()); $model->addColumn("CASE WHEN gaa_active = 1 THEN '' ELSE 'deleted' END", 'row_class'); return $model; }
/** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed * parameter was added, because the most common use of action is a split between detailed * and summarized actions. * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return \MUtil_Model_ModelAbstract */ protected function createModel($detailed, $action) { $translated = $this->util->getTranslated(); $model = new \MUtil_Model_TableModel('gems__agenda_procedures'); \Gems_Model::setChangeFieldsByPrefix($model, 'gapr'); $model->setDeleteValues('gapr_active', 0); $model->set('gapr_name', 'label', $this->_('Activity'), 'description', $this->_('A procedure describes an appointments effects on a respondent: e.g. an excercise, an explanantion, a massage, mindfullness, a (specific) operation, etc...'), 'required', true); $model->setIfExists('gapr_id_organization', 'label', $this->_('Organization'), 'description', $this->_('Optional, an import match with an organization has priority over those without.'), 'multiOptions', $translated->getEmptyDropdownArray() + $this->util->getDbLookup()->getOrganizations()); $model->setIfExists('gapr_name_for_resp', 'label', $this->_('Respondent explanation'), 'description', $this->_('Alternative description to use with respondents.')); $model->setIfExists('gapr_match_to', 'label', $this->_('Import matches'), 'description', $this->_("Split multiple import matches using '|'.")); $model->setIfExists('gapr_code', 'label', $this->_('Procedure code'), 'size', 10, 'description', $this->_('Optional code name to link the procedure to program code.')); $model->setIfExists('gapr_active', 'label', $this->_('Active'), 'description', $this->_('Inactive means assignable only through automatich processes.'), 'elementClass', 'Checkbox', 'multiOptions', $translated->getYesNo()); $model->setIfExists('gapr_filter', 'label', $this->_('Filter'), 'description', $this->_('When checked appointments with these procedures are not imported.'), 'elementClass', 'Checkbox', 'multiOptions', $translated->getYesNo()); $model->addColumn("CASE WHEN gapr_active = 1 THEN '' ELSE 'deleted' END", 'row_class'); return $model; }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { $model = parent::createModel(); $translated = $this->util->getTranslated(); $model->set('calc_used_date', 'formatFunction', $translated->formatDateNever, 'tdClass', 'date'); $model->set('gto_changed', 'dateFormat', 'dd-MM-yyyy HH:mm:ss', 'tdClass', 'date'); return $model; }
/** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed * parameter was added, because the most common use of action is a split between detailed * and summarized actions. * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return \MUtil_Model_ModelAbstract */ protected function createModel($detailed, $action) { $dblookup = $this->util->getDbLookup(); $translated = $this->util->getTranslated(); $model = new \MUtil_Model_TableModel('gems__agenda_staff'); \Gems_Model::setChangeFieldsByPrefix($model, 'gas'); $model->setDeleteValues('gas_active', 0); $model->set('gas_name', 'label', $this->_('Name'), 'required', true); $model->set('gas_function', 'label', $this->_('Function')); $model->setIfExists('gas_id_organization', 'label', $this->_('Organization'), 'multiOptions', $dblookup->getOrganizations(), 'required', true); $model->setIfExists('gas_id_user', 'label', $this->_('GemsTracker user'), 'description', $this->_('Optional: link this health care provider to a GemsTracker Staff user.'), 'multiOptions', $translated->getEmptyDropdownArray() + $dblookup->getStaff()); $model->setIfExists('gas_match_to', 'label', $this->_('Import matches'), 'description', $this->_("Split multiple import matches using '|'.")); $model->setIfExists('gas_active', 'label', $this->_('Active'), 'description', $this->_('Inactive means assignable only through automatich processes.'), 'elementClass', 'Checkbox', 'multiOptions', $translated->getYesNo()); $model->setIfExists('gas_filter', 'label', $this->_('Filter'), 'description', $this->_('When checked appointments with this staff member are not imported.'), 'elementClass', 'Checkbox', 'multiOptions', $translated->getYesNo()); $model->addColumn("CASE WHEN gas_active = 1 THEN '' ELSE 'deleted' END", 'row_class'); return $model; }
/** * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @param int $defaultOrgId The default organization id or null if current organization * @return \Gems_Model_StaffModel */ public function applySettings($detailed, $action, $defaultOrgId) { $this->resetOrder(); $dbLookup = $this->util->getDbLookup(); $editing = $action == 'edit' || $action == 'create'; $translated = $this->util->getTranslated(); $user = $this->loader->getCurrentUser(); $yesNo = $translated->getYesNo(); if ($editing) { $ucfirst = new \Zend_Filter_Callback('ucfirst'); if ($this->project->isLoginShared()) { $this->set('gsf_login', 'validator', $this->createUniqueValidator('gsf_login', array('gsf_id_user'))); } else { // per organization $this->set('gsf_login', 'validator', $this->createUniqueValidator(array('gsf_login', 'gsf_id_organization'), array('gsf_id_user'))); } } else { $ucfirst = null; } $this->set('gsf_login', 'label', $this->_('Username'), 'minlength', 4, 'required', true, 'size', 15); if ($user->hasPrivilege('pr.staff.see.all') || !$editing) { // Select organization $options = $dbLookup->getOrganizations(); } else { $options = $user->getAllowedOrganizations(); } $this->set('gsf_id_organization', 'label', $this->_('Organization'), 'multiOptions', $options, 'required', true); if ($detailed) { $this->set('gsf_first_name', 'label', $this->_('First name'), 'filters[ucfirst]', $ucfirst); $this->set('gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', $this->_('de, van der, \'t, etc...')); $this->set('gsf_last_name', 'label', $this->_('Last name'), 'required', true, 'filters[ucfirst]', $ucfirst); } else { $this->set('name', 'label', $this->_('Name')); } $this->set('gsf_gender', 'label', $this->_('Gender'), 'elementClass', 'Radio', 'multiOptions', $translated->getGenders(), 'separator', ' '); $this->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', array('MUtil_Html_AElement', 'ifmail'), 'size', 30, 'validators[email]', 'SimpleEmail'); $this->set('gsf_id_primary_group', 'label', $this->_('Primary function'), 'multiOptions', $editing ? $user->getAllowedStaffGroups() : $dbLookup->getStaffGroups()); if ($detailed) { // Now try to load the current organization and find out if it has a default user definition // otherwise use the defaultStaffDefinition $organization = $this->loader->getOrganization($defaultOrgId ? $defaultOrgId : $user->getCurrentOrganizationId()); $this->set('gsf_id_organization', 'default', $organization->getId()); $this->set('gul_user_class', 'label', $this->_('User Definition'), 'default', $organization->get('gor_user_class', $this->defaultStaffDefinition), 'multiOptions', $this->loader->getUserLoader()->getAvailableStaffDefinitions()); if ($editing) { $this->set('gul_user_class', 'order', 1, 'required', true); } $this->set('gsf_iso_lang', 'label', $this->_('Language'), 'default', $this->project->locale['default'], 'multiOptions', $this->util->getLocalized()->getLanguages()); $this->set('gul_can_login', 'label', $this->_('Can login'), 'default', 1, 'description', $this->_('Users can only login when this box is checked.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo); $this->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'description', $this->_('If checked the user will logoff when answering a survey.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo); $this->set('gsf_mail_watcher', 'label', $this->_('Check cron job mail'), 'description', $this->_('If checked the user will be mailed when the cron job does not run on time.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo); } $this->set('gsf_active', 'label', $this->_('Active'), 'elementClass', 'None', 'multiOptions', $yesNo); $this->setDeleteValues('gsf_active', 0, 'gul_can_login', 0); if (!$user->hasPrivilege('pr.staff.edit.all')) { $this->set('gsf_id_organization', 'elementClass', 'Exhibitor'); } return $this; }
/** * Sets the labels, format functions, etc... * * @param boolean $detailed True when shopwing detailed information * @param boolean $edit When true use edit settings * @return \Gems_Tracker_Model_TrackModel */ public function applyFormatting($detailed = false, $edit = false) { $translated = $this->util->getTranslated(); $translator = $this->getTranslateAdapter(); if ($edit) { $dateFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat'); } else { $dateFormat = $translated->dateFormatString; } $this->resetOrder(); $this->set('gtr_track_name', 'label', $translator->_('Name')); $this->set('gtr_track_class', 'label', $translator->_('Track Engine'), 'multiOptions', $this->tracker->getTrackEngineList($detailed)); $this->set('gtr_survey_rounds', 'label', $translator->_('Surveys')); $this->set('gtr_active', 'label', $translator->_('Active'), 'multiOptions', $translated->getYesNo()); $this->set('gtr_date_start', 'label', $translator->_('From'), 'dateFormat', $dateFormat, 'formatFunction', $translated->formatDate); $this->set('gtr_date_until', 'label', $translator->_('Use until'), 'dateFormat', $dateFormat, 'formatFunction', $translated->formatDateForever); $this->setIfExists('gtr_code', 'label', $translator->_('Track code'), 'size', 10, 'description', $translator->_('Optional code name to link the track to program code.')); if ($detailed) { $events = $this->loader->getEvents(); $caList = $events->listTrackCalculationEvents(); if (count($caList) > 1) { $this->setIfExists('gtr_calculation_event', 'label', $translator->_('Before (re)calculation'), 'multiOptions', $caList); } $coList = $events->listTrackCompletionEvents(); if (count($coList) > 1) { $this->setIfExists('gtr_completed_event', 'label', $translator->_('After completion'), 'multiOptions', $coList); } $bfuList = $events->listTrackBeforeFieldUpdateEvents(); if (count($bfuList) > 1) { $this->setIfExists('gtr_beforefieldupdate_event', 'label', $translator->_('Before field update'), 'multiOptions', $bfuList); } $fuList = $events->listTrackFieldUpdateEvents(); if (count($fuList) > 1) { $this->setIfExists('gtr_fieldupdate_event', 'label', $translator->_('After field update'), 'multiOptions', $fuList); } $this->setIfExists('gtr_organizations', 'label', $translator->_('Organizations'), 'elementClass', 'MultiCheckbox', 'multiOptions', $this->util->getDbLookup()->getOrganizationsWithRespondents(), 'required', true); $ct = new \MUtil_Model_Type_ConcatenatedRow('|', $translator->_(', ')); $ct->apply($this, 'gtr_organizations'); } if ($edit) { $this->set('toggleOrg', 'elementClass', 'ToggleCheckboxes', 'selectorName', 'gtr_organizations'); $this->set('gtr_track_name', 'minlength', 4, 'size', 30, 'validators[unique]', $this->createUniqueValidator('gtr_track_name')); } return $this; }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { $translated = $this->util->getTranslated(); $model = new \MUtil_Model_TableModel('gems__tracks'); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gtr_survey_rounds', 'label', $this->_('Survey #')); $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', $translated->formatDate, 'tdClass', 'date'); $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', $translated->formatDateForever, 'tdClass', 'date'); return $model; }
/** * Returns the changes to the model for this field that must be made in an array consisting of * * <code> * array(setting1 => $value1, setting2 => $value2, ...), * </code> * * By using [] array notation in the setting array key you can append to existing * values. * * Use the setting 'value' to change a value in the original data. * * When a 'model' setting is set, the workings cascade. * * @param array $context The current data this object is dependent on * @param boolean $new True when the item is a new record not yet saved * @return array (setting => value) */ public function getDataModelDependyChanges(array $context, $new) { if ($this->isReadOnly()) { return null; } $sql = $this->_sql . "WHERE grr_id_respondent = ? ORDER BY grr_type"; $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $output['multiOptions'] = $empty + $this->db->fetchPairs($sql, $context['gr2t_id_user']); return $output; }
/** * Returns the changes to the model for this field that must be made in an array consisting of * * <code> * array(setting1 => $value1, setting2 => $value2, ...), * </code> * * By using [] array notation in the setting array key you can append to existing * values. * * Use the setting 'value' to change a value in the original data. * * When a 'model' setting is set, the workings cascade. * * @param array $context The current data this object is dependent on * @param boolean $new True when the item is a new record not yet saved * @return array (setting => value) */ public function getDataModelDependyChanges(array $context, $new) { if ($this->isReadOnly()) { return null; } $agenda = $this->loader->getAgenda(); $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $output['multiOptions'] = $empty + $agenda->getActivities($context['gr2t_id_organization']); return $output; }
/** * Set those settings needed for the browse display * * * @return \Gems_Model_OrganizationModel */ public function applyBrowseSettings() { $dbLookup = $this->util->getDbLookup(); $definitions = $this->loader->getUserLoader()->getAvailableStaffDefinitions(); $localized = $this->util->getLocalized(); $projectName = $this->project->getName(); $yesNo = $this->util->getTranslated()->getYesNo(); $this->resetOrder(); $this->set('gor_name', 'label', $this->_('Name'), 'tab', $this->_('General')); $this->set('gor_location', 'label', $this->_('Location')); $this->set('gor_task', 'label', $this->_('Task'), 'description', sprintf($this->_('Task in %s project'), $projectName)); $this->set('gor_url', 'label', $this->_('Url')); $this->setIfExists('gor_url_base', 'label', $this->_("Default url's"), 'description', sprintf($this->_("Always switch to this organization when %s is accessed from one of these space separated url's. The first is used for mails."), $projectName)); $this->setIfExists('gor_code', 'label', $this->_('Organization code'), 'description', $this->_('Optional code name to link the organization to program code.')); $this->set('gor_provider_id', 'label', $this->_('Healtcare provider id'), 'description', $this->_('An interorganizational id used for import and export.')); $this->setIfExists('gor_active', 'label', $this->_('Active'), 'description', $this->_('Can the organization be used?'), 'multiOptions', $yesNo); $this->set('gor_contact_name', 'label', $this->_('Contact name')); $this->set('gor_contact_email', 'label', $this->_('Contact email')); // Determine order for details, but do not show in browse $this->set('gor_welcome'); $this->set('gor_signature'); $this->set('gor_create_account_template'); $this->set('gor_reset_pass_template'); $this->set('gor_has_login', 'label', $this->_('Login'), 'description', $this->_('Can people login for this organization?'), 'multiOptions', $yesNo); $this->set('gor_add_respondents', 'label', $this->_('Accepting'), 'description', $this->_('Can new respondents be added to the organization?'), 'multiOptions', $yesNo); $this->set('gor_has_respondents', 'label', $this->_('Respondents'), 'description', $this->_('Does the organization have respondents?'), 'multiOptions', $yesNo); $this->set('gor_respondent_group', 'label', $this->_('Respondent group'), 'description', $this->_('Allows respondents to login.'), 'multiOptions', $dbLookup->getAllowedRespondentGroups()); $this->set('gor_accessible_by', 'label', $this->_('Accessible by'), 'description', $this->_('Checked organizations see this organizations respondents.'), 'multiOptions', $dbLookup->getOrganizations()); $tp = new \MUtil_Model_Type_ConcatenatedRow(':', ', '); $tp->apply($this, 'gor_accessible_by'); $this->setIfExists('gor_allowed_ip_ranges'); if ($definitions && count($definitions) > 1) { $this->setIfExists('gor_user_class', 'label', $this->_('User Definition'), 'multiOptions', $definitions); } $this->setIfExists('gor_resp_change_event', 'label', $this->_('Respondent change event'), 'multiOptions', $this->loader->getEvents()->listRespondentChangedEvents()); $this->setIfExists('gor_iso_lang', 'label', $this->_('Language'), 'multiOptions', $localized->getLanguages()); if ($this->_styles) { $this->setIfExists('gor_style', 'label', $this->_('Style'), 'multiOptions', $this->_styles); } return $this; }
/** * Set those settings needed for the browse display * * @param boolean $detailed For detailed settings * @return \Gems\Tracker\Model\FieldMaintenanceModel (continuation pattern) */ public function applyBrowseSettings($detailed = false) { $this->resetOrder(); $yesNo = $this->util->getTranslated()->getYesNo(); $types = $this->getFieldTypes(); $this->set('gtf_id_track'); // Set order $this->set('gtf_field_name', 'label', $this->_('Name')); $this->set('gtf_id_order', 'label', $this->_('Order'), 'description', $this->_('The display and processing order of the fields.')); $this->set('gtf_field_type', 'label', $this->_('Type'), 'multiOptions', $types, 'default', 'text'); if ($detailed) { $this->set('gtf_field_values'); // Set order $this->set('gtf_field_description'); // Set order } $this->set('gtf_field_code', 'label', $this->_('Field code'), 'description', $this->_('Optional code name to link the field to program code.')); $this->set('htmlUse', 'elementClass', 'Exhibitor', 'value', \MUtil_Html::create('h3', $this->_('Field use'))); $this->set('gtf_to_track_info', 'label', $this->_('In description'), 'description', $this->_('Add this field to the track description'), 'multiOptions', $yesNo); $this->set('gtf_track_info_label', 'description', $this->_('Add the name of this field to the track description'), 'multiOptions', $yesNo, 'required', false); $this->set('gtf_required', 'label', $this->_('Required'), 'multiOptions', $yesNo, 'required', false); $this->set('gtf_readonly', 'label', $this->_('Readonly'), 'description', $this->_('Check this box if this field is always set by code instead of the user.'), 'multiOptions', $yesNo, 'required', false); $this->set('htmlCalc', 'elementClass', 'None', 'value', \MUtil_Html::create('h3', $this->_('Field calculation'))); $this->set('gtf_calculate_using', 'description', $this->_('Automatically calculate this field using other fields')); if ($detailed) { // Appointment caculcation field $this->set('gtf_filter_id'); // Set order $this->set('gtf_min_diff_length'); // Set order $this->set('gtf_min_diff_unit'); // Set order $this->set('gtf_max_diff_exists', 'multiOptions', $yesNo); // Set order $this->set('gtf_max_diff_length'); // Set order $this->set('gtf_max_diff_unit'); // Set order $this->set('gtf_after_next'); // Set order $this->set('gtf_uniqueness'); // Set order } else { $this->set('calculation', 'label', $this->_('Calculate using'), 'description', $this->_('Automatically calculate this field using other fields'), 'noSort', true); $this->setOnLoad('calculation', array($this, 'loadCalculationSources')); } $this->set('gtf_create_track', 'label', $this->_('Create track'), 'description', $this->_('Create a track if the respondent does not have a track where this field is empty.'), 'multiOptions', $yesNo); $this->set('gtf_create_wait_days'); // Set order return $this; }
/** * Returns a model that can be used to retrieve or save the data. * * @param boolean $detailed Create a model for the display of detailed item data or just a browse table * @param string $action The current action * @return \MUtil_Model_ModelAbstract */ public function getRoundModel($detailed, $action) { $model = $this->createRoundModel(); $translated = $this->util->getTranslated(); // Set the keys to the parameters in use. $model->setKeys(array(\MUtil_Model::REQUEST_ID => 'gro_id_track', \Gems_Model::ROUND_ID => 'gro_id_round')); if ($detailed) { $model->set('gro_id_track', 'label', $this->_('Track'), 'elementClass', 'exhibitor', 'multiOptions', $this->util->getTrackData()->getAllTracks); } $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveysAndDescriptions()); $model->set('gro_icon_file', 'label', $this->_('Icon')); $model->set('gro_id_order', 'label', $this->_('Order'), 'default', 10, 'validators[uni]', $model->createUniqueValidator(array('gro_id_order', 'gro_id_track'))); $model->set('gro_round_description', 'label', $this->_('Description'), 'size', '30'); //, 'minlength', 4, 'required', true); $list = $this->events->listRoundChangedEvents(); if (count($list) > 1) { $model->set('gro_changed_event', 'label', $this->_('After change'), 'multiOptions', $list); } $list = $this->events->listSurveyDisplayEvents(); if (count($list) > 1) { $model->set('gro_display_event', 'label', $this->_('Answer display'), 'multiOptions', $list); } $model->set('gro_active', 'label', $this->_('Active'), 'elementClass', 'checkbox', 'multiOptions', $translated->getYesNo()); $model->setIfExists('gro_code', 'label', $this->_('Round code'), 'description', $this->_('Optional code name to link the field to program code.'), 'size', 10); $model->addColumn("CASE WHEN gro_active = 1 THEN '' ELSE 'deleted' END", 'row_class'); $model->addColumn("CASE WHEN gro_organizations IS NULL THEN 0 ELSE 1 END", 'org_specific_round'); $model->addColumn('gro_organizations', 'organizations'); $model->set('organizations', 'label', $this->_('Organizations'), 'elementClass', 'MultiCheckbox', 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'data-source', 'org_specific_round'); $tp = new \MUtil_Model_Type_ConcatenatedRow('|', $this->_(', ')); $tp->apply($model, 'organizations'); switch ($action) { case 'create': $this->_ensureRounds(); if ($this->_rounds && ($round = end($this->_rounds))) { $model->set('gro_id_order', 'default', $round['gro_id_order'] + 10); } // Intentional fall through // break; // Intentional fall through // break; case 'edit': case 'show': $model->set('gro_icon_file', 'multiOptions', $translated->getEmptyDropdownArray() + $this->_getAvailableIcons()); $model->set('org_specific_round', 'label', $this->_('Organization specific round'), 'default', 0, 'multiOptions', $translated->getYesNo(), 'elementClass', 'radio'); break; default: $model->set('gro_icon_file', 'formatFunction', array('MUtil_Html_ImgElement', 'imgFile')); break; } return $model; }
/** * 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; }
/** * Set those values needed for editing * * @param int $orgId The id of the current organization * @param mixed $locale The locale for the settings * @return \Gems_Model_AppointmentModel */ public function applyEditSettings($orgId, $locale = null) { $this->applyDetailSettings($locale, false); $agenda = $this->loader->getAgenda(); $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $this->setIfExists('gap_id_organization', 'default', $orgId); $this->setIfExists('gap_admission_time', 'elementClass', 'Date'); $this->setIfExists('gap_discharge_time', 'elementClass', 'Date'); $this->setIfExists('gap_status', 'required', true); $this->setIfExists('gap_comment', 'elementClass', 'Textarea', 'rows', 5); $this->setIfExists('gap_id_activity', 'multiOptions', $empty + $agenda->getActivities($orgId)); $this->setIfExists('gap_id_procedure', 'multiOptions', $empty + $agenda->getProcedures($orgId)); $this->setIfExists('gap_id_location', 'multiOptions', $empty + $agenda->getLocations($orgId)); return $this; }
/** * Set those settings needed for the detailed display * * @param \Gems_Tracker_Engine_TrackEngineInterface $trackEngine * @param boolean $edit When true the fields are added in edit mode * @return \Gems_Model_RespondentTrackModel */ public function applyDetailSettings(\Gems_Tracker_Engine_TrackEngineInterface $trackEngine, $edit = false) { $this->resetOrder(); $translated = $this->util->getTranslated(); $formatDate = $this->util->getTranslated()->formatDate; $this->set('gr2o_patient_nr', 'label', $this->_('Respondent number')); $this->set('respondent_name', 'label', $this->_('Respondent name')); $this->set('gtr_track_name', 'label', $this->_('Track')); $this->set('gr2t_mailable', 'label', $this->_('May be mailed'), 'elementClass', 'radio', 'separator', ' ', 'multiOptions', array('1' => $this->_('Yes'), '0' => $this->_('No'))); $this->set('assigned_by', 'label', $this->_('Assigned by')); $this->set('gr2t_start_date', 'label', $this->_('Start'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $formatDate); // Integrate fields $trackEngine->addFieldsToModel($this, $edit); $this->set('gr2t_end_date_manual', 'label', $this->_('Set ending on'), 'description', $this->_('Manually set dates are fixed an will never be (re)calculated.'), 'elementClass', 'Radio', 'multiOptions', $translated->getDateCalculationOptions(), 'separator', ' '); $this->set('gr2t_end_date', 'label', $this->_('Ending on'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $formatDate); $this->set('gr2t_track_info', 'label', $this->_('Description')); $this->set('gr2t_comment', 'label', $this->_('Comment')); return $this; }
/** * Returns a list of selectable events with an empty element as the first option. * * @param string $eventType The type (i.e. lookup directory with an associated class) of the events to list * @return \Gems_tracker_TrackerEventInterface or more specific a $eventClass type object */ protected function _listEvents($eventType) { $results = array(); $eventClass = $this->_getEventClass($eventType); $paths = $this->_getEventDirs($eventType); foreach ($paths as $prefix => $path) { if (file_exists($path)) { $eDir = dir($path); $parts = explode('_', $prefix, 2); if ($name = reset($parts)) { $name = ' (' . $name . ')'; } while (false !== ($filename = $eDir->read())) { if ('.php' === substr($filename, -4)) { $eventName = $prefix . substr($filename, 0, -4); // Take care of double definitions if (!isset($results[$eventName])) { $eventNsName = '\\' . strtr($eventName, '_', '\\'); if (!(class_exists($eventName, false) || class_exists($eventNsName, false))) { include $path . '/' . $filename; } if (!class_exists($eventName, false) && class_exists($eventNsName, false)) { $eventName = $eventNsName; } $event = new $eventName(); if ($event instanceof $eventClass) { if ($event instanceof \MUtil_Registry_TargetInterface) { $this->applySource($event); } $results[$eventName] = trim($event->getEventName()) . $name; } // \MUtil_Echo::track($eventName); } } } } } natcasesort($results); $results = $this->util->getTranslated()->getEmptyDropdownArray() + $results; // \MUtil_Echo::track($paths, $results); return $results; }
/** * Returns the changes that must be made in an array consisting of * * <code> * array( * field1 => array(setting1 => $value1, setting2 => $value2, ...), * field2 => array(setting3 => $value3, setting4 => $value4, ...), * </code> * * By using [] array notation in the setting name you can append to existing * values. * * Use the setting 'value' to change a value in the original data. * * When a 'model' setting is set, the workings cascade. * * @param array $context The current data this object is dependent on * @param boolean $new True when the item is a new record not yet saved * @return array name => array(setting => value) */ public function getChanges(array $context, $new) { // Only change anything when there are filters $filters = $this->loader->getAgenda()->getFilterList(); if (!$filters) { return array(); } // Load utility $translated = $this->util->getTranslated(); $output['gtf_id_order'] = array('description' => $this->_('The display and processing order of the fields.') . "\n" . $this->_('When using automatic filters the fields are ALWAYS filled with appointments in ascending order.')); $output['htmlCalc'] = array('label' => ' ', 'elementClass' => 'Exhibitor'); $output['gtf_filter_id'] = array('label' => $this->_('Automatic link'), 'description' => $this->_('Automatically link an appointment when it passes this filter.'), 'elementClass' => 'Select', 'multiOptions' => $translated->getEmptyDropdownArray() + $filters, 'onchange' => 'this.form.submit();'); if ($context['gtf_filter_id']) { $periodUnits = $this->util->getTranslated()->getPeriodUnits(); $output['gtf_min_diff_length'] = array('label' => $this->_('Minimal time difference'), 'description' => $this->_('Difference with the previous appointment or track start date, can be negative but not zero'), 'elementClass' => 'Text', 'required' => true, 'filters[int]' => 'Int', 'validators[isnot]' => new \MUtil_Validate_IsNot(0, $this->_('This value may not be zero!'))); $output['gtf_min_diff_unit'] = array('label' => $this->_('Minimal difference unit'), 'elementClass' => 'Select', 'multiOptions' => $periodUnits); $output['gtf_max_diff_exists'] = array('label' => $this->_('Set a maximum time difference'), 'elementClass' => 'Checkbox', 'onclick' => 'this.form.submit();'); if ($context['gtf_max_diff_exists']) { $output['gtf_max_diff_length'] = array('label' => $this->_('Maximum time difference'), 'elementClass' => 'Text', 'required' => false, 'filters[int]' => 'Int'); if ($context['gtf_min_diff_length'] < 0) { $output['gtf_max_diff_length']['description'] = $this->_('Must be negative, just like the minimal difference.'); $output['gtf_max_diff_length']['validators[lt]'] = new \Zend_Validate_LessThan(0); } else { $output['gtf_max_diff_length']['description'] = $this->_('Must be positive, just like the minimal difference.'); $output['gtf_max_diff_length']['validators[gt]'] = new \Zend_Validate_GreaterThan(0); } $output['gtf_max_diff_unit'] = array('label' => $this->_('Maximum difference unit'), 'elementClass' => 'Select', 'multiOptions' => $periodUnits); } // $output['gtf_after_next'] = array( // 'label' => $this->_('Link ascending'), // 'description' => $this->_('Automatically linked appointments are added in ascending (or otherwise descending) order; starting with the track start date.'), // 'elementClass' => 'Checkbox', // 'multiOptions' => $translated->getYesNo(), // ); $output['gtf_uniqueness'] = array('label' => $this->_('Link unique'), 'description' => $this->_('Can one appointment be used in multiple fields?'), 'elementClass' => 'Radio', 'multiOptions' => array(0 => $this->_('No: repeatedly linked appointments are allowed.'), 1 => $this->_('Track instances may link only once to an appointment.'), 2 => $this->_('Tracks of this type may link only once to an appointment.'))); $output['gtf_create_track'] = array('elementClass' => 'Checkbox', 'label' => $this->_('Create track'), 'onclick' => 'this.form.submit();'); if ($context['gtf_create_track']) { $output['gtf_create_wait_days'] = array('label' => $this->_('Days between tracks'), 'description' => $this->_('Any previous track must have an end date at least this many days in the past.'), 'elementClass' => 'Text'); } } return $output; }
/** * Add form elements when a responseDatabase is present * @param \Gems_Form $form existing form type * @param array data existing options set in the form * @return array of form elements */ protected function addResponseDatabaseForm($form, &$data, &$elements) { if (isset($data['tid']) && !empty($data['tid'])) { // If we have a responsedatabase and a track id, try something cool ;-) $responseDb = $this->project->getResponseDatabase(); if ($this->db === $responseDb) { // We are in the same database, now put that to use by allowing to filter respondents based on an answer in any survey $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $allSurveys = $empty + $this->util->getDbLookup()->getSurveysForExport(); $element = new \Zend_Form_Element_Select('filter_sid'); $element->setLabel($this->_('Survey'))->setMultiOptions($allSurveys); $groupElements = array($element); if (isset($data['filter_sid']) && !empty($data['filter_sid'])) { $filterSurvey = $this->loader->getTracker()->getSurvey($data['filter_sid']); $filterQuestions = $empty + $filterSurvey->getQuestionList($this->locale->getLanguage()); $element = new \Zend_Form_Element_Select('filter_answer'); $element->setLabel($this->_('Question'))->setMultiOptions($filterQuestions); $groupElements[] = $element; } if (isset($filterSurvey) && isset($data['filter_answer']) && !empty($data['filter_answer'])) { $questionInfo = $filterSurvey->getQuestionInformation($this->locale->getLanguage()); if (array_key_exists($data['filter_answer'], $questionInfo)) { $questionInfo = $questionInfo[$data['filter_answer']]; } else { $questionInfo = array(); } if (array_key_exists('answers', $questionInfo) && is_array($questionInfo['answers']) && count($questionInfo['answers']) > 1) { $element = new \Zend_Form_Element_Multiselect('filter_value'); $element->setMultiOptions($empty + $questionInfo['answers']); $element->setAttrib('size', count($questionInfo['answers']) + 1); } else { $element = new \Zend_Form_Element_Text('filter_value'); } $element->setLabel($this->_('Value')); $groupElements[] = $element; } $form->addDisplayGroup($groupElements, 'filter', array('showLabels' => true, 'Description' => $this->_('Filter'))); array_shift($elements); } } }
/** * Set those settings needed for the detailed display * * @return \Gems_Agenda_AppointmentFilterModelAbstract */ public function applyDetailSettings() { $this->loadFilterDependencies(true); $yesNo = $this->util->getTranslated()->getYesNo(); $this->resetOrder(); $this->set('gaf_class', 'label', $this->_('Filter type'), 'description', $this->_('Determines what is filtered how.'), 'multiOptions', $this->filterOptions); $this->set('gaf_manual_name', 'label', $this->_('Manual name'), 'description', $this->_('A name for this filter. The calculated name is used otherwise.')); $this->set('gaf_calc_name', 'label', $this->_('Calculated name')); $this->set('gaf_id_order', 'label', $this->_('Order'), 'description', $this->_('Execution order of the filters, lower numbers are executed first.')); // Set the order $this->set('gaf_filter_text1'); $this->set('gaf_filter_text2'); $this->set('gaf_filter_text3'); $this->set('gaf_filter_text4'); $this->set('gaf_active', 'label', $this->_('Active'), 'multiOptions', $yesNo); $this->addColumn(new \Zend_Db_Expr(sprintf("(SELECT COALESCE(GROUP_CONCAT(gtr_track_name, '%s', gtap_field_name\n ORDER BY gtr_track_name, gtap_id_order SEPARATOR '%s'), '%s')\n FROM gems__track_appointments INNER JOIN gems__tracks ON gtap_id_track = gtr_id_track\n WHERE gaf_id = gtap_filter_id)", $this->_(': '), $this->_('; '), $this->_('Not used in tracks'))), 'usetrack'); $this->set('usetrack', 'label', $this->_('Use in track fields'), 'description', $this->_('The use of this filter in track fields.'), 'elementClass', 'Exhibitor'); $this->addColumn(new \Zend_Db_Expr(sprintf("(SELECT COALESCE(GROUP_CONCAT(gaf_calc_name ORDER BY gaf_id_order SEPARATOR '%s'), '%s')\n FROM gems__appointment_filters AS other\n WHERE gaf_class IN ('AndAppointmentFilter', 'OrAppointmentFilter') AND\n (\n gems__appointment_filters.gaf_id = other.gaf_filter_text1 OR\n gems__appointment_filters.gaf_id = other.gaf_filter_text2 OR\n gems__appointment_filters.gaf_id = other.gaf_filter_text3 OR\n gems__appointment_filters.gaf_id = other.gaf_filter_text4\n )\n )", $this->_('; '), $this->_('Not used in filters'))), 'usefilter'); $this->set('usefilter', 'label', $this->_('Use in filters'), 'description', $this->_('The use of this filter in other filters.'), 'elementClass', 'Exhibitor'); return $this; }
/** * Called after the check that all required registry values * have been set correctly has run. * * @return void */ public function afterRegistry() { $this->_filters = $this->util->getTranslated()->getEmptyDropdownArray() + $this->agenda->getFilterList(); parent::afterRegistry(); }
/** * Returns the gender for use in stand-alone name display * * In practice: starts uppercase * * @param string $locale * @return array gender => string */ protected function getGenderHello($locale = null) { $greetings = $this->util->getTranslated()->getGenderHello($locale); if (isset($greetings[$this->_getVar('user_gender')])) { return $greetings[$this->_getVar('user_gender')]; } }
/** * Add the model settings like the elementClass for this field. * * elementClass is overwritten when this field is read only, unless you override it again in getDataModelSettings() * * @param array $settings The settings set so far */ protected function addModelSettings(array &$settings) { $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $settings['elementClass'] = 'Select'; $settings['multiOptions'] = $empty + $this->util->getDbLookup()->getUserConsents(); }
/** * Load the settings for the survey */ protected function loadTrackSettings() { $respTracks = $this->tracker->getRespondentTracks($this->formData['gto_id_respondent'], $this->formData['gto_id_organization']); $tracks = array(); foreach ($respTracks as $respTrack) { if ($respTrack instanceof \Gems_Tracker_RespondentTrack) { if ($respTrack->hasSuccesCode()) { $tracks[$respTrack->getRespondentTrackId()] = substr(sprintf($this->_('%s - %s'), $respTrack->getTrackEngine()->getTrackName(), $respTrack->getFieldsInfo()), 0, 100); } } } if ($tracks) { if (!isset($this->formData['gto_id_track'])) { reset($tracks); $this->formData['gto_id_track'] = key($tracks); } } else { $this->addMessageInvalid($this->_('Survey insertion impossible: respondent has no track!')); $tracks = $this->util->getTranslated()->getEmptyDropdownArray(); } asort($tracks); $model = $this->getModel(); $model->set('gto_id_track', 'multiOptions', $tracks); if (count($tracks) === 1) { $model->set('gto_id_track', 'elementClass', 'Exhibitor'); } if (isset($this->formData['gto_id_track'])) { $this->respondentTrack = $respTracks[$this->formData['gto_id_track']]; // Add relation field when survey is not for staff if ($this->survey && $this->survey->isTakenByStaff() === false) { $engine = $this->respondentTrack->getTrackEngine(); if (method_exists($engine, 'getRespondentRelationFields')) { $empty = array('-1' => $this->_('Patient')); $relations = $empty + $engine->getRespondentRelationFields(); $model->set('gto_id_relationfield', 'label', $this->_('Fill out by'), 'multiOptions', $relations, 'elementClass', 'Select', 'required', true); } } } }