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;
 }
示例#2
0
 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>";
             }
         }
     }
 }