- bufix: incorrect dateCompleted after task complete

This commit is contained in:
Max Pozdeev 2010-04-19 14:31:53 +04:00
parent e46e7048fe
commit 8d7511a9c7
2 changed files with 8 additions and 4 deletions

View file

@ -229,13 +229,14 @@ function completeTask(id,ch)
var compl = 0;
if(ch.checked) compl = 1;
var nocache = '&rnd='+Math.random();
$.getJSON(mytinytodo.mttUrl+'ajax.php?completeTask='+id+'&compl='+compl+nocache, function(json){
$.getJSON(mytinytodo.mttUrl+'ajax.php?completeTask='+id+'&compl='+compl+'&tz='+tz()+nocache, function(json){
if(!parseInt(json.total)) return;
var item = json.list[0];
if(item.compl) $('#taskrow_'+id).addClass('task-completed');
else $('#taskrow_'+id).removeClass('task-completed');
taskList[id].ow = item.ow;
taskList[id].compl = item.compl;
taskList[id].dateCompleted = item.dateCompleted;
changeTaskCnt(taskList[id], 0);
if(item.compl && !curList.showCompl) {
delete taskList[id];

View file

@ -172,10 +172,13 @@ elseif(isset($_GET['completeTask']))
$compl = _get('compl') ? 1 : 0;
if($compl) $ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE compl=1");
else $ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE compl=0");
$db->dq("UPDATE {$db->prefix}todolist SET compl=$compl,ow=$ow,d_completed=? WHERE id=$id", array($compl?time():0 ));
$dateCompleted = $compl ? time() : 0;
$db->dq("UPDATE {$db->prefix}todolist SET compl=$compl,ow=$ow,d_completed=? WHERE id=$id", array($dateCompleted));
$tz = (int)_get('tz');
if(Config::get('autotz')==0 || $tz<-720 || $tz>720 || $tz%30!=0) $tz = round(date('Z')/60);
$t = array();
$t['total'] = 1;
$t['list'][] = array('id'=>$id, 'compl'=>$compl, 'ow'=>$ow);
$t['list'][] = array('id'=>$id, 'compl'=>$compl, 'ow'=>$ow, 'dateCompleted'=>$dateCompleted?htmlarray(timestampToDatetime($dateCompleted, $tz)):'');
echo json_encode($t);
exit;
}
@ -504,7 +507,7 @@ function prepareTaskRow($r, $tz)
'title' => escapeTags($r['title']),
'date' => htmlarray($dCreated),
'dateInline' => htmlarray(sprintf($lang->get('taskdate_inline'), $dCreated)),
'dateCompleted' => htmlarray(timestampToDatetime($r['d_completed'], $tz)),
'dateCompleted' => $r['d_completed'] ? htmlarray(timestampToDatetime($r['d_completed'], $tz)) : '',
'compl' => (int)$r['compl'],
'prio' => $r['prio'],
'note' => nl2br(escapeTags($r['note'])),