Commit 8751f9e2 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Merge branch 'kusanagi' into connor-dev

parents fadd97f1 5e8ccd1a
Loading
Loading
Loading
Loading
+6 −6
Changes for docker/.env.dev.dist: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ APP_ADMINISTRATORS=stephane.bouvry@unicaen.fr
# Exemple avec : PROXY=http://proxy.unicaen.fr:3128
# Exemple sans : PROXY=
HTTP_PROXY=
NO_PROXY=no_proxy=localhost,*.unicaen.fr,127.0.0.1,app-progresql,app-elasticsearch,app-gearman,app-apache,app-php,app-worker,app-vite
NO_PROXY=no_proxy=localhost,*.unicaen.fr,127.0.0.1,kusanagi-progresql,kusanagi-elasticsearch,kusanagi-gearman,kusanagi-apache,kusanagi-php,kusanagi-worker,kusanagi-vite

# ----------------------------------------------------------------------------
# MAILS ----------------------------------------------------------------------
@@ -28,7 +28,7 @@ MAILER_TYPE="smtp"
# -- Host
#MAILER_CMD="/usr/sbin/sendmail -bs"
MAILER_CMD=
MAILER_HOST="app-mailhog"
MAILER_HOST="kusanagi-mailhog"
MAILER_PORT=1025
MAILER_USERNAME=""
MAILER_PASSWORD=""
@@ -80,7 +80,7 @@ VOLUMES_TIMESHEET_SPENT_ACTIVITY=${VOLUMES_TEMPLATES}/estimated_spent_activity_.
# ----------------------------------------------------------------------------
## POSTGRESQL ----------------------------------------------------------------
# Cas 1 : Postgresql dans un container
POSGRESQL=app-postgres
POSGRESQL=kusanagi-postgres
POSGRESQL_USER=oscar_dev_user
POSGRESQL_PASS=oscar_dev_pass
POSGRESQL_BASE=oscar_dev_db
@@ -156,7 +156,7 @@ ENV_MODE=prod


# PHP FPM  -------------------------------------------------------------------
PHP_HOST=app-php
PHP_HOST=kusanagi-php



@@ -171,12 +171,12 @@ VITE_BASE_URL_DEV="http://localhost:5173"
VITE_BASE_URL_PROD="/js/oscar/vite/dist"

# Gearman --------------------------------------------------------------------
GEARMAN_HOST=app-gearman
GEARMAN_HOST=kusanagi-gearman
GEARMAN_PORT=4730
GEARMAN_ADDR=${GEARMAN_HOST}:${GEARMAN_PORT}

# Elasticsearch --------------------------------------------------------------
ELASTICSEARCH_HOST=app-elasticsearch
ELASTICSEARCH_HOST=kusanagi-elasticsearch
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_ADDR=${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}
ELASTICSEARCH_MEMORY=1g
+6 −6
Changes for docker/.env.prod.dist: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ APP_ADMINISTRATORS=admin.oscar@your-domain.ext
# Exemple avec : PROXY=http://proxy.your-domain.ext:3128
# Exemple sans : PROXY=
HTTP_PROXY=
NO_PROXY=no_proxy=localhost,*.your-domain.ext,127.0.0.1,app-progresql,app-elasticsearch,app-gearman,app-apache,app-php,app-worker,app-vite
NO_PROXY=no_proxy=localhost,*.your-domain.ext,127.0.0.1,kusanagi-progresql,kusanagi-elasticsearch,kusanagi-gearman,kusanagi-apache,kusanagi-php,kusanagi-worker,kusanagi-vite

# ----------------------------------------------------------------------------
# MAILS ----------------------------------------------------------------------
@@ -28,7 +28,7 @@ MAILER_TYPE="smtp"
# -- Host
#MAILER_CMD="/usr/sbin/sendmail -bs"
MAILER_CMD=
MAILER_HOST="app-mailhog"
MAILER_HOST="kusanagi-mailhog"
MAILER_PORT=1025
MAILER_USERNAME=""
MAILER_PASSWORD=""
@@ -80,7 +80,7 @@ VOLUMES_TIMESHEET_SPENT_ACTIVITY=${VOLUMES_TEMPLATES}/estimated_spent_activity_.
# ----------------------------------------------------------------------------
## POSTGRESQL ----------------------------------------------------------------
# Cas 1 : Postgresql dans un container
POSGRESQL=app-postgres
POSGRESQL=kusanagi-postgres
POSGRESQL_USER=oscar_dev_user
POSGRESQL_PASS=oscar_dev_pass
POSGRESQL_BASE=oscar_dev_db
@@ -156,7 +156,7 @@ ENV_MODE=prod


# PHP FPM  -------------------------------------------------------------------
PHP_HOST=app-php
PHP_HOST=kusanagi-php



