<?php
 namespace Modules\TaskManagement\Tasks; class View_Utils_FormChangeStatus extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $_LANG = \App\Loader_Lang::getInstance()->getAll(); $entCfg = \Entity\Task::loadCFG(); $form = \Engine\Form\General::create(); $form->addContainer(\Engine\Form\Container\Fieldset::create()); $form->setStyle('width', 300)->setStyle('labelWidth', 25); $fld_status = new \Engine\Form\Input\Select($this->lang['formFields']['status'], 'status', $this->values['status']); $fld_status->setPossibleValues([ 'pending' => $_LANG['tasks']['statusName']['pending'], 'refused' => $_LANG['tasks']['statusName']['refused'], 'inProgress'=> $_LANG['tasks']['statusName']['inProgress'], 'onHold' => $_LANG['tasks']['statusName']['onHold'], 'finished' => $_LANG['tasks']['statusName']['finished'], ]); $fld_status->importFromConfig($entCfg['status']); $fld_status->showDefaultOption(); $fld_status->setMandatory(); $form->addElement($fld_status); $fld_reasonRefused = new \Engine\Form\Input\Select($this->lang['formFields']['statusReason'], 'statusReasonRefused', $this->values['statusReasonRefused']); $values = []; foreach ($entCfg['_special']['statusReasonsList']['refused'] as $code) { $values[$code] = $_LANG['tasks']['reasonForStatus']['refused'][$code]; } $fld_reasonRefused->setPossibleValues($values); $fld_reasonRefused->showDefaultOption() ->setDefaultOptionText($this->lang['formFields']['select']['statusReason']); $fld_reasonRefused->setMandatory(); $form->addElement($fld_reasonRefused); $fld_reasonOnHold = new \Engine\Form\Input\Select($this->lang['formFields']['statusReason'], 'statusReasonOnHold', $this->values['statusReasonOnHold']); $values = []; foreach ($entCfg['_special']['statusReasonsList']['onHold'] as $code) { $values[$code] = $_LANG['tasks']['reasonForStatus']['onHold'][$code]; } $fld_reasonOnHold->setPossibleValues($values); $fld_reasonOnHold->showDefaultOption() ->setDefaultOptionText($this->lang['formFields']['select']['statusReason']); $form->addElement($fld_reasonOnHold); $fld_status->setControlledElements(['refused'=> [$fld_reasonRefused], 'onHold'=> [$fld_reasonOnHold]], 'hide'); $fld_description = new \Engine\Form\Input\Textarea($this->lang['formFields']['statusDescription'], 'statusDescription', $this->values['statusDescription']); $form->addElement($fld_description); $fld_estimatedTime = new \Engine\Form\Input\Datetime($this->lang['formFields']['estimatedFinishTime'], 'estimatedFinishTime', $this->values['estimatedFinishTime']); $fld_estimatedTime->setCustomHTML($this->lang['formFields']['details']['deadline']); $form->addElement($fld_estimatedTime); $fld_estimatedDuration = new \Engine\Form\Input\ElementWithElements($this->lang['formFields']['estimatedDuration'], null, null); $fld_estimatedDurationValue = \Engine\Form\Input\Text::create(null, 'estimatedDurationValue', $this->values['estimatedDurationValue']); $fld_estimatedDurationUnit = \Engine\Form\Input\Select::create(null, 'estimatedDurationUnit', $this->values['estimatedDurationUnit'], [ 'minutes' => $this->lang['formFields']['durationUnits']['minutes'], 'hours' => $this->lang['formFields']['durationUnits']['hours'], 'days' => $this->lang['formFields']['durationUnits']['days'], ]); $fld_estimatedDuration->addElement($fld_estimatedDurationValue, 'main'); $fld_estimatedDuration->addElement($fld_estimatedDurationUnit, 'main'); $fld_estimatedDuration->setStyle('renderMode', 'inline'); $form->addElement($fld_estimatedDuration); $form->addElement(new \Engine\Form\Input\Hidden('', 'id', $this->values['id'])); $form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1)); return $form; } } 