Beispiel #1
0
 function _instant_time($params)
 {
     $user = $params['user'];
     $channel = $params['channel'];
     $task = $params['task'];
     $pcode = $this->_project_alias($params['pcode']);
     $time = $params['time'];
     $approx = $params['approx'];
     $notes = $params['notes'];
     $return = true;
     if (strpos($time, ':') === 0) {
         $hours = floatval(substr($time, 1)) / 60;
     } elseif (strpos($time, ':') > 0) {
         list($hours, $minutes) = split(':', $time);
         $hours = intval($hours) + $minutes / 60;
     } else {
         $hours = floatval($time);
     }
     if (strpos($approx, ':') === 0) {
         $est = floatval(substr($approx, 1)) / 60;
     } elseif (strpos($approx, ':') > 0) {
         $est = (strtotime($approx) - strtotime($time)) / 3600;
     } elseif (trim($approx) == '') {
         $est = null;
     } else {
         $est = floatval($approx);
     }
     extract(Plugin::call('task_filter', array('task' => $task, 'notes' => $notes)));
     $timerec = array('time' => $hours, 'ondate' => date('Y-m-d'), 'pcode' => $pcode, 'task' => $task, 'notes' => $notes, 'billable' => !(preg_match('%-\\$%', $task) || preg_match('%-\\$%', $notes)));
     $projects = $this->_get_projects();
     if (in_array($timerec['pcode'], $projects)) {
         $this->_add_time($timerec);
         $msg = "<span class=\"time\">Added {$hours} hours</span> <span class=\"project\">{$pcode}</span> <span class=\"task\">{$task}</span>";
         Immediate::ok($msg, 'ok time time_instant');
     } else {
         Immediate::error('Specified project "' . $timerec['pcode'] . '" does not exist.');
     }
     return $return;
 }