report_user_per_group.php

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

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5