open pdf preview into new onglet
This commit is contained in:
parent
741368b12b
commit
5874760348
File diff suppressed because one or more lines are too long
@ -2983,6 +2983,11 @@ class PageController extends Controller {
|
||||
public function factureGroupDetails($numfacture){
|
||||
$this->denyIfNotAdmin();
|
||||
$facture = $this->myDb->getFactureGroupByFactureIdWithDetails($numfacture);
|
||||
$facture["path_to_file"] = $this->idNextcloud.'/'.FileExportHelpers::GetFactureGroupFileFullPath(
|
||||
clientName:$facture['group_name'],
|
||||
factureNum: $facture['num'],
|
||||
facturationDate: $facture['date_paiement']
|
||||
);
|
||||
return new TemplateResponse('gestion', 'factureGroupDetails', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud,
|
||||
'configuration'=> $this->getConfiguration(),
|
||||
'facture'=>json_decode(json_encode($facture)),
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace OCA\Gestion\Helpers;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class FileExportHelpers
|
||||
{
|
||||
|
||||
@ -53,6 +55,27 @@ class FileExportHelpers
|
||||
return $racinePath.'CLIENTS/'.mb_strtoupper($clientName,'UTF-8').'/';
|
||||
}
|
||||
|
||||
public static function GetFactureGroupFilename($factureNum,$clientName){
|
||||
$factureNum = str_replace('/','-',$factureNum);
|
||||
$clientName = str_replace(' ',' ',$clientName ?? '');
|
||||
return 'FACTURE'.'_'.$factureNum.'_'.mb_strtoupper($clientName,'UTF-8').'.pdf';
|
||||
}
|
||||
|
||||
public static function GetFactureGroupFolder($clientName,$facturationDate){
|
||||
$clientRacineFolder = 'CLIENTS/'.mb_strtoupper($clientName,'UTF-8').'/';
|
||||
$factureDatetime = new DateTime($facturationDate);
|
||||
$factureDateYear = $factureDatetime->format('Y');
|
||||
$factureMonth = DateHelpers::GetDateWithFormatDayAndMonthPlainString($facturationDate);
|
||||
$factureByYearFolder = $clientRacineFolder."$factureDateYear".'/'.$factureMonth.'/'.'FACTURES'.'/';
|
||||
return $factureByYearFolder;
|
||||
}
|
||||
|
||||
public static function GetFactureGroupFileFullPath($clientName,$factureNum,$facturationDate){
|
||||
$factureFolder = self::GetFactureGroupFolder($clientName,$facturationDate);
|
||||
$factureFilename = self::GetFactureGroupFilename($factureNum,$clientName);
|
||||
return $factureFolder.$factureFilename;
|
||||
}
|
||||
|
||||
public static function GetDefuntsFolder($clientName,$defuntName,$racinePath){
|
||||
$clientsFolder = self::GetClientsFolder($clientName,$racinePath);
|
||||
return $clientsFolder.'DEFUNTS/'.mb_strtoupper($defuntName,'UTF-8').'/';
|
||||
|
||||
@ -91,7 +91,7 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$factureNum = $this->factureData['num'];
|
||||
$factureNum = str_replace('/','-',$factureNum);
|
||||
$clientName = str_replace(' ',' ',$this->factureData['group_name'] ?? '');
|
||||
return $this->factureData['configuration']->facture_prefixe.'_'.$factureNum.'_'.mb_strtoupper($clientName,'UTF-8');
|
||||
return 'FACTURE'.'_'.$factureNum.'_'.mb_strtoupper($clientName,'UTF-8');
|
||||
}
|
||||
|
||||
public function DrawPageNumbersText($pageNumber,$pageCount){
|
||||
|
||||
@ -4,9 +4,19 @@ import "../css/mycss.css";
|
||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||
import "./listener/main_listener";
|
||||
import "./listener/invoiceListener";
|
||||
import { generateUrl } from "@nextcloud/router";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
globalConfiguration();
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('body').on('click', '#showPdfPathPreview', function () {
|
||||
let pdfPath = $(this).data('path');
|
||||
if(pdfPath != ""){
|
||||
let url = generateUrl(pdfPath);
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
|
||||
});
|
||||
@ -7,10 +7,14 @@ $factureOrderNumber = $facture->facture_order_number == '' ? '-' : $facture->fac
|
||||
$factureCaseNumber = $facture->facture_case_number == '' ? '-' : $facture->facture_case_number;
|
||||
$isFactureClientGroup = $facture->isFactureClientGroup;
|
||||
$currentConfig = json_decode($_['configuration'])[0];
|
||||
$facturePdfPath = 'remote.php/dav/files/'.$facture->path_to_file;
|
||||
?>
|
||||
<div class="bootstrap-iso">
|
||||
<canvas id="pdfCanvas"></canvas>
|
||||
<div id="factureId" data-id="<?php echo $facture->id; ?>"></div>
|
||||
<div id="factureIdentifier" data-id="<?php echo $facture->id; ?>"></div>
|
||||
<div id="facturePdfPath" data-path="<?php echo $facturePdfPath; ?>"></div>
|
||||
<button id="showPdfPathPreview" class="btn btn-secondary" data-path="<?php echo $facturePdfPath; ?>">Show path</button>
|
||||
<h2 class="mt-3 mb-3 text-center"> <?php echo ('Facture n° '.$facture->num); ?>
|
||||
</h2>
|
||||
<hr />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user