Commit 8c086f0a authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Reste des fichiers

parent 560331b6
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ return [
        // Emplacement où sont archivés les documents en cours de signature
        'documents_path' => __DIR__ . '/../../data/documents/signature',

        'redirect_internal' => 'contractdocument/my-documents',

        /////////////////////////////////////////////////////////////////////////////////
        /// SYSTEME de LOG
+1 −0
Original line number Diff line number Diff line
@@ -283,6 +283,7 @@ return array(
                        'reupload',
                        'search',
                        'show',
                        'signatureMine',
                        'upload',
                    ],
                    'roles' => ['user']
+6 −0
Original line number Diff line number Diff line
@@ -1302,6 +1302,12 @@ contractdocument:
  may_terminate: true

  child_routes:
    my-documents:
      type: segment
      options:
        route: /my-documents
        defaults:
          action: signatureMine

    search:
      type: segment
+27 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ use Doctrine\ORM\OptimisticLockException;
use Exception;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\Plugin\Redirect;
use Laminas\View\Model\ViewModel;
use Oscar\Entity\Activity;
use Oscar\Entity\ContractDocument;
use Oscar\Entity\Person;
@@ -746,7 +747,7 @@ class ContractDocumentController extends AbstractOscarController implements UseS
        if ($this->isAjax() || $this->params()->fromQuery('f', null) == 'json') {
            $this->getLoggerService()->debug("Chargement des documents observés");
            try {
                $documents = $this->getContractDocumentService()->getDocumentsWithSignProcessForUser($person);
                $documents = $this->getContractDocumentService()->getDocumentsObservedForUser($person);
                $output = $this->baseJsonResponse();
                $output['documents'] = $this->getJsonFormatterService()->contractDocuments($documents);
                return $this->jsonOutput($output);
@@ -759,6 +760,31 @@ class ContractDocumentController extends AbstractOscarController implements UseS
        return [];
    }

    public function signatureMineAction() {
        if( !$this->getCurrentPerson() ){
            throw new OscarException();
        }
        $this->getLoggerService()->debug("Signature MINE()");
        $this->getJsonFormatterService()->setUrlHelper($this->url());
        $person = $this->getCurrentPerson();
        if ($this->isAjax() || $this->params()->fromQuery('f', null) == 'json') {
            $this->getLoggerService()->debug("Chargement des documents observés");
            try {
                $documents = $this->getContractDocumentService()->getDocumentsWithSignProcessForUser($person);
                $output = $this->baseJsonResponse();
                $output['documents'] = $this->getJsonFormatterService()->contractDocuments($documents, true, [
                    'signPersonEmail' => $person ? $person->getEmail() : null,
                ]);
                return $this->jsonOutput($output);
            } catch (Exception $e) {
                $msg = "Impossible d'afficher le suivi des signatures";
                $this->getLoggerService()->error($msg . " : " . $e->getMessage());
                return $this->jsonError($msg);
            }
        }
        return [];
    }

    /**
     * Annulation d'un processus de signature.
     *
+27 −0
Original line number Diff line number Diff line
@@ -97,13 +97,40 @@ class ContractDocumentRepository extends AbstractTreeDataRepository
        return $query->getQuery()->getResult();
    }

    /**
     * Liste des documents impliquant le signataire (via l'email).
     *
     * @param string $person_email
     * @return array
     */
    public function getDocumentsWithProcessByPerson(string $person_email)
    {
        $query = $this->createQueryBuilder('d')
            ->innerJoin('d.process', 'p')
            ->innerJoin('p.steps', 'st')
            ->innerJoin('st.signature', 's')
            ->innerJoin('d.grant', 'a')
            ->innerJoin('s.recipients', 'o')
            ->orderBy('s.dateCreated', 'DESC')
            ->where("o.email = :email");
        $query->setParameter('email', $person_email);
        return $query->getQuery()->getResult();
    }

    /**
     * Liste des documents signés observés.
     *
     * @param string $person_email
     * @return array
     */
    public function getDocumentsSignedObservedByPerson( string $person_email): array {
        $query = $this->createQueryBuilder('d')
            ->innerJoin('d.process', 'p')
            ->innerJoin('p.steps', 'st')
            ->innerJoin('st.signature', 's')
            ->innerJoin('d.grant', 'a')
            ->innerJoin('s.observers', 'o')
            ->orderBy('s.dateCreated', 'DESC')
            ->where("o.email = :email");
        $query->setParameter('email', $person_email);
        return $query->getQuery()->getResult();
Loading