コード例 #1
0
ファイル: weeklyTime.php プロジェクト: cjbayliss/alloc
function show_timeSheetItems($template_name)
{
    global $date_to_view;
    $current_user =& singleton("current_user");
    global $TPL;
    $query = prepare("SELECT * \n                      FROM timeSheetItem \n                           LEFT JOIN timeSheet ON timeSheetItem.timeSheetID = timeSheet.timeSheetID\n                           LEFT JOIN project ON timeSheet.projectID = project.projectID\n                      WHERE dateTimeSheetItem='%s'\n                            AND timeSheet.personID=%d", date("Y-m-d", $date_to_view), $current_user->get_id());
    $db = new db_alloc();
    $db->query($query);
    while ($db->next_record()) {
        $timeSheetItem = new timeSheetItem();
        $timeSheetItem->read_db_record($db);
        $timeSheetItem->set_values();
        if ($timeSheetItem->get_value("unit") == "Hour") {
            $TPL["daily_hours_total"] += $timeSheetItem->get_value("timeSheetItemDuration");
        }
        $project = new project();
        $project->read_db_record($db);
        $project->set_values();
        if ($project->get_value("projectShortName")) {
            $TPL["item_description"] = $project->get_value("projectShortName");
        } else {
            $TPL["item_description"] = $project->get_value("projectName");
        }
        include_template($template_name);
    }
}
コード例 #2
0
 function render()
 {
     $current_user =& singleton("current_user");
     global $TPL;
     // Get averages for hours worked over the past fortnight and year
     $t = new timeSheetItem();
     $day = 60 * 60 * 24;
     //mktime(0,0,0,date("m"),date("d")-1, date("Y"))
     $today = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
     $yestA = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
     $yestB = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
     $fortn = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 14, date("Y")));
     list($hours_sum_today, $dollars_sum_today) = $t->get_averages($today, $current_user->get_id());
     list($hours_sum_yesterday, $dollars_sum_yesterday) = $t->get_averages($yestA, $current_user->get_id(), null, $yestB);
     list($hours_sum_fortnight, $dollars_sum_fortnight) = $t->get_averages($fortn, $current_user->get_id());
     list($hours_avg_fortnight, $dollars_avg_fortnight) = $t->get_fortnightly_average($current_user->get_id());
     $TPL["hours_sum_today"] = sprintf("%0.2f", $hours_sum_today[$current_user->get_id()]);
     $TPL["dollars_sum_today"] = page::money_print($dollars_sum_today[$current_user->get_id()]);
     $TPL["hours_sum_yesterday"] = sprintf("%0.2f", $hours_sum_yesterday[$current_user->get_id()]);
     $TPL["dollars_sum_yesterday"] = page::money_print($dollars_sum_yesterday[$current_user->get_id()]);
     $TPL["hours_sum_fortnight"] = sprintf("%0.2f", $hours_sum_fortnight[$current_user->get_id()]);
     $TPL["dollars_sum_fortnight"] = page::money_print($dollars_sum_fortnight[$current_user->get_id()]);
     $TPL["hours_avg_fortnight"] = sprintf("%0.2f", $hours_avg_fortnight[$current_user->get_id()]);
     $TPL["dollars_avg_fortnight"] = page::money(config::get_config_item("currency"), $dollars_avg_fortnight[$current_user->get_id()], "%s%m %c");
     $TPL["dateFrom"] = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 28, date("Y")));
     $TPL["dateTo"] = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
     return true;
 }
