/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($lineNr = null, $roundData = null) { $batch = $this->getBatch(); $import = $batch->getVariable('import'); if (!(isset($import['trackId']) && $import['trackId'])) { // Do nothing return; } // Only save when export code is known and set if (!isset($roundData['survey_export_code'], $import['surveyCodes'][$roundData['survey_export_code']])) { // Do nothing, no survey export code or no known export code return; } if (!$import['surveyCodes'][$roundData['survey_export_code']]) { // Export code not set to skip import of round return; } $fieldCodes = $import['fieldCodes']; $roundOrders = isset($import['roundOrders']) ? $import['roundOrders'] : array(); $tracker = $this->loader->getTracker(); $trackEngine = $tracker->getTrackEngine($import['trackId']); $model = $trackEngine->getRoundModel(true, 'create'); $roundData['gro_id_track'] = $import['trackId']; $roundData['gro_id_survey'] = $import['surveyCodes'][$roundData['survey_export_code']]; if (isset($roundData['valid_after']) && $roundData['valid_after']) { if (isset($roundOrders[$roundData['valid_after']]) && $roundOrders[$roundData['valid_after']]) { $roundData['gro_valid_after_id'] = $roundOrders[$roundData['valid_after']]; } else { $batch->addTask('Tracker\\Import\\UpdateRoundValidTask', $lineNr, $roundData['gro_id_order'], $roundData['valid_after'], 'gro_valid_after_id'); } } if (isset($roundData['gro_valid_after_source'], $fieldData['gro_valid_after_field'])) { switch ($roundData['gro_valid_after_source']) { case self::APPOINTMENT_TABLE: case self::RESPONDENT_TRACK_TABLE: if (isset($fieldCodes[$fieldData['gro_valid_after_field']])) { $fieldData['gro_valid_after_field'] = $fieldCodes[$fieldData['gro_valid_after_field']]; } } } if (isset($roundData['valid_for']) && $roundData['valid_for']) { if (isset($roundOrders[$roundData['valid_for']]) && $roundOrders[$roundData['valid_for']]) { $roundData['gro_valid_for_id'] = $roundOrders[$roundData['valid_for']]; } else { $batch->addTask('Tracker\\Import\\UpdateRoundValidTask', $lineNr, $roundData['gro_id_order'], $roundData['valid_for'], 'gro_valid_for_id'); } } if (isset($roundData['gro_valid_for_source'], $fieldData['gro_valid_for_field'])) { switch ($roundData['gro_valid_for_source']) { case self::APPOINTMENT_TABLE: case self::RESPONDENT_TRACK_TABLE: if (isset($fieldCodes[$fieldData['gro_valid_for_field']])) { $fieldData['gro_valid_for_field'] = $fieldCodes[$fieldData['gro_valid_for_field']]; } } } $roundData = $model->save($roundData); $import['rounds'][$lineNr]['gro_id_round'] = $roundData['gro_id_round']; $import['roundOrders'][$roundData['gro_id_order']] = $roundData['gro_id_round']; }
/** * Hook that allows actions when the form is submitted, but it was not the submit button that was checked * * When not rerouted, the form will be populated afterwards */ protected function onFakeSubmit() { if (isset($this->formData['create_account']) && $this->formData['create_account']) { $mail = $this->loader->getMailLoader()->getMailer('staffPassword', $this->user->getUserId()); $mail->setOrganizationFrom(); if ($mail->setCreateAccountTemplate()) { $mail->send(); $this->addMessage($this->_('Create account mail sent')); $this->setAfterSaveRoute(); } else { $this->addMessage($this->_('No default Create Account mail template set in organization or project')); } return; } if (isset($this->formData['reset_password']) && $this->formData['reset_password']) { $mail = $this->loader->getMailLoader()->getMailer('staffPassword', $this->user->getUserId()); $mail->setOrganizationFrom(); if ($mail->setResetPasswordTemplate()) { $mail->send(); $this->addMessage($this->_('Reset password mail sent')); $this->setAfterSaveRoute(); } else { $this->addMessage($this->_('No default Reset Password mail template set in organization or project')); } } }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task * * @param array $trackData Nested array of trackdata */ public function execute($lineNr = null, $fieldData = null) { $batch = $this->getBatch(); $import = $batch->getVariable('import'); if (isset($fieldData['gtf_id_order']) && $fieldData['gtf_id_order']) { $import['fieldOrder'][$fieldData['gtf_id_order']] = false; if ($batch->hasVariable('trackEngine') && isset($fieldData['gtf_field_type']) && $fieldData['gtf_field_type']) { $trackEngine = $batch->getVariable('trackEngine'); if ($trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $fieldDef = $trackEngine->getFieldsDefinition(); $field = $fieldDef->getFieldByOrder($fieldData['gtf_id_order']); if ($field instanceof FieldInterface) { if ($field->getFieldType() != $fieldData['gtf_field_type']) { $batch->addToCounter('import_errors'); $batch->addMessage(sprintf($this->_('Conflicting field types "%s" and "%s" for field orders %d specified on line %d.'), $field->getFieldType(), $fieldData['gtf_field_type'], $fieldData['gtf_id_order'], $lineNr)); } } } } } else { $batch->addToCounter('import_errors'); $batch->addMessage(sprintf($this->_('No gtf_id_order specified for field at line %d.'), $lineNr)); } if (isset($fieldData['gtf_field_type']) && $fieldData['gtf_field_type']) { $model = $this->loader->getTracker()->createTrackClass('Model\\FieldMaintenanceModel'); $fields = $model->getFieldTypes(); if (!isset($fields[$fieldData['gtf_field_type']])) { $batch->addToCounter('import_errors'); $batch->addMessage(sprintf($this->_('Unknown field type "%s" specified on line %d.'), $fieldData['gtf_field_type'], $lineNr)); } } else { $batch->addToCounter('import_errors'); $batch->addMessage(sprintf($this->_('No field type specified on line %d.'), $lineNr)); } }
/** * 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); $user = $this->loader->getCurrentUser(); if ($user->hasPrivilege('pr.respondent.select-on-track')) { $tracks = $this->searchData['__active_tracks']; $masks['show_all'] = $this->_('(all)'); $masks['show_without_track'] = $this->_('(no track)'); if (count($tracks) > 1) { $masks['show_with_track'] = $this->_('(with track)'); } if (count($tracks) > 1) { $elements[] = $this->_createSelectElement('gr2t_id_track', $masks + $tracks); } else { $element = $this->_createRadioElement('gr2t_id_track', $masks + $tracks); $element->setSeparator(' '); $elements[] = $element; } $lineBreak = true; } else { $lineBreak = false; } if ($user->hasPrivilege('pr.respondent.show-deleted')) { $elements[] = $this->_createCheckboxElement('grc_success', $this->_('Show active')); } if ($this->model->isMultiOrganization()) { $element = $this->_createSelectElement(\MUtil_Model::REQUEST_ID2, $user->getRespondentOrganizations(), $this->_('(all organizations)')); if ($lineBreak) { $element->setLabel($this->_('Organization'))->setAttrib('onchange', 'this.form.submit();'); $elements[] = \MUtil_Html::create('br'); } $elements[] = $element; } return $elements; }
/** * 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) { $dbLookup = $this->util->getDbLookup(); $translated = $this->util->getTranslated(); $noRound = array(self::NoRound => $this->_('No round description')); $empty = $translated->getEmptyDropdownArray(); $rounds = $empty + $noRound + $dbLookup->getRoundsForExport(); $surveys = $dbLookup->getSurveysForExport(); $elements[] = $this->_createSelectElement('gto_id_survey', $surveys, $this->_('(select a survey)')); $elements[] = $this->_createSelectElement('gto_id_track', $this->util->getTrackData()->getAllTracks(), $this->_('(select a track)')); $elements[] = $this->_createSelectElement('gto_round_description', $rounds, $this->_('(select a round)')); $orgs = $this->loader->getCurrentUser()->getRespondentOrganizations(); if (count($orgs) > 1) { $elements[] = $this->_createSelectElement('gto_id_organization', $orgs, $this->_('(all organizations)')); } $elements[] = null; $dates = array('gto_start_date' => $this->_('Track start'), 'gto_end_date' => $this->_('Track end'), 'gto_valid_from' => $this->_('Valid from'), 'gto_valid_until' => $this->_('Valid until')); // $dates = 'gto_valid_from'; $this->_addPeriodSelectors($elements, $dates, 'gto_valid_from'); $elements[] = null; $element = $this->form->createElement('checkbox', 'column_identifiers'); $element->setLabel($this->_('Column Identifiers')); $element->setDescription($this->_('Prefix the column labels with an identifier. (A) Answers, (TF) Trackfields, (D) Description')); $elements[] = $element; $element = $this->form->createElement('checkbox', 'show_parent'); $element->setLabel($this->_('Show parent')); $element->setDescription($this->_('Show the parent column even if it doesn\'t have answers')); $elements[] = $element; $element = $this->form->createElement('checkbox', 'prefix_child'); $element->setLabel($this->_('Prefix child')); $element->setDescription($this->_('Prefix the child column labels with parent question label')); $elements[] = $element; $elements[] = null; return $elements; }
/** * Called after the check that all required registry values * have been set correctly has run. * * @return void */ public function afterRegistry() { parent::afterRegistry(); if (!$this->user) { $this->user = $this->loader->getCurrentUser(); } }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($tokenData = null, $userId = null) { $batch = $this->getBatch(); $tracker = $this->loader->getTracker(); $batch->addToCounter('checkedTokens'); $token = $tracker->getToken($tokenData); $wasAnswered = $token->isCompleted(); if ($result = $token->checkTokenCompletion($userId)) { if ($result & \Gems_Tracker_Token::COMPLETION_DATACHANGE) { $i = $batch->addToCounter('resultDataChanges'); $batch->setMessage('resultDataChanges', sprintf($this->_('Results and timing changed for %d tokens.'), $i)); if ($wasAnswered) { $action = 'token.data-changed'; $message = sprintf($this->_("Token '%s' data has changed."), $token->getTokenId()); } else { $action = 'token.answered'; $message = sprintf($this->_("Token '%s' was answered."), $token->getTokenId()); } if (!$this->request instanceof \Zend_Controller_Request_Abstract) { $this->request = \Zend_Controller_Front::getInstance()->getRequest(); } $this->accesslog->logEntry($this->request, $action, true, $message, $token->getArrayCopy(), $token->getRespondentId()); } if ($result & \Gems_Tracker_Token::COMPLETION_EVENTCHANGE) { $i = $batch->addToCounter('surveyCompletionChanges'); $batch->setMessage('surveyCompletionChanges', sprintf($this->_('Answers changed by survey completion event for %d tokens.'), $i)); } } if ($token->isCompleted()) { $batch->setTask('Tracker_ProcessTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId); } $batch->setMessage('checkedTokens', sprintf($this->_('Checked %d tokens.'), $batch->getCounter('checkedTokens'))); // Free memory $tracker->removeToken($token); }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task * * @param array $trackData Nested array of trackdata */ public function execute($formData = null) { $batch = $this->getBatch(); $import = $batch->getVariable('import'); $tracker = $this->loader->getTracker(); $model = $tracker->getTrackModel(); $model->applyFormatting(true, true); $trackData = $import['trackData']; $trackData['gtr_track_name'] = $formData['gtr_track_name']; $trackData['gtr_organizations'] = $formData['gtr_organizations']; if ($batch->hasVariable('trackEngine')) { $trackEngine = $batch->getVariable('trackEngine'); if ($trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $trackData['gtr_id_track'] = $trackEngine->getTrackId(); } } // \MUtil_Echo::track($trackData); if ($trackData['gtr_date_start'] && !$trackData['gtr_date_start'] instanceof \Zend_Date) { $trackData['gtr_date_start'] = new \MUtil_Date($trackData['gtr_date_start'], 'yyyy-MM-dd'); } $output = $model->save($trackData); $import['trackId'] = $output['gtr_id_track']; $import['trackData']['gtr_id_track'] = $output['gtr_id_track']; $batch->addMessage($this->_('Merged track data')); }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($respTrackData = null, $userId = null) { $batch = $this->getBatch(); $tracker = $this->loader->getTracker(); $respTrack = $tracker->getRespondentTrack($respTrackData); $engine = $respTrack->getTrackEngine(); $engine->checkRoundsFor($respTrack, $userId, $batch); }
/** * Get information on the field translations * * @return array of fields sourceName => targetName * @throws \MUtil_Model_ModelException */ public function getFieldsTranslations() { if (!$this->_targetModel instanceof \MUtil_Model_ModelAbstract) { throw new \MUtil_Model_ModelTranslateException(sprintf('Called %s without a set target model.', __FUNCTION__)); } $this->_targetModel->set('gto_id_token', 'label', $this->_('Token'), 'import_descr', $this->loader->getTracker()->getTokenLibrary()->getFormat(), 'required', true, 'order', 2); return array('token' => 'gto_id_token') + parent::getFieldsTranslations(); }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if (!$this->model instanceof LogModel) { $this->model = $this->loader->getModels()->createLogModel(); $this->model->applyDetailSettings(); } return $this->model; }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($surveyId = null, $questionId = null, $order = null) { $batch = $this->getBatch(); $survey = $this->loader->getTracker()->getSurvey($surveyId); // Now save the questions $answerModel = $survey->getAnswerModel('en'); $questionModel = new \MUtil_Model_TableModel('gems__survey_questions'); \Gems_Model::setChangeFieldsByPrefix($questionModel, 'gsq'); $label = $answerModel->get($questionId, 'label'); /* if ($label instanceof \MUtil_Html_HtmlInterface) { $label = $label->render($this->view); } // */ $question['gsq_id_survey'] = $surveyId; $question['gsq_name'] = $questionId; $question['gsq_name_parent'] = $answerModel->get($questionId, 'parent_question'); $question['gsq_order'] = $order; $question['gsq_type'] = $answerModel->getWithDefault($questionId, 'type', \MUtil_Model::TYPE_STRING); $question['gsq_class'] = $answerModel->get($questionId, 'thClass'); $question['gsq_group'] = $answerModel->get($questionId, 'group'); $question['gsq_label'] = $label; $question['gsq_description'] = $answerModel->get($questionId, 'description'); // \MUtil_Echo::track($question); try { $questionModel->save($question); } catch (\Exception $e) { $batch->addMessage(sprintf($this->_('Save failed for survey %s, question %s: %s'), $survey->getName(), $questionId, $e->getMessage())); } $batch->addToCounter('checkedQuestions'); if ($questionModel->getChanged()) { $batch->addToCounter('changedQuestions'); } $batch->setMessage('questionschanged', sprintf($this->_('%d of %d questions changed.'), $batch->getCounter('changedQuestions'), $batch->getCounter('checkedQuestions'))); $options = $answerModel->get($questionId, 'multiOptions'); if ($options) { $optionModel = new \MUtil_Model_TableModel('gems__survey_question_options'); \Gems_Model::setChangeFieldsByPrefix($optionModel, 'gsqo'); $option['gsqo_id_survey'] = $surveyId; $option['gsqo_name'] = $questionId; $i = 0; // \MUtil_Echo::track($options); foreach ($options as $key => $label) { $option['gsqo_order'] = $i; $option['gsqo_key'] = $key; $option['gsqo_label'] = $label; try { $optionModel->save($option); } catch (\Exception $e) { $batch->addMessage(sprintf($this->_('Save failed for survey %s, question %s, option "%s" => "%s": %s'), $survey->getName(), $questionId, $key, $label, $e->getMessage())); } $i++; } $batch->addToCounter('checkedOptions', count($options)); $batch->addToCounter('changedOptions', $optionModel->getChanged()); $batch->setMessage('optionschanged', sprintf($this->_('%d of %d options changed.'), $batch->getCounter('changedOptions'), $batch->getCounter('checkedOptions'))); } }
/** * Create the snippets content * * This is a stub function either override getHtmlOutput() or override render() * * @param \Zend_View_Abstract $view Just in case it is needed here * @return \MUtil_Html_HtmlInterface Something that can be rendered */ public function getHtmlOutput(\Zend_View_Abstract $view) { $messages = false; if ($this->wasAnswered) { $this->currentToken = $this->token->getNextUnansweredToken(); } else { $validator = $this->loader->getTracker()->getTokenValidator(); if ($validator->isValid($this->token->getTokenId())) { $this->currentToken = $this->token; } else { $messages = $validator->getMessages(); $this->currentToken = $this->token->getNextUnansweredToken(); } } if ($this->currentToken instanceof \Gems_Tracker_Token) { $href = $this->getTokenHref($this->currentToken); $url = $href->render($this->view); // Redirect at once header('Location: ' . $url); exit; } // After the header() so that the patient does not see the messages after answering surveys if ($messages) { $this->addMessage($messages); } $org = $this->token->getOrganization(); $html = $this->getHtmlSequence(); $html->h3($this->_('Token')); $html->pInfo(sprintf($this->_('Thank you %s,'), $this->token->getRespondentName())); if ($welcome = $org->getWelcome()) { $html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html')); } $p = $html->pInfo()->spaced(); if ($this->wasAnswered) { $p->append($this->_('Thanks for answering our questions.')); } elseif (!$this->isValid) { if ($this->token->isExpired()) { $this->addMessage($this->_('This survey has expired. You can no longer answer it.')); } else { $this->addMessage($this->_('This survey is no longer valid.')); } } $p->append($this->_('We have no further questions for you at the moment.')); $p->append($this->_('We appreciate your cooperation very much.')); if ($sig = $org->getSignature()) { $html->pInfo()->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html')); } /* $html->br(); $href = array($this->request->getActionKey() => 'index', \MUtil_Model::REQUEST_ID => null); $buttonDiv = $html->buttonDiv(array('class' => 'centerAlign')); $buttonDiv->actionLink($href, $this->_('OK')); // */ return $html; }
public function afterRegistry() { $this->user = $this->loader->getUserLoader()->getUserByStaffId($this->staffId); parent::afterRegistry(); $this->user = $this->loader->getUserLoader()->getUserByStaffId($this->staffId); $mailFields = $this->user->getMailFields(); $this->addMailFields($mailFields); $this->addTo($this->user->getEmailAddress(), $this->user->getFullName()); $this->setLanguage($this->user->getLocale()); }
/** * 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 = $this->loader->getModels()->createLogModel(); if ($detailed) { $model->applyDetailSettings(); } else { $model->applyBrowseSettings(); } return $model; }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if ($this->model instanceof \Gems_Model_StaffModel) { $model = $this->model; } else { $model = $this->loader->getModels()->getStaffModel(); $model->applyBrowseSettings(); } return $model; }
public function afterRegistry() { if (!$this->respondent) { $this->respondent = $this->loader->getRespondent($this->patientId, $this->organizationId); } parent::afterRegistry(); if ($this->respondent) { $this->addTo($this->respondent->getEmailAddress(), $this->respondent->getName()); $this->setLanguage($this->respondent->getLanguage()); } }
/** * 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); $this->_addPeriodSelectors($elements, 'gla_created'); $elements[] = null; $elements[] = $this->_('Specific action'); $sql = "SELECT gls_id_action, gls_name\n FROM gems__log_setup\n WHERE gls_when_no_user = 1 OR gls_on_action = 1 OR gls_on_change = 1 OR gls_on_post = 1\n ORDER BY gls_name"; $elements[] = $this->_createSelectElement('gla_action', $sql, $this->_('(any action)')); $elements[] = $this->_createSelectElement('gla_organization', $this->loader->getCurrentUser()->getAllowedOrganizations(), $this->_('(all organizations)')); return $elements; }
/** * * @param \MUtil_Task_TaskBatch $batch Optional batch with different source etc.. * @return \MUtil_Task_TaskBatch */ public function getImportOnlyBatch(\MUtil_Task_TaskBatch $batch = null) { if (!$this->_importBatch instanceof \MUtil_Task_TaskBatch) { $batch = $this->loader->getTaskRunnerBatch(__CLASS__ . '_import_' . basename($this->sourceModel->getName()) . '_' . __FUNCTION__); $batch->setVariable('targetModel', $this->getTargetModel()); $this->_importBatch = $batch; } else { $batch = $this->_importBatch; } return parent::getImportOnlyBatch($batch); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->db = \Zend_Db::factory('pdo_sqlite', array('dbname' => ':memory:')); \Zend_Registry::set('db', $this->db); $settings = new \Zend_Config_Ini(GEMS_ROOT_DIR . '/configs/application.example.ini', APPLICATION_ENV); $sa = $settings->toArray(); $this->loader = new \Gems_Loader(\Zend_Registry::getInstance(), $sa['loaderDirs']); \Zend_Registry::set('loader', $this->loader); $this->tracker = $this->loader->getTracker(); \Zend_Registry::set('tracker', $this->tracker); }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($sourceId = null, $userId = null) { $batch = $this->getBatch(); $source = $this->loader->getTracker()->getSource($sourceId); if (is_null($userId)) { $userId = $this->loader->getCurrentUser()->getUserId(); } $surveyCount = $batch->addToCounter('sourceSyncSources'); $batch->setMessage('sourceSyncSources', sprintf($this->plural('Check %s source', 'Check %s sources', $surveyCount), $surveyCount)); $source->synchronizeSurveyBatch($batch, $userId); }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($sourceId = null, $command = null) { $batch = $this->getBatch(); $params = array_slice(func_get_args(), 2); $source = $this->loader->getTracker()->getSource($sourceId); if ($messages = call_user_func_array(array($source, $command), $params)) { foreach ($messages as $message) { $batch->addMessage($command . ': ' . $message); } } }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute() { $batch = $this->getBatch(); $import = $batch->getVariable('import'); if (!(isset($import['trackId']) && $import['trackId'])) { // Do nothing return; } $tracker = $this->loader->getTracker(); $trackEngine = $tracker->getTrackEngine($import['trackId']); $trackEngine->updateRoundCount($this->currentUser->getUserLoginId()); }
/** * 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) { // Search text $elements = parent::getAutoSearchElements($data); $this->_addPeriodSelectors($elements, array('grco_created' => $this->_('Date sent'))); $br = \MUtil_Html::create()->br(); $elements[] = null; $dbLookup = $this->util->getDbLookup(); $elements[] = $this->_createSelectElement('gto_id_track', $this->util->getTrackData()->getAllTracks(), $this->_('(select a track)')); $elements[] = $this->_createSelectElement('gto_id_survey', $this->util->getTrackData()->getAllSurveys(), $this->_('(all surveys)')); $elements[] = $this->_createSelectElement('grco_organization', $this->loader->getCurrentUser()->getRespondentOrganizations(), $this->_('(all organizations)')); return $elements; }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($respTrackData = null, $userId = null) { $batch = $this->getBatch(); $tracker = $this->loader->getTracker(); $respTrack = $tracker->getRespondentTrack($respTrackData); $i = $batch->addToCounter('checkedRespondentTracks'); if ($result = $respTrack->checkTrackTokens($userId)) { $a = $batch->addToCounter('tokenDateCauses'); $b = $batch->addToCounter('tokenDateChanges', $result); $batch->setMessage('tokenDateChanges', sprintf($this->_('%2$d token date changes in %1$d tracks.'), $a, $b)); } $batch->setMessage('checkedRespondentTracks', sprintf($this->_('Checked %d tracks.'), $i)); }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if ($this->model instanceof \Gems_Tracker_Model_StandardTokenModel) { $model = $this->model; } else { $model = $this->loader->getTracker()->getTokenModel(); } $model->addColumn('CASE WHEN gto_completion_time IS NULL THEN gto_valid_from ELSE gto_completion_time END', 'calc_used_date', 'gto_valid_from'); $model->addColumn('CASE WHEN gto_completion_time IS NULL THEN gto_valid_from ELSE NULL END', 'calc_valid_from', 'gto_valid_from'); $model->addColumn('CASE WHEN gto_completion_time IS NULL AND grc_success = 1 AND gto_valid_from <= CURRENT_TIMESTAMP AND gto_completion_time IS NULL AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP) THEN gto_id_token ELSE NULL END', 'calc_id_token', 'gto_id_token'); $model->addColumn('CASE WHEN gto_completion_time IS NULL AND grc_success = 1 AND gto_valid_from <= CURRENT_TIMESTAMP AND gto_completion_time IS NULL AND gto_valid_until < CURRENT_TIMESTAMP THEN 1 ELSE 0 END', 'was_missed'); return $model; }
/** * 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; }
/** * Process the respondent and return true when data has changed. * * The event has to handle the actual storage of the changes. * * @param \Gems_Tracker_Respondent $respondent * @param int $userId The current user * @return boolean True when something changed */ public function processChangedRespondent(\Gems_Tracker_Respondent $respondent) { $changes = 0; $tracker = $this->loader->getTracker(); $respTracks = $tracker->getRespondentTracks($respondent->getId(), $respondent->getOrganizationId()); $userId = $this->currentUser->getUserId(); foreach ($respTracks as $respondentTrack) { if ($respondentTrack instanceof \Gems_Tracker_RespondentTrack) { $changes += $respondentTrack->checkTrackTokens($userId); } } // \MUtil_Echo::track('Hi there! ' . $changes); return (bool) $changes; }
/** * 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); $orgs = $this->currentUser->getRespondentOrganizations(); if (count($orgs) > 1) { $elements[] = $this->_createSelectElement('gap_id_organization', $orgs, $this->_('(all organizations)')); } $locations = $this->loader->getAgenda()->getLocations(); if (count($locations) > 1) { $elements[] = $this->_createSelectElement('gap_id_location', $locations, $this->_('(all locations)')); } $elements[] = null; $this->_addPeriodSelectors($elements, 'gap_admission_time'); return $elements; }
/** * Should handle execution of the task, taking as much (optional) parameters as needed * * The parameters should be optional and failing to provide them should be handled by * the task */ public function execute($tokenId = null) { $batch = $this->getBatch(); $tracker = $this->loader->getTracker(); $token = $tracker->getToken($tokenId); $checked = $batch->addToCounter('ta-checkedTokens'); if ($token->inSource()) { $survey = $token->getSurvey(); if ($survey->copyTokenToSource($token, '')) { $batch->addToCounter('ta-changedTokens'); } } $cTokens = $batch->getCounter('ta-changedTokens'); $batch->setMessage('ta-check', sprintf($this->plural('%d token out of %d tokens changed.', '%d tokens out of %d tokens changed.', $cTokens), $cTokens, $checked)); }