Location: PHPKode > projects > Phpgw Time Tracking Add On App > timetrack/detail_report2.php
<?php
  /**************************************************************************\
  * phpgwtimetrack - phpGroupWare addon application                          *
  * http://phpgwtimetrack.sourceforge.net                                    *
  * Written by Robert Schader <hide@address.com>                         *
  * --------------------------------------------                             *
  *  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.                                              *
  \**************************************************************************/
 
  /* $Id: detail_report2.php,v 1.3 2001/01/08 21:29:07 rschader Exp $ */
  $plain_text_report = 1;
  if($plain_text_report) {
   $phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
  }

  $phpgw_info["flags"]["enable_nextmatchs_class"] = "True";
  $phpgw_info["flags"]["currentapp"] = "timetrack";
  include("../header.inc.php");

  if ($error) {
     echo "<center>" . lang("Error") . ":$error</center>";
  }

  if(! $startdate) $startdate = "0000-00-00";
  if(! $enddate) $enddate = "9999-00-00";

  // Testing:
  //echo "<center>job_id=$job_id, startdate=$startdate, enddate=$enddate<br></center>";

  // This will be the report generator for all timesheet activity, sorted by user then date,
  // then work catagory.
  if(! $plain_text_report) {
    echo "<h2><center>Employee Activity Report from $startdate to $enddate</center></h2>";
  } else {
    echo "<PRE>";
  }

    $phpgw->db->query("select jd.detail_id,jd.job_id,jd.work_catagory_id,jd.work_date,"
      . "jd.num_hours,jd.comments,c.company_name,j.job_number,j.job_revision,j.summary,j.description,"
      . "js.status_name,a.account_firstname,a.account_lastname,w.catagory_desc "
      . "from job_details as jd "
      . "left join jobs as j on jd.job_id = j.job_id "
      . "left join customers as c on j.company_id = c.company_id "
      . "left join accounts as a on jd.account_id = a.account_id "
      . "left join work_catagories as w on jd.work_catagory_id = w.work_catagory_id "
      . "left join job_status as js on j.status_id = js.status_id "
      . "WHERE jd.work_date >= '$startdate' AND jd.work_date <= '$enddate' "
      . "ORDER BY a.account_lastname,jd.work_date,c.company_name,j.job_number,j.job_revision,jd.work_catagory_id "
      . "asc");

while($phpgw->db->next_record()){
  $company_name = $phpgw->db->f("company_name");
  $job_number = $phpgw->db->f("job_number");
  $job_revision = $phpgw->db->f("job_revision");
  $description = $phpgw->db->f("description");
  $status_name = $phpgw->db->f("status_name");
  $summary = $phpgw->db->f("summary");
  $employee = $phpgw->db->f("account_lastname")
    . ", " . $phpgw->db->f("account_firstname");
  $wdate = $phpgw->db->f("work_date");
  $wcat = $phpgw->db->f("catagory_desc");
  $nhours = $phpgw->db->f("num_hours");
  $comments = $phpgw->db->f("comments");

  // If we want to print a comma separated list for Excel import, we can fread a flag
  // here and simply loop thru all the entries, printing them out.
  if($plain_text_report)
  {
   echo "\"$employee\",";
   echo "\"$company_name\",";
   echo "\"$job_number\",";
   echo "\"$job_revision\",";
   echo "\"$summary\",";
   echo "\"$wdate\",";
   echo "\"$wcat\",";
   echo "\"$nhours\"\n";
  } else {
    // set these if blank after plain text report
    if($comments == "") $comments = "&nbsp;";
    if($description == "") $description = "&nbsp;";
    ?>
    <br><CENTER><TABLE WIDTH=90% BORDER=0 bordercolor=FFFFFF cellspacing=2 cellpadding=2>
    <TR>
    <?php
    echo '<TH WIDTH=20% BGCOLOR="' . $phpgw_info["theme"]["th_bg"] 
      . '"><FONT COLOR="#000000">Company</FONT></TH>';
    echo '<TH WIDTH=10% BGCOLOR="' . $phpgw_info["theme"]["th_bg"] 
      . '"><FONT COLOR="#000000">Job No.</FONT></TH>';
    echo '<TH WIDTH=60% BGCOLOR="' . $phpgw_info["theme"]["th_bg"] 
      . '"><FONT COLOR="#000000">Description</FONT></TH>';
    echo '<TH WIDTH=10% BGCOLOR="' . $phpgw_info["theme"]["th_bg"] 
      . '"><FONT COLOR="#000000">Status</FONT></TH>';
    echo '</TR>';
    $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
    echo '<tr>';
    echo ' <td width="20%" bgcolor="' . $tr_color . '">' . " "
      . $company_name . '</td>';
    echo ' <td width="10%" align="center" bgcolor="' . $tr_color . '">'
      . $job_number . $job_revision . '</td>';
    echo ' <td width="60%" bgcolor="' . $tr_color . '">' . " "
      . $summary . '</td>';
    echo ' <td width="10%" align="center" bgcolor="' . $tr_color . '">' . " "
      . $status_name . '</td></tr>';
    echo '<tr>';
    echo ' <td width="20%" bgcolor="' . $tr_color . '">' . " "
      . '&nbsp;</td>';
    echo ' <td width="10%" align="center" bgcolor="' . $tr_color . '">'
      . '&nbsp;</td>';
    echo ' <td width="60%" bgcolor="' . $tr_color . '">' . " "
      . $description . '</td>';
    echo ' <td width="10%" align="center" bgcolor="' . $tr_color . '">' . " "
      . '&nbsp;</td></tr>';
    echo '</tr>';
    //echo '</table>';

    $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
    echo '<tr>';
    echo ' <td width="12%" align="center" bgcolor="' . $tr_color . '">' . " "
      . $wdate . '</td>';
    echo ' <td width="20%" align="center" bgcolor="' . $tr_color . '">'
      . $employee . '</td>';
    echo ' <td width="56%" bgcolor="' . $tr_color . '">' . " "
      . $wcat . '</td>';
    echo ' <td width="12%" align="center" bgcolor="' . $tr_color . '">' . " "
      . $nhours . '</td>';
    echo '<tr>';
    echo ' <td width="12%" bgcolor="' . $tr_color . '">' . " "
      . '&nbsp;</td>';
    echo ' <td width="20%" align="center" bgcolor="' . $tr_color . '">'
      . '&nbsp;</td>';
    echo ' <td width="56%" bgcolor="' . $tr_color . '">' . " "
      . $comments . '</td>';
    echo ' <td width="12%" align="center" bgcolor="' . $tr_color . '">' . " "
      . '&nbsp;</td></tr>';
    echo '</tr>';
  } //end else plain_text_report
  //echo '</table>';
 } // end while nextrecord.
if($plain_text_report){
 echo "</PRE>";
} else {
 $phpgw->common->phpgw_footer();
}
Return current item: Phpgw Time Tracking Add On App