コード例 #3
0
                if ($k == "multiplier") {
                    $v = $tsims[sprintf("%0.2f", $v)]["timeSheetItemMultiplierName"];
                }
            }
        }
        $rtn[$k] = $v;
    }
}
//2010-10-01  1 Days x Double Time
//Task: 102 This is the task
//Comment: This is the comment
$str[] = "<tr><td>" . $rtn["date"] . " </td><td class='nobr bold'> " . $rtn["duration"] . " " . $rtn["unit"] . "</td><td class='nobr'>&times; " . $rtn["multiplier"] . "</td></tr>";
$rtn["taskID"] and $str[] = "<tr><td colspan='3'>" . $rtn["taskID"] . "</td></tr>";
$rtn["comment"] and $str[] = "<tr><td colspan='3'>" . $rtn["comment"] . "</td></tr>";
if (isset($_REQUEST["save"]) && isset($_REQUEST["time_item"])) {
    $t = timeSheetItem::parse_time_string($_REQUEST["time_item"]);
    if (!is_numeric($t["duration"])) {
        $status = "bad";
        $extra = "Time not added. Duration not found.";
    } else {
        if (!is_numeric($t["taskID"])) {
            $status = "bad";
            $extra = "Time not added. Task not found.";
        }
    }
    if ($status != "bad") {
        $timeSheet = new timeSheet();
        $tsi_row = $timeSheet->add_timeSheetItem($t);
        if ($TPL["message"]) {
            $status = "bad";
            $extra = "Time not added.<br>" . implode("<br>", $TPL["message"]);
コード例 #4
0
ファイル: comment.inc.php プロジェクト: cjbayliss/alloc
 function get_list_summary($_FORM = array())
 {
     //$_FORM["fromDate"] = "2010-08-20";
     //$_FORM["projectID"] = "22";
     $_FORM["maxCommentLength"] or $_FORM["maxCommentLength"] = 500;
     list($filter1, $filter2, $filter3) = comment::get_list_summary_filter($_FORM);
     is_array($filter1) && count($filter1) and $filter1 = " AND " . implode(" AND ", $filter1);
     is_array($filter2) && count($filter2) and $filter2 = " AND " . implode(" AND ", $filter2);
     is_array($filter3) && count($filter3) and $filter3 = " AND " . implode(" AND ", $filter3);
     if ($_FORM["clients"]) {
         $client_join = " LEFT JOIN clientContact on comment.commentCreatedUserClientContactID = clientContact.clientContactID";
         $client_fields = " , clientContact.clientContactName";
     }
     $q = prepare("SELECT commentID as id\n                       , commentCreatedUser as personID\n                       , UNIX_TIMESTAMP(commentCreatedTime) as sortDate\n                       , date(commentCreatedTime) as date\n                       , commentCreatedTime as displayDate\n                       , commentMasterID as taskID\n                       , task.taskName\n                       , SUBSTRING(comment.comment,1,%d) AS comment_text\n                       , commentCreatedUserText\n                         " . $client_fields . "\n                    FROM comment\n               LEFT JOIN task on comment.commentMasterID = task.taskID\n                         " . $client_join . "\n                   WHERE commentMaster = 'task'\n                         " . $filter1 . "\n                ORDER BY commentCreatedTime, commentCreatedUser", $_FORM["maxCommentLength"]);
     $q .= " ";
     $people =& get_cached_table("person");
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->row()) {
         $row["icon"] = 'icon-comments-alt';
         $row["id"] = "comment_" . $row["id"];
         $row["personID"] and $row["person"] = $people[$row["personID"]]["name"];
         $row["clientContactName"] and $row["person"] = $row["clientContactName"];
         $row["person"] or list($e, $row["person"]) = parse_email_address($row["commentCreatedUserText"]);
         $row["displayDate"] = format_date("Y-m-d g:ia", $row["displayDate"]);
         if (!$tasks[$row["taskID"]]) {
             $t = new task();
             $t->set_id($row["taskID"]);
             $t->set_value("taskName", $row["taskName"]);
             $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true));
         }
         $rows[$row["taskID"]][$row["sortDate"]][] = $row;
     }
     // Note that timeSheetItemID is selected twice so that the perms checking can work
     // timeSheetID is also used by the perms checking.
     $q2 = prepare("SELECT timeSheetItemID as id\n                         ,timeSheetItemID\n                         ,timeSheetID\n                         ,timeSheetItem.personID\n                         ,dateTimeSheetItem as date\n                         ,UNIX_TIMESTAMP(CONCAT(dateTimeSheetItem, ' 23:59:58')) as sortDate\n                         ,dateTimeSheetItem as displayDate\n                         ,timeSheetItem.taskID\n                         ,task.taskName\n                         ,timeSheetItemDuration as duration\n                         ,SUBSTRING(timeSheetItem.comment,1,%d) AS comment_text\n                     FROM timeSheetItem\n                LEFT JOIN task on timeSheetItem.taskID = task.taskID\n                    WHERE 1\n                          " . $filter2 . "\n                 ORDER BY dateTimeSheetItem", $_FORM["maxCommentLength"]);
     $db->query($q2);
     while ($row = $db->row()) {
         $timeSheetItem = new timeSheetItem();
         if (!$timeSheetItem->read_row_record($row)) {
             continue;
         }
         $row["icon"] = 'icon-time';
         $row["id"] = "timeitem_" . $row["id"];
         $row["person"] = $people[$row["personID"]]["name"];
         if (!$tasks[$row["taskID"]]) {
             $t = new task();
             $t->set_id($row["taskID"]);
             $t->set_value("taskName", $row["taskName"]);
             $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true));
         }
         $totals[$row["taskID"]] += $row["duration"];
         $rows[$row["taskID"]][$row["sortDate"]][] = $row;
     }
     // get manager's guestimates about time worked from tsiHint table
     $q3 = prepare("SELECT tsiHintID as id\n                         ,tsiHintID\n                         ,tsiHint.personID\n                         ,tsiHint.date\n                         ,UNIX_TIMESTAMP(CONCAT(tsiHint.date,' 23:59:59')) as sortDate\n                         ,tsiHint.date as displayDate\n                         ,tsiHint.taskID\n                         ,tsiHint.duration\n                         ,tsiHint.tsiHintCreatedUser\n                         ,SUBSTRING(tsiHint.comment,1,%d) AS comment_text\n                         ,task.taskName\n                     FROM tsiHint\n                LEFT JOIN task on tsiHint.taskID = task.taskID\n                    WHERE 1\n                          " . $filter3 . "\n                 ORDER BY tsiHint.date", $_FORM["maxCommentLength"]);
     $db->query($q3);
     while ($row = $db->row()) {
         //$tsiHint = new tsiHint();
         //if (!$tsiHint->read_row_record($row))
         //  continue;
         $row["icon"] = 'icon-bookmark-empty';
         $row["id"] = "tsihint_" . $row["id"];
         $row["person"] = $people[$row["personID"]]["name"];
         $row["comment_text"] .= ' [by ' . $people[$row["tsiHintCreatedUser"]]["name"] . ']';
         if (!$tasks[$row["taskID"]]) {
             $t = new task();
             $t->set_id($row["taskID"]);
             $t->set_value("taskName", $row["taskName"]);
             $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true));
         }
         $totals_tsiHint[$row["taskID"]] += $row["duration"];
         $rows[$row["taskID"]][$row["sortDate"]][] = $row;
     }
     // If there is a time sheet entry for 2010-10-10 but there is no comment entry
     // for that date, then the time sheet entry will appear out of sequence i.e. at
     // the very end of the whole list. So we need to manually sort them.
     foreach ((array) $rows as $tid => $arr) {
         ksort($arr, SORT_NUMERIC);
         $rows[$tid] = $arr;
     }
     foreach ((array) $rows as $taskID => $dates) {
         $rtn .= comment::get_list_summary_header($tasks[$taskID], $totals[$taskID], $totals_tsiHint[$taskID], $_FORM);
         foreach ($dates as $date => $more_rows) {
             foreach ($more_rows as $row) {
                 $rtn .= comment::get_list_summary_body($row);
             }
         }
         $rtn .= comment::get_list_summary_footer($rows, $tasks);
     }
     return $rtn;
 }
