52
52
*/
53
53
function saturne_show_documents (string $ modulepart , $ modulesubdir , $ filedir , string $ urlsource , $ genallowed , int $ delallowed = 0 , string $ modelselected = '' , int $ allowgenifempty = 1 , int $ forcenomultilang = 0 , int $ notused = 0 , int $ noform = 0 , string $ param = '' , string $ title = '' , string $ buttonlabel = '' , string $ codelang = '' , string $ morepicto = '' , $ object = null , int $ hideifempty = 0 , string $ removeaction = 'remove_file ' , int $ active = 1 , string $ tooltiptext = '' , string $ sortfield = '' , string $ sortorder = '' ): string
54
54
{
55
- global $ conf , $ db , $ form , $ hookmanager , $ langs ;
55
+ global $ conf , $ db , $ form , $ hookmanager , $ langs, $ user ;
56
56
57
57
if (!is_object ($ form )) {
58
58
$ form = new Form ($ db );
59
59
}
60
60
61
+ require_once __DIR__ . '/../class/saturneqrcode.class.php ' ;
62
+ $ QRCode = new SaturneQRCode ($ db );
63
+
61
64
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php ' ;
62
65
63
66
// Add entity in $param if not already exists
@@ -288,6 +291,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
288
291
$ out .= $ form ->textwithpicto ($ langs ->trans ('Help ' ), $ htmltooltip , 1 , 0 );
289
292
$ out .= '</span> ' ;
290
293
}
294
+ $ out .= '</th><th> ' ;
291
295
$ out .= '</th> ' ;
292
296
293
297
if (!empty ($ hookmanager ->hooks ['formfile ' ])) {
@@ -308,6 +312,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
308
312
$ out .= '<td></td> ' ;
309
313
$ out .= get_document_title_search ('date ' , 'Date ' , 'right ' );
310
314
$ out .= '<td></td> ' ;
315
+ $ out .= '<td></td> ' ;
311
316
$ out .= '<td class="right "> ' ;
312
317
$ out .= '<i class="saturne-search-button fas fa-search" style="cursor: pointer;"></i> ' ;
313
318
$ out .= ' ' ;
@@ -320,6 +325,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
320
325
$ out .= get_document_title_field ($ sortfield , $ sortorder , 'Size ' , true , 'right ' );
321
326
$ out .= get_document_title_field ($ sortfield , $ sortorder , 'Date ' , true , 'right ' );
322
327
$ out .= get_document_title_field ($ sortfield , $ sortorder , 'PDF ' , false , 'right ' );
328
+ $ out .= get_document_title_field ($ sortfield , $ sortorder , 'QRCode ' , false , 'right ' );
323
329
$ out .= get_document_title_field ($ sortfield , $ sortorder , 'Action ' , false , 'right ' );
324
330
$ out .= '</tr> ' ;
325
331
@@ -353,6 +359,28 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
353
359
$ out .= '<table class="noborder centpercent" id=" ' . $ modulepart . '_table"> ' . "\n" ;
354
360
}
355
361
362
+ ?>
363
+ <script src="https://cdn.jsdelivr.net/npm/
[email protected] /dist/pdf-lib.min.js"></script>
364
+
365
+ <?php
366
+
367
+ $ out .= '<div id="pdfModal" class="wpeo-modal">
368
+ <div class="modal-container">
369
+ <div class="modal-header">
370
+ <h2>QR Code</h2>
371
+ </div>
372
+ <div class="modal-content" style="display: flex; justify-content: center">
373
+ <div id="pdfPreview">
374
+ <!-- Le PDF sera affiché ici dans un iframe -->
375
+ </div>
376
+ </div>
377
+ <div class="modal-footer">
378
+ <button id="downloadBtn" style="margin-top: 10px;"><i class="fas fa-download fa-2x"></i></button>
379
+ </div>
380
+ </div>
381
+ </div> ' ;
382
+
383
+
356
384
// Loop on each file found
357
385
if (is_array ($ fileList )) {
358
386
foreach ($ fileList as $ file ) {
@@ -425,6 +453,26 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
425
453
$ out .= '</td> ' ;
426
454
}
427
455
456
+ //Show QR Code
457
+ $ documentQRCode = $ QRCode ->fetchAll ('' , '' , 0 , 0 , ['url ' => $ documenturl . '?modulepart= ' . $ modulepart . '&file= ' . urlencode ($ relativepath ) . ($ param ? '& ' . $ param : '' )]);
458
+ if (is_array ($ documentQRCode ) && !empty ($ documentQRCode )) {
459
+ $ documentQRCode = array_shift ($ documentQRCode );
460
+ } else {
461
+ $ QRCode ->url = $ documenturl . '?modulepart= ' . $ modulepart . '&file= ' . urlencode ($ relativepath ) . ($ param ? '& ' . $ param : '' );
462
+ $ QRCode ->encoded_qr_code = $ QRCode ->getQRCodeBase64 ($ QRCode ->url );
463
+ $ QRCode ->status = 1 ;
464
+ $ QRCode ->module_name = $ modulepart ;
465
+ $ QRCode ->create ($ user );
466
+ $ documentQRCode = $ QRCode ;
467
+
468
+ }
469
+
470
+ $ out .= '<td class="right preview-qr-code"> ' ;
471
+ $ out .= '<input hidden class="qrcode-base64" value=" ' . $ documentQRCode ->encoded_qr_code .'"> ' ;
472
+ $ out .= img_picto ($ langs ->trans ("QRCodeGeneration " ), 'fontawesome_fa-qrcode_fas_blue ' );
473
+ $ out .= ' ' . $ form ->textwithpicto ('' , $ langs ->trans ('QRCodeGenerationTooltip ' ));
474
+ $ out .= '</td> ' ;
475
+
428
476
if ($ delallowed || $ morepicto ) {
429
477
$ out .= '<td class="right nowraponall"> ' ;
430
478
if ($ delallowed ) {
0 commit comments