/**
  * Produce a form element.
  *
  * @param Workpackage    $workpackage
  * @param ProjectService $projectService
  */
 public function __construct(Workpackage $workpackage, ProjectService $projectService)
 {
     parent::__construct($workpackage->getId());
     foreach ($projectService->getAffiliation() as $affiliationService) {
         $affiliationFieldSet = new EffortPerAffiliationFieldset($affiliationService->getAffiliation(), $projectService);
         $this->add($affiliationFieldSet);
     }
 }
예제 #2
0
 /**
  * Class constructor.
  */
 public function __construct(ProjectService $projectService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $valueChainFieldSet = new Fieldset('affiliation');
     foreach ($projectService->getAffiliation() as $affiliationService) {
         $fieldSet = new Fieldset($affiliationService->getAffiliation()->getId());
         $fieldSet->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'valueChain', 'options' => ['label' => sprintf(_("%s from %s"), $affiliationService->getAffiliation()->getOrganisation(), $affiliationService->getAffiliation()->getOrganisation()->getCountry())], 'attributes' => ['class' => 'form-control', 'placeholder' => sprintf(_("Posistion of %s on the value chain"), $affiliationService->getAffiliation()->getOrganisation(), $affiliationService->getAffiliation()->getOrganisation()->getCountry())]]);
         $valueChainFieldSet->add($fieldSet);
     }
     $this->add($valueChainFieldSet);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update-value-chain")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
예제 #3
0
 /**
  * @param ProjectService     $projectService
  * @param WorkpackageService $workpackageService
  */
 public function __construct(ProjectService $projectService, WorkpackageService $workpackageService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $fieldSet = new Fieldset('costPerAffiliationAndYear');
     foreach ($projectService->getAffiliation() as $affiliationService) {
         $affiliationFieldSet = new CostPerAffiliationFieldset($affiliationService->getAffiliation(), $projectService);
         $fieldSet->add($affiliationFieldSet);
     }
     $fieldSet->setUseAsBaseFieldset(true);
     $this->add($fieldSet);
     $fieldSet = new Fieldset('effortPerAffiliationAndYear');
     foreach ($workpackageService->findWorkpackageByProjectAndWhich($projectService->getProject()) as $workpackage) {
         $workpackageFieldSet = new EffortPerWorkpackageAndAffiliationFieldset($workpackage, $projectService);
         $fieldSet->add($workpackageFieldSet);
     }
     $fieldSet->setUseAsBaseFieldset(true);
     $this->add($fieldSet);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update-costs-and-effort")]]);
 }
예제 #4
0
 /**
  * This function will sum all the costs in a project.
  *
  * @param ProjectService $projectService
  *
  * @return array
  */
 public function findTotalCostByProject(ProjectService $projectService)
 {
     $costResult = 0;
     foreach ($projectService->getAffiliation() as $affiliationService) {
         /*
          * @var Cost\Cost[]
          */
         $cost = $this->getEntityManager()->getRepository($this->getFullEntityName('Cost\\Cost'))->findBy(['affiliation' => $affiliationService->getAffiliation()]);
         foreach ($cost as $singleCost) {
             $costResult += $singleCost->getCosts();
         }
     }
     return $costResult;
 }