facture type

This commit is contained in:
Tiavina 2025-03-02 16:04:59 +03:00
parent 9c6ba888f9
commit 4cbf598b12
29 changed files with 289 additions and 126 deletions

View File

@ -172,5 +172,6 @@ return [
//group of devis and facture
['name' => 'page#exportGroupOfDevisIntoFacture','url' => '/devis/exportGroupOfDevisIntoFacture', 'verb' => 'POST'],
['name' => 'page#getClientTemplateTypes','url' => '/client/getClientTemplateTypes', 'verb' => 'PROPFIND'],
]
];

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

@ -2948,4 +2948,13 @@ class PageController extends Controller {
return json_encode([]);
}
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
*/
public function getClientTemplateTypes(){
return $this->myDb->getClientTemplateTypes();
}
}

View File

@ -51,7 +51,7 @@ class Bdd {
"product_brand","product_reference",
"fk_user_uuid",
"phone_number","address",'postal_code','city','email','siret_number','tva_intracommu',
'order_number','case_number');
'order_number','case_number','fk_template_type_key');
$this->whiteTable = array(
"client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit", "configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis", "bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt",
"client_group_discount","client_group",
@ -4364,4 +4364,9 @@ class Bdd {
return $devisList;
}
public function getClientTemplateTypes(){
$sql = "SELECT * FROM ".$this->tableprefix."client_template_type as client_template_type";
return $this->execSQL($sql,[]);
}
}

View File

