diff --git a/admin/qrcode.php b/admin/qrcode.php index 1f611ba0..3ade663a 100644 --- a/admin/qrcode.php +++ b/admin/qrcode.php @@ -69,17 +69,41 @@ // Add a redirection if ($action == 'add') { + if (dol_strlen($url) == 0) { + setEventMessage('URLToEncodeRequired', 'errors'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; + } $saturneQRCode->url = $url; $saturneQRCode->encoded_qr_code = $saturneQRCode->getQRCodeBase64($url); $saturneQRCode->module_name = 'saturne'; $saturneQRCode->status = 1; $saturneQRCode->create($user); + + setEventMessage('QRCodeCreated'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; +} + +if ($action == 'update') { + $saturneQRCode->fetch(GETPOST('id')); + $saturneQRCode->url = GETPOST('url'); + $saturneQRCode->encoded_qr_code = $saturneQRCode->getQRCodeBase64($saturneQRCode->url); + $saturneQRCode->update($user); + + setEventMessage('QRCodeUpdated'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; } // Remove a redirection if ($action == 'remove') { $saturneQRCode->fetch(GETPOST('id')); $saturneQRCode->delete($user, false, false); + + setEventMessage('QRCodeRemoved'); + header('Location: ' . $_SERVER['PHP_SELF']); + exit; } /* @@ -120,29 +144,55 @@ print '' . $langs->trans('URL') . ''; print '' . $langs->trans('QR Code') . ''; print '' . $langs->trans('ModuleName') . ''; -print '' . $langs->trans('Action') . ''; +print '' . $langs->trans('Actions') . ''; print ''; if (is_array($QRCodes) && !empty($QRCodes)) { foreach ($QRCodes as $QRCode) { - print '
'; - print ''; - print ''; - print ''; - print $QRCode->url; - print ''; - print ''; - print ''; - print img_picto($langs->trans("QRCodeGeneration"), 'fontawesome_fa-qrcode_fas_blue'); - print ' ' . $form->textwithpicto('', $langs->trans('QRCodeGenerationTooltip')); - print ''; - print ''; - print ucfirst($QRCode->module_name); - print ''; - print ''; - print ''; - print ''; - print '
'; + if ($action == 'edit' && $QRCode->id == GETPOST('id')) { + print ''; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + } else { + print ''; + print $QRCode->url; + print ''; + print ''; + print ''; + print img_picto($langs->trans("QRCodeGeneration"), 'fontawesome_fa-qrcode_fas_blue'); + print ' ' . $form->textwithpicto('', $langs->trans('QRCodeGenerationTooltip')); + print ''; + print ''; + print ucfirst($QRCode->module_name); + print ''; + + // Modify this section to use anchor tags for edit and delete actions + print ''; + print img_picto($langs->trans('Edit'), 'edit'); + print ' '; + // Form for Remove action using a form with token and a styled submit button + print '
'; + print ''; // Token for CSRF protection + print ''; // Action to remove the QR code + print ''; // ID of the QR code to be removed + print ''; + print '
'; + + + print ''; + } } } diff --git a/class/saturneqrcode.class.php b/class/saturneqrcode.class.php index bf1d2808..0b1b1a90 100644 --- a/class/saturneqrcode.class.php +++ b/class/saturneqrcode.class.php @@ -58,7 +58,7 @@ class SaturneQRCode extends SaturneObject /** * @var int Does object support extrafields ? 0 = No, 1 = Yes */ - public $isextrafieldmanaged = 1; + public $isextrafieldmanaged = 0; /** * @var string Last output from end job execution diff --git a/langs/fr_FR/saturne.lang b/langs/fr_FR/saturne.lang index 37bc7603..f454230c 100644 --- a/langs/fr_FR/saturne.lang +++ b/langs/fr_FR/saturne.lang @@ -224,6 +224,11 @@ ExportData = Exporter mes données QRCode = QR Code URLToEncode = URL à encoder HowToUseURLToEncode = Ecrivez l'URL vers laquelle le QR Code doit pointer +QRCodeCreated = QR Code créé +QRCodeUpdated = QR Code mis à jour +QRCodeRemoved = QR Code supprimé +URLToEncodeRequired = L'URL à encoder est obligatoire +QRCodeGenerationTooltip = Appuyez sur ce bouton pour voir le QR Code # diff --git a/lib/documents.lib.php b/lib/documents.lib.php index 2c2b05b4..481bf1c4 100644 --- a/lib/documents.lib.php +++ b/lib/documents.lib.php @@ -453,7 +453,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str if (is_array($documentQRCode) && !empty($documentQRCode)) { $documentQRCode = array_shift($documentQRCode); } else { - $QRCode->url = $documenturl . '?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''); + $QRCode->url = DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''); $QRCode->encoded_qr_code = $QRCode->getQRCodeBase64($QRCode->url); $QRCode->status = 1; $QRCode->module_name = $modulepart; diff --git a/lib/saturne.lib.php b/lib/saturne.lib.php index 7b7a3be3..767bc574 100644 --- a/lib/saturne.lib.php +++ b/lib/saturne.lib.php @@ -53,7 +53,7 @@ function saturne_admin_prepare_head(): array $head[$h][2] = 'information'; $h++; - $head[$h][0] = dol_buildpath('/saturne/admin/qrcode.php', 1) . '?filename=saturne_dev&tab_name=qrcode'; + $head[$h][0] = dol_buildpath('/saturne/admin/qrcode.php', 1); $head[$h][1] = '' . $langs->trans('QRCode'); $head[$h][2] = 'qrcode'; $h++;