function build_effort_edit_form()
{
    $effort = new Effort();
    global $g_effort_status_names;
    global $PH;
    global $auth;
    $last_end_time = '';
    if ($last = Effort::getDateCreatedLast()) {
        $seconds_since_last_effort = strToGMTime('') - strToGMTime($last);
        if ($seconds_since_last_effort < 15 * 60 * 60) {
            $last_end_time = strToGMTime($last);
        }
    }
    echo "<h3>" . __("New Effort") . "</h3>" . "<div class='timetracking'>" . "<p>" . "<p>" . "<input type=hidden placeholder='Date' class='time date' id='effort_date' >" . "<a href='' id='trigger_date'>Today</a>" . "<input placeholder='Start' class='time start' id='effort_start' >" . "<input placeholder='Time' class='time duration' id='effort_duration' >" . "<input placeholder='Now' class='time end' id='effort_end' >" . '<span class="rating">' . '<input name="productivity" type="radio" class="star required" value="1"/>' . '<input name="productivity" type="radio" class="star" value="2"/>' . '<input name="productivity" type="radio" class="star" value="3" checked="checked"/>' . '<input name="productivity" type="radio" class="star" value="4"/>' . '<input name="productivity" type="radio" class="star" value="5"/>' . '</span>' . "</p>" . "<p>" . "<input placeholder='Project' class='project' id='effort_project' >" . "<input placeholder='Task' class='task' id='effort_task' name='task_name' >" . "</p>" . "<p>" . "<select name='billing'>" . "<option value='" . EFFORT_IS_BILLABLE . "'>Billable</option>" . "<option value='" . EFFORT_IS_NOT_BILLABLE . "'>Not Billable</option>" . "<option value='" . EFFORT_IS_REDUCED . "'>Reduced</option>" . "<option value='" . EFFORT_IS_TRAVEL . "'>Travel</option>" . "<option value='" . EFFORT_IS_CHARGE_EXTRA . "'>Extra Charge</option>" . "</select>" . "</p>" . "<p><textarea name='description' id='description' placeholder='Comment'></textarea></p>" . "</div>";
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $PH->go_submit = 'newEffortFromTimeTracking';
    echo "<input type=hidden id='effort_project_id' name='effort_project_id' value=''>";
    echo "<input type=hidden id='effort_task_id'  name='effort_task_id' value=''>";
    echo "<input type=hidden id='effort_start_seconds' name='effort_start_seconds' value='" . $last_end_time . "'>";
    echo "<input type=hidden id='effort_end_seconds'  name='effort_end_seconds' value=''>";
    echo "<input type=submit>";
}
示例#2
0
/**
* create a new effort @ingroup pages
*/
function effortNew()
{
    global $PH;
    global $auth;
    $name = get('new_name') ? get('new_name') : __("New Effort");
    ### first try single project-id ###
    $project = NULL;
    if ($ids = getPassedIds('prj', 'projects_*')) {
        if (!($project = Project::getVisibleById($ids[0]))) {
            $PH->abortWarning("ERROR: could not get Project");
            return;
        }
    }
    ### try to get task ###
    $task_id = 0;
    if ($task_ids = getPassedIds('parent_task', 'tasks_*')) {
        if (count($task_ids) > 1) {
            new FeedbackWarning(__("only expected one task. Used the first one."));
        }
        $task_id = $task_ids[0];
    } else {
        if ($task_ids = getPassedIds('', 'folders_*')) {
            if (count($task_ids) > 1) {
                new FeedbackWarning(__("only expected one task. Used the first one."));
            }
            $task_id = $task_ids[0];
        }
    }
    if (!$project) {
        if (!$task_id) {
            $PH->abortWarning("Could not get project", ERROR_NOTE);
        }
        if (!($task = Task::getVisibleById($task_id))) {
            $PH->abortWarning("Invalid task id?", ERROR_BUG);
        }
        if (!($project = Project::getVisibleById($task->project))) {
            $PH->abortWarning("Invalid project for task?", ERROR_BUG);
        }
    }
    if (!$project->isPersonVisibleTeamMember($auth->cur_user)) {
        $PH->abortWarning("ERROR: Insufficient rights");
    }
    $now = getGMTString();
    ### last effort selected? ###
    if ($effort_ids = getPassedIds('', 'efforts_*')) {
        $last_effort = Effort::getVisibleById($effort_ids[0]);
        $last = $last_effort->time_end;
        $now = $last_effort->time_end;
    } else {
        if ($last = Effort::getDateCreatedLast()) {
            $last_day = getdate(strToGMTime($last));
        } else {
            $last_day = "1980-01-01";
        }
        $today = getdate(time());
        if ($last_day['yday'] != $today['yday']) {
            $last = getGMTString();
        }
    }
    ### log efforts as durations? ###
    $as_duration = 0;
    if ($pp = $project->getCurrentProjectPerson()) {
        if ($pp->adjust_effort_style == 2) {
            if ($last = Effort::getDateCreatedLast()) {
                $last_day = $last;
            } else {
                $last_day = "1980-01-01";
            }
            $str_time = sprintf("%02d:%02d:%02d", floor((time() - strToGMTime($last_day)) / 60 / 60 % 24), floor((time() - strToGMTime($last_day)) / 60 % 60), floor((time() - strToGMTime($last_day)) % 60));
            $now = gmdate("Y-m-d", time()) . " " . $str_time;
            $last = gmdate("Y-m-d") . " " . "00:00:00";
            $as_duration = 1;
        }
    }
    ### build new object ###
    $newEffort = new Effort(array('id' => 0, 'name' => $name, 'project' => $project->id, 'time_start' => $last, 'time_end' => $now, 'task' => $task_id, 'as_duration' => $as_duration, 'person' => $auth->cur_user->id));
    $PH->show('effortEdit', array('effort' => $newEffort->id), $newEffort);
}