/** * @param int $week * @param string $start * @param string $end * @param bool $separate_closed * @return string * @access protected * @deprecated use getWeeklyReportData() and format data yourself */ public function getWeeklyReport($week, $start, $end, $separate_closed) { $usr_id = Auth::getUserID(); $week = abs($week); // we have to set a project so the template class works, even though the weekly report doesn't actually need it $projects = Project::getAssocList(Auth::getUserID()); $prj_id = current(array_keys($projects)); AuthCookie::setProjectCookie($prj_id); $prj_id = Auth::getCurrentProject(); // figure out the correct week if (empty($start) || empty($end)) { $start = date('U') - Date_Helper::DAY * (date('w') - 1); if ($week > 0) { $start = $start - Date_Helper::WEEK * $week; } $end = date('Y-m-d', $start + Date_Helper::DAY * 6); $start = date('Y-m-d', $start); } if ($separate_closed) { // emulate smarty value for reports/weekly_data.tpl.tmpl: // {if $smarty.post.separate_closed == 1} $_POST['separate_closed'] = true; } $options = array('separate_closed' => $separate_closed); $tpl = new Template_Helper(); $tpl->setTemplate('reports/weekly_data.tpl.html'); $tpl->assign(array('report_type' => 'weekly', 'data' => Report::getWeeklyReport($usr_id, $prj_id, $start, $end, $options))); $ret = $tpl->getTemplateContents() . "\n"; return $ret; }
} $prj_id = Auth::getCurrentProject(); if (count(@$HTTP_POST_VARS["start"]) > 0 && @$HTTP_POST_VARS["start"]["Year"] != 0 && @$HTTP_POST_VARS["start"]["Month"] != 0 && @$HTTP_POST_VARS["start"]["Day"] != 0) { $start_date = join("-", $HTTP_POST_VARS["start"]); } if (count(@$HTTP_POST_VARS["end"]) > 0 && @$HTTP_POST_VARS["end"]["Year"] != 0 && @$HTTP_POST_VARS["end"]["Month"] != 0 && @$HTTP_POST_VARS["end"]["Day"] != 0) { $end_date = join("-", $HTTP_POST_VARS["end"]); } $tpl->assign(array("weeks" => Date_API::getWeekOptions(3, 0), "users" => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), "start_date" => @$start_date, "end_date" => @$end_date, "report_type" => @$HTTP_POST_VARS["report_type"])); if (!empty($HTTP_POST_VARS["developer"])) { //split date up if (@$HTTP_POST_VARS["report_type"] == "weekly") { $dates = explode("_", $HTTP_POST_VARS["week"]); } else { $dates = array($start_date, $end_date); } // print out emails $data = Report::getWeeklyReport($HTTP_POST_VARS["developer"], $dates[0], $dates[1], @$_REQUEST['separate_closed']); $tpl->assign("data", $data); } if (empty($HTTP_POST_VARS["week"])) { $tpl->assign("week", Date_API::getCurrentWeek()); } else { $tpl->assign("week", $HTTP_POST_VARS["week"]); } if (empty($HTTP_POST_VARS["developer"])) { $tpl->assign("developer", Auth::getUserID()); } else { $tpl->assign("developer", $HTTP_POST_VARS["developer"]); } $tpl->displayTemplate();
} elseif (!empty($_GET['end_date'])) { $end_date = $_GET['end_date']; } $tpl->assign(array('weeks' => Date_Helper::getWeekOptions(3, 0), 'users' => Project::getUserAssocList($prj_id, 'active', User::ROLE_CUSTOMER), 'start_date' => @$start_date, 'end_date' => @$end_date, 'report_type' => @$_REQUEST['report_type'])); if (!empty($_REQUEST['developer'])) { //split date up if (@$_REQUEST['report_type'] == 'weekly') { $dates = explode('_', $_REQUEST['week']); } else { $dates = array($start_date, $end_date); } // print out emails $developer = $_REQUEST['developer']; $prj_id = Auth::getCurrentProject(); $options = array('separate_closed' => @$_REQUEST['separate_closed'], 'separate_not_assigned_to_user' => @$_REQUEST['separate_not_assigned_to_user'], 'ignore_statuses' => @$_REQUEST['ignore_statuses'], 'show_per_issue' => !empty($_REQUEST['show_per_issue']), 'separate_no_time' => !empty($_REQUEST['separate_no_time'])); $data = Report::getWeeklyReport($developer, $prj_id, $dates[0], $dates[1], $options); // order issues by time spent on them if (isset($_REQUEST['show_per_issue'])) { $sort_function = function ($a, $b) { if ($a['it_spent'] == $b['it_spent']) { return 0; } return $a['it_spent'] < $b['it_spent'] ? 1 : -1; }; usort($data['issues']['closed'], $sort_function); usort($data['issues']['other'], $sort_function); usort($data['issues']['not_mine'], $sort_function); } $tpl->assign('data', $data); } if (empty($_REQUEST['week'])) {
function getWeeklyReport($p) { $email = XML_RPC_decode($p->getParam(0)); $password = XML_RPC_decode($p->getParam(1)); $auth = authenticate($email, $password); if (is_object($auth)) { return $auth; } $week = abs(XML_RPC_decode($p->getParam(2))); $start = XML_RPC_decode($p->getParam(3)); $end = XML_RPC_decode($p->getParam(4)); // we have to set a project so the template class works, even though the weekly report doesn't actually need it $projects = Project::getAssocList(Auth::getUserID()); createFakeCookie($email, current(array_keys($projects))); // figure out the correct week if (empty($start) || empty($end)) { $start = date("U") - DAY * (date("w") - 1); if ($week > 0) { $start = $start - WEEK * $week; } $end = date("Y-m-d", $start + DAY * 6); $start = date("Y-m-d", $start); } $tpl = new Template_API(); $tpl->setTemplate("reports/weekly_data.tpl.html"); $tpl->assign("data", Report::getWeeklyReport(User::getUserIDByEmail($email), $start, $end)); $ret = $tpl->getTemplateContents() . "\n"; return new XML_RPC_Response(XML_RPC_Encode(base64_encode($ret))); }