finish new model for devis and facture for h2f, wip certificate

This commit is contained in:
Tiavina 2025-01-17 14:11:37 +03:00
parent 2726be3c5a
commit c3fbde928a
14 changed files with 147 additions and 23 deletions

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

View File

@ -74,7 +74,7 @@ class DevisPdfHandler extends FPDF {
$this->SetY(40);
$this->SetFont('Arial', '', 12);
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration']->entreprise), 0, 0);
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['client_nom']), 0, 1,'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['client_entreprise']), 0, 1,'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration_adresse']), 0, 0);
$this->Cell(0, 7, trim(FileExportHelpers::FormatTextForExport($this->devisData['client_real_adress'])), 0, 1,'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration_adresse_city']), 0, 0);border:

View File

@ -94,7 +94,7 @@ class InvoicePdfHandler extends FPDF {
$this->SetY(40);
$this->SetFont('Arial', '', 12);
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->factureData['configuration']->entreprise), 0, 0);
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->factureData['client_nom']), 0, 1,'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->factureData['client_entreprise']), 0, 1,'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse']), 0, 0);
$this->Cell(0, 7, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_real_adress'])), 0, 1,'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse_city']), 0, 0);border:

View File

@ -654,6 +654,17 @@
"node": ">= 8"
}
},
"node_modules/@popperjs/core": {
"version": "2.11.8",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
"integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==",
"dev": true,
"peer": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@skjnldsv/sanitize-svg": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@skjnldsv/sanitize-svg/-/sanitize-svg-1.0.2.tgz",
@ -2520,6 +2531,13 @@
"node": ">=8.0.0"
}
},
"node_modules/ical.js": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/ical.js/-/ical.js-1.5.0.tgz",
"integrity": "sha512-7ZxMkogUkkaCx810yp0ZGKvq1ZpRgJeornPttpoxe6nYZ3NLesZe1wWMXDdwTkj/b5NtXT+Y16Aakph/ao98ZQ==",
"dev": true,
"peer": true
},
"node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@ -3011,6 +3029,13 @@
"linkifyjs": "^4.0.0"
}
},
"node_modules/linkifyjs": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.2.0.tgz",
"integrity": "sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==",
"dev": true,
"peer": true
},
"node_modules/loader-runner": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
@ -4540,6 +4565,16 @@
"base64-arraybuffer": "^1.0.2"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"dev": true,
"peer": true,
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/v-click-outside": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/v-click-outside/-/v-click-outside-3.2.0.tgz",

View File

@ -4,13 +4,17 @@ import "../css/mycss.css";
import { globalConfiguration } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import { getPDF } from "./pdf";
import { exportClientDevisByMonthAndYearToPdf } from "./modules/ajaxRequest.mjs";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
var pdf = document.getElementById("pdfDevis");
pdf.addEventListener("click",async ()=>{
getPDF('devis');
const urlParams = new URLSearchParams(window.location.search);
const clientId = urlParams.get('cli');
const year = urlParams.get('annee');
const month = urlParams.get('mois');
var exportMultipleDevisToPdfButton = this.document.getElementById("exportMultipleDevisToPdf");
exportMultipleDevisToPdfButton.addEventListener("click",function(){
exportClientDevisByMonthAndYearToPdf(clientId,year,month);
});
});

View File

@ -4,6 +4,7 @@ import "../css/mycss.css";
import { globalConfiguration } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import "./listener/invoiceListener";
import { getPDF } from "./pdf";
import { saveDocumentRecap } from "./modules/ajaxRequest.mjs";

View File

