function times_my_tasks_dropdown() { echo '<li class="header"><a href="' . get_url('time', 'index') . '">' . lang('time') . '</a></li>'; if (ProjectTime::canAdd(logged_user(), active_project())) { echo '<li><a href="' . get_url('time', 'add') . '">' . lang('add time') . '</a></li>'; } // if }
<?php trace(__FILE__, 'start'); set_page_title(lang('view task')); project_tabbed_navigation('tasks'); project_crumbs(array(array(lang('tasks'), get_url('task')), array($task_list->getName(), $task_list->getViewUrl()), array(lang('view task')))); $options = array(); if ($task->canEdit(logged_user())) { $options[] = '<a href="' . $task->getEditUrl() . '">' . lang('edit') . '</a>'; } if ($task->canDelete(logged_user())) { $options[] = '<a href="' . $task->getDeleteUrl() . '">' . lang('delete') . '</a>'; } if (plugin_active('time')) { if (ProjectTime::canAdd(logged_user(), active_project())) { $options[] = '<a href="' . get_url('time', 'add', array('task' => $task->getId())) . '">' . lang('add time') . '</a>'; } } if ($task->canChangeStatus(logged_user())) { if ($task->isOpen()) { $options[] = '<a href="' . $task->getCompleteUrl() . '">' . lang('mark task as completed') . '</a>'; } else { $options[] = '<a href="' . $task->getOpenUrl() . '">' . lang('open task') . '</a>'; } // if } // if ?> <div id="taskDetails" class="block"> <div class="header"><?php
/** * Process add time form * * @access public * @param void * @return null */ function add() { $this->setTemplate('add_time'); if (!ProjectTime::canAdd(logged_user(), active_project())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('time')); } // if $time_data = array_var($_POST, 'time'); if (!is_array($time_data)) { $user = logged_user(); $time_data = array('done_date' => DateTimeValueLib::now(), 'is_billable' => true, 'assigned_to' => logged_user()->getCompanyId() . ":" . logged_user()->getId(), 'is_private' => config_option('default_private', false)); // array } // if $time = new ProjectTime(); tpl_assign('time_data', $time_data); tpl_assign('time', $time); tpl_assign('open_task_lists', active_project()->getOpenTaskLists()); if (is_array(array_var($_POST, 'time'))) { if (isset($_POST['time_done_date'])) { $time_data['done_date'] = DateTimeValueLib::makeFromString($_POST['time_done_date']); } else { $time_data['done_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'time_done_date_month', 1), array_var($_POST, 'time_done_date_day', 1), array_var($_POST, 'time_done_date_year', 1970)); } $assigned_to = explode(':', array_var($time_data, 'assigned_to', '')); // Attiks - BEGIN if (isset($time_data['task_id'])) { if (substr($time_data['task_id'], 0, 5) == 'task_') { $time_data['task_id'] = substr($time_data['task_id'], 5); $t = ProjectTasks::findById($time_data['task_id']); if (!$t instanceof ProjectTask) { flash_error(lang('task dnx')); $this->redirectTo('task'); } // if $time_data['task_list_id'] = $t->getTaskListId(); } else { $time_data['task_list_id'] = $time_data['task_id']; $time_data['task_id'] = null; } } // Attiks - END $time->setFromAttributes($time_data); if (!logged_user()->isMemberOfOwnerCompany()) { $time->setIsPrivate(false); } $time->setProjectId(active_project()->getId()); $time->setAssignedToCompanyId(array_var($assigned_to, 0, 0)); $time->setAssignedToUserId(array_var($assigned_to, 1, 0)); try { DB::beginWork(); $time->save(); ApplicationLogs::createLog($time, active_project(), ApplicationLogs::ACTION_ADD); DB::commit(); flash_success(lang('success add time', $time->getName())); $this->redirectTo('time'); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }