Commit 04a199b65186e0b99bac76c421dc6cb12f733a8a
1 parent
ee5fb602
Merged in from DEV trunk...
KTC-541 "On Task Scheduler Management Page in web interface - 'Frequency' drop-down and save button combo jumps" Fixed. The drop-down form is now displayed in the table cell and not as a floating div. KTC-542 "Task Scheduler Management Page - remove 'Clean-up old tasks' link at the bottom of the page" Fixed. Removed the link. KTS-3417 "Scheduler - replace YUI with ExtJS" Fixed. Removed the yui ajax, used an extjs request. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/branches/3.5.3-Branch@8580 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
147 additions
and
108 deletions
plugins/ktcore/scheduler/schedulerEntity.php
| @@ -6,31 +6,31 @@ | @@ -6,31 +6,31 @@ | ||
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2008 KnowledgeTree Inc. | 7 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | 9 | + * |
| 10 | * This program is free software; you can redistribute it and/or modify it under | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | * the terms of the GNU General Public License version 3 as published by the | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | * Free Software Foundation. | 12 | * Free Software Foundation. |
| 13 | - * | 13 | + * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | * details. | 17 | * details. |
| 18 | - * | 18 | + * |
| 19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | ||
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | 21 | + * |
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | * California 94120-7775, or email info@knowledgetree.com. | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | 24 | + * |
| 25 | * The interactive user interfaces in modified source and object code versions | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | * of this program must display Appropriate Legal Notices, as required under | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | * Section 5 of the GNU General Public License version 3. | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | 28 | + * |
| 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | * these Appropriate Legal Notices must retain the display of the "Powered by | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | 33 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 34 | * copyright notice. | 34 | * copyright notice. |
| 35 | * Contributor( s): ______________________________________ | 35 | * Contributor( s): ______________________________________ |
| 36 | * | 36 | * |
| @@ -201,9 +201,9 @@ class schedulerEntity extends KTEntity | @@ -201,9 +201,9 @@ class schedulerEntity extends KTEntity | ||
| 201 | $sStatus = $this->getStatus(); | 201 | $sStatus = $this->getStatus(); |
| 202 | $sFreqs = $this->getFrequencyByLang(); | 202 | $sFreqs = $this->getFrequencyByLang(); |
| 203 | 203 | ||
| 204 | - $sLink = "<a href='#' id='freqDrop{$sId}' onclick='javascript: showFrequencyDiv(\"{$sId}\");'"; | 204 | + $sLink = "<div id='div{$sId}'"; |
| 205 | $sLink .= ($sStatus == 'disabled') ? 'style="visibility: hidden;" >' : '>'; | 205 | $sLink .= ($sStatus == 'disabled') ? 'style="visibility: hidden;" >' : '>'; |
| 206 | - $sLink .= "<div id='div{$sId}'>$sFreqs</div></a>"; | 206 | + $sLink .= $sFreqs.'</div>'; |
| 207 | return $sLink; | 207 | return $sLink; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| @@ -214,9 +214,10 @@ class schedulerEntity extends KTEntity | @@ -214,9 +214,10 @@ class schedulerEntity extends KTEntity | ||
| 214 | $sId = $this->getId(); | 214 | $sId = $this->getId(); |
| 215 | $sStatus = $this->getStatus(); | 215 | $sStatus = $this->getStatus(); |
| 216 | 216 | ||
| 217 | - $sLink = "<a href='#' id='freqLink{$this->getId()}' onclick='javascript: showFrequencyDiv({$sId});'"; | ||
| 218 | - $sLink .= ($sStatus == 'disabled') ? 'style="visibility: hidden;" >' : '>'; | ||
| 219 | - $sLink .= _kt('Alter frequency')."</a>"; | 217 | + $sLink = "<input type='button' id='freqLink{$this->getId()}' onclick='javascript: showFrequencyDiv(\"{$sId}\");'"; |
| 218 | + $sLink .= " value='"._kt('Change Frequency')."' "; | ||
| 219 | + $sLink .= ($sStatus == 'disabled') ? 'style="visibility: hidden;" />' : ' />'; | ||
| 220 | + | ||
| 220 | return $sLink; | 221 | return $sLink; |
| 221 | } | 222 | } |
| 222 | 223 | ||
| @@ -228,9 +229,11 @@ class schedulerEntity extends KTEntity | @@ -228,9 +229,11 @@ class schedulerEntity extends KTEntity | ||
| 228 | $sStatus = $this->getStatus(); | 229 | $sStatus = $this->getStatus(); |
| 229 | $sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateRunTime'); | 230 | $sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateRunTime'); |
| 230 | 231 | ||
| 231 | - $sLink = "<a href='#' id='runnowLink{$this->getId()}' onclick='javascript: runOnNext(\"{$sId}\", \"{$sUrl}\");'"; | ||
| 232 | - $sLink .= ($sStatus == 'disabled') ? 'style="visibility: hidden;" >' : '>'; | ||
| 233 | - $sLink .= _kt('Run on next iteration')."</a>"; | 232 | + $sTitle = _kt('This task will run the next time the Scheduler runs'); //, and then revert to the frequency you set on this page'); |
| 233 | + $sLink = "<input type='button' id='runnowLink{$this->getId()}' onclick='javascript: runOnNext(\"{$sId}\", \"{$sUrl}\");'"; | ||
| 234 | + $sLink .= " title='$sTitle' value='"._kt('Run on Next Iteration')."' "; | ||
| 235 | + $sLink .= ($sStatus == 'disabled') ? 'style="visibility: hidden;" />' : ' />'; | ||
| 236 | + | ||
| 234 | return $sLink; | 237 | return $sLink; |
| 235 | } | 238 | } |
| 236 | 239 | ||
| @@ -244,13 +247,13 @@ class schedulerEntity extends KTEntity | @@ -244,13 +247,13 @@ class schedulerEntity extends KTEntity | ||
| 244 | return ''; | 247 | return ''; |
| 245 | } | 248 | } |
| 246 | 249 | ||
| 247 | - $sDisableText = _kt('Disable task'); | ||
| 248 | - $sEnableText = _kt('Enable task'); | 250 | + $sDisableText = _kt('Disable Task'); |
| 251 | + $sEnableText = _kt('Enable Task'); | ||
| 249 | 252 | ||
| 250 | $sLinkText = ($sStatus == 'enabled') ? $sDisableText : $sEnableText; | 253 | $sLinkText = ($sStatus == 'enabled') ? $sDisableText : $sEnableText; |
| 251 | $sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateStatus'); | 254 | $sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateStatus'); |
| 252 | - $sLink = "<a id='statusLink{$this->getId()}' href='#' | ||
| 253 | - onclick='javascript: toggleStatus(\"{$sId}\", \"{$sUrl}\", \"{$sDisableText}\", \"{$sEnableText}\");'>{$sLinkText}</a>"; | 255 | + $sLink = "<input type='button' id='statusLink{$this->getId()}' |
| 256 | + onclick='javascript: toggleStatus(\"{$sId}\", \"{$sUrl}\", \"{$sDisableText}\", \"{$sEnableText}\");' value='{$sLinkText}' />"; | ||
| 254 | return $sLink; | 257 | return $sLink; |
| 255 | } | 258 | } |
| 256 | } | 259 | } |
plugins/ktcore/scheduler/schedulerUtil.php
| @@ -6,31 +6,31 @@ | @@ -6,31 +6,31 @@ | ||
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2008 KnowledgeTree Inc. | 7 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | 9 | + * |
| 10 | * This program is free software; you can redistribute it and/or modify it under | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | * the terms of the GNU General Public License version 3 as published by the | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | * Free Software Foundation. | 12 | * Free Software Foundation. |
| 13 | - * | 13 | + * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | * details. | 17 | * details. |
| 18 | - * | 18 | + * |
| 19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | ||
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | 21 | + * |
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | * California 94120-7775, or email info@knowledgetree.com. | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | 24 | + * |
| 25 | * The interactive user interfaces in modified source and object code versions | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | * of this program must display Appropriate Legal Notices, as required under | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | * Section 5 of the GNU General Public License version 3. | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | 28 | + * |
| 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | * these Appropriate Legal Notices must retain the display of the "Powered by | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | 33 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 34 | * copyright notice. | 34 | * copyright notice. |
| 35 | * Contributor( s): ______________________________________ | 35 | * Contributor( s): ______________________________________ |
| 36 | * | 36 | * |
| @@ -214,6 +214,7 @@ class schedulerUtil extends KTUtil | @@ -214,6 +214,7 @@ class schedulerUtil extends KTUtil | ||
| 214 | // Recalculate the next run time, use the previous run time as the start time. | 214 | // Recalculate the next run time, use the previous run time as the start time. |
| 215 | $iPrevious = $oScheduler->getPrevious(); | 215 | $iPrevious = $oScheduler->getPrevious(); |
| 216 | $iNextTime = schedulerUtil::calculateRunTime($sFreq, $iPrevious); | 216 | $iNextTime = schedulerUtil::calculateRunTime($sFreq, $iPrevious); |
| 217 | + $iNextTime = ($iNextTime < time()) ? time() : $iNextTime; | ||
| 217 | 218 | ||
| 218 | $oScheduler->setFrequency($sFreq); | 219 | $oScheduler->setFrequency($sFreq); |
| 219 | $oScheduler->setRunTime($iNextTime); | 220 | $oScheduler->setRunTime($iNextTime); |
| @@ -250,6 +251,12 @@ class schedulerUtil extends KTUtil | @@ -250,6 +251,12 @@ class schedulerUtil extends KTUtil | ||
| 250 | // ignore | 251 | // ignore |
| 251 | return $sStatus; | 252 | return $sStatus; |
| 252 | } | 253 | } |
| 254 | + if($sStatus == 'disabled'){ | ||
| 255 | + // If the task is being enabled, set the next run time to the current date plus the frequency period | ||
| 256 | + $freq = $oScheduler->getFrequency(); | ||
| 257 | + $runTime = schedulerUtil::calculateRunTime($freq, time()); | ||
| 258 | + $oScheduler->setRunTime($runTime); | ||
| 259 | + } | ||
| 253 | 260 | ||
| 254 | $sNewStatus = ($sStatus == 'enabled') ? 'disabled' : 'enabled'; | 261 | $sNewStatus = ($sStatus == 'enabled') ? 'disabled' : 'enabled'; |
| 255 | $oScheduler->setStatus($sNewStatus); | 262 | $oScheduler->setStatus($sNewStatus); |
plugins/ktcore/scheduler/taskScheduler.php
| @@ -6,31 +6,31 @@ | @@ -6,31 +6,31 @@ | ||
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2008 KnowledgeTree Inc. | 7 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | 9 | + * |
| 10 | * This program is free software; you can redistribute it and/or modify it under | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | * the terms of the GNU General Public License version 3 as published by the | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | * Free Software Foundation. | 12 | * Free Software Foundation. |
| 13 | - * | 13 | + * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | * details. | 17 | * details. |
| 18 | - * | 18 | + * |
| 19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | ||
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | 21 | + * |
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | * California 94120-7775, or email info@knowledgetree.com. | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | 24 | + * |
| 25 | * The interactive user interfaces in modified source and object code versions | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | * of this program must display Appropriate Legal Notices, as required under | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | * Section 5 of the GNU General Public License version 3. | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | 28 | + * |
| 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | * these Appropriate Legal Notices must retain the display of the "Powered by | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | 33 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 34 | * copyright notice. | 34 | * copyright notice. |
| 35 | * Contributor( s): ______________________________________ | 35 | * Contributor( s): ______________________________________ |
| 36 | * | 36 | * |
| @@ -49,24 +49,21 @@ class manageSchedulerDispatcher extends KTAdminDispatcher | @@ -49,24 +49,21 @@ class manageSchedulerDispatcher extends KTAdminDispatcher | ||
| 49 | function do_main() { | 49 | function do_main() { |
| 50 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Task Scheduler Management')); | 50 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Task Scheduler Management')); |
| 51 | $this->oPage->setTitle(_kt('Task Scheduler Management')); | 51 | $this->oPage->setTitle(_kt('Task Scheduler Management')); |
| 52 | - $this->oPage->requireJSResource('thirdpartyjs/yui/event/event.js'); | ||
| 53 | - $this->oPage->requireJSResource('thirdpartyjs/yui/connection/connection.js'); | ||
| 54 | - $this->oPage->requireJSResource('thirdpartyjs/yui/dom/dom.js'); | ||
| 55 | $this->oPage->requireJSResource('resources/js/scheduler.js'); | 52 | $this->oPage->requireJSResource('resources/js/scheduler.js'); |
| 56 | 53 | ||
| 57 | $oTemplating =& KTTemplating::getSingleton(); | 54 | $oTemplating =& KTTemplating::getSingleton(); |
| 58 | $oTemplate = $oTemplating->loadTemplate('ktcore/scheduler'); | 55 | $oTemplate = $oTemplating->loadTemplate('ktcore/scheduler'); |
| 59 | 56 | ||
| 60 | // Link for clearing out old tasks | 57 | // Link for clearing out old tasks |
| 61 | - $lClear = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=clearTasks'); | ||
| 62 | - $sClear = "<a href='#' onclick='javascript: clearTasks(\"{$lClear}\");'>"._kt('Clean-up old tasks').'</a>'; | 58 | +// $lClear = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=clearTasks'); |
| 59 | +// $sClear = "<a href='#' onclick='javascript: clearTasks(\"{$lClear}\");'>"._kt('Clean-up old tasks').'</a>'; | ||
| 63 | 60 | ||
| 64 | // Link for saving the updated frequencies | 61 | // Link for saving the updated frequencies |
| 65 | $sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=saveFreq'); | 62 | $sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=saveFreq'); |
| 66 | 63 | ||
| 67 | // Get all tasks | 64 | // Get all tasks |
| 68 | $aList = SchedulerEntity::getTaskList(); | 65 | $aList = SchedulerEntity::getTaskList(); |
| 69 | - $aHeadings = array('', _kt('Task'), _kt('Frequency'), _kt('Next run time'), _kt('Previous run time'), _kt('Time taken to complete'), ''); | 66 | + $aHeadings = array(' ', _kt('Task'), _kt('Frequency'), _kt('Next run time'), _kt('Previous run time'), _kt('Time taken to complete'), ' '); |
| 70 | 67 | ||
| 71 | //$aFrequencies = array('monthly', 'weekly', 'daily', 'hourly', 'half_hourly', 'quarter_hourly', '10mins', '5mins'); | 68 | //$aFrequencies = array('monthly', 'weekly', 'daily', 'hourly', 'half_hourly', 'quarter_hourly', '10mins', '5mins'); |
| 72 | $aFrequencies = array( | 69 | $aFrequencies = array( |
| @@ -89,7 +86,7 @@ class manageSchedulerDispatcher extends KTAdminDispatcher | @@ -89,7 +86,7 @@ class manageSchedulerDispatcher extends KTAdminDispatcher | ||
| 89 | 'aFrequencies' => $aFrequencies, | 86 | 'aFrequencies' => $aFrequencies, |
| 90 | 'i' => 1, | 87 | 'i' => 1, |
| 91 | 'sUrl' => $sUrl, | 88 | 'sUrl' => $sUrl, |
| 92 | - 'sClear' => $sClear | 89 | +// 'sClear' => $sClear |
| 93 | ); | 90 | ); |
| 94 | return $oTemplate->render($aTemplateData); | 91 | return $oTemplate->render($aTemplateData); |
| 95 | } | 92 | } |
resources/js/scheduler.js
| 1 | - | 1 | +// Clean up tasks marked as completed |
| 2 | var clearTasks = function(sUrl) { | 2 | var clearTasks = function(sUrl) { |
| 3 | 3 | ||
| 4 | - var callback = { | ||
| 5 | - success: function(o) { | ||
| 6 | - alert('Tasks have been successfully cleaned up'); | 4 | + Ext.Ajax.request({ |
| 5 | + url: sUrl, | ||
| 6 | + success: function(response) { | ||
| 7 | + alert('The tasks have been successfully cleaned up'); | ||
| 7 | }, | 8 | }, |
| 8 | - failure: function(o) { | ||
| 9 | - alert('Clean up failed!'); | 9 | + failure: function(response) { |
| 10 | + alert('Error. The clean up failed.'); | ||
| 10 | } | 11 | } |
| 11 | - } | ||
| 12 | - | ||
| 13 | - var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); | 12 | + }); |
| 14 | } | 13 | } |
| 15 | 14 | ||
| 16 | -//<!-- Change the run time to now --> | 15 | +//<!-- Reschedule the task to run the next time the scheduler runs --> |
| 17 | var runOnNext = function(fId, sUrl) { | 16 | var runOnNext = function(fId, sUrl) { |
| 18 | var runDiv = document.getElementById('runDiv'+fId); | 17 | var runDiv = document.getElementById('runDiv'+fId); |
| 19 | 18 | ||
| 20 | //<!-- Display the new runtime --> | 19 | //<!-- Display the new runtime --> |
| 21 | var displayDate = formatDate('','no'); | 20 | var displayDate = formatDate('','no'); |
| 22 | 21 | ||
| 23 | - var callback = { | ||
| 24 | - success: function(o) { | 22 | + Ext.Ajax.request({ |
| 23 | + url: sUrl, | ||
| 24 | + success: function(response) { | ||
| 25 | runDiv.innerHTML = displayDate; | 25 | runDiv.innerHTML = displayDate; |
| 26 | - } | ||
| 27 | - } | ||
| 28 | - var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, "fId="+fId); | 26 | + }, |
| 27 | + failure: function(response) { | ||
| 28 | + alert('Error. The update failed, please refresh the page and try again.'); | ||
| 29 | + }, | ||
| 30 | + params: { fId: fId } | ||
| 31 | + }); | ||
| 29 | } | 32 | } |
| 30 | 33 | ||
| 31 | //<!-- Enable / disable the task --> | 34 | //<!-- Enable / disable the task --> |
| @@ -34,52 +37,67 @@ var toggleStatus = function(fId, sUrl, sDisableText, sEnableText) { | @@ -34,52 +37,67 @@ var toggleStatus = function(fId, sUrl, sDisableText, sEnableText) { | ||
| 34 | var statusLink = document.getElementById('statusLink'+fId); | 37 | var statusLink = document.getElementById('statusLink'+fId); |
| 35 | var freqLink = document.getElementById('freqLink'+fId); | 38 | var freqLink = document.getElementById('freqLink'+fId); |
| 36 | var runnowLink = document.getElementById('runnowLink'+fId); | 39 | var runnowLink = document.getElementById('runnowLink'+fId); |
| 37 | - var freqDrop = document.getElementById('freqDrop'+fId); | ||
| 38 | var fontClass = document.getElementById('font'+fId); | 40 | var fontClass = document.getElementById('font'+fId); |
| 39 | var freqDiv = document.getElementById('div'+fId); | 41 | var freqDiv = document.getElementById('div'+fId); |
| 40 | - | ||
| 41 | - var callback = { | ||
| 42 | - success: function(o) { | ||
| 43 | - if(statusLink.innerHTML == sDisableText){ | ||
| 44 | - statusLink.innerHTML = sEnableText; | 42 | + var runDiv = document.getElementById('runDiv'+fId); |
| 43 | + var freq = document.getElementById('freq_'+fId).value; | ||
| 44 | + | ||
| 45 | + var date = new Date(); | ||
| 46 | + var msNow = date.getTime(); | ||
| 47 | + var now = parseInt(msNow / 1000); | ||
| 48 | + var runTime = calculateFreq(freq, now); | ||
| 49 | + var displayDate = formatDate(runTime); | ||
| 50 | + | ||
| 51 | + Ext.Ajax.request({ | ||
| 52 | + url: sUrl, | ||
| 53 | + success: function(response) { | ||
| 54 | + if(statusLink.value == sDisableText){ | ||
| 55 | + statusLink.value = sEnableText; | ||
| 45 | freqLink.style.visibility = "hidden"; | 56 | freqLink.style.visibility = "hidden"; |
| 46 | runnowLink.style.visibility = "hidden"; | 57 | runnowLink.style.visibility = "hidden"; |
| 47 | - freqDrop.style.visibility = "hidden"; | 58 | + runDiv.style.visibility = 'hidden'; |
| 48 | fontClass.className = 'descriptiveText'; | 59 | fontClass.className = 'descriptiveText'; |
| 49 | freqDiv.style.display = "none"; | 60 | freqDiv.style.display = "none"; |
| 50 | }else{ | 61 | }else{ |
| 51 | - statusLink.innerHTML = sDisableText; | 62 | + statusLink.value = sDisableText; |
| 52 | freqLink.style.visibility = "visible"; | 63 | freqLink.style.visibility = "visible"; |
| 53 | runnowLink.style.visibility = "visible"; | 64 | runnowLink.style.visibility = "visible"; |
| 54 | - freqDrop.style.visibility = "visible"; | ||
| 55 | freqDiv.style.display = "block"; | 65 | freqDiv.style.display = "block"; |
| 66 | + freqDiv.style.visibility = "visible"; | ||
| 56 | fontClass.className = ''; | 67 | fontClass.className = ''; |
| 68 | + | ||
| 69 | + runDiv.style.visibility = 'visible'; | ||
| 70 | + runDiv.innerHTML = displayDate; | ||
| 57 | } | 71 | } |
| 58 | - } | ||
| 59 | - } | ||
| 60 | - var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, "fId="+fId); | 72 | + }, |
| 73 | + failure: function(response) { | ||
| 74 | + alert('Error. The status update failed, please refresh the page and try again.'); | ||
| 75 | + }, | ||
| 76 | + params: { fId: fId } | ||
| 77 | + }); | ||
| 61 | } | 78 | } |
| 62 | 79 | ||
| 80 | +// Display the form to changed the frequency at which the task runs | ||
| 63 | var showFrequencyDiv = function(fId) { | 81 | var showFrequencyDiv = function(fId) { |
| 64 | var formDiv = document.getElementById('formDiv'); | 82 | var formDiv = document.getElementById('formDiv'); |
| 83 | + | ||
| 84 | + if(formDiv.innerHTML == ''){ | ||
| 85 | + return; | ||
| 86 | + } | ||
| 87 | + | ||
| 65 | var fInput = document.getElementById('fId'); | 88 | var fInput = document.getElementById('fId'); |
| 66 | - var tblCol = document.getElementById('tblCol'); | ||
| 67 | - var freqDiv = document.getElementById('div'+fId); | ||
| 68 | - var posFreq = YAHOO.util.Dom.getXY('div'+fId); | 89 | + var tblCol = document.getElementById('col_'+fId); |
| 69 | 90 | ||
| 70 | - //<!-- Hide the frequency and display the form in place --> | ||
| 71 | - formDiv.style.display = "block"; | ||
| 72 | - freqDiv.style.display = "none"; | ||
| 73 | - formDiv.style.visibility = "visible"; | ||
| 74 | - freqDiv.style.visibility = "hidden"; | ||
| 75 | fInput.value = fId; | 91 | fInput.value = fId; |
| 76 | - tblCol.width = "20%"; | ||
| 77 | - YAHOO.util.Dom.setXY('formDiv', posFreq); | 92 | + tblCol.innerHTML = formDiv.innerHTML; |
| 93 | + tblCol.style.display = 'block'; | ||
| 94 | + formDiv.innerHTML = ''; | ||
| 78 | } | 95 | } |
| 79 | 96 | ||
| 97 | +// Save the new frequency | ||
| 80 | var saveFreq = function(sUrl) { | 98 | var saveFreq = function(sUrl) { |
| 81 | var fId = document.getElementById('fId').value; | 99 | var fId = document.getElementById('fId').value; |
| 82 | - var tblCol = document.getElementById('tblCol'); | 100 | + var tblCol = document.getElementById('col_'+fId); |
| 83 | var formDiv = document.getElementById('formDiv'); | 101 | var formDiv = document.getElementById('formDiv'); |
| 84 | var freqDiv = document.getElementById('div'+fId); | 102 | var freqDiv = document.getElementById('div'+fId); |
| 85 | var runDiv = document.getElementById('runDiv'+fId); | 103 | var runDiv = document.getElementById('runDiv'+fId); |
| @@ -89,32 +107,35 @@ var saveFreq = function(sUrl) { | @@ -89,32 +107,35 @@ var saveFreq = function(sUrl) { | ||
| 89 | var freq = fSelect.options[fSelect.selectedIndex].value; | 107 | var freq = fSelect.options[fSelect.selectedIndex].value; |
| 90 | var freqLabel = fSelect.options[fSelect.selectedIndex].label; | 108 | var freqLabel = fSelect.options[fSelect.selectedIndex].label; |
| 91 | 109 | ||
| 110 | + // Move the form content back to the form div | ||
| 111 | + formDiv.innerHTML = tblCol.innerHTML; | ||
| 112 | + tblCol.innerHTML = ''; | ||
| 113 | + tblCol.style.display = 'none'; | ||
| 114 | + | ||
| 92 | //<!-- Work out new runtime using the frequency --> | 115 | //<!-- Work out new runtime using the frequency --> |
| 93 | var prevNum = new Number(prevInput); | 116 | var prevNum = new Number(prevInput); |
| 94 | var nextTime = calculateFreq(freq, prevNum); | 117 | var nextTime = calculateFreq(freq, prevNum); |
| 95 | var displayDate = formatDate(nextTime); | 118 | var displayDate = formatDate(nextTime); |
| 96 | 119 | ||
| 97 | - var callback = { | ||
| 98 | - success: function(o) { | 120 | + Ext.Ajax.request({ |
| 121 | + url: sUrl, | ||
| 122 | + success: function(response) { | ||
| 99 | freqDiv.innerHTML = freqLabel; | 123 | freqDiv.innerHTML = freqLabel; |
| 100 | runDiv.innerHTML = displayDate; | 124 | runDiv.innerHTML = displayDate; |
| 125 | + document.getElementById('freq_'+fId).value = freq; | ||
| 126 | + }, | ||
| 127 | + failure: function(response) { | ||
| 128 | + alert('Error. The frequency update failed, please refresh the page and try again.'); | ||
| 129 | + }, | ||
| 130 | + params: { | ||
| 131 | + frequency: freq, | ||
| 132 | + fId: fId | ||
| 101 | } | 133 | } |
| 102 | - } | ||
| 103 | - | ||
| 104 | - YAHOO.util.Connect.setForm(freqForm); | ||
| 105 | - var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback); | ||
| 106 | - | ||
| 107 | - tblCol.width = ""; | ||
| 108 | - formDiv.style.display = "none"; | ||
| 109 | - freqDiv.style.display = "block"; | ||
| 110 | - formDiv.style.visibility = "hidden"; | ||
| 111 | - freqDiv.style.visibility = "visible"; | 134 | + }); |
| 112 | } | 135 | } |
| 113 | 136 | ||
| 114 | -//<!-- Calculate the next run time based on the previous runtime --> | 137 | +//<!-- Calculate the next run time based on the given runtime --> |
| 115 | var calculateFreq = function(freq, prev) { | 138 | var calculateFreq = function(freq, prev) { |
| 116 | - | ||
| 117 | - var curDate = new Date(); | ||
| 118 | var iDiff = 0; | 139 | var iDiff = 0; |
| 119 | 140 | ||
| 120 | switch(freq) { | 141 | switch(freq) { |
| @@ -155,16 +176,23 @@ var calculateFreq = function(freq, prev) { | @@ -155,16 +176,23 @@ var calculateFreq = function(freq, prev) { | ||
| 155 | } | 176 | } |
| 156 | 177 | ||
| 157 | var iNextTime = prev + iDiff; | 178 | var iNextTime = prev + iDiff; |
| 179 | + | ||
| 158 | return iNextTime; | 180 | return iNextTime; |
| 159 | } | 181 | } |
| 160 | 182 | ||
| 161 | //<!-- Return a formatted date given a unix timestamp --> | 183 | //<!-- Return a formatted date given a unix timestamp --> |
| 184 | +// If the date if prior to the current date then return the current date | ||
| 162 | var formatDate = function(unixTime, useUnix) { | 185 | var formatDate = function(unixTime, useUnix) { |
| 163 | if(useUnix == 'no') { | 186 | if(useUnix == 'no') { |
| 164 | var newDate = new Date(); | 187 | var newDate = new Date(); |
| 165 | }else{ | 188 | }else{ |
| 166 | var milliTime = unixTime * 1000; | 189 | var milliTime = unixTime * 1000; |
| 167 | var newDate = new Date(milliTime); | 190 | var newDate = new Date(milliTime); |
| 191 | + | ||
| 192 | + var curDate = new Date(); | ||
| 193 | + if(newDate < curDate){ | ||
| 194 | + newDate = curDate; | ||
| 195 | + } | ||
| 168 | } | 196 | } |
| 169 | 197 | ||
| 170 | var year = newDate.getFullYear(); | 198 | var year = newDate.getFullYear(); |
templates/ktcore/scheduler.smarty
| @@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
| 25 | 25 | ||
| 26 | {if $aList} | 26 | {if $aList} |
| 27 | {foreach from=$aList item=task} | 27 | {foreach from=$aList item=task} |
| 28 | +{assign var=taskId value=$task->getId()} | ||
| 28 | 29 | ||
| 29 | <tr class="{cycle name=rows values=",odd"}"> | 30 | <tr class="{cycle name=rows values=",odd"}"> |
| 30 | <td width='2%'> | 31 | <td width='2%'> |
| @@ -33,17 +34,24 @@ | @@ -33,17 +34,24 @@ | ||
| 33 | <td> | 34 | <td> |
| 34 | {$task->getTaskDiv()} | 35 | {$task->getTaskDiv()} |
| 35 | </td> | 36 | </td> |
| 36 | - <td id="tblCol"> | 37 | + <td> |
| 37 | {$task->getFreqDiv()} | 38 | {$task->getFreqDiv()} |
| 39 | + <div id="col_{$taskId}"> | ||
| 40 | + </div> | ||
| 41 | + <div style="visibility: hidden; display: none;"> | ||
| 42 | + <input type="hidden" name="freq_{$taskId}" id="freq_{$taskId}" value="{$task->getFrequency()}" /> | ||
| 43 | + </div> | ||
| 38 | </td> | 44 | </td> |
| 39 | <td> | 45 | <td> |
| 40 | - <div id="runDiv{$task->getId()}"> | ||
| 41 | - {$task->getRunTime()} | 46 | + <div id="runDiv{$taskId}"> |
| 47 | + {if $task->getStatus() != 'disabled'} | ||
| 48 | + {$task->getRunTime()} | ||
| 49 | + {/if} | ||
| 42 | </div> | 50 | </div> |
| 43 | </td> | 51 | </td> |
| 44 | <td> | 52 | <td> |
| 45 | - <div id="prevDiv{$task->getId()}" style="display:none; visibility:hidden;"> | ||
| 46 | - <input type="hidden" name="prev{$task->getId()}" id="prev{$task->getId()}" value="{$task->getPrevious()}" /> | 53 | + <div id="prevDiv{$taskId}" style="display:none; visibility:hidden;"> |
| 54 | + <input type="hidden" name="prev{$taskId}" id="prev{$taskId}" value="{$task->getPrevious()}" /> | ||
| 47 | </div> | 55 | </div> |
| 48 | {$task->getPrevious(TRUE)} | 56 | {$task->getPrevious(TRUE)} |
| 49 | </td> | 57 | </td> |
| @@ -76,7 +84,3 @@ | @@ -76,7 +84,3 @@ | ||
| 76 | <input type="button" name="save" id="save" onclick='javascript: saveFreq("{$sUrl}");' value="{i18n}Save{/i18n}" /> | 84 | <input type="button" name="save" id="save" onclick='javascript: saveFreq("{$sUrl}");' value="{i18n}Save{/i18n}" /> |
| 77 | </form> | 85 | </form> |
| 78 | </div> | 86 | </div> |
| 79 | - | ||
| 80 | -<p> | ||
| 81 | - {$sClear} | ||
| 82 | -</p> |