PMCORE-1884
This commit is contained in:
@@ -744,6 +744,9 @@ class Task extends BaseTask
|
||||
$calendarObj->assignCalendarTo($taskUid, $calendarUid, 'TASK');
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Method deprecated in Release 3.5.x
|
||||
*/
|
||||
public function getDelegatedTaskData($TAS_UID, $APP_UID, $DEL_INDEX)
|
||||
{
|
||||
require_once ('classes/model/AppDelegation.php');
|
||||
|
||||
@@ -5537,6 +5537,12 @@ msgstr "The value '{0}' is not a valid date for the format '{1}'."
|
||||
msgid "Day"
|
||||
msgstr "Day"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_DAY_DAYS
|
||||
#: LABEL/ID_DAY_DAYS
|
||||
msgid "Day(s)"
|
||||
msgstr "Day(s)"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_DAYS
|
||||
#: LABEL/ID_DAYS
|
||||
@@ -9467,6 +9473,12 @@ msgstr "Hour"
|
||||
msgid "Hours"
|
||||
msgstr "Hours"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_HOUR_ABBREVIATE
|
||||
#: LABEL/ID_HOUR_ABBREVIATE
|
||||
msgid "Hr(s)"
|
||||
msgstr "Hr(s)"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_HOUR_HOURS
|
||||
#: LABEL/ID_HOUR_HOURS
|
||||
@@ -18803,6 +18815,12 @@ msgstr "Minimum data required to run the \"Test Connection\": \"Server Address,
|
||||
msgid "[LABEL/ID_MINUTE] Minute"
|
||||
msgstr "Minute"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_MINUTE_ABBREVIATE
|
||||
#: LABEL/ID_MINUTE_ABBREVIATE
|
||||
msgid "min"
|
||||
msgstr "min"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_MINUTES
|
||||
#: LABEL/ID_MINUTES
|
||||
@@ -23603,6 +23621,12 @@ msgstr "Seconds"
|
||||
msgid "Second Graph"
|
||||
msgstr "Second Graph"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_SECOND_ABBREVIATE
|
||||
#: LABEL/ID_SECOND_ABBREVIATE
|
||||
msgid "s"
|
||||
msgstr "s"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_SEE
|
||||
#: LABEL/ID_SEE
|
||||
|
||||
@@ -57744,6 +57744,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_DATE_NOT_VALID','en','The value ''{0}'' is not a valid date for the format ''{1}''.','2014-05-29') ,
|
||||
( 'LABEL','ID_DAY','en','Day','2014-01-15') ,
|
||||
( 'LABEL','ID_DAYS','en','Days','2014-01-15') ,
|
||||
( 'LABEL','ID_DAY_DAYS','en','Day(s)','2020-10-02') ,
|
||||
( 'LABEL','ID_DBCNN_TITLE','en','Checking server configuration','2014-01-15') ,
|
||||
( 'LABEL','ID_DBC_CHECK','en','Checking server parameters','2014-01-15') ,
|
||||
( 'LABEL','ID_DBC_DBNAME_INVALID','en','The database connection with dbs_database_name: ''{0}'' is invalid','2014-10-21') ,
|
||||
@@ -58424,6 +58425,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_HOURLY','en','Hourly','2014-01-15') ,
|
||||
( 'LABEL','ID_HOURLY_AT','en','Hourly at','2014-01-15') ,
|
||||
( 'LABEL','ID_HOURS','en','Hours','2014-01-15') ,
|
||||
( 'LABEL','ID_HOUR_ABBREVIATE','en','Hr(s)','2020-10-02') ,
|
||||
( 'LABEL','ID_HOUR_HOURS','en','Hour(s)','2014-10-30') ,
|
||||
( 'LABEL','ID_HTML','en','HTML','2014-01-15') ,
|
||||
( 'LABEL','ID_IDENTIFIER_IMPORT_USER','en','Identifier for an imported user','2014-01-15') ,
|
||||
@@ -60015,6 +60017,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_MINIMUM_DATA_REQUIRED_TO_RUN_THE','en','Minimum data required to run the "Test Connection": "Server Address, Port, Enabled TLS, Anonymous, Username, Password','2015-09-15') ,
|
||||
( 'LABEL','ID_MINUTE','en','Minute','2014-01-15') ,
|
||||
( 'LABEL','ID_MINUTES','en','Minutes','2014-01-15') ,
|
||||
( 'LABEL','ID_MINUTE_ABBREVIATE','en','min','2020-10-02') ,
|
||||
( 'LABEL','ID_MIN_INDICATOR_DASHBOARD','en','You can not delete more Indicators.','2015-03-31') ,
|
||||
( 'LABEL','ID_MODIFIED','en','Modified','2014-01-15') ,
|
||||
( 'LABEL','ID_MON','en','Mon','2014-01-15') ,
|
||||
@@ -60836,6 +60839,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_SEARCH_XML_METADATA','en','Search XML metadata','2014-01-15') ,
|
||||
( 'LABEL','ID_SECOND','en','Second','2014-01-15') ,
|
||||
( 'LABEL','ID_SECONDS','en','Seconds','2014-01-15') ,
|
||||
( 'LABEL','ID_SECOND_ABBREVIATE','en','s','2020-10-02') ,
|
||||
( 'LABEL','ID_SECOND_FIGURE','en','Second Graph','2015-03-09') ,
|
||||
( 'LABEL','ID_SEE','en','See','2014-01-15') ,
|
||||
( 'LABEL','ID_SEE_FULL_LIST','en','See complete list','2016-02-29') ,
|
||||
|
||||
@@ -5,7 +5,9 @@ use ProcessMaker\BusinessModel\Cases\ChangeLog;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
use ProcessMaker\ChangeLog\ChangeLogResult;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
use ProcessMaker\Model\Task as ModelTask;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Util\DateTime;
|
||||
|
||||
if (!isset($_SESSION['USER_LOGGED'])) {
|
||||
$responseObject = new stdclass();
|
||||
@@ -428,9 +430,9 @@ class Ajax
|
||||
}
|
||||
$taskUid = $arrayTaskUid[0];
|
||||
|
||||
$taskData = $task->getDelegatedTaskData($taskUid, $_SESSION['APPLICATION'], $_SESSION['INDEX']);
|
||||
|
||||
$taskData = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($taskData);
|
||||
$task = new ModelTask();
|
||||
$taskData = $task->information($_SESSION['APPLICATION'], $taskUid, $_SESSION['INDEX']);
|
||||
$taskData = DateTime::convertUtcToTimeZone($taskData);
|
||||
|
||||
print(G::json_encode($taskData));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use DateTime;
|
||||
use G;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -687,4 +688,53 @@ class Delegation extends Model
|
||||
|
||||
return ($query->count() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the thread related to the specific task-index
|
||||
*
|
||||
* @param string $appUid
|
||||
* @param string $delIndex
|
||||
* @param string $tasUid
|
||||
* @param string $taskType
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getDatesFromThread(string $appUid, string $delIndex, string $tasUid, string $taskType)
|
||||
{
|
||||
$query = Delegation::query()->select([
|
||||
'DEL_INIT_DATE',
|
||||
'DEL_DELEGATE_DATE',
|
||||
'DEL_FINISH_DATE',
|
||||
'DEL_RISK_DATE',
|
||||
'DEL_TASK_DUE_DATE'
|
||||
]);
|
||||
$query->where('APP_UID', $appUid);
|
||||
$query->where('DEL_INDEX', $delIndex);
|
||||
$query->where('TAS_UID', $tasUid);
|
||||
$results = $query->get();
|
||||
|
||||
$thread = [];
|
||||
$results->each(function ($item, $key) use (&$thread, $taskType) {
|
||||
$thread = $item->toArray();
|
||||
if (in_array($taskType, Task::$typesRunAutomatically)) {
|
||||
$startDate = $thread['DEL_DELEGATE_DATE'];
|
||||
} else {
|
||||
$startDate = $thread['DEL_INIT_DATE'];
|
||||
}
|
||||
$endDate = $thread['DEL_FINISH_DATE'];
|
||||
// Calculate the task-thread duration
|
||||
if (!empty($startDate) && !empty($endDate)) {
|
||||
$initDate = new DateTime($startDate);
|
||||
$finishDate = new DateTime($endDate);
|
||||
$diff = $initDate->diff($finishDate);
|
||||
$format = ' %a ' . G::LoadTranslation('ID_DAY_DAYS');
|
||||
$format .= ' %H '. G::LoadTranslation('ID_HOUR_ABBREVIATE');
|
||||
$format .= ' %I '. G::LoadTranslation('ID_MINUTE_ABBREVIATE');
|
||||
$format .= ' %S '. G::LoadTranslation('ID_SECOND_ABBREVIATE');
|
||||
$thread['DEL_THREAD_DURATION'] = $diff->format($format);
|
||||
}
|
||||
});
|
||||
|
||||
return $thread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,17 @@ class Task extends Model
|
||||
protected $primaryKey = 'TAS_ID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
// The following types will execute without user and run automatically
|
||||
public static $typesRunAutomatically = [
|
||||
"WEBENTRYEVENT",
|
||||
"END-MESSAGE-EVENT",
|
||||
"START-MESSAGE-EVENT",
|
||||
"INTERMEDIATE-THROW-MESSAGE-EVENT",
|
||||
"INTERMEDIATE-CATCH-MESSAGE-EVENT",
|
||||
"SCRIPT-TASK",
|
||||
"START-TIMER-EVENT",
|
||||
"INTERMEDIATE-CATCH-TIMER-EVENT"
|
||||
];
|
||||
|
||||
public function process()
|
||||
{
|
||||
@@ -67,4 +78,45 @@ class Task extends Model
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task data
|
||||
*
|
||||
* @param string $tasUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function load($tasUid)
|
||||
{
|
||||
$query = Task::query();
|
||||
$query->where('TAS_UID', $tasUid);
|
||||
|
||||
return $query->get()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task thread information
|
||||
*
|
||||
* @param string $appUid
|
||||
* @param string $tasUid
|
||||
* @param string $delIndex
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function information(string $appUid, string $tasUid, string $delIndex)
|
||||
{
|
||||
// Load the the task information
|
||||
$taskInfo = $this->load($tasUid);
|
||||
$taskInfo = head($taskInfo);
|
||||
$taskType = $taskInfo['TAS_TYPE'];
|
||||
// Load the dates related to the thread
|
||||
$dates = Delegation::getDatesFromThread($appUid, $delIndex, $tasUid, $taskType);
|
||||
// Set the dates
|
||||
$taskInfo['INIT_DATE'] = !empty($dates['DEL_INIT_DATE']) ? $dates['DEL_INIT_DATE'] : G::LoadTranslation('ID_CASE_NOT_YET_STARTED');
|
||||
$taskInfo['DUE_DATE'] = !empty($dates['DEL_TASK_DUE_DATE']) ? $dates['DEL_TASK_DUE_DATE'] : G::LoadTranslation('ID_NOT_FINISHED');
|
||||
$taskInfo['FINISH'] = !empty($dates['DEL_FINISH_DATE']) ? $dates['DEL_FINISH_DATE'] : G::LoadTranslation('ID_NOT_FINISHED');
|
||||
$taskInfo['DURATION'] = !empty($dates['DEL_THREAD_DURATION']) ? $dates['DEL_THREAD_DURATION'] : G::LoadTranslation('ID_NOT_FINISHED');
|
||||
|
||||
return $taskInfo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user