user folder for facture and statistic
This commit is contained in:
parent
1cddf14d2c
commit
203fef39cc
@ -31,6 +31,9 @@ class PageController extends Controller {
|
|||||||
private $myDb;
|
private $myDb;
|
||||||
// private $src_path = "/var/www/html/apps/gestion/img/";
|
// private $src_path = "/var/www/html/apps/gestion/img/";
|
||||||
private $src_path = "/var/www/html/custom_apps/gestion/img/";
|
private $src_path = "/var/www/html/custom_apps/gestion/img/";
|
||||||
|
|
||||||
|
private const HYTHA_35_DEFAULT_ADMIN = "Johann";
|
||||||
|
private const H2F_DEFAULT_ADMIN = "Emmanuelle";
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
private $mailer;
|
private $mailer;
|
||||||
private $config;
|
private $config;
|
||||||
@ -2658,6 +2661,8 @@ class PageController extends Controller {
|
|||||||
|
|
||||||
public function exportFactureToPdf($factureId){
|
public function exportFactureToPdf($factureId){
|
||||||
try{
|
try{
|
||||||
|
//for HYTHA 35 , the default admin idnextcloud is Johann, for H2F it is Emmanuelle
|
||||||
|
$this->idNextcloud = self::HYTHA_35_DEFAULT_ADMIN;
|
||||||
$factureFilenames = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->idNextcloud);
|
$factureFilenames = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->idNextcloud);
|
||||||
return json_encode($factureFilenames);
|
return json_encode($factureFilenames);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,30 +35,28 @@ class InvoicePdfService {
|
|||||||
/** @var Bdd */
|
/** @var Bdd */
|
||||||
private $gestionBdd;
|
private $gestionBdd;
|
||||||
|
|
||||||
/** @var IRootStorage */
|
/** @var IRootFolder */
|
||||||
private $storage;
|
private $rootFolder;
|
||||||
|
|
||||||
|
private const DEFAULT_NEXTCLOUD_ADMIN = "admin";
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Bdd $gestionBdd,
|
Bdd $gestionBdd,
|
||||||
IRootFolder $rootFolder) {
|
IRootFolder $rootFolder) {
|
||||||
$this->gestionBdd = $gestionBdd;
|
$this->gestionBdd = $gestionBdd;
|
||||||
try{
|
$this->rootFolder = $rootFolder;
|
||||||
$this->storage = $rootFolder->getUserFolder('admin');
|
|
||||||
}catch(\OC\User\NoUserException $e){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLogo(){
|
private function getLogo(){
|
||||||
|
$storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN);
|
||||||
try{
|
try{
|
||||||
try {
|
try {
|
||||||
if(isset($this->storage)){
|
if(isset($storage)){
|
||||||
$file = $this->storage->get('/.gestion/logo.png');
|
$file = $storage->get('/.gestion/logo.png');
|
||||||
}else{
|
}else{
|
||||||
return "nothing";
|
return "nothing";
|
||||||
}
|
}
|
||||||
} catch(\OCP\Files\NotFoundException $e) {
|
} catch(\OCP\Files\NotFoundException $e) {
|
||||||
$file = $this->storage->get('/.gestion/logo.jpeg');
|
$file = $storage->get('/.gestion/logo.jpeg');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(\OCP\Files\NotFoundException $e) {
|
catch(\OCP\Files\NotFoundException $e) {
|
||||||
@ -69,7 +67,8 @@ class InvoicePdfService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function generateFacturePdfByFactureId($factureId,$idNextCloud){
|
public function generateFacturePdfByFactureId($factureId,$idNextCloud){
|
||||||
$configs = json_decode($this->gestionBdd->getConfiguration($idNextCloud));
|
$storage = $this->rootFolder->getUserFolder($idNextCloud);
|
||||||
|
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
|
||||||
$currentConfig = $configs[0];
|
$currentConfig = $configs[0];
|
||||||
$logo = $this->getLogo();
|
$logo = $this->getLogo();
|
||||||
$invoicePdfData = $this->gestionBdd->getInvoicePdfData($factureId,$currentConfig);
|
$invoicePdfData = $this->gestionBdd->getInvoicePdfData($factureId,$currentConfig);
|
||||||
@ -85,13 +84,13 @@ class InvoicePdfService {
|
|||||||
$filenames = [];
|
$filenames = [];
|
||||||
foreach($factureFolders as $folder){
|
foreach($factureFolders as $folder){
|
||||||
try {
|
try {
|
||||||
$this->storage->newFolder($folder);
|
$storage->newFolder($folder);
|
||||||
}
|
}
|
||||||
catch(\OCP\Files\NotPermittedException $e) {
|
catch(\OCP\Files\NotPermittedException $e) {
|
||||||
}
|
}
|
||||||
$ff_pdf = $folder.$pdfFilename.'.pdf';
|
$ff_pdf = $folder.$pdfFilename.'.pdf';
|
||||||
$this->storage->newFile($ff_pdf);
|
$storage->newFile($ff_pdf);
|
||||||
$file_pdf = $this->storage->get($ff_pdf);
|
$file_pdf = $storage->get($ff_pdf);
|
||||||
$file_pdf->putContent($pdfContent);
|
$file_pdf->putContent($pdfContent);
|
||||||
$filenames[] = $ff_pdf;
|
$filenames[] = $ff_pdf;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user