fix conflicts

This commit is contained in:
Rodrigo Quelca
2021-08-09 13:18:57 +00:00
55 changed files with 2214 additions and 899 deletions

View File

@@ -799,41 +799,45 @@ class Calendar extends CalendarDefinition
return $return;
}
/**
* Calculate date adding a duration, will considerate the calendar
*
* @param string $initialDate
* @param string $duration
* @param string $formatDuration
* @param array $calendarData
*
* @return string
*/
public function dashCalculateDate($initialDate, $duration, $formatDuration, $calendarData = [])
{
if (G::toUpper($formatDuration) == 'DAYS') {
$duration = $duration * $calendarData['HOURS_FOR_DAY'];
}
if (G::toUpper($formatDuration) == 'MINUTES') {
$duration = $duration / 60;
}
$hoursDuration = (float)$duration;
$newDate = $initialDate;
/**************SLA classes***************/
public function dashCalculateDate ($iniDate, $duration, $formatDuration, $calendarData = array())
{
if ( G::toUpper($formatDuration) == 'DAYS' ) {
$duration = $duration*$calendarData['HOURS_FOR_DAY'];
}
if ( G::toUpper($formatDuration) == 'MINUTES' ) {
$duration = $duration/60;
}
$hoursDuration = (float)$duration;
$newDate = $iniDate;
while ($hoursDuration > 0) {
$newDate = $this->dashGetIniDate($newDate, $calendarData);
$rangeWorkHour = $this->dashGetRangeWorkHours($newDate, $calendarData['BUSINESS_DAY']);
$onlyDate = (date('Y-m-d',strtotime($newDate))) . ' ' . $rangeWorkHour['END'];
if ( (((float)$hoursDuration) >= ((float)$rangeWorkHour['TOTAL'])) ||
((strtotime($onlyDate) - strtotime($newDate)) < (((float)$hoursDuration)*3600))
) {
$secondRes = (float)(strtotime($onlyDate) - strtotime($newDate));
$newDate = $onlyDate;
$hoursDuration -= (float)($secondRes/3600);
} else {
$newDate = date('Y-m-d H:i:s', strtotime('+' . round((((float)$hoursDuration)*3600), 5) . ' seconds', strtotime($newDate)));
$hoursDuration = 0;
}
}
return $newDate;
}
while ($hoursDuration > 0) {
$newDate = $this->dashGetIniDate($newDate, $calendarData);
$rangeWorkHour = $this->dashGetRangeWorkHours($newDate, $calendarData['BUSINESS_DAY']);
$onlyDate = (date('Y-m-d', strtotime($newDate))) . ' ' . $rangeWorkHour['END'];
$rangeWorkHourTotal = (float)$rangeWorkHour['TOTAL'];
if ($hoursDuration >= $rangeWorkHourTotal ||
((strtotime($onlyDate) - strtotime($newDate)) < (($hoursDuration) * 3600))
) {
$secondRes = (float)(strtotime($onlyDate) - strtotime($newDate));
$newDate = $onlyDate;
$hoursDuration -= (float)($secondRes / 3600);
} else {
$newDate = date('Y-m-d H:i:s', strtotime('+' . round((($hoursDuration) * 3600), 5) . ' seconds', strtotime($newDate)));
$hoursDuration = 0;
}
}
return $newDate;
}
//Calculate the duration betwen two dates with a calendar
public function dashCalculateDurationWithCalendar ($iniDate, $finDate = null, $calendarData = array())

View File

@@ -41,6 +41,22 @@ use ProcessMaker\Plugins\PluginRegistry;
*/
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)
*
@@ -91,42 +107,59 @@ class AppDelegation extends BaseAppDelegation
}
/**
* create an application delegation
* Create an application delegation
*
* @param $sProUid process Uid
* @param $sAppUid Application Uid
* @param $sTasUid Task Uid
* @param $sUsrUid User Uid
* @param $iPriority delegation priority
* @param $isSubprocess is a subprocess inside a process?
* @return delegation index of the application delegation.
* @param string $proUid process Uid
* @param string $appUid Application Uid
* @param string $tasUid Task Uid
* @param string $usrUid User Uid
* @param int $priority delegation priority
* @param bool $isSubprocess is a subprocess inside a process?
*
* @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)
{
if (! isset($sProUid) || strlen($sProUid) == 0) {
throw (new Exception('Column "PRO_UID" cannot be null.'));
public function createAppDelegation(
$proUid,
$appUid,
$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) {
throw (new Exception('Column "APP_UID" cannot be null.'));
if (! isset($appUid) || strlen($appUid) == 0) {
throw new Exception('Column "APP_UID" cannot be null.');
}
if (! isset($sTasUid) || strlen($sTasUid) == 0) {
throw (new Exception('Column "TAS_UID" cannot be null.'));
if (! isset($tasUid) || strlen($tasUid) == 0) {
throw new Exception('Column "TAS_UID" cannot be null.');
}
if (! isset($sUsrUid) /*|| strlen($sUsrUid ) == 0*/) {
throw (new Exception('Column "USR_UID" cannot be null.'));
if (! isset($usrUid)) {
throw new Exception('Column "USR_UID" cannot be null.');
}
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;
//Get max DEL_INDEX
// Get max DEL_INDEX
$criteria = new Criteria("workflow");
$criteria->add(AppDelegationPeer::APP_UID, $sAppUid);
$criteria->add(AppDelegationPeer::APP_UID, $appUid);
$criteria->add(AppDelegationPeer::DEL_LAST_INDEX, 1);
$criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
@@ -136,8 +169,8 @@ class AppDelegation extends BaseAppDelegation
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$delIndex = 1;
$delPreviusUsrUid = $sUsrUid;
$delPreviousFather = $sPrevious;
$delPreviusUsrUid = $usrUid;
$delPreviousFather = $previous;
if ($rs->next()) {
$row = $rs->getRow();
@@ -149,7 +182,7 @@ class AppDelegation extends BaseAppDelegation
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_INDEX);
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
$criteriaDelIndex->add(AppDelegationPeer::APP_UID, $sAppUid);
$criteriaDelIndex->add(AppDelegationPeer::APP_UID, $appUid);
$criteriaDelIndex->addDescendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
$rsCriteriaDelIndex = AppDelegationPeer::doSelectRS($criteriaDelIndex);
@@ -161,23 +194,23 @@ class AppDelegation extends BaseAppDelegation
$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) {
$nextTaskUid = $sTasUid;
$index = $this->getAllTasksBeforeSecJoin($nextTaskUid, $sAppUid, $delPreviousFather);
if ($this->createThread($index, $sAppUid)) {
$nextTaskUid = $tasUid;
$index = $this->getAllTasksBeforeSecJoin($nextTaskUid, $appUid, $delPreviousFather);
if ($this->createThread($index, $appUid)) {
return 0;
}
}
if ($flagControlMulInstance) {
$nextTaskUid = $sTasUid;
$index = $this->getAllTheardMultipleInstance($delPreviousFather, $sAppUid);
if ($this->createThread($index, $sAppUid, $sUsrUid)) {
$nextTaskUid = $tasUid;
$index = $this->getAllTheardMultipleInstance($delPreviousFather, $appUid);
if ($this->createThread($index, $appUid, $usrUid)) {
return 0;
}
}
//Update set
// Update set
$criteriaUpdate = new Criteria('workflow');
$criteriaUpdate->add(AppDelegationPeer::DEL_LAST_INDEX, 0);
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
$theadStatus = !$isSubprocess ? 'OPEN' : 'CLOSED';
$this->setAppUid($sAppUid);
$this->setProUid($sProUid);
$this->setTasUid($sTasUid);
$this->setAppUid($appUid);
$this->setProUid($proUid);
$this->setTasUid($tasUid);
$this->setDelIndex($delIndex);
$this->setDelLastIndex(1);
$this->setDelPrevious($sPrevious == - 1 ? 0 : $sPrevious);
$this->setUsrUid($sUsrUid);
$this->setDelPrevious($previous == - 1 ? 0 : $previous);
$this->setUsrUid($usrUid);
$this->setDelType('NORMAL');
$this->setDelPriority(($iPriority != '' ? $iPriority : '3'));
$this->setDelPriority(($priority != '' ? $priority : '3'));
$this->setDelThread($sAppThread);
$this->setDelThreadStatus($theadStatus);
$this->setDelThreadStatusId(Delegation::$thread_status[$theadStatus]);
@@ -203,24 +236,22 @@ class AppDelegation extends BaseAppDelegation
$this->setUsrId($userId);
$this->setProId($proId);
//The function return an array now. By JHL
$delTaskDueDate = $this->calculateDueDate($sNextTasParam);
$delRiskDate = $this->calculateRiskDate($sNextTasParam, $this->getRisk());
//$this->setDelTaskDueDate( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
// The function return an array now. By JHL
$delTaskDueDate = $this->calculateDueDate($nextTasParam);
$delRiskDate = $this->calculateRiskDate($nextTasParam, $this->getRisk());
$this->setDelTaskDueDate($delTaskDueDate);
$this->setDelRiskDate($delRiskDate);
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);
} else {
$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) {
//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');
}
@@ -247,16 +278,16 @@ class AppDelegation extends BaseAppDelegation
$bpmn = new \ProcessMaker\Project\Bpmn();
$flagActionsByEmail = true;
$arrayAppDelegationPrevious = $this->getPreviousDelegationValidTask($sAppUid, $delIndex);
$arrayAppDelegationPrevious = $this->getPreviousDelegationValidTask($appUid, $delIndex);
$data = new stdclass();
$data->TAS_UID = $sTasUid;
$data->APP_UID = $sAppUid;
$data->TAS_UID = $tasUid;
$data->APP_UID = $appUid;
$data->DEL_INDEX = $delIndex;
$data->USR_UID = $sUsrUid;
$data->USR_UID = $usrUid;
$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
// modify this section carefully, the if evaluation checks if the license has been
@@ -265,8 +296,8 @@ class AppDelegation extends BaseAppDelegation
::getSingleton()
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
$criteriaAbe = new Criteria();
$criteriaAbe->add(AbeConfigurationPeer::PRO_UID, $sProUid);
$criteriaAbe->add(AbeConfigurationPeer::TAS_UID, $sTasUid);
$criteriaAbe->add(AbeConfigurationPeer::PRO_UID, $proUid);
$criteriaAbe->add(AbeConfigurationPeer::TAS_UID, $tasUid);
$resultAbe = AbeConfigurationPeer::doSelectRS($criteriaAbe);
$resultAbe->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($resultAbe->next()) {
@@ -289,7 +320,7 @@ class AppDelegation extends BaseAppDelegation
$pmGoogle = new PmGoogleApi();
if ($pmGoogle->getServiceGmailStatus()) {
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
$Pmgmail->gmailsForRouting($sUsrUid, $sTasUid, $sAppUid, $delIndex, $isSubprocess);
$Pmgmail->gmailsForRouting($usrUid, $tasUid, $appUid, $delIndex, $isSubprocess);
}
} catch (Exception $oError) {
error_log($oError->getMessage());
@@ -299,8 +330,8 @@ class AppDelegation extends BaseAppDelegation
}
if ($flagActionsByEmail) {
$oPluginRegistry = PluginRegistry::loadSingleton();
$oPluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
$pluginRegistry = PluginRegistry::loadSingleton();
$pluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
}
}
@@ -474,30 +505,38 @@ class AppDelegation extends BaseAppDelegation
//Calendar - Use the dates class to calculate dates
$calendar = new Calendar();
$arrayCalendarData = $calendar->getCalendarData($aCalendarUID);
$calendarData = $calendar->getCalendarData($aCalendarUID);
if ($calendar->pmCalendarUid == "") {
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
$arrayCalendarData = $calendar->getCalendarData();
$calendarData = $calendar->getCalendarData();
}
//Due date
$initDate = $this->getDelDelegateDate();
$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);
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 {
$data = array();
if (isset($sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
$data['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
$data['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
$data = [];
if (isset($nextTask['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $nextTask['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
$data['TAS_DURATION'] = $nextTask['NEXT_TASK']['TAS_DURATION'];
$data['TAS_TIMEUNIT'] = $nextTask['NEXT_TASK']['TAS_TIMEUNIT'];
} else {
$task = TaskPeer::retrieveByPK($this->getTasUid());
$data['TAS_DURATION'] = $task->getTasDuration();
@@ -506,19 +545,21 @@ class AppDelegation extends BaseAppDelegation
$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();
$arrayCalendarData = array();
if ($calendar->pmCalendarUid == "") {
$calendarData = [];
if (empty($calendar->pmCalendarUid)) {
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
$arrayCalendarData = $calendar->getCalendarData();
$calendarData = $calendar->getCalendarData();
}
//Risk date
$riskDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), $riskTime, $data['TAS_TIMEUNIT'], $arrayCalendarData);
// Risk date
$riskDate = $calendar->dashCalculateDate(
$this->getDelDelegateDate(),
$riskTime,
$data['TAS_TIMEUNIT'],
$calendarData
);
return $riskDate;
} 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
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
*
* @param string $appUid, Uid related to the case
* @param integer $index, Index to review
*
* @return array
*/
public static function getCurrentUsers($appUid, $index)
@@ -820,7 +857,8 @@ class AppDelegation extends BaseAppDelegation
/**
* 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
*/
@@ -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
*

View File

@@ -4493,6 +4493,12 @@ msgstr "City"
msgid "Claim"
msgstr "Claim"
# TRANSLATION
# LABEL/ID_CLAIM_THIS_CASE
#: LABEL/ID_CLAIM_THIS_CASE
msgid "Claim this case"
msgstr "Claim this case"
# TRANSLATION
# LABEL/ID_CLASSIC_EDITOR
#: LABEL/ID_CLASSIC_EDITOR
@@ -24671,6 +24677,12 @@ msgstr "An error has occurred, please verify on which server \"SendMail\" has be
msgid "send at"
msgstr "send at"
# TRANSLATION
# LABEL/ID_SEND_BY
#: LABEL/ID_SEND_BY
msgid "Send By"
msgstr "Send By"
# TRANSLATION
# LABEL/ID_SEND_EMAIL_CASE_PARTICIPANTS
#: LABEL/ID_SEND_EMAIL_CASE_PARTICIPANTS

View File

@@ -57561,6 +57561,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_CITY','en','City','2020-12-15') ,
( 'LABEL','ID_CHOOSE_TIME','en','Choose a time','2014-08-27') ,
( 'LABEL','ID_CLAIM','en','Claim','2014-01-15') ,
( 'LABEL','ID_CLAIM_THIS_CASE','en','Claim this case','2021-08-03') ,
( 'LABEL','ID_CLASSIC_EDITOR','en','Classic Editor','2014-01-15') ,
( 'LABEL','ID_CLASS_ALREADY_EXISTS','en','Class already exists','2014-01-15') ,
( 'LABEL','ID_CLASS_TABLE_DOESNT_EXIST','en','This Class Table doesn''t exist!','2014-01-15') ,
@@ -61026,6 +61027,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_SENDING_REQUEST_SALES_DEPARTMENT','en','Sending request to ProcessMaker Sales Department, please wait...','2014-09-18') ,
( 'LABEL','ID_SENDMAIL_NOT_INSTALLED','en','An error has occured, please verify on which server "SendMail" has been installed or any other mail service, and if it has been configured correctly.','2014-01-15') ,
( 'LABEL','ID_SEND_AT','en','send at','2014-01-15') ,
( 'LABEL','ID_SEND_BY','en','Send By','2021-08-02') ,
( 'LABEL','ID_SEND_EMAIL_CASE_PARTICIPANTS','en','Send Email (Case Participants)','2014-01-15') ,
( 'LABEL','ID_SEND_EMAIL_TO_PARTICIPANTS','en','Send email to participants','2020-12-01') ,
( 'LABEL','ID_SENT','en','Participated','2016-07-11') ,

View File

@@ -6,6 +6,8 @@ use ProcessMaker\Core\System;
global $translation;
global $RBAC;
$conf = new Configurations();
if ($RBAC->userCanAccess("PM_SETUP") != 1 || $RBAC->userCanAccess("PM_SETUP_ADVANCE") != 1) {
G::SendTemporalMessage("ID_USER_HAVENT_RIGHTS_PAGE", "error", "labels");
exit(0);
@@ -30,4 +32,5 @@ ScriptVariables::add('SYS_WORKSPACE', config("system.workspace"));
ScriptVariables::add('SYS_URI', SYS_URI);
ScriptVariables::add('SYS_LANG', SYS_LANG);
ScriptVariables::add('TRANSLATIONS', $translation);
ScriptVariables::add('FORMATS', $conf->getFormats());
echo View::make('Views::admin.settings.customCasesList', compact("userCanAccess"))->render();

View File

@@ -46,6 +46,7 @@ use ProcessMaker\BusinessModel\User as BmUser;
use ProcessMaker\Core\System;
use ProcessMaker\Exception\UploadException;
use ProcessMaker\Exception\CaseNoteUploadFile;
use ProcessMaker\Model\AppDelay as Delay;
use ProcessMaker\Model\Application as ModelApplication;
use ProcessMaker\Model\AppNotes as Notes;
use ProcessMaker\Model\AppTimeoutAction;
@@ -2456,33 +2457,25 @@ class Cases
/**
* This function get the status information
*
* @param object $rsCriteria
* @param array $result
* @param string $status
*
* @return array
* @throws Exception
*/
private function getStatusInfoDataByRsCriteria($rsCriteria)
private function getStatusInfoFormatted(array $result, string $status = '')
{
try {
$arrayData = [];
if ($rsCriteria->next()) {
$record = $rsCriteria->getRow();
$arrayData = [
'APP_STATUS' => $record['APP_STATUS'],
'DEL_INDEX' => [],
'PRO_UID' => $record['PRO_UID']
];
$record = head($result);
$arrayData = [
'APP_STATUS' => empty($status) ? $record['APP_STATUS'] : $status,
'DEL_INDEX' => [],
'PRO_UID' => $record['PRO_UID']
];
$arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
foreach ($result as $record) {
$arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
while ($rsCriteria->next()) {
$record = $rsCriteria->getRow();
$arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
}
}
//Return
return $arrayData;
} catch (Exception $e) {
@@ -2493,8 +2486,8 @@ class Cases
/**
* Get status info Case
*
* @param string $applicationUid Unique id of Case
* @param int $delIndex Delegation index
* @param string $appUid Unique id of Case
* @param int $index Delegation index
* @param string $userUid Unique id of User
*
* @return array Return an array with status info Case, array empty otherwise
@@ -2502,179 +2495,120 @@ class Cases
*
* @see workflow/engine/methods/cases/main_init.php
* @see workflow/engine/methods/cases/opencase.php
* @see ProcessMaker\BusinessModel\Cases->setCaseVariables()
* @see ProcessMaker\BusinessModel\Cases\InputDocument->getCasesInputDocuments()
* @see ProcessMaker\BusinessModel\Cases\InputDocument->throwExceptionIfHaventPermissionToDelete()
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfCaseNotIsInInbox()
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfHaventPermissionToDelete()
* @see \ProcessMaker\BusinessModel\Cases::setCaseVariables()
* @see \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocuments()
* @see \ProcessMaker\BusinessModel\Cases\InputDocument::throwExceptionIfHaventPermissionToDelete()
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::throwExceptionIfCaseNotIsInInbox()
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::throwExceptionIfHaventPermissionToDelete()
*/
public function getStatusInfo($applicationUid, $delIndex = 0, $userUid = "")
public function getStatusInfo(string $appUid, int $index = 0, string $userUid = "")
{
try {
//Verify data
$this->throwExceptionIfNotExistsCase($applicationUid, $delIndex,
$this->getFieldNameByFormatFieldName("APP_UID"));
//Get data
//Status is PAUSED
$delimiter = DBAdapter::getStringDelimiter();
$criteria = new Criteria("workflow");
$criteria->setDistinct();
$criteria->addSelectColumn($delimiter . 'PAUSED' . $delimiter . ' AS APP_STATUS');
$criteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX . " AS DEL_INDEX");
$criteria->addSelectColumn(AppDelayPeer::PRO_UID);
$criteria->add(AppDelayPeer::APP_UID, $applicationUid, Criteria::EQUAL);
$criteria->add(AppDelayPeer::APP_TYPE, "PAUSE", Criteria::EQUAL);
$criteria->add(
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->addOr(
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL))
);
if ($delIndex != 0) {
$criteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex, Criteria::EQUAL);
$arrayData = [];
// Verify data
$this->throwExceptionIfNotExistsCase($appUid, $index, $this->getFieldNameByFormatFieldName("APP_UID"));
// Get the case number
$caseNumber = ModelApplication::getCaseNumber($appUid);
// Status is PAUSED
$result = Delay::getPaused($caseNumber, $index, $userUid);
if (!empty($result)) {
$arrayData = $this->getStatusInfoFormatted($result, 'PAUSED');
return $arrayData;
}
if ($userUid != "") {
$criteria->add(AppDelayPeer::APP_DELEGATION_USER, $userUid, Criteria::EQUAL);
// Status is UNASSIGNED
$query = Delegation::query()->select([
'APP_DELEGATION.APP_NUMBER',
'APP_DELEGATION.DEL_INDEX',
'APP_DELEGATION.PRO_UID'
]);
$query->taskAssignType('SELF_SERVICE');
$query->threadOpen()->withoutUserId();
// Filter specific user
if (!empty($userUid)) {
$delegation = new Delegation();
$delegation->casesUnassigned($query, $userUid);
}
// Filter specific case
$query->case($caseNumber);
// Filter specific index
if (is_int($index)) {
$query->index($index);
}
$results = $query->get();
$arrayData = $results->values()->toArray();
if (!empty($arrayData)) {
$arrayData = $this->getStatusInfoFormatted($arrayData, 'UNASSIGNED');
return $arrayData;
}
$rsCriteria = AppDelayPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
// Status is TO_DO, DRAFT
$query = Delegation::query()->select([
'APPLICATION.APP_STATUS',
'APP_DELEGATION.APP_NUMBER',
'APP_DELEGATION.DEL_INDEX',
'APP_DELEGATION.PRO_UID'
]);
$query->joinApplication();
// Filter the status TO_DO and DRAFT
$query->casesInProgress([1, 2]);
// Filter the OPEN thread
$query->threadOpen();
// Filter specific case
$query->case($caseNumber);
// Filter specific index
if ($index > 0) {
$query->index($index);
}
// Filter specific user
if (!empty($userUid)) {
$userId = !empty($userUid) ? User::getId($userUid) : 0;
$query->userId($userId);
}
$results = $query->get();
$arrayData = $results->values()->toArray();
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
if (!empty($arrayData)) {
$arrayData = $this->getStatusInfoFormatted($arrayData);
return $arrayData;
}
// Status is CANCELLED, COMPLETED
$query = Delegation::query()->select([
'APPLICATION.APP_STATUS',
'APP_DELEGATION.APP_NUMBER',
'APP_DELEGATION.DEL_INDEX',
'APP_DELEGATION.PRO_UID'
]);
$query->joinApplication();
// Filter the status COMPLETED and CANCELLED
$query->casesDone([3, 4]);
// Filter specific case
$query->case($caseNumber);
// Filter specific index
if ($index > 0) {
$query->index($index);
}
// Filter specific user
if (!empty($userUid)) {
$userId = !empty($userUid) ? User::getId($userUid) : 0;
$query->userId($userId);
}
$query->lastThread();
$results = $query->get();
$arrayData = $results->values()->toArray();
if (!empty($arrayData)) {
$arrayData = $this->getStatusInfoFormatted($arrayData);
return $arrayData;
}
// Status is PARTICIPATED
$arrayData = Delegation::getParticipatedInfo($appUid);
if (!empty($arrayData)) {
return $arrayData;
}
//Status is UNASSIGNED
if ($userUid != '') {
$appCacheView = new AppCacheView();
$criteria = $appCacheView->getUnassignedListCriteria($userUid);
} else {
$criteria = new Criteria('workflow');
$criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
$criteria->add(AppCacheViewPeer::USR_UID, '', Criteria::EQUAL);
}
$criteria->setDistinct();
$criteria->clearSelectColumns();
$criteria->addSelectColumn($delimiter . 'UNASSIGNED' . $delimiter . ' AS APP_STATUS');
$criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX);
$criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
$criteria->add(AppCacheViewPeer::APP_UID, $applicationUid, Criteria::EQUAL);
if ($delIndex != 0) {
$criteria->add(AppCacheViewPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
}
$rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
if (!empty($arrayData)) {
return $arrayData;
}
//Status is TO_DO, DRAFT
$criteria = new Criteria("workflow");
$criteria->setDistinct();
$criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
$criteria->addSelectColumn(ApplicationPeer::PRO_UID);
$criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
$arrayCondition = array();
$arrayCondition[] = array(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
$arrayCondition[] = array(
ApplicationPeer::APP_UID,
$delimiter . $applicationUid . $delimiter,
Criteria::EQUAL
);
$criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
$criteria->add(
$criteria->getNewCriterion(ApplicationPeer::APP_STATUS, "TO_DO", Criteria::EQUAL)->addAnd(
$criteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL))->addAnd(
$criteria->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))
)->addOr(
$criteria->getNewCriterion(ApplicationPeer::APP_STATUS, "DRAFT", Criteria::EQUAL)->addAnd(
$criteria->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))
);
if ($delIndex != 0) {
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
}
if ($userUid != "") {
$criteria->add(AppDelegationPeer::USR_UID, $userUid, Criteria::EQUAL);
}
$rsCriteria = ApplicationPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
if (!empty($arrayData)) {
return $arrayData;
}
//Status is CANCELLED, COMPLETED
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
$criteria->addSelectColumn(ApplicationPeer::PRO_UID);
$criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
$arrayCondition = array();
$arrayCondition[] = array(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
$arrayCondition[] = array(
ApplicationPeer::APP_UID,
$delimiter . $applicationUid . $delimiter,
Criteria::EQUAL
);
$criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
if ($delIndex != 0) {
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
}
if ($userUid != "") {
$criteria->add(AppDelegationPeer::USR_UID, $userUid, Criteria::EQUAL);
}
$criteria2 = clone $criteria;
$criteria2->setDistinct();
$criteria2->add(ApplicationPeer::APP_STATUS, ['CANCELLED', 'COMPLETED'], Criteria::IN);
$criteria2->add(AppDelegationPeer::DEL_LAST_INDEX, 1, Criteria::EQUAL);
$rsCriteria2 = ApplicationPeer::doSelectRS($criteria2);
$rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria2);
if (!empty($arrayData)) {
return $arrayData;
}
//Status is PARTICIPATED
$arrayData = Delegation::getParticipatedInfo($applicationUid);
if (!empty($arrayData)) {
return $arrayData;
}
//Return
return array();
return $arrayData;
} catch (Exception $e) {
throw $e;
}

View File

@@ -1492,8 +1492,7 @@ class AbstractCases implements CasesInterface
/**
* Count how many cases has each process
*
* @param string $list
*
* @param int $category
* @param bool $topTen
* @param array $processes
@@ -1528,7 +1527,7 @@ class AbstractCases implements CasesInterface
$query->topTen('TOTAL', 'DESC');
}
if (!empty($processes)) {
$query->inProcesses($processes);
$query->processInList($processes);
}
return $query->get()->values()->toArray();
}
@@ -1574,7 +1573,7 @@ class AbstractCases implements CasesInterface
}
$query->joinProcess();
if (!is_null($processId)) {
$query->inProcesses([$processId]);
$query->processInList([$processId]);
}
if (!is_null($dateFrom)) {
$query->where('APP_DELEGATION.DEL_DELEGATE_DATE', '>=', $dateFrom);

View File

@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -166,4 +167,44 @@ class Draft extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
/**
* Returns the total cases of the custom draft list.
* @param int $id
* @param string $type
* @return array
*/
public function getCustomListCount(int $id, string $type): array
{
$caseList = CaseList::where('CAL_ID', '=', $id)
->where('CAL_TYPE', '=', $type)
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
->select([
'CASE_LIST.*',
'ADDITIONAL_TABLES.ADD_TAB_NAME'
])
->get()
->first();
$query = Delegation::query()->select();
$query->draft($this->getUserId());
$name = '';
$description = '';
$tableName = '';
if (!is_null($caseList)) {
$name = $caseList->CAL_NAME;
$description = $caseList->CAL_DESCRIPTION;
$tableName = $caseList->ADD_TAB_NAME;
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
}
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
return [
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_DRAFT') . $count,
'name' => $name,
'description' => $description,
'tableName' => $tableName,
'total' => $count
];
}
}

View File

@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -179,4 +180,44 @@ class Inbox extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
/**
* Returns the total cases of the custom inbox list.
* @param int $id
* @param string $type
* @return array
*/
public function getCustomListCount(int $id, string $type): array
{
$caseList = CaseList::where('CAL_ID', '=', $id)
->where('CAL_TYPE', '=', $type)
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
->select([
'CASE_LIST.*',
'ADDITIONAL_TABLES.ADD_TAB_NAME'
])
->get()
->first();
$query = Delegation::query()->select();
$query->inbox($this->getUserId());
$name = '';
$description = '';
$tableName = '';
if (!is_null($caseList)) {
$name = $caseList->CAL_NAME;
$description = $caseList->CAL_DESCRIPTION;
$tableName = $caseList->ADD_TAB_NAME;
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
}
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
return [
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_INBOX') . $count,
'name' => $name,
'description' => $description,
'tableName' => $tableName,
'total' => $count
];
}
}

View File

@@ -3,6 +3,7 @@
namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -173,4 +174,44 @@ class Paused extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
/**
* Returns the total cases of the custom paused list.
* @param int $id
* @param string $type
* @return array
*/
public function getCustomListCount(int $id, string $type): array
{
$caseList = CaseList::where('CAL_ID', '=', $id)
->where('CAL_TYPE', '=', $type)
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
->select([
'CASE_LIST.*',
'ADDITIONAL_TABLES.ADD_TAB_NAME'
])
->get()
->first();
$query = Delegation::query()->select();
$query->paused($this->getUserId());
$name = '';
$description = '';
$tableName = '';
if (!is_null($caseList)) {
$name = $caseList->CAL_NAME;
$description = $caseList->CAL_DESCRIPTION;
$tableName = $caseList->ADD_TAB_NAME;
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
}
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
return [
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_PAUSED') . $count,
'name' => $name,
'description' => $description,
'tableName' => $tableName,
'total' => $count
];
}
}

View File

@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -181,4 +182,44 @@ class Unassigned extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
/**
* Returns the total cases of the custom unassigned list.
* @param int $id
* @param string $type
* @return array
*/
public function getCustomListCount(int $id, string $type): array
{
$caseList = CaseList::where('CAL_ID', '=', $id)
->where('CAL_TYPE', '=', $type)
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
->select([
'CASE_LIST.*',
'ADDITIONAL_TABLES.ADD_TAB_NAME'
])
->get()
->first();
$query = Delegation::query()->select();
$query->selfService($this->getUserId());
$name = '';
$description = '';
$tableName = '';
if (!is_null($caseList)) {
$name = $caseList->CAL_NAME;
$description = $caseList->CAL_DESCRIPTION;
$tableName = $caseList->ADD_TAB_NAME;
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
}
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
return [
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_UNASSIGNED') . $count,
'name' => $name,
'description' => $description,
'tableName' => $tableName,
'total' => $count
];
}
}

View File

@@ -8,6 +8,7 @@ use Fields;
use G;
use PmTable;
use ProcessMaker\BusinessModel\ReportTable as BusinessModelRpt;
use ProcessMaker\Model\AdditionalTables as ModelAdditionalTables;
use stdClass;
class Table
@@ -23,34 +24,25 @@ class Table
'or','throw','protected','public','static','switch','xor','try','use','var','while'];
/**
* List of Tables in process
* @var string $pro_uid. Uid for process
* @var string $reportFlag. If is report table
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* List of Tables in process.
* @param string $proUid
* @param bool $reportFlag
* @param bool $offline
* @param string $search
* @return array
*/
public function getTables($pro_uid = '', $reportFlag = false, $offline = false)
public function getTables(string $proUid = '', bool $reportFlag = false, bool $offline = false, string $search = ''): array
{
//VALIDATION
if ($reportFlag) {
$pro_uid = $this->validateProUid($pro_uid);
$proUid = $this->validateProUid($proUid);
}
$reportTables = array();
$oCriteria = new \Criteria('workflow');
$oCriteria->addSelectColumn(\AdditionalTablesPeer::ADD_TAB_UID);
$oCriteria->add(\AdditionalTablesPeer::PRO_UID, $pro_uid, \Criteria::EQUAL);
$oDataset = \AdditionalTablesPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($oDataset->next()) {
$row = $oDataset->getRow();
$reportTables[] = $this->getTable($row['ADD_TAB_UID'], $pro_uid, $reportFlag, false);
}
return $reportTables;
$additionalTables = ModelAdditionalTables::where('PRO_UID', '=', $proUid)
->where('ADD_TAB_NAME', 'LIKE', "%{$search}%")
->get();
$additionalTables->transform(function ($object) use ($proUid, $reportFlag) {
return $this->getTable($object->ADD_TAB_UID, $proUid, $reportFlag, false);
});
return $additionalTables->toArray();
}
/**

View File

@@ -30,4 +30,94 @@ class AppDelay extends Model
'APP_ENABLE_ACTION_DATE',
'APP_DISABLE_ACTION_DATE',
];
/**
* Scope a query to filter a specific type
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $type
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeType($query, string $type = 'PAUSE')
{
return $query->where('APP_DELAY.APP_TYPE', $type);
}
/**
* Scope a query to filter a specific disable action
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNotDisabled($query)
{
return $query->where('APP_DELAY.APP_DISABLE_ACTION_USER', 0);
}
/**
* Scope a query to filter a specific case
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $appNumber
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCase($query, int $appNumber)
{
return $query->where('APP_DELAY.APP_NUMBER', $appNumber);
}
/**
* Scope a query to filter a specific index
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $index
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeIndex($query, int $index)
{
return $query->where('APP_DELAY.APP_DEL_INDEX', $index);
}
/**
* Scope a query to filter a specific user
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $user
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeDelegateUser($query, string $user)
{
return $query->where('APP_DELAY.APP_DELEGATION_USER', $user);
}
/**
* Get the thread paused
*
* @param int $appNumber
* @param int $index
* @param string $userUid
*
* @return array
*/
public static function getPaused(int $appNumber, int $index, string $userUid = '')
{
$query = AppDelay::query()->select([
'APP_NUMBER',
'APP_DEL_INDEX AS DEL_INDEX',
'PRO_UID'
]);
$query->type('PAUSE')->notDisabled();
$query->case($appNumber);
// Filter specific index
if ($index > 0) {
$query->index($index);
}
// Filter specific delegate user
if (!empty($userUid)) {
$query->delegateUser($userUid);
}
// Get the result
$results = $query->get();
return $results->values()->toArray();
}
}

View File

@@ -173,9 +173,10 @@ class CaseList extends Model
* @param string $search
* @param int $offset
* @param int $limit
* @param bool $paged
* @return array
*/
public static function getSetting(string $type, string $search, int $offset, int $limit): array
public static function getSetting(string $type, string $search, int $offset, int $limit, bool $paged = true): array
{
$order = 'asc';
$model = CaseList::where('CAL_TYPE', '=', $type)
@@ -198,7 +199,11 @@ class CaseList extends Model
$count = $model->count();
$data = $model->offset($offset)->limit($limit)->get();
if ($paged === true) {
$model->offset($offset)->limit($limit);
}
$data = $model->get();
$data->transform(function ($item, $key) {
if (is_null($item->CAL_COLUMNS)) {
$item->CAL_COLUMNS = '[]';

View File

@@ -173,18 +173,6 @@ class Delegation extends Model
return $query->where('DEL_INDEX', '=', 1);
}
/**
* Scope a query to get the in-progress
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCaseInProgress($query)
{
return $query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]);
}
/**
* Scope a query to get the to_do cases
*
@@ -381,36 +369,39 @@ class Delegation extends Model
* Scope a query to get only the date on time
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $now
*
* @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
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $now
*
* @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
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $now
*
* @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);
}
/**
@@ -774,19 +765,6 @@ class Delegation extends Model
return $query->whereIn('APP_DELEGATION.PRO_ID', $processes);
}
/**
* Scope where in processes
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $processes
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeInProcesses($query, array $processes)
{
return $query->whereIn('PROCESS.PRO_ID', $processes);
}
/**
* Scope the Inbox cases
*
@@ -809,26 +787,6 @@ class Delegation extends Model
return $query;
}
/**
* Scope the Inbox cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeInboxWithoutUser($query)
{
// This scope is for the join with the APP_DELEGATION table
$query->joinApplication();
$query->status(Application::STATUS_TODO);
// Scope for the restriction of the task that must not be searched for
$query->excludeTaskTypes(Task::DUMMY_TASKS);
// Scope that establish that the DEL_THREAD_STATUS must be OPEN
$query->threadOpen();
return $query;
}
/**
* Scope a self service cases
*
@@ -1414,7 +1372,7 @@ class Delegation extends Model
* @param string $appUid
* @return array
*
* @see \ProcessMaker\BusinessModel\Cases:getStatusInfo()
* @see \ProcessMaker\BusinessModel\Cases::getStatusInfo()
*/
public static function getParticipatedInfo($appUid)
{

View File

@@ -215,6 +215,7 @@ class User extends Model
public static function getInformation(int $usrId)
{
$query = User::query()->select([
'USR_ID',
'USR_USERNAME',
'USR_FIRSTNAME',
'USR_LASTNAME',
@@ -226,6 +227,7 @@ class User extends Model
$results = $query->get();
$info = [];
$results->each(function ($item) use (&$info) {
$info['usr_id'] = $item->USR_ID;
$info['usr_username'] = $item->USR_USERNAME;
$info['usr_firstname'] = $item->USR_FIRSTNAME;
$info['usr_lastname'] = $item->USR_LASTNAME;

View File

@@ -14,6 +14,7 @@ use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\BusinessModel\Cases\Search;
use ProcessMaker\BusinessModel\Cases\Supervising;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessCategory;
@@ -609,6 +610,30 @@ class Home extends Api
if ($menuInstance->Id[$i] === 'ID_CASE_ARCHIVE_SEARCH') {
$option->icon = "fas fa-archive";
}
//custom cases list
if (in_array($menuInstance->Id[$i], $optionsWithCounter)) {
$mapKeys = [
'CASES_INBOX' => 'inbox',
'CASES_DRAFT' => 'draft',
'CASES_SELFSERVICE' => 'unassigned',
'CASES_PAUSED' => 'paused'
];
$option->customCasesList = [];
$result = CaseList::getSetting($mapKeys[$menuInstance->Id[$i]], '', 0, 10, false);
foreach ($result['data'] as $value) {
$option->customCasesList[] = [
"href" => "casesListExtJs?action=" . $mapKeys[$menuInstance->Id[$i]],
"id" => $value['id'],
"title" => $value['name'],
"description" => $value['description'],
"icon" => $value['iconList'],
"badge" => [
"text" => "0",
"class" => "badge-custom"
]
];
}
}
// Add option to the menu
$menuHome[] = $option;
}
@@ -727,10 +752,48 @@ class Home extends Api
$result = [];
$result['label'] = $text . $count;
$result['total'] = $count;
return $result;
}
/**
* Get task counters for inbox, draft, paused, and unassigned for custom case lists.
* @url GET /:task/counter/caseList/:id
* @param string $task
* @param int $id
* @return array
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function getCustomCaseListCounter(string $task, int $id)
{
try {
$usrUid = $this->getUserId();
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
switch ($task) {
case 'inbox':
$taskList = new Inbox();
break;
case 'draft':
$taskList = new Draft();
break;
case 'paused':
$taskList = new Paused();
break;
case 'unassigned':
$taskList = new Unassigned();
break;
default:
return [];
}
$taskList->setUserUid($usrUid);
$taskList->setUserId($usrId);
$result = $taskList->getCustomListCount($id, $task);
return $result;
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Get the tasks counters for todo, draft, paused and unassigned
*

View File

@@ -1,33 +1,29 @@
<?php
namespace ProcessMaker\Services\Api\Project;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Table;
use ProcessMaker\Services\Api;
/**
* Project\ReportTable Api Controller
*
* @author Brayan Pereyra <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @protected
*/
class ReportTable extends Api
{
/**
* @param string $prj_uid {@min 1} {@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* Get list of the report tables by project.
* @url GET /:proUid/report-tables
* @param string $proUid {@min 1} {@max 32}
* @param string $search
* @return array
*
* @url GET /:prj_uid/report-tables
* @throws RestException
*/
public function doGetReportTables($prj_uid)
public function doGetReportTables(string $proUid, string $search = '')
{
try {
$oReportTable = new \ProcessMaker\BusinessModel\Table();
$response = $oReportTable->getTables($prj_uid, true);
$reportTable = new Table();
$response = $reportTable->getTables($proUid, true, false, $search);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -38,9 +34,6 @@ class ReportTable extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $rep_uid {@min 1} {@max 32}
* @return array
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url GET /:prj_uid/report-table/:rep_uid
*/
public function doGetReportTable($prj_uid, $rep_uid)
@@ -58,9 +51,6 @@ class ReportTable extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $rep_uid {@min 1} {@max 32}
* @return array
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url GET /:prj_uid/report-table/:rep_uid/populate
*/
public function doGetPopulateReportTable($prj_uid, $rep_uid)
@@ -78,9 +68,6 @@ class ReportTable extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $rep_uid {@min 1} {@max 32}
* @return array
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url GET /:prj_uid/report-table/:rep_uid/data
*/
public function doGetReportTableData($prj_uid, $rep_uid)

View File

@@ -416,7 +416,7 @@ Ext.onReady(function(){
buttonCancel = new Ext.Button({
buttonAlign: 'center',
text: 'Cancel',
text: _("ID_CANCEL"),
handler: redirectHistory,
cls: 'cancelSummary',
width: '100px',
@@ -427,7 +427,7 @@ Ext.onReady(function(){
buttonClaimCase = new Ext.Button({
buttonAlign: 'center',
ui: 'round',
text: 'Claim this case',
text: _("ID_CLAIM_THIS_CASE"),
handler: claimCase,
cls: 'claimCaseSummary',
width: '120px',