@@ -171,12 +171,12 @@ VITE_BASE_URL_DEV="http://localhost:5173"
VITE_BASE_URL_PROD="/js/oscar/vite/dist"

# Gearman --------------------------------------------------------------------
GEARMAN_HOST=app-gearman
GEARMAN_HOST=kusanagi-gearman
GEARMAN_PORT=4730
GEARMAN_ADDR=${GEARMAN_HOST}:${GEARMAN_PORT}

# Elasticsearch --------------------------------------------------------------
ELASTICSEARCH_HOST=app-elasticsearch
ELASTICSEARCH_HOST=kusanagi-elasticsearch
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_ADDR=${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}
ELASTICSEARCH_MEMORY=1g
+78 −42
Changes for module/Oscar/src/Oscar/Controller/ProjectGrantController.php: 78 added lines, 42 removed lines.
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ namespace Oscar\Controller;


use BjyAuthorize\Exception\UnAuthorizedException;
use Doctrine\ORM\Exception\NotSupported;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Elasticsearch\Common\Exceptions\BadRequest400Exception;
@@ -38,7 +37,6 @@ use Oscar\Entity\SpentTypeGroup;
use Oscar\Entity\TabDocument;
use Oscar\Entity\ValidationPeriod;
use Oscar\Entity\ValidationPeriodRepository;
use Oscar\Event\OscarEvent;
use Oscar\Exception\OscarException;
use Oscar\Factory\ActivityGantJson;
use Oscar\Form\ProjectGrantForm;
@@ -47,6 +45,7 @@ use Oscar\Formatter\ActivityToJsonFormatter;
use Oscar\Formatter\CSVDownloader;
use Oscar\Formatter\JSONFormatter;
use Oscar\Formatter\OscarFormatterConst;
use Oscar\OscarText;
use Oscar\OscarVersion;
use Oscar\Provider\Privileges;
use Oscar\Service\ActivityAvenantsService;
@@ -83,8 +82,6 @@ use Laminas\Mvc\Console\View\Renderer;
use Laminas\View\Model\JsonModel;
use Laminas\View\Model\ViewModel;
use Laminas\View\Renderer\PhpRenderer;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenSignature\Provider\SignaturePrivileges;
use UnicaenSignature\Service\SignatureService;
use UnicaenSignature\Service\SignatureServiceAwareTrait;
@@ -265,7 +262,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        $fullaccess = false; // $this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_INDEX);
        if ($fullaccess) {
            $restricted_ids = false;
        } else {
        }
        else {
            $restricted_ids = array_unique($this->getActivityService()->getActivitiesIdsPerson($person));
        }

@@ -349,9 +347,11 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_REQUEST_MANAGE)) {
            $spot = "global";
        } elseif (count($organizations)) {
        }
        elseif (count($organizations)) {
            $spot = "organizations";
        } else {
        }
        else {
            throw new UnAuthorizedException("Vous n'avez pas l'autorisation d'accéder à ces informations");
        }

@@ -390,21 +390,25 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $statusTxt = $this->params()->fromQuery('status', '');
                        if (trim($statusTxt) == '') {
                            $status = [];
                        } else {
                        }
                        else {
                            $status = explode(',', $statusTxt);
                        }

                        if (count($status) == 0) {
                            $activityRequest = [];
                        } else {
                        }
                        else {
                            if ($spot == 'global') {
                                $activityRequests = $demandeActiviteRepository->getAll($status);
                            } elseif ($spot == 'organizations') {
                            }
                            elseif ($spot == 'organizations') {
                                $activityRequests = $demandeActiviteRepository->getAllForOrganizations(
                                    $organizations,
                                    $status
                                );
                            } else {
                            }
                            else {
                                return $this->getResponseBadRequest('Mauvais contexte !');
                            }
                        }
@@ -458,9 +462,11 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                                $personData,
                                $organisationData
                            );
                        } elseif ($action == "reject") {
                        }
                        elseif ($action == "reject") {
                            $activityRequestService->reject($request, $this->getCurrentPerson());
                        } else {
                        }
                        else {
                            return $this->getResponseBadRequest("Impossible de résoudre l'action '$action'.");
                        }

@@ -535,7 +541,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                header('Content-type: ' . $filetype);
                echo $content;
                die();
            } else {
            }
            else {
                $files = $demande->getFiles();
                $newFiles = [];
                foreach ($files as $file) {
@@ -545,7 +552,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                                'paths.document_request'
                            ) . '/' . $file['file']
                        );
                    } else {
                    }
                    else {
                        $newFiles[] = $file;
                    }
                }
@@ -574,7 +582,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $statusTxt = $this->params()->fromQuery('status', '');
                        if (trim($statusTxt) == '') {
                            $status = [];
                        } else {
                        }
                        else {
                            $status = explode(',', $statusTxt);
                        }

