features facture group by facture entreprise
This commit is contained in:
parent
075835211a
commit
44c984a46d
File diff suppressed because one or more lines are too long
@ -368,11 +368,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->getClients($this->idNextcloud));
|
$clients = json_decode($this->myDb->getClientsGroupedByClientEntreprise());
|
||||||
$clients_final = [];
|
|
||||||
foreach ($clients as $key => $client) {
|
|
||||||
if(!in_array(strtolower($client->entreprise), $clients_final)) array_push($clients_final, strtolower($client->entreprise));
|
|
||||||
}
|
|
||||||
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,
|
||||||
@ -750,7 +746,7 @@ class PageController extends Controller {
|
|||||||
} catch(\OCP\Files\NotPermittedException $e) { }
|
} catch(\OCP\Files\NotPermittedException $e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generer_document_comptable_client($date, $idclient) {
|
private function generer_document_comptable_client($date, $clientEntreprise) {
|
||||||
$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 {
|
||||||
@ -762,7 +758,8 @@ class PageController extends Controller {
|
|||||||
$tvaIntraCommuValue = $firstClient["legal_one"];
|
$tvaIntraCommuValue = $firstClient["legal_one"];
|
||||||
}
|
}
|
||||||
$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));
|
||||||
$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(
|
||||||
@ -1893,11 +1890,11 @@ class PageController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
* @param string $idclient
|
* @param string $clientEntreprise
|
||||||
* @param string $annee
|
* @param string $annee
|
||||||
* @param string $mois
|
* @param string $mois
|
||||||
*/
|
*/
|
||||||
public function saveDocumentRecap($idclient, $annee, $mois) {
|
public function saveDocumentRecap($clientEntreprise, $annee, $mois) {
|
||||||
$dateString = '15-'.$mois.'-'.$annee;
|
$dateString = '15-'.$mois.'-'.$annee;
|
||||||
$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');
|
||||||
@ -1908,7 +1905,7 @@ class PageController extends Controller {
|
|||||||
// } else {
|
// } else {
|
||||||
// $this->generer_document_comptable_client($date, intval($idclient));
|
// $this->generer_document_comptable_client($date, intval($idclient));
|
||||||
// }
|
// }
|
||||||
$this->generer_document_comptable_client($date, intval($idclient));
|
$this->generer_document_comptable_client($date, $clientEntreprise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2807,15 +2804,15 @@ class PageController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
* @param string $clientId
|
* @param string $clientEntreprise
|
||||||
* @param string $month
|
* @param string $month
|
||||||
* @param string $year
|
* @param string $year
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function exportFactureByClientAndMonthYearToPdf($clientId,$month,$year){
|
public function exportFactureByClientAndMonthYearToPdf($clientEntreprise,$month,$year){
|
||||||
try{
|
try{
|
||||||
$factureFilename = $this->invoicePdfService->generateMultipleInvoicePdfByClientAndMonthYear($clientId,$month,$year,$this->idNextcloud);
|
$factureFilename = $this->invoicePdfService->generateMultipleInvoicePdfByClientAndMonthYear($clientEntreprise,$month,$year,$this->idNextcloud);
|
||||||
return $factureFilename;
|
return $factureFilename;
|
||||||
}
|
}
|
||||||
catch(\OCP\Files\NotFoundException $e) { }
|
catch(\OCP\Files\NotFoundException $e) { }
|
||||||
|
|||||||
@ -291,11 +291,26 @@ class Bdd {
|
|||||||
return $this->execSQL($sql, array());
|
return $this->execSQL($sql, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getClientsGroupedByClientEntreprise(){
|
||||||
|
$sql = "SELECT * FROM ".$this->tableprefix."client as client GROUP BY client.entreprise;";
|
||||||
|
$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'] : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return json_encode($clientsGroupedByClientEntreprise);
|
||||||
|
}
|
||||||
|
|
||||||
public function getFactures($idNextcloud){
|
public function getFactures($idNextcloud){
|
||||||
$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.nom, ".$this->tableprefix."client.prenom, ".$this->tableprefix."client.id as id_cli, ".$this->tableprefix."client.entreprise as client_entreprise, "
|
||||||
.$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.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."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
|
||||||
@ -319,6 +334,27 @@ class Bdd {
|
|||||||
return json_encode($facturesList);
|
return json_encode($facturesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getClientFacturesByClientEntrepriseAndDate($clientEntreprise,$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.entreprise = ? ORDER BY year DESC, month DESC;";
|
||||||
|
$result = $this->execSQL($sql, array($clientEntreprise));
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCurrentMonthFactures_byClient($idNextcloud, $date, $idclient) {
|
public function getCurrentMonthFactures_byClient($idNextcloud, $date, $idclient) {
|
||||||
$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, "
|
||||||
@ -2458,8 +2494,8 @@ class Bdd {
|
|||||||
return $devisList;
|
return $devisList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoicePdfDataByClientAndMonthYear($clientId,$month,$year,$configuration){
|
public function getInvoicePdfDataByClientAndMonthYear($clientEntreprise,$month,$year,$configuration){
|
||||||
$invoices = $this->getInvoiceByClientAndMonthYear($clientId,$month,$year);
|
$invoices = $this->getInvoiceByClientAndMonthYear($clientEntreprise,$month,$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'] : '';
|
||||||
@ -2478,7 +2514,7 @@ class Bdd {
|
|||||||
return $invoices;
|
return $invoices;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getInvoiceByClientAndMonthYear($clientId,$month,$year){
|
private function getInvoiceByClientAndMonthYear($clientEntreprise,$month,$year){
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
facture.id,
|
facture.id,
|
||||||
facture.date,
|
facture.date,
|
||||||
@ -2504,10 +2540,10 @@ class Bdd {
|
|||||||
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 devis.id_client = ? AND
|
WHERE client.entreprise = ? AND
|
||||||
YEAR(facture.date_paiement) = ?";
|
YEAR(facture.date_paiement) = ?";
|
||||||
|
|
||||||
$conditions = [$clientId,$year];
|
$conditions = [$clientEntreprise,$year];
|
||||||
if($month != 0){
|
if($month != 0){
|
||||||
$conditions[] = $month;
|
$conditions[] = $month;
|
||||||
$sql .= " AND MONTH(facture.date_paiement) = ?";
|
$sql .= " AND MONTH(facture.date_paiement) = ?";
|
||||||
|
|||||||
@ -118,12 +118,12 @@ class InvoicePdfService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateMultipleInvoicePdfByClientAndMonthYear($clientId,$month,$year,$idNextCloud){
|
public function generateMultipleInvoicePdfByClientAndMonthYear($clientEntreprise,$month,$year,$idNextCloud){
|
||||||
$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($clientId,$month,$year,$currentConfig);
|
$invoiceData = $this->gestionBdd->getInvoicePdfDataByClientAndMonthYear($clientEntreprise,$month,$year,$currentConfig);
|
||||||
if(empty($invoiceData)){
|
if(empty($invoiceData)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,11 +22,11 @@ window.addEventListener("DOMContentLoaded", function () {
|
|||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
// Access specific parameter values
|
// Access specific parameter values
|
||||||
const idclient = urlParams.get('cli');
|
const clientEntreprise = urlParams.get('cli');
|
||||||
const annee = urlParams.get('annee');
|
const annee = urlParams.get('annee');
|
||||||
const mois = urlParams.get('mois');
|
const mois = urlParams.get('mois');
|
||||||
saveDocumentRecap({
|
saveDocumentRecap({
|
||||||
idclient,
|
clientEntreprise: clientEntreprise,
|
||||||
annee,
|
annee,
|
||||||
mois
|
mois
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,11 +4,11 @@ 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 clientId = urlParams.get('cli');
|
const clientEntreprise = urlParams.get('cli');
|
||||||
const year = urlParams.get('annee');
|
const year = urlParams.get('annee');
|
||||||
const month = urlParams.get('mois');
|
const month = urlParams.get('mois');
|
||||||
var exportMultipleFacturePayload = {
|
var exportMultipleFacturePayload = {
|
||||||
clientId : clientId,
|
clientEntreprise : clientEntreprise,
|
||||||
month : month,
|
month : month,
|
||||||
year : year
|
year : year
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,7 +6,11 @@
|
|||||||
<?php
|
<?php
|
||||||
foreach ($_['clients'] as $key => $client) {
|
foreach ($_['clients'] as $key => $client) {
|
||||||
?>
|
?>
|
||||||
<option <?php if($_GET['cli'] == $client->id) echo 'selected' ?> value='<?php echo $client->id ?>'><?php echo strtoupper(html_entity_decode($client->prenom.' '.$client->nom)); ?></option>
|
<option <?php
|
||||||
|
if($_GET['cli'] == $client->entreprise) echo 'selected' ?>
|
||||||
|
value='<?php echo $client->entreprise ?>'>
|
||||||
|
<?php echo strtoupper(html_entity_decode($client->entreprise)); ?>
|
||||||
|
</option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -46,10 +50,10 @@
|
|||||||
$year = (int) $datesplit[0];
|
$year = (int) $datesplit[0];
|
||||||
$month = (int) $datesplit[1];
|
$month = (int) $datesplit[1];
|
||||||
$checkClient = false;
|
$checkClient = false;
|
||||||
if(intval($_GET['cli'])==0) {
|
if($_GET['cli'] == null || $_GET['cli'] == '') {
|
||||||
$checkClient = (strcmp(strtolower($f->entreprise), 'cogf')==0);
|
$checkClient = (strcmp(strtolower($f->entreprise), 'cogf')==0);
|
||||||
} else {
|
} else {
|
||||||
$checkClient = ($f->id_cli==intval($_GET['cli']));
|
$checkClient = $f->client_entreprise == $_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']));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user