@ -219,7 +219,7 @@ class InvoiceGroupPdfHandler extends FPDF {
$totalTtc = 0;
$totalTva = 0;
$yValue = $this->startingYOfArticlesTable + 11;
$maxDescriptionWidth = 98;
$maxDescriptionWidth = 104;
$currentIndexPosition = $this->currentIndexPosition;
for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->devisCountToGet);$currentIndexPosition++){
$currentDevis = $devisData[$currentIndexPosition];
@ -239,13 +239,21 @@ class InvoiceGroupPdfHandler extends FPDF {
$productDescription .= " de " . $currentDevis["defunt_nom"] ?? "";
}
$productDescriptionWidth = $this->GetStringWidth($productDescription);
if($currentDevis["defunt_nom"] == "LANGLEMENT Catherine"){
var_dump($productDescriptionWidth);
}
$productDescriptionIsMultiline = $productDescriptionWidth > $maxDescriptionWidth;
$tvaAmount = $valueTtc - $valueHt;
$this->SetXY( 8,$yValue );
$this->Cell(20, 6, $dateValue, 0,0);
$this->SetXY( 35,$yValue );
$this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($productDescription),0,'0',);
if($productDescriptionIsMultiline){
$this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($productDescription),0,'0',);
}
else{
$this->Cell(100,6,FileExportHelpers::FormatTextForExport($productDescription),0,0);
}
$this->SetXY( 138,$yValue );
$this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C');
@ -265,12 +273,8 @@ class InvoiceGroupPdfHandler extends FPDF {
$this->currentIndexPosition = $currentIndexPosition;
$this->initialIndexPosition = $this->currentIndexPosition;
$chargedDevisCount = $this->currentIndexPosition + 1;
var_dump("CURRENT POSITION : ".$this->currentIndexPosition);
var_dump("CHARGED DEVIS COUNT : ".$chargedDevisCount);
$devisLeftToGet = $this->devisCount - $chargedDevisCount;
var_dump("LEFT TO GET : ".$devisLeftToGet);
$this->devisCountToGet = ($devisLeftToGet <= $this->maxArticlePerPage) ? $devisLeftToGet + 1 : $this->maxArticlePerPage;
var_dump("DEVIS COUNT TO GET : ".$this->devisCountToGet);
}
public function DrawBankAndTotalPriceInfo(){

View File

@ -60,6 +60,9 @@ document.body.addEventListener('click', e => {
else if(e.target.className.includes("selectClientGroupList")){
ClientGroup.loadClientGroupListToSelect(e);
}
else if(e.target.className.includes("selectClientTemplateTypes")){
ClientGroupFacturation.loadClientTemplateTypesIntoSelect(e);
}
else if(e.target.className.includes("selectClientGroupFacturationList")){
ClientGroupFacturation.loadClientGroupFacturationListToSelect(e);
}

View File

@ -1,23 +1,52 @@
import { showError } from "@nextcloud/dialogs";
import { baseUrl, checkSelectPurJs, LoadDT, showDone } from "../modules/mainFunction.mjs";
import {
baseUrl,
checkSelectPurJs,
LoadDT,
showDone,
} from "../modules/mainFunction.mjs";
import { updateDB } from "../modules/ajaxRequest.mjs";
export class ClientGroupFacturation {
/**
*
*
* @param myresp instantiate client group facturation object
*/
constructor(myresp) {
this.id = myresp.id;
this.clientGroupFacturationName = ((myresp.group_facturation_name.length === 0) ? '-' : myresp.group_facturation_name);
this.phoneNumber = (myresp.phone_number != null && myresp.phone_number.length > 0) ? myresp.phone_number : '-';
this.address = (myresp.address != null && myresp.address.length > 0) ? myresp.address : '-';
this.postalCode = (myresp.postal_code != null && myresp.postal_code.length > 0) ? myresp.postal_code : '-';
this.city = (myresp.city != null && myresp.city.length > 0) ? myresp.city : '-';
this.email = (myresp.email != null && myresp.email.length > 0) ? myresp.email : '-';
this.siretNumber = (myresp.siret_number != null && myresp.siret_number.length > 0) ? myresp.siret_number : '-';
this.tvaIntraCommu = (myresp.tva_intracommu != null && myresp.tva_intracommu.length > 0) ? myresp.tva_intracommu : '-';
this.clientGroupFacturationName =
myresp.group_facturation_name.length === 0
? "-"
: myresp.group_facturation_name;
this.phoneNumber =
myresp.phone_number != null && myresp.phone_number.length > 0
? myresp.phone_number
: "-";
this.address =
myresp.address != null && myresp.address.length > 0
? myresp.address
: "-";
this.postalCode =
myresp.postal_code != null && myresp.postal_code.length > 0
? myresp.postal_code
: "-";
this.city =
myresp.city != null && myresp.city.length > 0 ? myresp.city : "-";
this.email =
myresp.email != null && myresp.email.length > 0 ? myresp.email : "-";
this.siretNumber =
myresp.siret_number != null && myresp.siret_number.length > 0
? myresp.siret_number
: "-";
this.tvaIntraCommu =
myresp.tva_intracommu != null && myresp.tva_intracommu.length > 0
? myresp.tva_intracommu
: "-";
this.templateTypeKey =
myresp.fk_template_type_key != null &&
myresp.fk_template_type_key.length > 0
? myresp.fk_template_type_key
: "-";
}
/**
@ -25,120 +54,231 @@ export class ClientGroupFacturation {
*/
getDTRow() {
let clientGroupFacturationRow = [
'<div>' + this.id + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="group_facturation_name" data-id="' + this.id + '">' + this.clientGroupFacturationName + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="address" data-id="' + this.id + '">' + this.address + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="city" data-id="' + this.id + '">' + this.city + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="postal_code" data-id="' + this.id + '">' + this.postalCode + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="email" data-id="' + this.id + '">' + this.email + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="phone_number" data-id="' + this.id + '">' + this.phoneNumber + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="siret_number" data-id="' + this.id + '">' + this.siretNumber + '</div>',
'<div class="editable" data-table="client_group_facturation" data-column="tva_intracommu" data-id="' + this.id + '">' + this.tvaIntraCommu + '</div>',
'<div data-modifier="clientGroupFacturation" data-id=' + this.id + ' data-table="client_group_facturation" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
"<div>" + this.id + "</div>",
'<div class="editable" data-table="client_group_facturation" data-column="group_facturation_name" data-id="' +
this.id +
'">' +
this.clientGroupFacturationName +
"</div>",
'<div class="editable" data-table="client_group_facturation" data-column="address" data-id="' +
this.id +
'">' +
this.address +
"</div>",
'<div class="editable" data-table="client_group_facturation" data-column="city" data-id="' +
this.id +
'">' +
this.city +
"</div>",
'<div class="editable" data-table="client_group_facturation" data-column="postal_code" data-id="' +
this.id +
'">' +
this.postalCode +
"</div>",
'<div class="editable" data-table="client_group_facturation" data-column="email" data-id="' +
this.id +
'">' +
this.email +
"</div>",
'<div class="editable" data-table="client_group_facturation" data-column="phone_number" data-id="' +
this.id +
'">' +
this.phoneNumber +
"</div>",
'<div class="editable" data-table="client_group_facturation" data-column="siret_number" data-id="' +
this.id +
'">' +
this.siretNumber +
"</div>",
'<div class="editable" data-table="client_group_facturation" data-column="tva_intracommu" data-id="' +
this.id +
'">' +
this.tvaIntraCommu +
"</div>",
'<div class="selectClientTemplateTypes" data-table="client_group_facturation" data-column="fk_template_type_key" data-id="' +
this.id +
'" data-current="' +
this.templateTypeKey +
'">' +
this.templateTypeKey +
"</div>",
'<div data-modifier="clientGroupFacturation" data-id=' +
this.id +
' data-table="client_group_facturation" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>',
];
return clientGroupFacturationRow;
}
/**
*
* @param {*} clientGroupFacturationDatatable
*
* @param {*} clientGroupFacturationDatatable
*/
static loadClientGroupFacturationDatatable(clientGroupFacturationDatatable) {
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/client/getClientGroupFacturations', true);
oReq.open("PROPFIND", baseUrl + "/client/getClientGroupFacturations", true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){
oReq.onload = function (e) {
if (this.status == 200) {
LoadDT(clientGroupFacturationDatatable, JSON.parse(this.response), ClientGroupFacturation);
}else{
LoadDT(
clientGroupFacturationDatatable,
JSON.parse(this.response),
ClientGroupFacturation
);
} else {
showError(this.response);
}
};
oReq.send();
}
static getClientGroupFacturations(callback){
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/client/getClientGroupFacturations', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){
if (this.status == 200) {
callback(JSON.parse(this.response));
}else{
showError(this.response);
}
};
oReq.send();
}
/**
*
* @param {*} lid
*/
static loadClientGroupFacturationListToSelect(e){
ClientGroupFacturation.getClientGroupFacturations(response => {
var selectElement = document.createElement("select");
selectElement.dataset.current = e.target.dataset.current;
selectElement.dataset.id = e.target.dataset.id;
selectElement.dataset.old = e.target.innerHTML;
selectElement.addEventListener("change", el=>{
if(el.target.value != 0){
updateDB(el.target.parentElement.dataset.table,
el.target.parentElement.dataset.column,
el.target.value,
el.target.parentElement.dataset.id
);
// location.reload();
var parentElement = el.target.parentElement
parentElement.innerHTML = el.target.options[el.target.selectedIndex].text;
parentElement.dataset.current = el.target.value;
}else{
var parentElement = el.target.parentElement
parentElement.innerHTML = el.target.dataset.old
}
});
var option = document.createElement("option");
option.value = 0;
option.text = t('gestion', 'Cancel');
selectElement.appendChild(option);
JSON.parse(response).forEach(myresp => {
var txt = document.createElement("textarea");
txt.innerHTML = myresp.group_facturation_name;
var option = document.createElement("option");
option.value = myresp.id;
option.text = txt.value;
selectElement.appendChild(option);
});
checkSelectPurJs(selectElement);
e.target.innerHTML = ''
e.target.appendChild(selectElement);
});
static getClientGroupFacturations(callback) {
var oReq = new XMLHttpRequest();
oReq.open("PROPFIND", baseUrl + "/client/getClientGroupFacturations", true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function (e) {
if (this.status == 200) {
callback(JSON.parse(this.response));
} else {
showError(this.response);
}
};
oReq.send();
}
/**
*
* @param {*} dt
*
* @param {*} lid
*/
static loadClientGroupFacturationListToSelect(e) {
ClientGroupFacturation.getClientGroupFacturations((response) => {
var selectElement = document.createElement("select");
selectElement.dataset.current = e.target.dataset.current;
selectElement.dataset.id = e.target.dataset.id;
selectElement.dataset.old = e.target.innerHTML;
selectElement.addEventListener("change", (el) => {
if (el.target.value != 0) {
updateDB(
el.target.parentElement.dataset.table,
el.target.parentElement.dataset.column,
el.target.value,
el.target.parentElement.dataset.id
);
// location.reload();
var parentElement = el.target.parentElement;
parentElement.innerHTML =
el.target.options[el.target.selectedIndex].text;
parentElement.dataset.current = el.target.value;
} else {
var parentElement = el.target.parentElement;
parentElement.innerHTML = el.target.dataset.old;
}
});
var option = document.createElement("option");
option.value = 0;
option.text = t("gestion", "Cancel");
selectElement.appendChild(option);
JSON.parse(response).forEach((myresp) => {
var txt = document.createElement("textarea");
txt.innerHTML = myresp.group_facturation_name;
var option = document.createElement("option");
option.value = myresp.id;
option.text = txt.value;
selectElement.appendChild(option);
});
checkSelectPurJs(selectElement);
e.target.innerHTML = "";
e.target.appendChild(selectElement);
});
}
/**
*
* @param {*} dt
*/
static createDefaultClientGroupFacturation(dt) {
var oReq = new XMLHttpRequest();
oReq.open('POST', baseUrl + '/client/createDefaultClientGroupFacturation', true);
oReq.onload = function(e){
oReq.open(
"POST",
baseUrl + "/client/createDefaultClientGroupFacturation",
true
);
oReq.onload = function (e) {
if (this.status == 200) {
showDone()
showDone();
ClientGroupFacturation.loadClientGroupFacturationDatatable(dt);
}else{
} else {
showError(this.response);
}
};
oReq.send();
}
static getClientTemplateTypes(callback) {
var oReq = new XMLHttpRequest();
oReq.open("PROPFIND", baseUrl + "/client/getClientTemplateTypes", true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function (e) {
if (this.status == 200) {
callback(JSON.parse(this.response));
} else {
showError(this.response);
}
};
oReq.send();
}
static loadClientTemplateTypesIntoSelect(e) {
ClientGroupFacturation.getClientTemplateTypes((response) => {
var selectElement = document.createElement("select");
selectElement.dataset.current = e.target.dataset.current;
selectElement.dataset.id = e.target.dataset.id;
selectElement.dataset.old = e.target.innerHTML;
selectElement.addEventListener("change", (el) => {
if (el.target.value != "") {
updateDB(
el.target.parentElement.dataset.table,
el.target.parentElement.dataset.column,
el.target.value,
el.target.parentElement.dataset.id
);
var parentElement = el.target.parentElement;
parentElement.innerHTML =
el.target.options[el.target.selectedIndex].text;
parentElement.dataset.current = el.target.value;
} else {
var parentElement = el.target.parentElement;
parentElement.innerHTML = el.target.dataset.old;
}
});
var option = document.createElement("option");
option.value = "";
option.text = t("gestion", "Cancel");
selectElement.appendChild(option);
JSON.parse(response).forEach((myresp) => {
var txt = document.createElement("textarea");
txt.innerHTML = myresp.template_type_key;
var option = document.createElement("option");
option.value = myresp.template_type_key;
option.text = txt.value;
selectElement.appendChild(option);
});
checkSelectPurJs(selectElement);
e.target.innerHTML = "";
e.target.appendChild(selectElement);
});
}
}

View File

@ -23,6 +23,7 @@
<th><?php p($l->t('Téléphone'));?></th>
<th><?php p($l->t('Siret'));?></th>
<th><?php p($l->t('Tva Intra-communautaire'));?></th>
<th><?php p($l->t('Modèle de facture'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>