@@ -627,7 +636,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        // Création ou Mise à jour
                        if ($datas['id']) {
                            $activityRequest = $activityRequestService->getActivityRequest($datas['id']);
                        } else {
                        }
                        else {
                            $activityRequest = new ActivityRequest();
                            $this->getEntityManager()->persist($activityRequest);
                        }
@@ -640,18 +650,21 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                            $organization = $this->getEntityManager()->getRepository(Organization::class)->find(
                                $datas['organisation_id']
                            );
                        } else {
                        }
                        else {
                            $organization = null;
                        }

                        if ($datas['dateStart'] && $datas['dateStart'] != "null") {
                            $datas['dateStart'] = new \DateTime($datas['dateStart']);
                        } else {
                        }
                        else {
                            $datas['dateStart'] = null;
                        }
                        if ($datas['dateEnd'] && $datas['dateEnd'] != "null") {
                            $datas['dateEnd'] = new \DateTime($datas['dateEnd']);
                        } else {
                        }
                        else {
                            $datas['dateEnd'] = null;
                        }

@@ -672,7 +685,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                                            'size' => $size,
                                            'file' => $filepathname
                                        ];
                                    } else {
                                    }
                                    else {
                                        throw new OscarException(
                                            "Impossible de téléverser votre fichier $name." . error_get_last()
                                        );
@@ -799,7 +813,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

        foreach ($documentDatas as $key => $value) {
            if (is_array($value)) {
            } else {
            }
            else {
                $templateProcessor->setValue($key, htmlspecialchars($value, ENT_COMPAT | ENT_HTML401, NULL, false));
            }
        }
@@ -842,7 +857,6 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
    public function editAction()
    {


        $id = $this->params()->fromRoute('id');
        $numerotationKeys = $this->getEditableConfKey('numerotation', []);
        $numerotationEditable = $this->getOscarConfigurationService()->getNumerotationEditable();
@@ -1119,7 +1133,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

            if (!$project) {
                $this->redirect()->toRoute('contract/advancedsearch');
            } else {
            }
            else {
                $this->getEntityManager()->refresh($project);

                return $this->redirect()->toRoute(
@@ -1141,7 +1156,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        // Récupération des Id des activités
        if ($request->isPost()) {
            $paramID = $this->params()->fromPost('ids', '');
        } else {
        }
        else {
            $paramID = $this->params()->fromQuery('ids', '');
        }

@@ -1157,7 +1173,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
            );
            if ($this->getOrganizationPerimeter()) {
                $organizations = $this->getOrganizationPerimeter();
            } else {
            }
            else {
                throw new UnAuthorizedException('Droits insuffisants');
            }
        }
@@ -1218,15 +1235,18 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        $format = $this->params()->fromPost('format', 'csv');

        $delimiter = "\t";

        // Récupération des IDS
        if ($request->isPost()) {
            $paramID = $this->params()->fromPost('ids', '');
            if (!$paramID) {
                return $this->getResponseBadRequest();
            }
        } else {
        }
        else {
            return $this->getResponseUnauthorized();
        };

        $datas = new ExportDatas($this->getProjectGrantService(), $this->getOscarUserContextService());
        $dt = $datas->output($paramID, $fields, $perimeter);

@@ -1244,7 +1264,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif

        if ($format == "xls") {
            $downloader->downloadCSVToExcel($csvPath);
        } else {
        }
        else {
            $downloader->downloadCSV($csvPath);
        }
        die();
@@ -1398,7 +1419,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        if ($projectId) {
            $project = $this->getProjectService()->getProject($projectId);
            $this->getOscarUserContextService()->check(Privileges::PROJECT_ACTIVITY_ADD, $project);
        } else {
        }
        else {
            $project = null;
        }

@@ -1427,7 +1449,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                    }
                }
                $rolesOrganizations[''] = $this->oscarText('Pas de rôle pour cette organisation');
            } else {
            }
            else {
                return $this->getResponseInternalError("Données incohérentes");
            }
        }
@@ -1443,7 +1466,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        $form->setServiceContainer($this->getServiceContainer());
        $form->addOrganizationsLeader($withOrganization, $rolesOrganizations);
        $form->setNumbers($numerotationKeys, $numerotationEditable);
        $form->init(true);
        $form->init();
        ///////////////////////////////////////////////////////////////
        // TODO Transmettre les service au ProjectGrantForm
        // $form->setServiceLocator($this->getServiceLocator());
@@ -1629,7 +1652,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        'contractdocument/process',
                        ['id' => $doc->getId()]
                    );
                } else {
                }
                else {
                    $manageProcess = null;
                }
            }
