Commit c2b29e5d authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Ajout de la date de l'envoi par mail du contrat

Création d'un nouvel indicateur pour suivre les retours des contrats envoyés par email
parent 175c6aa8
Loading
Loading
Loading
Loading
+11
Changes for data/ddl/table/CONTRAT.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,17 @@ return [
            'default'     => NULL,
            'commentaire' => NULL,
        ],
        'DATE_ENVOI_EMAIL'     => [
            'name'        => 'DATE_ENVOI_EMAIL',
            'type'        => 'date',
            'bdd-type'    => 'DATE',
            'length'      => 0,
            'scale'       => NULL,
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'commentaire' => 'Date envoi du contrat par email',
        ],
        'HISTO_CREATEUR_ID'     => [
            'name'        => 'HISTO_CREATEUR_ID',
            'type'        => 'int',
+24
Changes for data/ddl/view/V_INDICATEUR_361.sql: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
CREATE OR REPLACE VIEW OSE.V_INDICATEUR_361
(ID,INTERVENANT_ID,ANNEE_ID,STRUCTURE_ID,CONTRAT_ID)
AS
SELECT
  rownum id,
  t."INTERVENANT_ID",t."ANNEE_ID",t."STRUCTURE_ID",t."CONTRAT_ID"
FROM (
SELECT DISTINCT
  i.id intervenant_id,
  i.annee_id annee_id,
  c.structure_id structure_id,
  c.id contrat_id
FROM
  contrat                c
  JOIN intervenant i ON i.id = c.intervenant_id
  JOIN tbl_workflow w ON w.intervenant_id = i.id AND w.structure_id = c.structure_id AND w.etape_code = 'CONTRAT' AND w.atteignable = 1
  JOIN validation v ON v.id = c.validation_id AND v.histo_destruction IS NULL
  LEFT JOIN contrat_fichier cf ON cf.contrat_id = c.id
  LEFT JOIN fichier f ON f.id = cf.fichier_id AND f.histo_destruction IS NULL
WHERE
  c.histo_destruction IS NULL
  AND f.id IS NULL
  AND c.date_envoi_email IS NOT NULL
) t
 No newline at end of file
+10
Changes for data/indicateurs.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -271,6 +271,16 @@ return [
        'TEM_DISTINCT'      => false,
        'TEM_NOT_STRUCTURE' => false,
    ],
    361  => [
        'TYPE'              => 'Contrat / avenant',
        'ENABLED'           => true,
        'LIBELLE_PLURIEL'   => '%s contrats  <i>envoyés par e-mail</i> sont en attente de retour',
        'LIBELLE_SINGULIER' => '%s contrats  <i>envoyés par e-mail</i> est en attente de retour',
        'MESSAGE'           => null,
        'ROUTE'             => 'intervenant/contrat',
        'TEM_DISTINCT'      => false,
        'TEM_NOT_STRUCTURE' => false,
    ],
    370  => [
        'TYPE'              => 'Contrat / avenant',
        'ENABLED'           => true,
+13
Changes for module/Application/src/Application/Controller/ContratController.php: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ use Application\Entity\Db\Contrat;
use Zend\View\Model\JsonModel;
use BjyAuthorize\Exception\UnAuthorizedException;
use Zend\View\Renderer\PhpRenderer;
use DateTime;

/**
 * Description of ContratController
@@ -341,6 +342,9 @@ class ContratController extends AbstractController

    public function envoyerMailAction()
    {
        /**
         * @var Contrat $contrat
         */
        $contrat = $this->getEvent()->getParam('contrat');

        if (!$this->isAllowed($contrat, ContratAssertion::PRIV_EXPORT)) {
@@ -352,6 +356,7 @@ class ContratController extends AbstractController
            $html = $this->getServiceParametres()->get('contrat_modele_mail');
            //Ajout pour transformer les sauts de lignes en html <br/>
            $html = nl2br($html);

            //Personnalisation des variables
            $vIntervenant = $contrat->getIntervenant()->getCivilite()->getLibelleCourt() . " " . $contrat->getIntervenant()->getNomUsuel();
            $vUtilisateur = $this->getServiceContext()->getUtilisateur()->getDisplayName();
@@ -360,7 +365,15 @@ class ContratController extends AbstractController
            $subject      = $this->getServiceParametres()->get('contrat_modele_mail_objet');
            $subject      = str_replace(':intervenant', $vIntervenant, $subject);
            $message      = $this->getServiceModeleContrat()->prepareMail($contrat, $html, $subject);
            try {
                $mail           = $this->mail()->send($message);
                $dateEnvoiEmail = new DateTime();
                $contrat->setDateEnvoiEmail($dateEnvoiEmail);
                $this->getServiceContrat()->save($contrat);
                $this->flashMessenger()->addSuccessMessage('Contrat bien envoyé par email');
            } catch (\Exception $e) {
                $this->flashMessenger()->addErrorMessage($this->translate($e));
            }
        }

        return $this->getResponse();
+33
Changes for module/Application/src/Application/Entity/Db/Contrat.php: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -53,6 +53,11 @@ class Contrat implements HistoriqueAwareInterface, ResourceInterface
     */
    private $dateRetourSigne;

    /**
     * @var \DateTime
     */
    private $dateEnvoiEmail;

    /**
     * @var \Doctrine\Common\Collections\Collection
     */
@@ -358,6 +363,34 @@ class Contrat implements HistoriqueAwareInterface, ResourceInterface



    /**
     * Set dateEnvoiEmail
     *
     * @param \DateTime $dateEnvoiEmail
     *
     * @return Contrat
     */
    public function setDateEnvoiEmail($dateEnvoiEmail)
    {
        $this->dateEnvoiEmail = $dateEnvoiEmail;

        return $this;
    }



    /**
     * Get dateEnvoiEmail
     *
     * @return \DateTime
     */
    public function getDateEnvoiEmail()
    {
        return $this->dateEnvoiEmail;
    }



    /**
     * Add fichier
     *
Loading