[fix]: add email input on invoice send by email
This commit is contained in:
parent
448b7e501a
commit
0bebd95b32
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -66,7 +66,7 @@ class InvoiceController extends Controller
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function sendInvoicePdfViaMail($factureId)
|
||||
public function sendInvoicePdfViaMail($factureId, $email = '')
|
||||
{
|
||||
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
||||
if($facture == null)
|
||||
@ -84,7 +84,7 @@ class InvoiceController extends Controller
|
||||
$factureContent = $factureGeneratedResponse["content"];
|
||||
try {
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo(recipients: [$factureClientMail => "Facture"]);
|
||||
$message->setTo(recipients: [$email => "Facture"]);
|
||||
$content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf");
|
||||
$message->attach($content);
|
||||
$message->setSubject("Facture");
|
||||
@ -92,8 +92,8 @@ class InvoiceController extends Controller
|
||||
$this->mailer->send($message);
|
||||
$this->gestionRepository->setFactureSentDate($factureId);
|
||||
} catch (Exception $e) {
|
||||
return new DataResponse("Veuillez configurer le mail sur nextcloud ?", 500, ['Content-Type' => 'application/json']);
|
||||
return new DataResponse("Veuillez configurer le serveur SMTP sur nextcloud ?", 500, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
return new DataResponse("Mail envoyé avec succès", 200, ['Content-Type' => 'application/json']);
|
||||
return new DataResponse("E-mail envoyé avec succès à ".$email.".", 200, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
}
|
||||
@ -46,12 +46,17 @@ $('body').on('click', '#showPdfPreview', function () {
|
||||
});
|
||||
$('body').on('click','#sendFacturePdf',function(){
|
||||
const factureId = $('#factureIdentifier').data('id');
|
||||
const previousMail = $('#valueFacturePdfMail').data('init-value')
|
||||
const email = $('#valueFacturePdfMail').val()
|
||||
if(factureId){
|
||||
showLoader();
|
||||
$.ajax({
|
||||
url: baseUrl + '/invoice/'+factureId+'/sendInvoicePdfViaMail',
|
||||
type: 'POST',
|
||||
contentType: 'application/json'
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
email
|
||||
})
|
||||
}).done(function (response, textStatus, xhr) {
|
||||
if (xhr.status === 200) {
|
||||
showSuccess(response);
|
||||
@ -64,6 +69,7 @@ $('body').on('click','#sendFacturePdf',function(){
|
||||
showError(response);
|
||||
}).always(function () {
|
||||
hideLoader();
|
||||
$('#valueFacturePdfMail').val(previousMail)
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -37,8 +37,8 @@
|
||||
<th><?php p($l->t('Articles'));?></th>
|
||||
<th><?php p($l->t('Status'));?></th>
|
||||
<th><?php p($l->t('Date de paiement'));?></th>
|
||||
<th><?php p($l->t('Généré'));?></th>
|
||||
<th><?php p($l->t('Envoyé au client'));?></th>
|
||||
<th><?php p($l->t('Générée'));?></th>
|
||||
<th><?php p($l->t('Envoyée au client'));?></th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -145,7 +145,17 @@ $currentConfig = json_decode($_['configuration'])[0];
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Envoyer la facture par email à <?= $facture->mail; ?></h5>
|
||||
<h5 class="modal-title">Envoyer la facture par email ?</h5>
|
||||
</div>
|
||||
<div class="form-group px-4">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="valueFacturePdfMail"
|
||||
value="<?= $clientMail; ?>"
|
||||
data-init-value="<?= $clientMail; ?>"
|
||||
placeholder="Adresse email"
|
||||
/>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="showPdfPreview" type="button" class="btn btn-secondary">Voir l'aperçu</button>
|
||||
|
||||
@ -160,7 +160,17 @@
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Envoyer la facture par email à <?= $clientMail; ?></h5>
|
||||
<h5 class="modal-title">Envoyer la facture par email ?</h5>
|
||||
</div>
|
||||
<div class="form-group px-4">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="valueFacturePdfMail"
|
||||
value="<?= $clientMail; ?>"
|
||||
data-init-value="<?= $clientMail; ?>"
|
||||
placeholder="Adresse email"
|
||||
/>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="showPdfPreview" type="button" class="btn btn-secondary">Voir l'aperçu</button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user