YetiForceCompany/YetiForceCRM

View on GitHub
modules/Occurrences/models/Calendar.php

Summary

Maintainability
B
6 hrs
Test Coverage
F
0%

Method getQuery has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getQuery()
    {
        $queryGenerator = new App\QueryGenerator($this->getModuleName());
        if ($this->has('customFilter')) {
            $queryGenerator->initForCustomViewById($this->get('customFilter'));
Severity: Major
Found in modules/Occurrences/models/Calendar.php - About 2 hrs to fix

    Function getQuery has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getQuery()
        {
            $queryGenerator = new App\QueryGenerator($this->getModuleName());
            if ($this->has('customFilter')) {
                $queryGenerator->initForCustomViewById($this->get('customFilter'));
    Severity: Minor
    Found in modules/Occurrences/models/Calendar.php - About 2 hrs 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

    Method getEntity has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getEntity()
        {
            $dataReader = $this->getQuery()->createCommand()->query();
            $result = [];
            $moduleModel = $this->getModule();
    Severity: Minor
    Found in modules/Occurrences/models/Calendar.php - About 1 hr to fix

      The method getQuery() has an NPath complexity of 2880. The configured NPath complexity threshold is 200.
      Open

          public function getQuery()
          {
              $queryGenerator = new App\QueryGenerator($this->getModuleName());
              if ($this->has('customFilter')) {
                  $queryGenerator->initForCustomViewById($this->get('customFilter'));

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

      Source https://phpmd.org/rules/codesize.html#npathcomplexity

      The method getQuery() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
      Open

          public function getQuery()
          {
              $queryGenerator = new App\QueryGenerator($this->getModuleName());
              if ($this->has('customFilter')) {
                  $queryGenerator->initForCustomViewById($this->get('customFilter'));

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

      Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed.
      Open

          public function getQuery()

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

      Missing class import via use statement (line '118', column '28').
      Open

                  $dateTimeInstance = new DateTimeField($record['date_end']);

      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 '114', column '28').
      Open

                  $dateTimeInstance = new DateTimeField($record['date_start']);

      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 '22').
      Open

                      $subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $selectedIds]);

      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 '25', column '25').
      Open

              $queryGenerator = new App\QueryGenerator($this->getModuleName());

      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 'Vtiger_Loader' in method 'getQuery'.
      Open

                      $filterClassName = Vtiger_Loader::getComponentClassName('CalendarFilter', $filter['name'], $this->getModuleName());

      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\Purifier' in method 'getEntity'.
      Open

                  $item['title'] = \App\Purifier::encodeHtml($record['topic']);

      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 getEntity uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      $item['url'] = $moduleModel->getDetailViewUrl($record['id']);
                  }

      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 assigning values to variables in if clauses and the like (line '71', column '48').
      Open

          public function getQuery()
          {
              $queryGenerator = new App\QueryGenerator($this->getModuleName());
              if ($this->has('customFilter')) {
                  $queryGenerator->initForCustomViewById($this->get('customFilter'));

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid using static access to class 'Vtiger_Record_Model' in method 'updateEvent'.
      Open

                  $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->getModuleName());

      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\Log' in method 'updateEvent'.
      Open

                  \App\Log::error($e->__toString());

      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 'DateTimeField' in method 'getQuery'.
      Open

                  $dbEndDateObject = DateTimeField::convertToDBTimeZone($this->get('end'));

      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 assigning values to variables in if clauses and the like (line '151', column '8').
      Open

          public function updateEvent(int $recordId, string $start, string $end, App\Request $request): bool
          {
              try {
                  $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->getModuleName());
                  if ($success = $recordModel->isEditable()) {

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid using static access to class 'App\Fields\DateTime' in method 'updateEvent'.
      Open

                      $recordModel->set('date_start', App\Fields\DateTime::formatToDb($start));

      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 'DateTimeField' in method 'getQuery'.
      Open

                  $dbStartDateOject = DateTimeField::convertToDBTimeZone($this->get('start'));

      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\Picklist' in method 'getEntity'.
      Open

              $colors = \App\Fields\Picklist::getColors('occurrences_type', false);

      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\DateTime' in method 'updateEvent'.
      Open

                      $recordModel->set('date_end', App\Fields\DateTime::formatToDb($end));

      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 "u_yf_occurrences.date_end" 3 times.
      Open

                          ['>=', 'u_yf_occurrences.date_end', $dbStartDateTime],

      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 "date_start" 4 times.
      Open

              $queryGenerator->setFields(['id', 'date_start', 'date_end', 'occurrences_type', 'occurrences_status', 'topic', 'assigned_user_id']);

      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 "occurrences_status" 3 times.
      Open

              $queryGenerator->setFields(['id', 'date_start', 'date_end', 'occurrences_type', 'occurrences_status', 'topic', 'assigned_user_id']);

      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 "date_end" 4 times.
      Open

              $queryGenerator->setFields(['id', 'date_start', 'date_end', 'occurrences_type', 'occurrences_status', 'topic', 'assigned_user_id']);

      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 "u_yf_occurrences.date_start" 4 times.
      Open

                          ['>=', 'u_yf_occurrences.date_start', $dbStartDateTime],

      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 "Y-m-d" 4 times.
      Open

                  $dbStartDate = $dbStartDateOject->format('Y-m-d');

      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 "start" 3 times.
      Open

              if ($this->get('start') && $this->get('end')) {

      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 "occurrences_type" 4 times.
      Open

              $queryGenerator->setFields(['id', 'date_start', 'date_end', 'occurrences_type', 'occurrences_status', 'topic', 'assigned_user_id']);

      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.

      Call to undeclared method \App\Db\Query::select
      Open

                      $subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $selectedIds]);
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

      Call to method read from undeclared class \yii\db\DataReader
      Open

              while ($record = $dataReader->read()) {
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

      Call to method close from undeclared class \yii\db\DataReader
      Open

              $dataReader->close();
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

      Call to method error from undeclared class \App\Log
      Open

                  \App\Log::error($e->__toString());
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

              $queryGenerator->setFields(['id', 'date_start', 'date_end', 'occurrences_type', 'occurrences_status', 'topic', 'assigned_user_id']);
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

                  $queryGenerator->addNativeCondition([
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

                  $queryGenerator->initForCustomViewById($this->get('customFilter'));
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

                  $queryGenerator->addCondition('occurrences_status', implode('##', $components), 'e');
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

              $query = $queryGenerator->createQuery();
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

                  $queryGenerator->addCondition('occurrences_status', implode('##', $components), 'n');
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

              $queryGenerator = new App\QueryGenerator($this->getModuleName());
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

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

                  $queryGenerator->addNativeCondition(['u_#__occurrences.occurrences_type' => $this->get('types')]);
      Severity: Critical
      Found in modules/Occurrences/models/Calendar.php by phan

      Avoid excessively long variable names like $isSummaryViewSupported. Keep variable name length under 20.
      Open

              $isSummaryViewSupported = $moduleModel->isSummaryViewSupported();

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#longvariable

      Each class must be in a namespace of at least one level (a top-level vendor name)
      Open

      class Occurrences_Calendar_Model extends Vtiger_Calendar_Model

      The class Occurrences_Calendar_Model is not named in CamelCase.
      Open

      class Occurrences_Calendar_Model extends Vtiger_Calendar_Model
      {
          /**
           * Get query.
           *

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

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

                          'and',

      Line exceeds 120 characters; contains 131 characters
      Open

                      $filterClassName = Vtiger_Loader::getComponentClassName('CalendarFilter', $filter['name'], $this->getModuleName());

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

           * Function to get records.

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

           */

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

                      $recordModel->set('date_end', App\Fields\DateTime::formatToDb($end));

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

          }

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

           * Get query.

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

              $queryGenerator = new App\QueryGenerator($this->getModuleName());

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

                  $dbStartDate = $dbStartDateOject->format('Y-m-d');

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

                  $selectedIds = $selectedUsers['selectedIds'];

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

                  if (isset($selectedUsers['excludedIds']) && 'all' === $selectedIds[0]) {

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

              $result = [];

      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 updateEvent(int $recordId, string $start, string $end, App\Request $request): bool

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

           *

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

                      $filterInstance = new $filterClassName();

      Line exceeds 120 characters; contains 123 characters
      Open

                      if ($filterInstance->checkPermissions() && $conditions = $filterInstance->getCondition($filter['value'])) {

      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($this->get('user')) && isset($this->get('user')['selectedIds'][0])) {

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

                      $subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $selectedIds]);

      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

                  $dateTimeInstance = new DateTimeField($record['date_start']);

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

                  $dbStartDateOject = DateTimeField::convertToDBTimeZone($this->get('start'));

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

                  $dbStartDateTime = $dbStartDateOject->format('Y-m-d H:i:s');

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

                  $dbEndDateObject = DateTimeField::convertToDBTimeZone($this->get('end'));

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

                  $dbEndDate = $dbEndDateObject->format('Y-m-d');

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

                      [

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

                          ['<=', 'u_yf_occurrences.date_start', $dbEndDateTime],

      Line exceeds 120 characters; contains 137 characters
      Open

                      $subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $selectedIds]);

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

                      $conditions[] = ['not in', 'vtiger_crmentity.smownerid', $selectedUsers['excludedIds']];

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

              $colors = \App\Fields\Picklist::getColors('occurrences_type', false);

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

                  $item = [];

      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 $this->getModule()->getFieldByName('occurrences_type')->getPicklistValues();

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

                  $success = false;

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

                  $queryGenerator->addNativeCondition(['u_#__occurrences.occurrences_type' => $this->get('types')]);

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

                          'and',

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

                          ['>=', 'u_yf_occurrences.date_end', $dbStartDateTime],

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

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

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

                  $item['end'] = DateTimeField::convertToUserTimeZone($record['date_end'])->format('Y-m-d') . ' ' . $dateTimeInstance->getFullcalenderTime();

      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 string[]

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

           */

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

                  $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->getModuleName());

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

              $components = ['PLL_ARCHIVED', 'PLL_CANCELLED'];

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

                  $queryGenerator->addCondition('occurrences_status', implode('##', $components), 'n');

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

                  $queryGenerator->addCondition('occurrences_status', implode('##', $components), 'e');

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

                      if ($filterInstance->checkPermissions() && $conditions = $filterInstance->getCondition($filter['value'])) {

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

              return $query;

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

              $isSummaryViewSupported = $moduleModel->isSummaryViewSupported();

      Line exceeds 120 characters; contains 155 characters
      Open

                  $item['start'] = DateTimeField::convertToUserTimeZone($record['date_start'])->format('Y-m-d') . ' ' . $dateTimeInstance->getFullcalenderTime();

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

                  $item['borderColor'] = $colors[$record['occurrences_type']] ?? '';

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

                  $item['className'] = 'js-popover-tooltip--record ownerCBg_' . $record['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

          {

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

                  if ($success = $recordModel->isEditable()) {

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

              return $success;

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

                  $queryGenerator->addNativeCondition([

      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

              $moduleModel = $this->getModule();

      Line exceeds 120 characters; contains 151 characters
      Open

                  $item['end'] = DateTimeField::convertToUserTimeZone($record['date_end'])->format('Y-m-d') . ' ' . $dateTimeInstance->getFullcalenderTime();

      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

           * Function to get type of calendars.

      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 \App\Db\Query

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

                  foreach ($this->get('filters') as $filter) {

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

                      $filterClassName = Vtiger_Loader::getComponentClassName('CalendarFilter', $filter['name'], $this->getModuleName());

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

              if ($conditions) {

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

          public function getEntity()

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

          {

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

                  $item['end_display'] = $dateTimeInstance->getDisplayDateTimeValue();

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

                  \App\Log::error($e->__toString());

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

              } elseif ('history' == $this->get('time')) {

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

                          ['>=', 'u_yf_occurrences.date_start', $dbStartDateTime],

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

                          ['<=', 'u_yf_occurrences.date_end', $dbEndDateTime],

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

                  ]);

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

                  $selectedUsers = $this->get('user');

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

                      $recordModel->save();

      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

                          $query->andWhere($conditions);

      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->andWhere(array_merge(['or'], $conditions));

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

                  $item['id'] = $record['id'];

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

          public function getCalendarTypes()

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

              } catch (Exception $e) {

      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(['id', 'date_start', 'date_end', 'occurrences_type', 'occurrences_status', 'topic', '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

                  }

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

           *

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

                  $item['start_display'] = $dateTimeInstance->getDisplayDateTimeValue();

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

                  $queryGenerator->initForCustomViewById($this->get('customFilter'));

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

              if ('current' == $this->get('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

                          'and',

      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

                  $dateTimeInstance = new DateTimeField($record['date_end']);

      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

                  $result[] = $item;

      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

              if ($this->has('filters')) {

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

              $query->orderBy(['u_yf_occurrences.date_start' => SORT_ASC]);

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

                  $item['start'] = DateTimeField::convertToUserTimeZone($record['date_start'])->format('Y-m-d') . ' ' . $dateTimeInstance->getFullcalenderTime();

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

                      $item['url'] = 'index.php?module=' . $this->getModuleName() . '&view=Detail&record=' . $record['id'];

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

              return $result;

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

              if ($this->get('start') && $this->get('end')) {

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

                  $dbEndDateTime = $dbEndDateObject->format('Y-m-d H:i:s');

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

                      [

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

                          ['>', 'u_yf_occurrences.date_end', $dbEndDate],

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

                      $conditions[] = ['vtiger_crmentity.crmid' => $subQuery];

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

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

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

                  $item['title'] = \App\Purifier::encodeHtml($record['topic']);

      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

              }

      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 ($this->has('customFilter')) {

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

                          ['<', 'u_yf_occurrences.date_start', $dbStartDate],

      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 ('all' !== $selectedIds[0]) {

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

                      $conditions[] = ['vtiger_crmentity.smownerid' => $selectedIds];

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

                  if ($isSummaryViewSupported) {

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

                      $item['className'] .= ' js-show-modal';

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

                      $item['url'] = $moduleModel->getDetailViewUrl($record['id']);

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

          /** {@inheritdoc} */

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

                      $success = true;

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

      Line exceeds 120 characters; contains 140 characters
      Open

              $queryGenerator->setFields(['id', 'date_start', 'date_end', 'occurrences_type', 'occurrences_status', 'topic', 'assigned_user_id']);

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

              if (!$this->isEmpty('types')) {

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

                      'or',

      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

              try {

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

                      $recordModel->set('date_start', App\Fields\DateTime::formatToDb($start));

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

      class Occurrences_Calendar_Model extends Vtiger_Calendar_Model

      There are no issues that match your filters.

      Category
      Status