| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- /**
- * The project deviation view file of pivot module of ZenTaoPMS.
- * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
- * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
- * @author Gang Liu <liugang@easycorp.ltd>
- * @package pivot
- * @link https://www.zentao.net
- */
- namespace zin;
- $getDeviationHtml = function(float $deviation): string
- {
- if($deviation > 0) return "<span class='up'>↑</span>" . $deviation;
- if($deviation < 0) return "<span class='down'>↓</span>" . abs($deviation);
- return "<span class='zero'>0</span>";
- };
- $getDeviationRateHtml = function($deviationRate): string
- {
- if($deviationRate == 'n/a') return "<span class='zero'>" . $deviationRate . '</span>';
- if($deviationRate == 0) return "<span class='zero'>" . $deviationRate . '%</span>';
- if($deviationRate >= 50) return "<span class='u50'>" . $deviationRate . '%</span>';
- if($deviationRate >= 30) return "<span class='u30'>" . $deviationRate . '%</span>';
- if($deviationRate >= 10) return "<span class='u10'>" . $deviationRate . '%</span>';
- if($deviationRate > 0) return "<span class='u0'>" . $deviationRate . '%</span>';
- if($deviationRate <= -20) return "<span class='d20'>" . abs($deviationRate) . '%</span>';
- return "<span class='d0'>" . abs($deviationRate) . '%</span>';
- };
- $canView = hasPriv('execution', 'view');
- $chartData = array();
- foreach($executions as $execution)
- {
- $chartData['labels'][] = $execution->executionName;
- $chartData['data'][] = $execution->deviation;
- if($execution->multiple)
- {
- if($canView) $execution->executionName = html::a(helper::createLink('execution', 'view', "executionID={$execution->executionID}"), $execution->executionName);
- }
- else
- {
- $execution->executionName = $this->lang->null;
- }
- $execution->deviation = $getDeviationHtml($execution->deviation);
- $execution->deviationRate = $getDeviationRateHtml($execution->deviationRate);
- }
- $cols = $config->pivot->dtable->projectDeviation->fieldList;
- $data = new stdclass();
- $data->cols = $this->pivot->processDTableCols($cols);
- $data->array = $this->pivot->processDTableData(array_keys($cols), $executions);
- $generateData = function() use ($lang, $title, $cols, $data, $executions, $chartData, $begin, $end)
- {
- return array
- (
- div
- (
- setID('conditions'),
- setClass('flex gap-4 bg-canvas p-2'),
- on::change('loadProjectDeviation'),
- inputGroup
- (
- setClass('w-1/4'),
- $lang->pivot->execution . $lang->pivot->begin,
- datePicker(set(array('name' => 'begin', 'value' => $begin)))
- ),
- inputGroup
- (
- setClass('w-1/4'),
- $lang->pivot->execution . $lang->pivot->end,
- datePicker(set(array('name' => 'end', 'value' => $end)))
- )
- ),
- panel
- (
- setID('pivotPanel'),
- set::title($title),
- set::shadow(false),
- set::headingClass('h-14'),
- set::bodyClass('pt-0'),
- to::titleSuffix(
- icon
- (
- setClass('cursor-pointer'),
- setData(array('toggle' => 'tooltip', 'title' => $lang->pivot->deviationDesc, 'placement' => 'right', 'className' => 'text-gray border border-light', 'type' => 'white')),
- 'help'
- )
- ),
- dtable(set::striped(true), set::bordered(true), set::cols($cols), set::data($executions), set::emptyTip($lang->error->noData)),
- div
- (
- setID('exportData'),
- setClass('hidden'),
- rawContent(),
- html($this->pivot->buildPivotTable($data, array()))
- )
- ),
- panel
- (
- setID('pivotChart'),
- set::title($lang->pivot->deviationChart),
- set::shadow(false),
- $chartData ? null : setClass('hidden'),
- $chartData ? echarts
- (
- set::width('100%'),
- set::height(300),
- set::xAxis
- (
- array
- (
- 'type' => 'category',
- 'boundaryGap' => false,
- 'axisLine' => array('onZero' => false),
- 'axisLabel' => array('interval' => 0),
- 'splitLine' => array('show' => true, 'interval' => 0),
- 'data' => $chartData['labels']
- )
- ),
- set::yAxis
- (
- array
- (
- 'type' => 'value',
- 'axisLine' => array('show' => true)
- )
- ),
- set::tooltip
- (
- array
- (
- 'trigger' => 'axis',
- 'formatter' => '{b}: {c}h'
- )
- ),
- set::series
- (
- array
- (
- array
- (
- 'data' => $chartData['data'],
- 'type' => 'line',
- 'lineStyle' => array('color' => '#0033CC')
- )
- )
- )
- ) : null
- )
- );
- };
|