method approve documentation in bbn\Appui\Task
function(string $id, bool $approveChildren = true, bool $approveParent = true)
{
&& ($perm = \bbn\User\Permissions::getInstance())
&& ($currentState = $this->getState($id))
&& ($unapproved = $this->idState('unapproved'))
&& ($currentState === $unapproved)
&& ((($deciders = $this->getDeciders($id, true))
&& \in_array($this->id_user, $deciders))
|| (($idFinancialManager = $this->idPrivilege('financial_manager'))
&& ($idPermFM = $perm->optionToPermission($idFinancialManager))
&& $perm->has($idPermFM))
)
){
$price = $this->getPrice($id);
if (empty($price)) {
$price = $this->getChildrenPrices($id);
}
if (!($opened = $this->idState('opened'))) {
throw new \Exception(X::_('No state found with the code opened'));
}
if ($approveChildren
&& ($children = $this->getUnapprovedChildrenIds($id))
) {
foreach ($children as $child) {
$this->approve($child, true, false);
}
}
if (!$this->getUnapprovedChildrenIds($id)
&& (($this->getState($id) === $this->idState('opened'))
|| $this->update($id, 'state', $opened))
) {
if (!empty($price)) {
$this->addLog($id, 'price_approved', [$price]);
}
if ($approveParent
&& ($parent = $this->getIdParent($id))
&& ($this->getState($parent) === $unapproved)
&& !$this->getUnapprovedChildrenIds($parent)
) {
$this->approve($parent, false);
}
return true;
}
}
return false;
}
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions