Loading src/UnicaenAutoform/Entity/Db/FormulaireInstance.php +17 −16 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ class FormulaireInstance implements HistoriqueAwareInterface { return $text; } public function fetchChampReponseByMotsClefs(array $mots, bool $displayIfEmpty = true) : string public function fetchChampReponseByMotsClefs(array $mots, bool $displayLibelle = true) : string { $champs = $this->getFormulaire()->getChamps(); $champToLookFor = null; Loading @@ -126,19 +126,19 @@ class FormulaireInstance implements HistoriqueAwareInterface { $champ = $reponse?->getChamp(); if ($champ?->hasMotsClefs($mots) AND $reponse->estNonHistorise()) { $type = $champ?->getType(); if ($type?->getCode() === Champ::TYPE_ANNEE) return ChampAsResultHelper::render_annee($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_CUSTOM) return ChampAsResultHelper::render_custom($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_FORMATION) return ChampAsResultHelper::render_formation($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_MULTIPLE) return ChampAsResultHelper::render_multiple($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_NOMBRE) return ChampAsResultHelper::render_nombre($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_PERIODE) return ChampAsResultHelper::render_periode($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_SELECT) return ChampAsResultHelper::render_select($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_SELECT_TEXT) return ChampAsResultHelper::render_select_text($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_TEXT) return ChampAsResultHelper::render_text($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_TEXTAREA) return ChampAsResultHelper::render_textarea($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_PLUS_TEXTE) return ChampAsResultHelper::render_plus_text($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_PLUS_CUSTOM) return ChampAsResultHelper::render_plus_custom($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_ANNEE) return ChampAsResultHelper::render_annee($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_CUSTOM) return ChampAsResultHelper::render_custom($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_FORMATION) return ChampAsResultHelper::render_formation($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_MULTIPLE) return ChampAsResultHelper::render_multiple($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_NOMBRE) return ChampAsResultHelper::render_nombre($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_PERIODE) return ChampAsResultHelper::render_periode($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_SELECT) return ChampAsResultHelper::render_select($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_SELECT_TEXT) return ChampAsResultHelper::render_select_text($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_TEXT) return ChampAsResultHelper::render_text($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_TEXTAREA) return ChampAsResultHelper::render_textarea($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_PLUS_TEXTE) return ChampAsResultHelper::render_plus_text($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_PLUS_CUSTOM) return ChampAsResultHelper::render_plus_custom($champ, $reponse?->getReponse(),$displayLibelle); if ($reponse->getChamp()->getType()->getCode() !== 'Multiple') return $reponse->getReponse(); else { return str_replace('on_','',$reponse->getReponse()); Loading @@ -147,8 +147,9 @@ class FormulaireInstance implements HistoriqueAwareInterface { } //cas spécial les checkbox reviennent avec null du coup si une checkbox faut renvoyer vers if ($champToLookFor->getType()->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champToLookFor, null); return "<span class='input-libelle'>".$champToLookFor->getLibelle()." :</span> ".ChampAsResultHelper::AUCUNE_REPONSE; if ($champToLookFor->getType()->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champToLookFor, null,$displayLibelle); if ($displayLibelle) return "<span class='input-libelle'>".$champToLookFor->getLibelle()." :</span> ".ChampAsResultHelper::AUCUNE_REPONSE; return ChampAsResultHelper::AUCUNE_REPONSE; } public function fetchChampsReponseByMotsClefs(array $mots) : string Loading src/UnicaenAutoform/View/Helper/ChampAsResultHelper.php +43 −66 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ class ChampAsResultHelper extends AbstractHelper const AUCUNE_REPONSE = "<span class='missing-data'> Aucune réponse </span>"; const NO_RESULT = [Champ::TYPE_LABEL, Champ::TYPE_SPACER, Champ::TYPE_CHECKBOX]; public function render(Champ $champ, $data = null, ?DateTime $date = null, bool $displayIfEmpty = true): string public function render(Champ $champ, $data = null, ?DateTime $date = null, bool $displayIfEmpty = true, bool $displayLibelle = true): string { $a = 1; if ($data === null and !in_array($champ->getType()->getCode(), self::NO_RESULT)) Loading @@ -44,33 +44,33 @@ class ChampAsResultHelper extends AbstractHelper case Champ::TYPE_ANNEE : return self::render_annee($champ, $data); return self::render_annee($champ, $data, $displayLibelle); case Champ::TYPE_CHECKBOX : return self::render_checkbox($champ, $data); return self::render_checkbox($champ, $data, $displayLibelle); case Champ::TYPE_CUSTOM : return self::render_custom($champ, $data); return self::render_custom($champ, $data, $displayLibelle); case Champ::TYPE_FORMATION : return self::render_formation($champ, $data); return self::render_formation($champ, $data, $displayLibelle); case Champ::TYPE_MULTIPLE : return self::render_multiple($champ, $data); return self::render_multiple($champ, $data, $displayLibelle); case Champ::TYPE_MULTIPLE_TEXT : return self::render_multiple_text($champ, $data); return self::render_multiple_text($champ, $data, $displayLibelle); case Champ::TYPE_NOMBRE : return self::render_nombre($champ, $data); return self::render_nombre($champ, $data, $displayLibelle); case Champ::TYPE_PERIODE : return self::render_periode($champ, $data); return self::render_periode($champ, $data, $displayLibelle); case Champ::TYPE_PLUS_TEXTE : return self::render_plus_text($champ, $data); return self::render_plus_text($champ, $data, $displayLibelle); case Champ::TYPE_PLUS_CUSTOM : return self::render_plus_custom($champ, $data); return self::render_plus_custom($champ, $data, $displayLibelle); case Champ::TYPE_SELECT : return self::render_select($champ, $data); return self::render_select($champ, $data, $displayLibelle); case Champ::TYPE_SELECT_TEXT : return self::render_select_text($champ, $data); return self::render_select_text($champ, $data, $displayLibelle); case Champ::TYPE_TEXT : return self::render_text($champ, $data); return self::render_text($champ, $data, $displayLibelle); case Champ::TYPE_TEXTAREA : return self::render_textarea($champ, $data); return self::render_textarea($champ, $data, $displayLibelle); case Champ::TYPE_ENTITY : //todo gerer le problème de champService Loading Loading @@ -110,63 +110,44 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_annee(Champ $champ, ?string $reponse): string static public function render_annee(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_ANNEE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_checkbox(Champ $champ, ?string $reponse): string static public function render_checkbox(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_CHECKBOX . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; $texte .= ($reponse === null)?"Non":"Oui"; $texte .= "</div>"; return $texte; } //todo ici on a un problème car on ne pourra pas récupérer le service depuis FormulaireInstance ... static public function render_entity(Champ $champ, ?string $reponse, ?ChampService $champService): string { $options = $champService->getAllInstance($champ->getOptions()); $reponse = "NOT FOUND !!!"; foreach ($options as $id => $option) { if ($id == $reponse) { $reponse = $option; break; } } $texte = "<div data-champ-type='" . Champ::TYPE_ENTITY . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_formation(Champ $champ, ?string $reponse): string static public function render_formation(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $split = explode("|",$reponse); $text = (count($split) === 2)?$split[0]:""; $select = (count($split) === 2)?$split[1]:""; $texte = "<div data-champ-type='" . Champ::TYPE_FORMATION . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($champ->getTexte() !== 'Échéance') $texte .= $text . " sur la période ".$select; else $texte .= $text . " à l'échéance ".$select; $texte .= "</div>"; return $texte; } static public function render_multiple(Champ $champ, ?string $reponse): string static public function render_multiple(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $splits = explode(";", (string) $reponse); $texte = "<div data-champ-type='" . Champ::TYPE_MULTIPLE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= "<ul>"; foreach ($splits as $split) { $resplits = str_replace("_"," ",substr($split,3)); Loading @@ -177,12 +158,12 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_multiple_text(Champ $champ, ?string $reponse): string static public function render_multiple_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $splits = explode(";", (string) $reponse); $texte = "<div data-champ-type='" . Champ::TYPE_MULTIPLE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= "<ul>"; foreach ($splits as $split) { $resplits = str_replace("_"," ",substr($split,3)); Loading @@ -194,34 +175,34 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_nombre(Champ $champ, ?string $reponse): string static public function render_nombre(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_NOMBRE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_periode(Champ $champ, ?string $reponse): string static public function render_periode(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_PERIODE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_select(Champ $champ, ?string $reponse): string static public function render_select(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_SELECT_TEXT . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_select_text(Champ $champ, ?string $reponse): string static public function render_select_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { [$select, $text] = explode(":::", (string) $reponse); Loading @@ -230,39 +211,35 @@ class ChampAsResultHelper extends AbstractHelper } $texte = "<div data-champ-type='" . Champ::TYPE_SELECT . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $select; if ($text) $texte .= "<br><span class='input-sublibelle'>Complément :</span> " . $text; $texte .= "</div>"; return $texte; } static public function render_text(Champ $champ, ?string $reponse): string static public function render_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_TEXT . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_textarea(Champ $champ, ?string $reponse): string static public function render_textarea(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_TEXTAREA . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_plus_text(Champ $champ, ?string $reponse): string static public function render_plus_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_PLUS_CUSTOM . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($champ->getTexte()) $texte .= "<br>" . $champ->getTexte(); $reponses = explode(Champ::SEPARATOR_PLUS_CUSTOM_FIELD, $reponse); Loading @@ -273,7 +250,7 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_custom(Champ $champ, ?string $reponse): string static public function render_custom(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $fields = explode(';', $champ->getOptions()); Loading @@ -284,7 +261,7 @@ class ChampAsResultHelper extends AbstractHelper } $texte = "<div data-champ-type='" . Champ::TYPE_PLUS_CUSTOM . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; $texte .= "<ul>"; $splits = explode(Champ::SEPARATOR_PLUS_CUSTOM_FIELD, $reponse); Loading @@ -304,7 +281,7 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_plus_custom(Champ $champ, ?string $reponse): string static public function render_plus_custom(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $fields = explode(';', $champ->getOptions()); Loading @@ -316,7 +293,7 @@ class ChampAsResultHelper extends AbstractHelper $reponses = explode(Champ::SEPARATOR_PLUS_CUSTOM_GROUP, (string)$reponse); $texte = "<div data-champ-type='" . Champ::TYPE_PLUS_CUSTOM . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; $texte .= "<ol>"; foreach ($reponses as $item) { $texte .= "<li>"; Loading Loading
src/UnicaenAutoform/Entity/Db/FormulaireInstance.php +17 −16 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ class FormulaireInstance implements HistoriqueAwareInterface { return $text; } public function fetchChampReponseByMotsClefs(array $mots, bool $displayIfEmpty = true) : string public function fetchChampReponseByMotsClefs(array $mots, bool $displayLibelle = true) : string { $champs = $this->getFormulaire()->getChamps(); $champToLookFor = null; Loading @@ -126,19 +126,19 @@ class FormulaireInstance implements HistoriqueAwareInterface { $champ = $reponse?->getChamp(); if ($champ?->hasMotsClefs($mots) AND $reponse->estNonHistorise()) { $type = $champ?->getType(); if ($type?->getCode() === Champ::TYPE_ANNEE) return ChampAsResultHelper::render_annee($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_CUSTOM) return ChampAsResultHelper::render_custom($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_FORMATION) return ChampAsResultHelper::render_formation($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_MULTIPLE) return ChampAsResultHelper::render_multiple($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_NOMBRE) return ChampAsResultHelper::render_nombre($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_PERIODE) return ChampAsResultHelper::render_periode($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_SELECT) return ChampAsResultHelper::render_select($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_SELECT_TEXT) return ChampAsResultHelper::render_select_text($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_TEXT) return ChampAsResultHelper::render_text($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_TEXTAREA) return ChampAsResultHelper::render_textarea($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_PLUS_TEXTE) return ChampAsResultHelper::render_plus_text($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_PLUS_CUSTOM) return ChampAsResultHelper::render_plus_custom($champ, $reponse?->getReponse()); if ($type?->getCode() === Champ::TYPE_ANNEE) return ChampAsResultHelper::render_annee($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_CUSTOM) return ChampAsResultHelper::render_custom($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_FORMATION) return ChampAsResultHelper::render_formation($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_MULTIPLE) return ChampAsResultHelper::render_multiple($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_NOMBRE) return ChampAsResultHelper::render_nombre($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_PERIODE) return ChampAsResultHelper::render_periode($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_SELECT) return ChampAsResultHelper::render_select($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_SELECT_TEXT) return ChampAsResultHelper::render_select_text($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_TEXT) return ChampAsResultHelper::render_text($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_TEXTAREA) return ChampAsResultHelper::render_textarea($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_PLUS_TEXTE) return ChampAsResultHelper::render_plus_text($champ, $reponse?->getReponse(),$displayLibelle); if ($type?->getCode() === Champ::TYPE_PLUS_CUSTOM) return ChampAsResultHelper::render_plus_custom($champ, $reponse?->getReponse(),$displayLibelle); if ($reponse->getChamp()->getType()->getCode() !== 'Multiple') return $reponse->getReponse(); else { return str_replace('on_','',$reponse->getReponse()); Loading @@ -147,8 +147,9 @@ class FormulaireInstance implements HistoriqueAwareInterface { } //cas spécial les checkbox reviennent avec null du coup si une checkbox faut renvoyer vers if ($champToLookFor->getType()->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champToLookFor, null); return "<span class='input-libelle'>".$champToLookFor->getLibelle()." :</span> ".ChampAsResultHelper::AUCUNE_REPONSE; if ($champToLookFor->getType()->getCode() === Champ::TYPE_CHECKBOX) return ChampAsResultHelper::render_checkbox($champToLookFor, null,$displayLibelle); if ($displayLibelle) return "<span class='input-libelle'>".$champToLookFor->getLibelle()." :</span> ".ChampAsResultHelper::AUCUNE_REPONSE; return ChampAsResultHelper::AUCUNE_REPONSE; } public function fetchChampsReponseByMotsClefs(array $mots) : string Loading
src/UnicaenAutoform/View/Helper/ChampAsResultHelper.php +43 −66 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ class ChampAsResultHelper extends AbstractHelper const AUCUNE_REPONSE = "<span class='missing-data'> Aucune réponse </span>"; const NO_RESULT = [Champ::TYPE_LABEL, Champ::TYPE_SPACER, Champ::TYPE_CHECKBOX]; public function render(Champ $champ, $data = null, ?DateTime $date = null, bool $displayIfEmpty = true): string public function render(Champ $champ, $data = null, ?DateTime $date = null, bool $displayIfEmpty = true, bool $displayLibelle = true): string { $a = 1; if ($data === null and !in_array($champ->getType()->getCode(), self::NO_RESULT)) Loading @@ -44,33 +44,33 @@ class ChampAsResultHelper extends AbstractHelper case Champ::TYPE_ANNEE : return self::render_annee($champ, $data); return self::render_annee($champ, $data, $displayLibelle); case Champ::TYPE_CHECKBOX : return self::render_checkbox($champ, $data); return self::render_checkbox($champ, $data, $displayLibelle); case Champ::TYPE_CUSTOM : return self::render_custom($champ, $data); return self::render_custom($champ, $data, $displayLibelle); case Champ::TYPE_FORMATION : return self::render_formation($champ, $data); return self::render_formation($champ, $data, $displayLibelle); case Champ::TYPE_MULTIPLE : return self::render_multiple($champ, $data); return self::render_multiple($champ, $data, $displayLibelle); case Champ::TYPE_MULTIPLE_TEXT : return self::render_multiple_text($champ, $data); return self::render_multiple_text($champ, $data, $displayLibelle); case Champ::TYPE_NOMBRE : return self::render_nombre($champ, $data); return self::render_nombre($champ, $data, $displayLibelle); case Champ::TYPE_PERIODE : return self::render_periode($champ, $data); return self::render_periode($champ, $data, $displayLibelle); case Champ::TYPE_PLUS_TEXTE : return self::render_plus_text($champ, $data); return self::render_plus_text($champ, $data, $displayLibelle); case Champ::TYPE_PLUS_CUSTOM : return self::render_plus_custom($champ, $data); return self::render_plus_custom($champ, $data, $displayLibelle); case Champ::TYPE_SELECT : return self::render_select($champ, $data); return self::render_select($champ, $data, $displayLibelle); case Champ::TYPE_SELECT_TEXT : return self::render_select_text($champ, $data); return self::render_select_text($champ, $data, $displayLibelle); case Champ::TYPE_TEXT : return self::render_text($champ, $data); return self::render_text($champ, $data, $displayLibelle); case Champ::TYPE_TEXTAREA : return self::render_textarea($champ, $data); return self::render_textarea($champ, $data, $displayLibelle); case Champ::TYPE_ENTITY : //todo gerer le problème de champService Loading Loading @@ -110,63 +110,44 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_annee(Champ $champ, ?string $reponse): string static public function render_annee(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_ANNEE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_checkbox(Champ $champ, ?string $reponse): string static public function render_checkbox(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_CHECKBOX . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; $texte .= ($reponse === null)?"Non":"Oui"; $texte .= "</div>"; return $texte; } //todo ici on a un problème car on ne pourra pas récupérer le service depuis FormulaireInstance ... static public function render_entity(Champ $champ, ?string $reponse, ?ChampService $champService): string { $options = $champService->getAllInstance($champ->getOptions()); $reponse = "NOT FOUND !!!"; foreach ($options as $id => $option) { if ($id == $reponse) { $reponse = $option; break; } } $texte = "<div data-champ-type='" . Champ::TYPE_ENTITY . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_formation(Champ $champ, ?string $reponse): string static public function render_formation(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $split = explode("|",$reponse); $text = (count($split) === 2)?$split[0]:""; $select = (count($split) === 2)?$split[1]:""; $texte = "<div data-champ-type='" . Champ::TYPE_FORMATION . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($champ->getTexte() !== 'Échéance') $texte .= $text . " sur la période ".$select; else $texte .= $text . " à l'échéance ".$select; $texte .= "</div>"; return $texte; } static public function render_multiple(Champ $champ, ?string $reponse): string static public function render_multiple(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $splits = explode(";", (string) $reponse); $texte = "<div data-champ-type='" . Champ::TYPE_MULTIPLE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= "<ul>"; foreach ($splits as $split) { $resplits = str_replace("_"," ",substr($split,3)); Loading @@ -177,12 +158,12 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_multiple_text(Champ $champ, ?string $reponse): string static public function render_multiple_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $splits = explode(";", (string) $reponse); $texte = "<div data-champ-type='" . Champ::TYPE_MULTIPLE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= "<ul>"; foreach ($splits as $split) { $resplits = str_replace("_"," ",substr($split,3)); Loading @@ -194,34 +175,34 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_nombre(Champ $champ, ?string $reponse): string static public function render_nombre(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_NOMBRE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_periode(Champ $champ, ?string $reponse): string static public function render_periode(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_PERIODE . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " ?</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_select(Champ $champ, ?string $reponse): string static public function render_select(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_SELECT_TEXT . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_select_text(Champ $champ, ?string $reponse): string static public function render_select_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { [$select, $text] = explode(":::", (string) $reponse); Loading @@ -230,39 +211,35 @@ class ChampAsResultHelper extends AbstractHelper } $texte = "<div data-champ-type='" . Champ::TYPE_SELECT . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $select; if ($text) $texte .= "<br><span class='input-sublibelle'>Complément :</span> " . $text; $texte .= "</div>"; return $texte; } static public function render_text(Champ $champ, ?string $reponse): string static public function render_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_TEXT . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_textarea(Champ $champ, ?string $reponse): string static public function render_textarea(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_TEXTAREA . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span> "; $texte .= $reponse; $texte .= "</div>"; return $texte; } static public function render_plus_text(Champ $champ, ?string $reponse): string static public function render_plus_text(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $texte = "<div data-champ-type='" . Champ::TYPE_PLUS_CUSTOM . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($champ->getTexte()) $texte .= "<br>" . $champ->getTexte(); $reponses = explode(Champ::SEPARATOR_PLUS_CUSTOM_FIELD, $reponse); Loading @@ -273,7 +250,7 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_custom(Champ $champ, ?string $reponse): string static public function render_custom(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $fields = explode(';', $champ->getOptions()); Loading @@ -284,7 +261,7 @@ class ChampAsResultHelper extends AbstractHelper } $texte = "<div data-champ-type='" . Champ::TYPE_PLUS_CUSTOM . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; $texte .= "<ul>"; $splits = explode(Champ::SEPARATOR_PLUS_CUSTOM_FIELD, $reponse); Loading @@ -304,7 +281,7 @@ class ChampAsResultHelper extends AbstractHelper return $texte; } static public function render_plus_custom(Champ $champ, ?string $reponse): string static public function render_plus_custom(Champ $champ, ?string $reponse, bool $displayLibelle=true): string { $fields = explode(';', $champ->getOptions()); Loading @@ -316,7 +293,7 @@ class ChampAsResultHelper extends AbstractHelper $reponses = explode(Champ::SEPARATOR_PLUS_CUSTOM_GROUP, (string)$reponse); $texte = "<div data-champ-type='" . Champ::TYPE_PLUS_CUSTOM . "' data-empty='false'>"; $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; if ($displayLibelle) $texte .= "<span class='input-libelle' >" . $champ->getLibelle() . " :</span>"; $texte .= "<ol>"; foreach ($reponses as $item) { $texte .= "<li>"; Loading