コード例 #1
0
ファイル: VerticalBar.php プロジェクト: Doluci/tomatocart
 function customizeChartProperties()
 {
     parent::customizeChartProperties();
     $dataSetsToDisplay = $this->getDataSetsToDisplay();
     if ($dataSetsToDisplay === false) {
         return;
     }
     $dataSetToDisplay = current($dataSetsToDisplay);
     $this->x->set_grid_colour('#ffffff');
     $this->x_labels->set_steps(2);
     $this->x->set_stroke(1);
     // create the Bar object
     $bar = new bar_filled('#3B5AA9', '#063E7E');
     $bar->set_alpha("0.5");
     $bar->set_key($this->yLabels[$dataSetToDisplay], 12);
     $bar->set_tooltip('#val# #key#');
     // create the bar values
     $yValues = $this->yValues[$dataSetToDisplay];
     $labelName = $this->yLabels[$dataSetToDisplay];
     $unit = $this->yUnit;
     $barValues = array();
     $i = 0;
     $sum = array_sum($yValues);
     foreach ($this->xLabels as $label) {
         $value = (double) $yValues[$i];
         $displayPercentage = '';
         if ($this->displayPercentageInTooltip) {
             $percentage = round(100 * $value / $sum);
             $displayPercentage = "({$percentage}%)";
         }
         $barValue = new bar_value($value);
         $barValue->set_tooltip("{$label}<br>{$value}{$unit} {$labelName} {$displayPercentage}");
         $barValues[] = $barValue;
         $i++;
     }
     $bar->set_values($barValues);
     $this->chart->add_element($bar);
 }
