コード例 #1
0
ファイル: tsiHint.inc.php プロジェクト: cjbayliss/alloc
 function add_tsiHint($stuff)
 {
     $current_user =& singleton("current_user");
     $errstr = "Failed to record new time sheet item hint. ";
     $username = $stuff["username"];
     $people = person::get_people_by_username();
     $personID = $people[$username]["personID"];
     $personID or alloc_error("Person " . $username . " not found.");
     $taskID = $stuff["taskID"];
     $projectID = $stuff["projectID"];
     $duration = $stuff["duration"];
     $comment = $stuff["comment"];
     $date = $stuff["date"];
     if ($taskID) {
         $task = new task();
         $task->set_id($taskID);
         $task->select();
         $projectID = $task->get_value("projectID");
         $extra = " for task " . $taskID;
     }
     $projectID or alloc_error(sprintf($errstr . "No project found%s.", $extra));
     $row_projectPerson = projectPerson::get_projectPerson_row($projectID, $current_user->get_id());
     $row_projectPerson or alloc_error($errstr . "The person(" . $current_user->get_id() . ") has not been added to the project(" . $projectID . ").");
     if ($row_projectPerson && $projectID) {
         // Add new time sheet item
         $tsiHint = new tsiHint();
         $d = $date or $d = date("Y-m-d");
         $tsiHint->set_value("date", $d);
         $tsiHint->set_value("duration", $duration);
         if (is_object($task)) {
             $tsiHint->set_value("taskID", sprintf("%d", $taskID));
         }
         $tsiHint->set_value("personID", $personID);
         $tsiHint->set_value("comment", $comment);
         $tsiHint->save();
         $ID = $tsiHint->get_id();
     }
     if ($ID) {
         return array("status" => "yay", "message" => $ID);
     } else {
         alloc_error($errstr . "Time hint not added.");
     }
 }
コード例 #2
0
ファイル: timeSheet.php プロジェクト: cjbayliss/alloc
function show_timeSheet_list($template)
{
    global $TPL;
    global $timeSheet;
    global $db;
    global $tskDesc;
    global $timeSheetItem;
    global $timeSheetID;
    $db_task = new db_alloc();
    if (is_object($timeSheet) && ($timeSheet->get_value("status") == "edit" || $timeSheet->get_value("status") == "rejected")) {
        $TPL["timeSheetItem_buttons"] = '
        <button type="submit" name="timeSheetItem_delete" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
        <button type="submit" name="timeSheetItem_edit" value="1">Edit<i class="icon-edit"></i></button>';
    }
    $TPL["currency"] = page::money($timeSheet->get_value("currencyTypeID"), '', "%S");
    $timeUnit = new timeUnit();
    $unit_array = $timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelA");
    $item_query = prepare("SELECT * from timeSheetItem WHERE timeSheetID=%d", $timeSheetID);
    // If editing a timeSheetItem then don't display it in the list
    $timeSheetItemID = $_POST["timeSheetItemID"] or $timeSheetItemID = $_GET["timeSheetItemID"];
    $timeSheetItemID and $item_query .= prepare(" AND timeSheetItemID != %d", $timeSheetItemID);
    $item_query .= prepare(" GROUP BY timeSheetItemID ORDER BY dateTimeSheetItem, timeSheetItemID");
    $db->query($item_query);
    if (is_object($timeSheet)) {
        $project = $timeSheet->get_foreign_object("project");
        $row_projectPerson = projectPerson::get_projectPerson_row($project->get_id(), $timeSheet->get_value("personID"));
        $default_rate = array();
        if ($row_projectPerson && $row_projectPerson['rate'] > 0) {
            $default_rate['rate'] = $row_projectPerson['rate'];
            $default_rate['unit'] = $row_projectPerson['rateUnitID'];
        }
    }
    while ($db->next_record()) {
        $timeSheetItem = new timeSheetItem();
        $timeSheetItem->currency = $timeSheet->get_value("currencyTypeID");
        $timeSheetItem->read_db_record($db);
        $timeSheetItem->set_tpl_values("timeSheetItem_");
        $TPL["timeSheet_totalHours"] += $timeSheetItem->get_value("timeSheetItemDuration");
        $TPL["unit"] = $unit_array[$timeSheetItem->get_value("timeSheetItemDurationUnitID")];
        $br = "";
        $commentPrivateText = "";
        $text = $timeSheetItem->get_value('description', DST_HTML_DISPLAY);
        if ($timeSheetItem->get_value("commentPrivate")) {
            $commentPrivateText = "<b>[Private Comment]</b> ";
        }
        $text and $TPL["timeSheetItem_description"] = "<a href=\"" . $TPL["url_alloc_task"] . "taskID=" . $timeSheetItem->get_value('taskID') . "\">" . $text . "</a>";
        $text && $timeSheetItem->get_value("comment") and $br = "<br>";
        $timeSheetItem->get_value("comment") and $TPL["timeSheetItem_comment"] = $br . $commentPrivateText . page::to_html($timeSheetItem->get_value("comment"));
        $TPL["timeSheetItem_unit_times_rate"] = $timeSheetItem->calculate_item_charge($timeSheet->get_value("currencyTypeID"), $timeSheetItem->get_value("rate"));
        $m = new meta("timeSheetItemMultiplier");
        $tsMultipliers = $m->get_list();
        $timeSheetItem->get_value('multiplier') and $TPL["timeSheetItem_multiplier"] = $tsMultipliers[$timeSheetItem->get_value('multiplier')]['timeSheetItemMultiplierName'];
        // Check to see if this tsi is part of an overrun
        $TPL["timeSheetItem_class"] = "panel";
        $TPL["timeSheetItem_status"] = "";
        $row_messages = array();
        if ($timeSheetItem->get_value('taskID')) {
            $task = new task();
            $task->set_id($timeSheetItem->get_value('taskID'));
            $task->select();
            if ($task->get_value('timeLimit') > 0) {
                $total_billed_time = $task->get_time_billed(false) / 3600;
                // get_time_billed returns seconds, limit hours is in hours
                if ($total_billed_time > $task->get_value('timeLimit')) {
                    $row_messages[] = "<em class='faint warn nobr'>[ Exceeds Limit ]</em>";
                }
            }
        }
        // Highlight the rate if the project person has a non-zero rate and it doesn't match the item's rate
        if ($default_rate) {
            if ($timeSheetItem->get_value('rate') != $default_rate['rate'] || $timeSheetItem->get_value('timeSheetItemDurationUnitID') != $default_rate['unit']) {
                $row_messages[] = "<em class='faint warn nobr'>[ Modified rate ]</em>";
            }
        }
        if ($row_messages) {
            $TPL["timeSheetItem_status"] = implode("<br />", $row_messages);
            $TPL["timeSheetItem_class"] = "panel loud";
        }
        include_template($template);
    }
    $TPL["summary_totals"] = $timeSheet->pay_info["summary_unit_totals"];
}
コード例 #3
0
ファイル: timeSheet.inc.php プロジェクト: cjbayliss/alloc
 function add_timeSheetItem($stuff)
 {
     $current_user =& singleton("current_user");
     $errstr = "Failed to record new time sheet item. ";
     $taskID = $stuff["taskID"];
     $projectID = $stuff["projectID"];
     $duration = $stuff["duration"];
     $comment = $stuff["comment"];
     $emailUID = $stuff["msg_uid"];
     $emailMessageID = $stuff["msg_id"];
     $date = $stuff["date"];
     $unit = $stuff["unit"];
     $multiplier = $stuff["multiplier"];
     if ($taskID) {
         $task = new task();
         $task->set_id($taskID);
         $task->select();
         $projectID = $task->get_value("projectID");
         $extra = " for task " . $taskID;
     }
     $projectID or alloc_error(sprintf($errstr . "No project found%s.", $extra));
     $row_projectPerson = projectPerson::get_projectPerson_row($projectID, $current_user->get_id());
     $row_projectPerson or alloc_error($errstr . "The person(" . $current_user->get_id() . ") has not been added to the project(" . $projectID . ").");
     if ($row_projectPerson && $projectID) {
         if ($stuff["timeSheetID"]) {
             $q = prepare("SELECT *\n                        FROM timeSheet\n                       WHERE status = 'edit'\n                         AND personID = %d\n                         AND timeSheetID = %d\n                    ORDER BY dateFrom\n                       LIMIT 1\n                  ", $current_user->get_id(), $stuff["timeSheetID"]);
             $db = new db_alloc();
             $db->query($q);
             $row = $db->row();
             $row or alloc_error("Couldn't find an editable time sheet with that ID.");
         } else {
             $q = prepare("SELECT *\n                        FROM timeSheet\n                       WHERE status = 'edit'\n                         AND projectID = %d\n                         AND personID = %d\n                    ORDER BY dateFrom\n                       LIMIT 1\n                  ", $projectID, $current_user->get_id());
             $db = new db_alloc();
             $db->query($q);
             $row = $db->row();
         }
         // If no timeSheets add a new one
         if (!$row) {
             $project = new project();
             $project->set_id($projectID);
             $project->select();
             $timeSheet = new timeSheet();
             $timeSheet->set_value("projectID", $projectID);
             $timeSheet->set_value("status", "edit");
             $timeSheet->set_value("personID", $current_user->get_id());
             $timeSheet->set_value("recipient_tfID", $current_user->get_value("preferred_tfID"));
             $timeSheet->set_value("customerBilledDollars", page::money($project->get_value("currencyTypeID"), $project->get_value("customerBilledDollars"), "%mo"));
             $timeSheet->set_value("currencyTypeID", $project->get_value("currencyTypeID"));
             $timeSheet->save();
             $timeSheetID = $timeSheet->get_id();
             // Else use the first timesheet we found
         } else {
             $timeSheetID = $row["timeSheetID"];
         }
         $timeSheetID or alloc_error($errstr . "Couldn't locate an existing, or create a new Time Sheet.");
         // Add new time sheet item
         if ($timeSheetID) {
             $timeSheet = new timeSheet();
             $timeSheet->set_id($timeSheetID);
             $timeSheet->select();
             $tsi = new timeSheetItem();
             $tsi->currency = $timeSheet->get_value("currencyTypeID");
             $tsi->set_value("timeSheetID", $timeSheetID);
             $d = $date or $d = date("Y-m-d");
             $tsi->set_value("dateTimeSheetItem", $d);
             $tsi->set_value("timeSheetItemDuration", $duration);
             $tsi->set_value("timeSheetItemDurationUnitID", $unit);
             if (is_object($task)) {
                 $tsi->set_value("description", $task->get_name());
                 $tsi->set_value("taskID", sprintf("%d", $taskID));
                 $_POST["timeSheetItem_taskID"] = sprintf("%d", $taskID);
                 // this gets used in timeSheetItem->save();
             }
             $tsi->set_value("personID", $current_user->get_id());
             $tsi->set_value("rate", page::money($timeSheet->get_value("currencyTypeID"), $row_projectPerson["rate"], "%mo"));
             $tsi->set_value("multiplier", $multiplier);
             $tsi->set_value("comment", $comment);
             $tsi->set_value("emailUID", $emailUID);
             $tsi->set_value("emailMessageID", $emailMessageID);
             $tsi->save();
             $id = $tsi->get_id();
             $tsi = new timeSheetItem();
             $tsi->set_id($id);
             $tsi->select();
             $ID = $tsi->get_value("timeSheetID");
         }
     }
     if ($ID) {
         return array("status" => "yay", "message" => $ID);
     } else {
         alloc_error($errstr . "Time not added.");
     }
 }
