diff --git a/plugins/ktcore/scheduler/schedulerEntity.php b/plugins/ktcore/scheduler/schedulerEntity.php
index d968252..5a03e35 100644
--- a/plugins/ktcore/scheduler/schedulerEntity.php
+++ b/plugins/ktcore/scheduler/schedulerEntity.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -201,9 +201,9 @@ class schedulerEntity extends KTEntity
$sStatus = $this->getStatus();
$sFreqs = $this->getFrequencyByLang();
- $sLink = "' : '>';
- $sLink .= "
";
+ $sLink .= $sFreqs.'';
return $sLink;
}
@@ -214,9 +214,10 @@ class schedulerEntity extends KTEntity
$sId = $this->getId();
$sStatus = $this->getStatus();
- $sLink = "' : '>';
- $sLink .= _kt('Alter frequency')."";
+ $sLink = "' : ' />';
+
return $sLink;
}
@@ -228,9 +229,11 @@ class schedulerEntity extends KTEntity
$sStatus = $this->getStatus();
$sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateRunTime');
- $sLink = "' : '>';
- $sLink .= _kt('Run on next iteration')."";
+ $sTitle = _kt('This task will run the next time the Scheduler runs'); //, and then revert to the frequency you set on this page');
+ $sLink = "' : ' />';
+
return $sLink;
}
@@ -244,13 +247,13 @@ class schedulerEntity extends KTEntity
return '';
}
- $sDisableText = _kt('Disable task');
- $sEnableText = _kt('Enable task');
+ $sDisableText = _kt('Disable Task');
+ $sEnableText = _kt('Enable Task');
$sLinkText = ($sStatus == 'enabled') ? $sDisableText : $sEnableText;
$sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateStatus');
- $sLink = "{$sLinkText}";
+ $sLink = "";
return $sLink;
}
}
diff --git a/plugins/ktcore/scheduler/schedulerUtil.php b/plugins/ktcore/scheduler/schedulerUtil.php
index 2bed69d..521e5d4 100644
--- a/plugins/ktcore/scheduler/schedulerUtil.php
+++ b/plugins/ktcore/scheduler/schedulerUtil.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -214,6 +214,7 @@ class schedulerUtil extends KTUtil
// Recalculate the next run time, use the previous run time as the start time.
$iPrevious = $oScheduler->getPrevious();
$iNextTime = schedulerUtil::calculateRunTime($sFreq, $iPrevious);
+ $iNextTime = ($iNextTime < time()) ? time() : $iNextTime;
$oScheduler->setFrequency($sFreq);
$oScheduler->setRunTime($iNextTime);
@@ -250,6 +251,12 @@ class schedulerUtil extends KTUtil
// ignore
return $sStatus;
}
+ if($sStatus == 'disabled'){
+ // If the task is being enabled, set the next run time to the current date plus the frequency period
+ $freq = $oScheduler->getFrequency();
+ $runTime = schedulerUtil::calculateRunTime($freq, time());
+ $oScheduler->setRunTime($runTime);
+ }
$sNewStatus = ($sStatus == 'enabled') ? 'disabled' : 'enabled';
$oScheduler->setStatus($sNewStatus);
diff --git a/plugins/ktcore/scheduler/taskScheduler.php b/plugins/ktcore/scheduler/taskScheduler.php
index f9e88e2..2d45f88 100644
--- a/plugins/ktcore/scheduler/taskScheduler.php
+++ b/plugins/ktcore/scheduler/taskScheduler.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -49,24 +49,21 @@ class manageSchedulerDispatcher extends KTAdminDispatcher
function do_main() {
$this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Task Scheduler Management'));
$this->oPage->setTitle(_kt('Task Scheduler Management'));
- $this->oPage->requireJSResource('thirdpartyjs/yui/event/event.js');
- $this->oPage->requireJSResource('thirdpartyjs/yui/connection/connection.js');
- $this->oPage->requireJSResource('thirdpartyjs/yui/dom/dom.js');
$this->oPage->requireJSResource('resources/js/scheduler.js');
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate('ktcore/scheduler');
// Link for clearing out old tasks
- $lClear = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=clearTasks');
- $sClear = ""._kt('Clean-up old tasks').'';
+// $lClear = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=clearTasks');
+// $sClear = ""._kt('Clean-up old tasks').'';
// Link for saving the updated frequencies
$sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=saveFreq');
// Get all tasks
$aList = SchedulerEntity::getTaskList();
- $aHeadings = array('', _kt('Task'), _kt('Frequency'), _kt('Next run time'), _kt('Previous run time'), _kt('Time taken to complete'), '');
+ $aHeadings = array(' ', _kt('Task'), _kt('Frequency'), _kt('Next run time'), _kt('Previous run time'), _kt('Time taken to complete'), ' ');
//$aFrequencies = array('monthly', 'weekly', 'daily', 'hourly', 'half_hourly', 'quarter_hourly', '10mins', '5mins');
$aFrequencies = array(
@@ -89,7 +86,7 @@ class manageSchedulerDispatcher extends KTAdminDispatcher
'aFrequencies' => $aFrequencies,
'i' => 1,
'sUrl' => $sUrl,
- 'sClear' => $sClear
+// 'sClear' => $sClear
);
return $oTemplate->render($aTemplateData);
}
diff --git a/resources/js/scheduler.js b/resources/js/scheduler.js
index 3e9f89e..bd07dfc 100644
--- a/resources/js/scheduler.js
+++ b/resources/js/scheduler.js
@@ -1,31 +1,34 @@
-
+// Clean up tasks marked as completed
var clearTasks = function(sUrl) {
- var callback = {
- success: function(o) {
- alert('Tasks have been successfully cleaned up');
+ Ext.Ajax.request({
+ url: sUrl,
+ success: function(response) {
+ alert('The tasks have been successfully cleaned up');
},
- failure: function(o) {
- alert('Clean up failed!');
+ failure: function(response) {
+ alert('Error. The clean up failed.');
}
- }
-
- var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
+ });
}
-//
+//
var runOnNext = function(fId, sUrl) {
var runDiv = document.getElementById('runDiv'+fId);
//
var displayDate = formatDate('','no');
- var callback = {
- success: function(o) {
+ Ext.Ajax.request({
+ url: sUrl,
+ success: function(response) {
runDiv.innerHTML = displayDate;
- }
- }
- var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, "fId="+fId);
+ },
+ failure: function(response) {
+ alert('Error. The update failed, please refresh the page and try again.');
+ },
+ params: { fId: fId }
+ });
}
//
@@ -34,52 +37,67 @@ var toggleStatus = function(fId, sUrl, sDisableText, sEnableText) {
var statusLink = document.getElementById('statusLink'+fId);
var freqLink = document.getElementById('freqLink'+fId);
var runnowLink = document.getElementById('runnowLink'+fId);
- var freqDrop = document.getElementById('freqDrop'+fId);
var fontClass = document.getElementById('font'+fId);
var freqDiv = document.getElementById('div'+fId);
-
- var callback = {
- success: function(o) {
- if(statusLink.innerHTML == sDisableText){
- statusLink.innerHTML = sEnableText;
+ var runDiv = document.getElementById('runDiv'+fId);
+ var freq = document.getElementById('freq_'+fId).value;
+
+ var date = new Date();
+ var msNow = date.getTime();
+ var now = parseInt(msNow / 1000);
+ var runTime = calculateFreq(freq, now);
+ var displayDate = formatDate(runTime);
+
+ Ext.Ajax.request({
+ url: sUrl,
+ success: function(response) {
+ if(statusLink.value == sDisableText){
+ statusLink.value = sEnableText;
freqLink.style.visibility = "hidden";
runnowLink.style.visibility = "hidden";
- freqDrop.style.visibility = "hidden";
+ runDiv.style.visibility = 'hidden';
fontClass.className = 'descriptiveText';
freqDiv.style.display = "none";
}else{
- statusLink.innerHTML = sDisableText;
+ statusLink.value = sDisableText;
freqLink.style.visibility = "visible";
runnowLink.style.visibility = "visible";
- freqDrop.style.visibility = "visible";
freqDiv.style.display = "block";
+ freqDiv.style.visibility = "visible";
fontClass.className = '';
+
+ runDiv.style.visibility = 'visible';
+ runDiv.innerHTML = displayDate;
}
- }
- }
- var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, "fId="+fId);
+ },
+ failure: function(response) {
+ alert('Error. The status update failed, please refresh the page and try again.');
+ },
+ params: { fId: fId }
+ });
}
+// Display the form to changed the frequency at which the task runs
var showFrequencyDiv = function(fId) {
var formDiv = document.getElementById('formDiv');
+
+ if(formDiv.innerHTML == ''){
+ return;
+ }
+
var fInput = document.getElementById('fId');
- var tblCol = document.getElementById('tblCol');
- var freqDiv = document.getElementById('div'+fId);
- var posFreq = YAHOO.util.Dom.getXY('div'+fId);
+ var tblCol = document.getElementById('col_'+fId);
- //
- formDiv.style.display = "block";
- freqDiv.style.display = "none";
- formDiv.style.visibility = "visible";
- freqDiv.style.visibility = "hidden";
fInput.value = fId;
- tblCol.width = "20%";
- YAHOO.util.Dom.setXY('formDiv', posFreq);
+ tblCol.innerHTML = formDiv.innerHTML;
+ tblCol.style.display = 'block';
+ formDiv.innerHTML = '';
}
+// Save the new frequency
var saveFreq = function(sUrl) {
var fId = document.getElementById('fId').value;
- var tblCol = document.getElementById('tblCol');
+ var tblCol = document.getElementById('col_'+fId);
var formDiv = document.getElementById('formDiv');
var freqDiv = document.getElementById('div'+fId);
var runDiv = document.getElementById('runDiv'+fId);
@@ -89,32 +107,35 @@ var saveFreq = function(sUrl) {
var freq = fSelect.options[fSelect.selectedIndex].value;
var freqLabel = fSelect.options[fSelect.selectedIndex].label;
+ // Move the form content back to the form div
+ formDiv.innerHTML = tblCol.innerHTML;
+ tblCol.innerHTML = '';
+ tblCol.style.display = 'none';
+
//
var prevNum = new Number(prevInput);
var nextTime = calculateFreq(freq, prevNum);
var displayDate = formatDate(nextTime);
- var callback = {
- success: function(o) {
+ Ext.Ajax.request({
+ url: sUrl,
+ success: function(response) {
freqDiv.innerHTML = freqLabel;
runDiv.innerHTML = displayDate;
+ document.getElementById('freq_'+fId).value = freq;
+ },
+ failure: function(response) {
+ alert('Error. The frequency update failed, please refresh the page and try again.');
+ },
+ params: {
+ frequency: freq,
+ fId: fId
}
- }
-
- YAHOO.util.Connect.setForm(freqForm);
- var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback);
-
- tblCol.width = "";
- formDiv.style.display = "none";
- freqDiv.style.display = "block";
- formDiv.style.visibility = "hidden";
- freqDiv.style.visibility = "visible";
+ });
}
-//
+//
var calculateFreq = function(freq, prev) {
-
- var curDate = new Date();
var iDiff = 0;
switch(freq) {
@@ -155,16 +176,23 @@ var calculateFreq = function(freq, prev) {
}
var iNextTime = prev + iDiff;
+
return iNextTime;
}
//
+// If the date if prior to the current date then return the current date
var formatDate = function(unixTime, useUnix) {
if(useUnix == 'no') {
var newDate = new Date();
}else{
var milliTime = unixTime * 1000;
var newDate = new Date(milliTime);
+
+ var curDate = new Date();
+ if(newDate < curDate){
+ newDate = curDate;
+ }
}
var year = newDate.getFullYear();
diff --git a/templates/ktcore/scheduler.smarty b/templates/ktcore/scheduler.smarty
index 2a5d4dc..3ffd5de 100644
--- a/templates/ktcore/scheduler.smarty
+++ b/templates/ktcore/scheduler.smarty
@@ -25,6 +25,7 @@
{if $aList}
{foreach from=$aList item=task}
+{assign var=taskId value=$task->getId()}