• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List

E:/E/GEAMP/www/openbiz/openbiz/bin/easy/element/ColumnBar.php

00001 <?php 
00002 include_once("ColumnText.php");
00003 class ColumnBar extends ColumnText
00004 {
00005     public $m_Percent;
00006     public $m_MaxValue;
00007     public $m_DisplayUnit;
00008     public $m_Color;
00009 
00010     protected function readMetaData(&$xmlArr)
00011     {
00012         parent::readMetaData($xmlArr);
00013         $this->m_Percent = isset($xmlArr["ATTRIBUTES"]["PERCENT"]) ? $xmlArr["ATTRIBUTES"]["PERCENT"] : "N";
00014         $this->m_MaxValue = isset($xmlArr["ATTRIBUTES"]["MAXVALUE"]) ? $xmlArr["ATTRIBUTES"]["MAXVALUE"] : "1";
00015         $this->m_DisplayUnit = isset($xmlArr["ATTRIBUTES"]["DISPLAYUNIT"]) ? $xmlArr["ATTRIBUTES"]["DISPLAYUNIT"] : null;
00016         $this->m_Color = isset($xmlArr["ATTRIBUTES"]["COLOR"]) ? $xmlArr["ATTRIBUTES"]["COLOR"] : null;        
00017         $this->m_cssClass = isset($xmlArr["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSCLASS"] : "column_bar";
00018         $this->m_Height = isset($xmlArr["ATTRIBUTES"]["HEIGHT"]) ? $xmlArr["ATTRIBUTES"]["HEIGHT"] : "14";
00019     }
00020 
00021     public function render(){
00022        $value = $this->m_Text ? $this->getText() : $this->m_Value;
00023        if($this->m_Color)
00024        {
00025               $formObj = $this->getFormObj();
00026               $color = Expression::evaluateExpression($this->m_Color, $formObj);                  
00027               if(!$color){
00028                      $color = '33b5fb';
00029               }
00030               $bgcolor_str = "background-color: #".$color.";";                             
00031        }else{
00032               $bgcolor_str = "background-color: #33b5fb;";
00033        }
00034        
00035        if($this->m_DisplayFormat)
00036         {
00037               $value = sprintf($this->m_DisplayFormat,$value);
00038         }
00039        if($this->m_Percent=='Y')
00040         {            
00041               $value = sprintf("%.2f",$value*100).'%';        
00042         }
00043         $style = $this->getStyle();
00044         $id = $this->m_Name;
00045         $func = $this->getFunction();
00046         $height = $this->m_Height;
00047         $width = $this->m_Width;        
00048         $max_value = Expression::evaluateExpression($this->m_MaxValue, $this->getFormObj());
00049         
00050         $width_rate = ($value/$max_value);
00051         
00052         if($width_rate>1){
00053               $width_rate=1;
00054         }
00055         $width_bar = (int)($width * $width_rate);
00056         if($width>0){
00057               $width-=2;
00058         }
00059               if(!preg_match("/MSIE 6/si",$_SERVER['HTTP_USER_AGENT'])){
00060                      $bar_overlay="<span class=\"bar_data_bg\" style=\"".$bgcolor_str."height:".$height."px;width:".$width_bar."px;\"></span>";
00061                      $bar = "<span class=\"bar_data\" style=\"".$bgcolor_str."height:".$height."px;width:".$width_bar."px;\"></span>";
00062               }else{
00063                      $bar = "<span class=\"bar_data\" style=\"".$bgcolor_str."height:".$height."px;width:".$width_bar."px;opacity: 0.4;filter: alpha(opacity=40);\"></span>";
00064               }
00065         $sHTML = "
00066        <span id=\"$id\" $func $style >
00067               
00068               <span class=\"bar_bg\" style=\"height:".$height."px;width:".$width."px;\">
00069                      
00070               $bar_overlay
00071               $bar                                      
00072               </span>
00073               <span class=\"value\">$value".$this->m_DisplayUnit."</span>
00074        </span>
00075        ";
00076        return $sHTML;
00077     }
00078    protected function getStyle()
00079     {        
00080               $formobj = $this->getFormObj();           
00081         $htmlClass = Expression::evaluateExpression($this->m_cssClass, $formobj);
00082         $htmlClass = "CLASS='$htmlClass'";
00083         if(!$htmlClass){
00084               $htmlClass = null;
00085         }
00086         $style ='';        
00087         if ($this->m_Style)
00088             $style .= $this->m_Style;
00089         if (!isset($style) && !$htmlClass)
00090             return null;
00091         if (isset($style))
00092         {
00093             
00094             $style = Expression::evaluateExpression($style, $formobj);
00095             $style = "STYLE='$style'";
00096         }
00097         if($formobj->m_Errors[$this->m_Name])
00098         {
00099            $htmlClass = "CLASS='".$this->m_cssErrorClass."'";
00100         }
00101         if ($htmlClass)
00102             $style = $htmlClass." ".$style;
00103         return $style;
00104     }    
00105 }
00106 ?>

Generated on Thu Apr 19 2012 17:09:13 for openbiz by  doxygen 1.7.2