Ejemplo n.º 1
0
 /**
  * @param Affiliation $affiliation
  * @param string      $action
  */
 public function updateCountryRationaleByAffiliation(Affiliation $affiliation, $action)
 {
     switch ($action) {
         case self::AFFILIATION_DEACTIVATE:
             $rationale = $this->findRationaleByProjectAndCountry($affiliation->getProject(), $affiliation->getOrganisation()->getCountry());
             //We need to check the rationale and maybe delete or update the contact persons.
             if (!is_null($rationale) && $rationale->getContact()->getId() === $affiliation->getContact()->getId()) {
                 //There is only 1 rationale, and our partner is contact person, so we need to update the contact
                 //or delete the rationale if there are no other countries available for the project
                 $countryFound = false;
                 //The country is still active in the project, we need to assign a new rationale responsible
                 foreach ($this->getAffiliationService()->findAffiliationByProjectAndCountryAndWhich($affiliation->getProject(), $affiliation->getOrganisation()->getCountry()) as $affiliationService) {
                     //Give the country rationale to the first contact in the affiliation
                     $rationale->setContact($affiliationService->getAffiliation()->getContact());
                     $this->updateEntity($rationale);
                     break 2;
                 }
                 if (!$countryFound) {
                     $this->removeEntity($rationale);
                 }
             }
             break;
         case self::AFFILIATION_REACTIVATE:
             //Simply use this function as a proxy to the generate function
             $this->generateCountryRationaleByProject($affiliation->getProject());
             break;
     }
 }
Ejemplo n.º 2
0
 /**
  * @param Affiliation $affiliation
  *
  * @return bool
  */
 public function canCreateInvoice(Affiliation $affiliation)
 {
     $errors = [];
     switch (true) {
         case $affiliation->getOrganisation()->getType()->getInvoice() === Type::NO_INVOICE && !($affiliation->getProject()->getCall()->getProgram()->getId() === 3 && $affiliation->getOrganisation()->getType()->getId() === Type::TYPE_UNIVERSITY):
             $errors[] = sprintf('No invoice is needed for %s', $affiliation->getOrganisation()->getType()->getDescription());
             break;
         case is_null($affiliation->getFinancial()):
             $errors[] = 'No financial organisation (affiliation financial) set for this partner';
             break;
         case !is_null($affiliation->getDateEnd()):
             $errors[] = 'Partner is de-activated';
             break;
         case is_null($affiliation->getFinancial()->getOrganisation()->getFinancial()):
             $errors[] = 'No financial information set for this organisation';
             break;
         case is_null($affiliation->getFinancial()->getContact()):
             $errors[] = 'No financial contact set for this organisation';
             break;
     }
     return $errors;
 }
Ejemplo n.º 3
0
 /**
  * @param Affiliation $affiliation
  *
  * @return array
  */
 public function findContactsInAffiliation(Affiliation $affiliation)
 {
     $contacts = [];
     $contactRole = [];
     /*
      * Add the technical contact
      */
     $contacts[$affiliation->getContact()->getId()] = $affiliation->getContact();
     $contactRole[$affiliation->getContact()->getId()][] = 'Technical Contact';
     /*
      * Add the financial contact
      */
     if (!is_null($affiliation->getFinancial())) {
         $contacts[$affiliation->getFinancial()->getContact()->getId()] = $affiliation->getFinancial()->getContact();
         $contactRole[$affiliation->getFinancial()->getContact()->getId()][] = 'Financial Contact';
     }
     /*
      * Add the associates
      */
     foreach ($affiliation->getAssociate() as $associate) {
         /*
          * Add the associates
          */
         $contacts[$associate->getId()] = $associate;
         $contactRole[$associate->getId()][] = 'Associate';
     }
     /*
      * Add the workpackage leaders
      */
     foreach ($affiliation->getProject()->getWorkpackage() as $workpackage) {
         /*
          * Add the work package leaders
          */
         if (!is_null($workpackage->getContact()->getContactOrganisation()) && $workpackage->getContact()->getContactOrganisation()->getOrganisation()->getId() === $affiliation->getOrganisation()->getId()) {
             $contacts[$workpackage->getContact()->getId()] = $workpackage->getContact();
             $contactRole[$workpackage->getContact()->getId()][] = 'Workpackage leader';
         }
     }
     $contactRole = array_map('array_unique', $contactRole);
     //Store the values local for the use of the toArray function
     $this->contacts = $contacts;
     return ['contacts' => $contacts, 'contactRole' => $contactRole];
 }
Ejemplo n.º 4
0
 /**
  * @param Affiliation $affiliation
  *
  * @return array
  */
 private function parseExtendedAffiliationOverview(Affiliation $affiliation)
 {
     $rows = [];
     $cols = [];
     $organisationService = $this->getOrganisationService()->setOrganisation($affiliation->getOrganisation());
     $contactService = clone $this->getContactService();
     $contactService->setContact($affiliation->getContact());
     $cols['dt'] = ['width' => 2000, 'align' => ''];
     $cols['dd'] = ['width' => $this->tableWidth - 2000, 'align' => ''];
     $rows[] = ['dt' => $affiliation->getOrganisation()->getCountry()->getCountry(), 'dd' => $organisationService->parseOrganisationWithBranch($affiliation->getBranch())];
     if ($affiliation->getDescription()->count() > 0) {
         $rows[] = ['dt' => 'Description', 'dd' => $this->cleanHTML($affiliation->getDescription()->first()->getDescription())];
     }
     $rows[] = ['dt' => 'Type', 'dd' => $organisationService->getOrganisation()->getType()->getDescription()];
     $rows[] = ['dt' => 'Contact Person', 'dd' => $contactService->parseAttention() . ' ' . $contactService->parseFullname()];
     $rows[] = ['dt' => 'Email Address', 'dd' => $contactService->getContact()->getEmail()];
     $rows[] = ['dt' => 'Main role and added-value for the project', 'dd' => $affiliation->getMainContribution()];
     $rows[] = ['dt' => 'Market access', 'dd' => $affiliation->getMarketAccess()];
     return ['cols' => $cols, 'rows' => $rows];
 }