Merged in feature/PMCORE-2396 (pull request #7586)
PMCORE-2396 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
7753270b92
@@ -34,7 +34,8 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_DATA' => ''
|
||||
'DEL_DATA' => '',
|
||||
'DEL_TITLE' => $faker->word()
|
||||
];
|
||||
});
|
||||
|
||||
@@ -73,7 +74,8 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_DATA' => ''
|
||||
'DEL_DATA' => '',
|
||||
'DEL_TITLE' => $faker->word()
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
@@ -277,8 +277,7 @@ class DelegationTest extends TestCase
|
||||
->states('foreign_keys')
|
||||
->create();
|
||||
$title = $delegations->last()
|
||||
->application
|
||||
->APP_TITLE;
|
||||
->DEL_TITLE;
|
||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||
DB::commit();
|
||||
|
||||
@@ -2386,4 +2385,19 @@ class DelegationTest extends TestCase
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the getDeltitle() method
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::getDeltitle()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_get_del_title_method()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->create([
|
||||
'DEL_TITLE' => "test"
|
||||
]);
|
||||
$result = Delegation::getDeltitle($delegation->APP_NUMBER, $delegation->DEL_INDEX);
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals($result, $delegation->DEL_TITLE);
|
||||
}
|
||||
}
|
||||
@@ -4147,14 +4147,16 @@ class Cases
|
||||
$this->getExecuteTriggerProcess($sApplicationUID, 'PAUSED');
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$threadTitle = Delegation::getDeltitle($aData['APP_NUMBER'], $aData['APP_DEL_INDEX']);
|
||||
$data = array(
|
||||
'APP_UID' => $sApplicationUID,
|
||||
'DEL_INDEX' => $iDelegation,
|
||||
'USR_UID' => $sUserUID,
|
||||
'APP_RESTART_DATE' => $sUnpauseDate,
|
||||
'APP_TITLE' => ($appTitle != null) ? $appTitle : $aFields['APP_TITLE']
|
||||
'APP_TITLE' => $threadTitle,
|
||||
);
|
||||
$data = array_merge($aFields, $data);
|
||||
|
||||
$oListPaused = new ListPaused();
|
||||
$oListPaused->create($data);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
@@ -387,7 +387,7 @@ class ListParticipatedLast extends BaseListParticipatedLast implements ListInter
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_NUMBER);
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_TITLE);
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_TITLE);
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_PRO_TITLE);
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_TAS_TITLE);
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_STATUS);
|
||||
@@ -405,7 +405,6 @@ class ListParticipatedLast extends BaseListParticipatedLast implements ListInter
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PRIORITY);
|
||||
$criteria->addSelectColumn(ListParticipatedLastPeer::DEL_THREAD_STATUS);
|
||||
$criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid, Criteria::EQUAL);
|
||||
|
||||
//Check if the user was participated in a specific case
|
||||
if ($appUid != '') {
|
||||
$criteria->add(ListParticipatedLastPeer::APP_UID, $appUid, Criteria::EQUAL);
|
||||
|
||||
@@ -262,10 +262,10 @@ class ListUnassigned extends BaseListUnassigned implements ListInterface
|
||||
'APP_DELEGATION.DEL_TASK_DUE_DATE',
|
||||
'APP_DELEGATION.DEL_PRIORITY',
|
||||
'APP_DELEGATION.DEL_PREVIOUS',
|
||||
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
|
||||
// TASK table
|
||||
'TASK.TAS_TITLE',
|
||||
// APPLICATION table
|
||||
'APPLICATION.APP_TITLE',
|
||||
'APPLICATION.APP_UPDATE_DATE',
|
||||
// PROCESS table
|
||||
'PROCESS.PRO_TITLE'
|
||||
@@ -274,7 +274,7 @@ class ListUnassigned extends BaseListUnassigned implements ListInterface
|
||||
'APP_NUMBER' => 'APP_NUMBER',
|
||||
'DEL_DUE_DATE' => 'DEL_TASK_DUE_DATE',
|
||||
'DEL_DELEGATE_DATE' => 'DEL_DELEGATE_DATE',
|
||||
'APP_TITLE' => 'APP_TITLE',
|
||||
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
|
||||
'APP_PRO_TITLE' => 'PRO_TITLE',
|
||||
'APP_TAS_TITLE' => 'TAS_TITLE',
|
||||
'DEL_PREVIOUS_USR_UID' => 'USR_ID'
|
||||
|
||||
@@ -187,7 +187,7 @@ class Delegation extends Model
|
||||
'APPLICATION.APP_CREATE_DATE',
|
||||
'APPLICATION.APP_FINISH_DATE',
|
||||
'APPLICATION.APP_UPDATE_DATE',
|
||||
'APPLICATION.APP_TITLE',
|
||||
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
|
||||
'APP_DELEGATION.USR_UID',
|
||||
'APP_DELEGATION.TAS_UID',
|
||||
'APP_DELEGATION.USR_ID',
|
||||
@@ -240,12 +240,11 @@ class Delegation extends Model
|
||||
|
||||
// Build the "fulltext" expression
|
||||
$search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"';
|
||||
|
||||
// Searching using "fulltext" index
|
||||
$join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
|
||||
$join->whereRaw("MATCH(APP_DELEGATION.DEL_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
|
||||
} else {
|
||||
// Searching using "like" operator
|
||||
$join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%");
|
||||
$join->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%${search}%");
|
||||
}
|
||||
}
|
||||
// Based on the below, we can further limit the join so that we have a smaller data set based on join criteria
|
||||
@@ -269,7 +268,6 @@ class Delegation extends Model
|
||||
// Don't do anything here, we'll need to do the more advanced where below
|
||||
}
|
||||
});
|
||||
|
||||
// Add join for process, but only for certain scenarios such as category or process
|
||||
if ($category || $process || $sort == 'APP_PRO_TITLE') {
|
||||
$query->join('PROCESS', function ($join) use ($category) {
|
||||
@@ -562,7 +560,7 @@ class Delegation extends Model
|
||||
});
|
||||
|
||||
// Add join clause with APPLICATION table if required
|
||||
if (array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
|
||||
if (array_search('APP_DELEGATION.DEL_TITLE AS APP_TITLE', $selectedColumns) !== false || array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
|
||||
$query1->join('APPLICATION', function ($join) {
|
||||
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
|
||||
});
|
||||
@@ -583,7 +581,7 @@ class Delegation extends Model
|
||||
|
||||
// Build where clause for the text to search
|
||||
if (!empty($textToSearch)) {
|
||||
$query1->where('APPLICATION.APP_TITLE', 'LIKE', "%$textToSearch%")
|
||||
$query1->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%$textToSearch%")
|
||||
->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%")
|
||||
->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
|
||||
}
|
||||
@@ -618,7 +616,7 @@ class Delegation extends Model
|
||||
|
||||
}
|
||||
// Add join clause with APPLICATION table if required
|
||||
if (array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
|
||||
if (array_search('APP_DELEGATION.DEL_TITLE AS APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
|
||||
$query2->join('APPLICATION', function ($join) {
|
||||
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
|
||||
});
|
||||
@@ -639,7 +637,7 @@ class Delegation extends Model
|
||||
|
||||
// Build where clause for the text to search
|
||||
if (!empty($textToSearch)) {
|
||||
$query2->where('APPLICATION.APP_TITLE', 'LIKE', "%$textToSearch%")
|
||||
$query2->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%$textToSearch%")
|
||||
->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%")
|
||||
->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
|
||||
}
|
||||
@@ -902,4 +900,18 @@ class Delegation extends Model
|
||||
|
||||
return $threadTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DEL_TITLE related to DELEGATION table
|
||||
*
|
||||
* @param int $appNumber
|
||||
* @param int $delIndex
|
||||
* @return string
|
||||
*/
|
||||
public static function getDeltitle($appNumber, $delIndex)
|
||||
{
|
||||
$query = Delegation::select(['DEL_TITLE'])->where('APP_NUMBER', $appNumber)->where('DEL_INDEX', $delIndex);
|
||||
$res = $query->first();
|
||||
return $res->DEL_TITLE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user