@ -2,7 +2,7 @@ import "@nextcloud/dialogs/dist/index.css";
import "datatables.net-dt/css/jquery.dataTables.css";
import "../css/mycss.css";
import { getArticlesById, getMailServerFrom, getProduitsById, savePdfToNextcloud} from "./modules/ajaxRequest.mjs";
import { getArticlesById, getMailServerFrom, getProduitsById, savePdfToNextcloud,exportDevisToPdf} from "./modules/ajaxRequest.mjs";
import { globalConfiguration } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import { Client } from "./objects/client.mjs";
@ -12,20 +12,14 @@ import { showError } from "@nextcloud/dialogs";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
const devisId = $("#devisid").data("id");
Client.getClientByIdDevis($("#devisid").data("id"));
getProduitsById();
getArticlesById();
var pdf = document.getElementById("pdf");
pdf.addEventListener("click",function(){
if(!!!document.getElementById("etp").innerText) {
showError("S'il vous plait! Veuillez d'abord selectionner un client.");
} else {
let defunt = document.getElementById("nomdefunt").innerText;
let lieusoin = document.getElementById("lieusoin").innerText;
let etp = document.getElementById("etp").innerText;
captureDevisFacture(savePdfToNextcloud, document.getElementById("dateContext").innerText, defunt, lieusoin, etp);
}
var exportDevisToPdfButton = this.document.getElementById("exportDevisToPdf");
exportDevisToPdfButton.addEventListener("click",function(){
exportDevisToPdf(devisId);
});
var mail = document.getElementById("mailGestion");

View File

@ -0,0 +1,32 @@
import {showError, showSuccess } from "@nextcloud/dialogs";
import {baseUrl} from "../modules/mainFunction.mjs";
$('body').on('click', '#exportMultipleFactureToPdf', function () {
// Access specific parameter values
const urlParams = new URLSearchParams(window.location.search);
const clientId = urlParams.get('cli');
const year = urlParams.get('annee');
const month = urlParams.get('mois');
var exportMultipleFacturePayload = {
clientId : clientId,
month : month,
year : year
};
$.ajax({
url: baseUrl + '/facture/exportFactureByClientAndMonthYearToPdf',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(exportMultipleFacturePayload)
}).done(function (response) {
var fileName = response;
if(fileName != null){
showSuccess('Sauvegardé dans' + fileName);
return;
}
showError(t('gestion', "Les données pour sauvegarde sont vides"));
}).fail(function (response, code) {
showError(t('gestion', "Erreur dans la génération de facture multiple"));
});
});

View File

@ -737,3 +737,61 @@ export function genererDefunts() {
error(response);
});
};
/**
* Export devis to pdf
* @param {*} devisId
*/
export function exportDevisToPdf(devisId) {
if(devisId == null){
showError('Devis non trouvé');
return;
}
let payload = {
devisId : devisId
}
$.ajax({
url: baseUrl + '/devis/exportDevisToPdf',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(payload)
}).done(function (response) {
if(response == null) {
showMessage('Le devis n\'existe pas');
return;
}
var fileNames = JSON.parse(response);
fileNames.forEach(fileName => {
showSuccess('Sauvegardé dans' + fileName);
});
}).fail(function (response, code) {
showMessage(t('gestion', 'Erreur dans l\'export du devis en PDF'));
error(response);
});
};
/**
* Export multiple devis to pdf
* @param {*} devisId
*/
export function exportClientDevisByMonthAndYearToPdf(clientId,year,month) {
let payload = {
clientId: clientId,
month : month,
year : year
};
$.ajax({
url: baseUrl + '/devis/exportDevisByClientAndMonthYearToPdf',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(payload)
}).done(function (response) {
if(response != null) {
showSuccess('Sauvegardé dans' + response);
return;
}
showError(t('gestion', "Les données pour sauvegarde sont vides"));
}).fail(function (response, code) {
showError(t('gestion', "Erreur dans la génération de devis multiple"));
});
};

View File

@ -61,7 +61,7 @@
});
if(strcmp($_GET['cli'], '')!=0 && sizeof($devis)>0) {
?>
<button class="btn btn-secondary" type="button" id="pdfDevis"><?php p($l->t('Save in Nextcloud'));?></button>
<button class="btn btn-secondary" type="button" id="exportMultipleDevisToPdf"><?php p($l->t('Save in Nextcloud'));?></button>
<?php
}
}

View File

@ -61,7 +61,7 @@
if(sizeof($factures)>0) {
?>
<?php if($showRecapButton) {?><button class="btn btn-secondary" type="button" id="documentrecap">Generer le document recapitulatif</button><?php }?>
<button class="btn btn-secondary ml-2" type="button" id="pdfFactures"><?php p($l->t('Save in Nextcloud'));?></button>
<button class="btn btn-secondary ml-2" type="button" id="exportMultipleFactureToPdf"><?php p($l->t('Save in Nextcloud'));?></button>
<?php
}
}

View File

@ -109,7 +109,7 @@
</div>
<hr>
<div>
<button id="pdf" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore data-name=""><?php p($l->t('Save in Nextcloud'));?></button>
<button id="exportDevisToPdf" type="button" class="mb-2 btn btn-outline-success"><?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>
</div>
<div class="mt-0 table-responsive">