/** * 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) { $fields = array(); // Export all if ('export' === $action) { $detailed = true; } $organizations = $this->util->getDbLookup()->getOrganizations(); $fields[] = 'gtr_track_name'; $sql = "CASE WHEN gtr_organizations LIKE '%%|%s|%%' THEN 1 ELSE 0 END"; foreach ($organizations as $orgId => $orgName) { $fields['O' . $orgId] = new \Zend_Db_Expr(sprintf($sql, $orgId)); } $fields['total'] = new \Zend_Db_Expr("(LENGTH(gtr_organizations) - LENGTH(REPLACE(gtr_organizations, '|', ''))-1)"); $fields[] = 'gtr_id_track'; $select = $this->db->select(); $select->from('gems__tracks', $fields); $model = new \MUtil_Model_SelectModel($select, 'track-verview'); $model->setKeys(array('gtr_id_track')); $model->resetOrder(); $model->set('gtr_track_name', 'label', $this->_('Track name')); $model->set('total', 'label', $this->_('Total')); $model->setOnTextFilter('total', array($this, 'noTextFilter')); foreach ($organizations as $orgId => $orgName) { $model->set('O' . $orgId, 'label', $orgName, 'tdClass', 'rightAlign', 'thClass', 'rightAlign'); $model->setOnTextFilter('O' . $orgId, array($this, 'noTextFilter')); if ($action !== 'export') { $model->set('O' . $orgId, 'formatFunction', array($this, 'formatCheckmark')); } } // \MUtil_Model::$verbose = true; 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) { // Export all if ('export' === $action) { $detailed = true; } if ($detailed) { $year = $this->_('Year'); $month = $this->_('Month'); $fields[$year] = new \Zend_Db_Expr("YEAR(gr2o_created)"); $fields[$month] = new \Zend_Db_Expr("MONTH(gr2o_created)"); } $consents = $this->util->getDbLookup()->getUserConsents(); $deleteds = array('' => '') + $this->util->getReceptionCodeLibrary()->getRespondentDeletionCodes(); $sql = "SUM(CASE WHEN grc_success = 1 AND gr2o_consent = '%s' THEN 1 ELSE 0 END)"; foreach ($consents as $consent => $translated) { $fields[$translated] = new \Zend_Db_Expr(sprintf($sql, $consent)); } $fields[$this->_('Total OK')] = new \Zend_Db_Expr("SUM(CASE WHEN grc_success = 1 THEN 1 ELSE 0 END)"); $sql = "SUM(CASE WHEN gr2o_reception_code = '%s' THEN 1 ELSE 0 END)"; foreach ($deleteds as $code => $translated) { $fields[$translated] = new \Zend_Db_Expr(sprintf($sql, $code)); } $fields[$this->_('Dropped')] = new \Zend_Db_Expr("SUM(CASE WHEN grc_success = 0 THEN 1 ELSE 0 END)"); $fields[$this->_('Total')] = new \Zend_Db_Expr("COUNT(*)"); $select = $this->db->select(); $select->from('gems__respondent2org', $fields)->joinInner('gems__reception_codes', 'gr2o_reception_code = grc_id_reception_code', array())->joinInner('gems__organizations', 'gr2o_id_organization = gor_id_organization', array('gor_name', 'gor_id_organization')); $select->group(array('gor_name', 'gor_id_organization')); if ($detailed) { $select->group(array($fields[$year], $fields[$month])); } $model = new \MUtil_Model_SelectModel($select, 'consent-plan'); $model->setKeys(array('gor_id_organization')); $model->resetOrder(); $model->set('gor_name', 'label', $this->_('Organization')); foreach ($fields as $field => $expr) { $model->set($field, 'label', $field, 'tdClass', 'rightAlign', 'thClass', 'rightAlign'); } foreach ($deleteds as $code => $translated) { $model->set($translated, 'tdClass', 'rightAlign smallTime', 'thClass', 'rightAlign smallTime'); } foreach (array($this->_('Total OK'), $this->_('Dropped'), $this->_('Total')) as $name) { $model->set($name, 'itemDisplay', \MUtil_Html::create('strong'), 'tableHeaderDisplay', \MUtil_Html::create('em'), 'tdClass', 'rightAlign selectedColumn', 'thClass', 'rightAlign selectedColumn'); } if ($detailed) { $model->set($month, 'formatFunction', $this->util->getLocalized()->getMonthName); } // Only show organisations the user is allowed to see $allowed = $this->currentUser->getAllowedOrganizations(); $model->setFilter(array('gr2o_id_organization' => array_keys($allowed))); // \MUtil_Model::$verbose = true; 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) { $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; }
/** * Set those settings needed for the detailed display * * @param mixed $locale The locale for the settings * @param boolean $setMulti When false organization dependent multi options are nor filled. * @return \Gems_Model_AppointmentModel */ public function applyDetailSettings($locale = null, $setMulti = true) { $this->resetOrder(); $agenda = $this->loader->getAgenda(); $dbLookup = $this->util->getDbLookup(); $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $this->setIfExists('gap_admission_time', 'label', $this->_('Appointment'), 'dateFormat', 'dd-MM-yyyy HH:mm', 'description', $this->_('dd-mm-yyyy hh:mm')); $this->setIfExists('gap_discharge_time', 'label', $this->_('Discharge'), 'dateFormat', 'dd-MM-yyyy HH:mm', 'description', $this->_('dd-mm-yyyy hh:mm')); $this->setIfExists('gap_code', 'label', $this->_('Type'), 'multiOptions', $agenda->getTypeCodes()); $this->setIfExists('gap_status', 'label', $this->_('Status'), 'multiOptions', $agenda->getStatusCodes()); $this->setIfExists('gap_id_attended_by', 'label', $this->_('With'), 'multiOptions', $empty + $agenda->getHealthcareStaff()); $this->setIfExists('gap_id_referred_by', 'label', $this->_('Referrer'), 'multiOptions', $empty + $agenda->getHealthcareStaff()); $this->setIfExists('gap_id_activity', 'label', $this->_('Activities')); $this->setIfExists('gap_id_procedure', 'label', $this->_('Procedures')); $this->setIfExists('gap_id_location', 'label', $this->_('Location')); $this->setIfExists('gap_id_organization', 'label', $this->_('Organization'), 'elementClass', 'Exhibitor', 'multiOptions', $empty + $dbLookup->getOrganizations()); $this->setIfExists('gap_subject', 'label', $this->_('Subject')); $this->setIfExists('gap_comment', 'label', $this->_('Comment')); if ($setMulti) { $this->setIfExists('gap_id_activity', 'multiOptions', $empty + $agenda->getActivities()); $this->setIfExists('gap_id_procedure', 'multiOptions', $empty + $agenda->getProcedures()); $this->setIfExists('gap_id_location', 'multiOptions', $empty + $agenda->getLocations()); } return $this; }
/** * 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) { $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 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; }
/** * Set the footer of the browse table. * * Overrule this function to set the header differently, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $row = $bridge->getRow(); parent::setShowTableFooter($bridge, $model); if (isset($row['gla_respondent_id'], $row['gla_organization']) && $this->menuList instanceof \Gems_Menu_MenuList) { $patientNr = $this->util->getDbLookup()->getPatientNr($row['gla_respondent_id'], $row['gla_organization']); $this->menuList->addParameterSources(array('gr2o_patient_nr' => $patientNr, 'gr2o_id_organization' => $row['gla_organization'])); $this->menuList->addByController('respondent', 'show', $this->_('Show respondent')); } }
/** * Set the reception code for a respondent and cascade non-success codes to the * tracks / surveys. * * @param string $patientId Can be empty if $respondentId is passed * @param int $organizationId * @param string $newCode String or \Gems_Util_ReceptionCode * @param int $respondentId Pass when at hand, is looked up otherwise * @param string $oldCode Pass when at hand as tring or \Gems_Util_ReceptionCode, is looked up otherwise * @return \Gems_Util_ReceptionCode The new code reception code object for further processing */ public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null) { if ($newCode instanceof \Gems_Util_ReceptionCode) { $code = $newCode; $newCode = $code->getCode(); } else { $code = $this->util->getReceptionCode($newCode); } $userId = $this->currentUser->getUserId(); // Perform actual save, but not for simple stop codes. if ($code->isForRespondents()) { if (null === $oldCode) { $oldCode = $this->getReceptionCode($patientId, $organizationId, $respondentId); } if ($oldCode instanceof \Gems_Util_ReceptionCode) { $oldCode = $oldCode->getCode(); } // If the code wasn't set already if ($oldCode !== $newCode) { $values['gr2o_reception_code'] = $newCode; $values['gr2o_changed'] = new \MUtil_Db_Expr_CurrentTimestamp(); $values['gr2o_changed_by'] = $userId; if ($patientId) { // Update though primamry key is prefered $where = 'gr2o_patient_nr = ? AND gr2o_id_organization = ?'; $where = $this->db->quoteInto($where, $patientId, null, 1); } else { $where = 'gr2o_id_user = ? AND gr2o_id_organization = ?'; $where = $this->db->quoteInto($where, $respondentId, null, 1); } $where = $this->db->quoteInto($where, $organizationId, null, 1); $this->db->update('gems__respondent2org', $values, $where); } } // Is the respondent really removed if (!$code->isSuccess()) { // Only check for $respondentId when it is really needed if (null === $respondentId) { $respondentId = $this->util->getDbLookup()->getRespondentId($patientId, $organizationId); } // Cascade to tracks // the responsiblilty to handle it correctly is on the sub objects now. $tracks = $this->loader->getTracker()->getRespondentTracks($respondentId, $organizationId); foreach ($tracks as $track) { if ($track->setReceptionCode($code, null, $userId)) { $this->addChanged(); } } } if ($code->isForRespondents()) { $this->handleRespondentChanged($patientId, $organizationId, $respondentId); } return $code; }
/** * 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; }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); if ($this->organizationField) { $user = $this->loader->getCurrentUser(); if ($this->respondentOrganizations) { $availableOrganizations = $this->util->getDbLookup()->getOrganizationsWithRespondents(); } else { $availableOrganizations = $this->util->getDbLookup()->getActiveOrganizations(); } if ($user->hasPrivilege('pr.staff.see.all')) { // Select organization $options = $availableOrganizations; } else { $options = array_intersect($availableOrganizations, $user->getAllowedOrganizations()); } if ($options) { $elements[] = $this->_createSelectElement($this->organizationField, $options, $this->_('(all organizations)')); } } return $elements; }
/** * 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; }
/** * 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; }
/** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. * * @return boolean False if required are missing. */ public function checkRegistryRequestsAnswers() { if (!$this->organizationId) { if ($this->respondent) { $this->organizationId = $this->respondent->getOrganizationId(); } if (!$this->organizationId) { $this->organizationId = $this->request->getParam(\MUtil_Model::REQUEST_ID2); } } if ($this->organizationId && !$this->respondentId) { if ($this->respondent) { $this->respondentId = $this->respondent->getId(); } if (!$this->respondentId) { $this->respondentId = $this->util->getDbLookup()->getRespondentId($this->request->getParam(\MUtil_Model::REQUEST_ID1), $this->organizationId); } } return $this->organizationId && $this->respondentId && $this->db && $this->model; }
/** * 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); } } }
/** * Start the cron mail monitor * * @return boolean True when the job was started */ public function reverseMaintenanceMonitor() { $job = new MonitorJob($this->project->getName() . ' maintenance mode'); $lock = $this->util->getMaintenanceLock(); if ($lock->isLocked()) { $job->stop(); $lock->unlock(); return false; } $lock->lock(); $roles = $this->util->getDbLookup()->getRolesByPrivilege('pr.maintenance.maintenance-mode'); if ($roles) { $where = 'gsf_id_primary_group IN (SELECT ggp_id_group FROM gems__groups WHERE ggp_role IN (' . implode(', ', array_map(array($this->db, 'quote'), array_keys($roles))) . '))'; } else { $where = null; } $to = $this->_getMailTo('maintenancemode', $where); if (!$to) { return true; } switch ($this->project->getLocaleDefault()) { case 'nl': $initSubject = "{name} is aangezet"; $initBbText = "L.S.,\n\nDe [b]{name}[/b] is op {setTime} aangezet.\n\nZolang dit aan blijft staan kan u regelmatig waarschuwingen krijgen.\n\nDit is een automatisch bericht."; $subject = "{name} staat al meer dan {periodHours} uur aan"; $messageBbText = "L.S.,\n\nDe [b]{name}[/b] is op {setTime} aangezet en staat nog steeds aan.\n\nDit is waarschuwing nummer [b]{mailCount}[/b]. Controleer s.v.p. of de onderhouds modus nog steeds nodig is.\n\nDit is een automatische waarschuwing."; break; default: $initSubject = "{name} has been turned on"; $initBbText = "L.S.,\n\nThe [b]{name}[/b] was activated at {setTime}.\n\nAs long as maintenance mode is active the system may send you warning messages.\n\nThis messages was send automatically."; $subject = "{name} has been active for over {periodHours} hours"; $messageBbText = "L.S.,\n\nThe [b]{name}[/b] was activated at {setTime} and is still active.\n\nThis is notice number {mailCount}. Please check whether the maintenance mode is still required.\n\nThis messages was send automatically."; break; } $job->setFrom($this->project->getMonitorFrom('maintenancemode'))->setMessage($messageBbText)->setPeriod($this->project->getMonitorPeriod('maintenancemode'))->setSubject($subject)->setTo($to); if ($job->start()) { $job->sendOtherMail($initSubject, $initBbText); } return true; }
/** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. * * @return boolean False if required are missing. */ public function checkRegistryRequestsAnswers() { if (!$this->organizationId) { if (isset($this->respondentData)) { foreach ($this->organizationFields as $field) { if (isset($this->respondentData[$field]) && $this->respondentData[$field]) { $this->organizationId = $this->respondentData[$field]; break; } } } if (!$this->organizationId) { $this->organizationId = $this->request->getParam(\MUtil_Model::REQUEST_ID2); } } if ($this->organizationId && !$this->respondentId) { if (isset($this->respondentData)) { foreach ($this->respondentFields as $field) { if (isset($this->respondentData[$field]) && $this->respondentData[$field]) { $this->respondentId = $this->respondentData[$field]; break; } } } if (!$this->respondentId) { $this->respondentId = $this->util->getDbLookup()->getRespondentId($this->request->getParam(\MUtil_Model::REQUEST_ID1), $this->organizationId); } } return $this->organizationId && $this->respondentId && $this->db && $this->model; }
/** * Allowes a refresh of the existing list of organizations * for this user. * * @return \Gems_User_User (continuation pattern) */ public function refreshAllowedOrganizations() { // Privilege overrules organizational settings if ($this->hasPrivilege('pr.organization-switch')) { $orgs = $this->util->getDbLookup()->getOrganizations(); } else { $org = $this->getBaseOrganization(); $orgs = array($org->getId() => $org->getName()) + $org->getAllowedOrganizations(); } // \MUtil_Echo::track($orgs); $this->_setVar('__allowedOrgs', $orgs); // Clean this cache $this->_unsetVar('__allowedRespOrgs'); return $this; }
/** * 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 survey object and use it */ protected function loadSurvey() { if (!$this->surveyList) { $this->addMessageInvalid($this->_('Survey insertion impossible: no insertable survey exists!')); } if (count($this->surveyList) === 1) { $model = $this->getModel(); $model->set('gto_id_survey', 'elementClass', 'Exhibitor'); reset($this->surveyList); $this->formData['gto_id_survey'] = key($this->surveyList); } if (isset($this->formData['gto_id_survey'])) { $this->survey = $this->tracker->getSurvey($this->formData['gto_id_survey']); $groupId = $this->survey->getGroupId(); $groups = $this->util->getDbLookup()->getGroups(); if (isset($groups[$groupId])) { $this->formData['ggp_name'] = $groups[$groupId]; } $this->formData['gto_valid_until'] = $this->survey->getInsertDateUntil($this->formData['gto_valid_from']); } }
/** * Get information on the field translations * * @return array of fields sourceName => targetName * @throws \MUtil_Model_ModelException */ public function getRespondentAnswerTranslations() { $this->_targetModel->set($this->patientNrField, 'label', $this->_('Patient ID'), 'order', 5, 'required', true, 'type', \MUtil_Model::TYPE_STRING); $this->_targetModel->set($this->orgIdField, 'label', $this->_('Organization ID'), 'multiOptions', $this->util->getDbLookup()->getOrganizationsWithRespondents(), 'order', 6, 'required', true, 'type', \MUtil_Model::TYPE_STRING); return array($this->patientNrField => $this->patientNrField, $this->orgIdField => $this->orgIdField); }
/** * Perform automatic job mail */ public function commJob() { /* \Zend_Mail::setDefaultTransport(new \Zend_Mail_Transport_File(array( 'callback' => function ($transport) { // throw new \Zend_Mail_Transport_Exception('Invalid e-mail address'); return $transport->recipients . '_' . time() . '_' . mt_rand() . '.tmp'; }, 'path' => GEMS_ROOT_DIR . '/var/sentmails' ))); // */ $dbLookup = $this->util->getDbLookup(); $mailLoader = $this->loader->getMailLoader(); $tracker = $this->loader->getTracker(); $model = $tracker->getTokenModel(); // Fix for #680: token with the valid from the longest in the past should be the // used as first token and when multiple rounds start at the same date the // lowest round order should be used. $model->setSort(array('gto_valid_from' => SORT_ASC, 'gto_round_order' => SORT_ASC)); // Check for unprocessed tokens $tracker->processCompletedTokens(null, $this->currentUser->getUserId()); $sql = "SELECT *\r\n FROM gems__comm_jobs INNER JOIN\r\n gems__comm_templates ON gcj_id_message = gct_id_template\r\n WHERE gcj_active = 1\r\n ORDER BY CASE WHEN gcj_id_survey IS NULL THEN 1 ELSE 0 END,\r\n CASE WHEN gcj_round_description IS NULL THEN 1 ELSE 0 END,\r\n CASE WHEN gcj_id_track IS NULL THEN 1 ELSE 0 END,\r\n CASE WHEN gcj_id_organization IS NULL THEN 1 ELSE 0 END"; $jobs = $this->db->fetchAll($sql); $mailed = false; if ($jobs) { foreach ($jobs as $job) { $sendByMail = $this->getUserEmail($job['gcj_id_user_as']); $filter = $dbLookup->getFilterForMailJob($job); $multipleTokensData = $model->load($filter); if (count($multipleTokensData)) { $errors = 0; $mails = 0; $updates = 0; $sentMailAddresses = array(); foreach ($multipleTokensData as $tokenData) { $mailer = $mailLoader->getMailer('token', $tokenData); /* @var $mailer \Gems_Mail_TokenMailer */ $token = $mailer->getToken(); $email = $token->getEmail(); $respondentId = $token->getRespondent()->getId(); if (!empty($email)) { if ($job['gcj_from_method'] == 'O') { $organization = $mailer->getOrganization(); $from = $organization->getEmail(); //$organization->getName() . ' <' . $organization->getEmail() . '>'; $mailer->setFrom($from); } elseif ($job['gcj_from_method'] == 'U') { $from = $sendByMail; $mailer->setFrom($from); } elseif ($job['gcj_from_method'] == 'F') { $mailer->setFrom($job['gcj_from_fixed']); } $mailer->setBy($sendByMail); try { if ($job['gcj_process_method'] == 'M') { $mailer->setTemplate($job['gcj_id_message']); $mailer->send(); $mailed = true; $mails++; $updates++; } elseif (!isset($sentMailAddresses[$respondentId][$email])) { $mailer->setTemplate($job['gcj_id_message']); $mailer->send(); $mailed = true; $mails++; $updates++; $sentMailAddresses[$respondentId][$email] = true; } elseif ($job['gcj_process_method'] == 'O') { $mailer->updateToken(); $updates++; } } catch (\Zend_Mail_Exception $exception) { $fields = $mailer->getMailFields(false); $info = sprintf("Error mailing to %s respondent %s with email address %s.", $fields['organization'], $fields['full_name'], $fields['email']); // Use a gems exception to pass extra information to the log $gemsException = new \Gems_Exception($info, 0, $exception); \Gems_Log::getLogger()->logError($gemsException); $errors++; } } } $this->addMessage(sprintf($this->_('Sent %d e-mails with template %s, updated %d tokens.'), $mails, $job['gct_name'], $updates)); if ($errors) { $this->addMessage(sprintf($this->_('%d error(s) occurred while creating mails for template %s. Check error log for details.'), $errors, $job['gct_name'])); } } $tokensData = null; } } if (!$mailed) { $this->addMessage($this->_('No mails sent.')); } }
/** * 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; }