fix disabled devis invoice facturé

This commit is contained in:
Tolotsoa 2026-01-20 15:38:22 +03:00
parent f16830c5a0
commit eccc085124
28 changed files with 102 additions and 55 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

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

View File

@ -1,11 +1,14 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
namespace OCA\Gestion\Constants; namespace OCA\Gestion\Constants;
abstract class DevisMentionConstant abstract class DevisMentionConstant
{ const FACTURED = "factur&eacute;"; {
const FACTURED_FORMATTED = "facturé"; public const FACTURED = "factur&eacute;";
const MENTION = "Mention"; public const FACTURED_FORMATTED = "facturé";
const NEW = "Nouveau"; public const MENTION = "Mention";
const CANCELED = "CANCELED"; public const NEW = "Nouveau";
public const CANCELED = "CANCELED";
} }

View File

@ -894,7 +894,7 @@ class Bdd
public function getOneDevis($numdevis, $idNextcloud) public function getOneDevis($numdevis, $idNextcloud)
{ {
$sql = "SELECT ".$this->tableprefix."devis.id as devisid, ".$this->tableprefix."devis.version, ".$this->tableprefix."devis.comment, ".$this->tableprefix."devis.date, num," $sql = "SELECT ".$this->tableprefix."devis.id as devisid, ".$this->tableprefix."devis.version, ".$this->tableprefix."devis.comment, ".$this->tableprefix."devis.date, ".$this->tableprefix."devis.mentions, num,"
.$this->tableprefix."devis.id_nextcloud as didnextcloud,".$this->tableprefix."devis.id_client, id_lieu, id_thanato,case_number,order_number," .$this->tableprefix."devis.id_nextcloud as didnextcloud,".$this->tableprefix."devis.id_client, id_lieu, id_thanato,case_number,order_number,"
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt," .$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt,"
.$this->tableprefix."client.id as clientid, ".$this->tableprefix."client.nom, " .$this->tableprefix."client.id as clientid, ".$this->tableprefix."client.nom, "

View File

@ -9,6 +9,7 @@ import { Client } from "./objects/client.mjs";
import { capture, sendMail, captureDevisFacture } from "./pdf"; import { capture, sendMail, captureDevisFacture } from "./pdf";
window.addEventListener("DOMContentLoaded", function () { window.addEventListener("DOMContentLoaded", function () {
window.isDevisFacture = $('.bootstrap-iso').data('is-facture') === 1;
globalConfiguration(); globalConfiguration();
const devisId = $("#devisid").data("id"); const devisId = $("#devisid").data("id");
@ -16,6 +17,12 @@ window.addEventListener("DOMContentLoaded", function () {
getProduitsById(); getProduitsById();
getArticlesById(); getArticlesById();
if (window.isDevisFacture) {
$('#devisAdd').hide();
$('#devisAddProduit').hide();
$('.editable').removeClass('editable');
}
var exportDevisToPdfButton = this.document.getElementById("exportDevisToPdf"); var exportDevisToPdfButton = this.document.getElementById("exportDevisToPdf");
exportDevisToPdfButton.addEventListener("click",function(){ exportDevisToPdfButton.addEventListener("click",function(){
exportDevisToPdf(devisId); exportDevisToPdf(devisId);

View File

@ -360,7 +360,6 @@ export function getProduitsByIdDevis(id_devis) {
export function getProduitsById() { export function getProduitsById() {
var devis_id = $('#devisid').data('id'); var devis_id = $('#devisid').data('id');
var myData = { numdevis: devis_id, }; var myData = { numdevis: devis_id, };
$.ajax({ $.ajax({
url: baseUrl + '/getProduitsById', url: baseUrl + '/getProduitsById',
type: 'POST', type: 'POST',
@ -371,20 +370,36 @@ export function getProduitsByIdDevis(id_devis) {
$('#produits tbody').empty(); $('#produits tbody').empty();
var total = 0; var total = 0;
var deleteDisable = ""; var deleteDisable = "";
if ($('#produits').data("type") === "facture") { var isFacture = window.isDevisFacture || false;
if ($('#produits').data("type") === "facture" || isFacture) {
deleteDisable = "d-none"; deleteDisable = "d-none";
} }
$.each(JSON.parse(response), function (arrayID, myresp) { $.each(JSON.parse(response), function (arrayID, myresp) {
$('#produits tbody').append('<tr><td><div data-html2canvas-ignore data-modifier="getProduitsById" data-id="' + myresp.pdid + '" data-table="produit_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div><div style="display:inline;" data-val="' + myresp.pid + '" data-id="' + myresp.pdid + '" class="selectable">' + myresp.reference + '</div></td>' + // Référence : sélectionnable ou simple affichage
var referenceHtml = isFacture
? '<div style="display:inline;">' + myresp.reference + '</div>'
: '<div style="display:inline;" data-val="' + myresp.pid + '" data-id="' + myresp.pdid + '" class="selectable">' + myresp.reference + '</div>';
// Quantité : éditable ou simple affichage selon statut
var quantiteHtml = isFacture
? '<div>' + myresp.quantite + '</div>'
: '<div class="editableNumber getProduitsById" style="display:inline;" data-modifier="getProduitsById" data-table="produit_devis" data-column="quantite" data-id=' + myresp.pdid + '>' + myresp.quantite + '</div>';
// Commentaire : éditable ou simple affichage
var commentHtml = isFacture
? '<div>' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div>'
: '<div class="editable" data-table="produit_devis" data-column="comment" data-id="' + myresp.pdid + '">' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div>';
$('#produits tbody').append('<tr><td><div data-html2canvas-ignore data-modifier="getProduitsById" data-id="' + myresp.pdid + '" data-table="produit_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div>' + referenceHtml + '</td>' +
'<td>' + myresp.description + '</td>' + '<td>' + myresp.description + '</td>' +
'<td><div class="editable" data-table="produit_devis" data-column="comment" data-id="' + myresp.pdid + '">' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div></td>' + '<td>' + commentHtml + '</td>' +
'<td><div class="editableNumber getProduitsById" style="display:inline;" data-modifier="getProduitsById" data-table="produit_devis" data-column="quantite" data-id=' + myresp.pdid + '>' + myresp.quantite + '</div> </td>' + '<td>' + quantiteHtml + '</td>' +
'<td>' + cur.format(myresp.prix_unitaire) + '</td>' + '<td>' + cur.format(myresp.prix_unitaire) + '</td>' +
'<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>'); '<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>');
total += (myresp.quantite * myresp.prix_unitaire); total += (myresp.quantite * myresp.prix_unitaire);
}); });
$("#totaldevis tbody").empty(); $("#totaldevis tbody").empty();
getGlobal(devis_id); getGlobal(devis_id);
}).fail(function (response, code) { }).fail(function (response, code) {
@ -398,7 +413,6 @@ export function getProduitsByIdDevis(id_devis) {
export function getArticlesById() { export function getArticlesById() {
var devis_id = $('#devisid').data('id'); var devis_id = $('#devisid').data('id');
var myData = { numdevis: devis_id }; var myData = { numdevis: devis_id };
$.ajax({ $.ajax({
url: baseUrl + '/getArticlesById', url: baseUrl + '/getArticlesById',
type: 'POST', type: 'POST',
@ -409,20 +423,36 @@ export function getArticlesById() {
$('#articles tbody').empty(); $('#articles tbody').empty();
var total = 0; var total = 0;
var deleteDisable = ""; var deleteDisable = "";
if ($('#articles').data("type") === "facture") { var isFacture = window.isDevisFacture || false;
if ($('#articles').data("type") === "facture" || isFacture) {
deleteDisable = "d-none"; deleteDisable = "d-none";
} }
$.each(JSON.parse(response), function (arrayID, myresp) { $.each(JSON.parse(response), function (arrayID, myresp) {
$('#articles tbody').append('<tr><td><div data-html2canvas-ignore data-modifier="getArticlesById" data-id="' + myresp.adid + '" data-table="article_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div><div style="display:inline;" data-val="' + myresp.aid + '" data-id="' + myresp.adid + '" class="articleSelectable">' + myresp.reference + '</div></td>' + // Référence : sélectionnable ou simple affichage
var referenceHtml = isFacture
? '<div style="display:inline;">' + myresp.reference + '</div>'
: '<div style="display:inline;" data-val="' + myresp.aid + '" data-id="' + myresp.adid + '" class="articleSelectable">' + myresp.reference + '</div>';
// Quantité : éditable ou simple affichage selon statut
var quantiteHtml = isFacture
? '<div>' + myresp.quantite + '</div>'
: '<div class="editableNumber getArticlesById" style="display:inline;" data-modifier="getArticlesById" data-table="article_devis" data-column="quantite" data-id=' + myresp.adid + '>' + myresp.quantite + '</div>';
// Commentaire : éditable ou simple affichage
var commentHtml = isFacture
? '<div>' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div>'
: '<div class="editable" data-table="article_devis" data-column="comment" data-id="' + myresp.adid + '">' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div>';
$('#articles tbody').append('<tr><td><div data-html2canvas-ignore data-modifier="getArticlesById" data-id="' + myresp.adid + '" data-table="article_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div>' + referenceHtml + '</td>' +
'<td>' + myresp.description + '</td>' + '<td>' + myresp.description + '</td>' +
'<td><div class="editable" data-table="article_devis" data-column="comment" data-id="' + myresp.adid + '">' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div></td>' + '<td>' + commentHtml + '</td>' +
'<td><div class="editableNumber getArticlesById" style="display:inline;" data-modifier="getArticlesById" data-table="article_devis" data-column="quantite" data-id=' + myresp.adid + '>' + myresp.quantite + '</div> </td>' + '<td>' + quantiteHtml + '</td>' +
'<td>' + cur.format(myresp.prix_unitaire) + '</td>' + '<td>' + cur.format(myresp.prix_unitaire) + '</td>' +
'<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>'); '<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>');
total += (myresp.quantite * myresp.prix_unitaire); total += (myresp.quantite * myresp.prix_unitaire);
}); });
$("#totaldevis tbody").empty(); $("#totaldevis tbody").empty();
getGlobal(devis_id); getGlobal(devis_id);
}).fail(function (response, code) { }).fail(function (response, code) {

View File

@ -1,4 +1,7 @@
<div class="bootstrap-iso"> <?php
$isFacture = isset($_['devis'][0]->mentions) && ($_['devis'][0]->mentions == \OCA\Gestion\Constants\DevisMentionConstant::FACTURED || $_['devis'][0]->mentions == \OCA\Gestion\Constants\DevisMentionConstant::FACTURED_FORMATTED);
?>
<div class="bootstrap-iso" data-is-facture="<?php echo $isFacture ? '1' : '0'; ?>">
<h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Quote'));?> <h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Quote'));?>
<div id="devisid" style="display:inline" class="editable" data-table="devis" data-column="num" data-id="<?php echo $_['devis'][0]->devisid; ?>">sur le defunt <?php echo $_['devis'][0]->nom_defunt; ?></div> <div id="devisid" style="display:inline" class="editable" data-table="devis" data-column="num" data-id="<?php echo $_['devis'][0]->devisid; ?>">sur le defunt <?php echo $_['devis'][0]->nom_defunt; ?></div>
<span data-html2canvas-ignore>(</span> <div data-html2canvas-ignore id="devisversion" style="display:inline" data-table="devis" data-column="version" data-id="<?php echo $_['devis'][0]->id; ?>"><?php echo $_['devis'][0]->lieu; ?>)</div> <span data-html2canvas-ignore>(</span> <div data-html2canvas-ignore id="devisversion" style="display:inline" data-table="devis" data-column="version" data-id="<?php echo $_['devis'][0]->id; ?>"><?php echo $_['devis'][0]->lieu; ?>)</div>
@ -85,7 +88,9 @@
</div> </div>
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div><h2>Articles</h2></div> <div><h2>Articles</h2></div>
<?php if (!$isFacture): ?>
<button id="devisAdd" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore>Ajouter article</button> <button id="devisAdd" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore>Ajouter article</button>
<?php endif; ?>
</div> </div>
<hr> <hr>
<div class="table-responsive"> <div class="table-responsive">
@ -106,7 +111,9 @@
</div> </div>
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div><h2>Produits</h2></div> <div><h2>Produits</h2></div>
<?php if (!$isFacture): ?>
<button id="devisAddProduit" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore>Ajouter produit</button> <button id="devisAddProduit" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore>Ajouter produit</button>
<?php endif; ?>
</div> </div>
<hr> <hr>
<div class="table-responsive"> <div class="table-responsive">