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

- Migration des vues de synthèses / consultation des dépenses passée à Vue3/Vite

- Date de fin des personnes OK
parent e1c13c80
Loading
Loading
Loading
Loading
Loading
+47 −24
Original line number Diff line number Diff line
@@ -34,11 +34,13 @@ class ConnectorPersonREST extends AbstractConnector
    /** @var  ConnectorPersonHydrator */
    private $personHydrator = null;

    public function setEditable($editable){
    public function setEditable($editable)
    {
        $this->editable = $editable;
    }

    public function isEditable(){
    public function isEditable()
    {
        return $this->editable;
    }

@@ -78,7 +80,8 @@ class ConnectorPersonREST extends AbstractConnector
        return $this->personHydrator;
    }

    protected function log( string $text ) :void {
    protected function log(string $text): void
    {
        if (true) {
            echo "$text";
        }
@@ -95,7 +98,13 @@ class ConnectorPersonREST extends AbstractConnector
        $exist = $personRepository->getUidsConnector($this->getName());
        $repport = new ConnectorRepport();
        $this->getPersonHydrator()->setPurge($this->getOptionPurge());
        $repport->addnotice(sprintf("Il y'a déjà %s personne(s) synchronisée(s) pour le connector '%s'", count($exist), $this->getName()));
        $repport->addnotice(
            sprintf(
                "Il y'a déjà %s personne(s) synchronisée(s) pour le connector '%s'",
                count($exist),
                $this->getName()
            )
        );
        $access = $this->getAccessStrategy();
        $this->log("Pending access : " . count($exist));

@@ -113,48 +122,55 @@ class ConnectorPersonREST extends AbstractConnector
            if (!is_array($personsDatas)) {
                throw new \Exception("L'API n'a pas retourné un tableau de donnée");
            }
            $nbrPersonsConnector = count($personsDatas);
            $repport->addnotice(count($personsDatas) . " résultat(s) a traiter.");
            ////////////////////////////////////

            foreach ($personsDatas as $personData) {

                if (!property_exists($personData, 'uid')) {
                    $repport->addwarning(sprintf("Les donnèes %s n'ont pas d'UID.", print_r($personData, true)));
                    continue;
                }

                if( $this->getOptionPurge() ){
                $uid = $personData->uid;
                if (($index = array_search($uid, $exist)) >= 0) {
                    array_splice($exist, $index, 1);
                }
                }

                try {
                    /** @var Person $personOscar */
                    $personOscar = $personRepository->getPersonByConnectorID($this->getName(),
                        $personData->uid);
                    $personOscar = $personRepository->getPersonByConnectorID(
                        $this->getName(),
                        $personData->uid
                    );
                    $action = "update";
                } catch (NoResultException $e) {
                    $personOscar = $personRepository->newPersistantPerson();
                    $action = "add";

                } catch (NonUniqueResultException $e) {
                    $repport->adderror(sprintf("La personne avec l'ID %s est en double dans oscar.", $personData->uid));
                    continue;
                } catch (\Exception $e) {
                    // FIX : Erreur de conversion de type survenue
                    $repport->adderror(sprintf("La personne avec l'ID %s provoque une exception : %s - %s.", $personData->uid, $e->getMessage(), $e->getTraceAsString()));
                    $repport->adderror(
                        sprintf(
                            "La personne avec l'ID %s provoque une exception : %s - %s.",
                            $personData->uid,
                            $e->getMessage(),
                            $e->getTraceAsString()
                        )
                    );
                    continue;
                }

                if ($personData->dateupdated == null
                    || $personOscar->getDateSyncLdap() == null
                    || $personOscar->getDateSyncLdap()->format('Y-m-d') < $personData->dateupdated
                    || $force == true )
                {
                    $personOscar = $this->getPersonHydrator()->hydratePerson($personOscar, $personData, $this->getName());
                    || $force == true) {
                    $personOscar = $this->getPersonHydrator()->hydratePerson(
                        $personOscar,
                        $personData,
                        $this->getName()
                    );

                    $repport->addRepport($this->getPersonHydrator()->getRepport());

@@ -170,15 +186,20 @@ class ConnectorPersonREST extends AbstractConnector
                }
            }

            if( $this->getOptionPurge() ){

            $idsToDelete = [];

            foreach ($exist as $uid) {
                if (!$uid) {
                    continue;
                }

                try {
                    /** @var Person $personOscarToDelete */
                    $personOscarToDelete = $personRepository->getPersonByConnectorID($this->getName(), $uid);
                    $personOscarToDelete->disabledLdapNow();

                    if ($this->getOptionPurge()) {
                        $activeIn = [];

                        if (count($personOscarToDelete->getActivities()) > 0) {
@@ -204,17 +225,21 @@ class ConnectorPersonREST extends AbstractConnector
                        if (count($activeIn) == 0) {
                            $idsToDelete[] = $personOscarToDelete->getId();
                        } else {

                            // Tentative de suppression des rôles synchronisés



                            $repport->addwarning("$personOscarToDelete n'a pas été supprimé car il est actif dans : " . implode(', ', $activeIn));
                            $repport->addwarning(
                                "$personOscarToDelete n'a pas été supprimé car il est actif dans : " . implode(
                                    ', ',
                                    $activeIn
                                )
                            );
                        }

                    } catch (\Exception $e){
                        $repport->adderror("$personOscarToDelete n'a pas été supprimé car il est utilisé dans oscar : " . $e->getMessage());
                    }
                } catch (\Exception $e) {
                    $repport->adderror(
                        "$personOscarToDelete n'a pas été supprimé car il est utilisé dans oscar : " . $e->getMessage()
                    );
                }

                foreach ($idsToDelete as $idPerson) {
@@ -259,7 +284,6 @@ class ConnectorPersonREST extends AbstractConnector
                        return $person;
                    default:
                        throw new OscarException("Code d'erreur '" . $personData->error_code . "' inconnu");

                }
                $personData = $personData->person;
            }
@@ -270,7 +294,6 @@ class ConnectorPersonREST extends AbstractConnector
            }

            return $this->getPersonHydrator()->hydratePerson($person, $personData, $this->getName());

        } else {
            $msg = 'Impossible de synchroniser la personne ' . $person;
            $this->getLogger()->error($msg);
+2 −4
Original line number Diff line number Diff line
@@ -44,12 +44,9 @@ class ConnectorSpentSifacOCI

    public function sync( $pfi ){
        $c = $this->getConnection();

        echo "Traitement pour '$pfi'\n";
        $exists = $this->spentService->getSpentsSyncIdByPFI($pfi);

        // Limite de 5 secondes pour cette requête
        //oci_set_call_timeout(3000, $c);

        if( $c ){
            $stid = oci_parse($c, sprintf($this->sifacAccess['spent_query'], $pfi));
            if( !$stid ){
@@ -63,6 +60,7 @@ class ConnectorSpentSifacOCI
            $nbrExist = count($exists);

            while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
                echo "foo.\n";
                $nbr++;
                if( !in_array($row['IDSYNC'], $exists) ) {
                    try {
+3 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ namespace Oscar\Controller;
use Doctrine\ORM\EntityManager;
use Monolog\Logger;
use Oscar\Entity\Activity;
use Oscar\Entity\SpentLine;
use Oscar\Entity\SpentTypeGroup;
use Oscar\Exception\OscarException;
use Oscar\Formatter\Spent\SpentActivityDetailsExcelFormater;
@@ -250,7 +251,8 @@ class DepenseController extends AbstractOscarController implements UseServiceCon
                throw new OscarException(sprintf(_("Cette activité n'a pas de Numéro financier")));
            }
            //$spents = $this->getSpentService()->getGroupedSpentsDatas($activity->getCodeEOTP());
            $spents = $this->getSpentService()->getSpentsDatas($activity->getCodeEOTP());
            $spents = $this->getSpentService()->getSpentsDatas($activity->getCodeEOTP(), SpentService::SPENT_BOTH);
            $spents['informations'] = $activity->toArray();

            $format = $this->params()->fromQuery('format', 'json');
            switch($format){
+25 −0
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ class SpentLine
     */
    private $rldnr = '9A';

    /**
     * @ORM\Column(type="string", nullable=true, options={"default":"0250"})
     */
    private $btart = '0250';

    /**
     * @ORM\Column(type="string", nullable=true)
     */
@@ -188,6 +193,23 @@ class SpentLine
        return $this;
    }

    /**
     * @return string
     */
    public function getBtart(): string
    {
        return $this->btart;
    }

    /**
     * @param string $btart
     */
    public function setBtart(string $btart): self
    {
        $this->btart = $btart;
        return $this;
    }

    /**
     * @return mixed
     */
@@ -620,6 +642,9 @@ class SpentLine
            'numSifac' => $this->getNumSifac(),
            'numPiece' => $this->getNumPiece(),

            // btart
            'btart' => $this->getBtart(),

            // Infos
            'montant' => $this->getMontant(),
            'compteBudgetaire' => $this->getCompteBudgetaire(),
+6 −4
Original line number Diff line number Diff line
@@ -750,13 +750,13 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us
            ->setParameter('ids', $ids);

        if( $spentType == self::SPENT_EFFECTIVE ){
            $qb->andWhere('s.rldnr = :rldnr')
                ->setParameter('rldnr', '9A');
            $qb->andWhere('s.btart = :btart')
                ->setParameter('btart', '0250');
        }

        if( $spentType == self::SPENT_PREVISIONNAL ){
            $qb->andWhere('s.rldnr = :rldnr')
                ->setParameter('rldnr', '9B');
            $qb->andWhere('s.btart = :btart')
                ->setParameter('btart', '0100');
        }

        $filtreCompte = $this->getOscarConfigurationService()->getSpentAccountFilter();
@@ -1241,6 +1241,7 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us
        $comptes = [];



        /** @var SpentLine $spent */
        foreach ( $spents as $spent) {
            $compte = $this->getCompte($spent->getCompteGeneral());
@@ -1504,6 +1505,7 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us
        $spentLine->setPfi($data['PFI']);
        $spentLine->setNumSifac($data['NUMSIFAC']);
        $spentLine->setRldnr($data['AB9']);
        $spentLine->setBtart($data['BTART']);
        $spentLine->setNumCommandeAff($data['NUMCOMMANDEAFF']);
        $spentLine->setNumPiece($data['NUMPIECE']);
        $spentLine->setNumFournisseur($data['NUMFOURNISSEUR']);
Loading