From da713cc06d99875f468e011690a3578b352757c2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Tue, 10 Sep 2024 15:37:22 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20identit=C3=A9=20membre=20dans=20fo?= =?UTF-8?q?rmulaire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/_facture_common.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/admin/_facture_common.php b/admin/_facture_common.php index ecc0c30..10b10a4 100644 --- a/admin/_facture_common.php +++ b/admin/_facture_common.php @@ -4,6 +4,28 @@ namespace Paheko; require_once __DIR__ . '/_inc.php'; +function toArray($array, $cle, $sep=",") +{ + $result = array(); + foreach ($array as $elem) + { + $ro = new \ReflectionObject($elem); + $proprietes = $ro->getProperties(); + $ligne = ""; + foreach ($proprietes as $p) + { + if ($p->getName() == $cle) { + $key = $p->getValue($elem); + } + else { + $ligne .= $sep . $p->getValue($elem); + } + } + $result[$key] = substr($ligne, strlen($sep)); + } + return $result; +} + if (!isset($target) || !in_array( $target, ['new', 'edit'])) { throw new Exception('blabla illegal call'); // Fix: exception type? } else { @@ -301,9 +323,8 @@ $date = new \DateTime; $date->setTimestamp(time()); $tpl->assign('date', $date->format('d/m/Y')); - $tpl->assign(compact('liste', 'radio', 'step', 'designations', 'prix', 'from_user', 'identite', 'csrf_key', 'doc')); -$tpl->assign('users', $db->getAssoc('SELECT id, '.$identite.' FROM users WHERE id_category != -2 NOT IN (SELECT id FROM users_categories WHERE hidden = 1) ORDER BY ' .$identite. ';')); +$tpl->assign('users', toArray($db->get('SELECT id, '.$identite.' FROM users WHERE id_category != -2 NOT IN (SELECT id FROM users_categories WHERE hidden = 1) ORDER BY ' .$identite. ';'), 'id', " ")); $tpl->assign('clients', $db->getAssoc('SELECT id, nom FROM plugin_facturation_clients;')); $tpl->assign('require_number', $require_number); $tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]);