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
{ const FACTURED = "factur&eacute;"; abstract class DevisMentionConstant
const FACTURED_FORMATTED = "facturé"; {
const MENTION = "Mention"; public const FACTURED = "factur&eacute;";
const NEW = "Nouveau"; public const FACTURED_FORMATTED = "facturé";
const CANCELED = "CANCELED"; public const MENTION = "Mention";
} 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

@ -357,10 +357,9 @@ export function getProduitsByIdDevis(id_devis) {
/** /**
* Get a product in database using id * Get a product in database using id
*/ */
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,5 +1,8 @@
<div class="bootstrap-iso"> <?php
<h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Quote'));?> $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'));?>
<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>
</h2> </h2>
@ -19,12 +22,12 @@
</div> </div>
<div class="col-2 h-100 m-0" style="min-height:250px;"> <div class="col-2 h-100 m-0" style="min-height:250px;">
<?php <?php
if(isset($_['logo']) && $_['logo'] !== "nothing"){ if(isset($_['logo']) && $_['logo'] !== "nothing") {
echo "<center><a><img alt='".$l->t('Company logo')."' class=\"img-fluid\" src=\"data:image/png;base64, ".$_['logo']."\"/></a></center>"; echo "<center><a><img alt='".$l->t('Company logo')."' class=\"img-fluid\" src=\"data:image/png;base64, ".$_['logo']."\"/></a></center>";
}else{ } else {
echo "<span style='font-size:12px' id='Company-logo' data-html2canvas-ignore><b><center>".$l->t('You can add your company logo here.')."</center></b><br/><i>".$l->t('To add a logo, drop the logo.png file in ".gestion" folder at the root of your Nextcloud Files app. Remember to set "Show hidden files".')."</i><br/><br/><center>".$l->t('This message will not appear on generated PDF.')."</center></span>"; echo "<span style='font-size:12px' id='Company-logo' data-html2canvas-ignore><b><center>".$l->t('You can add your company logo here.')."</center></b><br/><i>".$l->t('To add a logo, drop the logo.png file in ".gestion" folder at the root of your Nextcloud Files app. Remember to set "Show hidden files".')."</i><br/><br/><center>".$l->t('This message will not appear on generated PDF.')."</center></span>";
} }
?> ?>
</div> </div>
<div class="col-5 h-100 m-0" style="min-height:250px;"> <div class="col-5 h-100 m-0" style="min-height:250px;">
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO'));?> <span id="entreprise"></span></h5> <h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO'));?> <span id="entreprise"></span></h5>
@ -66,7 +69,7 @@
style="display:inline" style="display:inline"
data-table="devis" data-column="order_number" data-table="devis" data-column="order_number"
data-id="<?php echo $_['devis'][0]->devisid;?>"> data-id="<?php echo $_['devis'][0]->devisid;?>">
<?php echo ($_['devis'][0]->order_number == "" ) ? "-" : $_['devis'][0]->order_number ; ?> <?php echo ($_['devis'][0]->order_number == "") ? "-" : $_['devis'][0]->order_number ; ?>
</div> </div>
</div> </div>
<hr /> <hr />
@ -78,14 +81,16 @@
style="display:inline" style="display:inline"
data-table="devis" data-column="case_number" data-table="devis" data-column="case_number"
data-id="<?php echo $_['devis'][0]->devisid;?>"> data-id="<?php echo $_['devis'][0]->devisid;?>">
<?php echo ($_['devis'][0]->case_number == "" ) ? "-" : $_['devis'][0]->case_number ; ?> <?php echo ($_['devis'][0]->case_number == "") ? "-" : $_['devis'][0]->case_number ; ?>
</div> </div>
</div> </div>
<hr /> <hr />
</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>
<button id="devisAdd" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore>Ajouter article</button> <?php if (!$isFacture): ?>
<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>
<button id="devisAddProduit" type="button" class="mb-2 btn btn-outline-success" data-html2canvas-ignore>Ajouter produit</button> <?php if (!$isFacture): ?>
<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">