finish client group facturation, wip recap group

This commit is contained in:
Tiavina 2025-02-10 16:57:22 +03:00
parent b91373abde
commit eefeb9f0bf
41 changed files with 400 additions and 28 deletions

View File

@ -17,6 +17,7 @@ return [
['name' => 'page#legalnotice', 'url' => '/legalnotice', 'verb' => 'GET'],
['name' => 'page#clientGroupDiscount', 'url' => '/clientGroupDiscount', 'verb' => 'GET'],
['name' => 'page#clientGroups', 'url' => '/clientGroups', 'verb' => 'GET'],
['name' => 'page#clientGroupFacturation', 'url' => '/clientGroupFacturation', 'verb' => 'GET'],
['name' => 'page#france', 'url' => '/legalnotice/france', 'verb' => 'GET'],
@ -166,5 +167,9 @@ return [
['name' => 'page#getClientGroups', 'url' => '/getClientGroups', 'verb' => 'PROPFIND'],
['name' => 'page#createDefaultClientGroup', 'url' => '/clientGroup/createDefaultClientGroup', 'verb' => 'POST'],
['name' => 'page#createDefaultClientGroupDiscount', 'url' => '/clientGroupDiscount/createDefaultClientGroupDiscount', 'verb' => 'POST'],
//client group facturation
['name' => 'page#getClientGroupFacturations', 'url' => '/client/getClientGroupFacturations', 'verb' => 'PROPFIND'],
['name' => 'page#createDefaultClientGroupFacturation', 'url' => '/client/createDefaultClientGroupFacturation', 'verb' => 'POST'],
]
];

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

@ -0,0 +1,46 @@
/*!
* Sizzle CSS Selector Engine v2.3.9
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2022-12-19
*/
/*!
* Toastify js 1.12.0
* https://github.com/apvarun/toastify-js
* @license MIT licensed
*
* Copyright (C) 2018 Varun A P
*/
/*!
* escape-html
* Copyright(c) 2012-2013 TJ Holowaychuk
* Copyright(c) 2015 Andreas Lubbe
* Copyright(c) 2015 Tiancheng "Timothy" Gu
* MIT Licensed
*/
/*!
* jQuery JavaScript Library v3.6.3
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2022-12-20T21:28Z
*/
/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */
/*! DataTables 1.13.2
* ©2008-2023 SpryMedia Ltd - datatables.net/license
*/

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

@ -7,6 +7,7 @@ abstract class BddConstant
const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related";
const DEFAULT_TABLE_PREFIX = "*PREFIX*";
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
public const DEFAULT_CLIENT_GROUP_FACTURATION_NAME = "Nom du groupe";
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Emmanuelle";

View File

