PHP
  Home arrow PHP arrow Page 7 - Time Is Money (part 2)
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Time Is Money (part 2)
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2001-11-16

    Table of Contents:
  • Time Is Money (part 2)
  • Getting Creative
  • Split Personality
  • In...
  • ...And Out
  • The Number Game
  • Exercising Restraint
  • The Big Picture...
  • ...And The Little Brush Strokes
  • When Things Go Wrong
  • Happy Endings

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Time Is Money (part 2) - Exercising Restraint


    (Page 7 of 11 )

    No, I didn't really do that - I still need a paycheck. But every dog has his day, and mine will come soon...

    Anyway, disturbing though that conversation was, I still managed to get some useful data from it. I can now state with certainty that the system should generate the following three types of reports:

    a big-picture overview of the time spent by users on all active projects for a specific period of time,

    a big-picture overview of the time spent on different tasks over a specific period of time;

    a focused report of time spent by different users on the different components of a project for a specific period.

    With this in mind, let's quickly review the code for the report generation menu item in "menu.php"

    <!-- menu.php --> <li> <!-- generate report option --> <form name="report" action="report.php" method="post"> <a href="javascript:submitForm(1)">Generate activity reports</a> between <? generateDateSelector("s"); ?> and <? generateDateSelector("e"); ?> for <select name="pid"> <option value="0">&lt;all projects&gt;</option> <? // open connection to database $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); // get project list $query = "SELECT pid, pname from projects"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); while (list($pid, $pname) = mysql_fetch_row($result)) { echo "<option value=$pid>$pname</option>"; } mysql_free_result($result); ?> </select> </form> <p> <? } ?>
    This has all the data I need to build any of the three report types - a starting date (created from the date variables $sd, $sm and $sy), an ending date (created from the date variables $ed, $em and $ey) and a project identifier (which may be 0 for "all projects"). When this form is submitted, it sends these variables to the script "report.php", which performs the actual report generation.

    If you look at "report.php", you'll see that it's basically one gigantic "if" loop - the first part generates big-picture type reports, while the second part generates more specific reports.

    <? // report.php - generate reports // includes // check for valid session and valid administrator // check for valid dates if (!checkdate($sm, $sd, $sy) || !checkdate($em, $ed, $ey)) { header("Location: error.php?ec=2"); exit; } // open connection to database $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); // create start and end datestamp $sdate = $sy . "-" . $sm . "-" . $sd; $edate = $ey . "-" . $em . "-" . $ed; ?> <? // main "if" loop begins // if report required for ALL projects if ($pid == 0) { // code goes here } // report required for a specific project else { // code goes here snip! } // main "if" loop done - now clean up and print page footer mysql_close($connection); ?> <? include("footer.inc.php"); ?> </body> </html>
    Let's write some code for the general report first - once that's done, writing code to build a report for a specific project should be a piece of cake.

    More PHP Articles
    More By The Disenchanted Developer, (c) Melonfire


     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway