Skip to content

feature/FOUR-15682: Set up the DueDate in run request according the configuration in the task. #6944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion ProcessMaker/Repositories/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Mustache_Engine;
use ProcessMaker\Models\ProcessCollaboration;
use ProcessMaker\Models\ProcessRequest as Instance;
use ProcessMaker\Models\ProcessRequestToken;
Expand Down Expand Up @@ -145,7 +146,7 @@ public function persistActivityActivated(ActivityInterface $activity, TokenInter
}

//Default 3 days of due date
$due = $activity->getProperty('dueIn', '72');
$due = $this->getDueVariable($activity, $token);
$token->due_at = $due ? Carbon::now()->addHours($due) : null;
$token->initiated_at = null;
$token->riskchanges_at = $due ? Carbon::now()->addHours($due * 0.7) : null;
Expand All @@ -158,6 +159,25 @@ public function persistActivityActivated(ActivityInterface $activity, TokenInter
$this->instanceRepository->persistInstanceUpdated($token->getInstance());
}

/**
* Get due Variable
*
* @param Instance $instance
* @param User $user
*/
private function getDueVariable(ActivityInterface $activity, TokenInterface $token)
{
$isDueVariable = $activity->getProperty('isDueInVariable', false);
$dueVariable = $activity->getProperty('dueInVariable');
if ($isDueVariable && !empty($dueVariable)) {
$instanceData= $token->getInstance()->getDataStore()->getData();
$mustache = new Mustache_Engine();
$mustacheDueVariable = $mustache->render($dueVariable, $instanceData);
return is_numeric($mustacheDueVariable) ? $mustacheDueVariable : '72';
}
return $activity->getProperty('dueIn', '72');
}

/**
* Persists tokens that triggered a Start Event
*
Expand Down
2 changes: 2 additions & 0 deletions public/definitions/ProcessMaker.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<xsd:attribute name="interstitialScreenRef" type="xsd:string"/>
<xsd:attribute name="screenVersion" type="xsd:string" use="optional"/>
<xsd:attribute name="dueIn" type="xsd:decimal"/>
<xsd:attribute name="dueInVariable" type="xsd:string" use="optional"/>
<xsd:attribute name="isDueInVariable" type="xsd:boolean" default="false"/>
<xsd:attribute name="notifyAfterRouting" type="xsd:boolean" default="false"/>
<xsd:attribute name="notifyToRequestCreator" type="xsd:boolean" default="false"/>
<xsd:attribute name="assignment" type="xsd:string" default="requestor"/>
Expand Down
Loading