Method process
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$currentUserId = \App\User::getCurrentUserId();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
Function process
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$currentUserId = \App\User::getCurrentUserId();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function parseData
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function parseData($data, $previousData)
{
foreach ($data['datasets'] ?? [] as $key => $values) {
unset($values);
if (!isset($previousData['datasets'][$key])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Missing class import via use statement (line '75', column '25'). Open
$queryGenerator = new \App\QueryGenerator('SSalesProcesses');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getEstimatedValue has a boolean flag argument $compare, which is a certain sign of a Single Responsibility Principle violation. Open
public function getEstimatedValue(string $timeString, bool $compare = false, $owner = false): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getEstimatedValue has a boolean flag argument $owner, which is a certain sign of a Single Responsibility Principle violation. Open
public function getEstimatedValue(string $timeString, bool $compare = false, $owner = false): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '125', column '17'). Open
$start = new \DateTime($time[0]);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '82', column '14'). Open
$sum = new \yii\db\Expression('SUM(estimated)');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '127', column '15'). Open
$end = new \DateTime($time[1]);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\App\User' in method 'process'. Open
$currentUserId = \App\User::getCurrentUserId();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Widget_Model' in method 'process'. Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$viewer->view('dashboards/TeamsEstimatedSales.tpl', $moduleName);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Utils' in method 'getEstimatedValue'. Open
$chartData['labels'][] = \App\Utils::getInitials($ownerName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Settings_WidgetsManagement_Module_Model' in method 'process'. Open
$owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget, 'Accounts');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$owner = $request->getByType('owner', 2);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Fields\Date' in method 'getSearchParams'. Open
array_push($conditions, ['estimated_date', 'bw', implode(',', \App\Fields\Date::formatRangeToDisplay(explode(',', $time)))]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\Date' in method 'process'. Open
$viewer->assign('DTIME', implode(',', \App\Fields\Date::formatRangeToDisplay($time)));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\Owner' in method 'getEstimatedValue'. Open
$ownerName = \App\Fields\Owner::getUserLabel($row['assigned_user_id']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Settings_WidgetsManagement_Module_Model' in method 'process'. Open
$time = Settings_WidgetsManagement_Module_Model::getDefaultDateRange($widget);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "Accounts" 3 times. Open
$owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget, 'Accounts');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "backgroundColor" 3 times. Open
$previousData['datasets'][$key]['backgroundColor'] = '#EDC240';
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "assigned_user_id" 5 times. Open
array_push($conditions, ['assigned_user_id', 'e', $owner]);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "datasets" 14 times. Open
foreach ($data['datasets'] ?? [] as $key => $values) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Saw an @param annotation for time,
but it was not found in the param list of function getEstimatedValue(string $timeString, bool|false $compare = null, false|int|string $owner = null) : array
Open
* @param string $time
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = new \App\QueryGenerator('SSalesProcesses');
- Exclude checks
Call to method setCustomColumn
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setCustomColumn(['estimated' => $sum]);
- Exclude checks
Call to method getUserLabel
from undeclared class \App\Fields\Owner
Open
$ownerName = \App\Fields\Owner::getUserLabel($row['assigned_user_id']);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$sum = new \yii\db\Expression('SUM(estimated)');
- Exclude checks
Call to method addCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addCondition('estimated_date', $timeString, 'bw', false, false);
- Exclude checks
Call to method getInstance
from undeclared class \App\Fields\Owner
Open
$viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('WIDGET', $widget);
- Exclude checks
Call to method addNativeCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addNativeCondition(['smownerid' => $owner]);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setFields(['assigned_user_id']);
- Exclude checks
Call to method getModuleModel
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$listView = $queryGenerator->getModuleModel()->getListViewUrl();
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('MODULE_NAME', $moduleName);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('DTIME', implode(',', \App\Fields\Date::formatRangeToDisplay($time)));
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('COMPARE', $compare);
- Exclude checks
Call to method getInstance
from undeclared class \App\Fields\Owner
Open
$viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());
- Exclude checks
Default value for int|string
$owner
can't be false
Open
public function getEstimatedValue(string $timeString, bool $compare = false, $owner = false): array
- Exclude checks
Call to method setGroup
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setGroup('assigned_user_id');
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$query = $queryGenerator->createQuery();
- Exclude checks
Argument 2 (time)
is string
but \SSalesProcesses_TeamsEstimatedSales_Dashboard::getSearchParams()
takes array
defined at /code/modules/SSalesProcesses/dashboards/TeamsEstimatedSales.php:20
Open
$chartData['datasets'][0]['links'][] = $listView . $this->getSearchParams($row['assigned_user_id'], $timeString);
- Exclude checks
Call to method getInstance
from undeclared class \Vtiger_Widget_Model
Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('DATA', $data);
- Exclude checks
Argument 2 (str)
is array
but \explode()
takes string
Open
array_push($conditions, ['estimated_date', 'bw', implode(',', \App\Fields\Date::formatRangeToDisplay(explode(',', $time)))]);
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$currentUserId = \App\User::getCurrentUserId();
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
while ($row = $dataReader->read()) {
$chartData['datasets'][0]['data'][] = round($row['estimated'], 2);
$chartData['datasets'][0]['backgroundColor'][] = '#95a458';
$chartData['datasets'][0]['links'][] = $listView . $this->getSearchParams($row['assigned_user_id'], $timeString);
$ownerName = \App\Fields\Owner::getUserLabel($row['assigned_user_id']);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 156.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function getSearchParams($owner, $time)
{
$conditions = [];
$listSearchParams = [];
if (!empty($owner)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 142.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid excessively long class names like SSalesProcesses_TeamsEstimatedSales_Dashboard. Keep class name length under 40. Open
class SSalesProcesses_TeamsEstimatedSales_Dashboard extends Vtiger_IndexAjax_View
{
/**
* Function to get search params in address listview.
*
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SSalesProcesses_TeamsEstimatedSales_Dashboard extends Vtiger_IndexAjax_View
- Exclude checks
The class SSalesProcesses_TeamsEstimatedSales_Dashboard is not named in CamelCase. Open
class SSalesProcesses_TeamsEstimatedSales_Dashboard extends Vtiger_IndexAjax_View
{
/**
* Function to get search params in address listview.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Expected 1 space after comma in function call; 2 found Open
$viewer->assign('DTIME', implode(',', \App\Fields\Date::formatRangeToDisplay($time)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values['backgroundColor'] = '#EDC240';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setCustomColumn(['estimated' => $sum]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($time)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$owner = $request->getByType('owner', 2);
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
array_push($conditions, ['estimated_date', 'bw', implode(',', \App\Fields\Date::formatRangeToDisplay(explode(',', $time)))]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['datasets'][] = $values;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Main function.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$previousData = $this->getEstimatedValue($previousTime, $compare, $owner);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listSearchParams = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addNativeCondition(['smownerid' => $owner]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$chartData = [];
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$chartData['datasets'][0]['links'][] = $listView . $this->getSearchParams($row['assigned_user_id'], $timeString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $chartData;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$time = $request->getDateRange('time');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '&viewname=All&search_params=' . json_encode($listSearchParams);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$chartData['show_chart'] = (bool) isset($chartData['datasets']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$start->modify("-{$interval} days");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSearchParams($owner, $time)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($compare);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = $queryGenerator->createQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentUserId = \App\User::getCurrentUserId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = $this->getViewer($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($time[0] !== $time[1]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('COMPARE', $compare);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$conditions = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($time)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($values);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get data to chart.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setFields(['assigned_user_id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$interval = (int) $start->diff($end)->format('%r%a');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $this->parseData($data, $previousData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('WIDGET', $widget);
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
$viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get search params in address listview.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listSearchParams[] = $conditions;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$previousData['datasets'][$key]['data'] = [0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($previousData['datasets'] ?? [] as $key => $values) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['datasets'] = array_reverse($data['datasets']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$chartData['labels'][] = \App\Utils::getInitials($ownerName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$previousData['datasets'][$key]['backgroundColor'] = '#EDC240';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $time
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getEstimatedValue(string $timeString, bool $compare = false, $owner = false): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$chartData['datasets'][0]['backgroundColor'][] = '#95a458';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeString = implode(',', $time);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($compare) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has('content')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($owner)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
array_push($conditions, ['assigned_user_id', 'e', $owner]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $data
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($data['datasets'] ?? [] as $key => $values) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|string $owner
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addCondition('estimated_date', $timeString, 'bw', false, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sum = new \yii\db\Expression('SUM(estimated)');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ownerName = \App\Fields\Owner::getUserLabel($row['assigned_user_id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$time = Settings_WidgetsManagement_Module_Model::getDefaultDateRange($widget);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$endPeriod = clone $start;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$end = new \DateTime($time[1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listView = $queryGenerator->getModuleModel()->getListViewUrl();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$start = new \DateTime($time[0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('DATA', $data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Parse data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$request->has('owner')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $this->getEstimatedValue($timeString, $compare, $owner);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('dashboards/TeamsEstimatedSales.tpl', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $owner number id of user
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
array_push($conditions, ['estimated_date', 'bw', implode(',', \App\Fields\Date::formatRangeToDisplay(explode(',', $time)))]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($data['datasets'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $compare
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$chartData['datasets'][0]['data'][] = round($row['estimated'], 2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$chartData['datasets'][0]['links'][] = $listView . $this->getSearchParams($row['assigned_user_id'], $timeString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget, 'Accounts');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($data) || !empty($previousData)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $previousData
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
$viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($data['datasets'][$key]) && is_array($values)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setGroup('assigned_user_id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$previousTime = $start->format('Y-m-d') . ',' . $endPeriod->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('MODULE_NAME', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $time
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($previousData['datasets'][$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('all' !== $owner) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$interval;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function parseData($data, $previousData)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = new \App\QueryGenerator('SSalesProcesses');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$chartData['fullLabels'][] = $ownerName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$compare = $request->getBoolean('compare');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$endPeriod->modify('-1 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('DTIME', implode(',', \App\Fields\Date::formatRangeToDisplay($time)));
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 9 Open
$queryGenerator->addNativeCondition(['smownerid' => $owner]);
- Exclude checks
Class name "SSalesProcesses_TeamsEstimatedSales_Dashboard" is not in camel caps format Open
class SSalesProcesses_TeamsEstimatedSales_Dashboard extends Vtiger_IndexAjax_View
- Exclude checks