コード例 #2
0
    public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
    {
        $sHtml = '';
        // Add the extra params into the filter if they make sense for such a filter
        $bDoSearch = utils::ReadParam('dosearch', false);
        if ($this->m_oSet == null) {
            $aQueryParams = array();
            if (isset($aExtraParams['query_params'])) {
                $aQueryParams = $aExtraParams['query_params'];
            }
            if ($this->m_sStyle != 'links') {
                $oAppContext = new ApplicationContext();
                $sClass = $this->m_oFilter->GetClass();
                $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($sClass));
                $aCallSpec = array($sClass, 'MapContextParam');
                if (is_callable($aCallSpec)) {
                    foreach ($oAppContext->GetNames() as $sContextParam) {
                        $sParamCode = call_user_func($aCallSpec, $sContextParam);
                        //Map context parameter to the value/filter code depending on the class
                        if (!is_null($sParamCode)) {
                            $sParamValue = $oAppContext->GetCurrentValue($sContextParam, null);
                            if (!is_null($sParamValue)) {
                                $aExtraParams[$sParamCode] = $sParamValue;
                            }
                        }
                    }
                }
                foreach ($aFilterCodes as $sFilterCode) {
                    $externalFilterValue = utils::ReadParam($sFilterCode, '', false, 'raw_data');
                    $condition = null;
                    if (isset($aExtraParams[$sFilterCode])) {
                        $condition = $aExtraParams[$sFilterCode];
                    }
                    if ($bDoSearch && $externalFilterValue != "") {
                        // Search takes precedence over context params...
                        unset($aExtraParams[$sFilterCode]);
                        if (!is_array($externalFilterValue)) {
                            $condition = trim($externalFilterValue);
                        } else {
                            if (count($externalFilterValue) == 1) {
                                $condition = trim($externalFilterValue[0]);
                            } else {
                                $condition = $externalFilterValue;
                            }
                        }
                    }
                    if (!is_null($condition)) {
                        $sOpCode = null;
                        // default operator
                        if (is_array($condition)) {
                            // Multiple values, add them as AND X IN (v1, v2, v3...)
                            $sOpCode = 'IN';
                        }
                        $this->AddCondition($sFilterCode, $condition, $sOpCode);
                    }
                }
                if ($bDoSearch) {
                    // Keep the table_id identifying this table if we're performing a search
                    $sTableId = utils::ReadParam('_table_id_', null, false, 'raw_data');
                    if ($sTableId != null) {
                        $aExtraParams['table_id'] = $sTableId;
                    }
                }
            }
            $aOrderBy = array();
            if (isset($aExtraParams['order_by'])) {
                // Convert the string describing the order_by parameter into an array
                // The syntax is +attCode1,-attCode2
                // attCode1 => ascending, attCode2 => descending
                $aTemp = explode(',', $aExtraParams['order_by']);
                foreach ($aTemp as $sTemp) {
                    $aMatches = array();
                    if (preg_match('/^([+-])?(.+)$/', $sTemp, $aMatches)) {
                        $bAscending = true;
                        if ($aMatches[1] == '-') {
                            $bAscending = false;
                        }
                        $aOrderBy[$aMatches[2]] = $bAscending;
                    }
                }
            }
            $this->m_oSet = new CMDBObjectSet($this->m_oFilter, $aOrderBy, $aQueryParams);
        }
        switch ($this->m_sStyle) {
            case 'count':
                if (isset($aExtraParams['group_by'])) {
                    if (isset($aExtraParams['group_by_label'])) {
                        $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                        $sGroupByLabel = $aExtraParams['group_by_label'];
                    } else {
                        // Backward compatibility: group_by is simply a field id
                        $sAlias = $this->m_oFilter->GetClassAlias();
                        $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                        $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                    }
                    $aGroupBy = array();
                    $aGroupBy['grouped_by_1'] = $oGroupByExp;
                    $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                    $aRes = CMDBSource::QueryToArray($sSql);
                    $aGroupBy = array();
                    $aLabels = array();
                    $aValues = array();
                    $iTotalCount = 0;
                    foreach ($aRes as $iRow => $aRow) {
                        $sValue = $aRow['grouped_by_1'];
                        $aValues[$iRow] = $sValue;
                        $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                        $aLabels[$iRow] = $sHtmlValue;
                        $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                        $iTotalCount += $aRow['_itop_count_'];
                    }
                    $aData = array();
                    $oAppContext = new ApplicationContext();
                    $sParams = $oAppContext->GetForLink();
                    foreach ($aGroupBy as $iRow => $iCount) {
                        // Build the search for this subset
                        $oSubsetSearch = $this->m_oFilter->DeepClone();
                        $oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow]));
                        $oSubsetSearch->AddConditionExpression($oCondition);
                        $sFilter = urlencode($oSubsetSearch->serialize());
                        $aData[] = array('group' => $aLabels[$iRow], 'value' => "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search&dosearch=1&{$sParams}&filter={$sFilter}\">{$iCount}</a>");
                        // TO DO: add the context information
                    }
                    $aAttribs = array('group' => array('label' => $sGroupByLabel, 'description' => ''), 'value' => array('label' => Dict::S('UI:GroupBy:Count'), 'description' => Dict::S('UI:GroupBy:Count+')));
                    $sFormat = isset($aExtraParams['format']) ? $aExtraParams['format'] : 'UI:Pagination:HeaderNoSelection';
                    $sHtml .= $oPage->GetP(Dict::Format($sFormat, $iTotalCount));
                    $sHtml .= $oPage->GetTable($aAttribs, $aData);
                } else {
                    // Simply count the number of elements in the set
                    $iCount = $this->m_oSet->Count();
                    $sFormat = 'UI:CountOfObjects';
                    if (isset($aExtraParams['format'])) {
                        $sFormat = $aExtraParams['format'];
                    }
                    $sHtml .= $oPage->GetP(Dict::Format($sFormat, $iCount));
                }
                break;
            case 'join':
                $aDisplayAliases = isset($aExtraParams['display_aliases']) ? explode(',', $aExtraParams['display_aliases']) : array();
                if (!isset($aExtraParams['group_by'])) {
                    $sHtml .= $oPage->GetP(Dict::S('UI:Error:MandatoryTemplateParameter_group_by'));
                } else {
                    $aGroupByFields = array();
                    $aGroupBy = explode(',', $aExtraParams['group_by']);
                    foreach ($aGroupBy as $sGroupBy) {
                        $aMatches = array();
                        if (preg_match('/^(.+)\\.(.+)$/', $sGroupBy, $aMatches) > 0) {
                            $aGroupByFields[] = array('alias' => $aMatches[1], 'att_code' => $aMatches[2]);
                        }
                    }
                    if (count($aGroupByFields) == 0) {
                        $sHtml .= $oPage->GetP(Dict::Format('UI:Error:InvalidGroupByFields', $aExtraParams['group_by']));
                    } else {
                        $aResults = array();
                        $aCriteria = array();
                        while ($aObjects = $this->m_oSet->FetchAssoc()) {
                            $aKeys = array();
                            foreach ($aGroupByFields as $aField) {
                                $sAlias = $aField['alias'];
                                if (is_null($aObjects[$sAlias])) {
                                    $aKeys[$sAlias . '.' . $aField['att_code']] = '';
                                } else {
                                    $aKeys[$sAlias . '.' . $aField['att_code']] = $aObjects[$sAlias]->Get($aField['att_code']);
                                }
                            }
                            $sCategory = implode($aKeys, ' ');
                            $aResults[$sCategory][] = $aObjects;
                            $aCriteria[$sCategory] = $aKeys;
                        }
                        $sHtml .= "<table>\n";
                        // Construct a new (parametric) query that will return the content of this block
                        $oBlockFilter = $this->m_oFilter->DeepClone();
                        $aExpressions = array();
                        $index = 0;
                        foreach ($aGroupByFields as $aField) {
                            $aExpressions[] = '`' . $aField['alias'] . '`.`' . $aField['att_code'] . '` = :param' . $index++;
                        }
                        $sExpression = implode(' AND ', $aExpressions);
                        $oExpression = Expression::FromOQL($sExpression);
                        $oBlockFilter->AddConditionExpression($oExpression);
                        $aExtraParams['menu'] = false;
                        foreach ($aResults as $sCategory => $aObjects) {
                            $sHtml .= "<tr><td><h1>{$sCategory}</h1></td></tr>\n";
                            if (count($aDisplayAliases) == 1) {
                                $aSimpleArray = array();
                                foreach ($aObjects as $aRow) {
                                    $oObj = $aRow[$aDisplayAliases[0]];
                                    if (!is_null($oObj)) {
                                        $aSimpleArray[] = $oObj;
                                    }
                                }
                                $oSet = CMDBObjectSet::FromArray($this->m_oFilter->GetClass(), $aSimpleArray);
                                $sHtml .= "<tr><td>" . cmdbAbstractObject::GetDisplaySet($oPage, $oSet, $aExtraParams) . "</td></tr>\n";
                            } else {
                                $index = 0;
                                $aArgs = array();
                                foreach ($aGroupByFields as $aField) {
                                    $aArgs['param' . $index] = $aCriteria[$sCategory][$aField['alias'] . '.' . $aField['att_code']];
                                    $index++;
                                }
                                $oSet = new CMDBObjectSet($oBlockFilter, array(), $aArgs);
                                $sHtml .= "<tr><td>" . cmdbAbstractObject::GetDisplayExtendedSet($oPage, $oSet, $aExtraParams) . "</td></tr>\n";
                            }
                        }
                        $sHtml .= "</table>\n";
                    }
                }
                break;
            case 'list':
                $aClasses = $this->m_oSet->GetSelectedClasses();
                $aAuthorizedClasses = array();
                if (count($aClasses) > 1) {
                    // Check the classes that can be read (i.e authorized) by this user...
                    foreach ($aClasses as $sAlias => $sClassName) {
                        if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $this->m_oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
                            $aAuthorizedClasses[$sAlias] = $sClassName;
                        }
                    }
                    if (count($aAuthorizedClasses) > 0) {
                        if ($this->m_oSet->Count() > 0) {
                            $sHtml .= cmdbAbstractObject::GetDisplayExtendedSet($oPage, $this->m_oSet, $aExtraParams);
                        } else {
                            // Empty set
                            $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
                        }
                    } else {
                        // Not authorized
                        $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
                    }
                } else {
                    // The list is made of only 1 class of objects, actions on the list are possible
                    if ($this->m_oSet->Count() > 0 && UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) {
                        $sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $this->m_oSet, $aExtraParams);
                    } else {
                        $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
                        $sClass = $this->m_oFilter->GetClass();
                        $bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true;
                        if ($bDisplayMenu) {
                            if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) {
                                $sLinkTarget = '';
                                $oAppContext = new ApplicationContext();
                                $sParams = $oAppContext->GetForLink();
                                // 1:n links, populate the target object as a default value when creating a new linked object
                                if (isset($aExtraParams['target_attr'])) {
                                    $sLinkTarget = ' target="_blank" ';
                                    $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
                                }
                                $sDefault = '';
                                if (!empty($aExtraParams['default'])) {
                                    foreach ($aExtraParams['default'] as $sKey => $sValue) {
                                        $sDefault .= "&default[{$sKey}]={$sValue}";
                                    }
                                }
                                $sHtml .= $oPage->GetP("<a{$sLinkTarget} href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=new&class={$sClass}&{$sParams}{$sDefault}\">" . Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass)) . "</a>\n");
                            }
                        }
                    }
                }
                break;
            case 'links':
                //$bDashboardMode = isset($aExtraParams['dashboard']) ? ($aExtraParams['dashboard'] == 'true') : false;
                //$bSelectMode = isset($aExtraParams['select']) ? ($aExtraParams['select'] == 'true') : false;
                if ($this->m_oSet->Count() > 0 && UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) {
                    //$sLinkage = isset($aExtraParams['linkage']) ? $aExtraParams['linkage'] : '';
                    $sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $this->m_oSet, $aExtraParams);
                } else {
                    $sClass = $this->m_oFilter->GetClass();
                    $oAttDef = MetaModel::GetAttributeDef($sClass, $this->m_aParams['target_attr']);
                    $sTargetClass = $oAttDef->GetTargetClass();
                    $sHtml .= $oPage->GetP(Dict::Format('UI:NoObject_Class_ToDisplay', MetaModel::GetName($sTargetClass)));
                    $bDisplayMenu = isset($this->m_aParams['menu']) ? $this->m_aParams['menu'] == true : true;
                    if ($bDisplayMenu) {
                        if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) {
                            $oAppContext = new ApplicationContext();
                            $sParams = $oAppContext->GetForLink();
                            $sDefaults = '';
                            if (isset($this->m_aParams['default'])) {
                                foreach ($this->m_aParams['default'] as $sName => $sValue) {
                                    $sDefaults .= '&' . urlencode($sName) . '=' . urlencode($sValue);
                                }
                            }
                            $sHtml .= $oPage->GetP("<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=modify_links&class={$sClass}&sParams&link_attr=" . $aExtraParams['link_attr'] . "&id=" . $aExtraParams['object_id'] . "&target_class={$sTargetClass}&addObjects=true{$sDefaults}\">" . Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass)) . "</a>\n");
                        }
                    }
                }
                break;
            case 'details':
                while ($oObj = $this->m_oSet->Fetch()) {
                    $sHtml .= $oObj->GetDetails($oPage);
                    // Still used ???
                }
                break;
            case 'actions':
                $sClass = $this->m_oFilter->GetClass();
                $oAppContext = new ApplicationContext();
                $bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false;
                if ($bContextFilter) {
                    $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
                    foreach ($oAppContext->GetNames() as $sFilterCode) {
                        $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null);
                        if (!is_null($sContextParamValue) && !empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode)) {
                            $this->AddCondition($sFilterCode, $sContextParamValue);
                        }
                    }
                    $aQueryParams = array();
                    if (isset($aExtraParams['query_params'])) {
                        $aQueryParams = $aExtraParams['query_params'];
                    }
                    $this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
                }
                $iCount = $this->m_oSet->Count();
                $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize());
                $sHtml .= '<p><a class="actions" href="' . $sHyperlink . '">';
                // Note: border set to 0 due to various browser interpretations (IE9 adding a 2px border)
                $sHtml .= MetaModel::GetClassIcon($sClass, true, 'float;left;margin-right:10px;border:0;');
                $sHtml .= MetaModel::GetName($sClass) . ': ' . $iCount . '</a></p>';
                $sParams = $oAppContext->GetForLink();
                $sHtml .= '<p>';
                if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY)) {
                    $sHtml .= "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=new&class={$sClass}&{$sParams}\">" . Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($sClass)) . "</a><br/>\n";
                }
                $sHtml .= "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search_form&do_search=0&class={$sClass}&{$sParams}\">" . Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass)) . "</a>\n";
                $sHtml .= '</p>';
                break;
            case 'summary':
                $sClass = $this->m_oFilter->GetClass();
                $oAppContext = new ApplicationContext();
                $sTitle = isset($aExtraParams['title[block]']) ? $aExtraParams['title[block]'] : '';
                $sLabel = isset($aExtraParams['label[block]']) ? $aExtraParams['label[block]'] : '';
                $sStateAttrCode = isset($aExtraParams['status[block]']) ? $aExtraParams['status[block]'] : 'status';
                $sStatesList = isset($aExtraParams['status_codes[block]']) ? $aExtraParams['status_codes[block]'] : '';
                $bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false;
                if ($bContextFilter) {
                    $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
                    foreach ($oAppContext->GetNames() as $sFilterCode) {
                        $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null);
                        if (!is_null($sContextParamValue) && !empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode)) {
                            $this->AddCondition($sFilterCode, $sContextParamValue);
                        }
                    }
                    $aQueryParams = array();
                    if (isset($aExtraParams['query_params'])) {
                        $aQueryParams = $aExtraParams['query_params'];
                    }
                    $this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
                }
                // Summary details
                $aCounts = array();
                $aStateLabels = array();
                if (!empty($sStateAttrCode) && !empty($sStatesList)) {
                    $aStates = explode(',', $sStatesList);
                    $oAttDef = MetaModel::GetAttributeDef($sClass, $sStateAttrCode);
                    foreach ($aStates as $sStateValue) {
                        $oFilter = $this->m_oFilter->DeepClone();
                        $oFilter->AddCondition($sStateAttrCode, $sStateValue, '=');
                        $oSet = new DBObjectSet($oFilter);
                        $aCounts[$sStateValue] = $oSet->Count();
                        $aStateLabels[$sStateValue] = htmlentities($oAttDef->GetValueLabel($sStateValue), ENT_QUOTES, 'UTF-8');
                        if ($aCounts[$sStateValue] == 0) {
                            $aCounts[$sStateValue] = '-';
                        } else {
                            $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($oFilter->serialize());
                            $aCounts[$sStateValue] = "<a href=\"{$sHyperlink}\">{$aCounts[$sStateValue]}</a>";
                        }
                    }
                }
                $sHtml .= '<div class="summary-details"><table><tr><th>' . implode('</th><th>', $aStateLabels) . '</th></tr>';
                $sHtml .= '<tr><td>' . implode('</td><td>', $aCounts) . '</td></tr></table></div>';
                // Title & summary
                $iCount = $this->m_oSet->Count();
                $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize());
                $sHtml .= '<h1>' . Dict::S(str_replace('_', ':', $sTitle)) . '</h1>';
                $sHtml .= '<a class="summary" href="' . $sHyperlink . '">' . Dict::Format(str_replace('_', ':', $sLabel), $iCount) . '</a>';
                $sHtml .= '<div style="clear:both;"></div>';
                break;
            case 'csv':
                $bAdvancedMode = utils::ReadParam('advanced', false);
                $sCsvFile = strtolower($this->m_oFilter->GetClass()) . '.csv';
                $sDownloadLink = utils::GetAbsoluteUrlAppRoot() . 'webservices/export.php?expression=' . urlencode($this->m_oFilter->ToOQL(true)) . '&format=csv&filename=' . urlencode($sCsvFile);
                $sLinkToToggle = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize()) . '&format=csv';
                if ($bAdvancedMode) {
                    $sDownloadLink .= '&fields_advanced=1';
                    $sChecked = 'CHECKED';
                } else {
                    $sLinkToToggle = $sLinkToToggle . '&advanced=1';
                    $sChecked = '';
                }
                $sAjaxLink = $sDownloadLink . '&charset=UTF-8';
                // Includes &fields_advanced=1 if in advanced mode
                /*
                			$sCSVData = cmdbAbstractObject::GetSetAsCSV($this->m_oSet, array('fields_advanced' => $bAdvancedMode));
                			$sCharset = MetaModel::GetConfig()->Get('csv_file_default_charset');
                			if ($sCharset == 'UTF-8')
                			{
                				$bLostChars = false;
                			}
                			else
                			{
                				$sConverted = @iconv('UTF-8', $sCharset, $sCSVData);
                				$sRestored = @iconv($sCharset, 'UTF-8', $sConverted);
                				$bLostChars = ($sRestored != $sCSVData);
                			}
                			if ($bLostChars)
                			{
                				$sCharsetNotice = "&nbsp;&nbsp;<span id=\"csv_charset_issue\">";
                				$sCharsetNotice .= '<img src="../images/error.png"  style="vertical-align:middle"/>';
                				$sCharsetNotice .= "</span>";
                				$sTip = "<p>".htmlentities(Dict::S('UI:CSVExport:LostChars'), ENT_QUOTES, 'UTF-8')."</p>";
                				$sTip .= "<p>".htmlentities(Dict::Format('UI:CSVExport:LostChars+', $sCharset), ENT_QUOTES, 'UTF-8')."</p>";
                				$oPage->add_ready_script("$('#csv_charset_issue').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
                			}
                			else
                			{
                				$sCharsetNotice = '';
                			}
                */
                $sCharsetNotice = false;
                $sHtml .= "<div>";
                $sHtml .= '<table style="width:100%" class="transparent">';
                $sHtml .= '<tr>';
                $sHtml .= '<td><a href="' . $sDownloadLink . '">' . Dict::Format('UI:Download-CSV', $sCsvFile) . '</a>' . $sCharsetNotice . '</td>';
                $sHtml .= '<td style="text-align:right"><input type="checkbox" ' . $sChecked . ' onClick="window.location.href=\'' . $sLinkToToggle . '\'">&nbsp;' . Dict::S('UI:CSVExport:AdvancedMode') . '</td>';
                $sHtml .= '</tr>';
                $sHtml .= '</table>';
                if ($bAdvancedMode) {
                    $sHtml .= "<p>";
                    $sHtml .= htmlentities(Dict::S('UI:CSVExport:AdvancedMode+'), ENT_QUOTES, 'UTF-8');
                    $sHtml .= "</p>";
                }
                $sHtml .= "</div>";
                $sHtml .= "<div id=\"csv_content_loading\"><div style=\"width: 250px; height: 20px; background: url(../setup/orange-progress.gif); border: 1px #999 solid; margin-left:auto; margin-right: auto; text-align: center;\">" . Dict::S('UI:Loading') . "</div></div><textarea id=\"csv_content\" style=\"display:none;\">\n";
                //$sHtml .= htmlentities($sCSVData, ENT_QUOTES, 'UTF-8');
                $sHtml .= "</textarea>\n";
                $oPage->add_ready_script("\$.post('{$sAjaxLink}', {}, function(data) { \$('#csv_content').html(data); \$('#csv_content_loading').hide(); \$('#csv_content').show();} );");
                break;
            case 'modify':
                if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_MODIFY, $this->m_oSet) == UR_ALLOWED_YES) {
                    while ($oObj = $this->m_oSet->Fetch()) {
                        $sHtml .= $oObj->GetModifyForm($oPage);
                    }
                }
                break;
            case 'search':
                $sStyle = isset($aExtraParams['open']) && $aExtraParams['open'] == 'true' ? 'SearchDrawer' : 'SearchDrawer DrawerClosed';
                $sHtml .= "<div id=\"ds_{$sId}\" class=\"{$sStyle}\">\n";
                $oPage->add_ready_script(<<<EOF
\t\$("#dh_{$sId}").click( function() {
\t\t\$("#ds_{$sId}").slideToggle('normal', function() { \$("#ds_{$sId}").parent().resize(); FixSearchFormsDisposition(); } );
\t\t\$("#dh_{$sId}").toggleClass('open');
\t});
EOF
);
                $aExtraParams['currentId'] = $sId;
                $sHtml .= cmdbAbstractObject::GetSearchForm($oPage, $this->m_oSet, $aExtraParams);
                $sHtml .= "</div>\n";
                $sHtml .= "<div class=\"HRDrawer\"></div>\n";
                $sHtml .= "<div id=\"dh_{$sId}\" class=\"DrawerHandle\">" . Dict::S('UI:SearchToggle') . "</div>\n";
                break;
            case 'open_flash_chart':
                static $iChartCounter = 0;
                $oAppContext = new ApplicationContext();
                $sContext = $oAppContext->GetForLink();
                if (!empty($sContext)) {
                    $sContext = '&' . $sContext;
                }
                $sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
                $sTitle = isset($aExtraParams['chart_title']) ? $aExtraParams['chart_title'] : '';
                $sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : '';
                $sGroupByExpr = isset($aExtraParams['group_by_expr']) ? '&params[group_by_expr]=' . $aExtraParams['group_by_expr'] : '';
                $sFilter = $this->m_oFilter->serialize();
                $sHtml .= "<div id=\"my_chart_{$sId}{$iChartCounter}\">If the chart does not display, <a href=\"http://get.adobe.com/flash/\" target=\"_blank\">install Flash</a></div>\n";
                $oPage->add_script("function ofc_resize(left, width, top, height) { /* do nothing special */ }");
                if (isset($aExtraParams['group_by_label'])) {
                    $sUrl = urlencode(utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=open_flash_chart&params[group_by]={$sGroupBy}{$sGroupByExpr}&params[group_by_label]={$aExtraParams['group_by_label']}&params[chart_type]={$sChartType}&params[chart_title]={$sTitle}&params[currentId]={$sId}&id={$sId}&filter=" . urlencode($sFilter));
                } else {
                    $sUrl = urlencode(utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=open_flash_chart&params[group_by]={$sGroupBy}{$sGroupByExpr}&params[chart_type]={$sChartType}&params[chart_title]={$sTitle}&params[currentId]={$sId}&id={$sId}&filter=" . urlencode($sFilter));
                }
                $oPage->add_ready_script("swfobject.embedSWF(\"../images/open-flash-chart.swf\", \"my_chart_{$sId}{$iChartCounter}\", \"100%\", \"300\",\"9.0.0\", \"expressInstall.swf\",\n\t\t\t\t{\"data-file\":\"" . $sUrl . "\"}, {wmode: 'transparent'} );\n");
                $iChartCounter++;
                if (isset($aExtraParams['group_by'])) {
                    if (isset($aExtraParams['group_by_label'])) {
                        $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                        $sGroupByLabel = $aExtraParams['group_by_label'];
                    } else {
                        // Backward compatibility: group_by is simply a field id
                        $sAlias = $this->m_oFilter->GetClassAlias();
                        $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                        $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                    }
                    $aGroupBy = array();
                    $aGroupBy['grouped_by_1'] = $oGroupByExp;
                    $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                    $aRes = CMDBSource::QueryToArray($sSql);
                    $aGroupBy = array();
                    $aLabels = array();
                    $aValues = array();
                    $iTotalCount = 0;
                    foreach ($aRes as $iRow => $aRow) {
                        $sValue = $aRow['grouped_by_1'];
                        $aValues[$iRow] = $sValue;
                        $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                        $aLabels[$iRow] = $sHtmlValue;
                        $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                        $iTotalCount += $aRow['_itop_count_'];
                    }
                    $aData = array();
                    $idx = 0;
                    $aURLs = array();
                    foreach ($aGroupBy as $iRow => $iCount) {
                        // Build the search for this subset
                        $oSubsetSearch = $this->m_oFilter->DeepClone();
                        $oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow]));
                        $oSubsetSearch->AddConditionExpression($oCondition);
                        $aURLs[$idx] = $oSubsetSearch->serialize();
                        $idx++;
                    }
                    $sURLList = '';
                    foreach ($aURLs as $index => $sURL) {
                        $sURLList .= "\taURLs[{$index}] = '" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search&format=html{$sContext}&filter=" . urlencode($sURL) . "';\n";
                    }
                    $oPage->add_script(<<<EOF
function ofc_drill_down_{$sId}(index)
{
\tvar aURLs = new Array();
{$sURLList}
\twindow.location.href=aURLs[index];
}
EOF
);
                }
                break;
            case 'open_flash_chart_ajax':
                require_once APPROOT . '/pages/php-ofc-library/open-flash-chart.php';
                $sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
                $sId = utils::ReadParam('id', '');
                $oChart = new open_flash_chart();
                switch ($sChartType) {
                    case 'bars':
                        $oChartElement = new bar_glass();
                        if (isset($aExtraParams['group_by'])) {
                            if (isset($aExtraParams['group_by_label'])) {
                                $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                                $sGroupByLabel = $aExtraParams['group_by_label'];
                            } else {
                                // Backward compatibility: group_by is simply a field id
                                $sAlias = $this->m_oFilter->GetClassAlias();
                                $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                                $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                            }
                            $aGroupBy = array();
                            $aGroupBy['grouped_by_1'] = $oGroupByExp;
                            $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                            $aRes = CMDBSource::QueryToArray($sSql);
                            $aGroupBy = array();
                            $aLabels = array();
                            $iTotalCount = 0;
                            foreach ($aRes as $iRow => $aRow) {
                                $sValue = $aRow['grouped_by_1'];
                                $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                                $aLabels[$iRow] = strip_tags($sHtmlValue);
                                $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                                $iTotalCount += $aRow['_itop_count_'];
                            }
                            $aData = array();
                            $aChartLabels = array();
                            $maxValue = 0;
                            foreach ($aGroupBy as $iRow => $iCount) {
                                $oBarValue = new bar_value($iCount);
                                $oBarValue->on_click("ofc_drill_down_{$sId}");
                                $aData[] = $oBarValue;
                                if ($iCount > $maxValue) {
                                    $maxValue = $iCount;
                                }
                                $aChartLabels[] = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
                            }
                            $oYAxis = new y_axis();
                            $aMagicValues = array(1, 2, 5, 10);
                            $iMultiplier = 1;
                            $index = 0;
                            $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
                            while ($maxValue > $iTop) {
                                $index++;
                                $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
                                if ($index % count($aMagicValues) == 0) {
                                    $iMultiplier = $iMultiplier * 10;
                                }
                            }
                            //echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
                            $oYAxis->set_range(0, $iTop, $iMultiplier);
                            $oChart->set_y_axis($oYAxis);
                            $oChartElement->set_values($aData);
                            $oXAxis = new x_axis();
                            $oXLabels = new x_axis_labels();
                            // set them vertical
                            $oXLabels->set_vertical();
                            // set the label text
                            $oXLabels->set_labels($aChartLabels);
                            // Add the X Axis Labels to the X Axis
                            $oXAxis->set_labels($oXLabels);
                            $oChart->set_x_axis($oXAxis);
                        }
                        break;
                    case 'pie':
                    default:
                        $oChartElement = new pie();
                        $oChartElement->set_start_angle(35);
                        $oChartElement->set_animate(true);
                        $oChartElement->set_tooltip('#label# - #val# (#percent#)');
                        $oChartElement->set_colours(array('#FF8A00', '#909980', '#2C2B33', '#CCC08D', '#596664'));
                        if (isset($aExtraParams['group_by'])) {
                            if (isset($aExtraParams['group_by_label'])) {
                                $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                                $sGroupByLabel = $aExtraParams['group_by_label'];
                            } else {
                                // Backward compatibility: group_by is simply a field id
                                $sAlias = $this->m_oFilter->GetClassAlias();
                                $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                                $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                            }
                            $aGroupBy = array();
                            $aGroupBy['grouped_by_1'] = $oGroupByExp;
                            $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                            $aRes = CMDBSource::QueryToArray($sSql);
                            $aGroupBy = array();
                            $aLabels = array();
                            $iTotalCount = 0;
                            foreach ($aRes as $iRow => $aRow) {
                                $sValue = $aRow['grouped_by_1'];
                                $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                                $aLabels[$iRow] = strip_tags($sHtmlValue);
                                $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                                $iTotalCount += $aRow['_itop_count_'];
                            }
                            $aData = array();
                            foreach ($aGroupBy as $iRow => $iCount) {
                                $sFlashLabel = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
                                $PieValue = new pie_value($iCount, $sFlashLabel);
                                //@@ BUG: not passed via ajax !!!
                                $PieValue->on_click("ofc_drill_down_{$sId}");
                                $aData[] = $PieValue;
                            }
                            $oChartElement->set_values($aData);
                            $oChart->x_axis = null;
                        }
                }
                if (isset($aExtraParams['chart_title'])) {
                    // The title has been given in an url, and urlencoded...
                    // and urlencode transforms utf-8 into something similar to ISO-8859-1
                    // Example: é (C3A9 becomes %E9)
                    // As a consequence, json_encode (called within open-flash-chart.php)
                    // was returning 'null' and the graph was not displayed at all
                    // To make sure that the graph is displayed AND to get a correct title
                    // (at least for european characters) let's transform back into utf-8 !
                    $sTitle = iconv("ISO-8859-1", "UTF-8//IGNORE", $aExtraParams['chart_title']);
                    // If the title is a dictionnary entry, fetch it
                    $sTitle = Dict::S($sTitle);
                    $oTitle = new title($sTitle);
                    $oChart->set_title($oTitle);
                    $oTitle->set_style("{font-size: 16px; font-family: Tahoma; font-weight: bold; text-align: center;}");
                }
                $oChart->set_bg_colour('#FFFFFF');
                $oChart->add_element($oChartElement);
                $sHtml = $oChart->toPrettyString();
                break;
            default:
                // Unsupported style, do nothing.
                $sHtml .= Dict::format('UI:Error:UnsupportedStyleOfBlock', $this->m_sStyle);
        }
        return $sHtml;
    }
