Exemplo n.º 1
1
 /**
  * Class constructor.
  */
 public function __construct(ProjectService $projectService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $this->setAttribute('id', 'create-report');
     /*
      * Create an array with possible periods. This will trigger a date but display a period (semester)
      */
     $semesterOptions = [];
     foreach ($projectService->parseYearRange() as $year) {
         /*
          * Use the Report object to parse the data
          */
         $report = new Report();
         $report->setDatePeriod(\DateTime::createFromFormat('Y-m-d', $year . '-03-01'));
         $semesterOptions[$year . '-1'] = $report->parseName();
         $report->setDatePeriod(\DateTime::createFromFormat('Y-m-d', $year . '-09-01'));
         $semesterOptions[$year . '-2'] = $report->parseName();
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'period', 'options' => ['label' => _("txt-report-period"), 'help-block' => _("txt-report-period-explanation"), 'value_options' => $semesterOptions], 'attributes' => ['class' => "form-control", 'id' => "period"]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'item', 'options' => ['label' => _("txt-document-name"), 'help-block' => _("txt-document-name-explanation")], 'attributes' => ['placeholder' => _("txt-please-give-a-document-name")]]);
     $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => ["label" => "txt-file", "help-block" => _("txt-file-requirements")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-create")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
Exemplo n.º 2
0
 /**
  * AddAffiliation constructor.
  *
  * @param OrganisationService $organisationService
  * @param ProjectService      $projectService
  */
 public function __construct(OrganisationService $organisationService, ProjectService $projectService)
 {
     parent::__construct();
     $currentProjects = [];
     /**
      * @var $projectService ProjectService
      */
     foreach ($projectService->findProjectByOrganisation($organisationService->getOrganisation(), ProjectService::WHICH_ALL) as $projectService) {
         $currentProjects[] = $projectService->getProject()->getId();
     }
     $projects = [];
     /**
      * @var $newProjectService ProjectService
      */
     foreach ($projectService->findAllProjects(ProjectService::WHICH_ALL)->getResult() as $newProject) {
         if (!in_array($newProject->getId(), $currentProjects)) {
             $projects[$newProject->getId()] = sprintf("%s", $newProject);
         }
     }
     arsort($projects);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'project', 'options' => ['value_options' => $projects, 'help-block' => _("txt-project-help-block")], 'attributes' => ['label' => _("txt-project")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'branch', 'options' => ['help-block' => _("txt-branch-help-block")], 'attributes' => ['label' => _("txt-branch")]]);
     $contacts = [];
     foreach ($organisationService->getOrganisation()->getContactOrganisation() as $contactOrganisation) {
         $contacts[$contactOrganisation->getContact()->getId()] = $contactOrganisation->getContact()->getFormName();
     }
     asort($contacts);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $contacts, 'help-block' => _("txt-technical-contact-help-block")], 'attributes' => ['label' => _("txt-technical-contact")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->versionService = $this->serviceManager->get(VersionService::class);
     $version = new Version();
     $version->setId(1);
     $versionType = new Type();
     $versionType->setDescription('This is the description');
     $version->setVersionType($versionType);
     $this->versionService->setVersion($version);
     $project = new Project();
     $project->setProject('This is the project');
     $this->projectService = $this->serviceManager->get(ProjectService::class);
     //        $this->projectService->setProject($project);
     $this->projectService->setProjectId(1);
     $this->versionService->getVersion()->setProject($this->projectService->getProject());
     $authorizeServiceMock = $this->getMockBuilder('BjyAuthorize\\View\\Helper\\IsAllowed')->disableOriginalConstructor()->getMock();
     $authorizeServiceMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $viewHelperManager = $this->serviceManager->get('viewhelpermanager');
     $viewHelperManager->setService('isAllowed', $authorizeServiceMock);
     $urlViewHelperMock = $this->getMockBuilder(Url::class)->disableOriginalConstructor()->getMock();
     $urlViewHelperMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $viewHelperManager->setService('url', $urlViewHelperMock);
     $this->versionLink = $viewHelperManager->get('versionlink');
 }
 /**
  * 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);
     }
 }
Exemplo n.º 5
0
 /**
  * @return ProjectService
  */
 public function getProjectService()
 {
     if (is_null($this->projectService)) {
         $this->projectService = new ProjectService();
         $project = new Project();
         $this->projectService->setProject($project);
     }
     return $this->projectService;
 }
 /**
  * Produce a form element.
  *
  * @param Affiliation    $affiliation
  * @param ProjectService $projectService
  */
 public function __construct(Affiliation $affiliation, ProjectService $projectService)
 {
     parent::__construct($affiliation->getId());
     foreach ($projectService->parseEditYearRange() as $year) {
         $fieldSet = new Fieldset($year);
         $fieldSet->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'cost', 'attributes' => ['class' => 'form-control cost-input year-' . $year, 'label' => 'cost', 'placeholder' => _("txt-cost")]]);
         $this->add($fieldSet);
     }
 }
Exemplo n.º 7
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->projectService = $this->serviceManager->get(ProjectService::class);
     $this->projectService->setProjectId(1);
     $authorizeServiceMock = $this->getMockBuilder('BjyAuthorize\\View\\Helper\\IsAllowed')->disableOriginalConstructor()->getMock();
     $authorizeServiceMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $viewHelperManager = $this->serviceManager->get('viewhelpermanager');
     $viewHelperManager->setService('isAllowed', $authorizeServiceMock);
     $urlViewHelperMock = $this->getMockBuilder(Url::class)->disableOriginalConstructor()->getMock();
     $urlViewHelperMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $viewHelperManager->setService('url', $urlViewHelperMock);
     $this->projectLink = $viewHelperManager->get('projectLink');
 }
 /**
  * Class constructor.
  *
  * @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('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-planned-versus-spent")]]);
 }
Exemplo n.º 9
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")]]);
 }
Exemplo n.º 10
0
 /**
  * @param ProjectService $projectService
  * @param EntityManager  $entityManager
  */
 public function __construct(ProjectService $projectService, EntityManager $entityManager)
 {
     parent::__construct();
     $doctrineHydrator = new DoctrineHydrator($entityManager);
     $this->setHydrator($doctrineHydrator)->setObject(new Document());
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $this->setAttribute('id', 'create-document');
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'document', 'options' => ['label' => _("txt-document-name"), 'help-block' => _("txt-document-name-explanation")], 'attributes' => ['required' => true, 'placeholder' => _("txt-please-give-a-document-name")]]);
     $this->add(['type' => 'DoctrineORMModule\\Form\\Element\\EntitySelect', 'name' => 'type', 'options' => ['label' => _("txt-document-type"), 'help-block' => _("txt-document-type-explanation"), 'object_manager' => $entityManager, 'target_class' => 'Project\\Entity\\Document\\Type', 'find_method' => ['name' => 'findDocumentTypeByVersionType', 'params' => ['type' => $projectService->getNextMode()->versionType->getId()]]], 'attributes' => ['required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Csrf', 'name' => 'csrf']);
     $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => ["label" => _("txt-file"), "help-block" => _("txt-file-requirements")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-upload")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'delete', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-delete")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
Exemplo n.º 11
0
 /**
  * Parse the action.
  */
 public function parseAction()
 {
     switch ($this->getAction()) {
         case 'evaluate-project':
             //Evaluate and overview are the same actions
         //Evaluate and overview are the same actions
         case 'overview-project':
             /*
              * The parameters are the same but the router and the text change
              */
             if ($this->getAction() === 'overview-project') {
                 $this->setRouter('community/evaluation/overview-project');
                 $this->setText(sprintf($this->translate("txt-overview-%s-evaluation-for-project-%s-in-%s"), $this->evaluationType, $this->projectService->parseFullName(), $this->country));
             } else {
                 $this->setRouter('community/evaluation/evaluate-project');
                 $this->setText(sprintf($this->translate("txt-give-%s-evaluation-for-project-%s-in-%s"), $this->evaluationType, $this->projectService->parseFullName(), $this->country));
             }
             break;
         case 'download-project':
             $this->setRouter('community/evaluation/download-project');
             $this->setText(sprintf($this->translate("txt-download-overview-%s-evaluation-for-project-%s-in-%s"), $this->evaluationType, $this->projectService->parseFullName(), $this->country));
             break;
         default:
             throw new \InvalidArgumentException(sprintf("%s is an incorrect action for %s", $this->getAction(), __CLASS__));
     }
 }
Exemplo n.º 12
0
 /**
  * Class constructor.
  */
 public function __construct(ProjectService $projectService, EntityManager $entityManager)
 {
     parent::__construct();
     $document = new Document();
     $doctrineHydrator = new DoctrineHydrator($entityManager);
     $this->setHydrator($doctrineHydrator)->setObject($document);
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $this->setAttribute('id', 'create-document');
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'document', 'options' => ['label' => _("txt-document-name"), 'help-block' => _("txt-document-name-explanation")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-please-give-a-workpackage-document-name")]]);
     $this->add(['type' => 'DoctrineORMModule\\Form\\Element\\EntitySelect', 'name' => 'workpackage', 'options' => ['label' => _("txt-workpackage"), 'help-block' => _("txt-workpackage-explanation"), 'object_manager' => $entityManager, 'target_class' => 'Project\\Entity\\Workpackage\\Workpackage', 'find_method' => ['name' => 'findBy', 'params' => ['criteria' => ['project' => $projectService->getProject()]]]], 'attributes' => ['required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'public', 'options' => ['label' => _("txt-confidentiality"), 'help-block' => _("txt-workpackage-public-explanation"), 'value_options' => $document->getPublicTemplates()], 'attributes' => ['required' => true]]);
     $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => ["label" => _("txt-file"), "help-block" => _("txt-file-requirements")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'delete', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-delete")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
Exemplo n.º 13
0
 /**
  * Returns true if and only if $value is less than max option, inclusively
  * when the inclusive option is true.
  *
  * @param mixed $value
  *
  * @return bool
  */
 public function isValid($value)
 {
     $this->setValue($value);
     /*
      * We need to make an array of all given documents and the corresponding types
      */
     $availableDocuments = [];
     foreach ($value as $documentId) {
         $availableDocuments[] = $this->projectService->findEntityById('Document\\Document', $documentId);
     }
     /*
      * Create an array of required documents
      */
     $requiredDocumentTypes = [];
     foreach ($this->type->getDocumentType() as $requiredDocumentType) {
         $requiredDocumentTypes[$requiredDocumentType->getId()] = $requiredDocumentType;
     }
     /*
      * Check first if an unwanted document is given
      */
     foreach ($availableDocuments as $document) {
         if (!array_key_exists($document->getType()->getId(), $requiredDocumentTypes)) {
             $this->setDocumentType($document->getType());
             $this->error(self::DOCUMENT_NOT_NEEDED);
             return false;
         }
     }
     /*
      * Check now if a double document is selected
      */
     $alreadySelectedDocumentType = [];
     foreach ($availableDocuments as $document) {
         if (in_array($document->getType()->getId(), $alreadySelectedDocumentType)) {
             $this->setDocumentType($document->getType());
             $this->error(self::REQUIRED_DOCUMENT_DOUBLE);
             return false;
         }
         $alreadySelectedDocumentType[] = $document->getType()->getId();
     }
     /*
      * Check now if all required documents are present, this will be done by
      * emptying the requiredDocumentTypes array
      */
     foreach ($availableDocuments as $document) {
         if (array_key_exists($document->getType()->getId(), $requiredDocumentTypes)) {
             unset($requiredDocumentTypes[$document->getType()->getId()]);
         }
     }
     /*
      * Now return false when the size of the requiredDocumentArray > 0
      */
     if (sizeof($requiredDocumentTypes) > 0) {
         $this->setDocumentType(implode(', ', $requiredDocumentTypes));
         $this->error(self::REQUIRED_DOCUMENT_MISSING);
         return false;
     }
     return true;
 }
Exemplo n.º 14
0
 /**
  * @param ProjectService $projectService
  * @param Type           $type
  */
 public function __construct(ProjectService $projectService, Type $type)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $this->type = $type;
     $this->projectService = $projectService;
     /*
      * Create an array of required documents
      */
     $versionDocuments = [];
     if (sizeof($type->getDocumentType()) > 0 && sizeof($projectService->getProject()->getDocument()) > 0) {
         foreach ($type->getDocumentType() as $requiredDocumentType) {
             foreach ($projectService->getProject()->getDocument() as $document) {
                 if ($document->getType()->getId() === $requiredDocumentType->getId()) {
                     $versionDocuments[$document->getId()] = sprintf(_("Document: %s (%s)"), $document->getDocument(), $document->getType());
                 }
             }
         }
     }
     $this->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'versionDocuments', 'options' => ['label' => _("txt-version-documents"), 'help-block' => _("txt-select-version-documents"), 'value_options' => $versionDocuments]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'create', 'attributes' => ['class' => "btn btn-primary", 'value' => sprintf(_("Submit %s"), $type)]]);
 }
Exemplo n.º 15
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;
 }
Exemplo n.º 16
0
 /**
  * Produce a list of contacts which are active in a project.
  *
  * @param ProjectService $projectService
  *
  * @return Contact[]
  *
  * @throws \InvalidArgumentException
  */
 public function findContactsInProject(ProjectService $projectService)
 {
     /*
      * Throw an exception when no project is selected
      */
     if (is_null($projectService->getProject())) {
         throw new \InvalidArgumentException(sprintf("No project selected"));
     }
     $contacts = [];
     /*
      * Add the project leader
      */
     $contacts[$projectService->getProject()->getContact()->getId()] = $projectService->getProject()->getContact();
     /*
      * Add the contacts form the affiliations and the associates
      */
     foreach ($projectService->getProject()->getAffiliation() as $affiliation) {
         $contacts[$affiliation->getContact()->getId()] = $affiliation->getContact();
         foreach ($affiliation->getAssociate() as $associate) {
             $contacts[$associate->getId()] = $associate;
         }
     }
     /*
      * Add the workpackage leaders
      */
     foreach ($projectService->getProject()->getWorkpackage() as $workpackage) {
         $contacts[$workpackage->getContact()->getId()] = $workpackage->getContact();
     }
     return $contacts;
 }
Exemplo n.º 17
0
 /**
  * @param ProjectService $projectService
  *
  * @return string
  */
 public function parseDocuments(ProjectService $projectService)
 {
     /*
      * Go over each of the items to create the order
      */
     $documents = [];
     $workpackageDocuments = [];
     /*
      * @var ResultLink
      */
     $resultLink = $this->serviceLocator->get('resultLink');
     /*
      * @var WorkpackageDocumentLink
      */
     $workpackageDocumentLink = $this->serviceLocator->get('workpackageDocumentLink');
     /*
      * @var PosterLink
      */
     $posterLink = $this->serviceLocator->get('posterLink');
     /*
      * @var ArticleLink
      */
     $articleLink = $this->serviceLocator->get('articleLink');
     /*
      * @var ArticleTypeIcon
      */
     $articleTypeIcon = $this->serviceLocator->get('articleTypeIcon');
     /*
      * @var ContentTypeIcon
      */
     $contentTypeIcon = $this->serviceLocator->get('contentTypeIcon');
     /*
      * @var NewsLink
      */
     $newsLink = $this->serviceLocator->get('newsLink');
     /*
      * @var PressArticleLink
      */
     $pressArticleLink = $this->serviceLocator->get('pressArticleLink');
     /*
      * Grab all the public results
      */
     foreach ($projectService->findPublicResults() as $result) {
         //Generate a key for sorting
         $key = 'label-' . $result->getType()->parseCssName() . '-' . $result->getResult();
         $documents[$key]['label'] = '<span class="label label-' . $result->getType()->parseCssName() . '">
             <span class="glyphicon glyphicon-file" title="' . $result->getType() . '"></span>
             </span> ';
         $documents[$key]['document'] = $resultLink($result, 'download', 'public-name') . ' <i class="fa fa-download itea"></i>';
     }
     /*
      * Grab all the workpackage documents
      */
     foreach ($projectService->findPublicWorkpackageDocuments() as $workpackageDocument) {
         /*
          * Check first if the Link has a length (and if the user has access)
          */
         $workpackageDocumentLinkResult = $workpackageDocumentLink($workpackageDocument, 'download', 'no_underscore_filename');
         if (!empty($workpackageDocumentLinkResult)) {
             //Generate a key for sorting
             $key = 'label-article-type-work-package-documents-' . $workpackageDocument->getDocument();
             $workpackageDocuments[$key]['label'] = '<span class="label label-article-type-work-package-documents">' . '<span class="glyphicon glyphicon-file"></span></span>';
             $workpackageDocuments[$key]['document'] = sprintf("%s %s %s", $contentTypeIcon($workpackageDocument->getContentType()), $workpackageDocumentLinkResult, ' <i class="fa fa-download itea"></i>');
         }
     }
     /*
      * Grab the posters
      */
     foreach ($projectService->findFinalPosters() as $poster) {
         //Generate a key for sorting
         $key = 'label-article-type-poster-' . $poster->getProject();
         $documents[$key]['label'] = '<span class="label label-article-type-poster"><span class="glyphicon glyphicon-file"></span></span>';
         $documents[$key]['document'] = $posterLink($poster, 'download', 'public-name') . '  <i class="fa fa-download itea"></i>';
     }
     /*
      * Iterate over all press articles
      */
     foreach ($projectService->getProject()->getArticle() as $article) {
         if ($article->getType()->getShowInList() === ArticleType::SHOW_IN_LIST_YES) {
             //Generate a key for sorting
             $key = 'label-' . $article->getType()->parseCssName() . '-' . $article->getArticle();
             $documents[$key]['label'] = $articleTypeIcon($article->getType());
             $documents[$key]['document'] = $articleLink($article, 'view-public', 'name');
         }
     }
     /*
      * Iterate over all news articles
      */
     $articleType = $this->getContentService()->findEntityById('articleType', ArticleType::TYPE_NEWS);
     foreach ($projectService->getProject()->getNews() as $news) {
         //Generate a key for sorting
         $key = 'label-' . $articleType->parseCssName() . '-' . $news->getNews();
         $documents[$key]['label'] = $articleTypeIcon($articleType);
         $documents[$key]['document'] = $newsLink($news, 'view', 'name');
     }
     /*
      * Iterate over all press articles
      */
     $articleType = $this->getContentService()->findEntityById('articleType', ArticleType::TYPE_PRESS);
     foreach ($projectService->getProject()->getPressArticle() as $pressArticle) {
         $key = 'label-' . $articleType->parseCssName() . '-' . $pressArticle->getArticle();
         $documents[$key]['label'] = $articleTypeIcon($articleType);
         $documents[$key]['document'] = $pressArticleLink($pressArticle, 'view', 'name');
     }
     ksort($documents);
     ksort($workpackageDocuments);
     return $this->getZfcTwigRenderer()->render('project/partial/list/document', ['documents' => $documents, 'workpackageDocuments' => $workpackageDocuments]);
 }
Exemplo n.º 18
0
 /**
  * @param ProjectService $projectService
  *
  * @return array
  */
 private function parseProjectConsortium(ProjectService $projectService)
 {
     $rows = [];
     $cols = [];
     $cols['dt'] = ['width' => 3000, 'align' => ''];
     $cols['dd'] = ['width' => $this->tableWidth - 3000, 'align' => ''];
     $affiliationOverview = $this->getAffiliationService()->findAffiliationByProjectPerCountryAndWhich($projectService->getProject());
     $nationalCoordinators = [];
     foreach ($projectService->getProject()->getRationale() as $rationale) {
         $nationalCoordinators[] = $rationale->getContact()->getContactOrganisation()->getOrganisation()->getId();
     }
     foreach ($affiliationOverview as $countryId => $affiliationInCountry) {
         /*
          * Build the string per country
          */
         $consortiumPerCountry = [];
         foreach ($affiliationInCountry as $affiliationService) {
             /*
              * @var Organisation
              */
             $organisation = $affiliationService->getAffiliation()->getOrganisation();
             if (in_array($organisation->getId(), $nationalCoordinators)) {
                 $consortiumPerCountry[] = $organisation->getOrganisation() . '*';
             } else {
                 $consortiumPerCountry[] = $organisation->getOrganisation();
             }
         }
         /*
          * //Find the country;.
          *
          * @var Country
          */
         $country = $this->getGeneralService()->findEntityById('country', $countryId);
         $rows[] = ['dt' => $country->getCountry(), 'dd' => implode(', ', $consortiumPerCountry)];
     }
     return ['cols' => $cols, 'rows' => $rows];
 }