Commit 7c450051 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

UP : MAJ du startup docker

MAJ : L'import des activités permet d'importer les lots de travail
parent 1fb8f6db
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -12,9 +12,9 @@ touch logs/oscar.log
chmod 777 config/autoload/oscar-editable.yml
chmod 777 logs/oscar.log

cp -R -u -p /opt/oscar_config/local.php config/autoload/local.php
cp -R -u -p /opt/oscar_config/unicaen-app.local.php config/autoload/unicaen-app.local.php
cp -R -u -p /opt/oscar_config/unicaen-auth.local.php config/autoload/unicaen-auth.local.php
cp -u -p /opt/oscar_config/local.php config/autoload/local.php
cp -u -p /opt/oscar_config/unicaen-app.local.php config/autoload/unicaen-app.local.php
cp -u -p /opt/oscar_config/unicaen-auth.local.php config/autoload/unicaen-auth.local.php

# On attends que Postgresql soit UP
until PGPASSWORD="azerty" psql -h "£CONTAINER_POSTGRESQL" -U "oscar" "oscar_dev" -c '\q'; do
+33 −8
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
        "date": "2018-01-31"
      }
    ],

    "organizations": {
      "Référent extérieur": [],
      "Laboratoire": [
@@ -36,7 +35,8 @@
        "Albert Einstein"
      ],
      "Ingénieur": [
        "John Doe", "Sarah Déclarant"
        "John Doe",
        "Sarah Déclarant"
      ]
    }
  },
@@ -54,10 +54,8 @@
    "amount": 15000,
    "financialImpact": "Aucune",
    "milestones": [

    ],
    "payments": [

    ],
    "organizations": {
      "Laboratoire": [
@@ -78,7 +76,36 @@
        "Marcel Grossmann",
        "Sarah Déclarant"
      ]
    },
    "workpackages": [
      {
        "code": "WP1",
        "label": "Etude et analyse",
        "declarers": [
          "Albert Einstein",
          "Maurice Solovine",
          "Marcel Grossmann",
          "Sarah Déclarant"
        ]
      },
      {
        "code": "WP2",
        "label": "Rédaction d'article",
        "declarers": [
          "Albert Einstein",
          "Maurice Solovine",
          "Marcel Grossmann"
        ]
      },
      {
        "code": "WP3",
        "label": "Expériences",
        "declarers": [
          "Albert Einstein",
          "Marcel Grossmann"
        ]
      }
    ]
  },
  {
    "uid": "A0003",
@@ -93,10 +120,8 @@
    "type": "ANR",
    "amount": 9990,
    "milestones": [

    ],
    "payments": [

    ],
    "organizations": {
      "Laboratoire": [
+10 −0
Original line number Diff line number Diff line
[
  {
    "declarer" : "",
    "declarer_id" : 1,
    "workpackage_code" : "",
    "activity_acronym" : "",
    "date": "",
    "duration": ""
  }
]
 No newline at end of file
+122 −71
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ use Oscar\Entity\PersonRepository;
use Oscar\Entity\Project;
use Oscar\Entity\Role;
use Oscar\Entity\TVA;
use Oscar\Entity\WorkPackage;
use Oscar\Entity\WorkPackagePerson;
use Oscar\Exception\ConnectorException;
use Oscar\Exception\OscarException;
use Oscar\Import\Data\DataExtractorFullname;
@@ -473,19 +475,19 @@ class ConnectorActivityJSON implements ConnectorInterface
            $dateStart = null;
            $dateEnd = null;

            if ($data->currency) {
            if (property_exists($data, 'currency')) {
                $currency = $this->getCurrency($data->currency);
            } else {
                $currency = $defaultCurrency;
            }

            if ($data->currency) {
            if (property_exists($data, 'tva')) {
                $tva = $this->getTva($data->tva);
            } else {
                $tva = null;
            }

            if ($data->status) {
            if (property_exists($data, 'status')) {
                $status = (int)$data->status;
            } else {
                $status = Activity::STATUS_ERROR_STATUS;
@@ -542,6 +544,7 @@ class ConnectorActivityJSON implements ConnectorInterface
            /** @var DisciplineRepository $disciplineRepo */
            $disciplineRepo = $this->entityManager->getRepository(Discipline::class);

            if( property_exists($data, 'disciplines') ){
                foreach ($data->disciplines as $discipline) {
                    $disc = $disciplineRepo->findOneBy(['label' => $discipline]);

@@ -553,6 +556,7 @@ class ConnectorActivityJSON implements ConnectorInterface
                    }
                    $activity->addDiscipline($disc);
                }
            }

            $this->entityManager->flush($activity);

@@ -670,7 +674,11 @@ class ConnectorActivityJSON implements ConnectorInterface
                            )
                        );
                    }

                    $description = "";
                    if( property_exists($milestone, 'description') ){
                        $description = $milestone->description;
                    }
                    if (!$activity->hasMilestoneAt($type, $date)) {
                        $milestoneActivity = new ActivityDate();
                        $this->entityManager->persist($milestoneActivity);
@@ -701,6 +709,48 @@ class ConnectorActivityJSON implements ConnectorInterface
//                        $fullName, $role, $activity, $e->getMessage()));
                }
            }
            if( property_exists($data, 'workpackages') ){
                foreach ($data->workpackages as $workpackageData) {
                    $code = $workpackageData->code;
                    $workpackage = $activity->getWorkpackageByCode($code);
                    if( !$workpackage ){
                        $workpackage = new WorkPackage();
                        $workpackage->setActivity($activity);
                        $workpackage->setCode($workpackageData->code);
                        $this->entityManager->persist($workpackage);
                    }

                    $label = "";
                    if( property_exists($workpackageData, 'label') ){
                        $label = $workpackageData->label;
                    }
                    $workpackage->setLabel($label);
                    $workpackage->setDescription("Imported WP");
                    $this->entityManager->flush($workpackage);

                    // Traitement des déclarants
                    foreach ($workpackageData->declarers as $fullName) {
                        $datasPerson = (new DataExtractorFullname())->extract($fullName);
                        if ($datasPerson) {
                            $person = $this->getPersonOrCreate($datasPerson, $repport);
                            if( !$workpackage->hasPerson($person) ){
                                try {
                                    $workpackagePerson = new WorkPackagePerson();
                                    $this->entityManager->persist($workpackagePerson);
                                    $workpackagePerson->setPerson($person)
                                        ->setWorkPackage($workpackage);
                                    $this->entityManager->flush($workpackagePerson);
                                    $repport->addadded("Déclarant '$person' dans '$workpackage'");
                                } catch (\Exception $e) {
                                    $repport->adderror("Impossible d'ajouter le déclarant '$person' : " . $e->getMessage());
                                }
                            }
                        }
                    }
                }
            }

            if( property_exists($data, 'payments') ){
                foreach ($data->payments as $paymentData) {
                    try {
                        $amount = doubleval($paymentData->amount);
@@ -775,6 +825,7 @@ class ConnectorActivityJSON implements ConnectorInterface
                    }
                }
            }
        }
        return $repport;
    }

+10 −0
Original line number Diff line number Diff line
@@ -2302,6 +2302,16 @@ class Activity implements ResourceInterface
        );
    }

    public function getWorkpackageByCode( string $code )
    {
        foreach ($this->getWorkPackages() as $workPackage) {
            if ($workPackage->getCode() == $code){
                return $workPackage;
            }
        }
        return null;
    }

    public static function csvHeaders()
    {
        return array(