YetiForceCompany/YetiForceCRM

View on GitHub
modules/SSalesProcesses/dashboards/TeamsEstimatedSales.php

Summary

Maintainability
C
1 day
Test Coverage
F
0%

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();
Severity: Minor
Found in modules/SSalesProcesses/dashboards/TeamsEstimatedSales.php - About 1 hr to fix

    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();
    Severity: Minor
    Found in modules/SSalesProcesses/dashboards/TeamsEstimatedSales.php - About 1 hr to fix

    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])) {
    Severity: Minor
    Found in modules/SSalesProcesses/dashboards/TeamsEstimatedSales.php - About 45 mins to fix

    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');

    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

    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

    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]);

    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)');

    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]);

    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();

    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);

    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);
            }

    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);

    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');

    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);
            }

    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)))]);

    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)));

    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']);

    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);

    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');

    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';

    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]);

    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) {

    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

    Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator = new \App\QueryGenerator('SSalesProcesses');

    Call to method setCustomColumn from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator->setCustomColumn(['estimated' => $sum]);

    Call to method getUserLabel from undeclared class \App\Fields\Owner
    Open

                $ownerName = \App\Fields\Owner::getUserLabel($row['assigned_user_id']);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());

    Call to method __construct from undeclared class \yii\db\Expression
    Open

            $sum = new \yii\db\Expression('SUM(estimated)');

    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);

    Call to method getInstance from undeclared class \App\Fields\Owner
    Open

            $viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGET', $widget);

    Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

             $queryGenerator->addNativeCondition(['smownerid' => $owner]);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());

    Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator->setFields(['assigned_user_id']);

    Call to method getModuleModel from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $listView = $queryGenerator->getModuleModel()->getListViewUrl();

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_NAME', $moduleName);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DTIME',  implode(',', \App\Fields\Date::formatRangeToDisplay($time)));

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('COMPARE', $compare);

    Call to method getInstance from undeclared class \App\Fields\Owner
    Open

            $viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());

    Default value for int|string $owner can't be false
    Open

        public function getEstimatedValue(string $timeString, bool $compare = false, $owner = false): array

    Call to method setGroup from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator->setGroup('assigned_user_id');

    Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $query = $queryGenerator->createQuery();

    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);

    Call to method getInstance from undeclared class \Vtiger_Widget_Model
    Open

            $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DATA', $data);

    Argument 2 (str) is array but \explode() takes string
    Open

                array_push($conditions, ['estimated_date', 'bw', implode(',', \App\Fields\Date::formatRangeToDisplay(explode(',', $time)))]);

    Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

            $currentUserId = \App\User::getCurrentUserId();

    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']);
    Severity: Major
    Found in modules/SSalesProcesses/dashboards/TeamsEstimatedSales.php and 1 other location - About 3 hrs to fix
    modules/SSalesProcesses/dashboards/ActualSalesOfTeam.php on lines 63..70

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getSearchParams($owner, $time)
        {
            $conditions = [];
            $listSearchParams = [];
            if (!empty($owner)) {
    Severity: Major
    Found in modules/SSalesProcesses/dashboards/TeamsEstimatedSales.php and 1 other location - About 3 hrs to fix
    modules/SSalesProcesses/dashboards/ActualSalesOfTeam.php on lines 25..37

    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

    Further Reading

    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.
         *

    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

    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.
         *

    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)));

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $values['backgroundColor'] = '#EDC240';

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $queryGenerator->setCustomColumn(['estimated' => $sum]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $dataReader = $query->createCommand()->query();

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function process(App\Request $request)

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (empty($time)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $owner = $request->getByType('owner', 2);

    Line exceeds 120 characters; contains 137 characters
    Open

                array_push($conditions, ['estimated_date', 'bw', implode(',', \App\Fields\Date::formatRangeToDisplay(explode(',', $time)))]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $data['datasets'][] = $values;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Main function.

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $previousData = $this->getEstimatedValue($previousTime, $compare, $owner);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $listSearchParams = [];

    Spaces must be used to indent lines; tabs are not allowed
    Open

             $queryGenerator->addNativeCondition(['smownerid' => $owner]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $chartData = [];

    Line exceeds 120 characters; contains 125 characters
    Open

                $chartData['datasets'][0]['links'][] = $listView . $this->getSearchParams($row['assigned_user_id'], $timeString);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $chartData;

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $time = $request->getDateRange('time');

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return string

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return '&viewname=All&search_params=' . json_encode($listSearchParams);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return array

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $chartData['show_chart'] = (bool) isset($chartData['datasets']);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $start->modify("-{$interval} days");

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function getSearchParams($owner, $time)

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            unset($compare);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $query = $queryGenerator->createQuery();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $currentUserId = \App\User::getCurrentUserId();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer = $this->getViewer($request);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if ($time[0] !== $time[1]) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('COMPARE', $compare);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $moduleName = $request->getModule();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $conditions = [];

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!empty($time)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return array

    Spaces must be used to indent lines; tabs are not allowed
    Open

                unset($values);

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Function to get data to chart.

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $queryGenerator->setFields(['assigned_user_id']);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $dataReader->close();

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $interval = (int) $start->diff($end)->format('%r%a');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $data = $this->parseData($data, $previousData);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('WIDGET', $widget);

    Line exceeds 120 characters; contains 136 characters
    Open

            $viewer->assign('ACCESSIBLE_GROUPS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleGroupForModule());

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Function to get search params in address listview.

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $listSearchParams[] = $conditions;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $previousData['datasets'][$key]['data'] = [0];

    Spaces must be used to indent lines; tabs are not allowed
    Open

            foreach ($previousData['datasets'] ?? [] as $key => $values) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $data['datasets'] = array_reverse($data['datasets']);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $chartData['labels'][] = \App\Utils::getInitials($ownerName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $previousData['datasets'][$key]['backgroundColor'] = '#EDC240';

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param string      $time

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function getEstimatedValue(string $timeString, bool $compare = false, $owner = false): array

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $chartData['datasets'][0]['backgroundColor'][] = '#95a458';

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $timeString = implode(',', $time);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($compare) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($request->has('content')) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!empty($owner)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                array_push($conditions, ['assigned_user_id', 'e', $owner]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param array $data

    Spaces must be used to indent lines; tabs are not allowed
    Open

            foreach ($data['datasets'] ?? [] as $key => $values) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $data;

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param int|string $owner

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $queryGenerator->addCondition('estimated_date', $timeString, 'bw', false, false);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $sum = new \yii\db\Expression('SUM(estimated)');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $ownerName = \App\Fields\Owner::getUserLabel($row['assigned_user_id']);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $time = Settings_WidgetsManagement_Module_Model::getDefaultDateRange($widget);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $endPeriod = clone $start;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $end = new \DateTime($time[1]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $listView = $queryGenerator->getModuleModel()->getListViewUrl();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            while ($row = $dataReader->read()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $start = new \DateTime($time[0]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('DATA', $data);

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Parse data.

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param \App\Request $request

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!$request->has('owner')) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            } else {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $data = $this->getEstimatedValue($timeString, $compare, $owner);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());

    Spaces must be used to indent lines; tabs are not allowed
    Open

            } else {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $viewer->view('dashboards/TeamsEstimatedSales.tpl', $moduleName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param int   $owner number id of user

    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)))]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (isset($data['datasets'])) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param bool $compare

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $chartData['datasets'][0]['data'][] = round($row['estimated'], 2);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $chartData['datasets'][0]['links'][] = $listView . $this->getSearchParams($row['assigned_user_id'], $timeString);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget, 'Accounts');

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if (!empty($data) || !empty($previousData)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param array $previousData

    Line exceeds 120 characters; contains 135 characters
    Open

            $viewer->assign('ACCESSIBLE_USERS', \App\Fields\Owner::getInstance('Accounts', $currentUserId)->getAccessibleUsersForModule());

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if (isset($data['datasets'][$key]) && is_array($values)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $queryGenerator->setGroup('assigned_user_id');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $previousTime = $start->format('Y-m-d') . ',' . $endPeriod->format('Y-m-d');

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('MODULE_NAME', $moduleName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param array $time

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if (!isset($previousData['datasets'][$key])) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ('all' !== $owner) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    ++$interval;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function parseData($data, $previousData)

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $queryGenerator = new \App\QueryGenerator('SSalesProcesses');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $chartData['fullLabels'][] = $ownerName;

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $compare = $request->getBoolean('compare');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $endPeriod->modify('-1 days');

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('DTIME',  implode(',', \App\Fields\Date::formatRangeToDisplay($time)));

    Line indented incorrectly; expected at least 12 spaces, found 9
    Open

             $queryGenerator->addNativeCondition(['smownerid' => $owner]);

    Class name "SSalesProcesses_TeamsEstimatedSales_Dashboard" is not in camel caps format
    Open

    class SSalesProcesses_TeamsEstimatedSales_Dashboard extends Vtiger_IndexAjax_View

    There are no issues that match your filters.

    Category
    Status