@@ -1673,10 +1697,12 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $docAdded['urlPerson'] = false;
                    }
                    $privateTab ["documents"] [] = $docAdded;
                } else {
                }
                else {
                    $unclassifiedTab ["documents"] [] = $docAdded;
                }
            } else {
            }
            else {
                if (!array_key_exists($doc->getTabDocument()->getId(), $arrayTabs)) {
                    continue;
                }
@@ -1820,7 +1846,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        ),
                    ];
                    return $this->jsonOutput($datas);
                } elseif ($this->isAjax() || $this->getRequest()->getQuery('f') === 'json') {
                }
                elseif ($this->isAjax() || $this->getRequest()->getQuery('f') === 'json') {
                    try {
                        $perimeter = $this->getRequest()->getQuery('p', null);
                        $datas = [
@@ -1836,7 +1863,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $this->getLoggerService()->error($e->getMessage());
                        return $this->jsonError("Impossible de charger l'activité '$id'");
                    }
                } else {
                }
                else {
                    return [
                        'activity' => $entity
                    ];
@@ -2044,7 +2072,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                    }
                }
            }
        } elseif ($method == 'POST') {
        }
        elseif ($method == 'POST') {
            $masses = $_POST['masses'];
            $previsionnals = $_POST['previsionnel'];

@@ -2068,7 +2097,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        $out[$compte][$year]->setYear($year);
                        $out[$compte][$year]->setActivity($entity);
                        $out[$compte][$year]->setAccount($compte);
                    } else {
                    }
                    else {
                        if (array_key_exists($compte, $out) && array_key_exists($year, $out[$compte])) {
                            $this->getEntityManager()->remove($out[$compte][$year]);
                        }
@@ -2371,7 +2401,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
            $view->setTemplate('/oscar/project/project-selector.phtml');

            return $view;
        } else {
        }
        else {
            throw new Exception(sprintf("L'activité n'existe pas"));
        }
    }
@@ -2432,7 +2463,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $context = "activity";
                $contextKey = $activityPerson->getActivity()->getOscarNum();
                $idEnroller = $activityPerson->getActivity()->getId();
            } else {
            }
            else {
                $urlDelete = $deletableA ? $this->url()->fromRoute(
                    'personproject/delete',
                    ['idenroll' => $activityPerson->getId()]
@@ -2461,6 +2493,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                'roleLabel'     => $activityPerson->getRole(),
                'roleId'        => $activityPerson->getRoleObj() ? $activityPerson->getRoleObj()->getId() : "",
                'rolePrincipal' => $activityPerson->isPrincipal(),
                'personEnd'     => $activityPerson->getPerson()->getLdapFinInscription(),
                'urlDelete'     => $urlDelete,
                'context'       => $context,
                'contextKey'    => $contextKey,
@@ -2474,6 +2507,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                'enrolled'      => $activityPerson->getPerson()->getId(),
                'firstname'      => $activityPerson->getPerson()->getFirstname(),
                'lastname'      => $activityPerson->getPerson()->getLastname(),
                'disabled' => true,
                'enrolledLabel' => $activityPerson->getPerson()->getDisplayName(),
                'start'         => DateTimeUtils::toStr($activityPerson->getDateStart(), 'Y-m-d'),
                'end'           => DateTimeUtils::toStr($activityPerson->getDateEnd(), 'Y-m-d'),
@@ -2543,7 +2577,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $roleprincipal = false;
                $rolelabel = "Rôle inconnu";
                $role = null;
            } else {
            }
            else {
                $roleId = $activityOrganization->getRoleObj()->getId();
                $roleprincipal = $activityOrganization->getRoleObj()->isPrincipal();
                $rolelabel = $activityOrganization->getRoleObj()->getRoleId();
@@ -2557,7 +2592,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $deletable = $deletableA;
                $context = "activity";
                $contextKey = $activityOrganization->getActivity()->getOscarNum();
            } else {
            }
            else {
                $editable = $editableP;
                $deletable = $deletableP;
                $context = "project";
+0 −5
Changes for module/Oscar/src/Oscar/Entity/ActivityOrganization.php: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -128,9 +128,4 @@ class ActivityOrganization implements ILoggable
            ->setRoleObj($this->getRoleObj());
        return $new;
    }

    function isActive(): bool
    {
        return !$this->isOutOfDate() && !$this->getOrganization()->isClose();
    }
}
+5 −0
Changes for module/Oscar/src/Oscar/Entity/Organization.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -523,6 +523,11 @@ class Organization implements ResourceInterface, IConnectedObject
        return $this->getDateEnd() && $this->getDateEnd() <= new \DateTime();
    }

    public function isActive() :bool
    {
        return !$this->isClose();
    }

    /**
     * @return string
     */
Loading