コード例 #3
0
ファイル: solardata_day.php プロジェクト: ragchuck/pv
 $def->size(0)->halo_size(0);
 $sline->set_default_dot_style($def);
 $sline->set_key('Leistung (W)', 11);
 $v = array();
 foreach ($data_watt as $key => $val) {
     $v[] = new scatter_value($key, $val);
     $v[] = new scatter_value($key + 1, $val);
 }
 $sline->set_values($v);
 $bars_curr = new bar_glass();
 $bars_curr->set_key('Leistung (W)', 10);
 $bars_curr->set_colour('#EFC01D');
 $bars_curr->set_alpha(0.8);
 $bars_curr->set_tooltip('#val# W');
 for ($i = 0; $i < count($data_watt); $i++) {
     $bval = new bar_value($data_watt[$i]);
     if ($data_watt[$i] == max($data_watt)) {
         $bval->set_tooltip("Tages-Spitzenwert:<br>#val# W um {$time_axis[$i]} Uhr");
         $bval->set_colour('#ef4747');
     }
     $bars_curr->append_value($bval);
 }
 // PEAK
 $max_val = max($data_watt);
 $i = array_search($max_val, $data_watt);
 $s = new star($data_watt[$i]);
 $s->tooltip("Tages-Spitzenwert:<br>#val# W um #x_label# Uhr");
 $data_watt[$i] = $s->size(6)->halo_size(3)->colour('#ff0000');
 /*		
 $line_max_default_dot = new dot();
 $line_max_default_dot->size(3)->halo_size(2)->colour('#3D5C56');
コード例 #4
0
    protected function RenderChart($oPage, $sId, $aValues, $sDrillDown = '', $aRows = array())
    {
        // 1- Compute Open Flash Chart data
        //
        $aValueKeys = array();
        $index = 0;
        if (count($aValues) > 0 && $sDrillDown != '') {
            $oFilter = DBObjectSearch::FromOQL($sDrillDown);
            $sClass = $oFilter->GetClass();
            $sOQLClause = str_replace('SELECT ' . $sClass, '', $sDrillDown);
            $aSQLColNames = array_keys(current($aRows));
            // Read the list of columns from the current (i.e. first) element of the array
            $oAppContext = new ApplicationContext();
            $sURL = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search_oql&search_form=0&oql_class=' . $sClass . '&format=html&' . $oAppContext->GetForLink() . '&oql_clause=';
        }
        $aURLs = array();
        foreach ($aValues as $key => $value) {
            // Make sure that values are integers (so that max() will work....)
            // and build an array of STRING with the keys (numeric keys are transformed into string by PHP :-(
            $aValues[$key] = (int) $value;
            $aValueKeys[] = (string) $key;
            // Build the custom query for the 'drill down' on each element
            if ($sDrillDown != '') {
                $sFilter = $sOQLClause;
                foreach ($aSQLColNames as $sColName) {
                    $sFilter = str_replace(':' . $sColName, "'" . addslashes($aRows[$key][$sColName]) . "'", $sFilter);
                    $aURLs[$index] = $sURL . urlencode($sFilter);
                }
            }
            $index++;
        }
        $oChart = new open_flash_chart();
        if ($this->m_sType == 'bars') {
            $oChartElement = new bar_glass();
            if (count($aValues) > 0) {
                $maxValue = max($aValues);
            } else {
                $maxValue = 1;
            }
            $oYAxis = new y_axis();
            $aMagicValues = array(1, 2, 5, 10);
            $iMultiplier = 1;
            $index = 0;
            $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
            while ($maxValue > $iTop) {
                $index++;
                $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
                if ($index % count($aMagicValues) == 0) {
                    $iMultiplier = $iMultiplier * 10;
                }
            }
            //echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
            $oYAxis->set_range(0, $iTop, $iMultiplier);
            $oChart->set_y_axis($oYAxis);
            $aBarValues = array();
            foreach ($aValues as $iValue) {
                $oBarValue = new bar_value($iValue);
                $oBarValue->on_click("ofc_drilldown_{$sId}");
                $aBarValues[] = $oBarValue;
            }
            $oChartElement->set_values($aBarValues);
            //$oChartElement->set_values(array_values($aValues));
            $oXAxis = new x_axis();
            $oXLabels = new x_axis_labels();
            // set them vertical
            $oXLabels->set_vertical();
            // set the label text
            $oXLabels->set_labels($aValueKeys);
            // Add the X Axis Labels to the X Axis
            $oXAxis->set_labels($oXLabels);
            $oChart->set_x_axis($oXAxis);
        } else {
            $oChartElement = new pie();
            $oChartElement->set_start_angle(35);
            $oChartElement->set_animate(true);
            $oChartElement->set_tooltip('#label# - #val# (#percent#)');
            $oChartElement->set_colours(array('#FF8A00', '#909980', '#2C2B33', '#CCC08D', '#596664'));
            $aData = array();
            foreach ($aValues as $sValue => $iValue) {
                $oPieValue = new pie_value($iValue, $sValue);
                //@@ BUG: not passed via ajax !!!
                $oPieValue->on_click("ofc_drilldown_{$sId}");
                $aData[] = $oPieValue;
            }
            $oChartElement->set_values($aData);
            $oChart->x_axis = null;
        }
        // Title given in HTML
        //$oTitle = new title($this->m_sTitle);
        //$oChart->set_title($oTitle);
        $oChart->set_bg_colour('#FFFFFF');
        $oChart->add_element($oChartElement);
        $sData = $oChart->toPrettyString();
        $sData = json_encode($sData);
        // 2- Declare the Javascript function that will render the chart data\
        //
        $oPage->add_script(<<<EOF
function ofc_get_data_{$sId}()
{
\treturn {$sData};
}
EOF
);
        if (count($aURLs) > 0) {
            $sURLList = '';
            foreach ($aURLs as $index => $sURL) {
                $sURLList .= "\taURLs[{$index}] = '" . addslashes($sURL) . "';\n";
            }
            $oPage->add_script(<<<EOF
function ofc_drilldown_{$sId}(index)
{
\tvar aURLs = new Array();
{$sURLList}
\tvar sURL = aURLs[index];
\t
\twindow.location.href = sURL; // Navigate ! 
}
EOF
);
        }
        // 3- Insert the Open Flash chart
        //
        $oPage->add("<div id=\"{$sId}\"><div>\n");
        $oPage->add_ready_script(<<<EOF
swfobject.embedSWF(\t"../images/open-flash-chart.swf", 
\t"{$sId}", 
\t"100%", "300","9.0.0",
\t"expressInstall.swf",
\t{"get-data":"ofc_get_data_{$sId}", "id":"{$sId}"}, 
\t{'wmode': 'transparent'}
);
EOF
);
    }
コード例 #5
0
    }
}
*/
//BAR CHART DATA
$data = array();
$dataraw = array();
while ($row = tep_db_fetch_array($r)) {
    $dataraw[$row['status']] = $row['status_total'];
}
$statuslist = array('1', '2', '7', '3', '4', '5', '6');
$statuscolor = array('1' => '#bababa', '2' => '#ababab', '7' => '#838383', '3' => '#900000', '4' => '#ffd200', '5' => '#0066CC', '6' => '#066303');
$statustext = array();
foreach ($statuslist as $status) {
    $text = ($status == '1' ? 'New ' : 'Moved to ') . improvement::getImprovementStatus($status);
    $statustext[$status] = $text;
    $bar = new bar_value(intval($dataraw[$status]));
    $bar->set_colour($statuscolor[$status]);
    $data[$status] = $bar;
}
$title = new title('MIMS ' . $time_lookback_date . '-' . $time_lookuntil_date . ' (' . array_sum($dataraw) . ')');
$title->set_style("{font-size:13px;font-weight:bold;margin:5px 0 20px 0;}");
$chart = new open_flash_chart();
$chart->set_title($title);
/*
// PIE CHART
$pie = new pie();
$pie->set_alpha(0.6);
$pie->set_start_angle(-90);
$pie->add_animation( new pie_fade() );
$pie->set_tooltip('#val# of #total#<br>#percent# of 100%');
$pie->set_colours(array('#bababa', '#ababab', '#838383', '#900000', '#ffd200', '#0066CC', '#066303'));
コード例 #6
0
    $data = $dt;
}
//echo "<pre>";var_dump($data);die();
//make SOURCING bar is grey
if (in_array('SOURCING', array_keys($data))) {
    $bar = new bar_value($sourcing);
    $bar->set_colour('#ababab');
    $data['SOURCING'] = $bar;
}
//make OPEN (ready, workshop, lab) bar is yellow or red
if (in_array('READY', array_keys($data)) || in_array('AKAN DATANG', array_keys($data)) || in_array('PULLRACK', array_keys($data)) || in_array('TUNGGU', array_keys($data)) || in_array('SOLDER SETTING', array_keys($data)) || in_array('AMPOL AND QC', array_keys($data)) || in_array('LAB', array_keys($data))) {
    $bar_ready = new bar_value($ready);
    $bar_pullrack = new bar_value($pullrack);
    $bar_workshop = new bar_value($workshop);
    $bar_ampol = new bar_value($ampol);
    $bar_lab = new bar_value($lab);
    if ($open > $daily_capacity) {
        $bar_ready->set_colour('#900000');
        //#ffd200 = yellow, #136b05 = green, #000000 = black
        $bar_pullrack->set_colour('#900000');
        //#ffd200 = yellow, #136b05 = green, #000000 = black
        $bar_workshop->set_colour('#900000');
        //#ffd200 = yellow, #136b05 = green, #000000 = black
        $bar_ampol->set_colour('#900000');
        //#ffd200 = yellow, #136b05 = green, #000000 = black
        $bar_lab->set_colour('#900000');
        //#ffd200 = yellow, #136b05 = green, #000000 = black
    } else {
        $bar_ready->set_colour('#ffd200');
        $bar_pullrack->set_colour('#ffd200');
        $bar_workshop->set_colour('#ffd200');
コード例 #7
0
ファイル: ofc_bar_filled.php プロジェクト: sulicz/JINC_J30
 function bar_filled_value($top, $bottom = null)
 {
     parent::bar_value($top, $bottom);
 }
コード例 #8
0
ファイル: solardata_month.php プロジェクト: ragchuck/pv
}
if ($i == 0) {
    echo 0;
    exit;
}
$title = new title("\n" . date('F Y', $time) . " (" . round($MaxETotal - $MinETotal, 2) . " kWh)");
$title->set_style('{font-size: 20px; color: #778877}');
$tooltip = new tooltip();
$tooltip->set_hover();
$bars_curr = new bar_glass();
$bars_curr->set_key('Ist Tagesleistung (kWh)', 10);
$bars_curr->set_colour('#EFC01D');
$bars_curr->set_alpha(0.8);
$bars_curr->set_tooltip('#val# kWh');
for ($i = 0; $i < count($data_curr); $i++) {
    $bval = new bar_value($data_curr[$i]);
    $bval->{"on-click"} = "load_chart('day',{$ttime_axis[$i]})";
    if ($data_soll[$i] > 0) {
        $perc = round($data_curr[$i] / $data_soll[$i] * 100, 1);
    } else {
        $perc = 0;
    }
    $bval->set_tooltip($data_curr[$i] . ' kWh - ' . $perc . ' %');
    if ($data_curr[$i] == max($data_curr)) {
        $bval->set_colour('#ef4747');
    }
    $bars_curr->append_value($bval);
}
$line_soll = new line();
$line_soll->set_values($data_soll);
$line_soll->set_colour('#BFA447');
コード例 #9
0
    $bar = new bar_value($return_to_bali);
    $bar->set_colour('#900000');
    $data['RETURN DAMAGED'] = $bar;
    $bar = new bar_value($return_missing);
    $bar->set_colour('#900000');
    $data['RETURN MISSING'] = $bar;
}
//make BIN IN bar is blue
if (in_array('BIN IN', array_keys($data))) {
    $bar = new bar_value($bin_in);
    $bar->set_colour('#0066CC');
    $data['BIN IN'] = $bar;
}
//make PICKED FROM BIN bar is purple
if (in_array('PICKED FROM BIN', array_keys($data))) {
    $bar = new bar_value($picked_from_bin);
    $bar->set_colour('#9c00ff');
    $data['PICKED FROM BIN'] = $bar;
}
$bar = new bar_3d();
if ($fullscreen) {
    $bar->set_alpha(100);
}
$bar->colour('#066303');
$bar->set_values(array_values($data));
$tags = new ofc_tags();
$tags->font("Verdana", $tagfs)->colour("#0066CC")->align_x_center()->text('#y#')->style(true, false, false, 1);
$x = 0;
foreach ($data as $key => $v) {
    if (is_object($v)) {
        $v = $v->top;
コード例 #10
0
<?php

include 'php-ofc-library/open-flash-chart.php';
srand((double) microtime() * 1000000);
$data = array();
// add random height bars:
for ($i = 0; $i < 9; $i++) {
    $data[] = rand(2, 9);
}
// make the last bar a different colour:
$bar = new bar_value(5);
$bar->set_colour('#900000');
$bar->set_tooltip('Hello<br>#val#');
$data[] = $bar;
$title = new title(date("D M d Y"));
$bar = new bar_3d();
$bar->set_values($data);
$bar->colour = '#D54C78';
$x_axis = new x_axis();
$x_axis->set_3d(5);
$x_axis->colour = '#909090';
$x_axis->set_labels(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$chart->set_x_axis($x_axis);
echo $chart->toPrettyString();
コード例 #11
0
}
//make GRAPHICS bar is purple
if (in_array('GRAPHICS', array_keys($data))) {
    $bar = new bar_value($graphics);
    $bar->set_colour('#9c00ff');
    $data['GRAPHICS'] = $bar;
}
//make PRODUCT QC bar is brown
if (in_array('PRODUCT QC', array_keys($data))) {
    $bar = new bar_value($product_qc);
    $bar->set_colour('#9d3b00');
    $data['PRODUCT QC'] = $bar;
}
//make GRAPHICS bar is orange
if (in_array('DETAILS', array_keys($data))) {
    $bar = new bar_value($details);
    $bar->set_colour('#ec9022');
    $data['DETAILS'] = $bar;
}
$bar = new bar_3d();
if ($fullscreen) {
    $bar->set_alpha(100);
}
$bar->colour('#066303');
$bar->set_values(array_values($data));
$tags = new ofc_tags();
$tags->font("Verdana", $xfs)->colour("#0066CC")->align_x_center()->text('#y#')->style(true, false, false, 1);
$x = 0;
//SET FONT COLOUR MATCH WITH EACH BAR
foreach ($data as $key => $v) {
    if (is_object($v)) {
コード例 #12
0
 function __construct($top, $bottom = null)
 {
     parent::__construct($top, $bottom);
 }
コード例 #13
0
ファイル: month_surplus.php プロジェクト: bettse/ledger-ofc
include 'include.php';
$this_month = ' -c -w -F "%(account)\\t%(amount)\\n" -p "this month" --budget -M reg ^exp | sed -e \'s/\\$//g\' | sed -e \'s/,//g\'';
exec("{$ledger} {$this_month}", $output);
$max = 0;
$min = 0;
foreach ($output as $line) {
    //make into key-value pairs
    $tmp = explode("\t", $line);
    $labellist[] = $tmp[0];
    if ($tmp[1] * -1 > $max) {
        $max = $tmp[1] * -1;
    }
    if ($tmp[1] * -1 < $min) {
        $min = $tmp[1] * -1;
    }
    $bar = new bar_value($tmp[1] * -1);
    if ($tmp[1] * -1 == 0) {
        $bar->set_colour('#FFFFFF');
    } else {
        if ($tmp[1] * -1 > 0) {
            $bar->set_colour('#000000');
        } else {
            if ($tmp[1] * -1 < 0) {
                $bar->set_colour('#900000');
            }
        }
    }
    $datalist[] = $bar;
}
$title = new title("This month budget over/under");
$bar = new bar_3d();
コード例 #14
0
	public function __construct( $top, $bottom=null )
	{
		parent::bar_value( $top, $bottom );	
	}