コード例 #5
0
ファイル: timeSheet.php プロジェクト: cjbayliss/alloc
function show_new_timeSheet($template)
{
    global $TPL;
    global $timeSheet;
    global $timeSheetID;
    $current_user =& singleton("current_user");
    // Don't show entry form for new timeSheet.
    if (!$timeSheetID) {
        return;
    }
    if (is_object($timeSheet) && ($timeSheet->get_value("status") == 'edit' || $timeSheet->get_value("status") == 'rejected') && ($timeSheet->get_value("personID") == $current_user->get_id() || $timeSheet->have_perm(PERM_TIME_INVOICE_TIMESHEETS))) {
        $TPL["currency"] = page::money($timeSheet->get_value("currencyTypeID"), '', "%S");
        // If we are editing an existing timeSheetItem
        $timeSheetItem_edit = $_POST["timeSheetItem_edit"] or $timeSheetItem_edit = $_GET["timeSheetItem_edit"];
        $timeSheetItemID = $_POST["timeSheetItemID"] or $timeSheetItemID = $_GET["timeSheetItemID"];
        if ($timeSheetItemID && $timeSheetItem_edit) {
            $timeSheetItem = new timeSheetItem();
            $timeSheetItem->currency = $timeSheet->get_value("currencyTypeID");
            $timeSheetItem->set_id($timeSheetItemID);
            $timeSheetItem->select();
            $timeSheetItem->set_values("tsi_");
            $TPL["tsi_rate"] = $timeSheetItem->get_value("rate", DST_HTML_DISPLAY);
            $taskID = $timeSheetItem->get_value("taskID");
            $TPL["tsi_buttons"] = '
         <button type="submit" name="timeSheetItem_delete" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
         <button type="submit" name="timeSheetItem_save" value="1" class="save_button default">Save Item<i class="icon-ok-sign"></i></button>
         ';
            $timeSheetItemDurationUnitID = $timeSheetItem->get_value("timeSheetItemDurationUnitID");
            $TPL["tsi_commentPrivate"] and $TPL["commentPrivateChecked"] = " checked";
            $TPL["ts_rate_editable"] = $timeSheet->can_edit_rate();
            $timeSheetItemMultiplier = $timeSheetItem->get_value("multiplier");
            // Else default values for creating a new timeSheetItem
        } else {
            $TPL["tsi_buttons"] = '<button type="submit" name="timeSheetItem_save" value="1" class="save_button">Add Item<i class="icon-plus-sign"></i></button>';
            $TPL["tsi_personID"] = $current_user->get_id();
            $timeSheet->load_pay_info();
            $TPL["tsi_rate"] = $timeSheet->pay_info["project_rate"];
            $timeSheetItemDurationUnitID = $timeSheet->pay_info["project_rateUnitID"];
            $TPL["ts_rate_editable"] = $timeSheet->can_edit_rate();
        }
        $taskID or $taskID = $_GET["taskID"];
        $TPL["taskListDropdown_taskID"] = $taskID;
        $TPL["taskListDropdown"] = $timeSheet->get_task_list_dropdown("mine", $timeSheet->get_id(), $taskID);
        $TPL["tsi_timeSheetID"] = $timeSheet->get_id();
        $timeUnit = new timeUnit();
        $unit_array = $timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelA");
        $TPL["tsi_unit_options"] = page::select_options($unit_array, $timeSheetItemDurationUnitID);
        $timeSheetItemDurationUnitID and $TPL["tsi_unit_label"] = $unit_array[$timeSheetItemDurationUnitID];
        $m = new meta("timeSheetItemMultiplier");
        $tsMultipliers = $m->get_list();
        foreach ($tsMultipliers as $k => $v) {
            $multiplier_array[$k] = $v["timeSheetItemMultiplierName"];
        }
        $TPL["tsi_multiplier_options"] = page::select_options($multiplier_array, $timeSheetItemMultiplier);
        include_template($template);
    }
}
コード例 #6
0
ファイル: timeSheetGraph.php プロジェクト: cjbayliss/alloc
 * 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/>.
*/
require_once "../alloc.php";
$current_user =& singleton("current_user");
function show_filter()
{
    global $TPL;
    global $defaults;
    $arr = timeSheetGraph::load_filter($defaults);
    is_array($arr) and $TPL = array_merge($TPL, $arr);
    include_template("templates/timeSheetGraphFilterS.tpl");
}
$defaults = array("url_form_action" => $TPL["url_alloc_timeSheetGraph"], "form_name" => "timeSheetGraph_filter", "groupBy" => "day", "personID" => $current_user->get_id());
$_FORM = timeSheetGraph::load_filter($defaults);
if ($_FORM["groupBy"] == "day") {
    $TPL["chart1"] = timeSheetItem::get_total_hours_worked_per_day($_FORM["personID"], $_FORM["dateFrom"], $_FORM["dateTo"]);
} else {
    if ($_FORM["groupBy"] == "month") {
        $TPL["chart1"] = timeSheetItem::get_total_hours_worked_per_month($_FORM["personID"], $_FORM["dateFrom"], $_FORM["dateTo"]);
    }
}
$TPL["dateFrom"] = $_FORM["dateFrom"];
$TPL["dateTo"] = $_FORM["dateTo"];
$TPL["groupBy"] = $_FORM["groupBy"];
include_template("templates/timeSheetGraphM.tpl");
コード例 #7
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.");
     }
 }
