Location: PHPKode > projects > NetOffice > netoffice/reports/hours.php
<?php // $Revision: 1.17 $
/* vim: set expandtab ts=4 sw=4 sts=4: */

/**
 * $Id: hours.php,v 1.17 2004/01/18 20:55:09 madbear Exp $
 * 
 * Copyright (c) 2003 by the NetOffice developers
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * ../reports/hours.php
 * 
 * show hours logged
 * 
 * TODO: add month/year selection
 *        enable sorting
 */
// configuration options
// set up the member selection
if ($HTTP_POST_VARS['S_ATSEL']) {
    if ($HTTP_POST_VARS['S_ATSEL'] == 'ALL') {
        $S_mem = "ALL";
    } else {
        $S_mem = implode (',', $HTTP_POST_VARS['S_ATSEL']);
    } 
} else {
    $S_mem = "ALL";
} 
// a date range was selected
if ($HTTP_POST_VARS{'S_COMPLETEDATE'} == 'DATERANGE') {
    $dateRange = true; 
    // get the range start date (if given)
    if ($HTTP_POST_VARS{'S_SDATE2'}) {
        $s_sdate2 = $HTTP_POST_VARS{'S_SDATE2'};
    } else {
        $s_sdate2 = date("Y-m-d",
            mktime (0, 0, 0, date("m"), "1", date("Y")));
    } 
    // get the range end date
    if ($HTTP_POST_VARS{'S_EDATE2'}) {
        $s_edate2 = $HTTP_POST_VARS{'S_EDATE2'};
    } else {
        $s_edate2 = date("Y-m-d",
            mktime (0, 0, 0, date("m"), date("d"), date("Y")));
    } 
} else {
    // select all dates
    $dateRange = false;
} 
// end of configuration
$checkSession = true;
require_once("../includes/library.php");

require_once("../themes/" . THEME . "/header.php");

$blockPage = new block();
$blockPage->openBreadcrumbs();
$blockPage->itemBreadcrumbs($strings['reports']);
$blockPage->itemBreadcrumbs($blockPage->buildLink('../reports/createreport.php?typeReports=create', $strings["create_report"], in) . ' | ' . $blockPage->buildLink('../reports/createreport.php?typeReports=custom', $strings['custom_reports'], in));
$blockPage->closeBreadcrumbs();

if ($msg != "") {
    require_once("../includes/messages.php");
    $blockPage->messagebox($msgLabel);
} 
// start the first block
$block1 = new block();
$block1->form = "xwbT";
$block1->openForm("../reports/hours.php#" . $block1->form . "Anchor");
$block1->openContent();
// $block1->sorting("task_time",$sortingUser->sor_tasks_time[0],"tim.org_name ASC",$sortingFields = array(0=>"tim.org_name",1=>"tim.pro_name",2=>"tim.mem_name",3=>"tim.pro_type",4=>"tim.svc_type",5=>"tim.hours"));
// $query = " WHERE tim.date like '$reportDate%' ";
// $tmpquery = "$query ORDER BY $block1->sortingValue";
// a date range was selected
if ($dateRange) {
    if ($query != "") {
        $query .= "AND (tim.date <= '$s_edate2'  AND tim.date >= '$s_sdate2')";
    } else {
        $query .= "WHERE (tim.date <= '$s_edate2'  AND tim.date >= '$s_sdate2')";
    } 
} 
// a member selection was made
if ($S_mem != 'ALL' && $S_mem != "") {
    if ($query != "") {
        $query .= " AND tim.owner IN($S_mem)";
    } else {
        $query .= "WHERE tim.owner IN($S_mem)";
    } 
} 

$tmpquery = "$query ORDER BY org.name,pro.name,mem.name,tim.date";
$listHours = new request();
$listHours->openTaskTime($tmpquery);
$comptListHours = count($listHours->tim_id);

$block0 = new block();

$block0->openContent();
$block0->contentTitle($strings["report_results"]);

if ($comptListHours == "0") {
    $block1->contentRow("", "0 " . $strings["matches"] . "<br>" . $strings["no_results_report"]);
} 

if ($comptListHours == "1") {
    $block1->contentRow("", "1 " . $strings["match"]);
} 

if ($comptListHours > "1") {
    $block1->contentRow("", $comptListHours . " " . $strings["matches"]);
} 

$block0->closeContent();

$block1->openPaletteIcon();
$block1->paletteIcon(0, "export", $strings["export"]);
$block1->closePaletteIcon();

$block1->openPaletteScript();

$exportOptions = "";
// handle date ranges
if ($dateRange) {
    if ($exportOptions != "") {
        $exportOptions = "&S_COMPLETEDATE=DATERANGE&S_SDATE2=$s_sdate2&S_EDATE2=$s_edate2";
    } else {
        $exportOptions = "S_COMPLETEDATE=DATERANGE&S_SDATE2=$s_sdate2&S_EDATE2=$s_edate2";
    } 
} 
// a member selection was made
if ($S_mem != 'ALL' && $S_mem != "") {
    if ($exportOptions != "") {
        $exportOptions .= "&S_mem=$S_mem";
    } else {
        $exportOptions .= "S_mem=$S_mem";
    } 
} 

$block1->paletteScript(0, "export", "../reports/exporthours.php?$exportOptions", "true,false,false", $strings["export"]);
$block1->closePaletteScript($comptListHours, $listHours->tim_id);
// set up the header string
$block1->heading("Hours Logged from " . $s_sdate2 . " to " . $s_edate2);
// initialize counters
$totalMemHours = 0;

if ($comptListHours != "0") {
    $block1->openResults($checkbox = "false");
    $block1->labels($labels = array(0 => $strings["organization"], 1 => $strings["project"], 2 => $strings["name"], 3 => $strings["date"], 4 => $strings["type"], 5 => $strings["service"], 6 => $strings["hours"]), "true");

    for ($i = 0;$i < $comptListHours;$i++) {
        $block1->openRow();
        $block1->checkboxRow($listHours->tim_id[$i], $checkbox = "false");
        $block1->cellRow($listHours->tim_org_name[$i]);
        $block1->cellRow($blockPage->buildLink("../projects/viewproject.php?id=" . $listHours->tim_project[$i], $listHours->tim_pro_name[$i], in));
        $block1->cellRow($listHours->tim_mem_name[$i]);
        $block1->cellRow($listHours->tim_date[$i]);
        $block1->cellRow($projectType[$listHours->tim_pro_type[$i]]); 
        // $block1->contentRow($strings["type"],$projectType[$projectDetail->pro_type[0]]);
        $block1->cellRow($listHours->tim_svc_nam[$i]);
        $block1->cellRow($listHours->tim_hours[$i]);
        $block1->closeRow(); 
        // add to total hours
        $totalMemHours += $listHours->tim_hours[$i];
    } 
    // print the totals
    $block1->openRow();
    $block1->checkboxRow($listHours->tim_id[$i], $checkbox = "false");
    $block1->cellRow("");
    $block1->cellRow("");
    $block1->cellRow("");
    $block1->cellRow("");
    $block1->cellRow("Total:");
    $block1->cellRow($totalMemHours);
    $block1->closeRow();

    $block1->closeResults();
} else {
    $block1->noresults();
} 
// close block1
$block1->closeFormResults();

require_once("../themes/" . THEME . "/footer.php");

?>
Return current item: NetOffice