Changeset - 8985d9de9faa
[Not reviewed]
default
0 2 0
ethanzonca - 15 years ago 2010-12-24 01:10:21

Crude statistics from the past month now work properly
2 files changed with 18 insertions and 14 deletions:
0 comments (0 inline, 0 general)
inc/class.graph.php
Show inline comments
 
@@ -56,9 +56,13 @@ public function __construct($userVals, $
 

	
 
    $label = $this->values[$i]['label'];
 
    $font = '/usr/share/fonts/liberation/LiberationSans-Regular.ttf';
 
    $font2 = '/usr/share/fonts/liberation/LiberationSans-Bold.ttf';
 

	
 
    imagettftext($im, 10, 0, $x1 + ($column_width / 2) - 20, $height - 5, $black, $font, $label);
 
    imagettftext($im, 7, 0, $x1 + ($column_width / 2) - 7, $height - 20, $gray_dark, $font, $this->values[$i]['count']);
 
 
 
  }
 
  imagettftext($im, 10, 0, 0, 10, $black, $font2, "Past Month:");
 

	
 
  // Send the PNG header information. Replace for JPEG or GIF or whatever
 
  $this->image = $im;
statsGraph.php
Show inline comments
 
@@ -5,39 +5,39 @@
 
  // Make array of values
 
  $arr = array();
 

	
 
  // @TODO - pull in isBeforeDate from admin library, create isAfterDate (!isBeforeDate)
 

	
 
  $startDate = "0";
 
  $stopDate = "99999999999999999999";
 
  $startDate = strtotime("-1 month");
 
  $stopDate = time(); // now
 
  $dir = 'saved_schedules/';
 
  // Do this the new fun php5 OO-way
 
  foreach(new DirectoryIterator($dir) as $key => $file) {
 
    if(is_numeric($file->getFilename())){
 
      $uctime = $file->getCTime();
 
      $ctime = date("m/d/Y",$uctime);
 
      $ctime = strtotime($ctime); // Results in a day-specific unix timestamp
 
      $uCtime = $file->getCTime();
 
      $strCtime = date("m/d/Y",$uCtime);
 
      $ctime = strtotime($strCtime); // Results in a day-specific unix timestamp
 

	
 
      if($ctime < $stopDate && $ctime > $startDate) {
 
        $currDate = $file->getCTime();
 
        if(!isset($arr[$currDate])) {
 
          $arr[$currDate] = 1;
 
        if(!isset($arr[$ctime])) {
 
          $arr[$ctime] = 1;
 
        }
 
        else { 
 
          $arr[$currDate]++;
 
          $arr[$ctime]++;
 
        }
 
      }
 
    }
 
  }
 

	
 

	
 
  $gphArr = array();
 
  $i = 0;
 
  foreach($arr as $index => $item) {
 
    $gphArr[$i]['count'] = $item;
 
    $gphArr[$i]['label'] = date("j/n", $index);
 
    $gphArr[$i]['label'] = date("n/j", $index);
 
    $i++;
 
  }
 
//echo "<pre>";
 
//  print_r($gphArr); 
 
/*
 
echo "<pre>";
 
  print_r($arr);
 
  print_r($gphArr);  */
 
  // Graph array
 
  $myGraph = new barGraph($gphArr, 900, 100);
 
?>
0 comments (0 inline, 0 general)