diff --git a/module/block/view/todoblock.html.php b/module/block/view/todoblock.html.php index 8fd74cc90d..e508e91628 100644 --- a/module/block/view/todoblock.html.php +++ b/module/block/view/todoblock.html.php @@ -14,7 +14,7 @@
-
'> + '>

todo->create . $lang->todo->common;?>

@@ -94,5 +94,31 @@ }); }); }); + + function ajaxCreateTodo(obj) + { + var $todoes = $(obj).closest('.block-todoes'); + var $form = $(obj).closest('form'); + $.ajax( + { + type: "POST", + dataType: "json", + url: $form.attr('action'), + data: $form.serialize(), + success: function(todo) + { + var item = "
  • "; + item += ''; + item += ''; + item += '' + todo.name + ''; + item += '' + todo.priName + '' + todo.time + '
  • '; + $todoes.find('ul.todoes').prepend(item); + $todoes.removeClass('show-form'); + $todoes.find('ul.todoes li:first a').modalTrigger(); + $form.find('input[name="name"]').val(''); + $form.find('#todoDate').val(''); + } + }); + }
    diff --git a/module/todo/control.php b/module/todo/control.php index 0bfcf8527f..9740625239 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -34,7 +34,7 @@ class todo extends control * @access public * @return void */ - public function create($date = 'today', $account = '') + public function create($date = 'today', $account = '', $from = 'todo') { if($date == 'today') $date = date::today(); if($account == '') $account = $this->app->user->account; @@ -54,6 +54,14 @@ class todo extends control } if(!empty($_POST['idvalue'])) $this->send(array('result' => 'success')); + if($from == 'block') + { + $todo = $this->todo->getById($todoID); + $this->app->loadClass('date'); + $todo->begin = date::formatTime($todo->begin); + $this->send(array('result' => 'success', 'id' => $todoID, 'name' => $todo->name, 'pri' => $todo->pri, 'priName' => $this->lang->todo->priList[$todo->pri], 'time' => date(DT_DATE4, strtotime($todo->date)) . ' ' . $todo->begin)); + } + die(js::locate($this->createLink('my', 'todo', "type=$date"), 'parent')); }