Overview
Comment:Amélioration recherche
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e89a17318ac64d8939562b6d5a346996eb046f4e
User & Date: bohwaz on 2013-01-30 14:53:30
Other Links: manifest | tags
Context
2013-01-30
15:19
Ajout de membre en utilisant les champs personnalisés check-in: 3b9b01fecb user: bohwaz tags: trunk
14:53
Amélioration recherche check-in: e89a17318a user: bohwaz tags: trunk
2013-01-29
19:01
Ajout option list_row pour gérer le tableau de liste des membres check-in: 4dfcbdc0cb user: bohwaz tags: trunk
Changes

Modified include/class.membres.php from [7a8f852d64] to [04d094b864].

426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448







449
450
451
452
453
454
455
456
457
    }

    public function search($field, $query)
    {
        $db = DB::getInstance();
        $champs = Config::getInstance()->get('champs_membres');

        if (!$champs->get($field))
        {
            throw new \UnexpectedValue($field . ' is not a valid field');
        }

        if (!$champs->isText($field))
        {
            $where = 'WHERE '.$field.' = \''.$db->escapeString($query).'\'';
            $order = $field;
        }
        else
        {
            $where = 'WHERE transliterate_to_ascii('.$field.') LIKE transliterate_to_ascii(\'%'.$db->escapeString($query).'%\')';
            $order = 'transliterate_to_ascii('.$field.') COLLATE NOCASE';
        }








        return $db->simpleStatementFetch(
            'SELECT id, id_categorie, nom, email, code_postal, ville,
                strftime(\'%s\', date_cotisation) AS date_cotisation,
                strftime(\'%s\', date_inscription) AS date_inscription
                FROM membres '.$where.'
                ORDER BY '.$order.' LIMIT 100;',
            SQLITE3_ASSOC
        );
    }







|

|













>
>
>
>
>
>
>

|







426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
    }

    public function search($field, $query)
    {
        $db = DB::getInstance();
        $champs = Config::getInstance()->get('champs_membres');

        if ($field != 'id' && !$champs->get($field))
        {
            throw new \UnexpectedValueException($field . ' is not a valid field');
        }

        if (!$champs->isText($field))
        {
            $where = 'WHERE '.$field.' = \''.$db->escapeString($query).'\'';
            $order = $field;
        }
        else
        {
            $where = 'WHERE transliterate_to_ascii('.$field.') LIKE transliterate_to_ascii(\'%'.$db->escapeString($query).'%\')';
            $order = 'transliterate_to_ascii('.$field.') COLLATE NOCASE';
        }

        $fields = array_keys($champs->getListedFields());

        if (!in_array($field, $fields))
        {
            $fields[] = $field;
        }

        return $db->simpleStatementFetch(
            'SELECT id, id_categorie, ' . implode(', ', $fields) . ',
                strftime(\'%s\', date_cotisation) AS date_cotisation,
                strftime(\'%s\', date_inscription) AS date_inscription
                FROM membres '.$where.'
                ORDER BY '.$order.' LIMIT 100;',
            SQLITE3_ASSOC
        );
    }

Modified templates/admin/membres/recherche.tpl from [32ee66a7f3] to [f1c4c1fe3e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32




33


34
35
36
37
38
39
40
41




42


43
44
45
46
47
48
49
{include file="admin/_head.tpl" title="Recherche de membre" current="membres"}

<form method="get" action="{$admin_url}membres/recherche.php" class="searchMember">
    <fieldset>
        <legend>Rechercher un membre</legend>
        <dl>
            <dt><label for="f_champ">Champ</label></dt>
            <dd>
                <select name="c" id="f_champ">
                    {foreach from=$champs key="k" item="v"}
                    <option value="{$k|escape}"{form_field name="c" default=$champ selected=$k}>{$v.title|escape}</option>
                    {/foreach}
                </select>
            </dd>
            <dt><label for="f_texte">Recherche</label></dt>
            <dd><input id="f_texte" type="text" name="r" value="{$recherche|escape}" /></dd>
        </dl>
        <p class="submit">
            <input type="submit" value="Chercher &rarr;" />
        </p>
    </fieldset>
</form>

{if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}

    <form method="post" action="{$admin_url}membres/action.php" class="memberList">

    {if !empty($liste)}
    <table class="list">
        <thead>
            {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" value="Tout cocher / décocher" onclick="checkUncheck();" /></td>{/if}
            <td></td>




            <td>{$titre_champ|escape}</td>


            <td>Cotisation</td>
            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" name="selected[]" value="{$membre.id|escape}" /></td>{/if}
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></th>




                    <td>{$membre[$champ]|escape}</td>


                    {if empty($membre.date_cotisation)}
                        <td class="error">jamais réglée</td>
                    {elseif $membre.date_cotisation > strtotime('12 months ago')}
                        <td class="confirm">à jour</td>
                    {else}
                        <td class="alert">en retard</td>
                    {/if}









|


















|



>
>
>
>
|
>
>








>
>
>
>
|
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{include file="admin/_head.tpl" title="Recherche de membre" current="membres"}

<form method="get" action="{$admin_url}membres/recherche.php" class="searchMember">
    <fieldset>
        <legend>Rechercher un membre</legend>
        <dl>
            <dt><label for="f_champ">Champ</label></dt>
            <dd>
                <select name="c" id="f_champ">
                    {foreach from=$champs_liste key="k" item="v"}
                    <option value="{$k|escape}"{form_field name="c" default=$champ selected=$k}>{$v.title|escape}</option>
                    {/foreach}
                </select>
            </dd>
            <dt><label for="f_texte">Recherche</label></dt>
            <dd><input id="f_texte" type="text" name="r" value="{$recherche|escape}" /></dd>
        </dl>
        <p class="submit">
            <input type="submit" value="Chercher &rarr;" />
        </p>
    </fieldset>
</form>

{if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}

    <form method="post" action="{$admin_url}membres/action.php" class="memberList">

    {if !empty($liste)}
    <table class="list search">
        <thead>
            {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" value="Tout cocher / décocher" onclick="checkUncheck();" /></td>{/if}
            <td></td>
            {foreach from=$champs_entete key="c" item="cfg"}
                {if $champ == $c}
                    <th><strong>{$cfg.title|escape}</strong></th>
                {else}
                    <td>{$cfg.title|escape}</td>
                {/if}
            {/foreach}
            <td>Cotisation</td>
            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" name="selected[]" value="{$membre.id|escape}" /></td>{/if}
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></th>
                    {foreach from=$champs_entete key="c" item="cfg"}
                        {if $champ == $c}
                            <th><strong>{$membre[$c]|escape}</strong></th>
                        {else}
                            <td>{$membre[$c]|escape}</td>
                        {/if}
                    {/foreach}
                    {if empty($membre.date_cotisation)}
                        <td class="error">jamais réglée</td>
                    {elseif $membre.date_cotisation > strtotime('12 months ago')}
                        <td class="confirm">à jour</td>
                    {else}
                        <td class="alert">en retard</td>
                    {/if}

Modified www/admin/membres/recherche.php from [81da42f2c3] to [0d2f3ccd0b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38



39


40










41
42
43
44
45
46
47
48
49
50
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$recherche = trim(utils::get('r')) ?: '';
$champ = trim(utils::get('c')) ?: '';

$champs = $config->get('champs_membres');

if (!$champ)
{
    if (is_numeric(trim($recherche))) {
        $champ = 'id';
    }
    elseif (strpos($recherche, '@') !== false) {
        $champ = 'email';
    }
    elseif ($champs->get('nom')) {
        $champ = 'nom';
    }
    else {
        $champ = $champs->getFirst();
    }
}
else
{
    if (!$champs->get($champ))
    {
        throw new UserException('Le champ demandé n\'existe pas.');
    }
}




$champs = array_merge(array('id' => array('title' => 'Numéro unique')), $champs->getList());













$tpl->assign('champs', $champs);
$tpl->assign('champ', $champ);
$tpl->assign('titre_champ', $champs[$champ]['title']);
$tpl->assign('liste', $membres->search($champ, $recherche));

$tpl->assign('recherche', $recherche);

$tpl->display('admin/membres/recherche.tpl');

?>










|
|




















|





>
>
>
|
>
>

>
>
>
>
>
>
>
>
>
>
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$recherche = trim(utils::get('r'));
$champ = trim(utils::get('c'));

$champs = $config->get('champs_membres');

if (!$champ)
{
    if (is_numeric(trim($recherche))) {
        $champ = 'id';
    }
    elseif (strpos($recherche, '@') !== false) {
        $champ = 'email';
    }
    elseif ($champs->get('nom')) {
        $champ = 'nom';
    }
    else {
        $champ = $champs->getFirst();
    }
}
else
{
    if ($champ != 'id' && !$champs->get($champ))
    {
        throw new UserException('Le champ demandé n\'existe pas.');
    }
}

$champs_liste = $champs->getList();

$champs_liste = array_merge(
    array('id' => array('title' => 'Numéro unique')),
    $champs_liste
);

$champs_entete = $champs->getListedFields();

if (!array_key_exists($champ, $champs_entete))
{
    $champs_entete = array_merge(
        array($champ => $champs_liste[$champ]),
        $champs_entete
    );
}

$tpl->assign('champs_entete', $champs_entete);
$tpl->assign('champs_liste', $champs_liste);
$tpl->assign('champ', $champ);
$tpl->assign('liste', $membres->search($champ, $recherche));

$tpl->assign('recherche', $recherche);

$tpl->display('admin/membres/recherche.tpl');

?>

Modified www/admin/static/admin.css from [77de133239] to [0d8a113d56].

339
340
341
342
343
344
345



346
347
348
349
350
351
352
    font-size: .9em;
}

table.list .check {
    width: 1%;
}





table.list thead .cur {
    background: rgb(217, 134, 40);
    color: #fff;
}

table.list thead th a, table.list thead td a {







>
>
>







339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
    font-size: .9em;
}

table.list .check {
    width: 1%;
}

table.search th {
    background: rgba(217, 134, 40, 0.5);
}

table.list thead .cur {
    background: rgb(217, 134, 40);
    color: #fff;
}

table.list thead th a, table.list thead td a {