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

Ecran à finaliser - Edition des modèles bientôt prêt

parent 5b17bb65
Loading
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -100,6 +100,25 @@ class ActivityDateController extends AbstractOscarController implements UseServi
        }
    }

    protected function milestonesPutFlow( array $datas, Activity $activity ): Response
    {
        try {
            foreach ($datas['elements'] as $element) {
                $this->getMilestoneService()->createFromArray(
                    [
                        'type_id'     => $element['datetype_id'],
                        'comment'     => "",
                        'dateStart'   => $element['date'],
                        'activity_id' => $activity->getId()
                    ]
                );
            }
            return $this->getResponseOk();
        }catch (\Exception $exception){
            return $this->jsonError($exception->getMessage());
        }
    }

    protected function milestonesActivityPut(Activity $activity): JsonModel|Response
    {
        $this->getLoggerService()->debug(__METHOD__);
@@ -169,6 +188,9 @@ class ActivityDateController extends AbstractOscarController implements UseServi
        $this->getOscarUserContextService()->check(Privileges::ACTIVITY_MILESTONE_MANAGE, $activity);
        try {
            $datas = $this->getJsonREST();
            if( $datas['action'] == 'flow' ){
                return $this->milestonesPutFlow($datas['datas'], $activity);
            }
            $this->getMilestoneService()->createFromArray(
                [
                    'type_id'     => $datas['type']['id'],
+10 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ 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;
@@ -80,6 +81,8 @@ 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;
@@ -841,6 +844,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
    public function editAction()
    {


        $id = $this->params()->fromRoute('id');
        $numerotationKeys = $this->getEditableConfKey('numerotation', []);
        $numerotationEditable = $this->getOscarConfigurationService()->getNumerotationEditable();
@@ -1803,6 +1807,12 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        ];
    }

    /**
     * @throws NotFoundExceptionInterface
     * @throws OscarException
     * @throws ContainerExceptionInterface
     * @throws NotSupported
     */
    public function show2Action()
    {
        $method = $this->getHttpXMethod();
+3 −0
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ class ActivityDateFlow
        $this->description = $description;
    }

    /**
     * @return Collection<ActivityDateFlowElement>
     */
    public function getElements(): Collection
    {
        return $this->elements;
+1 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ class DateType implements ITrackable
            'id' => $this->getId(),
            'label' => $this->getLabel(),
            'facet' => $this->getFacet(),
            'finishable' => $this->isFinishable(),
            'description' => $this->getDescription(),
            'recursivity' => $this->getRecursivityArray()
        ];
+26 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
namespace Oscar\Entity\Repository;

use Doctrine\ORM\EntityRepository;
use Oscar\Entity\ActivityDateFlow;

class ActivityDateFlowRepository extends EntityRepository
{
@@ -21,6 +22,7 @@ class ActivityDateFlowRepository extends EntityRepository
     */
    public function getAuthFlow( ?int $authId = null )
    {
        $out = [];
        $query = $this->createQueryBuilder('f');

        $query->where('f.public = TRUE');
@@ -29,6 +31,29 @@ class ActivityDateFlowRepository extends EntityRepository
            $query->setParameter('authId', $authId);
        }

        return $query->getQuery()->getArrayResult();
        $datas = $query->getQuery()->getResult();

        /** @var ActivityDateFlow $flow */
        foreach ($datas as $flow) {
            $elements = [];
            foreach ($flow->getElements() as $element) {
                $elements[] = [
                    'id' => $element->getId(),
                    'interval' => $element->getDaysInterval(),
                    'datetype_id' => $element->getDateType()->getId(),
                    'datetype' => $element->getDateType()->toArray(),
                ];
            }
            $out[] = [
                'id' => $flow->getId(),
                'mine' => $flow->getCreatedBy() == $authId,
                'label' => $flow->getLabel(),
                'description' => $flow->getDescription(),
                'createdBy' => $flow->getCreatedBy(),
                'public' => $flow->getPublic(),
                'datetypes' => $elements
            ];
        }
        return $out;
    }
}
Loading