Happy New Year
[platal.git] / templates / table-editor.tpl
1 {**************************************************************************}
2 {*                                                                        *}
3 {*  Copyright (C) 2003-2009 Polytechnique.org                             *}
4 {*  http://opensource.polytechnique.org/                                  *}
5 {*                                                                        *}
6 {*  This program is free software; you can redistribute it and/or modify  *}
7 {*  it under the terms of the GNU General Public License as published by  *}
8 {*  the Free Software Foundation; either version 2 of the License, or     *}
9 {*  (at your option) any later version.                                   *}
10 {*                                                                        *}
11 {*  This program is distributed in the hope that it will be useful,       *}
12 {*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
13 {*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
14 {*  GNU General Public License for more details.                          *}
15 {*                                                                        *}
16 {*  You should have received a copy of the GNU General Public License     *}
17 {*  along with this program; if not, write to the Free Software           *}
18 {*  Foundation, Inc.,                                                     *}
19 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
20 {*                                                                        *}
21 {**************************************************************************}
22
23
24 <h1>{$title}</h1>
25
26 {if $list}
27 <script type="text/javascript">
28         {literal}
29         function redirect(a) {
30                 document.location = a;
31         }
32         {/literal}
33 </script>
34 <table class="bicol">
35 <tr>
36   {foreach from=$t->vars item=myval key=myvar}{if $myval.display}
37     <th style="cursor:pointer" onclick="redirect('{$t->pl}/sort{if $t->sortfield eq $myvar && !$t->sortdesc}desc{/if}/{$myvar}')">{$myval.desc}{if $t->sortfield eq $myvar}{if $t->sortdesc}{icon name="bullet_arrow_down"}{else}{icon name="bullet_arrow_up"}{/if}{/if}</th>
38   {/if}{/foreach}
39   {if !$hideactions}
40   <th>action</th>
41   {/if}
42 </tr>
43 {if !$readonly and !$deleteonly}
44 <tr class="impair">
45   <td colspan="{$t->nbfields}">
46     <strong>
47       Nouvelles entrées&nbsp;: <a href="{$t->pl}/new">Manuellement</a> &bull; <a href="{$t->pl}/massadd">Depuis un CSV</a>
48     </strong>
49   </td>
50   <td class="right">
51     <a href="{$t->pl}/new">{icon name=add title='nouvelle entrée'}</a>
52   </td>
53 </tr>
54 {/if}
55 {iterate from=$list item=myrow}
56 <tr class="{cycle values="pair,impair"}">
57 {foreach from=$t->vars item=myval}{if $myval.display}
58   <td>
59     {assign var="myfield" value=$myval.Field}
60     {if $myfield eq $t->idfield}
61         {assign var="idval" value=$myrow.$myfield}
62     {/if}
63     {if $myval.Type eq 'timestamp'}
64       <span class="smaller">{$myrow.$myfield|date_format:"%x %X"}</span>
65     {elseif $myval.Type eq 'checkbox'}
66       <input type="checkbox" disabled="disabled"{if $myrow.$myfield} checked="checked"{/if}/>
67     {elseif $myval.Type eq 'ip_address'}
68       {$myrow.$myfield|uint_to_ip}
69     {else}
70       {$myrow.$myfield}
71     {/if}
72   </td>
73 {/if}{/foreach}
74   {if !$hideactions}
75   <td class="action">
76     {if !$readonly and !$deleteonly}
77     <a href="{$t->pl}/edit/{$idval}">{icon name=page_edit title='éditer'}</a>
78     {/if}
79     {if !$readonly}
80     <a href="{$t->pl}/delete/{$idval}?token={xsrf_token}">{icon name=delete title='supprimer'}</a>
81     {/if}
82   </td>
83   {/if}
84 </tr>
85 {/iterate}
86 </table>
87
88 {if ($p_prev > -1) || ($p_next > -1)}
89 <p class="pagenavigation">
90 {if $p_prev > -1}<a href="{$platal->path}?start={$p_prev}">{$msg_previous_page}</a>&nbsp;{/if}
91 {if $p_next > -1}<a href="{$platal->path}?start={$p_next}">{$msg_next_page}</a>{/if}
92 </p>
93 {/if}
94
95 {elseif $massadd}
96 {include core=csv-importer.tpl}
97
98 <p>
99 <a href="{$t->pl}">back</a>
100 </p>
101
102 {else}
103
104 <form method="post" action="{$t->pl}/update/{$id}">
105   {xsrf_token_field}
106   <table class="bicol">
107     <tr class="impair">
108       <th colspan="2">
109         {if $id}
110             modification de l'entrée 
111         {else}
112             nouvelle entrée
113         {/if}
114       </th>
115     </tr>
116     {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if ($myfield neq $t->idfield) or ($t->idfield_editable)}
117     <tr class="{cycle values="pair,impair"}">
118       <td>
119         <strong>{$myval.desc}</strong>
120       </td>
121       <td>
122         {if $myval.Type eq 'set'}
123           <select name="{$myfield}[]" multiple="multiple">
124             {foreach from=$myval.List item=option}
125               <option value="{$option}" {if $entry.$myfield.$option}selected="selected"{/if}>{$option}</option>
126             {/foreach}
127           </select>
128         {elseif $myval.Type eq 'enum'}
129           <select name="{$myfield}">
130             {foreach from=$myval.List item=option}
131               <option value="{$option}" {if $entry.$myfield eq $option}selected="selected"{/if}>{$option}</option>
132             {/foreach}
133           </select>
134         {elseif ($myval.Type eq 'textarea') or ($myval.Type eq 'varchar200')}
135           <textarea name="{$myfield}" rows="{if $myval.Type eq 'varchar200'}3{else}10{/if}" cols="70">{$entry.$myfield}</textarea>
136         {elseif ($myval.Type eq 'checkbox')}
137           <input type="checkbox" name="{$myfield}" value="{$myval.Value}"{if $entry.$myfield} checked="checked"{/if}/>
138         {else}
139           <input type="text" name="{$myfield}" value="{$entry.$myfield}" {if $myval.Size}size="{$myval.Size}" maxlength="{$myval.Maxlength}"{/if}/>
140           {if $myval.Type eq 'timestamp'}<em>jj/mm/aaaa hh:mm:ss</em>{/if}
141           {if $myval.Type eq 'date'}<em>jj/mm/aaaa</em>{/if}
142           {if $myval.Type eq 'time'}<em>hh:mm:ss</em>{/if}
143         {/if}
144       </td>
145     </tr>
146     {/if}{/foreach}
147   </table>
148
149   <p class="center">
150   <input type="submit" value="enregistrer" />
151   </p>
152
153 </form>
154
155 <p>
156 <a href="{$t->pl}">back</a>
157 </p>
158
159 {/if}
160
161
162 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}