コード例 #8
0
 function get_timeSheetItem_list_items($timeSheetID)
 {
     global $TPL;
     list($db, $customerBilledDollars, $timeSheet, $unit_array, $currency) = $this->get_timeSheetItem_vars($timeSheetID);
     $m = new meta("timeSheetItemMultiplier");
     $multipliers = $m->get_list();
     while ($db->next_record()) {
         $timeSheetItem = new timeSheetItem();
         $timeSheetItem->read_db_record($db);
         $row_num++;
         $taskID = sprintf("%d", $timeSheetItem->get_value("taskID"));
         $num = sprintf("%0.2f", $timeSheetItem->get_value("timeSheetItemDuration"));
         $info["total"] += $num;
         $rows[$row_num]["date"] = $timeSheetItem->get_value("dateTimeSheetItem");
         $rows[$row_num]["units"] = $num . " " . $unit_array[$timeSheetItem->get_value("timeSheetItemDurationUnitID")];
         $rows[$row_num]["multiplier_string"] = $multipliers[$timeSheetItem->get_value("multiplier")]["timeSheetItemMultiplierName"];
         unset($str);
         $d = $timeSheetItem->get_value('taskID', DST_HTML_DISPLAY) . ": " . $timeSheetItem->get_value('description', DST_HTML_DISPLAY);
         $d && !$rows[$row_num]["desc"] and $str[] = "<b>" . $d . "</b>";
         // Get task description
         if ($taskID && $TPL["printDesc"]) {
             $t = new task();
             $t->set_id($taskID);
             $t->select();
             $d2 = str_replace("\r\n", "\n", $t->get_value("taskDescription", DST_HTML_DISPLAY));
             $d2 .= "\n";
             $d2 && !$d2s[$taskID] and $str[] = $d2;
             $d2 and $d2s[$taskID] = true;
         }
         $c = str_replace("\r\n", "\n", $timeSheetItem->get_value("comment"));
         !$timeSheetItem->get_value("commentPrivate") && $c and $str[] = page::htmlentities($c);
         is_array($str) and $rows[$row_num]["desc"] .= trim(implode(DEFAULT_SEP, $str));
     }
     $timeSheet->load_pay_info();
     $info["total"] = $timeSheet->pay_info["summary_unit_totals"];
     $rows or $rows = array();
     $info or $info = array();
     return array($rows, $info);
 }
