// time spent echo '<td>'; echo '<a href="' . $this->fc->getUrl('timer', 'delete', $params) . '" class="onhold ajax confirm" rel="tab2">' . TR::html('button', 'delete') . '</a>'; echo $this->data->getTimeSpent(); echo '</td>'; echo '</tr>'; } while ($this->data->next()); ?> </tbody> <tfoot> <tr> <td colspan="2"><?php TR::phtml('ui', 'total'); ?> </td> <td><?php echo TaskSummary::htmlTime($total); ?> </td> </tr> </tfoot> </table> <?php } else { echo '<p class="empty">' . TR::html('ui', 'history_empty') . '</p>'; } ?> <p class="empty"><a href="#tab3" onclick="tabber.show(3); return false;"><?php TR::phtml('ui', 'report_spent'); ?> </a></p>
/** * load task list */ protected function _loadTaskList($filter) { $data = new TaskSummary(); $data->connectDb(); $data->where($filter); $data->where('archived=0'); $data->where('member_id=' . $this->fc->user->getUid()); $data->orderBy('status ASC, deadline ASC, priority ASC, title ASC, start ASC'); $data->loadCompactList(); return $data; }
/** * change a task status (start, stop, close) or save a new one * will only update the timer panel and reload the task list * (method called by ajax request only) */ public function timerReaction() { $this->jsCode = ''; if ($id = $this->fc->getReqVar('id')) { // start / stop timer $obj = new TaskSummary(); $obj->connectDb(); $obj->setUid($id); $obj->load(); // what action then ? $action = $this->fc->chkReqVar('pause,resume,start,stop,close'); FC::log_debug('loaded task ID=' . $obj->getUid()); switch ($action) { case 'pause': // try to pause if ($this->current && $this->current->getUid() == $id) { // ok, task is actually running TimerModel::stop($id); $this->current->set('stop', APP_SQL_NOW); $this->jsCode .= "clockreport('{$cid}');clockstatus('paused');"; } else { // nope, requested task is not running, show error $this->jsCode = "alert('" . TR::get('error', 'action_failed') . "')"; FC::log_debug('error trying to pause non running task'); } break; case 'resume': case 'start': TimerModel::start($id); $this->current = TaskSummary::loadCurrent(); $this->jsCode = "clockstart();"; break; case 'stop': if (TimerModel::stop($id)) { $this->jsCode = "clockstatus();"; } else { $this->jsCode = "alert('" . TR::get('error', 'action_failed') . "');"; } $this->current = false; break; case 'close': if (TimerModel::stop($id)) { $this->jsCode = "clockstatus();"; $this->current->updateStatus(1); // mark as done $this->current = false; } break; } } else { if ($title = $this->fc->getReqVar('title')) { // creating a new task ? $obj = TaskModel::parse($title, $def, $dte); $obj->connectDb(); if ($this->fc->getReqVar('start')) { $obj->set('deadline', APP_SQL_TODAY); } if ($obj->check($this->switch_id)) { $obj->insert(); } if ($this->fc->chkReqVar('start')) { TimerModel::start($obj->getUid()); $this->current = TaskSummary::loadCurrent(); $this->jsCode = "clockstart();"; } else { $this->current = false; $this->jsCode = "clockstatus();"; } } } $this->jsCode .= 'reloadList();'; $this->setView('include/timer'); $this->view(); return false; }
/** * load current running timer */ public static function loadCurrent($id = 0) { $obj = new TaskSummary(); $obj->connectDb(); if ($id) { $obj->setUid($id); if ($obj->load()) { return $obj; } } else { $ftr = "stop='0000-00-00 00:00:00'"; if (!empty($_SESSION['appUserId'])) { $ftr .= " AND member_id='" . $_SESSION['appUserId'] . "'"; } if ($obj->load($ftr)) { return $obj; } } return false; }