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"]; }