amelioration du systeme de filtre, pour gerer au mieux les inconnues
This commit is contained in:
parent
8fe52051d3
commit
f41d6a6e8b
2 changed files with 11 additions and 9 deletions
|
@ -23,18 +23,20 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
|||
*
|
||||
* @return String valeur modifiée ou pas par le filtre
|
||||
*/
|
||||
function gamufiltre($objet, $champ, $valeur) {
|
||||
function gamufiltre($objet, $champ, $ligne) {
|
||||
$valeur = $ligne[$champ] ?? '';
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if (
|
||||
$champ_tab = $s['gamutable']['champ'] ?? $s['options']['nom']
|
||||
(!empty($s['gamutable']) or !empty($s['options']))
|
||||
and $champ_tab = $s['gamutable']['champ'] ?? $s['options']['nom']
|
||||
and $champ_tab === $champ
|
||||
and !empty($s['gamutable']['fonction'])
|
||||
) {
|
||||
$filtre = $s['gamutable']['fonction'];
|
||||
return $filtre($valeur) ?? '';
|
||||
return $filtre($valeur ?: $ligne) ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,17 +245,17 @@ function gamuform_recup_valeurs($objet, $id_objet = 0):array {
|
|||
if (gamuform_objet_autoriser($objet)) {
|
||||
$table = table_objet_sql($objet);
|
||||
$id = id_table_objet($objet);
|
||||
$s = gamuform_recup_champs_gamutable($objet);
|
||||
// $s = gamuform_recup_champs_gamutable($objet);
|
||||
|
||||
$s[] = $id;
|
||||
// $s[] = $id;
|
||||
if (intval($id_objet)) {
|
||||
$valeurs = sql_fetsel($s, $table, "$id=".intval($id_objet));
|
||||
$valeurs = sql_fetsel('*', $table, "$id=".intval($id_objet));
|
||||
$valeurs['id'] = $valeurs[$id];
|
||||
if (!empty($valeurs)) {
|
||||
$r[0] = $valeurs;
|
||||
}
|
||||
} else {
|
||||
$T = sql_allfetsel($s, $table, 1);
|
||||
$T = sql_allfetsel('*', $table, 1);
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $t) {
|
||||
$t['id'] = $t[$id];
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
"id": #GET{ligne/id},
|
||||
"edit": [(#GET{edit}|json_encode)],
|
||||
<BOUCLE_champsA(DATA){source table,#GET{champs}}>
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|json_encode)],
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne}}|json_encode)],
|
||||
</BOUCLE_champsA>
|
||||
"sup": [(#GET{sup}|json_encode)]
|
||||
},
|
||||
|
@ -65,7 +65,7 @@
|
|||
"id": #GET{ligne/id},
|
||||
"edit": "",
|
||||
<BOUCLE_champsB(DATA){source table,#GET{champs}}>
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|textebrut|json_encode)],
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne}}|textebrut|json_encode)],
|
||||
</BOUCLE_champsB>
|
||||
"sup":""
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue