Overview
Comment: | Implement export of search also for SQL search |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA3-256: |
4cd6bea2bb1147873bf432ff8bf10d1e |
User & Date: | bohwaz on 2022-04-04 01:22:22 |
Other Links: | branch diff | manifest | tags |
Context
2022-04-04
| ||
01:31 | Fix form autofocus check-in: a76de85f35 user: bohwaz tags: dev | |
01:22 | Implement export of search also for SQL search check-in: 4cd6bea2bb user: bohwaz tags: dev | |
01:14 | Implement export and pagination in search dynamic list check-in: 0385147488 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Entities/Search.php from [04cd8a1a66] to [10ca5327f1].
1 2 3 4 5 6 7 8 9 10 11 12 | <?php namespace Garradin\Entities; use Garradin\AdvancedSearch; use Garradin\DB; use Garradin\DynamicList; use Garradin\Entity; use Garradin\UserException; use Garradin\Accounting\AdvancedSearch as Accounting_AdvancedSearch; use Garradin\Users\AdvancedSearch as Users_AdvancedSearch; | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php namespace Garradin\Entities; use Garradin\AdvancedSearch; use Garradin\CSV; use Garradin\DB; use Garradin\DynamicList; use Garradin\Entity; use Garradin\UserException; use Garradin\Accounting\AdvancedSearch as Accounting_AdvancedSearch; use Garradin\Users\AdvancedSearch as Users_AdvancedSearch; |
︙ | ︙ | |||
180 181 182 183 184 185 186 187 188 189 190 191 192 193 | { $r = $this->query($columns); while ($row = $r->fetchArray(\SQLITE3_NUM)) { yield $row; } } public function getProtectedTables(): ?array { if ($this->type != self::TYPE_SQL) { return null; } | > > > > > | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | { $r = $this->query($columns); while ($row = $r->fetchArray(\SQLITE3_NUM)) { yield $row; } } public function export(string $format) { CSV::export($format, 'Recherche', $this->iterateResults(), $this->getHeader()); } public function getProtectedTables(): ?array { if ($this->type != self::TYPE_SQL) { return null; } |
︙ | ︙ |
Modified src/templates/acc/search.tpl from [df5d13ade8] to [0779fd86f7].
1 2 3 4 5 6 7 8 9 10 11 | {include file="admin/_head.tpl" title="Recherche" current="acc" custom_js=['lib/query_builder.min.js']} <nav class="tabs"> <ul> <li class="current"><a href="{$self_url}">Recherche</a></li> <li><a href="saved_searches.php">Recherches enregistrées</a></li> </ul> </nav> <form method="post" action="{$self_url}" id="queryBuilderForm" data-disable-progress="1"> | | | < | 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 | {include file="admin/_head.tpl" title="Recherche" current="acc" custom_js=['lib/query_builder.min.js']} <nav class="tabs"> <ul> <li class="current"><a href="{$self_url}">Recherche</a></li> <li><a href="saved_searches.php">Recherches enregistrées</a></li> </ul> </nav> <form method="post" action="{$self_url}" id="queryBuilderForm" data-disable-progress="1"> {include file="common/search/advanced.tpl"} {if $list !== null} <p class="help">{$list->count()} écritures trouvées pour cette recherche.</p> {if $list->count() > 0 && $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)} <p class="actions"> {button type="submit" name="_dl_export" value="csv" shape="export" label="Export CSV"} {button type="submit" name="_dl_export" value="ods" shape="export" label="Export LibreOffice"} {button type="submit" name="_dl_export" value="xlsx" shape="export" label="Export Excel"} </p> {/if} {include file="common/dynamic_list_head.tpl" check=$is_admin use_buttons=true} <?php $prev_id = null; ?> |
︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | {include file="admin/membres/_list_actions.tpl" colspan=count($result_header)+1} {/if*} </table> {pagination url=$list->paginationURL() page=$list.page bypage=$list.per_page total=$list->count() use_buttons=true} {elseif $results} <table class="list"> <thead> <tr> {foreach from=$header item="column"} <td>{$column}</td> {/foreach} | > > > > > > > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | {include file="admin/membres/_list_actions.tpl" colspan=count($result_header)+1} {/if*} </table> {pagination url=$list->paginationURL() page=$list.page bypage=$list.per_page total=$list->count() use_buttons=true} {elseif $results} {if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)} <p class="actions"> {button type="submit" name="_export" value="csv" shape="export" label="Export CSV"} {button type="submit" name="_export" value="ods" shape="export" label="Export LibreOffice"} {button type="submit" name="_export" value="xlsx" shape="export" label="Export Excel"} </p> {/if} <table class="list"> <thead> <tr> {foreach from=$header item="column"} <td>{$column}</td> {/foreach} |
︙ | ︙ |
Modified src/templates/common/search/advanced.tpl from [5262081f67] to [309919d4c9].
1 2 | <?php assert(isset($columns)); | < | 1 2 3 4 5 6 7 8 9 | <?php assert(isset($columns)); assert(isset($s)); assert(isset($is_admin)); $is_unprotected = $s->type == $s::TYPE_SQL_UNPROTECTED; $sql_disabled = !$is_admin || (!$session->canAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN) && $is_unprotected); ?> {form_errors} |
︙ | ︙ |
Modified src/templates/users/search.tpl from [2a68490bb1] to [1c164e0326].
1 2 3 4 | {include file="admin/_head.tpl" title="Recherche de membre" current="users" custom_js=['lib/query_builder.min.js']} {include file="users/_nav.tpl" current="search"} | | | < < > > > > > > > > | 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 | {include file="admin/_head.tpl" title="Recherche de membre" current="users" custom_js=['lib/query_builder.min.js']} {include file="users/_nav.tpl" current="search"} <form method="post" action="{$self_url}" id="queryBuilderForm" data-disable-progress="1"> {include file="common/search/advanced.tpl"} {if $list !== null} <p class="help">{$list->count()} membres trouvés pour cette recherche.</p> {if $list->count() > 0 && $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)} <p class="actions"> {button type="submit" name="_dl_export" value="csv" shape="export" label="Export CSV"} {button type="submit" name="_dl_export" value="ods" shape="export" label="Export LibreOffice"} {button type="submit" name="_dl_export" value="xlsx" shape="export" label="Export Excel"} </p> {/if} {include file="common/dynamic_list_head.tpl" check=$is_admin use_buttons=true} {foreach from=$list->iterate() item="row"} <tr> {if $is_admin} <td class="check">{input type="checkbox" name="selected[]" value=$row.id}</td> |
︙ | ︙ | |||
33 34 35 36 37 38 39 | {if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)} {linkbutton shape="edit" label="Modifier" href="!membres/modifier.php?id=%d"|args:$row.id} {/if} </td> </tr> {/foreach} </tbody> | | > > > > > > > > | < < | 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 66 67 68 | {if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)} {linkbutton shape="edit" label="Modifier" href="!membres/modifier.php?id=%d"|args:$row.id} {/if} </td> </tr> {/foreach} </tbody> {if $is_admin && $row._user_id} {include file="admin/membres/_list_actions.tpl" colspan=count($result_header)+1} {/if} </table> {pagination url=$list->paginationURL() page=$list.page bypage=$list.per_page total=$list->count() use_buttons=true} {elseif $results} {if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)} <p class="actions"> {button type="submit" name="_export" value="csv" shape="export" label="Export CSV"} {button type="submit" name="_export" value="ods" shape="export" label="Export LibreOffice"} {button type="submit" name="_export" value="xlsx" shape="export" label="Export Excel"} </p> {/if} <table class="list"> <thead> <tr> {foreach from=$header item="column"} <td>{$column}</td> {/foreach} |
︙ | ︙ | |||
69 70 71 72 73 74 75 76 77 | </tr> {/foreach} </tbody> </table> {/if} {include file="admin/_foot.tpl"} | > | 81 82 83 84 85 86 87 88 89 90 | </tr> {/foreach} </tbody> </table> {/if} </form> {include file="admin/_foot.tpl"} |
Modified src/www/admin/common/search.php from [94b4edf633] to [f78c660b4a].
︙ | ︙ | |||
86 87 88 89 90 91 92 93 94 95 96 97 98 99 | if (!$default) { try { if ($s->type == $s::TYPE_JSON) { $list = $s->getDynamicList(); $list->loadFromQueryString(); } else { $header = $s->getHeader(); $results = $s->iterateResults(); } } catch (UserException $e) { $form->addError($e->getMessage()); } | > > > > > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | if (!$default) { try { if ($s->type == $s::TYPE_JSON) { $list = $s->getDynamicList(); $list->loadFromQueryString(); } else { if (!empty($_POST['_export'])) { $s->export($_POST['_export']); exit; } $header = $s->getHeader(); $results = $s->iterateResults(); } } catch (UserException $e) { $form->addError($e->getMessage()); } |
︙ | ︙ |