コード例 #4
0
ファイル: project.php プロジェクト: cjbayliss/alloc
function show_new_person($template)
{
    global $TPL;
    global $email_type_array;
    global $rate_type_array;
    global $projectID;
    global $project_person_role_array;
    // Don't show entry form for new projects
    if (!$projectID) {
        return;
    }
    $project_person = new projectPerson();
    $project_person->set_values("person_");
    $TPL["person_emailType_options"] = page::select_options($email_type_array, $TPL["person_emailType"]);
    $TPL["person_role_options"] = page::select_options($project_person_role_array, false);
    $TPL["rateType_options"] = page::select_options($rate_type_array);
    include_template($template);
}
コード例 #5
0
<?php

/*
 * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions
 * Pty. Ltd.
 * 
 * This file is part of the allocPSA application <*****@*****.**>.
 * 
 * allocPSA is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
define("NO_REDIRECT", 1);
require_once "../alloc.php";
if ($_GET["project"] && $_GET["person"]) {
    $rate = projectPerson::get_rate($_GET["project"], $_GET["person"]);
    $project = new project($_GET["project"]);
    $currency = $project->get_value("currencyTypeID") or $currency = config::get_config_item("currency");
    $rate['rate'] = page::money($currency, $rate['rate'], '%mo');
    echo alloc_json_encode($rate);
}
コード例 #6
0
ファイル: stats.inc.php プロジェクト: cjbayliss/alloc
 function project_stats()
 {
     // date from which a project is counted as being new. if monday then date back to friday, else the previous day
     $days = date("w") == 1 ? 3 : 1;
     $date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $days, date("Y")));
     $query = "SELECT * FROM project";
     $db = new db_alloc();
     $db_sub = new db_alloc();
     $db->query($query);
     while ($db->next_record()) {
         $project = new project();
         $project->read_db_record($db);
         $this->projects["total"]["total"]++;
         switch ($project->get_value("projectStatus")) {
             case "current":
             case "overdue":
                 $this->projects["current"]["total"]++;
                 break;
             case "archived":
                 $this->projects["archived"]["total"]++;
                 break;
         }
         $query = prepare("SELECT * FROM projectPerson WHERE projectID=%d", $project->get_id());
         $db_sub->query($query);
         while ($db_sub->next_record()) {
             $projectPerson = new projectPerson();
             $projectPerson->read_db_record($db_sub);
             $this->projects["total"][$projectPerson->get_value("personID")]++;
             switch ($project->get_value("projectStatus")) {
                 case "current":
                 case "overdue":
                     $this->projects["current"][$projectPerson->get_value("personID")]++;
                     break;
                 case "archived":
                     $this->projects["archived"][$projectPerson->get_value("personID")]++;
                     break;
             }
             if ($project->get_value("dateActualStart") != "") {
                 if (!isset($this->projects["all"][$projectPerson->get_value("personID")])) {
                     $this->projects["all"][$projectPerson->get_value("personID")] = array();
                 }
                 $this->projects["all"][$projectPerson->get_value("personID")][$project->get_value("dateActualStart")]++;
                 $this->projects["all"][$projectPerson->get_value("personID")]["total"]++;
                 $this->projects["all"]["total"][$project->get_value("dateActualStart")]++;
                 if (strcmp($date, $project->get_value("dateActualStart")) <= 0) {
                     if (!isset($this->projects["new"][$projectPerson->get_value("personID")])) {
                         $this->projects["new"][$projectPerson->get_value("personID")] = array();
                     }
                     $this->projects["new"][$projectPerson->get_value("personID")][$project->get_value("dateActualStart")]++;
                     $this->projects["new"][$projectPerson->get_value("personID")]["total"]++;
                     $this->projects["new"]["total"][$project->get_value("dateActualStart")]++;
                 }
             }
         }
     }
     return $this->projects;
 }