report_user_per_group.php

Go to the documentation of this file.
00001 <?php
00002 
00003 if ( !class_exists( "report_user_per_group")) {
00007     class Report_user_per_group extends report_base
00008     {
00014         protected $_sThisTemplate = "report_user_per_group.tpl";
00015 
00021         public function user_per_group()
00022         {
00023             $myConfig = $this->getConfig();
00024             global $aTitles;
00025 
00026             $aDataX = array();
00027             $aDataY = array();
00028 
00029             $sTime_from = date( "Y-m-d H:i:s", strtotime( oxConfig::getParameter( "time_from")));
00030             $sTime_to   = date( "Y-m-d H:i:s", strtotime( oxConfig::getParameter( "time_to")));
00031 
00032             $sSQL = "SELECT oxgroups.oxtitle,
00033                             count(oxuser.oxid)
00034                      FROM oxobject2group,
00035                           oxuser,
00036                           oxgroups
00037                      WHERE oxobject2group.oxobjectid = oxuser.oxid  AND
00038                            oxobject2group.oxgroupsid = oxgroups.oxid
00039                      GROUP BY oxobject2group.oxgroupsid
00040                      ORDER BY oxobject2group.oxgroupsid";
00041 
00042             $rs = oxDb::getDb()->execute( $sSQL);
00043             if ($rs != false && $rs->recordCount() > 0) {
00044                 while (!$rs->EOF) {
00045                     if ( $rs->fields[1]) {
00046                         $aDataX[] = $rs->fields[1];
00047                         $aDataY[] = $rs->fields[0];
00048                     }
00049                     $rs->moveNext();
00050                 }
00051             }
00052 
00053             header ("Content-type: image/png" );
00054 
00055             // New graph with a drop shadow
00056             if (count($aDataX) > 10)
00057                 $graph = new PieGraph(800, 830);
00058             else
00059                 $graph = new PieGraph(600, 600);
00060 
00061             $graph->setBackgroundImage( $myConfig->getAbsAdminImageDir()."/reportbgrnd.jpg", BGIMG_FILLFRAME);
00062             $graph->setShadow();
00063 
00064             // Set title and subtitle
00065             //$graph->title->set($this->aTitles[$myConfig->getConfigParam( 'iAdminLanguage' ) ]);
00066             $graph->title->set($this->aTitles[oxLang::getInstance()->getTplLanguage() ]);
00067 
00068             // Use built in font
00069             $graph->title->setFont(FF_FONT1, FS_BOLD);
00070 
00071             // Create the bar plot
00072             $bplot = new PiePlot3D($aDataX);
00073 
00074             $bplot->setSize(0.4);
00075             $bplot->setCenter(0.5, 0.32);
00076 
00077             // explodes all chunks of Pie from center point
00078             $bplot->explodeAll(10);
00079             $iUserCount = 0;
00080             foreach ($aDataX as $iVal)
00081                 $iUserCount += $iVal;
00082             for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
00083                 $iSLeng = strlen($aDataY[$iCtr]);
00084                 if ($iSLeng > 20) {
00085                     if ($iSLeng > 23)
00086                         $aDataY[$iCtr] = trim(substr($aDataY[$iCtr], 0, 20))."...";
00087 
00088                 }
00089                 $aDataY[$iCtr] .= " - ".$aDataX[$iCtr]." Kund.";
00090             }
00091             $bplot->setLegends($aDataY);
00092 
00093             if (count($aDataX) > 10) {
00094                 $graph->legend->pos(0.49, 0.66, 'center');
00095                 $graph->legend->setFont(FF_FONT0, FS_NORMAL);
00096                 $graph->legend->setColumns(4);
00097             } else {
00098                 $graph->legend->pos(0.49, 0.70, 'center');
00099                 $graph->legend->setFont(FF_FONT1, FS_NORMAL);
00100                 $graph->legend->setColumns(2);
00101             }
00102 
00103             $graph->add($bplot);
00104 
00105             // Finally output the  image
00106             $graph->stroke();
00107         }
00108     }
00109 }

Generated on Tue Apr 21 15:45:44 2009 for OXID eShop CE by  doxygen 1.5.5