From 66b1a36a1dda59b092a5a82ac1a4fa8db1275ba7 Mon Sep 17 00:00:00 2001
From: Antoine M
Date: Tue, 21 May 2024 10:45:26 +0200
Subject: [PATCH] updating form functionnality
---
includes/forms/_garbagecode.php | 47 ++++++++++++
includes/forms/field-OrderDocumentsList.php | 72 ++++++++-----------
.../forms/template-field-order-brochures.php | 5 +-
.../forms/template-field-order-documents.php | 17 ++---
resources/css/components/forms.css | 24 +++++--
5 files changed, 106 insertions(+), 59 deletions(-)
create mode 100644 includes/forms/_garbagecode.php
diff --git a/includes/forms/_garbagecode.php b/includes/forms/_garbagecode.php
new file mode 100644
index 0000000..d5c270a
--- /dev/null
+++ b/includes/forms/_garbagecode.php
@@ -0,0 +1,47 @@
+ $document) : ?>
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/includes/forms/field-OrderDocumentsList.php b/includes/forms/field-OrderDocumentsList.php
index 1c5d55a..86d3d67 100644
--- a/includes/forms/field-OrderDocumentsList.php
+++ b/includes/forms/field-OrderDocumentsList.php
@@ -5,46 +5,30 @@ if (class_exists('GF_Field')) {
{
public $type = 'order_documents_list';
- public $choices = [
- ['text' => 'Synthèse des primes'],
- ['text' => 'Publication 2'],
- ['text' => 'Publication 3'],
- ];
-
- // public $choices = [
- // [
- // 'text' => 'Synthèse des primes',
- // 'slug' => "the post name",
- // 'ID' => 24
- // ],
- // [
- // 'text' => 'Document 2',
- // 'slug' => "the post name",
- // 'ID' => 24
- // ],
-
- // ];
-
- private function buildChoices()
+ private function buildChoicesArray()
{
- $choices = [
+ $posts_array = [
[
'text' => 'La synthèse des primes',
- 'description' => __("Ce document informe sur les incitants financiers à l’achat et à la rénovation des logements en Région de Bruxelles-Capitale, dont les primes RENOLUTION, le crédit ECORENO, la subvention petit patrimoine, la prime gaz, les certificats verts...", "homegrade-theme__texte-fonctionnel"),
- 'slug' => "the post name",
- 'ID' => 24
+ 'ID_fr' => 7153,
+ 'ID_nl' => 7157,
],
- [
- 'text' => 'Document 2',
- 'slug' => "the post name",
- 'ID' => 24
- ],
-
];
+ $currentLang = apply_filters('wpml_current_language', null);
- $this->choices = $choices;
+
+ foreach ($posts_array as $post) {
+ $id = $currentLang === 'nl' ? $post['ID_nl'] : $post['ID_fr'];
+
+ $choices[] = [
+ 'title' => get_the_title($id),
+ 'ID' => $id,
+ ];
+ }
+
+ return $choices;
}
public function get_form_editor_field_title()
@@ -125,31 +109,31 @@ if (class_exists('GF_Field')) {
}
- private function PrettyListBrochureOrder($value)
+ private function PrettyListDocumentOrder($value)
{
- $brochureOrderPreviewHtml = '';
+ $documentOrderPreviewHtml = '';
foreach ($value as $brochure => $quantities) {
- $brochureOrderAmount = null;
+ $documentOrderAmountHtml = null;
if ($quantities["quantity_fr"]) {
- $brochureOrderAmount .= '- ' . __("Quantité FR: ", "homegrade-theme__texte-fonctionnel") . '' . $quantities["quantity_fr"] . '
';
+ $documentOrderAmountHtml .= '- ' . __("Quantité FR: ", "homegrade-theme__texte-fonctionnel") . '' . $quantities["quantity_fr"] . '
';
}
if ($quantities["quantity_nl"]) {
- $brochureOrderAmount .= '- ' . __("Quantité NL: ", "homegrade-theme__texte-fonctionnel") . '' . $quantities["quantity_nl"] . '
';
+ $documentOrderAmountHtml .= '- ' . __("Quantité NL: ", "homegrade-theme__texte-fonctionnel") . '' . $quantities["quantity_nl"] . '
';
}
- if (!$brochureOrderAmount) continue;
+ if (!$documentOrderAmountHtml) continue;
- if (!empty($brochureOrderAmount)) {
- $brochureOrderPreviewHtml .= '' . $brochure . '
' . $brochureOrderAmount . '
';
+ if (!empty($documentOrderAmountHtml)) {
+ $documentOrderPreviewHtml .= '' . $brochure . '
' . $documentOrderAmountHtml . '
';
}
}
- $brochureOrderPreviewHtml .= '
';
- return $brochureOrderPreviewHtml;
+ $documentOrderPreviewHtml .= '
';
+ return $documentOrderPreviewHtml;
}
@@ -164,14 +148,14 @@ if (class_exists('GF_Field')) {
if (empty($value)) {
return;
}
- $str = $this->PrettyListBrochureOrder($value);
+ $str = $this->PrettyListDocumentOrder($value);
return $str;
}
public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br)
{
- return $this->PrettyListBrochureOrder($value);
+ return $this->PrettyListDocumentOrder($value);
}
}
GF_Fields::register(new OrderDocumentList());
diff --git a/includes/forms/template-field-order-brochures.php b/includes/forms/template-field-order-brochures.php
index c344826..bb0e741 100644
--- a/includes/forms/template-field-order-brochures.php
+++ b/includes/forms/template-field-order-brochures.php
@@ -10,6 +10,7 @@
term_id);
+ $brochure_pdf_link = get_field('brochure_pdf', $brochurePost['ID']);
?>
@@ -22,7 +23,9 @@
name ?>
-
+
+
+