show client group on client list , WIP editable select on client

This commit is contained in:
Tiavina 2025-01-06 17:02:30 +03:00
parent af1033ad0e
commit b58c75fdbb
33 changed files with 247 additions and 29 deletions

View File

@ -16,6 +16,7 @@ return [
['name' => 'page#statistique', 'url' => '/statistique', 'verb' => 'GET'],
['name' => 'page#legalnotice', 'url' => '/legalnotice', 'verb' => 'GET'],
['name' => 'page#clientGroupDiscount', 'url' => '/clientGroupDiscount', 'verb' => 'GET'],
['name' => 'page#clientGroups', 'url' => '/clientGroups', 'verb' => 'GET'],
['name' => 'page#france', 'url' => '/legalnotice/france', 'verb' => 'GET'],
@ -128,5 +129,6 @@ return [
//clients discount
['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'],
['name' => 'page#getClientGroups', 'url' => '/getClientGroups', '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

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

View File

@ -379,7 +379,6 @@ class PageController extends Controller {
public function getNavigationLink(){
return array(
"index" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.index"),
"groups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.groups"),
"clientGroups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroups"),
"defunt" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.defunt"),
"devis" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.devis"),
@ -2843,4 +2842,20 @@ class PageController extends Controller {
public function clientGroupDiscount() {
return new TemplateResponse('gestion', 'clientGroupDiscount', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/thanatopracteur.php
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function clientGroups() {
return new TemplateResponse('gestion', 'clientGroup', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink())); // templates/thanatopracteur.php
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getClientGroups() {
return $this->myDb->getClientGroups();
}
}

View File

@ -62,7 +62,30 @@ 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'] : '';
}
}
return json_encode($clients);
}
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 getClientsName(){
@ -2568,12 +2591,6 @@ class Bdd {
return null;
}
public function getClientsGroupedByEntreprise(){
$sql = "SELECT * FROM ".$this->tableprefix."client as client GROUP BY client.entreprise;";
$clients = $this->execSQL($sql,[]);
return $clients;
}
public function getClientGroupDiscounts(){
@ -2597,6 +2614,12 @@ class Bdd {
return $clientGroupDiscounts;
}
public function getClientGroups(){
$sql = "SELECT * FROM ".$this->tableprefix."client_group as client_group;";
$clientGroups = $this->execSQL($sql,[]);
return $clientGroups;
}
}

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 { ClientGroup} from "./objects/clientGroup.mjs"
window.addEventListener("DOMContentLoaded", function () {
globalConfiguration();
ClientGroup.loadClientGroupDatatable(new DataTable(".tabledt",optionDatatable));
});

View File

@ -16,6 +16,7 @@ export class Client {
this.telephone = ((myresp.telephone.length === 0) ? '-' : myresp.telephone);
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);
}
/**
@ -32,6 +33,7 @@ export class Client {
'<div class="editable" data-table="client" data-column="telephone" data-id="' + this.id + '">' + this.telephone + '</div>',
'<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="editable" data-table="client" data-column="clientGroup" data-id="' + this.id + '">' + this.clientGroupName + '</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,63 @@
import { showError } from "@nextcloud/dialogs";
import { baseUrl, cur, LoadDT, showDone } from "../modules/mainFunction.mjs";
export class ClientGroup {
/**
*
* @param myresp instantiate client group object
*/
constructor(myresp) {
this.id = myresp.id;
this.clientGroupName = ((myresp.client_group_name.length === 0) ? '-' : myresp.client_group_name);
}
/**
* Get datatable row for a client group
*/
getDTRow() {
let clientGroupRow = [
'<div>' + this.id + '</div>',
'<div data-id="' + this.id + '">' + this.clientGroupName + '</div>',
'<div data-id=' + this.id + ' data-table="clientGroupDiscount" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
];
return clientGroupRow;
}
/**
*
* @param {*} clientGroupDatatable
*/
static loadClientGroupDatatable(clientGroupDatatable) {
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/getClientGroups', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){
if (this.status == 200) {
LoadDT(clientGroupDatatable, JSON.parse(this.response), ClientGroup);
}else{
showError(this.response);
}
};
oReq.send();
}
/**
*
* @param {*} dt
*/
static newProduct(dt) {
var oReq = new XMLHttpRequest();
oReq.open('POST', baseUrl + '/produit/insert', true);
oReq.onload = function(e){
if (this.status == 200) {
showDone()
Produit.loadProduitDT(dt);
}else{
showError(this.response);
}
};
oReq.send();
}
}

View File

@ -0,0 +1,18 @@
<?php
style('gestion', array('style'));
script('gestion', array('clientGroup.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/clientGroup')); ?>
</div>
</div>
</div>

View File

@ -0,0 +1,25 @@
<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 de clients</span>
</div>
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="addClientGroupDiscount">Ajouter un groupe</button>
</div>
</div>
<table id="clientGroup" class="display tabledt">
<thead>
<tr>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Groupe'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

View File

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

View File

@ -39,6 +39,13 @@
</ul>
</div>
</li>
<li class="app-navigation-entry"><span class="navmarg icon-contacts-dark"></span><a class="a-entry" href="<?php echo($_['url']['clientGroups']); ?>"><?php p($l->t('Groupes'));?></a>
<div class="app-navigation-entry-utils">
<ul>
<li class="app-navigation-entry-utils-counter"><span id="statsclient"><div class="loader"></div></span></li>
</ul>
</div>
</li>
<li class="app-navigation-entry"><span class="navmarg icon-contacts-dark"></span><a href="<?php echo($_['url']['thanatopracteur']); ?>">Thanatopracteurs</a>
<div class="app-navigation-entry-utils">
<ul>
@ -91,7 +98,7 @@
<li class="app-navigation-entry"><span class="navmarg icon-category-integration"></span><a href="<?php echo($_['url']['clientGroupDiscount']); ?>">Remise clients</a>
<div class="app-navigation-entry-utils">
<ul>
<li class="app-navigation-entry-utils-counter"><span id="statsclientgroupdiscount"><div class="loader"></div></span></li>
<li class="app-navigation-entry-utils-counter"><span id="statsclient"><div class="loader"></div></span></li>
</ul>
</div>
</li>

View File

@ -28,6 +28,7 @@ module.exports =
adminSection: './src/js/adminSection.js',
configuration: './src/js/configuration.js',
clientGroupDiscount: './src/js/clientGroupDiscount.js',
clientGroup: './src/js/clientGroup.js',
pdf: './src/js/pdf.js',
},
output: {