예제 #1
0
 /**
  * @param AffiliationService $affiliationService
  * @param GeneralService     $generalService
  */
 public function __construct(AffiliationService $affiliationService, GeneralService $generalService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '');
     $this->setAttribute('class', 'form-horizontal');
     $countries = [];
     foreach ($generalService->findAll('country') as $country) {
         $countries[$country->getId()] = $country->getCountry();
     }
     asort($countries);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'organisation', 'options' => ['label' => _("txt-organisation-name")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'registeredCountry', 'options' => ['value_options' => $countries, 'label' => _("txt-registered-country")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'vat', 'options' => ['label' => _("txt-vat-number")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'attention', 'options' => ['label' => _("txt-attention"), 'help-block' => _("txt-financial-attention-form-element-explanation")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-financial-attention-placeholder")]]);
     /*
      * Collect the financial contacts
      */
     $financialContactValueOptions = [];
     $financialContactValueOptions[$affiliationService->getAffiliation()->getContact()->getId()] = $affiliationService->getAffiliation()->getContact()->getFormName();
     /**
      * Add the associates
      */
     foreach ($affiliationService->getAffiliation()->getAssociate() as $contact) {
         $financialContactValueOptions[$contact->getId()] = $contact->getFormName();
     }
     $organisation = $affiliationService->getAffiliation()->getOrganisation();
     /**
      * Add the contacts in the organisation
      */
     foreach ($organisation->getContactOrganisation() as $contactOrganisation) {
         $financialContactValueOptions[$contactOrganisation->getContact()->getId()] = $contactOrganisation->getContact()->getFormName();
     }
     /**
      * Add all the financial contacts form other projects
      */
     foreach ($organisation->getAffiliation() as $affiliation) {
         if (!is_null($affiliation->getFinancial())) {
             $financialContactValueOptions[$affiliation->getFinancial()->getContact()->getId()] = $affiliation->getFinancial()->getContact()->getFormName();
         }
     }
     asort($financialContactValueOptions);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $financialContactValueOptions, 'label' => _("txt-financial-contact")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $organisationFinancial = new FinancialOrganisation();
     $this->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'omitContact', 'options' => ['value_options' => $organisationFinancial->getOmitContactTemplates(), 'label' => _("txt-omit-contact")], 'attributes' => ['required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'address', 'options' => ['label' => _("txt-address")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-address-placeholder"), 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'zipCode', 'options' => ['label' => _("txt-zip-code")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-zip-code-placeholder"), 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'city', 'options' => ['label' => _("txt-city")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-city-placeholder"), 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'country', 'options' => ['value_options' => $countries, 'label' => _("txt-country")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'preferredDelivery', 'options' => ['value_options' => $organisationFinancial->getEmailTemplates(), 'label' => _("txt-preferred-delivery")], 'attributes' => ['required' => true]]);
     $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' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
예제 #2
0
 /**
  * @param AffiliationService $affiliationService
  * @param ContactService     $contactService
  */
 public function __construct(AffiliationService $affiliationService, ContactService $contactService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $contacts = [];
     foreach ($contactService->findContactsInOrganisation($affiliationService->getAffiliation()->getOrganisation()) as $contact) {
         $contacts[$contact->getId()] = $contact->getDisplayName();
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $contacts, 'label' => _("txt-contact-name")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $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' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
예제 #3
0
 /**
  * AdminAffiliation constructor.
  *
  * @param AffiliationService  $affiliationService
  * @param OrganisationService $organisationService
  */
 public function __construct(AffiliationService $affiliationService, OrganisationService $organisationService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '');
     $this->setAttribute('class', 'form-horizontal');
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'organisation', 'options' => ['value_options' => [$affiliationService->getAffiliation()->getOrganisation()->getId() => $affiliationService->getAffiliation()->getOrganisation()->getOrganisation()], 'label' => _("txt-organisation")]]);
     $technicalContactValueOptions = [];
     /*
      * Collect the technical contacts
      */
     $technicalContactValueOptions[$affiliationService->getAffiliation()->getContact()->getId()] = $affiliationService->getAffiliation()->getContact()->getFormName();
     foreach ($affiliationService->getAffiliation()->getAssociate() as $contact) {
         $technicalContactValueOptions[$contact->getId()] = $contact->getFormName();
     }
     asort($technicalContactValueOptions);
     /*
      * Collect the financial contacts
      * This array starts from the technical contacts
      */
     $financialContactValueOptions = $technicalContactValueOptions;
     $organisation = $affiliationService->getAffiliation()->getOrganisation();
     foreach ($organisation->getAffiliation() as $affiliation) {
         if (!is_null($affiliation->getFinancial())) {
             $financialContactValueOptions[$affiliation->getFinancial()->getContact()->getId()] = $affiliation->getFinancial()->getContact()->getFormName();
         }
     }
     asort($financialContactValueOptions);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'branch', 'options' => ['label' => _("txt-branch"), 'help-block' => _("txt-branch-inline-help")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Date', 'name' => 'dateEnd', 'options' => ['label' => _("txt-date-removed"), 'help-block' => _("txt-date-removed-inline-help")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Date', 'name' => 'dateSelfFunded', 'options' => ['label' => _("txt-date-self-funded"), 'help-block' => _("txt-date-self-funded-inline-help")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $technicalContactValueOptions, 'label' => _("txt-technical-contact")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'valueChain', 'options' => ['label' => _("txt-position-on-value-chain"), 'help-block' => _("txt-position-on-value-chain-inline-help")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'mainContribution', 'options' => ['label' => _("txt-main-contribution-for-the-project"), 'help-block' => _("txt--main-contribution-for-the-project-inline-help")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'marketAccess', 'options' => ['label' => _("txt-market-access"), 'help-block' => _("txt-market-access-inline-help")], 'attributes' => ['cols' => 8, 'class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'financialContact', 'options' => ['value_options' => $financialContactValueOptions, 'label' => _("txt-financial-contact")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'financialBranch', 'options' => ['label' => _("txt-branch"), 'help-block' => _("txt-branch-inline-help")]]);
     $financialOrganisation = [];
     if (!is_null($financial = $affiliationService->getAffiliation()->getFinancial())) {
         $financialOrganisation[$financial->getOrganisation()->getId()] = $financial->getOrganisation()->getOrganisation();
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'financialOrganisation', 'options' => ['value_options' => $financialOrganisation, 'label' => _("txt-financial-organisation"), 'help-block' => _("txt-financial-organisation-help")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Email', 'name' => 'emailCC', 'options' => ['label' => _("txt-email-cc"), 'help-block' => _("txt-email-cc-inline-help")]]);
     $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' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'deactivate', 'attributes' => ['class' => "btn btn-danger", 'value' => sprintf(_("Deactivate %s"), $affiliationService->getAffiliation()->getOrganisation()->getOrganisation())]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'reactivate', 'attributes' => ['class' => "btn btn-warning", 'value' => sprintf(_("Reactivate %s"), $affiliationService->getAffiliation()->getOrganisation()->getOrganisation())]]);
 }
예제 #4
0
 /**
  * EditAssociate constructor.
  * @param AffiliationService $affiliationService
  */
 public function __construct(AffiliationService $affiliationService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '');
     $this->setAttribute('class', 'form-horizontal');
     //We can transfer the assocate to ohter affiliations in the project
     $affiliations = [];
     foreach ($affiliationService->getAffiliation()->getProject()->getAffiliation() as $affiliation) {
         $affiliations[$affiliation->getId()] = sprintf("%s (%s) %s", $affiliation->getOrganisation()->getOrganisation(), $affiliation->getOrganisation()->getCountry(), is_null($affiliation->getDateEnd()) ? '' : ' (deactivated)');
     }
     asort($affiliations);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'affiliation', 'options' => ['value_options' => $affiliations, 'label' => _("txt-partner-name")]]);
     $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")]]);
 }
 /**
  *
  */
 public function testCanSetAffiliations()
 {
     $service = new AffiliationService();
     // Create a dummy user entity
     $affiliation = new Affiliation();
     $affiliation->setId(1);
     // Create a dummy user entity
     $affiliation2 = new Affiliation();
     $affiliation2->setId(2);
     // Mock the repository, disabling the constructor
     $userRepositoryMock = $this->getMockBuilder(\Affiliation\Repository\Affiliation::class)->disableOriginalConstructor()->getMock();
     $userRepositoryMock->expects($this->once())->method('findAll')->will($this->returnValue([$affiliation, $affiliation2]));
     // Mock the entity manager
     $emMock = $this->getMock('EntityManager', ['getRepository'], [], '', false);
     $emMock->expects($this->any())->method('getRepository')->will($this->returnValue($userRepositoryMock));
     $service->setEntityManager($emMock);
     $this->assertEquals(2, sizeof($service->findAll('affiliation')));
 }
예제 #6
0
 /**
  * @param AffiliationService $affiliationService
  */
 public function __construct(AffiliationService $affiliationService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '');
     $this->setAttribute('class', 'form-horizontal');
     $technicalContactValueOptions = [];
     $affiliationValueOptions = [];
     foreach ($affiliationService->parseRenameOptions() as $country => $options) {
         $groupOptions = [];
         foreach ($options as $organisationId => $branchAndName) {
             foreach ($branchAndName as $branch => $organisationWithBranch) {
                 $groupOptions[sprintf("%s|%s", $organisationId, $branch)] = $organisationWithBranch;
             }
         }
         $affiliationValueOptions[$country] = ['label' => $country, 'options' => $groupOptions];
     }
     /*
      * Collect the technical contacts
      */
     $technicalContactValueOptions[$affiliationService->getAffiliation()->getContact()->getId()] = $affiliationService->getAffiliation()->getContact()->getFormName();
     foreach ($affiliationService->getAffiliation()->getAssociate() as $contact) {
         $technicalContactValueOptions[$contact->getId()] = $contact->getFormName();
     }
     asort($technicalContactValueOptions);
     /*
      * Collect the financial contacts
      * This array starts from the technical contacts
      */
     $financialContactValueOptions = $technicalContactValueOptions;
     $organisation = $affiliationService->getAffiliation()->getOrganisation();
     foreach ($organisation->getAffiliation() as $affiliation) {
         if (!is_null($affiliation->getFinancial())) {
             $financialContactValueOptions[$affiliation->getFinancial()->getContact()->getId()] = $affiliation->getFinancial()->getContact()->getFormName();
         }
     }
     asort($financialContactValueOptions);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'affiliation', 'options' => ['value_options' => $affiliationValueOptions, 'label' => _("txt-change-affiliation")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'technical', 'options' => ['value_options' => $technicalContactValueOptions, 'label' => _("txt-technical-contact")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'financial', 'options' => ['value_options' => $financialContactValueOptions, 'label' => _("txt-financial-contact")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'valueChain', 'options' => ['label' => _("txt-position-on-value-chain"), 'help-block' => _("txt-position-on-value-chain-inline-help")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'mainContribution', 'options' => ['label' => _("txt-main-contributions-and-added-value"), 'help-block' => _("txt--main-contribution-for-the-project-inline-help")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'marketAccess', 'options' => ['label' => _("txt-market-access"), 'help-block' => _("txt-market-access-inline-help")], 'attributes' => ['cols' => 8, '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' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'deactivate', 'attributes' => ['class' => "btn btn-danger", 'value' => sprintf(_("Deactivate %s"), $affiliationService->getAffiliation()->getOrganisation()->getOrganisation())]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'reactivate', 'attributes' => ['class' => "btn btn-warning", 'value' => sprintf(_("Reactivate %s"), $affiliationService->getAffiliation()->getOrganisation()->getOrganisation())]]);
 }
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return AffiliationService
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $affiliationService = new AffiliationService();
     $affiliationService->setServiceLocator($serviceLocator);
     /** @var EntityManager $entityManager */
     $entityManager = $serviceLocator->get(EntityManager::class);
     $affiliationService->setEntityManager($entityManager);
     /** @var AdminService $adminService */
     $adminService = $serviceLocator->get(AdminService::class);
     $affiliationService->setAdminService($adminService);
     /** @var InvoiceService $invoiceService */
     $invoiceService = $serviceLocator->get(InvoiceService::class);
     $affiliationService->setInvoiceService($invoiceService);
     /** @var VersionService $versionService */
     $versionService = $serviceLocator->get(VersionService::class);
     $affiliationService->setVersionService($versionService);
     /** @var OrganisationService $organisationService */
     $organisationService = $serviceLocator->get(OrganisationService::class);
     $affiliationService->setOrganisationService($organisationService);
     /** @var Authorize $authorizeService */
     $authorizeService = $serviceLocator->get(Authorize::class);
     $affiliationService->setAuthorizeService($authorizeService);
     return $affiliationService;
 }
예제 #8
0
 /**
  * This if the market access is given.
  *
  * @param AffiliationService $affiliationService
  */
 private function checkAffiliationMarketAccess(AffiliationService $affiliationService)
 {
     /*
      * Check the market access
      */
     if (strlen($affiliationService->getAffiliation()->getMarketAccess()) < self::MINIMAL_FIELD_LENGTH) {
         if (!array_key_exists(self::CHECKLIST_AFFILIATION_FIELD_LENGTH_MARKET_ACCESS, $this->warnings)) {
             $this->warnings[self::CHECKLIST_AFFILIATION_FIELD_LENGTH_MARKET_ACCESS] = [];
         }
         $this->partnersWithEmptyMarketAccess[] = $this->getAffiliationLink($affiliationService->getAffiliation());
     }
 }