@ -1983,6 +1983,7 @@ class PageController extends Controller {
$res['thanatoProductFee'] = $this->orderService->getThanatoProductFeeCount();
$res['clientGroup'] = json_decode($this->myDb->getClientGroupCount())[0]->c;
$res['clientGroupDiscount'] = json_decode($this->myDb->getClientGroupDiscountCount())[0]->c;
$res['clientGroupFacturation'] = json_decode($this->myDb->getClientGroupFacturationCount())[0]->c;
return json_encode($res);
}
@ -2873,4 +2874,29 @@ class PageController extends Controller {
public function createDefaultClientGroupDiscount(){
return $this->myDb->createDefaultClientGroupDiscount();
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function clientGroupFacturation() {
return new TemplateResponse('gestion', 'clientGroupFacturation', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getClientGroupFacturations() {
return $this->myDb->getClientGroupFacturations();
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
*/
public function createDefaultClientGroupFacturation(){
return $this->myDb->createDefaultGroupFacturation();
}
}

View File

@ -86,7 +86,26 @@ class Bdd {
public function getClients($idNextcloud){
$sql = "SELECT * FROM ".$this->tableprefix."client;";
return $this->execSQL($sql, array());
$clients = $this->execSQLNoJsonReturn($sql,[]);
foreach($clients as &$client){
if($client['fk_client_group_id'] == null){
$client['client_group_name'] = '';
}
else{
$clientGroup = $this->getClientGroupById($client['fk_client_group_id']);
$client['client_group_name'] = $clientGroup != null ? $clientGroup['client_group_name'] : '';
}
if($client['fk_client_group_facturation_id'] == null){
$client['client_group_facturation_name'] = '';
}
else{
$clientGroupFacturation = $this->getClientGroupFacturationById($client['fk_client_group_facturation_id']);
$client['client_group_facturation_name'] = $clientGroupFacturation != null ? $clientGroupFacturation['group_facturation_name'] : '';
}
}
return json_encode($clients);
}
public function getClientsByDateDevis($idNextcloud, $date) {
@ -2938,4 +2957,45 @@ class Bdd {
return null;
}
public function getClientGroupFacturations(){
$sql = "SELECT * FROM ".$this->tableprefix."client_group_facturation as client_group_facturation ORDER BY client_group_facturation.id DESC;";
$clientGroupFacturations = $this->execSQL($sql,[]);
return $clientGroupFacturations;
}
public function createDefaultGroupFacturation(){
$sql = "INSERT INTO `".$this->tableprefix."client_group_facturation` (`group_facturation_name`) VALUES (?);";
$this->execSQLNoData($sql, array(BddConstant::DEFAULT_CLIENT_GROUP_FACTURATION_NAME));
return true;
}
public function getClientGroupFacturationCount(){
$sql = "SELECT count(*) as c from ".$this->tableprefix."client_group_facturation;";
return $this->execSQL($sql, array());
}
private function getClientGroupById($clientGroupId){
$sql = "SELECT *
FROM ".$this->tableprefix."client_group as client_group
WHERE client_group.id = ? ;";
$clientGroup = $this->execSQLNoJsonReturn($sql, array($clientGroupId));
if(!empty($clientGroup)){
return $clientGroup[0];
}
return null;
}
public function getClientGroupFacturationById($clientGroupFacturationId){
$sql = "SELECT *
FROM ".$this->tableprefix."client_group_facturation as client_group_facturation
WHERE client_group_facturation.id = ? ;";
$clientGroupFacturation = $this->execSQLNoJsonReturn($sql, array($clientGroupFacturationId));
if(!empty($clientGroupFacturation)){
return $clientGroupFacturation[0];
}
return null;
}
}

View File

@ -57,6 +57,7 @@ class NavigationService {
"thanatoProductFees" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.thanatoProductFee"),
"clientGroups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroups"),
"clientGroupDiscount" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupDiscount"),
"clientGroupFacturation" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupFacturation"),
);
}

View File

@ -0,0 +1,6 @@
create table oc_gestion_client_group_facturation(
id INT PRIMARY KEY AUTO_INCREMENT,
group_facturation_name VARCHAR(255) DEFAULT 'Nom du groupe'
);
alter table oc_gestion_client ADD fk_client_group_facturation_id INT NULL;

View File

@ -0,0 +1,13 @@
import "@nextcloud/dialogs/dist/index.css";
import "datatables.net-dt/css/jquery.dataTables.css";
import "../css/mycss.css";
import DataTable from "datatables.net";
import { globalConfiguration, optionDatatable } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import { ClientGroupFacturation } from "./objects/clientGroupFacturation.mjs";
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
ClientGroupFacturation.loadClientGroupFacturationDatatable(new DataTable(".tabledt",optionDatatable));
});

View File

@ -19,7 +19,7 @@ import { ThanatoEmployeeTypeKey,ThanatoSubcontractorTypeKey } from "../constants
import { ThanatoProductFee } from "../objects/thanatoProductFee.mjs";
import { ClientGroup } from '../objects/clientGroup.mjs';
import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs";
import { ClientGroupFacturation } from "../objects/clientGroupFacturation.mjs";
var choose_folder = t('gestion', 'Choose work folder');
$('body').on('click', '#theFolder', function () {
@ -80,6 +80,9 @@ document.body.addEventListener('click', e => {
else if(e.target.className.includes("selectClientGroupList")){
ClientGroup.loadClientGroupListToSelect(e);
}
else if(e.target.className.includes("selectClientGroupFacturationList")){
ClientGroupFacturation.loadClientGroupFacturationListToSelect(e);
}
else if(e.target.className.includes("selectProductsList")){
Produit.loadProductListToSelect(e);
}
@ -115,6 +118,9 @@ document.body.addEventListener('click', e => {
else if("newClientGroup" === e.target.id){
ClientGroup.createDefaultClientGroup(new DataTable('.tabledt'));
}
else if("newClientGroupFacturation" === e.target.id){
ClientGroupFacturation.createDefaultClientGroupFacturation(new DataTable('.tabledt'));
}
else if("newClientGroupDiscount" === e.target.id){
ClientGroupDiscount.createDefaultClientGroupDiscount(new DataTable('.tabledt'));
} else if("saveIk" == e.target.id) {
@ -251,6 +257,7 @@ $('body').on('click', '.deleteItem', function () {
if (modifier === "thanatoProductFee") { ThanatoProductFee.loadThanatoProductFeeDatatable(dt);}
if (modifier === "clientGroup") { ClientGroup.loadClientGroupDatatable(dt); }
if (modifier === "clientGroupDiscount") { ClientGroupDiscount.loadClientGroupDiscountDatatable(dt); }
if (modifier === "clientGroupFacturation") { ClientGroupFacturation.loadClientGroupFacturationDatatable(dt); }
});
$('body').on('change', '.listClient,.listDevis', function () {

View File

@ -83,6 +83,7 @@ export function getStats() {
$("#orderStat").text(res.order);
$("#clientGroupStat").text(res.clientGroup);
$("#clientGroupDiscountStat").text(res.clientGroupDiscount);
$("#clientGroupFacturationStat").text(res.clientGroupFacturation);
}).fail(function (response, code) {
showError(response);
});

View File

@ -18,11 +18,18 @@ export class Client {
this.mail = ((myresp.mail.length === 0) ? '-' : myresp.mail);
this.adresse = ((myresp.adresse.length === 0) ? '-' : myresp.adresse);
this.clientGroupName = ((myresp.client_group_name.length === 0) ? '-' : myresp.client_group_name);
this.clientGroupFacturationName = ((myresp.client_group_facturation_name.length === 0) ? '-' : myresp.client_group_facturation_name);
let clientGroupId = 0;
if(myresp.fk_client_group_id != null && myresp.fk_client_group_id.length > 0){
clientGroupId = myresp.fk_client_group_id
}
this.clientGroupId = clientGroupId;
let clientGroupFacturationId = 0;
if(myresp.fk_client_group_facturation_id != null && myresp.fk_client_group_facturation_id.length > 0){
clientGroupFacturationId = myresp.fk_client_group_facturation_id
}
this.clientGroupFacturationId = clientGroupFacturationId;
}
/**
@ -40,6 +47,7 @@ export class Client {
'<div class="editable" data-table="client" data-column="mail" data-id="' + this.id + '">' + this.mail + '</div>',
'<div class="editable" data-table="client" data-column="adresse" data-id="' + this.id + '">' + this.adresse + '</div>',
'<div class="selectClientGroupList" data-table="client" data-column="fk_client_group_id" data-id="' + this.id + '" data-current="' + this.clientGroupId + '">' + this.clientGroupName + '</div>',
'<div class="selectClientGroupFacturationList" data-table="client" data-column="fk_client_group_facturation_id" data-id="' + this.id + '" data-current="' + this.clientGroupFacturationId + '">' + this.clientGroupFacturationName + '</div>',
'<center><div data-modifier="client" data-id=' + this.id + ' data-table="client" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div></center>'
];
return myrow;

View File

@ -0,0 +1,144 @@
import { showError } from "@nextcloud/dialogs";
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 : '-';
}
/**
* Get datatable row for a client group facturation
*/
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>'
];
return clientGroupFacturationRow;
}
/**
*
* @param {*} clientGroupFacturationDatatable
*/
static loadClientGroupFacturationDatatable(clientGroupFacturationDatatable) {
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) {
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);
});
}
/**
*
* @param {*} dt
*/
static createDefaultClientGroupFacturation(dt) {
var oReq = new XMLHttpRequest();
oReq.open('POST', baseUrl + '/client/createDefaultClientGroupFacturation', true);
oReq.onload = function(e){
if (this.status == 200) {
showDone()
ClientGroupFacturation.loadClientGroupFacturationDatatable(dt);
}else{
showError(this.response);
}
};
oReq.send();
}
}

View File

@ -0,0 +1,18 @@
<?php
style('gestion', array('style'));
script('gestion', array('clientGroupFacturation.app', '814.app', '856.app'));
?>
<div id="app">
<div id="app-navigation">
<?php print_unescaped($this->inc('navigation/index')); ?>
<?php print_unescaped($this->inc('settings/index')); ?>
</div>
<div id="app-content">
<div id="app-content-wrapper">
<?php print_unescaped($this->inc('content/changelog')); ?>
<?php print_unescaped($this->inc('content/clientGroupFacturation')); ?>
</div>
</div>
</div>

View File

@ -0,0 +1,32 @@
<div id="contentTable">
<div class="breadcrumb" data-html2canvas-ignore>
<div class="crumb svg crumbhome">
<a href="<?php echo($_['url']['index']); ?>" class="icon-home"></a>
<span style="display: none;"></span>
</div>
<div class="crumb svg crumbhome">
<span>Groupe facturation de clients</span>
</div>
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="newClientGroupFacturation">Ajouter un groupe de facturation</button>
</div>
</div>
<table id="clientGroupFacturation" class="display tabledt">
<thead>
<tr>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Groupe'));?></th>
<th><?php p($l->t('Adresse'));?></th>
<th><?php p($l->t('Ville'));?></th>
<th><?php p($l->t('Code postal'));?></th>
<th><?php p($l->t('Email'));?></th>
<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('Actions'));?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

View File

@ -32,6 +32,7 @@
<th><?php p($l->t('Email'));?></th>
<th><?php p($l->t('Address'));?></th>
<th><?php p($l->t('Groupes tarifaires'));?></th>
<th><?php p($l->t('Groupes facturations'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>

View File

@ -97,13 +97,13 @@
</li>
<li class="app-navigation-entry-submenu">
<span class="navmarg icon-category-integration"></span>
<a class="a-entry-submenu" href="<?php echo($_['url']['produit']); ?>">
<a class="a-entry-submenu" href="<?php echo($_['url']['clientGroupFacturation']); ?>">
<?php p($l->t('Groupe clients'));?>
</a>
<div class="app-navigation-entry-utils-submenu">
<ul>
<li class="app-navigation-entry-utils-counter">
<span>5</span>
<span id="clientGroupFacturationStat"><div class="loader"></div></span>
</li>
</ul>
</div>

View File

@ -31,7 +31,8 @@ module.exports =
order: './src/js/order.js',
thanatoProductFee: './src/js/thanatoProductFee.js',
clientGroupDiscount: './src/js/clientGroupDiscount.js',
clientGroup: './src/js/clientGroup.js'
clientGroup: './src/js/clientGroup.js',
clientGroupFacturation : './src/js/clientGroupFacturation.js'
},
output: {
filename: '../js/[name].app.js',