Merge branch 'features/feature-facture-generated-state-and-sent-state' into staging
This commit is contained in:
commit
f22c75b97a
@ -177,5 +177,9 @@ return [
|
||||
|
||||
// API
|
||||
['name' => 'api#getDefundIdByCalendarUuid', 'url' => '/api/getDefundIdByCalendarUuid/{uuid}', 'verb' => 'GET'],
|
||||
|
||||
//invoice controller
|
||||
['name' => 'invoice#sendInvoicePdfViaMail', 'url' => '/invoice/{factureId}/sendInvoicePdfViaMail', 'verb' => 'POST'],
|
||||
['name' => 'invoice#getInvoicePdfContent', 'url' => '/invoice/{factureId}/getInvoicePdfContent', 'verb' => 'GET'],
|
||||
]
|
||||
];
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
99
gestion/lib/Controller/InvoiceController.php
Normal file
99
gestion/lib/Controller/InvoiceController.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
namespace OCA\Gestion\Controller;
|
||||
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use OCA\Gestion\Service\InvoicePdfService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\DB\Exception;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IRequest;
|
||||
use OCP\Mail\IMailer;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
private Bdd $gestionRepository;
|
||||
private InvoicePdfService $invoicePdfService;
|
||||
private $rootFolder;
|
||||
private $mailer;
|
||||
private $currentUserIdNextcloud;
|
||||
private $storage;
|
||||
public function __construct(
|
||||
$UserId,
|
||||
$AppName,
|
||||
IRequest $request,
|
||||
Bdd $bdd,
|
||||
InvoicePdfService $invoicePdfService,
|
||||
IRootFolder $rootFolder,
|
||||
IMailer $mailer
|
||||
)
|
||||
{
|
||||
$this->currentUserIdNextcloud = $UserId;
|
||||
$this->invoicePdfService = $invoicePdfService;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->mailer = $mailer;
|
||||
$this->gestionRepository = $bdd;
|
||||
try{
|
||||
$this->storage = $rootFolder->getUserFolder($this->currentUserIdNextcloud);
|
||||
}catch(\OC\User\NoUserException $e){
|
||||
|
||||
}
|
||||
parent::__construct($AppName, request: $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
|
||||
public function getInvoicePdfContent($factureId){
|
||||
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
||||
if($facture == null)
|
||||
{
|
||||
return new DataResponse("La facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->currentUserIdNextcloud);
|
||||
if($factureGeneratedResponse == null){
|
||||
return new DataResponse("La facture n'a pas été générée correctement", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureContent = base64_encode($factureGeneratedResponse['content']);
|
||||
return new DataResponse([
|
||||
"content" => $factureContent
|
||||
], 200, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function sendInvoicePdfViaMail($factureId)
|
||||
{
|
||||
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
||||
if($facture == null)
|
||||
{
|
||||
return new DataResponse("La facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureClientMail = $this->gestionRepository->getFactureClientMailByFactureId($factureId);
|
||||
if($factureClientMail == null){
|
||||
return new DataResponse("Le mail de la facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->currentUserIdNextcloud);
|
||||
if($factureGeneratedResponse == null){
|
||||
return new DataResponse("La facture n'a pas été générée correctement", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureContent = $factureGeneratedResponse["content"];
|
||||
try {
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo(recipients: [$factureClientMail => "Facture"]);
|
||||
$content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf");
|
||||
$message->attach($content);
|
||||
$message->setSubject("Facture");
|
||||
$message->setPlainBody("Veuiller trouver ci-joint votre facture");
|
||||
$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("Mail envoyé avec succès", 200, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
}
|
||||
@ -2536,8 +2536,8 @@ class PageController extends Controller {
|
||||
|
||||
public function exportFactureToPdf($factureId){
|
||||
try{
|
||||
$factureFilenames = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->idNextcloud);
|
||||
return json_encode($factureFilenames);
|
||||
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->idNextcloud);
|
||||
return json_encode($factureGeneratedResponse["filenames"]);
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
|
||||
@ -3024,6 +3024,11 @@ class PageController extends Controller {
|
||||
public function factureGroupDetails($numfacture){
|
||||
$this->denyIfNotAdmin();
|
||||
$facture = $this->myDb->getFactureGroupByFactureIdWithDetails($numfacture);
|
||||
$facture["path_to_file"] = $this->idNextcloud.'/'.FileExportHelpers::GetFactureGroupFileFullPath(
|
||||
clientName:$facture['group_name'],
|
||||
factureNum: $facture['num'],
|
||||
facturationDate: $facture['date_paiement']
|
||||
);
|
||||
return new TemplateResponse('gestion', 'factureGroupDetails', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud,
|
||||
'configuration'=> $this->getConfiguration(),
|
||||
'facture'=>json_decode(json_encode($facture)),
|
||||
|
||||
@ -408,6 +408,8 @@ class Bdd {
|
||||
.$this->tableprefix."facture.facture_type, "
|
||||
.$this->tableprefix."facture.fk_client_id as facture_client_id, "
|
||||
.$this->tableprefix."facture.fk_client_group_facturation_id as facture_client_group_facturation_id, "
|
||||
.$this->tableprefix."facture.document_generated_date as facture_document_generated_date, "
|
||||
.$this->tableprefix."facture.document_sent_date as facture_document_sent_date, "
|
||||
.$this->tableprefix."devis.num as dnum, ".$this->tableprefix."devis.comment as dcomment, date_paiement, type_paiement, id_devis, entreprise, "
|
||||
.$this->tableprefix."facture.version, status_paiement,"
|
||||
.$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, "
|
||||
@ -597,18 +599,22 @@ class Bdd {
|
||||
}
|
||||
|
||||
public function getOneFacture($numfacture, $idNextcloud){
|
||||
// $sql = "SELECT ".$this->tableprefix."facture.id," . $this->tableprefix . "facture.version," . $this->tableprefix . "facture.num, ".$this->tableprefix."facture.date, ".$this->tableprefix."devis.num as dnum, comment, date_paiement, type_paiement, id_devis, nom, prenom, entreprise FROM (".$this->tableprefix."facture LEFT JOIN ".$this->tableprefix."devis on ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."devis.id AND ".$this->tableprefix."facture.id_nextcloud = ".$this->tableprefix."devis.id_nextcloud) LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id AND ".$this->tableprefix."devis.id_nextcloud = ".$this->tableprefix."client.id_nextcloud WHERE ".$this->tableprefix."facture.id = ? AND ".$this->tableprefix."facture.id_nextcloud = ?";
|
||||
$sql = "SELECT ".$this->tableprefix."facture.id," . $this->tableprefix . "facture.version," . $this->tableprefix . "facture.num, "
|
||||
.$this->tableprefix."facture.date, ".$this->tableprefix."devis.num as dnum, comment, date_paiement, type_paiement, id_devis, ".$this->tableprefix."client.nom, prenom, entreprise,"
|
||||
.$this->tableprefix."devis.comment as dcomment,".$this->tableprefix."lieu.nom as lieu, ".$this->tableprefix."lieu.adresse as adresse_soin,"
|
||||
.$this->tableprefix."defunt.nom as nom_defunt, "
|
||||
.$this->tableprefix."devis.order_number as order_number, "
|
||||
.$this->tableprefix."devis.case_number as case_number, "
|
||||
.$this->tableprefix."client.id as client_id, "
|
||||
.$this->tableprefix."client.mail as client_mail, "
|
||||
.$this->tableprefix."client_group_facturation.id as group_client_id, "
|
||||
.$this->tableprefix."client_group_facturation.email as group_client_mail, "
|
||||
.$this->tableprefix."facture_payment_type.facture_payment_type_label as facture_payment_type_label
|
||||
FROM (".$this->tableprefix."facture
|
||||
LEFT JOIN ".$this->tableprefix."devis on ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."devis.id
|
||||
LEFT JOIN ".$this->tableprefix."lieu on ".$this->tableprefix."devis.id_lieu = ".$this->tableprefix."lieu.id)
|
||||
LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id
|
||||
LEFT JOIN ".$this->tableprefix."client_group_facturation on ".$this->tableprefix."client.fk_client_group_facturation_id = ".$this->tableprefix."client_group_facturation.id
|
||||
LEFT JOIN ".$this->tableprefix."defunt on ".$this->tableprefix."devis.id_defunt = ".$this->tableprefix."defunt.id
|
||||
LEFT JOIN ".$this->tableprefix."facture_payment_type on ".$this->tableprefix."facture.fk_facture_payment_type_id = ".$this->tableprefix."facture_payment_type.id
|
||||
WHERE ".$this->tableprefix."facture.id = ?";
|
||||
@ -4558,4 +4564,71 @@ class Bdd {
|
||||
$facture["isFactureClientGroup"] = !$isFactureSingleClient;
|
||||
return $facture;
|
||||
}
|
||||
|
||||
public function setFactureGeneratedDate($factureId){
|
||||
$datetimeNow = new Datetime();
|
||||
$dateNow = $datetimeNow->format("Y-m-d");
|
||||
$sql = "UPDATE ".$this->tableprefix."facture set document_generated_date = ? WHERE id = ?";
|
||||
$this->execSQLNoData($sql,[
|
||||
$dateNow,
|
||||
$factureId
|
||||
]);
|
||||
}
|
||||
|
||||
public function setFactureSentDate($factureId){
|
||||
$datetimeNow = new Datetime();
|
||||
$dateNow = $datetimeNow->format("Y-m-d");
|
||||
$sql = "UPDATE ".$this->tableprefix."facture set document_sent_date = ? WHERE id = ?";
|
||||
$this->execSQLNoData($sql,[
|
||||
$dateNow,
|
||||
$factureId
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFactureClientMailByFactureId($factureId){
|
||||
$sql = "SELECT
|
||||
facture.id,
|
||||
facture.facture_type,
|
||||
facture_client.mail as facture_client_mail,
|
||||
facture_client_group_facturation.email as facture_client_group_mail,
|
||||
facture.fk_client_id as facture_client_id,
|
||||
facture.fk_client_group_facturation_id as facture_client_group_facturation_id,
|
||||
client.id as client_id,
|
||||
client.fk_client_group_facturation_id as devis_client_group_facturation_id,
|
||||
client.mail as devis_client_mail,
|
||||
client_group_facturation.email as devis_client_group_mail
|
||||
FROM ".$this->tableprefix."facture as facture
|
||||
LEFT JOIN ".$this->tableprefix."devis as devis
|
||||
on facture.id_devis = devis.id
|
||||
LEFT JOIN ".$this->tableprefix."client as client
|
||||
on devis.id_client = client.id
|
||||
LEFT JOIN ".$this->tableprefix."client_group_facturation as client_group_facturation
|
||||
on client.fk_client_group_facturation_id = client_group_facturation.id
|
||||
LEFT JOIN ".$this->tableprefix."client as facture_client
|
||||
on facture.fk_client_id = facture_client.id
|
||||
LEFT JOIN ".$this->tableprefix."client_group_facturation as facture_client_group_facturation
|
||||
on facture.fk_client_group_facturation_id = client_group_facturation.id
|
||||
WHERE facture.id = ?
|
||||
LIMIT 1;";
|
||||
|
||||
$mail = null;
|
||||
$result = $this->execSQLNoJsonReturn($sql,[$factureId]);
|
||||
if(!empty($result)){
|
||||
$facture = $result[0];
|
||||
$factureIsSingle = $facture["facture_type"] == FactureTypeConstant::TYPE_SINGLE;
|
||||
if($factureIsSingle){
|
||||
$mail = $facture["fk_client_group_facturation_id"] != null ?
|
||||
$facture["devis_client_group_mail"] :
|
||||
$facture["devis_client_mail"];
|
||||
}
|
||||
else{
|
||||
$factureIsClientWithoutGroup = $facture["facture_client_id"] != null && $facture["facture_client_id"] != 0;
|
||||
$mail = $factureIsClientWithoutGroup ?
|
||||
$facture["facture_client_mail"] :
|
||||
$facture["facture_client_group_mail"];
|
||||
}
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace OCA\Gestion\Helpers;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class FileExportHelpers
|
||||
{
|
||||
|
||||
@ -53,6 +55,27 @@ class FileExportHelpers
|
||||
return $racinePath.'CLIENTS/'.mb_strtoupper($clientName,'UTF-8').'/';
|
||||
}
|
||||
|
||||
public static function GetFactureGroupFilename($factureNum,$clientName){
|
||||
$factureNum = str_replace('/','-',$factureNum);
|
||||
$clientName = str_replace(' ',' ',$clientName ?? '');
|
||||
return 'FACTURE'.'_'.$factureNum.'_'.mb_strtoupper($clientName,'UTF-8').'.pdf';
|
||||
}
|
||||
|
||||
public static function GetFactureGroupFolder($clientName,$facturationDate){
|
||||
$clientRacineFolder = 'CLIENTS/'.mb_strtoupper($clientName,'UTF-8').'/';
|
||||
$factureDatetime = new DateTime($facturationDate);
|
||||
$factureDateYear = $factureDatetime->format('Y');
|
||||
$factureMonth = DateHelpers::GetDateWithFormatDayAndMonthPlainString($facturationDate);
|
||||
$factureByYearFolder = $clientRacineFolder."$factureDateYear".'/'.$factureMonth.'/'.'FACTURES'.'/';
|
||||
return $factureByYearFolder;
|
||||
}
|
||||
|
||||
public static function GetFactureGroupFileFullPath($clientName,$factureNum,$facturationDate){
|
||||
$factureFolder = self::GetFactureGroupFolder($clientName,$facturationDate);
|
||||
$factureFilename = self::GetFactureGroupFilename($factureNum,$clientName);
|
||||
return $factureFolder.$factureFilename;
|
||||
}
|
||||
|
||||
public static function GetDefuntsFolder($clientName,$defuntName,$racinePath){
|
||||
$clientsFolder = self::GetClientsFolder($clientName,$racinePath);
|
||||
return $clientsFolder.'DEFUNTS/'.mb_strtoupper($defuntName,'UTF-8').'/';
|
||||
|
||||
@ -91,7 +91,7 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$factureNum = $this->factureData['num'];
|
||||
$factureNum = str_replace('/','-',$factureNum);
|
||||
$clientName = str_replace(' ',' ',$this->factureData['group_name'] ?? '');
|
||||
return $this->factureData['configuration']->facture_prefixe.'_'.$factureNum.'_'.mb_strtoupper($clientName,'UTF-8');
|
||||
return 'FACTURE'.'_'.$factureNum.'_'.mb_strtoupper($clientName,'UTF-8');
|
||||
}
|
||||
|
||||
public function DrawPageNumbersText($pageNumber,$pageCount){
|
||||
|
||||
@ -88,7 +88,7 @@ class InvoicePdfService {
|
||||
$logo = $this->getLogo();
|
||||
$invoicePdfData = $this->gestionBdd->getInvoicePdfData($factureId,$currentConfig);
|
||||
if($invoicePdfData == null){
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
$clean_folder = html_entity_decode(string: $currentConfig->path).'/';
|
||||
$factureFolders = $this->getFacturesFolder($invoicePdfData,$clean_folder);
|
||||
@ -112,7 +112,11 @@ class InvoicePdfService {
|
||||
$file_pdf->putContent($pdfContent);
|
||||
$filenames[] = $ff_pdf;
|
||||
}
|
||||
return $filenames;
|
||||
$this->gestionBdd->setFactureGeneratedDate($factureId);
|
||||
return [
|
||||
"content" => $pdfContent,
|
||||
"filenames" => $filenames
|
||||
];
|
||||
}
|
||||
|
||||
public function generateFacturePdfByFactureId($factureId,$idNextCloud){
|
||||
@ -195,7 +199,11 @@ class InvoicePdfService {
|
||||
$file_pdf->putContent($pdfContent);
|
||||
$filenames[] = $ff_pdf;
|
||||
}
|
||||
return $filenames;
|
||||
$this->gestionBdd->setFactureGeneratedDate($factureId);
|
||||
return [
|
||||
"content" => $pdfContent,
|
||||
"filenames" => $filenames
|
||||
];
|
||||
}
|
||||
|
||||
public function generateFacturePdfByFactureIds(array $factureIds,$idNextCloud){
|
||||
@ -279,8 +287,8 @@ class InvoicePdfService {
|
||||
}
|
||||
|
||||
$this->gestionBdd->invoiceListOfDevisIds($devisIds);
|
||||
$filenames = $this->generateFactureGroupPdfByFactureId($factureId,$idNextcloud);
|
||||
return $filenames;
|
||||
$factureGeneratedResponse = $this->generateFactureGroupPdfByFactureId($factureId,$idNextcloud);
|
||||
return $factureGeneratedResponse["filenames"];
|
||||
}
|
||||
catch(Exception){
|
||||
return null;
|
||||
|
||||
@ -4,9 +4,9 @@ import "../css/mycss.css";
|
||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||
import "./listener/main_listener";
|
||||
import "./listener/invoiceListener";
|
||||
import "./listener/factureSendMailListener";
|
||||
import { generateUrl } from "@nextcloud/router";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
globalConfiguration();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import "../css/mycss.css";
|
||||
import { getArticlesById, getMailServerFrom, getProduitsById, saveNextcloud, savePdfToNextcloud} from "./modules/ajaxRequest.mjs";
|
||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||
import "./listener/main_listener";
|
||||
import "./listener/factureSendMailListener";
|
||||
import { Client } from "./objects/client.mjs";
|
||||
import { capture, captureDevisFacture, sendMail } from "./pdf";
|
||||
|
||||
|
||||
69
gestion/src/js/listener/factureSendMailListener.js
Normal file
69
gestion/src/js/listener/factureSendMailListener.js
Normal file
@ -0,0 +1,69 @@
|
||||
import {showError, showSuccess } from "@nextcloud/dialogs";
|
||||
import {baseUrl, hideLoader, showLoader} from "../modules/mainFunction.mjs";
|
||||
import { Facture } from "../objects/facture.mjs";
|
||||
import DataTable from "datatables.net";
|
||||
import { generateUrl } from "@nextcloud/router";
|
||||
|
||||
$('body').on('click', '#showSendFacturePdfMailModal', function () {
|
||||
$('#sendFacturePdfMail').show();
|
||||
});
|
||||
|
||||
$('body').on('click', '#closeSendFacturePdfMail', function () {
|
||||
$('#sendFacturePdfMail').hide();
|
||||
});
|
||||
|
||||
$('body').on('click', '#showPdfPreview', function () {
|
||||
const factureId = $('#factureIdentifier').data('id');
|
||||
if(factureId){
|
||||
showLoader();
|
||||
$.ajax({
|
||||
url: baseUrl + '/invoice/'+factureId+'/getInvoicePdfContent',
|
||||
type: 'GET',
|
||||
contentType: 'application/json'
|
||||
}).done(function (response, textStatus, xhr) {
|
||||
if (xhr.status === 200) {
|
||||
var base64PDF = response.content;
|
||||
var byteCharacters = atob(base64PDF);
|
||||
var byteNumbers = new Array(byteCharacters.length);
|
||||
for (var i = 0; i < byteCharacters.length; i++) {
|
||||
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
||||
}
|
||||
var byteArray = new Uint8Array(byteNumbers);
|
||||
var fileBlob = new Blob([byteArray], { type: "application/pdf" });
|
||||
|
||||
var fileURL = URL.createObjectURL(fileBlob);
|
||||
window.open(fileURL, "_blank");
|
||||
} else {
|
||||
showError(t('gestion', "Erreur dans la récupération du document de la facture"));
|
||||
}
|
||||
}).fail(function (response, code) {
|
||||
showError(response);
|
||||
}).always(function () {
|
||||
hideLoader();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
$('body').on('click','#sendFacturePdf',function(){
|
||||
const factureId = $('#factureIdentifier').data('id');
|
||||
if(factureId){
|
||||
showLoader();
|
||||
$.ajax({
|
||||
url: baseUrl + '/invoice/'+factureId+'/sendInvoicePdfViaMail',
|
||||
type: 'POST',
|
||||
contentType: 'application/json'
|
||||
}).done(function (response, textStatus, xhr) {
|
||||
if (xhr.status === 200) {
|
||||
showSuccess(response);
|
||||
} else {
|
||||
showError(t('gestion', "Erreur dans l'envoi du mail chez le client"));
|
||||
}
|
||||
$('#sendFacturePdfMail').hide();
|
||||
}).fail(function (response, code) {
|
||||
$('#sendFacturePdfMail').hide();
|
||||
showError(response);
|
||||
}).always(function () {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -41,6 +41,13 @@ export class Facture {
|
||||
else{
|
||||
this.baseUrl = generateUrl(`/apps/gestion/facture/${this.id}/groupDetails`);
|
||||
}
|
||||
const isDocumentAlreadyGenerated = myresp.facture_document_generated_date != null;
|
||||
const isDocumentAlreadySent = myresp.facture_document_sent_date != null;
|
||||
this.isDocumentAlreadyGeneratedLabel = this.getDocumentStateLabel(isDocumentAlreadyGenerated);
|
||||
this.isDocumentAlreadySentLabel = this.getDocumentStateLabel(isDocumentAlreadySent);
|
||||
this.isDocumentAlreadyGeneratedClass = this.getDocumentStateClass(isDocumentAlreadyGenerated);
|
||||
this.isDocumentAlreadySentClass = this.getDocumentStateClass(isDocumentAlreadySent);
|
||||
|
||||
this.clientName = this.nom;
|
||||
if(isFactureSingle == false){
|
||||
const isFactureClientWithoutGroup = myresp.facture_client_id != null && myresp.facture_client_id != 0;
|
||||
@ -53,6 +60,14 @@ export class Facture {
|
||||
}
|
||||
}
|
||||
|
||||
getDocumentStateLabel(documentState){
|
||||
return documentState ? "Oui" : "Non";
|
||||
}
|
||||
|
||||
getDocumentStateClass(documentState){
|
||||
return documentState ? "text-bg-success" : "text-bg-warning";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get datatable row for a devis
|
||||
*/
|
||||
@ -69,6 +84,8 @@ export class Facture {
|
||||
'<div>' + this.factureProduits + '</div>',
|
||||
'<div>' + this.status_paiement + '</div>',
|
||||
'<div>' + this.payment_date + '</div>',
|
||||
'<div><span class="badge '+this.isDocumentAlreadyGeneratedClass+'">' + this.isDocumentAlreadyGeneratedLabel + '</span></div>',
|
||||
'<div><span class="badge '+this.isDocumentAlreadySentClass+'">' + this.isDocumentAlreadySentLabel + '</span></div>',
|
||||
'<div style="display:inline-block;margin-right:0px;width:80%;"><a href="' + this.baseUrl +'"><button>' + t('gestion', 'Open') + '</button></a></div><div data-modifier="facture" data-id=' + this.id + ' data-table="facture" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>',
|
||||
];
|
||||
return myrow;
|
||||
|
||||
@ -37,6 +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('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -108,7 +108,10 @@ $currentConfig = json_decode($_['configuration'])[0];
|
||||
</div>
|
||||
<div>
|
||||
<button id="exportFactureToPdf" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore data-name=""><?php p($l->t('Save in Nextcloud'));?></button>
|
||||
<button id="mailGestion" type="button" class="mb-2 btn btn-outline-success sendmail" data-html2canvas-ignore data-name=""><?php p($l->t('Send by email'));?></button>
|
||||
<button id="showSendFacturePdfMailModal"
|
||||
type="button"
|
||||
class="mb-2 btn btn-outline-success sendmail"
|
||||
><?php p($l->t('Send by email'));?></button>
|
||||
</div>
|
||||
<div class="mt-0 table-responsive">
|
||||
<table id="totalFactureGroupPrice" class="table table-striped table-xl">
|
||||
@ -138,4 +141,18 @@ $currentConfig = json_decode($_['configuration'])[0];
|
||||
<p><?php echo $currentConfig->entreprise; ?><br /><?php echo $currentConfig->adresse; ?><br /><?php echo $currentConfig->legal_one; ?><br /><?php echo $currentConfig->legal_two; ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal" id="sendFacturePdfMail" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Envoyer la facture par email à <?= $facture->mail; ?></h5>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="showPdfPreview" type="button" class="btn btn-secondary">Voir l'aperçu</button>
|
||||
<button id="closeSendFacturePdfMail" type="button" class="btn btn-secondary">Annuler</button>
|
||||
<button id="sendFacturePdf" type="button" class="btn btn-primary">Envoyer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1,3 +1,7 @@
|
||||
<?php
|
||||
$facture = $_['facture'][0];
|
||||
$clientMail = $facture->client_id != null ? $facture->client_mail : $facture->group_client_mail;
|
||||
?>
|
||||
<div class="bootstrap-iso d-flex flex-column justify-content-between">
|
||||
<div class="d-flex flex-column w-100">
|
||||
<h2 class="mt-3 mb-3 text-center"><?php p($l->t('Invoice #'));?>
|
||||
@ -123,7 +127,10 @@
|
||||
<hr>
|
||||
<div>
|
||||
<button id="exportFactureToPdf" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore data-name=""><?php p($l->t('Save in Nextcloud'));?></button>
|
||||
<button id="mailGestion" type="button" class="mb-2 btn btn-outline-success sendmail" data-html2canvas-ignore data-name=""><?php p($l->t('Send by email'));?></button>
|
||||
<button id="showSendFacturePdfMailModal"
|
||||
type="button"
|
||||
class="mb-2 btn btn-outline-success sendmail"
|
||||
><?php p($l->t('Send by email'));?></button>
|
||||
</div>
|
||||
<div class="mt-0 table-responsive">
|
||||
<table id="totaldevis" class="table table-striped table-xl">
|
||||
@ -149,5 +156,19 @@
|
||||
<p><?php echo $res->entreprise; ?><br /><?php echo $res->adresse; ?><br /><?php echo $res->legal_one; ?><br/><?php echo $res->legal_two; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal" id="sendFacturePdfMail" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Envoyer la facture par email à <?= $clientMail; ?></h5>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="showPdfPreview" type="button" class="btn btn-secondary">Voir l'aperçu</button>
|
||||
<button id="closeSendFacturePdfMail" type="button" class="btn btn-secondary">Annuler</button>
|
||||
<button id="sendFacturePdf" type="button" class="btn btn-primary">Envoyer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user