PMCORE-3188
This commit is contained in:
@@ -60,6 +60,11 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
|
|||||||
'APP_CUR_USER' => $user->USR_UID
|
'APP_CUR_USER' => $user->USR_UID
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$delegateDate = $faker->dateTime();
|
||||||
|
$initDate = $faker->dateTimeInInterval($delegateDate, '+30 minutes');
|
||||||
|
$riskDate = $faker->dateTimeInInterval($initDate, '+1 day');
|
||||||
|
$taskDueDate = $faker->dateTimeInInterval($riskDate, '+2 day');
|
||||||
|
|
||||||
// Return with default values
|
// Return with default values
|
||||||
return [
|
return [
|
||||||
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
|
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
|
||||||
@@ -74,10 +79,10 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
|
|||||||
'DEL_THREAD' => 1,
|
'DEL_THREAD' => 1,
|
||||||
'DEL_THREAD_STATUS' => 'OPEN',
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
'DEL_PRIORITY' => 3,
|
'DEL_PRIORITY' => 3,
|
||||||
'DEL_DELEGATE_DATE' => $faker->dateTime(),
|
'DEL_DELEGATE_DATE' => $delegateDate,
|
||||||
'DEL_INIT_DATE' => $faker->dateTime(),
|
'DEL_INIT_DATE' => $initDate,
|
||||||
'DEL_TASK_DUE_DATE' => $faker->dateTime(),
|
'DEL_TASK_DUE_DATE' => $taskDueDate,
|
||||||
'DEL_RISK_DATE' => $faker->dateTime(),
|
'DEL_RISK_DATE' => $riskDate,
|
||||||
'DEL_LAST_INDEX' => 1,
|
'DEL_LAST_INDEX' => 1,
|
||||||
'USR_ID' => $user->USR_ID,
|
'USR_ID' => $user->USR_ID,
|
||||||
'PRO_ID' => $process->PRO_ID,
|
'PRO_ID' => $process->PRO_ID,
|
||||||
@@ -138,7 +143,7 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'open', function (Faker $
|
|||||||
$delegateDate = $faker->dateTime();
|
$delegateDate = $faker->dateTime();
|
||||||
$initDate = $faker->dateTimeInInterval($delegateDate, '+30 minutes');
|
$initDate = $faker->dateTimeInInterval($delegateDate, '+30 minutes');
|
||||||
$riskDate = $faker->dateTimeInInterval($initDate, '+1 day');
|
$riskDate = $faker->dateTimeInInterval($initDate, '+1 day');
|
||||||
$taskDueDate = $faker->dateTimeInInterval($riskDate, '+1 day');
|
$taskDueDate = $faker->dateTimeInInterval($riskDate, '+2 day');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'DEL_THREAD_STATUS' => 'OPEN',
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
@@ -156,7 +161,7 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'closed', function (Faker
|
|||||||
$delegateDate = $faker->dateTime();
|
$delegateDate = $faker->dateTime();
|
||||||
$initDate = $faker->dateTimeInInterval($delegateDate, '+30 minutes');
|
$initDate = $faker->dateTimeInInterval($delegateDate, '+30 minutes');
|
||||||
$riskDate = $faker->dateTimeInInterval($initDate, '+1 day');
|
$riskDate = $faker->dateTimeInInterval($initDate, '+1 day');
|
||||||
$taskDueDate = $faker->dateTimeInInterval($riskDate, '+1 day');
|
$taskDueDate = $faker->dateTimeInInterval($riskDate, '+2 day');
|
||||||
$finishDate = $faker->dateTimeInInterval($initDate, '+10 days');
|
$finishDate = $faker->dateTimeInInterval($initDate, '+10 days');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class EmailServerAjaxTest extends TestCase
|
|||||||
$content = $this->requireOnceForEmailServerAjax();
|
$content = $this->requireOnceForEmailServerAjax();
|
||||||
$data = json_decode($content, JSON_OBJECT_AS_ARRAY);
|
$data = json_decode($content, JSON_OBJECT_AS_ARRAY);
|
||||||
|
|
||||||
$this->assertContains(200, $data);
|
$this->assertContains(500, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -426,6 +426,42 @@ class DelegationTest extends TestCase
|
|||||||
$this->assertCount(1, $table->dueTo($table->DEL_TASK_DUE_DATE)->get());
|
$this->assertCount(1, $table->dueTo($table->DEL_TASK_DUE_DATE)->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeOnTime
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeOnTime()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_on_time()
|
||||||
|
{
|
||||||
|
$table = factory(Delegation::class)->states('closed')->create();
|
||||||
|
$this->assertCount(1, $table->onTime($table->DEL_DELEGATE_DATE)->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeAtRisk
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeAtRisk()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_at_risk()
|
||||||
|
{
|
||||||
|
$table = factory(Delegation::class)->states('closed')->create();
|
||||||
|
$this->assertCount(1, $table->atRisk($table->DEL_DELEGATE_DATE)->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeOverdue
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeOverdue()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_overdue()
|
||||||
|
{
|
||||||
|
$table = factory(Delegation::class)->states('closed')->create();
|
||||||
|
$this->assertCount(1, $table->overdue($table->DEL_DELEGATE_DATE)->get());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test scopeCase
|
* This test scopeCase
|
||||||
*
|
*
|
||||||
@@ -3196,6 +3232,28 @@ class DelegationTest extends TestCase
|
|||||||
$this->assertNotEmpty($result);
|
$this->assertNotEmpty($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This check the return of thread info
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::getDatesFromThread()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_get_thread_dates()
|
||||||
|
{
|
||||||
|
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||||
|
$task = new Task();
|
||||||
|
$taskInfo = $task->load($delegation->TAS_UID);
|
||||||
|
$taskInfo = head($taskInfo);
|
||||||
|
$taskType = $taskInfo['TAS_TYPE'];
|
||||||
|
$result = Delegation::getDatesFromThread(
|
||||||
|
$delegation->APP_UID,
|
||||||
|
$delegation->DEL_INDEX,
|
||||||
|
$delegation->TAS_UID,
|
||||||
|
$taskType
|
||||||
|
);
|
||||||
|
$this->assertNotEmpty($result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This check the return of pending threads
|
* This check the return of pending threads
|
||||||
*
|
*
|
||||||
@@ -3207,6 +3265,8 @@ class DelegationTest extends TestCase
|
|||||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||||
$result = Delegation::getPendingThreads($delegation->APP_NUMBER);
|
$result = Delegation::getPendingThreads($delegation->APP_NUMBER);
|
||||||
$this->assertNotEmpty($result);
|
$this->assertNotEmpty($result);
|
||||||
|
$result = Delegation::getPendingThreads($delegation->APP_NUMBER, false);
|
||||||
|
$this->assertNotEmpty($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3283,9 +3343,9 @@ class DelegationTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$res = Delegation::hasActiveParentsCases($parents);
|
$res = Delegation::hasActiveParentsCases($parents);
|
||||||
|
|
||||||
// Assert the result is true
|
|
||||||
$this->assertTrue($res);
|
$this->assertTrue($res);
|
||||||
|
$res = Delegation::hasActiveParentsCases([]);
|
||||||
|
$this->assertFalse($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3296,9 +3356,9 @@ class DelegationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_get_cases_completed_by_specific_user()
|
public function it_get_cases_completed_by_specific_user()
|
||||||
{
|
{
|
||||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
$delegation = factory(Delegation::class)->states('last_thread')->create();
|
||||||
$result = Delegation::casesCompletedBy($delegation->USR_ID);
|
$result = Delegation::casesCompletedBy($delegation->USR_ID);
|
||||||
$this->assertEmpty($result);
|
$this->assertNotEmpty($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -799,36 +799,40 @@ class Calendar extends CalendarDefinition
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate date adding a duration, will considerate the calendar
|
||||||
|
*
|
||||||
|
* @param string $initialDate
|
||||||
/**************SLA classes***************/
|
* @param string $duration
|
||||||
public function dashCalculateDate ($iniDate, $duration, $formatDuration, $calendarData = array())
|
* @param string $formatDuration
|
||||||
|
* @param array $calendarData
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function dashCalculateDate($initialDate, $duration, $formatDuration, $calendarData = [])
|
||||||
{
|
{
|
||||||
if ( G::toUpper($formatDuration) == 'DAYS' ) {
|
if (G::toUpper($formatDuration) == 'DAYS') {
|
||||||
$duration = $duration*$calendarData['HOURS_FOR_DAY'];
|
$duration = $duration * $calendarData['HOURS_FOR_DAY'];
|
||||||
}
|
}
|
||||||
if ( G::toUpper($formatDuration) == 'MINUTES' ) {
|
if (G::toUpper($formatDuration) == 'MINUTES') {
|
||||||
$duration = $duration/60;
|
$duration = $duration / 60;
|
||||||
}
|
}
|
||||||
$hoursDuration = (float)$duration;
|
$hoursDuration = (float)$duration;
|
||||||
$newDate = $iniDate;
|
$newDate = $initialDate;
|
||||||
|
|
||||||
while ($hoursDuration > 0) {
|
while ($hoursDuration > 0) {
|
||||||
$newDate = $this->dashGetIniDate($newDate, $calendarData);
|
$newDate = $this->dashGetIniDate($newDate, $calendarData);
|
||||||
|
|
||||||
$rangeWorkHour = $this->dashGetRangeWorkHours($newDate, $calendarData['BUSINESS_DAY']);
|
$rangeWorkHour = $this->dashGetRangeWorkHours($newDate, $calendarData['BUSINESS_DAY']);
|
||||||
$onlyDate = (date('Y-m-d',strtotime($newDate))) . ' ' . $rangeWorkHour['END'];
|
$onlyDate = (date('Y-m-d', strtotime($newDate))) . ' ' . $rangeWorkHour['END'];
|
||||||
|
$rangeWorkHourTotal = (float)$rangeWorkHour['TOTAL'];
|
||||||
if ( (((float)$hoursDuration) >= ((float)$rangeWorkHour['TOTAL'])) ||
|
if ($hoursDuration >= $rangeWorkHourTotal ||
|
||||||
((strtotime($onlyDate) - strtotime($newDate)) < (((float)$hoursDuration)*3600))
|
((strtotime($onlyDate) - strtotime($newDate)) < (($hoursDuration) * 3600))
|
||||||
) {
|
) {
|
||||||
$secondRes = (float)(strtotime($onlyDate) - strtotime($newDate));
|
$secondRes = (float)(strtotime($onlyDate) - strtotime($newDate));
|
||||||
$newDate = $onlyDate;
|
$newDate = $onlyDate;
|
||||||
$hoursDuration -= (float)($secondRes/3600);
|
$hoursDuration -= (float)($secondRes / 3600);
|
||||||
} else {
|
} else {
|
||||||
$newDate = date('Y-m-d H:i:s', strtotime('+' . round((((float)$hoursDuration)*3600), 5) . ' seconds', strtotime($newDate)));
|
$newDate = date('Y-m-d H:i:s', strtotime('+' . round((($hoursDuration) * 3600), 5) . ' seconds', strtotime($newDate)));
|
||||||
$hoursDuration = 0;
|
$hoursDuration = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,22 @@ use ProcessMaker\Plugins\PluginRegistry;
|
|||||||
*/
|
*/
|
||||||
class AppDelegation extends BaseAppDelegation
|
class AppDelegation extends BaseAppDelegation
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get the risk value
|
||||||
|
*
|
||||||
|
* @return double
|
||||||
|
*/
|
||||||
|
public function getRisk()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$risk = 2;
|
||||||
|
|
||||||
|
return $risk;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get previous delegation (Valid Task)
|
* Get previous delegation (Valid Task)
|
||||||
*
|
*
|
||||||
@@ -91,42 +107,59 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create an application delegation
|
* Create an application delegation
|
||||||
*
|
*
|
||||||
* @param $sProUid process Uid
|
* @param string $proUid process Uid
|
||||||
* @param $sAppUid Application Uid
|
* @param string $appUid Application Uid
|
||||||
* @param $sTasUid Task Uid
|
* @param string $tasUid Task Uid
|
||||||
* @param $sUsrUid User Uid
|
* @param string $usrUid User Uid
|
||||||
* @param $iPriority delegation priority
|
* @param int $priority delegation priority
|
||||||
* @param $isSubprocess is a subprocess inside a process?
|
* @param bool $isSubprocess is a subprocess inside a process?
|
||||||
* @return delegation index of the application delegation.
|
*
|
||||||
|
* @return int index of the application delegation.
|
||||||
*/
|
*/
|
||||||
public function createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null, $flagControl = false, $flagControlMulInstance = false, $delPrevious = 0, $appNumber = 0, $taskId = 0, $userId = 0, $proId = 0)
|
public function createAppDelegation(
|
||||||
{
|
$proUid,
|
||||||
if (! isset($sProUid) || strlen($sProUid) == 0) {
|
$appUid,
|
||||||
throw (new Exception('Column "PRO_UID" cannot be null.'));
|
$tasUid,
|
||||||
|
$usrUid,
|
||||||
|
$sAppThread,
|
||||||
|
$priority = 3,
|
||||||
|
$isSubprocess = false,
|
||||||
|
$previous = -1,
|
||||||
|
$nextTasParam = null,
|
||||||
|
$flagControl = false,
|
||||||
|
$flagControlMulInstance = false,
|
||||||
|
$delPrevious = 0,
|
||||||
|
$appNumber = 0,
|
||||||
|
$taskId = 0,
|
||||||
|
$userId = 0,
|
||||||
|
$proId = 0
|
||||||
|
){
|
||||||
|
if (! isset($proUid) || strlen($proUid) == 0) {
|
||||||
|
throw new Exception('Column "PRO_UID" cannot be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($sAppUid) || strlen($sAppUid) == 0) {
|
if (! isset($appUid) || strlen($appUid) == 0) {
|
||||||
throw (new Exception('Column "APP_UID" cannot be null.'));
|
throw new Exception('Column "APP_UID" cannot be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($sTasUid) || strlen($sTasUid) == 0) {
|
if (! isset($tasUid) || strlen($tasUid) == 0) {
|
||||||
throw (new Exception('Column "TAS_UID" cannot be null.'));
|
throw new Exception('Column "TAS_UID" cannot be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($sUsrUid) /*|| strlen($sUsrUid ) == 0*/) {
|
if (! isset($usrUid)) {
|
||||||
throw (new Exception('Column "USR_UID" cannot be null.'));
|
throw new Exception('Column "USR_UID" cannot be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($sAppThread) || strlen($sAppThread) == 0) {
|
if (! isset($sAppThread) || strlen($sAppThread) == 0) {
|
||||||
throw (new Exception('Column "APP_THREAD" cannot be null.'));
|
throw new Exception('Column "APP_THREAD" cannot be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->delegation_id = null;
|
$this->delegation_id = null;
|
||||||
//Get max DEL_INDEX
|
// Get max DEL_INDEX
|
||||||
$criteria = new Criteria("workflow");
|
$criteria = new Criteria("workflow");
|
||||||
$criteria->add(AppDelegationPeer::APP_UID, $sAppUid);
|
$criteria->add(AppDelegationPeer::APP_UID, $appUid);
|
||||||
$criteria->add(AppDelegationPeer::DEL_LAST_INDEX, 1);
|
$criteria->add(AppDelegationPeer::DEL_LAST_INDEX, 1);
|
||||||
$criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
$criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
||||||
|
|
||||||
@@ -136,8 +169,8 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
$delIndex = 1;
|
$delIndex = 1;
|
||||||
$delPreviusUsrUid = $sUsrUid;
|
$delPreviusUsrUid = $usrUid;
|
||||||
$delPreviousFather = $sPrevious;
|
$delPreviousFather = $previous;
|
||||||
if ($rs->next()) {
|
if ($rs->next()) {
|
||||||
$row = $rs->getRow();
|
$row = $rs->getRow();
|
||||||
|
|
||||||
@@ -149,7 +182,7 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
|
|
||||||
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||||
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||||
$criteriaDelIndex->add(AppDelegationPeer::APP_UID, $sAppUid);
|
$criteriaDelIndex->add(AppDelegationPeer::APP_UID, $appUid);
|
||||||
$criteriaDelIndex->addDescendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
$criteriaDelIndex->addDescendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||||
|
|
||||||
$rsCriteriaDelIndex = AppDelegationPeer::doSelectRS($criteriaDelIndex);
|
$rsCriteriaDelIndex = AppDelegationPeer::doSelectRS($criteriaDelIndex);
|
||||||
@@ -161,23 +194,23 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
$delIndex = (isset($row["DEL_INDEX"]))? $row["DEL_INDEX"] + 1 : 1;
|
$delIndex = (isset($row["DEL_INDEX"]))? $row["DEL_INDEX"] + 1 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Verify successors: parrallel submit in the same time
|
// Verify successors: parallel submit in the same time
|
||||||
if ($flagControl) {
|
if ($flagControl) {
|
||||||
$nextTaskUid = $sTasUid;
|
$nextTaskUid = $tasUid;
|
||||||
$index = $this->getAllTasksBeforeSecJoin($nextTaskUid, $sAppUid, $delPreviousFather);
|
$index = $this->getAllTasksBeforeSecJoin($nextTaskUid, $appUid, $delPreviousFather);
|
||||||
if ($this->createThread($index, $sAppUid)) {
|
if ($this->createThread($index, $appUid)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($flagControlMulInstance) {
|
if ($flagControlMulInstance) {
|
||||||
$nextTaskUid = $sTasUid;
|
$nextTaskUid = $tasUid;
|
||||||
$index = $this->getAllTheardMultipleInstance($delPreviousFather, $sAppUid);
|
$index = $this->getAllTheardMultipleInstance($delPreviousFather, $appUid);
|
||||||
if ($this->createThread($index, $sAppUid, $sUsrUid)) {
|
if ($this->createThread($index, $appUid, $usrUid)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update set
|
// Update set
|
||||||
$criteriaUpdate = new Criteria('workflow');
|
$criteriaUpdate = new Criteria('workflow');
|
||||||
$criteriaUpdate->add(AppDelegationPeer::DEL_LAST_INDEX, 0);
|
$criteriaUpdate->add(AppDelegationPeer::DEL_LAST_INDEX, 0);
|
||||||
BasePeer::doUpdate($criteria, $criteriaUpdate, Propel::getConnection('workflow'));
|
BasePeer::doUpdate($criteria, $criteriaUpdate, Propel::getConnection('workflow'));
|
||||||
@@ -185,15 +218,15 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
// Define the status of the thread, if is subprocess we need to CLOSED the thread
|
// Define the status of the thread, if is subprocess we need to CLOSED the thread
|
||||||
$theadStatus = !$isSubprocess ? 'OPEN' : 'CLOSED';
|
$theadStatus = !$isSubprocess ? 'OPEN' : 'CLOSED';
|
||||||
|
|
||||||
$this->setAppUid($sAppUid);
|
$this->setAppUid($appUid);
|
||||||
$this->setProUid($sProUid);
|
$this->setProUid($proUid);
|
||||||
$this->setTasUid($sTasUid);
|
$this->setTasUid($tasUid);
|
||||||
$this->setDelIndex($delIndex);
|
$this->setDelIndex($delIndex);
|
||||||
$this->setDelLastIndex(1);
|
$this->setDelLastIndex(1);
|
||||||
$this->setDelPrevious($sPrevious == - 1 ? 0 : $sPrevious);
|
$this->setDelPrevious($previous == - 1 ? 0 : $previous);
|
||||||
$this->setUsrUid($sUsrUid);
|
$this->setUsrUid($usrUid);
|
||||||
$this->setDelType('NORMAL');
|
$this->setDelType('NORMAL');
|
||||||
$this->setDelPriority(($iPriority != '' ? $iPriority : '3'));
|
$this->setDelPriority(($priority != '' ? $priority : '3'));
|
||||||
$this->setDelThread($sAppThread);
|
$this->setDelThread($sAppThread);
|
||||||
$this->setDelThreadStatus($theadStatus);
|
$this->setDelThreadStatus($theadStatus);
|
||||||
$this->setDelThreadStatusId(Delegation::$thread_status[$theadStatus]);
|
$this->setDelThreadStatusId(Delegation::$thread_status[$theadStatus]);
|
||||||
@@ -203,24 +236,22 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
$this->setUsrId($userId);
|
$this->setUsrId($userId);
|
||||||
$this->setProId($proId);
|
$this->setProId($proId);
|
||||||
|
|
||||||
//The function return an array now. By JHL
|
// The function return an array now. By JHL
|
||||||
$delTaskDueDate = $this->calculateDueDate($sNextTasParam);
|
$delTaskDueDate = $this->calculateDueDate($nextTasParam);
|
||||||
$delRiskDate = $this->calculateRiskDate($sNextTasParam, $this->getRisk());
|
$delRiskDate = $this->calculateRiskDate($nextTasParam, $this->getRisk());
|
||||||
|
|
||||||
//$this->setDelTaskDueDate( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
|
|
||||||
$this->setDelTaskDueDate($delTaskDueDate);
|
$this->setDelTaskDueDate($delTaskDueDate);
|
||||||
$this->setDelRiskDate($delRiskDate);
|
$this->setDelRiskDate($delRiskDate);
|
||||||
|
|
||||||
if ((defined("DEBUG_CALENDAR_LOG")) && (DEBUG_CALENDAR_LOG)) {
|
if ((defined("DEBUG_CALENDAR_LOG")) && (DEBUG_CALENDAR_LOG)) {
|
||||||
//$this->setDelData( $delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
|
// Log of actions made by Calendar Engine
|
||||||
$this->setDelData($delTaskDueDate);
|
$this->setDelData($delTaskDueDate);
|
||||||
} else {
|
} else {
|
||||||
$this->setDelData('');
|
$this->setDelData('');
|
||||||
}
|
}
|
||||||
|
|
||||||
// this condition assures that an internal delegation like a subprocess dont have an initial date setted
|
// This condition assures that an internal delegation like a subprocess don't have an initial date set
|
||||||
if ($delIndex == 1 && ! $isSubprocess) {
|
if ($delIndex == 1 && ! $isSubprocess) {
|
||||||
//the first delegation, init date this should be now for draft applications, in other cases, should be null.
|
// The first delegation, init date this should be now for draft applications, in other cases, should be null.
|
||||||
$this->setDelInitDate('now');
|
$this->setDelInitDate('now');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,16 +278,16 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
$bpmn = new \ProcessMaker\Project\Bpmn();
|
$bpmn = new \ProcessMaker\Project\Bpmn();
|
||||||
$flagActionsByEmail = true;
|
$flagActionsByEmail = true;
|
||||||
|
|
||||||
$arrayAppDelegationPrevious = $this->getPreviousDelegationValidTask($sAppUid, $delIndex);
|
$arrayAppDelegationPrevious = $this->getPreviousDelegationValidTask($appUid, $delIndex);
|
||||||
|
|
||||||
$data = new stdclass();
|
$data = new stdclass();
|
||||||
$data->TAS_UID = $sTasUid;
|
$data->TAS_UID = $tasUid;
|
||||||
$data->APP_UID = $sAppUid;
|
$data->APP_UID = $appUid;
|
||||||
$data->DEL_INDEX = $delIndex;
|
$data->DEL_INDEX = $delIndex;
|
||||||
$data->USR_UID = $sUsrUid;
|
$data->USR_UID = $usrUid;
|
||||||
$data->PREVIOUS_USR_UID = ($arrayAppDelegationPrevious !== false)? $arrayAppDelegationPrevious['USR_UID'] : $delPreviusUsrUid;
|
$data->PREVIOUS_USR_UID = ($arrayAppDelegationPrevious !== false)? $arrayAppDelegationPrevious['USR_UID'] : $delPreviusUsrUid;
|
||||||
|
|
||||||
if ($bpmn->exists($sProUid)) {
|
if ($bpmn->exists($proUid)) {
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
// this section evaluates the actions by email trigger execution please
|
// this section evaluates the actions by email trigger execution please
|
||||||
// modify this section carefully, the if evaluation checks if the license has been
|
// modify this section carefully, the if evaluation checks if the license has been
|
||||||
@@ -265,8 +296,8 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
::getSingleton()
|
::getSingleton()
|
||||||
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
|
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
|
||||||
$criteriaAbe = new Criteria();
|
$criteriaAbe = new Criteria();
|
||||||
$criteriaAbe->add(AbeConfigurationPeer::PRO_UID, $sProUid);
|
$criteriaAbe->add(AbeConfigurationPeer::PRO_UID, $proUid);
|
||||||
$criteriaAbe->add(AbeConfigurationPeer::TAS_UID, $sTasUid);
|
$criteriaAbe->add(AbeConfigurationPeer::TAS_UID, $tasUid);
|
||||||
$resultAbe = AbeConfigurationPeer::doSelectRS($criteriaAbe);
|
$resultAbe = AbeConfigurationPeer::doSelectRS($criteriaAbe);
|
||||||
$resultAbe->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$resultAbe->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
if ($resultAbe->next()) {
|
if ($resultAbe->next()) {
|
||||||
@@ -289,7 +320,7 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
$pmGoogle = new PmGoogleApi();
|
$pmGoogle = new PmGoogleApi();
|
||||||
if ($pmGoogle->getServiceGmailStatus()) {
|
if ($pmGoogle->getServiceGmailStatus()) {
|
||||||
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
||||||
$Pmgmail->gmailsForRouting($sUsrUid, $sTasUid, $sAppUid, $delIndex, $isSubprocess);
|
$Pmgmail->gmailsForRouting($usrUid, $tasUid, $appUid, $delIndex, $isSubprocess);
|
||||||
}
|
}
|
||||||
} catch (Exception $oError) {
|
} catch (Exception $oError) {
|
||||||
error_log($oError->getMessage());
|
error_log($oError->getMessage());
|
||||||
@@ -299,8 +330,8 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($flagActionsByEmail) {
|
if ($flagActionsByEmail) {
|
||||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
$pluginRegistry = PluginRegistry::loadSingleton();
|
||||||
$oPluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
|
$pluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,30 +505,38 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
//Calendar - Use the dates class to calculate dates
|
//Calendar - Use the dates class to calculate dates
|
||||||
$calendar = new Calendar();
|
$calendar = new Calendar();
|
||||||
|
|
||||||
$arrayCalendarData = $calendar->getCalendarData($aCalendarUID);
|
$calendarData = $calendar->getCalendarData($aCalendarUID);
|
||||||
|
|
||||||
if ($calendar->pmCalendarUid == "") {
|
if ($calendar->pmCalendarUid == "") {
|
||||||
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
|
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
|
||||||
|
|
||||||
$arrayCalendarData = $calendar->getCalendarData();
|
$calendarData = $calendar->getCalendarData();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Due date
|
//Due date
|
||||||
$initDate = $this->getDelDelegateDate();
|
$initDate = $this->getDelDelegateDate();
|
||||||
$timeZone = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($initDate);
|
$timeZone = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($initDate);
|
||||||
$dueDate = $calendar->dashCalculateDate($timeZone, $aData["TAS_DURATION"], $aData["TAS_TIMEUNIT"], $arrayCalendarData);
|
$dueDate = $calendar->dashCalculateDate($timeZone, $aData["TAS_DURATION"], $aData["TAS_TIMEUNIT"], $calendarData);
|
||||||
|
|
||||||
$dueDate = \ProcessMaker\Util\DateTime::convertDataToUtc($dueDate);
|
$dueDate = \ProcessMaker\Util\DateTime::convertDataToUtc($dueDate);
|
||||||
return $dueDate;
|
return $dueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculateRiskDate($dueDate, $risk)
|
/**
|
||||||
|
* Calculate the risk date
|
||||||
|
*
|
||||||
|
* @param array $nextTask
|
||||||
|
* @param double $risk
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function calculateRiskDate($nextTask, $risk)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$data = array();
|
$data = [];
|
||||||
if (isset($sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
|
if (isset($nextTask['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $nextTask['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
|
||||||
$data['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
|
$data['TAS_DURATION'] = $nextTask['NEXT_TASK']['TAS_DURATION'];
|
||||||
$data['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
|
$data['TAS_TIMEUNIT'] = $nextTask['NEXT_TASK']['TAS_TIMEUNIT'];
|
||||||
} else {
|
} else {
|
||||||
$task = TaskPeer::retrieveByPK($this->getTasUid());
|
$task = TaskPeer::retrieveByPK($this->getTasUid());
|
||||||
$data['TAS_DURATION'] = $task->getTasDuration();
|
$data['TAS_DURATION'] = $task->getTasDuration();
|
||||||
@@ -506,19 +545,21 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
|
|
||||||
$riskTime = $data['TAS_DURATION'] - ($data['TAS_DURATION'] * $risk);
|
$riskTime = $data['TAS_DURATION'] - ($data['TAS_DURATION'] * $risk);
|
||||||
|
|
||||||
//Calendar - Use the dates class to calculate dates
|
// Calendar - Use the dates class to calculate dates
|
||||||
$calendar = new Calendar();
|
$calendar = new Calendar();
|
||||||
|
$calendarData = [];
|
||||||
$arrayCalendarData = array();
|
if (empty($calendar->pmCalendarUid)) {
|
||||||
|
|
||||||
if ($calendar->pmCalendarUid == "") {
|
|
||||||
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
|
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
|
||||||
|
$calendarData = $calendar->getCalendarData();
|
||||||
$arrayCalendarData = $calendar->getCalendarData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Risk date
|
// Risk date
|
||||||
$riskDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), $riskTime, $data['TAS_TIMEUNIT'], $arrayCalendarData);
|
$riskDate = $calendar->dashCalculateDate(
|
||||||
|
$this->getDelDelegateDate(),
|
||||||
|
$riskTime,
|
||||||
|
$data['TAS_TIMEUNIT'],
|
||||||
|
$calendarData
|
||||||
|
);
|
||||||
|
|
||||||
return $riskDate;
|
return $riskDate;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -526,12 +567,6 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDiffDate($date1, $date2)
|
|
||||||
{
|
|
||||||
return ($date1 - $date2) / (24 * 60 * 60); //days
|
|
||||||
return ($date1 - $date2) / 3600;
|
|
||||||
}
|
|
||||||
|
|
||||||
//usually this function is called when routing in the flow, so by default cron =0
|
//usually this function is called when routing in the flow, so by default cron =0
|
||||||
public function calculateDuration($cron = 0)
|
public function calculateDuration($cron = 0)
|
||||||
{
|
{
|
||||||
@@ -799,8 +834,10 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function get the current user related to the specific case and index
|
* This function get the current user related to the specific case and index
|
||||||
|
*
|
||||||
* @param string $appUid, Uid related to the case
|
* @param string $appUid, Uid related to the case
|
||||||
* @param integer $index, Index to review
|
* @param integer $index, Index to review
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getCurrentUsers($appUid, $index)
|
public static function getCurrentUsers($appUid, $index)
|
||||||
@@ -820,7 +857,8 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
/**
|
/**
|
||||||
* Verify if the current case is already routed.
|
* Verify if the current case is already routed.
|
||||||
*
|
*
|
||||||
* @param string $AppUid the uid of the application
|
* @param string $appUid the uid of the application
|
||||||
|
*
|
||||||
* @return array $Fields the fields
|
* @return array $Fields the fields
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -841,18 +879,6 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRisk()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$risk = 0.2;
|
|
||||||
|
|
||||||
//Return
|
|
||||||
return $risk;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all task before Join Threads
|
* Get all task before Join Threads
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -381,36 +381,39 @@ class Delegation extends Model
|
|||||||
* Scope a query to get only the date on time
|
* Scope a query to get only the date on time
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param string $now
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
public function scopeOnTime($query)
|
public function scopeOnTime($query, $now)
|
||||||
{
|
{
|
||||||
return $query->whereRaw('TIMEDIFF(DEL_RISK_DATE, NOW()) > 0');
|
return $query->where('DEL_RISK_DATE', '>', $now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope a query to get only the date at risk
|
* Scope a query to get only the date at risk
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param string $now
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
public function scopeAtRisk($query)
|
public function scopeAtRisk($query, $now)
|
||||||
{
|
{
|
||||||
return $query->whereRaw('TIMEDIFF(DEL_RISK_DATE, NOW()) < 0 AND TIMEDIFF(DEL_TASK_DUE_DATE, NOW()) > 0');
|
return $query->where('DEL_RISK_DATE', '>=', $now)->where('DEL_TASK_DUE_DATE', '>=', $now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope a query to get only the date overdue
|
* Scope a query to get only the date overdue
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param string $now
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
public function scopeOverdue($query)
|
public function scopeOverdue($query, $now)
|
||||||
{
|
{
|
||||||
return $query->whereRaw('TIMEDIFF(DEL_TASK_DUE_DATE, NOW()) < 0');
|
return $query->where('DEL_TASK_DUE_DATE', '>', $now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user