[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/reports/ -> weekly.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */
   3  // +----------------------------------------------------------------------+
   4  // | Eventum - Issue Tracking System                                      |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 2003, 2004, 2005, 2006, 2007 MySQL AB                              |
   7  // |                                                                      |
   8  // | This program is free software; you can redistribute it and/or modify |
   9  // | it under the terms of the GNU General Public License as published by |
  10  // | the Free Software Foundation; either version 2 of the License, or    |
  11  // | (at your option) any later version.                                  |
  12  // |                                                                      |
  13  // | This program is distributed in the hope that it will be useful,      |
  14  // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  15  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
  16  // | GNU General Public License for more details.                         |
  17  // |                                                                      |
  18  // | You should have received a copy of the GNU General Public License    |
  19  // | along with this program; if not, write to:                           |
  20  // |                                                                      |
  21  // | Free Software Foundation, Inc.                                       |
  22  // | 59 Temple Place - Suite 330                                          |
  23  // | Boston, MA 02111-1307, USA.                                          |
  24  // +----------------------------------------------------------------------+
  25  // | Authors: Bryan Alsdorf <bryan@mysql.com>                             |
  26  // +----------------------------------------------------------------------+
  27  //
  28  require_once(dirname(__FILE__) . "/../init.php");
  29  require_once (APP_INC_PATH . "class.template.php");
  30  require_once (APP_INC_PATH . "class.auth.php");
  31  require_once (APP_INC_PATH . "class.report.php");
  32  require_once (APP_INC_PATH . "class.date.php");
  33  require_once (APP_INC_PATH . "db_access.php");
  34  
  35  $tpl = new Template_API();
  36  $tpl->setTemplate("reports/weekly.tpl.html");
  37  
  38  Auth::checkAuthentication(APP_COOKIE);
  39  
  40  if (Auth::getCurrentRole() <= User::getRoleID("Customer")) {
  41      echo "Invalid role";
  42      exit;
  43  }
  44  
  45  $prj_id = Auth::getCurrentProject();
  46  
  47  if (count(@$_POST["start"]) > 0 &&
  48          (@$_POST["start"]["Year"] != 0) &&
  49          (@$_POST["start"]["Month"] != 0) &&
  50          (@$_POST["start"]["Day"] != 0)) {
  51      $start_date = join("-", $_POST["start"]);
  52  }
  53  if (count(@$_POST["end"]) > 0 &&
  54          (@$_POST["end"]["Year"] != 0) &&
  55          (@$_POST["end"]["Month"] != 0) &&
  56          (@$_POST["end"]["Day"] != 0)) {
  57      $end_date = join("-", $_POST["end"]);
  58  }
  59  
  60  $tpl->assign(array(
  61      "weeks" => Date_API::getWeekOptions(3,0),
  62      "users" => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')),
  63      "start_date"    =>  @$start_date,
  64      "end_date"      =>  @$end_date,
  65      "report_type"   =>  @$_POST["report_type"]
  66  ));
  67  
  68  if (!empty($_POST["developer"])) {
  69  
  70      //split date up
  71      if (@$_POST["report_type"] == "weekly") {
  72          $dates = explode("_", $_POST["week"]);
  73      } else {
  74          $dates = array($start_date, $end_date);
  75      }
  76  
  77      // print out emails
  78      $data = Report::getWeeklyReport($_POST["developer"], $dates[0], $dates[1], @$_REQUEST['separate_closed'], @$_REQUEST['ignore_statuses']);
  79      // order issues by time spent on them
  80      if (isset($_POST['show_per_issue'])) {
  81          $sort_function = create_function('$a,$b', 'if ($a["it_spent"] == $b["it_spent"]) {return 0;} return ($a["it_spent"] < $b["it_spent"]) ? 1 : -1;');
  82          @usort($data['issues']['closed'], $sort_function);
  83          @usort($data['issues']['other'], $sort_function);
  84      }
  85      $tpl->assign("data", $data);
  86  }
  87  
  88  if (empty($_POST["week"])) {
  89      $tpl->assign("week", Date_API::getCurrentWeek());
  90  } else {
  91      $tpl->assign("week", $_POST["week"]);
  92  }
  93  if (empty($_POST["developer"])) {
  94      $tpl->assign("developer", Auth::getUserID());
  95  } else {
  96      $tpl->assign("developer", $_POST["developer"]);
  97  }
  98  
  99  $tpl->displayTemplate();


Generated: Wed Dec 19 21:21:33 2007 Cross-referenced by PHPXref 0.7