groupe facturation features, WIP sous menu on group

This commit is contained in:
Tiavina 2025-01-16 17:45:05 +03:00
parent 1941e9af62
commit 64c80da5b5
43 changed files with 649 additions and 81 deletions

View File

@ -17,6 +17,7 @@ return [
['name' => 'page#legalnotice', 'url' => '/legalnotice', 'verb' => 'GET'], ['name' => 'page#legalnotice', 'url' => '/legalnotice', 'verb' => 'GET'],
['name' => 'page#clientGroupDiscount', 'url' => '/clientGroupDiscount', 'verb' => 'GET'], ['name' => 'page#clientGroupDiscount', 'url' => '/clientGroupDiscount', 'verb' => 'GET'],
['name' => 'page#clientGroups', 'url' => '/clientGroups', 'verb' => 'GET'], ['name' => 'page#clientGroups', 'url' => '/clientGroups', 'verb' => 'GET'],
['name' => 'page#clientGroupFacturation', 'url' => '/clientGroupFacturation', 'verb' => 'GET'],
['name' => 'page#france', 'url' => '/legalnotice/france', 'verb' => 'GET'], ['name' => 'page#france', 'url' => '/legalnotice/france', 'verb' => 'GET'],
@ -127,7 +128,9 @@ return [
['name' => 'page#addDevisNumberColumn', 'url' => '/addDevisNumberColumn', 'verb' => 'POST'], ['name' => 'page#addDevisNumberColumn', 'url' => '/addDevisNumberColumn', 'verb' => 'POST'],
['name' => 'page#addFactureNumberColumn', 'url' => '/addFactureNumberColumn', 'verb' => 'POST'], ['name' => 'page#addFactureNumberColumn', 'url' => '/addFactureNumberColumn', 'verb' => 'POST'],
['name' => 'page#addClientGroupDiscountFeatureTables', 'url' => '/addClientGroupDiscountFeatureTables', 'verb' => 'POST'], ['name' => 'page#addClientGroupDiscountFeatureTables', 'url' => '/addClientGroupDiscountFeatureTables', 'verb' => 'POST'],
['name' => 'page#addClientGroupFacturationFeatureTables', 'url' => '/addClientGroupFacturationFeatureTables', 'verb' => 'POST'],
//clients discount //clients discount
['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'], ['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'],
['name' => 'page#getClientGroups', 'url' => '/getClientGroups', 'verb' => 'PROPFIND'], ['name' => 'page#getClientGroups', 'url' => '/getClientGroups', 'verb' => 'PROPFIND'],
@ -150,5 +153,9 @@ return [
//devis pdf //devis pdf
['name' => 'page#exportDevisToPdf', 'url' => '/devis/exportDevisToPdf', 'verb' => 'POST'], ['name' => 'page#exportDevisToPdf', 'url' => '/devis/exportDevisToPdf', 'verb' => 'POST'],
['name' => 'page#exportDevisByClientAndMonthYearToPdf', 'url' => '/devis/exportDevisByClientAndMonthYearToPdf', 'verb' => 'POST'], ['name' => 'page#exportDevisByClientAndMonthYearToPdf', 'url' => '/devis/exportDevisByClientAndMonthYearToPdf', '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

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

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace OCA\Gestion\Constants;
abstract class MultipleFactureTypeConstant
{
const CLIENT_FILTER_TYPE = "client";
const GROUP_FILTER_TYPE = "group";
}

View File

@ -19,6 +19,7 @@ use \Datetime;
use \DatetimeImmutable; use \DatetimeImmutable;
use \IntlDateFormatter; use \IntlDateFormatter;
use \FPDF; use \FPDF;
use OCA\Gestion\Constants\MultipleFactureTypeConstant;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Service\Certificate\CertificateService; use OCA\Gestion\Service\Certificate\CertificateService;
use OCA\Gestion\Service\Devis\Pdf\DevisPdfService; use OCA\Gestion\Service\Devis\Pdf\DevisPdfService;
@ -368,7 +369,7 @@ class PageController extends Controller {
$produits = json_decode($this->myDb->getListProduit($facture->id_devis, $this->idNextcloud)); $produits = json_decode($this->myDb->getListProduit($facture->id_devis, $this->idNextcloud));
$facture->dproduits = $produits; $facture->dproduits = $produits;
} }
$clients = json_decode($this->myDb->getClientsGroupedByClientEntreprise()); $clients = json_decode($this->myDb->getClientsAndClientGroupFacturations());
return new TemplateResponse('gestion', 'apercustoutesfactures', array( 'groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, return new TemplateResponse('gestion', 'apercustoutesfactures', array( 'groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud,
'configuration'=> $this->getConfiguration(), 'configuration'=> $this->getConfiguration(),
'factures'=> $factures, 'factures'=> $factures,
@ -395,6 +396,7 @@ class PageController extends Controller {
return array( return array(
"index" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.index"), "index" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.index"),
"clientGroups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroups"), "clientGroups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroups"),
"clientGroupFacturation" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupFacturation"),
"defunt" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.defunt"), "defunt" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.defunt"),
"devis" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.devis"), "devis" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.devis"),
"thanatopracteur" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.thanatopracteur"), "thanatopracteur" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.thanatopracteur"),
@ -746,7 +748,7 @@ class PageController extends Controller {
} catch(\OCP\Files\NotPermittedException $e) { } } catch(\OCP\Files\NotPermittedException $e) { }
} }
private function generer_document_comptable_client($date, $clientEntreprise) { private function generer_document_comptable_client($date, $filter,$filterType) {
$current_config = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); $current_config = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
try { try {
try { try {
@ -759,7 +761,18 @@ class PageController extends Controller {
} }
$data_factures = array(); $data_factures = array();
// $factures = json_decode($this->myDb->getCurrentMonthFactures_byClient($this->idNextcloud, $date, $idclient)); // $factures = json_decode($this->myDb->getCurrentMonthFactures_byClient($this->idNextcloud, $date, $idclient));
$factures = json_decode($this->myDb->getClientFacturesByClientEntrepriseAndDate($clientEntreprise, $date)); if($filterType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){
$factures = json_decode($this->myDb->getClientFacturesByClientIdAndDate(
clientId: $filter,
date: $date
));
}
else{
$factures = json_decode($this->myDb->getClientFacturesByClientGroupFacturationIdAndDate(
clientGroupFacturationId: $filter,
date: $date
));
}
$factures = array_filter($factures, callback: function($facture) {return $facture->id_client != NULL; }); $factures = array_filter($factures, callback: function($facture) {return $facture->id_client != NULL; });
foreach ($factures as $key => $facture) { foreach ($factures as $key => $facture) {
$facture_temp = array( $facture_temp = array(
@ -1890,22 +1903,16 @@ class PageController extends Controller {
/** /**
* @NoAdminRequired * @NoAdminRequired
* @NoCSRFRequired * @NoCSRFRequired
* @param string $clientEntreprise * @param string $filter
* @param string $annee * @param string $year
* @param string $mois * @param string $month
* @param string $filterType
*/ */
public function saveDocumentRecap($clientEntreprise, $annee, $mois) { public function saveDocumentRecap($filter, $year, $month, $filterType = MultipleFactureTypeConstant::CLIENT_FILTER_TYPE) {
$dateString = '15-'.$mois.'-'.$annee; $dateString = '15-'.$month.'-'.$year;
$date_temp = DateTime::createFromFormat('d-m-Y', $dateString); $date_temp = DateTime::createFromFormat('d-m-Y', $dateString);
$date = $date_temp->format('d-m-Y'); $date = $date_temp->format('d-m-Y');
$this->generer_document_comptable_client($date, $filter,$filterType);
// if(intval($idclient)==0) {
// //generer recap OGF
// $this->generer_recap_ogf($date);
// } else {
// $this->generer_document_comptable_client($date, intval($idclient));
// }
$this->generer_document_comptable_client($date, $clientEntreprise);
} }
/** /**
@ -2102,6 +2109,7 @@ class PageController extends Controller {
$res['bibliotheque'] = json_decode($this->myDb->numberBibliotheque($this->idNextcloud))[0]->c; $res['bibliotheque'] = json_decode($this->myDb->numberBibliotheque($this->idNextcloud))[0]->c;
$res['clientGroup'] = json_decode($this->myDb->getClientGroupCount())[0]->c; $res['clientGroup'] = json_decode($this->myDb->getClientGroupCount())[0]->c;
$res['clientGroupDiscount'] = json_decode($this->myDb->getClientGroupDiscountCount())[0]->c; $res['clientGroupDiscount'] = json_decode($this->myDb->getClientGroupDiscountCount())[0]->c;
$res['clientGroupFacturation'] = json_decode($this->myDb->getClientGroupFacturationCount())[0]->c;
return json_encode($res); return json_encode($res);
} }
@ -2804,15 +2812,21 @@ class PageController extends Controller {
/** /**
* @NoAdminRequired * @NoAdminRequired
* @NoCSRFRequired * @NoCSRFRequired
* @param string $clientEntreprise * @param string $filter
* @param string $month * @param string $month
* @param string $year * @param string $year
* @param string $filterType // client|group
* *
*/ */
public function exportFactureByClientAndMonthYearToPdf($clientEntreprise,$month,$year){ public function exportFactureByClientAndMonthYearToPdf($filter,$month,$year,$filterType="client"){
try{ try{
$factureFilename = $this->invoicePdfService->generateMultipleInvoicePdfByClientAndMonthYear($clientEntreprise,$month,$year,$this->idNextcloud); $factureFilename = $this->invoicePdfService->generateMultipleInvoicePdfByClientAndMonthYear(
filter: $filter,
month: $month,
year: $year,
idNextCloud: $this->idNextcloud,
filterType: $filterType);
return $factureFilename; return $factureFilename;
} }
catch(\OCP\Files\NotFoundException $e) { } catch(\OCP\Files\NotFoundException $e) { }
@ -3019,4 +3033,43 @@ class PageController extends Controller {
catch(\OCP\Files\NotFoundException $e) { } catch(\OCP\Files\NotFoundException $e) { }
} }
/**
* @NoAdminRequired
* @NoCSRFRequired
*
*/
public function addClientGroupFacturationFeatureTables(){
try{
$this->myDb->addClientGroupFacturationFeatureTables();
return true;
}
catch(\OCP\Files\NotFoundException $e) { }
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function clientGroupFacturation() {
return new TemplateResponse('gestion', 'clientGroupFacturation', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->getNavigationLink()));
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getClientGroupFacturations() {
return $this->myDb->getClientGroupFacturations();
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
*/
public function createDefaultClientGroupFacturation(){
return $this->myDb->createDefaultClientGroup();
}
} }

View File

@ -7,6 +7,7 @@ use OCP\IL10N;
use \Datetime; use \Datetime;
use OCA\Gestion\Constants\BddConstant; use OCA\Gestion\Constants\BddConstant;
use OCA\Gestion\Constants\DevisMentionConstant; use OCA\Gestion\Constants\DevisMentionConstant;
use OCA\Gestion\Constants\MultipleFactureTypeConstant;
use OCA\Gestion\Constants\ProductConstant; use OCA\Gestion\Constants\ProductConstant;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -18,6 +19,7 @@ class Bdd {
public const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related"; public const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related";
public const CALENDAR_TABLE_PREFIX = "*PREFIX*"; public const CALENDAR_TABLE_PREFIX = "*PREFIX*";
public const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe"; public const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
public const DEFAULT_CLIENT_GROUP_FACTURATION_NAME = "Nom du groupe";
private IDbConnection $pdo; private IDbConnection $pdo;
private array $whiteColumn; private array $whiteColumn;
private array $whiteTable; private array $whiteTable;
@ -38,10 +40,12 @@ class Bdd {
"drainage", "drainage_qte", "drainage_etat", "ponction", "ponction_qte", "cavite", "cavite_qte", "desinfection", "lavage", "drainage", "drainage_qte", "drainage_etat", "ponction", "ponction_qte", "cavite", "cavite_qte", "desinfection", "lavage",
"rasage", "presentation_cosmetique", "presentation_sur", "hypodermiques", "hypodermiques_sur", "local", "local_sur", "contenu", "rasage", "presentation_cosmetique", "presentation_sur", "hypodermiques", "hypodermiques_sur", "local", "local_sur", "contenu",
"commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit", "commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit",
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name"); "fk_client_group_id","fk_produit_id","ht_amount","client_group_name",
"fk_client_group_facturation_id","group_facturation_name");
$this->whiteTable = array( $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", "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"); "client_group_discount","client_group",
"client_group_facturation");
$this->tableprefix = '*PREFIX*' ."gestion_"; $this->tableprefix = '*PREFIX*' ."gestion_";
$this->pdo = $db; $this->pdo = $db;
$this->l = $l; $this->l = $l;
@ -78,6 +82,14 @@ class Bdd {
$clientGroup = $this->getClientGroupById($client['fk_client_group_id']); $clientGroup = $this->getClientGroupById($client['fk_client_group_id']);
$client['client_group_name'] = $clientGroup != null ? $clientGroup['client_group_name'] : ''; $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); return json_encode($clients);
} }
@ -300,6 +312,29 @@ class Bdd {
return $this->execSQL($sql, array()); return $this->execSQL($sql, array());
} }
private function getClientsWithClientGroupDetails(){
$sql = "SELECT * FROM ".$this->tableprefix."client as client;";
$clientsGroupedByClientEntreprise = $this->execSQLNoJsonReturn($sql,[]);
foreach($clientsGroupedByClientEntreprise 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'] : '';
}
$client['client_type'] = MultipleFactureTypeConstant::CLIENT_FILTER_TYPE;
}
return $clientsGroupedByClientEntreprise;
}
public function getClientsAndClientGroupFacturations(){
$clients = $this->getClientsWithClientGroupDetails();
$clientGroupFacturations = $this->getClientGroupFacturationsWithType();
$result = [...$clientGroupFacturations,...$clients];
return json_encode($result);
}
public function getClientsGroupedByClientEntreprise(){ public function getClientsGroupedByClientEntreprise(){
$sql = "SELECT * FROM ".$this->tableprefix."client as client GROUP BY client.entreprise;"; $sql = "SELECT * FROM ".$this->tableprefix."client as client GROUP BY client.entreprise;";
$clientsGroupedByClientEntreprise = $this->execSQLNoJsonReturn($sql,[]); $clientsGroupedByClientEntreprise = $this->execSQLNoJsonReturn($sql,[]);
@ -319,9 +354,11 @@ class Bdd {
$sql = "SELECT ".$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, " $sql = "SELECT ".$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, "
.$this->tableprefix."devis.num as dnum, ".$this->tableprefix."devis.comment as dcomment, date_paiement, type_paiement, id_devis, entreprise, " .$this->tableprefix."devis.num as dnum, ".$this->tableprefix."devis.comment as dcomment, date_paiement, type_paiement, id_devis, entreprise, "
.$this->tableprefix."facture.version, status_paiement," .$this->tableprefix."facture.version, status_paiement,"
.$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, ".$this->tableprefix."client.id as id_cli, ".$this->tableprefix."client.entreprise as client_entreprise, " .$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, "
.$this->tableprefix."client.adresse as adresse_cli,".$this->tableprefix."client.mail as mail_cli,".$this->tableprefix."client.telephone as telephone_cli,".$this->tableprefix."client.legal_one as legalone_cli," .$this->tableprefix."client.id as id_cli, ".$this->tableprefix."client.entreprise as client_entreprise, ".$this->tableprefix."client.fk_client_group_facturation_id as fk_client_group_facturation_id, "
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt," .$this->tableprefix."client.adresse as adresse_cli,".$this->tableprefix."client.mail as mail_cli, "
.$this->tableprefix."client.telephone as telephone_cli,".$this->tableprefix."client.legal_one as legalone_cli, "
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt, "
.$this->tableprefix."lieu.id as lid, ".$this->tableprefix."lieu.nom as lieu,".$this->tableprefix."lieu.adresse as adresse_soin,".$this->tableprefix."devis.id_lieu .$this->tableprefix."lieu.id as lid, ".$this->tableprefix."lieu.nom as lieu,".$this->tableprefix."lieu.adresse as adresse_soin,".$this->tableprefix."devis.id_lieu
FROM (".$this->tableprefix."facture FROM (".$this->tableprefix."facture
LEFT JOIN ".$this->tableprefix."devis on ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."devis.id) LEFT JOIN ".$this->tableprefix."devis on ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."devis.id)
@ -343,7 +380,8 @@ class Bdd {
return json_encode($facturesList); return json_encode($facturesList);
} }
public function getClientFacturesByClientEntrepriseAndDate($clientEntreprise,$date){ private function getClientFacturesByClientIdListAndDate($clientIdList,$date) {
$clientIdsSqlPlaceholder = implode(',', array_fill(0, count($clientIdList), '?'));
$sql = "SELECT YEAR(".$this->tableprefix."facture.date_paiement) AS year, MONTH(".$this->tableprefix."facture.date_paiement) AS month," $sql = "SELECT YEAR(".$this->tableprefix."facture.date_paiement) AS year, MONTH(".$this->tableprefix."facture.date_paiement) AS month,"
.$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, " .$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, "
.$this->tableprefix."devis.num as dnum,".$this->tableprefix."devis.version as adresse_devis,".$this->tableprefix."devis.comment as numero_commande, " .$this->tableprefix."devis.num as dnum,".$this->tableprefix."devis.version as adresse_devis,".$this->tableprefix."devis.comment as numero_commande, "
@ -359,8 +397,39 @@ class Bdd {
LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id
LEFT JOIN ".$this->tableprefix."defunt on ".$this->tableprefix."devis.id_defunt = ".$this->tableprefix."defunt.id LEFT JOIN ".$this->tableprefix."defunt on ".$this->tableprefix."devis.id_defunt = ".$this->tableprefix."defunt.id
WHERE YEAR(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[2]." AND MONTH(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[1]." WHERE YEAR(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[2]." AND MONTH(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[1]."
AND ".$this->tableprefix."client.entreprise = ? ORDER BY year DESC, month DESC;"; AND ".$this->tableprefix."client.id IN($clientIdsSqlPlaceholder) ORDER BY year DESC, month DESC;";
$result = $this->execSQL($sql, array($clientEntreprise)); $result = $this->execSQL(
sql: $sql,
conditions: $clientIdList );
return $result;
}
public function getClientFacturesByClientGroupFacturationIdAndDate($clientGroupFacturationId,$date){
$clientIds = $this->getClientIdsByClientGroupFacturationId($clientGroupFacturationId);
if(empty($clientIds)){
return [];
}
return $this->getClientFacturesByClientIdListAndDate($clientIds,$date);
}
public function getClientFacturesByClientIdAndDate($clientId,$date){
$sql = "SELECT YEAR(".$this->tableprefix."facture.date_paiement) AS year, MONTH(".$this->tableprefix."facture.date_paiement) AS month,"
.$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, "
.$this->tableprefix."devis.num as dnum,".$this->tableprefix."devis.version as adresse_devis,".$this->tableprefix."devis.comment as numero_commande, "
.$this->tableprefix."client.adresse as adresse_client, ".$this->tableprefix."devis.date as date_soin, "
.$this->tableprefix."client.mail as mail_client, ".$this->tableprefix."client.entreprise as client_entreprise, "
.$this->tableprefix."devis.id_client as id_client, date_paiement, type_paiement, id_devis, ".$this->tableprefix."client.nom as nom, prenom, entreprise, "
.$this->tableprefix."lieu.id as lid, ".$this->tableprefix."lieu.nom as lieu,".$this->tableprefix."lieu.adresse as adresse_soin,"
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt,"
.$this->tableprefix."facture.version, status_paiement
FROM (".$this->tableprefix."facture
LEFT JOIN ".$this->tableprefix."devis on ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."devis.id)
LEFT JOIN ".$this->tableprefix."lieu on ".$this->tableprefix."devis.id_lieu = ".$this->tableprefix."lieu.id
LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id
LEFT JOIN ".$this->tableprefix."defunt on ".$this->tableprefix."devis.id_defunt = ".$this->tableprefix."defunt.id
WHERE YEAR(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[2]." AND MONTH(".$this->tableprefix."facture.date_paiement) = ".explode('-', $date)[1]."
AND ".$this->tableprefix."client.id = ? ORDER BY year DESC, month DESC;";
$result = $this->execSQL($sql, array($clientId));
return $result; return $result;
} }
@ -2508,8 +2577,22 @@ class Bdd {
return $devisList; return $devisList;
} }
public function getInvoicePdfDataByClientAndMonthYear($clientEntreprise,$month,$year,$configuration){ public function getInvoicePdfDataByClientAndMonthYear($filter,$month,$year,$configuration,$filterType){
$invoices = $this->getInvoiceByClientAndMonthYear($clientEntreprise,$month,$year); $isFilterByClient = $filterType === MultipleFactureTypeConstant::CLIENT_FILTER_TYPE;
if($isFilterByClient){
$invoices = $this->getInvoiceByClientAndMonthYear(
clientId: $filter,
month: $month,
year: $year
);
}
else{
$invoices = $this->getInvoiceByClientGroupFacturationAndMonthYear(
clientGroupFacturationId: $filter,
month: $month,
year: $year
);
}
$firstClient = $this->getFirstClient(); $firstClient = $this->getFirstClient();
foreach($invoices as &$invoice){ foreach($invoices as &$invoice){
$invoice["siret"] = $firstClient != null ? $firstClient['legal_one'] : ''; $invoice["siret"] = $firstClient != null ? $firstClient['legal_one'] : '';
@ -2528,7 +2611,27 @@ class Bdd {
return $invoices; return $invoices;
} }
private function getInvoiceByClientAndMonthYear($clientEntreprise,$month,$year){ private function getClientIdsByClientGroupFacturationId($clientGroupFacturationId){
$sql = "SELECT client.id
FROM ".$this->tableprefix."client as client
WHERE client.fk_client_group_facturation_id = ? ;";
$clientIds = [];
$clients = $this->execSQLNoJsonReturn(
$sql,
[$clientGroupFacturationId]);
if(!empty($clients)){
foreach($clients as $client){
$clientIds[] = $client["id"];
}
}
return $clientIds;
}
private function getInvoiceByClientIdsListAndMonthYear($clientIds,$month,$year){
$clientIdsSqlPlaceholder = implode(',', array_fill(0, count($clientIds), '?'));
$sql = "SELECT $sql = "SELECT
facture.id, facture.id,
facture.date, facture.date,
@ -2547,17 +2650,69 @@ class Bdd {
lieu.nom as lieu_nom, lieu.nom as lieu_nom,
lieu.adresse as lieu_adresse, lieu.adresse as lieu_adresse,
thanato.nom as thanato_nom, thanato.nom as thanato_nom,
thanato.prenom as thanato_prenom thanato.prenom as thanato_prenom,
'group' as facture_type
FROM ".$this->tableprefix."facture as facture FROM ".$this->tableprefix."facture as facture
LEFT JOIN ".$this->tableprefix."devis as devis on facture.id_devis = devis.id LEFT JOIN ".$this->tableprefix."devis as devis on facture.id_devis = devis.id
LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id
LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id
LEFT JOIN ".$this->tableprefix."lieu as lieu on devis.id_lieu = lieu.id LEFT JOIN ".$this->tableprefix."lieu as lieu on devis.id_lieu = lieu.id
LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id
WHERE client.entreprise = ? AND WHERE client.id IN ($clientIdsSqlPlaceholder) AND
YEAR(facture.date_paiement) = ?"; YEAR(facture.date_paiement) = ?";
$conditions = [$clientEntreprise,$year]; $conditions = array_merge($clientIds,[$year]);
if($month != 0){
$conditions[] = $month;
$sql .= " AND MONTH(facture.date_paiement) = ?";
}
$sql .= ";";
$factures = $this->execSQLNoJsonReturn(
$sql,
$conditions);
return $factures;
}
private function getInvoiceByClientGroupFacturationAndMonthYear($clientGroupFacturationId,$month, $year){
$clientIdsInsideClientFacturationGroup = $this->getClientIdsByClientGroupFacturationId($clientGroupFacturationId);
if(empty($clientIdsInsideClientFacturationGroup)){
return [];
}
return $this->getInvoiceByClientIdsListAndMonthYear($clientIdsInsideClientFacturationGroup,$month,$year);
}
private function getInvoiceByClientAndMonthYear($clientId,$month,$year){
$sql = "SELECT
facture.id,
facture.date,
facture.date_paiement,
facture.num,
devis.id as devis_id,
devis.date as devis_date,
devis.num as calendar_uuid,
devis.comment as devis_comment,
devis.id_client as devis_id_client,
client.nom as client_nom,
client.entreprise as client_entreprise,
client.adresse as client_adresse,
defunt.nom as defunt_nom,
defunt.sexe as defunt_sexe,
lieu.nom as lieu_nom,
lieu.adresse as lieu_adresse,
thanato.nom as thanato_nom,
thanato.prenom as thanato_prenom,
'client' as facture_type
FROM ".$this->tableprefix."facture as facture
LEFT JOIN ".$this->tableprefix."devis as devis on facture.id_devis = devis.id
LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id
LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id
LEFT JOIN ".$this->tableprefix."lieu as lieu on devis.id_lieu = lieu.id
LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id
WHERE client.id = ? AND
YEAR(facture.date_paiement) = ?";
$conditions = [$clientId,$year];
if($month != 0){ if($month != 0){
$conditions[] = $month; $conditions[] = $month;
$sql .= " AND MONTH(facture.date_paiement) = ?"; $sql .= " AND MONTH(facture.date_paiement) = ?";
@ -3194,4 +3349,59 @@ class Bdd {
} }
public function addClientGroupFacturationFeatureTables(){
$createTableClientGroupSQL = "CREATE TABLE oc_gestion_client_group_facturation (
id INT PRIMARY KEY AUTO_INCREMENT,
group_facturation_name VARCHAR(255) DEFAULT ''
);";
$this->execSQLNoData($createTableClientGroupSQL,[]);
$addColumnFkClientGroupFacturationIdIntoClientTableSQL= "ALTER TABLE oc_gestion_client
ADD fk_client_group_facturation_id INT NULL;";
$this->execSQLNoData($addColumnFkClientGroupFacturationIdIntoClientTableSQL,[]);
return true;
}
private function getClientGroupFacturationsWithType(){
$sql = "SELECT
client_group_facturation.id as id,
client_group_facturation.group_facturation_name as nom,
'group' as client_type
FROM ".$this->tableprefix."client_group_facturation as client_group_facturation ORDER BY client_group_facturation.id DESC;";
$clientGroupFacturations = $this->execSQLNoJsonReturn($sql,[]);
return $clientGroupFacturations;
}
public function getClientGroupFacturations(){
$sql = "SELECT * as client_type 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(self::DEFAULT_CLIENT_GROUP_FACTURATION_NAME));
return true;
}
private 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;
}
public function getClientGroupFacturationCount(){
$sql = "SELECT count(*) as c from ".$this->tableprefix."client_group_facturation;";
return $this->execSQL($sql, array());
}
} }

View File

@ -28,6 +28,7 @@ namespace OCA\Gestion\Service;
use DateTime; use DateTime;
use \FPDF; use \FPDF;
use OCA\Gestion\Constants\MultipleFactureTypeConstant;
use OCA\Gestion\Helpers\DateHelpers; use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers; use OCA\Gestion\Helpers\PriceHelpers;
@ -74,7 +75,13 @@ class InvoicePdfHandler extends FPDF {
public function GetMultipleInvoiceFilename($month,$year){ public function GetMultipleInvoiceFilename($month,$year){
$filename = ""; $filename = "";
foreach($this->multipleFactureData as $factureData){ foreach($this->multipleFactureData as $factureData){
$filename = strtoupper($factureData["client_entreprise"]); $factureType = $factureData["facture_type"];
if($factureType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){
$filename = strtoupper($factureData["client_entreprise"]);
}
else{
$filename = 'GROUP_'.strtoupper($factureData["client_entreprise"]);
}
$filename .= $month != 0 ? '_'.DateHelpers::GetMonthPlainString($month) :''; $filename .= $month != 0 ? '_'.DateHelpers::GetMonthPlainString($month) :'';
$filename .= "_".$year; $filename .= "_".$year;
break; break;

View File

@ -118,12 +118,12 @@ class InvoicePdfService {
} }
} }
public function generateMultipleInvoicePdfByClientAndMonthYear($clientEntreprise,$month,$year,$idNextCloud){ public function generateMultipleInvoicePdfByClientAndMonthYear($filter,$month,$year,$idNextCloud,$filterType){
$storage = $this->rootFolder->getUserFolder($idNextCloud); $storage = $this->rootFolder->getUserFolder($idNextCloud);
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); $configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
$currentConfig = $configs[0]; $currentConfig = $configs[0];
$logo = $this->getLogo(); $logo = $this->getLogo();
$invoiceData = $this->gestionBdd->getInvoicePdfDataByClientAndMonthYear($clientEntreprise,$month,$year,$currentConfig); $invoiceData = $this->gestionBdd->getInvoicePdfDataByClientAndMonthYear($filter,$month,$year,$currentConfig,$filterType);
if(empty($invoiceData)){ if(empty($invoiceData)){
return null; return null;
} }

View File

@ -18,17 +18,17 @@ window.addEventListener("DOMContentLoaded", function () {
var documentRecap = document.getElementById("documentrecap"); var documentRecap = document.getElementById("documentrecap");
documentRecap.addEventListener("click", async ()=> { documentRecap.addEventListener("click", async ()=> {
// Get the URL parameters
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const filter = urlParams.get('cli');
const year = urlParams.get('annee');
const month = urlParams.get('mois');
const filterType = urlParams.get('filterType') ?? 'client';
// Access specific parameter values
const clientEntreprise = urlParams.get('cli');
const annee = urlParams.get('annee');
const mois = urlParams.get('mois');
saveDocumentRecap({ saveDocumentRecap({
clientEntreprise: clientEntreprise, filter: filter,
annee, year: year,
mois month: month,
filterType: filterType
}); });
}) })
}); });

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

@ -4,13 +4,15 @@ import {baseUrl} from "../modules/mainFunction.mjs";
$('body').on('click', '#exportMultipleFactureToPdf', function () { $('body').on('click', '#exportMultipleFactureToPdf', function () {
// Access specific parameter values // Access specific parameter values
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const clientEntreprise = urlParams.get('cli'); const filter = urlParams.get('cli');
const year = urlParams.get('annee'); const year = urlParams.get('annee');
const month = urlParams.get('mois'); const month = urlParams.get('mois');
const filterType = urlParams.get('filterType');
var exportMultipleFacturePayload = { var exportMultipleFacturePayload = {
clientEntreprise : clientEntreprise, filter : filter,
month : month, month : month,
year : year year : year,
filterType : filterType
}; };
$.ajax({ $.ajax({
@ -29,4 +31,10 @@ $('body').on('click', '#exportMultipleFactureToPdf', function () {
showError(t('gestion', "Erreur dans la génération de facture multiple")); showError(t('gestion', "Erreur dans la génération de facture multiple"));
}); });
});
document.getElementById('clientselector').addEventListener('change', function() {
let selectedOption = this.options[this.selectedIndex];
let filterType = selectedOption.getAttribute('data-type');
document.getElementById('filterType').value = filterType;
}); });

View File

@ -16,6 +16,7 @@ import { Defunt } from "../objects/defunt.mjs";
import { Bibliotheque } from "../objects/bibliotheque.mjs"; import { Bibliotheque } from "../objects/bibliotheque.mjs";
import { ClientGroup } from '../objects/clientGroup.mjs'; import { ClientGroup } from '../objects/clientGroup.mjs';
import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs"; import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs";
import { ClientGroupFacturation } from "../objects/clientGroupFacturation.mjs";
import { DefaultDevisMentionConstant, FacturedDevisMentionConstant, NewDevisMentionConstant } from "../constants/invoiceConstant"; import { DefaultDevisMentionConstant, FacturedDevisMentionConstant, NewDevisMentionConstant } from "../constants/invoiceConstant";
var choose_folder = t('gestion', 'Choose work folder'); var choose_folder = t('gestion', 'Choose work folder');
@ -59,6 +60,9 @@ document.body.addEventListener('click', e => {
else if(e.target.className.includes("selectClientGroupList")){ else if(e.target.className.includes("selectClientGroupList")){
ClientGroup.loadClientGroupListToSelect(e); ClientGroup.loadClientGroupListToSelect(e);
} }
else if(e.target.className.includes("selectClientGroupFacturationList")){
ClientGroupFacturation.loadClientGroupFacturationListToSelect(e);
}
else if(e.target.className.includes("selectProductsList")){ else if(e.target.className.includes("selectProductsList")){
Produit.loadProductListToSelect(e); Produit.loadProductListToSelect(e);
} }
@ -104,12 +108,16 @@ document.body.addEventListener('click', e => {
else if("newClientGroup" === e.target.id){ else if("newClientGroup" === e.target.id){
ClientGroup.createDefaultClientGroup(new DataTable('.tabledt')); ClientGroup.createDefaultClientGroup(new DataTable('.tabledt'));
} }
else if("newClientGroupFacturation" === e.target.id){
ClientGroupFacturation.createDefaultClientGroupFacturation(new DataTable('.tabledt'));
}
else if("newClientGroupDiscount" === e.target.id){ else if("newClientGroupDiscount" === e.target.id){
ClientGroupDiscount.createDefaultClientGroupDiscount(new DataTable('.tabledt')); ClientGroupDiscount.createDefaultClientGroupDiscount(new DataTable('.tabledt'));
} else if("saveIk" == e.target.id) { } else if("saveIk" == e.target.id) {
TrajetDetails.saveIkNextcloud(); TrajetDetails.saveIkNextcloud();
} else if("apercusFactures" === e.target.id) { } else if("apercusFactures" === e.target.id) {
window.location.replace(generateUrl(`/apps/gestion/factures/apercus?cli=&annee=${(new Date()).getFullYear()}&mois=${(new Date()).getMonth()}`)); let url = generateUrl(`/apps/gestion/factures/apercus?cli=&annee=${(new Date()).getFullYear()}&mois=${(new Date()).getMonth()}&filterType=client`);
window.location.replace(url);
} else if("apercusDevis" === e.target.id) { } else if("apercusDevis" === e.target.id) {
window.location.replace(generateUrl(`/apps/gestion/devis/apercus?cli=&annee=${(new Date()).getFullYear()}&mois=${(new Date()).getMonth()}`)); window.location.replace(generateUrl(`/apps/gestion/devis/apercus?cli=&annee=${(new Date()).getFullYear()}&mois=${(new Date()).getMonth()}`));
} else if("newArticle" === e.target.id) { } else if("newArticle" === e.target.id) {

View File

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

View File

@ -17,12 +17,19 @@ export class Client {
this.mail = ((myresp.mail.length === 0) ? '-' : myresp.mail); this.mail = ((myresp.mail.length === 0) ? '-' : myresp.mail);
this.adresse = ((myresp.adresse.length === 0) ? '-' : myresp.adresse); this.adresse = ((myresp.adresse.length === 0) ? '-' : myresp.adresse);
this.clientGroupName = ((myresp.client_group_name.length === 0) ? '-' : myresp.client_group_name); 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; let clientGroupId = 0;
if(myresp.fk_client_group_id != null && myresp.fk_client_group_id.length > 0){ if(myresp.fk_client_group_id != null && myresp.fk_client_group_id.length > 0){
clientGroupId = myresp.fk_client_group_id clientGroupId = myresp.fk_client_group_id
} }
this.clientGroupId = clientGroupId; 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="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="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="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>' '<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; return myrow;

View File

@ -0,0 +1,130 @@
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);
}
/**
* 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 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

@ -6,10 +6,16 @@
<?php <?php
foreach ($_['clients'] as $key => $client) { foreach ($_['clients'] as $key => $client) {
?> ?>
<option <?php <option
if($_GET['cli'] == $client->entreprise) echo 'selected' ?> <?php
value='<?php echo $client->entreprise ?>'> if($_GET['cli'] == $client->id && $_GET['filterType'] == $client->client_type){
<?php echo strtoupper(html_entity_decode($client->entreprise)); ?> echo 'selected';
}
?>
value='<?php echo $client->id ?>'
data-type='<?php echo $client->client_type ?>'
>
<?php echo strtoupper(html_entity_decode($client->nom)); ?>
</option> </option>
<?php <?php
} }
@ -39,6 +45,7 @@
<option value="11" <?php if((int) $_GET['mois'] == 11) echo 'selected' ?>>Novembre</option> <option value="11" <?php if((int) $_GET['mois'] == 11) echo 'selected' ?>>Novembre</option>
<option value="12" <?php if((int) $_GET['mois'] == 12) echo 'selected' ?>>Decembre</option> <option value="12" <?php if((int) $_GET['mois'] == 12) echo 'selected' ?>>Decembre</option>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<input type="hidden" name="filterType" id="filterType" value="<?php echo ($_GET['filterType'] ?? 'client'); ?>">
<input type="submit" value="Filtrer"/> <input type="submit" value="Filtrer"/>
</form> </form>
<div class="d-flex flex-row"> <div class="d-flex flex-row">
@ -50,10 +57,17 @@
$year = (int) $datesplit[0]; $year = (int) $datesplit[0];
$month = (int) $datesplit[1]; $month = (int) $datesplit[1];
$checkClient = false; $checkClient = false;
if($_GET['cli'] == null || $_GET['cli'] == '') { $filterType = "client";
$checkClient = (strcmp(strtolower($f->entreprise), 'cogf')==0); if(array_key_exists('filterType',$_GET) && $_GET['filterType'] == 'group'){
} else { $filterType = "group";
$checkClient = $f->client_entreprise == $_GET['cli']; }
if($_GET['cli'] != null && $_GET['cli'] != '') {
if($filterType == "group"){
$checkClient = $f->fk_client_group_facturation_id == $_GET['cli'];
}
else{
$checkClient = $f->id_cli == $_GET['cli'];
}
} }
$checkYear = ((int) ($_GET['annee']) == -1)?(true):($year==((int) $_GET['annee'])); $checkYear = ((int) ($_GET['annee']) == -1)?(true):($year==((int) $_GET['annee']));
$checkMounth = (((int) $_GET['mois']) == 0)? (true): ($month==((int) $_GET['mois'])); $checkMounth = (((int) $_GET['mois']) == 0)? (true): ($month==((int) $_GET['mois']));

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 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('Actions'));?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

View File

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

View File

@ -39,13 +39,20 @@
</ul> </ul>
</div> </div>
</li> </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> <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('Groupe tarifaire'));?></a>
<div class="app-navigation-entry-utils"> <div class="app-navigation-entry-utils">
<ul> <ul>
<li class="app-navigation-entry-utils-counter"><span id="clientGroupStat"><div class="loader"></div></span></li> <li class="app-navigation-entry-utils-counter"><span id="clientGroupStat"><div class="loader"></div></span></li>
</ul> </ul>
</div> </div>
</li> </li>
<li class="app-navigation-entry"><span class="navmarg icon-contacts-dark"></span><a class="a-entry" href="<?php echo($_['url']['clientGroupFacturation']); ?>"><?php p($l->t('Groupe facturation'));?></a>
<div class="app-navigation-entry-utils">
<ul>
<li class="app-navigation-entry-utils-counter"><span id="clientGroupFacturationStat"><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> <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"> <div class="app-navigation-entry-utils">
<ul> <ul>

View File

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