From: <gem...@li...> - 2012-04-26 11:36:48
|
Revision: 638 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=638&view=rev Author: matijsdejong Date: 2012-04-26 11:36:37 +0000 (Thu, 26 Apr 2012) Log Message: ----------- Bugfixes for Organization.php and OnClickArrayAttribute.php Fix for #12 screen where patients return Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php trunk/library/classes/Gems/User/Organization.php trunk/library/classes/MUtil/Html/OnClickArrayAttribute.php trunk/library/languages/default-en.mo trunk/library/languages/default-en.po trunk/library/languages/default-nl.mo trunk/library/languages/default-nl.po Added Paths: ----------- trunk/library/snippets/Track/Token/ShowAllOpenSnippet.php Modified: trunk/library/classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php 2012-04-26 09:10:32 UTC (rev 637) +++ trunk/library/classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php 2012-04-26 11:36:37 UTC (rev 638) @@ -47,6 +47,12 @@ class Gems_Tracker_Snippets_ShowTokenLoopAbstract extends MUtil_Snippets_SnippetAbstract { /** + * General date format + * @var string + */ + protected $dateFormat = 'd MMMM yyyy'; + + /** * Required * * @var Zend_Controller_Request_Abstract @@ -95,6 +101,70 @@ } /** + * Formats an completion date for this display + * + * @param MUtil_Date $dateTime + * @return string + */ + public function formatCompletion(MUtil_Date $dateTime) + { + $days = abs($dateTime->diffDays()); + + switch ($days) { + case 0: + return $this->_('We have received your answers today. Thank you!'); + + case 1: + return $this->_('We have received your answers yesterday. Thank you!'); + + case 2: + return $this->_('We have received your answers 2 days ago. Thank you.'); + + default: + if ($days <= 14) { + return sprintf($this->_('We have received your answers %d days ago. Thank you.'), $days); + } + return sprintf($this->_('We have received your answers on %s. '), $dateTime->toString($this->dateFormat)); + } + } + + /** + * Formats an until date for this display + * + * @param MUtil_Date $dateTime + * @return string + */ + public function formatUntil(MUtil_Date $dateTime = null) + { + if (null === $dateTime) { + return $this->_('This survey has no set time limit.'); + } + + $days = $dateTime->diffDays(); + + switch ($days) { + case 0: + return array(MUtil_Html::create('strong', $this->_('Warning!!!')), ' ', $this->_('This survey must be answered today!')); + + case 1: + return array(MUtil_Html::create('strong', $this->_('Warning!!')), ' ', $this->_('This survey must be answered tomorrow!')); + + case 2: + return $this->_('Warning! This survey must be answered over 2 days!'); + + default: + if (abs($days) <= 14) { + if ($days >= 0) { + return sprintf($this->_('This survey must be answered in %d days.'), $days); + } else { + return $this->_('This survey can no longer be answered.'); + } + } + return sprintf($this->_('This survey can be answered until %s.'), $dateTime->toString($this->dateFormat)); + } + } + + /** * Get the href for a token * * @param Gems_Tracker_Token $token Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2012-04-26 09:10:32 UTC (rev 637) +++ trunk/library/classes/Gems/User/Organization.php 2012-04-26 11:36:37 UTC (rev 638) @@ -340,7 +340,7 @@ $organizationId = $this->getId(); if (! Gems_Cookies::setOrganization($organizationId, $this->basepath->getBasePath())) { - throw new Exception($this->translate->_('Cookies must be enabled for this site.')); + throw new Exception('Cookies must be enabled for this site.'); } $escort = GemsEscort::getInstance(); Modified: trunk/library/classes/MUtil/Html/OnClickArrayAttribute.php =================================================================== --- trunk/library/classes/MUtil/Html/OnClickArrayAttribute.php 2012-04-26 09:10:32 UTC (rev 637) +++ trunk/library/classes/MUtil/Html/OnClickArrayAttribute.php 2012-04-26 11:36:37 UTC (rev 638) @@ -95,9 +95,14 @@ */ public function addUrl($href) { - $this->add("location.href='"); - $this->add($href); - $this->add("';"); + $last = is_array($this->_values) ? end($this->_values) : null; + if (false === strpos($last, 'location.href')) { + $this->_values[] = "location.href='"; + $this->_values[] = $href; + $this->_values[] = "';"; + } else { + $this->_values[] = $href; + } return $this; } Modified: trunk/library/languages/default-en.mo =================================================================== (Binary files differ) Modified: trunk/library/languages/default-en.po =================================================================== --- trunk/library/languages/default-en.po 2012-04-26 09:10:32 UTC (rev 637) +++ trunk/library/languages/default-en.po 2012-04-26 11:36:37 UTC (rev 638) @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: GemsTracker EN\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-25 16:16+0100\n" +"POT-Creation-Date: 2012-04-26 13:30+0100\n" "PO-Revision-Date: \n" "Last-Translator: Matijs de Jong <mj...@ma...>\n" "Language-Team: Erasmus MGZ <mat...@ma...>\n" @@ -3375,6 +3375,66 @@ msgid "Next >" msgstr "Next >" +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:115 +msgid "We have received your answers today. Thank you!" +msgstr "We have received your answers today. Thank you!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:118 +msgid "We have received your answers yesterday. Thank you!" +msgstr "We have received your answers yesterday. Thank you!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:121 +msgid "We have received your answers 2 days ago. Thank you." +msgstr "We have received your answers 2 days ago. Thank you." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:125 +#, php-format +msgid "We have received your answers %d days ago. Thank you." +msgstr "We have received your answers %d days ago. Thank you." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:127 +#, php-format +msgid "We have received your answers on %s. " +msgstr "We have received your answers on %s. " + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:140 +msgid "This survey has no set time limit." +msgstr "This survey has no set time limit." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:147 +msgid "Warning!!!" +msgstr "Warning!!!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:147 +msgid "This survey must be answered today!" +msgstr "This survey must be answered today!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:150 +msgid "Warning!!" +msgstr "Warning!!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:150 +msgid "This survey must be answered tomorrow!" +msgstr "This survey must be answered tomorrow!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:153 +msgid "Warning! This survey must be answered over 2 days!" +msgstr "Warning! This survey must be answered over 2 days!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:158 +#, php-format +msgid "This survey must be answered in %d days." +msgstr "This survey must be answered in %d days." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:160 +msgid "This survey can no longer be answered." +msgstr "This survey can no longer be answered." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:163 +#, php-format +msgid "This survey can be answered until %s." +msgstr "This survey can be answered until %s." + #: classes/Gems/Tracker/Source/LimeSurvey1m9Database.php:376 #: classes/Gems/Tracker/Source/LimeSurvey1m9Database.php:1156 #, php-format @@ -3545,10 +3605,6 @@ msgid "Unknown token." msgstr "Unknown token." -#: classes/Gems/User/Organization.php:342 -msgid "Cookies must be enabled for this site." -msgstr "Cookies must be enabled for this site." - #: classes/Gems/User/PasswordChecker.php:95 #, php-format msgid "should contain at least one uppercase character" @@ -3992,19 +4048,24 @@ msgstr "Edit track" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:172 +#: snippets/DeleteSingleSurveyNotUsedTokenSnippet.php:143 +#: snippets/DeleteTrackTokenSnippet.php:193 msgid "Edit token" msgstr "Edit token" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:225 +#: snippets/DeleteTrackTokenSnippet.php:245 #, php-format msgid "Redo of token %s." msgstr "Redo of token %s." #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:228 +#: snippets/DeleteTrackTokenSnippet.php:248 msgid "Old comment:" msgstr "Old comment:" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:249 +#: snippets/DeleteTrackTokenSnippet.php:269 #, php-format msgid "Created replacement token %2$s for token %1$s." msgstr "Created replacement token %2$s for token %1$s." @@ -4031,7 +4092,6 @@ msgstr "Lists choices changed." #: snippets/EditSingleSurveyTokenSnippet.php:132 -#: snippets/ShowSingleSurveyTokenSnippet.php:150 msgid "Show survey" msgstr "Show survey" @@ -4082,6 +4142,7 @@ msgstr "Selected surveys" #: snippets/ShowSingleSurveyTokenSnippet.php:76 +#: snippets/ShowTrackTokenSnippet.php:77 msgid "Actions" msgstr "Actions" @@ -4168,16 +4229,42 @@ msgid "Can access" msgstr "Can access" +#: snippets/Track/Token/ShowAllOpenSnippet.php:89 #: snippets/Track/Token/ShowFirstOpenSnippet.php:111 #, php-format msgid "Welcome %s," msgstr "Welcome %s," +#: snippets/Track/Token/ShowAllOpenSnippet.php:94 #: snippets/Track/Token/ShowFirstOpenSnippet.php:114 #, php-format msgid "Thank you for answering the \"%s\" survey." msgstr "Thank you for answering the \"%s\" survey." +#: snippets/Track/Token/ShowAllOpenSnippet.php:152 +#, php-format +msgid " (%s)" +msgstr " (%s)" + +#: snippets/Track/Token/ShowAllOpenSnippet.php:160 +#, php-format +msgid "Round: %s" +msgstr "Round: %s" + +#: snippets/Track/Token/ShowAllOpenSnippet.php:188 +msgid "Please answer the open survey." +msgid_plural "Please answer the open surveys." +msgstr[0] "Please answer the open survey." +msgstr[1] "Please answer the open surveys." + +#: snippets/Track/Token/ShowAllOpenSnippet.php:190 +msgid "Thank you for answering all open surveys." +msgstr "Thank you for answering all open surveys." + +#: snippets/Track/Token/ShowAllOpenSnippet.php:193 +msgid "There are no surveys to show for this token." +msgstr "There are no surveys to show for this token." + #: snippets/Track/Token/ShowFirstOpenSnippet.php:115 msgid "Please click the button below to answer the next survey." msgstr "Please click the button below to answer the next survey." @@ -4201,6 +4288,9 @@ msgstr[0] "After this survey there is one other survey we would like you to answer." msgstr[1] "After this survey there are another %d surveys we would like you to answer." +#~ msgid "Cookies must be enabled for this site." +#~ msgstr "Cookies must be enabled for this site." + #~ msgid "Combination of organization, username and password not found." #~ msgstr "Combination of organization, username and password not found." Modified: trunk/library/languages/default-nl.mo =================================================================== (Binary files differ) Modified: trunk/library/languages/default-nl.po =================================================================== --- trunk/library/languages/default-nl.po 2012-04-26 09:10:32 UTC (rev 637) +++ trunk/library/languages/default-nl.po 2012-04-26 11:36:37 UTC (rev 638) @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: GemsTracker NL\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-25 16:16+0100\n" +"POT-Creation-Date: 2012-04-26 13:31+0100\n" "PO-Revision-Date: \n" "Last-Translator: Matijs de Jong <mj...@ma...>\n" "Language-Team: Erasmus MGZ <mat...@ma...>\n" @@ -3375,6 +3375,66 @@ msgid "Next >" msgstr "Verder >" +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:115 +msgid "We have received your answers today. Thank you!" +msgstr "We hebben uw vragenlijst vandaag ingevuld ontvangen. Dank u wel!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:118 +msgid "We have received your answers yesterday. Thank you!" +msgstr "We hebben uw vragenlijst gisteren ingevuld ontvangen. Dank u wel!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:121 +msgid "We have received your answers 2 days ago. Thank you." +msgstr "We hebben uw vragenlijst eergisteren ingevuld ontvangen. Dank u wel." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:125 +#, php-format +msgid "We have received your answers %d days ago. Thank you." +msgstr "We hebben uw vragenlijst %d dagen geleden ingevuld ontvangen. Dank u wel." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:127 +#, php-format +msgid "We have received your answers on %s. " +msgstr "We hebben uw vragenlijst op %s ingevuld ontvangen." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:140 +msgid "This survey has no set time limit." +msgstr "Deze vragenlijst heeft geen eindtijd." + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:147 +msgid "Warning!!!" +msgstr "Let op!!!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:147 +msgid "This survey must be answered today!" +msgstr "Deze vragenlijst moet vandaag ingevuld zijn!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:150 +msgid "Warning!!" +msgstr "Let op!!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:150 +msgid "This survey must be answered tomorrow!" +msgstr "Deze vragenlijst moet morgen ingevuld zijn!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:153 +msgid "Warning! This survey must be answered over 2 days!" +msgstr "Let op! Deze vragenlijst moet overmorgen ingevuld zijn!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:158 +#, php-format +msgid "This survey must be answered in %d days." +msgstr "Deze vragenlijst moet binnen %d dagen ingevuld zijn!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:160 +msgid "This survey can no longer be answered." +msgstr "Deze vragenlijst kan niet langer worden ingevuld!" + +#: classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php:163 +#, php-format +msgid "This survey can be answered until %s." +msgstr "Deze vragenlijst moet ingevuld worden voor %s." + #: classes/Gems/Tracker/Source/LimeSurvey1m9Database.php:376 #: classes/Gems/Tracker/Source/LimeSurvey1m9Database.php:1156 #, php-format @@ -3545,10 +3605,6 @@ msgid "Unknown token." msgstr "Onbekend kenmerk." -#: classes/Gems/User/Organization.php:342 -msgid "Cookies must be enabled for this site." -msgstr "Zonder cookies heeft u geen toegang tot deze site." - #: classes/Gems/User/PasswordChecker.php:95 #, php-format msgid "should contain at least one uppercase character" @@ -3992,19 +4048,24 @@ msgstr "Bewerk traject" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:172 +#: snippets/DeleteSingleSurveyNotUsedTokenSnippet.php:143 +#: snippets/DeleteTrackTokenSnippet.php:193 msgid "Edit token" msgstr "Kenmerk bewerken" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:225 +#: snippets/DeleteTrackTokenSnippet.php:245 #, php-format msgid "Redo of token %s." msgstr "Herkansing voor kenmerk %s." #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:228 +#: snippets/DeleteTrackTokenSnippet.php:248 msgid "Old comment:" msgstr "Oude opmerkingen" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:249 +#: snippets/DeleteTrackTokenSnippet.php:269 #, php-format msgid "Created replacement token %2$s for token %1$s." msgstr "Kenmerk %s is vervangen door het nieuwe kenmerk %s." @@ -4031,7 +4092,6 @@ msgstr "Keuzelijst is veranderd." #: snippets/EditSingleSurveyTokenSnippet.php:132 -#: snippets/ShowSingleSurveyTokenSnippet.php:150 msgid "Show survey" msgstr "Toon vragenlijst" @@ -4082,6 +4142,7 @@ msgstr "Geselecteerde vragenlijsten" #: snippets/ShowSingleSurveyTokenSnippet.php:76 +#: snippets/ShowTrackTokenSnippet.php:77 msgid "Actions" msgstr "Acties" @@ -4168,16 +4229,42 @@ msgid "Can access" msgstr "Toegang tot" +#: snippets/Track/Token/ShowAllOpenSnippet.php:89 #: snippets/Track/Token/ShowFirstOpenSnippet.php:111 #, php-format msgid "Welcome %s," msgstr "Welkom %s," +#: snippets/Track/Token/ShowAllOpenSnippet.php:94 #: snippets/Track/Token/ShowFirstOpenSnippet.php:114 #, php-format msgid "Thank you for answering the \"%s\" survey." msgstr "Dank u voor het invullen van de \"%s\" vragenlijst." +#: snippets/Track/Token/ShowAllOpenSnippet.php:152 +#, php-format +msgid " (%s)" +msgstr " (%s)" + +#: snippets/Track/Token/ShowAllOpenSnippet.php:160 +#, php-format +msgid "Round: %s" +msgstr "Ronde: %s" + +#: snippets/Track/Token/ShowAllOpenSnippet.php:188 +msgid "Please answer the open survey." +msgid_plural "Please answer the open surveys." +msgstr[0] "Wij verzoeken u de openstaande vragenlijst nu in te vullen." +msgstr[1] "Wij verzoeken u de openstaande vragenlijsten nu in te vullen." + +#: snippets/Track/Token/ShowAllOpenSnippet.php:190 +msgid "Thank you for answering all open surveys." +msgstr "Dank u voor het beantwoorden van alle openstaande vragenlijsten." + +#: snippets/Track/Token/ShowAllOpenSnippet.php:193 +msgid "There are no surveys to show for this token." +msgstr "U heeft geen open vragenlijsten voor dit kenmerk." + #: snippets/Track/Token/ShowFirstOpenSnippet.php:115 msgid "Please click the button below to answer the next survey." msgstr "Klik op de onderstaande knop om de volgende vragenlijst in te vullen." @@ -4201,6 +4288,9 @@ msgstr[0] "Na deze vragenlijst hebben we nog één andere vragenlijst voor u." msgstr[1] "Na deze vragenlijst hebben we nog %d andere vragenlijsten voor u." +#~ msgid "Cookies must be enabled for this site." +#~ msgstr "Zonder cookies heeft u geen toegang tot deze site." + #~ msgid "Combination of organization, username and password not found." #~ msgstr "" #~ "Combinatie van organisatie, gebruikersnaam en wachtwoord niet gevonden." Added: trunk/library/snippets/Track/Token/ShowAllOpenSnippet.php =================================================================== --- trunk/library/snippets/Track/Token/ShowAllOpenSnippet.php (rev 0) +++ trunk/library/snippets/Track/Token/ShowAllOpenSnippet.php 2012-04-26 11:36:37 UTC (rev 638) @@ -0,0 +1,203 @@ +<?php + +/** + * Copyright (c) 2012, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Tracker\Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: ShowAllOpenSnippet.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage Tracker\Snippets + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.4 + */ +class Track_Token_ShowAllOpenSnippet extends Gems_Tracker_Snippets_ShowTokenLoopAbstract +{ + /** + * + * @var Zend_Db_Adapter_Abstract + */ + protected $db; + + /** + * + * @var Gems_Loader + */ + protected $loader; + + /** + * Show completed surveys answered in last X hours + * + * @var int + */ + protected $lookbackInHours = 24; + + /** + * + * @var Gems_Util + */ + protected $util; + + /** + * 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) + { + $html = $this->getHtmlSequence(); + $org = $this->token->getOrganization(); + $tracker = $this->loader->getTracker(); + + $html->h3($this->_('Token')); + $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->token->getRespondentName())); + $p->br(); + $p->br(); + + if ($this->wasAnswered) { + $html->pInfo(sprintf($this->_('Thank you for answering the "%s" survey.'), $this->token->getSurveyName())); + // $html->pInfo($this->_('Please click the button below to answer the next survey.')); + } else { + if ($welcome = $org->getWelcome()) { + $html->pInfo()->raw(MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html')); + } + // $html->pInfo(sprintf($this->_('Please click the button below to answer the survey for token %s.'), strtoupper($this->token->getTokenId()))); + } + + // Only valid or answerd in the last + $where = "(gto_completion_time IS NULL AND gto_valid_from <= CURRENT_TIMESTAMP AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP))"; + + // Do we always look back + if ($this->lookbackInHours) { + $where .= $this->db->quoteInto("OR DATE_ADD(gto_completion_time, INTERVAL ? HOUR) >= CURRENT_TIMESTAMP", $this->lookbackInHours, Zend_Db::INT_TYPE); + } + + // We always look back from the entered token + if ($this->token->isCompleted()) { + $filterTime = $this->token->getCompletionTime(); + $filterTime->subHour(1); + $where .= $this->db->quoteInto(" OR gto_completion_time >= ?", $filterTime->toString('yyyy-MM-dd HH:mm:ss')); + } + + // Get the tokens + $select = $tracker->getTokenSelect(); + $select->andReceptionCodes() + ->andRespondentTracks() + ->andRounds() + ->andSurveys() + ->andTracks() + ->forGroupId($this->token->getSurvey()->getGroupId()) + ->forRespondent($this->token->getRespondentId(), $this->token->getOrganizationId()) + ->onlySucces() + ->forWhere($where) + ->order('gtr_track_type') + ->order('gtr_track_name') + ->order('gr2t_track_info') + ->order('gto_valid_until') + ->order('gto_valid_from'); + + if ($tokens = $select->fetchAll()) { + $currentToken = $this->token->isCompleted() ? false : $this->token->getTokenId(); + $lastRound = false; + $lastTrack = false; + $open = 0; + $pStart = $html->pInfo(); + + foreach ($tokens as $row) { + if (('T' == $row['gtr_track_type']) && ($row['gtr_track_name'] !== $lastTrack)) { + $lastTrack = $row['gtr_track_name']; + + $div = $html->div(); + $div->class = 'askTrack'; + $div->append($this->_('Track')); + $div->append(' '); + $div->strong($row['gtr_track_name']); + if ($row['gr2t_track_info']) { + $div->small(sprintf($this->_(' (%s)'), $row['gr2t_track_info'])); + } + } + + if ($row['gto_round_description'] && ($row['gto_round_description'] !== $lastRound)) { + $lastRound = $row['gto_round_description']; + $div = $html->div(); + $div->class = 'askRound'; + $div->append(sprintf($this->_('Round: %s'), $row['gto_round_description'])); + $div->br(); + } + $token = $tracker->getToken($row); + + $div = $html->div(); + $div->class = 'askSurvey'; + if ($token->isCompleted()) { + $div->actionDisabled($token->getSurveyName()); + $div->append(' '); + $div->append($this->formatCompletion($token->getCompletionTime())); + + } else { + $open++; + + $a = $div->actionLink($this->getTokenHref($token), $token->getSurveyName()); + $div->append(' '); + $div->append($this->formatUntil($token->getValidUntil())); + + if (false === $currentToken) { + $currentToken = $token->getTokenId(); + } + if ($token->getTokenId() == $currentToken) { + $a->appendAttrib('class', 'currentRow'); + } + } + } + if ($open) { + $pStart->append($this->plural('Please answer the open survey.', 'Please answer the open surveys.', $open)); + } else { + $html->pInfo($this->_('Thank you for answering all open surveys.')); + } + } else { + $html->pInfo($this->_('There are no surveys to show for this token.')); + } + + if ($sig = $org->getSignature()) { + $p = $html->pInfo(); + $p->br(); + $p->raw(MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html')); + } + return $html; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |