Commit dd8e7954 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Ajout des champs RNSR et CNRS dans la fiche organisation

 - Génération des données PCRU / Validation des données générées (et affichage dans l'écran de synthèse)
parent 2ef5cce9
Loading
Loading
Loading
Loading
Loading
+4 −3
Changes for module/Oscar/src/Oscar/Controller/ProjectGrantController.php: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -630,8 +630,6 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                                throw new OscarException("Impossible d'enregistrer le demande : " . $e->getMessage());
                            }
                        }


                }
            } catch (OscarException $e) {
                return $this->getResponseInternalError($e->getMessage());
@@ -2808,6 +2806,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        $factory = new ActivityPcruInfoFromActivityFactory($this->getOscarConfigurationService(), $this->getEntityManager());
        $pcruInfos = $factory->createNew($activity);
        $headers = $factory->getHeaders();
        $datas = $pcruInfos->toArray();
        $validation = $pcruInfos->validation();

//        $form = new PcruInfosForm();
//        $form->setServiceContainer($this->getServiceContainer());
@@ -2827,8 +2827,9 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

        return [
            //'form' => $form,
            'validations' => $validation,
            'headers' => $headers,
            'datas' => $pcruInfos->toArray(),
            'datas' => $datas,
            'activity' => $activity
        ];
    }
+120 −0
Changes for module/Oscar/src/Oscar/Entity/ActivityPcruInfos.php: 120 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,12 @@ use Oscar\Utils\DateTimeUtils;
 */
class ActivityPcruInfos
{

    const VALIDATION_VALID = 'valid';
    const VALIDATION_DISABLED = 'disabled';
    const VALIDATION_ERROR = 'error';
    const VALIDATION_EMPTY = 'empty';

    /**
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
@@ -262,6 +268,120 @@ class ActivityPcruInfos
        return $out;
    }

    public function validation()
    {
        $datas = $this->toArray();

        $out = [];
        $out['Objet'] = self::VALIDATION_ERROR;                             // Requis
        $out['CodeUniteLabintel'] = self::VALIDATION_ERROR;                 // Requis
        $out['SigleUnite'] = self::VALIDATION_EMPTY;
        $out['NumContratTutelleGestionnaire'] = self::VALIDATION_ERROR;     // Requis
        $out['Equipe'] = self::VALIDATION_EMPTY;
        $out['TypeContrat'] = self::VALIDATION_ERROR;
        $out['Acronyme'] = self::VALIDATION_EMPTY;
        $out['ContratsAssocies'] = self::VALIDATION_EMPTY;
        $out['ResponsableScientifique'] = self::VALIDATION_ERROR;           // Requis
        $out['EmployeurResponsableScientifique'] = self::VALIDATION_EMPTY;
        $out['CoordinateurConsortium'] = self::VALIDATION_EMPTY;
        $out['Partenaires'] = self::VALIDATION_EMPTY;
        $out['PartenairePrincipal'] = self::VALIDATION_ERROR;               // Requis
        $out['IdPartenairePrincipal'] = self::VALIDATION_EMPTY;
        $out['SourceFinancement'] = self::VALIDATION_ERROR;                 // Requis
        $out['LieuExecution'] = self::VALIDATION_ERROR;                     // Requis
        $out['DateDerniereSignature'] = self::VALIDATION_ERROR;             // Requis
        $out['Duree'] = self::VALIDATION_EMPTY;
        $out['DateDebut'] = self::VALIDATION_ERROR;                         // Requis
        $out['DateFin'] = self::VALIDATION_ERROR;                           // Requis
        $out['MontantPercuUnite'] = self::VALIDATION_ERROR;                 // Requis
        $out['CoutTotalEtude'] = self::VALIDATION_EMPTY;
        $out['MontantTotal'] = self::VALIDATION_EMPTY;
        $out['ValidePoleCompetivite'] = self::VALIDATION_EMPTY;
        $out['PoleCompetivite'] = self::VALIDATION_EMPTY;
        $out['Commentaires'] = self::VALIDATION_EMPTY;
        $out['Pia'] = self::VALIDATION_EMPTY;
        $out['Reference'] = self::VALIDATION_EMPTY;
        $out['AccordCadre'] = self::VALIDATION_EMPTY;
        $out['Cifre'] = self::VALIDATION_EMPTY;
        $out['ChaireIndustrielle'] = self::VALIDATION_EMPTY;
        $out['PresencePartenaireIndustriel'] = self::VALIDATION_EMPTY;

        $disabledFields = [
            'Equipe','ContratsAssocies', 'EmployeurResponsableScientifique',
            'CoordinateurConsortium','Partenaires', 'PartenairePrincipal',
            'IdPartenairePrincipal','LieuExecution', 'Duree',
            'MontantPercuUnite','CoutTotalEtude', 'Commentaires',
            'Pia','AccordCadre', 'Cifre',
            'ChaireIndustrielle','PresencePartenaireIndustriel'
            ];

        foreach ($disabledFields as $unusedField) {
            $out[$unusedField] = self::VALIDATION_DISABLED;
        }

        if( $datas['Objet'] )
            $out['Objet'] = self::VALIDATION_VALID;

        if( $datas['CodeUniteLabintel'] )
            $out['CodeUniteLabintel'] = self::VALIDATION_VALID;

        if( $datas['SigleUnite'] )
            $out['SigleUnite'] = self::VALIDATION_VALID;

        if( $datas['NumContratTutelleGestionnaire'] )
            $out['NumContratTutelleGestionnaire'] = self::VALIDATION_VALID;

        if( $datas['NumContratTutelleGestionnaire'] )
            $out['NumContratTutelleGestionnaire'] = self::VALIDATION_VALID;

        if( $datas['TypeContrat'] )
            $out['TypeContrat'] = self::VALIDATION_VALID;

        if( $datas['Acronyme'] )
            $out['Acronyme'] = self::VALIDATION_VALID;

        if( $datas['ResponsableScientifique'] )
            $out['ResponsableScientifique'] = self::VALIDATION_VALID;

        if( $datas['EmployeurResponsableScientifique'] )
            $out['EmployeurResponsableScientifique'] = self::VALIDATION_VALID;

        if( $datas['PartenairePrincipal'] )
            $out['PartenairePrincipal'] = self::VALIDATION_VALID;

        if( $datas['SourceFinancement'] )
            $out['SourceFinancement'] = self::VALIDATION_VALID;

        if( $datas['LieuExecution'] )
            $out['LieuExecution'] = self::VALIDATION_VALID;

        if( $datas['DateDerniereSignature'] )
            $out['DateDerniereSignature'] = self::VALIDATION_VALID;

        if( $datas['DateDebut'] )
            $out['DateDebut'] = self::VALIDATION_VALID;

        if( $datas['DateFin'] )
            $out['DateFin'] = self::VALIDATION_VALID;

        if( $datas['MontantTotal'] )
            $out['MontantTotal'] = self::VALIDATION_VALID;


        if( $datas['ValidePoleCompetivite'] == true ){
            $out['ValidePoleCompetivite'] = self::VALIDATION_VALID;
            if( $out['PoleCompetivite'] ){
                $out['PoleCompetivite'] = self::VALIDATION_VALID;
            }
        }

        if( $datas['Reference'] )
            $out['Reference'] = self::VALIDATION_VALID;


        return $out;
    }

    /**
     * @return mixed
     */
+23 −0
Changes for module/Oscar/src/Oscar/Entity/Organization.php: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -308,6 +308,12 @@ class Organization implements ResourceInterface, IConnectedObject
     */
    protected $labintel;

    /**
     * N°RNSR
     * @ORM\Column(type="string", nullable=true)
     */
    protected $rnsr;

    /**
     * @var string
     * @ORM\Column(type="object", nullable=true)
@@ -344,6 +350,23 @@ class Organization implements ResourceInterface, IConnectedObject
        $this->typeObj = $typeObj;
    }

    /**
     * @return mixed
     */
    public function getRnsr()
    {
        return $this->rnsr;
    }

    /**
     * @param mixed $rnsr
     */
    public function setRnsr($rnsr): self
    {
        $this->rnsr = $rnsr;
        return $this;
    }

    /**
     * @return mixed
     */
+11 −0
Changes for module/Oscar/src/Oscar/Factory/ActivityPcruInfoFromActivityFactory.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Oscar\Entity\Activity;
use Oscar\Entity\ActivityOrganization;
use Oscar\Entity\ActivityPcruInfos;
use Oscar\Entity\ActivityPerson;
use Oscar\Exception\OscarException;
use Oscar\Service\OscarConfigurationService;

class ActivityPcruInfoFromActivityFactory
@@ -40,12 +41,22 @@ class ActivityPcruInfoFromActivityFactory
        $codeUniteLabintel = "";
        $sigleUnit = "";

        $structures = $activity->getOrganizationsWithRole($roleStructureToFind);
        if( count($structures) == 0 ){
            throw new OscarException("Aucune structure $roleStructureToFind pour cette activité.");
        }


        /** @var ActivityOrganization $unite */
        foreach ($activity->getOrganizationsWithRole($roleStructureToFind) as $unite) {
           $codeUniteLabintel = $unite->getOrganization()->getLabintel();
           $sigleUnit = $unite->getOrganization()->getShortName();
        }

        if( $codeUniteLabintel == "" ){
            throw new OscarException("Le $roleStructureToFind n'a pas de code LABINTEL");
        }

        // Recherche automatique du responsable scientifique
        $roleRSToFind = $this->oscarConfigurationService->getOptionalConfiguration('pcru_respscien_role', 'Responsable scientifique');
        $responsable = "";
+7 −0
Changes for module/Oscar/src/Oscar/Form/OrganizationIdentificationForm.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -82,6 +82,13 @@ class OrganizationIdentificationForm extends \Zend\Form\Form implements InputFil
        ]);
        $this->add($labintel);

        $rnsr = new Element\Text('rnsr');
        $rnsr->setAttributes([
            'class'       => 'form-control',
            'placeholder'   => 'N°RNSR'
        ]);
        $this->add($rnsr);

        $fullName = new Element\Text('fullName');
        $fullName->setAttributes([
            'class'       => 'form-control',
Loading