コード例 #9
0
ファイル: timeSheetItem.php プロジェクト: cjbayliss/alloc
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "../alloc.php";
if (!$current_user->is_employee()) {
    alloc_error("You do not have permission to access time sheets", true);
}
$timeSheetID = $_POST["timeSheetID"];
$timeSheetItemID = $_POST["timeSheetItem_timeSheetItemID"];
if (($_POST["timeSheetItem_save"] || $_POST["timeSheetItem_edit"] || $_POST["timeSheetItem_delete"]) && $timeSheetID) {
    $timeSheet = new timeSheet();
    $timeSheet->set_id($timeSheetID);
    $timeSheet->select();
    $timeSheet->load_pay_info();
    $timeSheetItem = new timeSheetItem();
    if ($timeSheetItemID) {
        $timeSheetItem->set_id($timeSheetItemID);
        $timeSheetItem->select();
    }
    $timeSheetItem->read_globals();
    $timeSheetItem->read_globals("timeSheetItem_");
    if ($_POST["timeSheetItem_save"]) {
        $timeSheetItem->read_globals();
        $timeSheetItem->read_globals("timeSheetItem_");
        $rtn = $timeSheetItem->save();
        $rtn and $TPL["message_good"][] = "Time Sheet Item saved.";
        $_POST["timeSheetItem_taskID"] and $t = "&taskID=" . $_POST["timeSheetItem_taskID"];
        alloc_redirect($TPL["url_alloc_timeSheet"] . "timeSheetID=" . $timeSheetID . $t);
    } else {
        if ($_POST["timeSheetItem_edit"]) {
コード例 #10
0
ファイル: timeSheetItem.inc.php プロジェクト: cjbayliss/alloc
 function get_averages($dateTimeSheetItem, $personID = false, $divisor = "", $endDate = null)
 {
     $personID and $personID_sql = prepare(" AND timeSheetItem.personID = %d", $personID);
     $endDate and $endDate_sql = prepare(" AND timeSheetItem.dateTimeSheetItem <= '%s'", $endDate);
     $q = prepare("SELECT personID\n                       , SUM(timeSheetItemDuration*timeUnitSeconds) " . $divisor . " AS avg\n                    FROM timeSheetItem \n               LEFT JOIN timeUnit ON timeUnitID = timeSheetItemDurationUnitID \n                   WHERE dateTimeSheetItem > '%s'\n                      " . $personID_sql . "\n                      " . $endDate_sql . "\n                GROUP BY personID\n                 ", $dateTimeSheetItem);
     $db = new db_alloc();
     $db->query($q);
     $rows = array();
     while ($db->next_record()) {
         $rows[$db->f("personID")] = $db->f("avg") / 3600;
     }
     //Calculate the dollar values
     $q = prepare("SELECT (rate * POW(10, -currencyType.numberToBasic) * timeSheetItemDuration * multiplier) as amount\n                       , timeSheet.currencyTypeID as currency \n                       , timeSheetItem.*\n                    FROM timeSheetItem \n               LEFT JOIN timeSheet on timeSheetItem.timeSheetID = timeSheet.timeSheetID\n               LEFT JOIN currencyType ON timeSheet.currencyTypeID = currencyType.currencyTypeID\n                WHERE dateTimeSheetItem > '%s'\n                      " . $personID_sql . "\n                      " . $endDate_sql, $dateTimeSheetItem);
     $db->query($q);
     $rows_dollars = array();
     while ($row = $db->row()) {
         $tsi = new timeSheetItem();
         $tsi->read_db_record($db);
         $rows_dollars[$row["personID"]][] = $row;
     }
     return array($rows, $rows_dollars);
 }
コード例 #11
0
ファイル: updateTimeGraph.php プロジェクト: cjbayliss/alloc
<?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";
$current_user =& singleton("current_user");
$num_days_back = 28;
$start = date("Y-m-d", mktime() - 60 * 60 * 24 * $num_days_back);
$points = timeSheetItem::get_total_hours_worked_per_day($current_user->get_id(), $start);
print alloc_json_encode(array("status" => "good", "points" => $points));
コード例 #12
0
ファイル: services.inc.php プロジェクト: cjbayliss/alloc
 /**
  * Get all time sheet item comments in a faked mbox format
  * @param integer $taskID which task the time sheet item comments relate to
  * @return string of mbox format emails
  */
 public function get_timeSheetItem_comments($taskID)
 {
     $people =& get_cached_table("person");
     has("time") and $rows = timeSheetItem::get_timeSheetItemComments($taskID);
     foreach ((array) $rows as $row) {
         $d = $row["timeSheetItemCreatedTime"] or $d = $row["date"];
         $timestamp = format_date("U", $d);
         $name = $people[$row["personID"]]["name"];
         $str .= $br . "From allocPSA " . date('D M  j G:i:s Y', $timestamp);
         $str .= "\nFrom: " . $name;
         $str .= "\nDate: " . date("D, d M Y H:i:s O", $timestamp);
         $str .= "\n\n" . $name . " " . $row["duration"] . " " . $row["comment"];
         $br = "\n\n";
     }
     return $str;
 }
コード例 #13
0
ファイル: command.inc.php プロジェクト: cjbayliss/alloc
 function add_time($commands, $email_receive)
 {
     $current_user =& singleton("current_user");
     if ($commands["time"]) {
         // CLI passes time along as a string, email passes time along as an array
         if (!is_array($commands["time"])) {
             $t = $commands["time"];
             unset($commands["time"]);
             $commands["time"][] = $t;
         }
         foreach ((array) $commands["time"] as $time) {
             $t = timeSheetItem::parse_time_string($time);
             if (is_numeric($t["duration"]) && $current_user->get_id()) {
                 $timeSheet = new timeSheet();
                 is_object($email_receive) and $t["msg_uid"] = $email_receive->msg_uid;
                 $tsi_row = $timeSheet->add_timeSheetItem($t);
                 $status[] = $tsi_row["status"];
                 $message[] = $tsi_row["message"];
             }
         }
     }
     return array($status, $message);
 }
コード例 #14
0
ファイル: person.inc.php プロジェクト: cjbayliss/alloc
 public static function get_list($_FORM = array())
 {
     global $TPL;
     $current_user =& singleton("current_user");
     list($filter, $filter2) = person::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     // Get averages for hours worked over the past fortnight and year
     if ($current_user->have_perm(PERM_PERSON_READ_MANAGEMENT) && $_FORM["showHours"]) {
         $t = new timeSheetItem();
         list($ts_hrs_col_1, $ts_dollars_col_1) = $t->get_averages(date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 14, date("Y"))));
         list($ts_hrs_col_2, $ts_dollars_col_2) = $t->get_fortnightly_average();
     } else {
         unset($_FORM["showHours"]);
     }
     // A header row
     $summary .= person::get_list_tr_header($_FORM);
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     if (is_array($filter2) && count($filter2)) {
         unset($filter["skill"]);
         $filter .= " AND " . implode(" OR ", $filter2);
     }
     $q = "SELECT person.*\n            FROM person\n       LEFT JOIN proficiency ON person.personID = proficiency.personID\n           " . $filter . "\n        GROUP BY username\n        ORDER BY firstName,surname,username";
     $debug and print "Query: " . $q;
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $p = new person();
         if (!$p->read_db_record($db)) {
             continue;
         }
         $row = $p->perm_cleanup($row);
         // this is not the right way to do this - alla
         $print = true;
         $_FORM["showHours"] and $row["hoursSum"] = $ts_hrs_col_1[$row["personID"]];
         $_FORM["showHours"] and $row["hoursAvg"] = $ts_hrs_col_2[$row["personID"]];
         $row["name"] = $p->get_name();
         $row["name_link"] = $p->get_link($_FORM);
         $row["personActive_label"] = $p->get_value("personActive") == 1 ? "Y" : "";
         if ($_FORM["showSkills"]) {
             $senior_skills = $p->get_skills('Senior');
             $advanced_skills = $p->get_skills('Advanced');
             $intermediate_skills = $p->get_skills('Intermediate');
             $junior_skills = $p->get_skills('Junior');
             $novice_skills = $p->get_skills('Novice');
             $skills = array();
             $senior_skills and $skills[] = "<img src=\"../images/skill_senior.png\" alt=\"Senior=\"> " . page::htmlentities($senior_skills);
             $advanced_skills and $skills[] = "<img src=\"../images/skill_advanced.png\" alt=\"Advanced=\"> " . page::htmlentities($advanced_skills);
             $intermediate_skills and $skills[] = "<img src=\"../images/skill_intermediate.png\" alt=\"Intermediate=\"> " . page::htmlentities($intermediate_skills);
             $junior_skills and $skills[] = "<img src=\"../images/skill_junior.png\" alt=\"Junior=\"> " . page::htmlentities($junior_skills);
             $novice_skills and $skills[] = "<img src=\"../images/skill_novice.png\" alt=\"Novice\"> " . page::htmlentities($novice_skills);
             $row["skills_list"] = implode("<br>", $skills);
         }
         if ($_FORM["showLinks"]) {
             $row["navLinks"] = '<a href="' . $TPL["url_alloc_taskList"] . 'personID=' . $row["personID"] . '&taskView=byProject&applyFilter=1';
             $row["navLinks"] .= '&dontSave=1&taskStatus=open&projectType=Current">Tasks</a>&nbsp;&nbsp;';
             has("project") and $row["navLinks"] .= '<a href="' . $TPL["url_alloc_personGraph"] . 'personID=' . $row["personID"] . '">Graph</a>&nbsp;&nbsp;';
             $row["navLinks"] .= '<a href="' . $TPL["url_alloc_taskCalendar"] . 'personID=' . $row["personID"] . '">Calendar</a>&nbsp;&nbsp;';
             $dateFrom = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 28, date("Y")));
             $dateTo = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
             $row["navLinks"] .= '<a href="' . $TPL["url_alloc_timeSheetGraph"] . 'personID=' . $row["personID"] . '&dateFrom=' . $dateFrom . '&dateTo=' . $dateTo . '&applyFilter=1&dontSave=1">Hours</a>';
         }
         $summary .= person::get_list_tr($row, $_FORM);
         $rows[$row["personID"]] = $row;
     }
     $rows or $rows = array();
     if ($print && $_FORM["return"] == "array") {
         return $rows;
     } else {
         if ($print && $_FORM["return"] == "html") {
             return "<table class=\"list sortable\">" . $summary . "</table>";
         } else {
             if (!$print && $_FORM["return"] == "html") {
                 return "<table style=\"width:100%\"><tr><td colspan=\"10\" style=\"text-align:center\"><b>No People Found</b></td></tr></table>";
             }
         }
     }
 }