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

- Ajout de message selon la date (A venir, En retard, Aujourd'hui)

 - Ajout de variables dans le message
 - à documenter
parent 1fdcfc29
Loading
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -518,8 +518,18 @@ class ActivityDate implements ITrackable
            . $this->getActivity();
    }

    public function getEmailBody(array $variables = []) :string
    public function getEmailBody(array $variables = [], DateTime $dateReference = new DateTime()) :string
    {
        return "EMAIL BODY\n";
        $out = $this->getType()->getEmailMessage();
        if( $this->isLate($dateReference) ){
            $out = $this->getType()->getEmailMessageLate();
        } elseif ($this->isFutur($dateReference)) {
            $out = $this->getType()->getEmailMessagePredicted();
        }
        if( !$out ){
            $out = "Bonjour {PERSONNE},\n\n"
                . "Le jalon {JALON} arrive à échéance le {DATE}.";
        }
        return $out;
    }
}
 No newline at end of file
+40 −0
Original line number Diff line number Diff line
@@ -54,6 +54,22 @@ class DateType implements ITrackable
     */
    private ?string $emailMessage = "";

    /**
     * Message spécifique pour le mail (Jalon dans le futur).
     *
     * @var string
     * @ORM\Column(type="string", nullable=true)
     */
    private ?string $emailMessagePredicted = "";

    /**
     * Message spécifique pour le mail (Jalon à faire en retard).
     *
     * @var string
     * @ORM\Column(type="string", nullable=true)
     */
    private ?string $emailMessageLate = "";

    /**
     * Mail activé.
     *
@@ -216,6 +232,28 @@ class DateType implements ITrackable
        return $this;
    }

    public function getEmailMessagePredicted(): ?string
    {
        return $this->emailMessagePredicted;
    }

    public function setEmailMessagePredicted(?string $emailMessagePredicted): self
    {
        $this->emailMessagePredicted = $emailMessagePredicted;
        return $this;
    }

    public function getEmailMessageLate(): ?string
    {
        return $this->emailMessageLate;
    }

    public function setEmailMessageLate(?string $emailMessageLate): self
    {
        $this->emailMessageLate = $emailMessageLate;
        return $this;
    }

    /**
     * @return bool
     */
@@ -245,6 +283,8 @@ class DateType implements ITrackable
            'recursivity' => $this->getRecursivityArray(),
            'emailEnable' => $this->isEmailEnable(),
            'emailMessage' => $this->getEmailMessage(),
            'emailMessagePredicted' => $this->getEmailMessagePredicted(),
            'emailMessageLate' => $this->getEmailMessageLate(),
        ];
    }

+26 −0
Original line number Diff line number Diff line
@@ -101,6 +101,32 @@ class DateTypeForm extends Form implements InputFilterProviderInterface
            'type'=>'Textarea'
        ]);

        $label = 'Message du mail (à venir)';
        $this->add([
            'name'   => 'emailMessagePredicted',
            'options' => [
                'label' => $label
            ],
            'attributes'    => [
                'class'       => 'form-control',
                'placeholder'   => $label,
            ],
            'type'=>'Textarea'
        ]);

        $label = 'Message du mail (en retard)';
        $this->add([
            'name'   => 'emailMessageLate',
            'options' => [
                'label' => $label
            ],
            'attributes'    => [
                'class'       => 'form-control',
                'placeholder'   => $label,
            ],
            'type'=>'Textarea'
        ]);


        // Fréquence des notifications
        $label = 'Fréquence des notifications';
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ class DateTypeFormHydrator implements HydratorInterface, ServiceLocatorAwareInte
            'label' => $object->getLabel(),
            'recursivity' => $object->getRecursivity(),
            'emailMessage' => $object->getEmailMessage(),
            'emailMessagePredicted' => $object->getEmailMessagePredicted(),
            'emailMessageLate' => $object->getEmailMessageLate(),
            'emailEnable' => $object->isEmailEnable() ? '1' : '0',
        ];
        if( $object->isFinishable() ){
@@ -67,6 +69,8 @@ class DateTypeFormHydrator implements HydratorInterface, ServiceLocatorAwareInte
            ->setFinishable(array_key_exists('finishable', $data) ? true : false)
            ->setEmailEnable(array_key_exists('emailEnable', $data) ? true : false)
            ->setEmailMessage($data['emailMessage'])
            ->setEmailMessagePredicted($data['emailMessagePredicted'])
            ->setEmailMessageLate($data['emailMessageLate'])
            ->setLabel($data['label']);
        return $object;
    }
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ class MailingService implements UseEntityManager, UseOscarConfigurationService,
{
    use UseEntityManagerTrait, UseOscarConfigurationServiceTrait, UseLoggerServiceTrait;

    public function forgeText(string $bodyTemplate, array $paramBody)
    {
        return str_ireplace(array_keys($paramBody), array_values($paramBody), $bodyTemplate);
    }

    /**
     * Retourne la configuration Oscar pour l'envoi des mails.
     *
Loading