コード例 #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 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);
 }
コード例 #3
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"];
}
コード例 #4
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);
 }