Beispiel #1
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // only teamMembers & observers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             $weekid = isset($_POST['weekid']) ? $_POST['weekid'] : date('W');
             $year = isset($_POST['year']) ? $_POST['year'] : date('Y');
             $this->smartyHelper->assign('weeks', SmartyTools::getWeeks($weekid, $year));
             $this->smartyHelper->assign('years', SmartyTools::getYears($year, 2));
             if ('computeCsvWeekly' == $_POST['action']) {
                 $formatedteamName = TeamCache::getInstance()->getTeam($this->teamid)->getName();
                 $weekDates = Tools::week_dates($weekid, $year);
                 $startTimestamp = $weekDates[1];
                 $endTimestamp = mktime(23, 59, 59, date("m", $weekDates[5]), date("d", $weekDates[5]), date("Y", $weekDates[5]));
                 $reports = "";
                 $managedIssuesfile = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports' . DIRECTORY_SEPARATOR . $formatedteamName . "_Mantis_" . Tools::formatDate("%Y%m%d", time()) . ".csv";
                 $managedIssuesfile = ExportCsvTools::exportManagedIssuesToCSV($this->teamid, $startTimestamp, $endTimestamp, $managedIssuesfile);
                 $reports[] = array('file' => basename($managedIssuesfile), 'title' => T_('Export Managed Issues'), 'subtitle' => T_('Issues form Team projects, including issues assigned to other teams'));
                 $timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid);
                 $weekActivityReportfile = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports' . DIRECTORY_SEPARATOR . $formatedteamName . "_CRA_" . Tools::formatDate("%Y_W%W", $startTimestamp) . ".csv";
                 $weekActivityReportfile = $this->exportWeekActivityReportToCSV($this->teamid, $weekDates, $timeTracking, $weekActivityReportfile);
                 $reports[] = array('file' => basename($weekActivityReportfile), 'title' => T_('Export Week') . ' ' . $weekid . ' ' . T_('Member Activity'));
                 $projectActivityFile = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports' . DIRECTORY_SEPARATOR . $formatedteamName . "_projects_" . Tools::formatDate("%Y_W%W", $startTimestamp) . ".csv";
                 $projectActivityFile = $this->exportProjectActivityToCSV($timeTracking, $projectActivityFile);
                 $reports[] = array('file' => basename($projectActivityFile), 'title' => T_('Export Week') . ' ' . $weekid . ' ' . T_('Projects Activity'));
                 $this->smartyHelper->assign('reports', $reports);
                 $monthsReport = "";
                 // reduce scope to enhance speed
                 $monthsLineReport = "";
                 $startMonth = 1;
                 for ($i = $startMonth; $i <= 12; $i++) {
                     $myFile = ExportCsvTools::exportHolidaystoCSV($i, $year, $this->teamid, $formatedteamName, Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports');
                     $monthsLineReport[] = array('file' => basename($myFile));
                 }
                 $monthsReport['title'] = T_('Export Holidays') . ' ' . $year;
                 $monthsReport['line'] = $monthsLineReport;
                 $this->smartyHelper->assign('monthsReport', $monthsReport);
                 $this->smartyHelper->assign('reportsDir', Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports');
             }
         }
     }
 }
Beispiel #2
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // only teamMembers & observers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             $team = TeamCache::getInstance()->getTeam($this->teamid);
             $formatedteamName = str_replace(" ", "_", $team->getName());
             // dates
             $month = date('m');
             $year = date('Y');
             // The first day of the current month
             $startdate = Tools::getSecurePOSTStringValue("startdate", Tools::formatDate("%Y-%m-%d", mktime(0, 0, 0, $month, 1, $year)));
             $this->smartyHelper->assign('startDate', $startdate);
             $startTimestamp = Tools::date2timestamp($startdate);
             // The current date plus one year
             $nbDaysInMonth = date("t", mktime(0, 0, 0, $month, 1, $year));
             $enddate = Tools::getSecurePOSTStringValue("enddate", Tools::formatDate("%Y-%m-%d", mktime(23, 59, 59, $month, $nbDaysInMonth, $year)));
             $this->smartyHelper->assign('endDate', $enddate);
             $endTimestamp = Tools::date2timestamp($enddate);
             $endTimestamp += 24 * 60 * 60 - 1;
             // + 1 day -1 sec.
             if ('computeCsvMonthly' == $_POST['action']) {
                 $timeTracking = new TimeTracking($startTimestamp, $endTimestamp, $this->teamid);
                 $myFile = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports' . DIRECTORY_SEPARATOR . $formatedteamName . "_Mantis_" . date("Ymd") . ".csv";
                 ExportCsvTools::exportManagedIssuesToCSV($this->teamid, $startTimestamp, $endTimestamp, $myFile);
                 $this->smartyHelper->assign('managedIssuesToCSV', basename($myFile));
                 $myFile = Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports' . DIRECTORY_SEPARATOR . $formatedteamName . "_Projects_" . date("Ymd", $timeTracking->getStartTimestamp()) . "-" . date("Ymd", $timeTracking->getEndTimestamp()) . ".csv";
                 $this->exportProjectMonthlyActivityToCSV($timeTracking, $myFile);
                 $this->smartyHelper->assign('projectMonthlyActivityToCSV', basename($myFile));
                 // reduce scope to enhance speed
                 $reports = array();
                 for ($i = 1; $i <= 12; $i++) {
                     $reports[] = basename(ExportCsvTools::exportHolidaystoCSV($i, $year, $this->teamid, $formatedteamName, Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports'));
                 }
                 $this->smartyHelper->assign('reports', $reports);
                 $this->smartyHelper->assign('reportsDir', Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports');
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Initialize complex static variables
  * @static
  */
 public static function staticInit()
 {
     self::$logger = Logger::getLogger(__CLASS__);
 }