Correction identité membre dans formulaire

This commit is contained in:
Jean-Christophe Engel 2024-09-10 15:37:22 +02:00
parent 57e6ad09f9
commit da713cc06d

View File

@ -4,6 +4,28 @@ namespace Paheko;
require_once __DIR__ . '/_inc.php'; 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'])) { if (!isset($target) || !in_array( $target, ['new', 'edit'])) {
throw new Exception('blabla illegal call'); // Fix: exception type? throw new Exception('blabla illegal call'); // Fix: exception type?
} else { } else {
@ -301,9 +323,8 @@ $date = new \DateTime;
$date->setTimestamp(time()); $date->setTimestamp(time());
$tpl->assign('date', $date->format('d/m/Y')); $tpl->assign('date', $date->format('d/m/Y'));
$tpl->assign(compact('liste', 'radio', 'step', 'designations', 'prix', 'from_user', 'identite', 'csrf_key', 'doc')); $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('clients', $db->getAssoc('SELECT id, nom FROM plugin_facturation_clients;'));
$tpl->assign('require_number', $require_number); $tpl->assign('require_number', $require_number);
$tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]); $tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]);