On gere correctement l'envoi du json complet ou seulement ce qui est

affiché, attention , il faut gerer la conf de php correctement, cf
readme.
On change le nom du fichier, plus besoin qu'il soit hashé maintenant,
car un job le supprimera
This commit is contained in:
Christophe 2022-09-27 21:11:34 +02:00
parent 738688516d
commit f2272fe2c6
4 changed files with 76 additions and 47 deletions

View file

@ -9,6 +9,16 @@ Dans cette nouvelle version, on découpe le stockage en 2:
## Configuration ## Configuration
Choisir entre la version minifiée de vuejs (sans le debug) ou la version de dev Choisir entre la version minifiée de vuejs (sans le debug) ou la version de dev
### PHP dans php.ini
* post_max_size which is directly related to the POST size
* upload_max_filesize which may be unrelated, not sure
* max_input_time, if the POSt takes too long
* max_input_nesting_level if your data is an array with a lot of sublevels
* max_execution_time, but quite sure its not that
* memory_limit, as you may reach a size exceding the subprocess allowed memory
* max_input_vars, if your data array has many elements => **le plus important**
## Utilisation ## Utilisation
- charger l'inclure (5 args possibles et facultatifs) - charger l'inclure (5 args possibles et facultatifs)
```html ```html

View file

@ -11,9 +11,9 @@ function action_pdf_gamutable_dist() {
} }
$fichierpdf = _request('fichierpdf') ?? ''; $fichierpdf = _request('fichierpdf') ?? '';
// $namepdf = _request('namepdf') ?? $fichierpdf; $namepdf = _request('namepdf') ?? $fichierpdf;
$header = _request('header') ?? []; $header = _request('header') ?? [];
$Tdata = _request('data') ?? []; $Tdata = _request('Tdata') ?? [];
$arg = _request('arg') ?? ''; $arg = _request('arg') ?? '';
if (empty($header) or empty($fichierpdf)) { if (empty($header) or empty($fichierpdf)) {
@ -23,15 +23,14 @@ function action_pdf_gamutable_dist() {
$Tcles = []; $Tcles = [];
if (!empty($Tdata)) { if (!empty($Tdata)) {
foreach ($Tdata as $d) { foreach ($Tdata as $d) {
$Tcles[] = $d['html']['id']; $Tcles[] = $d['id'];
} }
} }
if (find_in_path('gamutable_pdf/' . $fichierpdf . '.html')) { if (find_in_path('gamutable_pdf/' . $fichierpdf . '.html')) {
$set = ['arg' => $arg]; $set = ['arg' => $arg];
if (!empty($Tcles)) { if (!empty($Tcles)) {
$set = array_merge($set, ['Lids' => implode(',', $Tcles)]); $set = array_merge($set, ['Tids' => $Tcles]);
} }
$fond = recuperer_fond('gamutable_pdf/' . $fichierpdf, $set); $fond = recuperer_fond('gamutable_pdf/' . $fichierpdf, $set);
@ -43,10 +42,10 @@ function action_pdf_gamutable_dist() {
include_spip('spipdf_options'); include_spip('spipdf_options');
include_spip('inc/spipdf'); include_spip('inc/spipdf');
$namepdf = 'pdf_' . time(); $namepdf = date("Y-m-d_H-i") . '_' . $namepdf;
$a = spipdf_html2pdf($fond); $a = spipdf_html2pdf($fond);
$dir = sous_repertoire(_DIR_IMG . 'pdfgamutable'); $dir = sous_repertoire(_DIR_IMG . 'pdfgamutable');
$chemin = $dir . md5($namepdf) . '.pdf' ; $chemin = $dir . $namepdf . '.pdf' ;
file_put_contents($chemin, $a); file_put_contents($chemin, $a);
$id_job = job_queue_add( $id_job = job_queue_add(

View file

@ -197,9 +197,6 @@ let monTableau = {
namecsv: { namecsv: {
type: String, type: String,
}, },
namepdf: {
type: String,
},
url_sort_asc: { url_sort_asc: {
type: String, type: String,
}, },
@ -710,13 +707,19 @@ let monTableau = {
} }
}, },
genererPDF(quoi = 'tableau') { genererPDF(quoi = 'tableau') {
let $tableau = [];
Object.values(this[quoi]).forEach((d) => {
$tableau.push(d.html);
});
const data = { const data = {
fichierpdf: this.fichierpdf, fichierpdf: this.fichierpdf,
namepdf: this.namepdf, namepdf: this.namepdf,
header: this.header, header: this.header,
data: this[quoi],
arg: this.argpdf, arg: this.argpdf,
Tdata: $tableau,
}; };
let req = $.ajax({ let req = $.ajax({
url: this.pdfuri, url: this.pdfuri,
type: 'POST', type: 'POST',
@ -815,18 +818,26 @@ let monTableau = {
> >
<i class="fa fa-file-excel-o fas fa-file-csv" aria-hidden="true"></i> <i class="fa fa-file-excel-o fas fa-file-csv" aria-hidden="true"></i>
</button> </button>
<button class="btn" type="button" @click.stop="genererPDF()"
v-show="this.fichierpdf"
title="Générer le PDF du tableau affiché"
>
<i class="fas fa-file-pdf rouge" aria-hidden="true" alt="pdf"></i>
</button>
<button class="btn gamutable--exportCSV" type="button" @click.stop="exportCSV('table')" <button class="btn gamutable--exportCSV" type="button" @click.stop="exportCSV('table')"
v-show="this.namecsv" v-show="this.namecsv"
title="Exporter le tableau complet en csv" title="Exporter le tableau complet en csv"
> >
<i class="fas fas fa-file-excel" aria-hidden="true" alt="csv"></i> <i class="fas fas fa-file-excel" aria-hidden="true" alt="csv"></i>
</button> </button>
<button class="btn" type="button" @click.stop="genererPDF()"
<button class="btn" type="button" @click.stop="genererPDF('table')"
v-show="this.fichierpdf" v-show="this.fichierpdf"
title="Générer le PDF du tableau complet" title="Générer le PDF du tableau complet"
> >
<i class="fas fa-file-pdf rouge" aria-hidden="true" alt="pdf"></i> <i class="far fa-file-pdf rouge" aria-hidden="true" alt="pdf"></i>
</button> </button>
<span v-show="chargement" class="rouge"> <span v-show="chargement" class="rouge">
<i class="fa fa-refresh fa-spin fa-fw rouge fas fa-sync fa-spin"></i> <i class="fa fa-refresh fa-spin fa-fw rouge fas fa-sync fa-spin"></i>
<span class="texteMajBDD"> <span class="texteMajBDD">

File diff suppressed because one or more lines are too long