Function updateRecords
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public function updateRecords()
{
if ($this->isEmpty('id')) {
return [];
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The class RecordNumber has an overall complexity of 60 which is very high. The configured complexity threshold is 50. Open
class RecordNumber extends \App\Base
{
/**
* Instance cache by module id.
*
- Exclude checks
Method updateRecords
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateRecords()
{
if ($this->isEmpty('id')) {
return [];
}
File RecordNumber.php
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App\Fields;
/**
Function getRelatedValue
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function getRelatedValue(bool $reload = false): string
{
if (!isset($this->relatedValue) || $reload) {
$value = [];
preg_match_all('/{{picklist:([a-zA-Z0-9_]+)}}|\$\((\w+) : ([,"\+\#\%\.\=\-\[\]\&\w\s\|\)\(\:]+)\)\$/u', $this->get('prefix') . $this->get('postfix'), $matches);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method updateRecords() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function updateRecords()
{
if ($this->isEmpty('id')) {
return [];
}
- Read upRead up
- Exclude checks
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
The method getRelatedValue has a boolean flag argument $reload, which is a certain sign of a Single Responsibility Principle violation. Open
public function getRelatedValue(bool $reload = false): string
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '250', column '40'). Open
$oldSequences = $sequences = (new \App\Db\Query())->select(['value', 'cur_id'])->from('u_#__modentity_sequences')->where(['tabid' => $this->get('tabid')])->createCommand()->queryAllByGroup();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '68', column '15'). Open
$sql = (new \App\Db\Query())->from('vtiger_modentity_num')->where(['tabid' => $this->get('tabid')])->createCommand()->getRawSql() . ' FOR UPDATE ';
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '54', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_modentity_num')->where(['tabid' => $tabId])->one() ?: [];
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '114', column '17'). Open
$sql = (new \App\Db\Query())->select(['cur_id'])->from('u_#__modentity_sequences')->where(['tabid' => $this->get('tabid'), 'value' => $value])->createCommand()->getRawSql() . ' FOR UPDATE ';
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '236', column '27'). Open
$queryGenerator = new \App\QueryGenerator(\App\Module::getModuleName($this->get('tabid')));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '386', column '57'). Open
return self::$sequenceNumberFieldCache[$tabId] = (new \App\Db\Query())->select(['fieldname', 'columnname', 'tablename'])->from('vtiger_field')
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getRelatedValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value[] = \App\TextParser::getInstanceByModel($this->getRecord())->setGlobalPermissions(false)->setContent($element)->parse()->getContent();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method updateRecords uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$seq = $sequenceNumber++;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Purifier' in method 'getIncrementNumber'. Open
return \App\Purifier::decodeHtml($fullPrefix);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Vtiger_Module_Model' in method 'updateRecords'. Open
$moduleModel = \Vtiger_Module_Model::getInstance($this->get('tabid'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method setNumberSequence uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$data['cur_id'] = $reqNo;
$this->set('cur_id', $reqNo);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getIncrementNumber uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$currentSequenceNumber = $this->get('cur_id');
if ($value) {
$sql = (new \App\Db\Query())->select(['cur_id'])->from('u_#__modentity_sequences')->where(['tabid' => $this->get('tabid'), 'value' => $value])->createCommand()->getRawSql() . ' FOR UPDATE ';
$currentSequenceNumber = \App\Db::getInstance()->createCommand($sql)->queryScalar() ?: 1;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\TextParser' in method 'updateRecords'. Open
if (\App\TextParser::isVaribleToParse($this->get('prefix') . $this->get('postfix'))) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '181', column '7'). Open
public function setNumberSequence(int $reqNo, string $actualSequence)
{
$dbCommand = \App\Db::getInstance()->createCommand();
$data = ['cur_sequence' => $actualSequence];
$this->set('cur_sequence', $actualSequence);
- Read upRead up
- Exclude checks
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\Module' in method 'updateRecords'. Open
$queryGenerator = new \App\QueryGenerator(\App\Module::getModuleName($this->get('tabid')));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'getInstance'. Open
$tabId = \App\Module::getModuleId($tabId);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'updateRecords'. Open
\App\Log::error('Updating Missing Sequence Number FAILED! REASON: Field table and module table mismatching.');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method updateRecords uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
\App\Log::error('Updating Missing Sequence Number FAILED! REASON: Field table and module table mismatching.');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'App\Fields\Picklist' in method 'getPicklistValue'. Open
$values = Picklist::getValues($picklistName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Purifier' in method 'updateRecords'. Open
$dbCommand->update($fieldTable, [$fieldColumn => \App\Purifier::decodeHtml($this->parseNumber($seq))], [$moduleModel->getEntityInstance()->table_index => $recordInfo['id']])
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST)
Open
private static array $instanceCache = [];
- Exclude checks
Avoid excessively long variable names like $currentSequenceNumber. Keep variable name length under 20. Open
$currentSequenceNumber = 1;
- Read upRead up
- Exclude checks
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
Avoid excessively long variable names like $sequenceNumberFieldCache. Keep variable name length under 20. Open
private static array $sequenceNumberFieldCache = [];
- Read upRead up
- Exclude checks
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
Spaces must be used for alignment; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Updates missing numbers of records.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$oldNumber = $sequenceNumber;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('vtiger_modentity_num', ['cur_id' => $sequenceNumber], ['tabid' => $this->get('tabid')])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function updateModuleVariablesSequences($currentId, $conditions = []): void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$conditions['tabid'] = $this->get('tabid');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldTable = $fieldModel->getTableName();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update($fieldTable, [$fieldColumn => \App\Purifier::decodeHtml($this->parseNumber($seq))], [$moduleModel->getEntityInstance()->table_index => $recordInfo['id']])
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return false|string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($fieldModel) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$queryGenerator->setFields(array_keys($queryGenerator->getModuleFields()))->setField('id');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while ($recordInfo = $dataReader->read()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->upsert('u_#__modentity_sequences', ['tabid' => $this->get('tabid'), 'value' => $value, 'cur_id' => $reqNo], ['cur_id' => $reqNo])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function isNewSequence(): bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($fieldTable === $moduleModel->getEntityInstance()->table_name) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$sequenceNumber = $this->get('cur_id');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$moduleModel = \Vtiger_Module_Model::getInstance($this->get('tabid'));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($value && isset($sequences[$value])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($oldNumber != $sequenceNumber) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('u_#__modentity_sequences', ['cur_id' => $num], ['value' => $prefix, 'tabid' => $this->get('tabid')])
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$queryGenerator->permissions = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $returninfo;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($totalCount) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Date function that can be overrided in tests.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this->getRecord()->isNew()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @throws \yii\db\Exception
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldModel = current($moduleModel->getFieldsByUiType(4));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$seq = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$sequences[$value] = 1;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int|null $time
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$returninfo = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader = $queryGenerator->createQuery()->createCommand()->query();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$oldSequences = $sequences = (new \App\Db\Query())->select(['value', 'cur_id'])->from('u_#__modentity_sequences')->where(['tabid' => $this->get('tabid')])->createCommand()->queryAllByGroup();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
++$returninfo['updatedrecords'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $format
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->setRecord($moduleModel->getRecordFromArray($recordInfo));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int $currentId
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldColumn = $fieldModel->getColumnName();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$queryGenerator = new \App\QueryGenerator(\App\Module::getModuleName($this->get('tabid')));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$queryGenerator->setFields([$picklistName, $fieldModel->getName(), 'id']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$queryGenerator->addNativeCondition(['or', [$fieldColumn => ''], [$fieldColumn => null]]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$returninfo['updatedrecords'] = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::error('Updating Missing Sequence Number FAILED! REASON: Field table and module table mismatching.');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('vtiger_modentity_num', $data, ['tabid' => $this->get('tabid')])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
|| ($this->getRelatedValue() && $this->getRelatedValue() !== (clone $this)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function updateRecords()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (\App\TextParser::isVaribleToParse($this->get('prefix') . $this->get('postfix'))) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$seq = $sequences[$value]++;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->upsert('u_#__modentity_sequences', ['tabid' => $this->get('tabid'), 'value' => $value, 'cur_id' => $reqNo], ['cur_id' => $reqNo])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach (array_diff($sequences, $oldSequences) as $prefix => $num) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($this->isEmpty('id')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$picklistName = $this->getPicklistName();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$seq = $sequenceNumber++;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function to check if record need a new number of sequence.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$seq = $sequences[$value]++;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function date($format, $time = null)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currentSeqId = static::date('Y');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getSequenceNumberFieldName(int $tabId)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return self::$sequenceNumberFieldCache[$tabId] = (new \App\Db\Query())->select(['fieldname', 'columnname', 'tablename'])->from('vtiger_field')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($tabId) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->setRecord((clone $this->getRecord())->getInstanceByEntity($this->getRecord()->getEntity(), $this->getRecord()->getId()))->getRelatedValue(true));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} elseif ($value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$time = time();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return int
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $dbCommand->insert('vtiger_modentity_num', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
unset(self::$sequenceNumberFieldCache[$tabId]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (null === $recordValue) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->set('cur_id', $reqNo);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Update module variables sequences.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->update('u_#__modentity_sequences', ['cur_id' => $currentId], $conditions)->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$returninfo['totalrecords'] = $totalCount;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = $this->getRelatedValue(true);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Saves configuration.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'postfix' => $this->get('postfix') ?: '',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int $tabId
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get sequence number that should be saved.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
switch ($resetSequence) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case 'Y':
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where(['tabid' => $tabId, 'uitype' => 4, 'presence' => [0, 2]])->one();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currentSeqId = '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'prefix' => $this->get('prefix'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $dbCommand->update(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
['tabid' => $this->get('tabid')]
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get sequence number field name.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (isset(self::$sequenceNumberFieldCache[$tabId])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'cur_sequence' => $this->get('cur_sequence'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'prefix' => $this->get('prefix'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (null === $time) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currentSeqId = static::date('Ymd'); // same as above because 2016-10-03 (03) === 2016-11-03 (03)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $currentSeqId;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($this->isEmpty('id')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'tabid' => $this->get('tabid'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$data['cur_id'] = $reqNo;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param array $conditions
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$totalCount = $dataReader->count();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currentSeqId = static::date('Ym'); // with year because 2016-10 (10) === 2017-10 (10) and number will be incremented but should be set to 1 (new year)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case 'D':
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function save()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'leading_zeros' => $this->get('leading_zeros'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int $tabId
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return self::$sequenceNumberFieldCache[$tabId];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$sequenceNumberFieldCache = null;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string|bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get sequence number field.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private function getPicklistName(): string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $matches[1] ?? '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Returns prefix of picklist.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $picklistName
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return date($format, $time);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'reset_sequence' => $this->get('reset_sequence'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getSequenceNumberField(int $tabId)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private function getPicklistValue(string $picklistName, ?string $recordValue = null): string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($values as $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($recordValue === $value[$picklistName]) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Returns name of picklist. Postfix or prefix can contains name of picklist.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $resetSequence one character
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getSequenceNumber($resetSequence): string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @throws \yii\db\Exception
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'cur_sequence' => $this->get('cur_sequence'), ],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
preg_match('/{{picklist:([a-z0-9_]+)}}/i', $this->get('prefix') . $this->get('postfix'), $matches);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string|null $recordValue
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'reset_sequence' => $this->get('reset_sequence'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
[
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function cleanSequenceNumberFieldCache(?int $tabId)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'cur_id' => $this->get('cur_id'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return self::getSequenceNumberField($tabId)['fieldname'] ?? '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int|null $tabId
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordValue = $this->getRecord()->get($picklistName);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $value['prefix'] ?? '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'leading_zeros' => $this->get('leading_zeros') ?: 0,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'start_id' => $this->get('cur_id'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'cur_id' => $this->get('cur_id'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'postfix' => $this->get('postfix'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string[]|bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Clean sequence number field cache.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$values = Picklist::getValues($picklistName);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case 'M':
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_modentity_num',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Instance cache by module id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->getNumDataForUpdate();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new static();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$actualSequence = static::getSequenceNumber($this->get('reset_sequence'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value[] = $this->getPicklistValue($matches[1][$key]);
- Exclude checks
Line exceeds 120 characters; contains 165 characters Open
$value[] = \App\TextParser::getInstanceByModel($this->getRecord())->setGlobalPermissions(false)->setContent($element)->parse()->getContent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sequence number field cache by module id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_numeric($tabId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getNumDataForUpdate()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sql = (new \App\Db\Query())->from('vtiger_modentity_num')->where(['tabid' => $this->get('tabid')])->createCommand()->getRawSql() . ' FOR UPDATE ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->setData(array_merge($this->getData(), $row));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->get('reset_sequence') && $this->get('cur_sequence') !== $actualSequence) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->relatedValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['tabid'] = $tabId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->setData($row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setRecord(\Vtiger_Record_Model $recordModel): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Vtiger_Record_Model|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRecord(): ?\Vtiger_Record_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setNumberSequence($reqNo, $actualSequence);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fullPrefix = $this->parseNumber($currentSequenceNumber);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRelatedValue(bool $reload = false): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match_all('/{{picklist:([a-zA-Z0-9_]+)}}|\$\((\w+) : ([,"\+\#\%\.\=\-\[\]\&\w\s\|\)\(\:]+)\)\$/u', $this->get('prefix') . $this->get('postfix'), $matches);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var \App\Fields\RecordNumber[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tabId = \App\Module::getModuleId($tabId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$instanceCache[$tabId])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$instanceCache[$tabId];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentSequenceNumber = $this->get('cur_id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->relatedValue) || $reload) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($matches[0] as $key => $element) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Related value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$instanceCache[$tabId] = $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns model of record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('recordModel');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('vtiger_modentity_num')->where(['tabid' => $tabId])->one() ?: [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentSequenceNumber = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->updateModuleVariablesSequences($currentSequenceNumber);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$reqNo = $currentSequenceNumber + 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $relatedValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['tabid'] = $this->get('tabid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets related value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->getRecord() && !empty($matches[0])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \App\Fields\RecordNumber
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->relatedValue = implode('|', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return preg_replace_callback('/{{picklist:([a-z0-9_]+)}}/i', fn ($matches) => $this->getRecord() ? $this->getPicklistValue($matches[1]) : $matches[1], $string);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sets model of record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 206 characters Open
$sql = (new \App\Db\Query())->select(['cur_id'])->from('u_#__modentity_sequences')->where(['tabid' => $this->get('tabid'), 'value' => $value])->createCommand()->getRawSql() . ' FOR UPDATE ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
return preg_replace_callback('/{{picklist:([a-z0-9_]+)}}/i', fn ($matches) => $this->getRecord() ? $this->getPicklistValue($matches[1]) : $matches[1], $string);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setNumberSequence(int $reqNo, string $actualSequence)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = ['cur_sequence' => $actualSequence];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static array $instanceCache = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
$sql = (new \App\Db\Query())->from('vtiger_modentity_num')->where(['tabid' => $this->get('tabid')])->createCommand()->getRawSql() . ' FOR UPDATE ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $this->getRelatedValue();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentSequenceNumber = \App\Db::getInstance()->createCommand($sql)->queryScalar() ?: 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 172 characters Open
preg_match_all('/{{picklist:([a-zA-Z0-9_]+)}}|\$\((\w+) : ([,"\+\#\%\.\=\-\[\]\&\w\s\|\)\(\:]+)\)\$/u', $this->get('prefix') . $this->get('postfix'), $matches);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$string = str_replace(['{{YYYY}}', '{{YY}}', '{{MM}}', '{{M}}', '{{DD}}', '{{D}}'], [static::date('Y'), static::date('y'), static::date('m'), static::date('n'), static::date('d'), static::date('j')], $this->get('prefix') . str_pad((string) $seq, $this->get('leading_zeros'), '0', STR_PAD_LEFT) . $this->get('postfix'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $reqNo
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = \App\Db::getInstance()->createCommand($sql)->queryOne();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|string $tabId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('recordModel', $recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Purifier::decodeHtml($fullPrefix);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $reload
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $seq
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sql = (new \App\Db\Query())->select(['cur_id'])->from('u_#__modentity_sequences')->where(['tabid' => $this->get('tabid'), 'value' => $value])->createCommand()->getRawSql() . ' FOR UPDATE ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === strpos($element, '{{picklist:')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value[] = \App\TextParser::getInstanceByModel($this->getRecord())->setGlobalPermissions(false)->setContent($element)->parse()->getContent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->getRecord()) {
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
$string = \App\TextParser::getInstanceByModel($this->getRecord())->setGlobalPermissions(false)->setContent($string)->parse()->getContent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sets number of sequence.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
$dbCommand->update('u_#__modentity_sequences', ['cur_id' => $num], ['value' => $prefix, 'tabid' => $this->get('tabid')])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static array $sequenceNumberFieldCache = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstance($tabId): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get data for update.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getIncrementNumber(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
\App\Log::error('Updating Missing Sequence Number FAILED! REASON: Field table and module table mismatching.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the next nuber of record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function parseNumber(int $seq): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($value = $this->getRelatedValue()) {
- Exclude checks
Line exceeds 120 characters; contains 211 characters Open
$oldSequences = $sequences = (new \App\Db\Query())->select(['value', 'cur_id'])->from('u_#__modentity_sequences')->where(['tabid' => $this->get('tabid')])->createCommand()->queryAllByGroup();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \yii\db\Exception
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
\App\Db::getInstance()->createCommand()->update('u_#__modentity_sequences', ['cur_id' => $currentId], $conditions)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $actualSequence
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
$dbCommand->update('vtiger_modentity_num', ['cur_id' => $sequenceNumber], ['tabid' => $this->get('tabid')])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$string = \App\TextParser::getInstanceByModel($this->getRecord())->setGlobalPermissions(false)->setContent($string)->parse()->getContent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->upsert('u_#__modentity_sequences', ['tabid' => $this->get('tabid'), 'value' => $value, 'cur_id' => $reqNo], ['cur_id' => $reqNo])->execute();
- Exclude checks
Line exceeds 120 characters; contains 197 characters Open
$dbCommand->update($fieldTable, [$fieldColumn => \App\Purifier::decodeHtml($this->parseNumber($seq))], [$moduleModel->getEntityInstance()->table_index => $recordInfo['id']])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Parse number based on postfix and prefix.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('cur_sequence', $actualSequence);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
->setRecord((clone $this->getRecord())->getInstanceByEntity($this->getRecord()->getEntity(), $this->getRecord()->getId()))->getRelatedValue(true));
- Exclude checks
Line exceeds 120 characters; contains 167 characters Open
$currentSeqId = static::date('Ym'); // with year because 2016-10 (10) === 2017-10 (10) and number will be incremented but should be set to 1 (new year)
- Exclude checks
Line exceeds 120 characters; contains 327 characters Open
$string = str_replace(['{{YYYY}}', '{{YY}}', '{{MM}}', '{{M}}', '{{DD}}', '{{D}}'], [static::date('Y'), static::date('y'), static::date('m'), static::date('n'), static::date('d'), static::date('j')], $this->get('prefix') . str_pad((string) $seq, $this->get('leading_zeros'), '0', STR_PAD_LEFT) . $this->get('postfix'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 166 characters Open
$dbCommand->upsert('u_#__modentity_sequences', ['tabid' => $this->get('tabid'), 'value' => $value, 'cur_id' => $reqNo], ['cur_id' => $reqNo])->execute();
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
return self::$sequenceNumberFieldCache[$tabId] = (new \App\Db\Query())->select(['fieldname', 'columnname', 'tablename'])->from('vtiger_field')
- Exclude checks
Space before opening parenthesis of function call prohibited Open
return preg_replace_callback('/{{picklist:([a-z0-9_]+)}}/i', fn ($matches) => $this->getRecord() ? $this->getPicklistValue($matches[1]) : $matches[1], $string);
- Exclude checks