Example #1
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');
 }
Example #2
0
 /**
  * @return Evaluation
  */
 public function getEvaluation()
 {
     /*
      * If the evaluation is null, create it
      */
     if (is_null($this->evaluation)) {
         /*
          * $projectService, $evaluationType, $country cannot be null when we want to create a new evaluation
          */
         if (is_null($this->projectService)) {
             throw new \InvalidArgumentException(sprintf("ProjectService cannot be null to give evaluation in %s", $this->getAction(), __CLASS__));
         }
         if (is_null($this->evaluationType)) {
             throw new \InvalidArgumentException(sprintf("Evaluation type cannot be null to give evaluation in %s", $this->getAction(), __CLASS__));
         }
         if (is_null($this->country)) {
             throw new \InvalidArgumentException(sprintf("The country cannot be null to give evaluation in %s", $this->getAction(), __CLASS__));
         }
         $this->evaluation = new Evaluation();
         $this->evaluation->setProject($this->projectService->getProject());
         $auth = $this->getServiceLocator()->get('zfcuser_auth_service');
         $this->evaluation->setContact($auth->getIdentity());
         $this->evaluation->setType($this->evaluationType);
         $this->evaluation->setCountry($this->country);
     }
     return $this->evaluation;
 }
 /**
  * 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")]]);
 }
 /**
  * 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")]]);
 }
Example #5
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)]]);
 }
 /**
  * @param ProjectService $projectService
  * @param EntityManager  $entityManager
  */
 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' => ['required' => true, 'class' => 'form-control', 'placeholder' => _("txt-please-give-a-workpackage-document-name")]]);
     $this->add(['type' => 'DoctrineORMModule\\Form\\Element\\EntitySelect', 'name' => 'type', 'options' => ['label' => _("txt-type"), 'help-block' => _("txt-type-explanation"), 'object_manager' => $entityManager, 'target_class' => 'Project\\Entity\\Document\\Type', 'find_method' => ['name' => 'findAll', 'params' => ['criteria' => ['project' => $projectService->getProject()]]]], '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-update")]]);
     $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")]]);
 }
Example #7
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]);
 }
Example #8
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;
 }
 /**
  * @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];
 }