Start working on the medals page
[platal.git] / templates / profile / deco.tpl
1 {**************************************************************************}
2 {*                                                                        *}
3 {*  Copyright (C) 2003-2007 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 {literal}
25 <script type="text/javascript">//<![CDATA[
26 function update()
27 {
28   var val = document.forms.prof_annu['medal_sel'].value;
29   if (val == '' || document.getElementById('medal_' + val) != null) {
30     document.getElementById('medal_add').display.style = 'none';
31   } else {
32     document.getElementById('medal_add').display.style = '';
33   }
34 }
35
36   var valid = new array();
37   function medal_add()
38   {
39     var selid = document.forms.prof_annu.medal_sel.selectedIndex;
40     document.forms.prof_annu.medal_id.value = document.forms.prof_annu.medal_sel.options[selid].value;
41     document.forms.prof_annu.grade_id.value = document.forms.prof_annu.grade_sel.value;
42     document.forms.prof_annu.medal_op.value = "ajouter";
43     document.forms.prof_annu.submit();
44   }
45
46   function medal_del( id )
47   {
48     document.forms.prof_annu.medal_id.value = id;
49     document.forms.prof_annu.medal_op.value = "retirer";
50     document.forms.prof_annu.submit();
51   }
52
53   function medal_cancel(stamp)
54   {
55     document.forms.prof_annu.medal_id.value = stamp;
56     document.forms.prof_annu.medal_op.value = "annuler";
57     document.forms.prof_annu.submit();
58   }
59   var subgrades = new array();
60   function getoption( select_input, j)
61   {
62     if (!document.all)
63     {
64       return select_input.options[j];
65     }
66     else
67     {
68       return j;
69     }
70   }
71   function medal_grades( sel_medal )
72   {
73     var subg = subgrades[sel_medal.selectedIndex];
74     document.getElementById("grade_sel_div").style.display = subg?"inline":"none";
75     if (!subg) return;
76     var select = document.getElementById("grade_sel");
77     while (select.length > 1)
78     {
79       select.remove(1);
80     }
81
82     for (i=0; i < subg.length; i++)
83     {
84       var dmc = document.createElement("option");
85       dmc.text= subg[i][1];
86       dmc.value = subg[i][0];
87       select.add(dmc,getoption(select,i));
88     }
89     var vide = document.createElement("option");
90     vide.text = "";
91     vide.value = 0;
92     select.add(vide,getoption(select,0));
93     select.remove(subg.length+1);
94   }
95   //]]>
96 {/literal}
97 {foreach from=$medal_list key=type item=list}
98   {foreach from=$list item=m}{if $grades[$m.id]|@count}
99     subgrades[{$m.id}] = new array({$grades[$m.id]|@count});
100     i = 0;
101     {foreach from=$grades[$m.id] item=g}
102       subgrades[{$m.id}][i] = [{$g.gid},"{$g.text}"];
103       i++;
104     {/foreach}
105   {/if}{/foreach}
106 {/foreach}
107
108 </script>
109
110 <table class="bicol">
111   <tr>
112     <th>
113       Médailles, Décorations, Prix, ...
114     </th>
115   </tr>
116   <tr>
117     <td>
118       <div class="flags">
119         <div class="vert" style="float: left">
120           <input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if} />
121         </div>
122         <div class="texte">
123           ces informations sont normalement publiques (JO, ...) mais tu peux choisir de les associer a ta fiche publique
124         </div>
125       </div>
126       <div style="clear: both; margin-top: 0.2em">
127         <select name="medal_sel" onchange="update()">
128           <option value=''></option>
129           {foreach from=$medal_list key=type item=list}
130           <optgroup label="{$trad[$type]}...">
131             {foreach from=$list item=m}
132             <option value="{$m.id}">{$m.text}</option>
133             {/foreach}
134           </optgroup>
135           {/foreach}
136         </select>
137         <span id="medal_add">
138           <a href="javascript:add();">{icon name=add title="Ajouter cette médaille"}</a>
139         </span>
140       </div>
141       {foreach from=$medals item=medal key=id}
142       {include file="profile/deco.medal.tpl" medal=$medal id=$id}
143       {/foreach}
144     </td>
145   </tr>
146 </table>
147
148 <script type="text/javascript">
149 update();
150 </script>
151
152 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}