Merge remote-tracking branch 'origin/fix/fix-facture-send-file-by-email-input' into staging
This commit is contained in:
commit
b04e66a4ee
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
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*/
|
*/
|
||||||
public function sendInvoicePdfViaMail($factureId)
|
public function sendInvoicePdfViaMail($factureId, $email = '')
|
||||||
{
|
{
|
||||||
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
||||||
if($facture == null)
|
if($facture == null)
|
||||||
@ -84,7 +84,7 @@ class InvoiceController extends Controller
|
|||||||
$factureContent = $factureGeneratedResponse["content"];
|
$factureContent = $factureGeneratedResponse["content"];
|
||||||
try {
|
try {
|
||||||
$message = $this->mailer->createMessage();
|
$message = $this->mailer->createMessage();
|
||||||
$message->setTo(recipients: [$factureClientMail => "Facture"]);
|
$message->setTo(recipients: [$email => "Facture"]);
|
||||||
$content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf");
|
$content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf");
|
||||||
$message->attach($content);
|
$message->attach($content);
|
||||||
$message->setSubject("Facture");
|
$message->setSubject("Facture");
|
||||||
@ -92,8 +92,8 @@ class InvoiceController extends Controller
|
|||||||
$this->mailer->send($message);
|
$this->mailer->send($message);
|
||||||
$this->gestionRepository->setFactureSentDate($factureId);
|
$this->gestionRepository->setFactureSentDate($factureId);
|
||||||
} catch (Exception $e) {
|
} 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(){
|
$('body').on('click','#sendFacturePdf',function(){
|
||||||
const factureId = $('#factureIdentifier').data('id');
|
const factureId = $('#factureIdentifier').data('id');
|
||||||
|
const previousMail = $('#valueFacturePdfMail').data('init-value')
|
||||||
|
const email = $('#valueFacturePdfMail').val()
|
||||||
if(factureId){
|
if(factureId){
|
||||||
showLoader();
|
showLoader();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseUrl + '/invoice/'+factureId+'/sendInvoicePdfViaMail',
|
url: baseUrl + '/invoice/'+factureId+'/sendInvoicePdfViaMail',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
contentType: 'application/json'
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify({
|
||||||
|
email
|
||||||
|
})
|
||||||
}).done(function (response, textStatus, xhr) {
|
}).done(function (response, textStatus, xhr) {
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
showSuccess(response);
|
showSuccess(response);
|
||||||
@ -64,6 +69,7 @@ $('body').on('click','#sendFacturePdf',function(){
|
|||||||
showError(response);
|
showError(response);
|
||||||
}).always(function () {
|
}).always(function () {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
$('#valueFacturePdfMail').val(previousMail)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -37,8 +37,8 @@
|
|||||||
<th><?php p($l->t('Articles'));?></th>
|
<th><?php p($l->t('Articles'));?></th>
|
||||||
<th><?php p($l->t('Status'));?></th>
|
<th><?php p($l->t('Status'));?></th>
|
||||||
<th><?php p($l->t('Date de paiement'));?></th>
|
<th><?php p($l->t('Date de paiement'));?></th>
|
||||||
<th><?php p($l->t('Généré'));?></th>
|
<th><?php p($l->t('Générée'));?></th>
|
||||||
<th><?php p($l->t('Envoyé au client'));?></th>
|
<th><?php p($l->t('Envoyée au client'));?></th>
|
||||||
<th><?php p($l->t('Actions'));?></th>
|
<th><?php p($l->t('Actions'));?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
@ -145,7 +145,17 @@ $currentConfig = json_decode($_['configuration'])[0];
|
|||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<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>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="showPdfPreview" type="button" class="btn btn-secondary">Voir l'aperçu</button>
|
<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-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<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>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="showPdfPreview" type="button" class="btn btn-secondary">Voir l'aperçu</button>
|
<button id="showPdfPreview" type="button" class="btn btn-secondary">Voir l'aperçu</button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user