1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of FacturaScripts |
4
|
|
|
* Copyright (C) 2019 Carlos Garcia Gomez <[email protected]> |
5
|
|
|
* |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU Lesser General Public License as |
8
|
|
|
* published by the Free Software Foundation, either version 3 of the |
9
|
|
|
* License, or (at your option) any later version. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU Lesser General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
*/ |
19
|
|
|
namespace FacturaScripts\Core\Controller; |
20
|
|
|
|
21
|
|
|
use FacturaScripts\Core\Lib\ExtendedController\BaseView; |
22
|
|
|
use FacturaScripts\Core\Lib\ExtendedController\EditController; |
23
|
|
|
use FacturaScripts\Dinamic\Lib\ReportChart\AreaChart; |
|
|
|
|
24
|
|
|
use FacturaScripts\Dinamic\Model\Report; |
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Description of EditReport |
28
|
|
|
* |
29
|
|
|
* @author Carlos Garcia Gomez <[email protected]> |
30
|
|
|
*/ |
31
|
|
|
class EditReport extends EditController |
32
|
|
|
{ |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* |
36
|
|
|
* @return AreaChart |
37
|
|
|
*/ |
38
|
|
|
public function getChart() |
39
|
|
|
{ |
40
|
|
|
foreach ($this->views as $view) { |
41
|
|
|
return new AreaChart($view->model); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return new AreaChart(new Report()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public function getModelClassName() |
52
|
|
|
{ |
53
|
|
|
return 'Report'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* |
58
|
|
|
* @return array |
59
|
|
|
*/ |
60
|
|
|
public function getPageData(): array |
61
|
|
|
{ |
62
|
|
|
$data = parent::getPageData(); |
63
|
|
|
$data['menu'] = 'reports'; |
64
|
|
|
$data['title'] = 'report'; |
65
|
|
|
$data['icon'] = 'fas fa-chart-pie'; |
66
|
|
|
return $data; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
protected function createViews() |
70
|
|
|
{ |
71
|
|
|
parent::createViews(); |
72
|
|
|
$this->setTabsPosition('bottom'); |
73
|
|
|
$this->addHtmlView('chart', 'Master/htmlChart', 'Report', 'chart'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* |
78
|
|
|
* @param string $viewName |
79
|
|
|
* @param BaseView $view |
80
|
|
|
*/ |
81
|
|
|
protected function loadData($viewName, $view) |
82
|
|
|
{ |
83
|
|
|
switch ($viewName) { |
84
|
|
|
default: |
85
|
|
|
parent::loadData($viewName, $view); |
86
|
|
|
$this->loadWidgetValues($viewName); |
87
|
|
|
break; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* |
93
|
|
|
* @param string $viewName |
94
|
|
|
*/ |
95
|
|
|
protected function loadWidgetValues($viewName) |
96
|
|
|
{ |
97
|
|
|
$tableColumn = $this->views[$viewName]->columnForField('table'); |
98
|
|
|
if ($tableColumn) { |
99
|
|
|
$tableColumn->widget->setValuesFromArray($this->dataBase->getTables()); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
$tableName = $this->views[$viewName]->model->table; |
103
|
|
|
$columns = empty($tableName) || !$this->dataBase->tableExists($tableName) ? [] : array_keys($this->dataBase->getColumns($tableName)); |
104
|
|
|
sort($columns); |
105
|
|
|
|
106
|
|
|
$xcolColumn = $this->views[$viewName]->columnForField('xcolumn'); |
107
|
|
|
if ($xcolColumn && count($columns) > 0) { |
108
|
|
|
$xcolColumn->widget->setValuesFromArray($columns); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
$ycolColumn = $this->views[$viewName]->columnForField('ycolumn'); |
112
|
|
|
if ($ycolColumn && count($columns) > 0) { |
113
|
|
|
$ycolColumn->widget->setValuesFromArray($columns, false, true); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths