Less restrictive check on recipients list
[platal.git] / templates / events / form.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 <script type="text/javascript">//<![CDATA[
24   {literal}
25   function updatePreview()
26   {
27     if (document.getElementById('image').value != '' || document.getElementById('image_url').value != '') {
28       return true;
29     }
30     var titre = document.getElementById('titre').value;
31     var texte = document.getElementById('texte').value;
32
33     if (titre == '' || texte == '') {
34       document.getElementById('valid').style.display = 'none';
35       document.getElementById('info').style.display = '';
36     } else {
37       document.getElementById('valid').style.display = '';
38       document.getElementById('info').style.display = 'none';
39     }
40     var page  = 'events/preview?titre=' + encodeURIComponent(titre) + '&texte=' + encodeURIComponent(texte);
41     if (is_IE) {
42       {/literal}
43       page = "{$globals->baseurl}/" + page;
44       {literal}
45     }
46     Ajax.update_html('preview', page, null);
47     return false;
48   }
49   {/literal}
50 //]]></script>
51
52 <div id="preview">
53 {include file="events/preview.tpl"}
54 </div>
55 <br />
56
57 <form action="{$platal->path}" method="post" enctype="multipart/form-data">
58   <table class="bicol">
59     <tr>
60       <th colspan="2">Contenu de l'annonce</th>
61     </tr>
62     <tr>
63       <td class="titre">Titre</td>
64       <td>
65         <input type="text" name="titre" id="titre" size="50" maxlength="200" value="{$titre}" />
66       </td>
67     </tr>
68     <tr>
69       <td class="titre">Texte</td>
70       <td><textarea name="texte" id="texte" rows="10" cols="60" onfocus="update_texte_count(this.form)">{$texte}</textarea></td>
71     </tr>
72     <tr>
73       <td colspan="2" class="smaller">
74         <script type="text/javascript">//<![CDATA[
75           var form_propose_texte = false;
76           {literal}
77           function update_texte_count(f) {
78             if (!form_propose_texte && f) form_propose_texte = f;
79             form_propose_texte.texte_count.value=form_propose_texte.texte.value.length;
80             setTimeout("update_texte_count(0)", 100);
81           }
82           {/literal}
83         //]]></script>
84         Essaie de faire un <strong>texte court</strong>, une annonce ne doit pas excéder 800 caractères soit une douzaine de ligne. Tu en es déjà à <input type='text' name='texte_count' size="4" /> caractères.
85       </td>
86     </tr>
87     <tr class="pair">
88       <td class="titre">Illustration</td>
89       <td>
90         {if $eid && $img}
91         <div style="float: left; text-align: center">
92           <em>Image actuelle</em><br />
93           <img src="events/photo/{$eid}" alt="Image actuelle" /><br />
94           <input type="submit" name="action" value="Pas d'image" />
95         </div>
96         {/if}
97         {if $upload && $upload->exists()}
98         <div style="float: right; text-align: center">
99           <em>Nouvelle image</em><br />
100           <img src="events/photo" alt="Nouvelle Image" /><br />
101           <input type="submit" name="action" value="Supprimer l'image" />
102         </div>
103         {/if}
104         <div style="clear: both">
105           Choisir un fichier : <input type="file" name="image" id="image" /><br />
106           Indiquer une adresse : <input type="text" name="image_url" id="image_url" value="" />
107         </div>
108       </td>
109     </tr>
110   </table>
111
112   <div class="center">
113     <input type="submit" name="preview" value="Aperçu" onclick="return updatePreview();" />
114   </div>
115   <p id="info" {if trim($texte) && trim($titre)}style="display: none"{/if}>
116     Le bouton de confirmation n'apparaît que si l'aperçu est concluant.
117   </p>
118   <p class="erreur">
119     N'oublie pas de remplir les informations suivantes&nbsp;:
120   </p>
121
122   <script type="text/javascript">//<![CDATA[
123     {literal}
124     function updateRange(min, max)
125     {
126       var range = document.getElementById('range');
127       if (min == null) {
128         min = document.getElementById('promo_min').value;
129       }
130       if (max == null) {
131         max = document.getElementById('promo_max').value;
132       }
133       if (isNaN(min) || (min != 0 && (min < 1900 || min > 2020))) {
134         range.innerHTML = '<span class="erreur">La promotion minimum n\'est pas valide</span>';
135         return false;
136       } else if (isNaN(max) || (max != 0 && (max < 1900  || max > 2020))) {
137         range.innerHTML = '<span class="erreur">La promotion maximum n\'est pas valide</span>';
138         return false;
139       } else if (max != 0 && min != 0 && max < min) {
140         range.innerHTML = '<span class="erreur">L\'intervalle de promotion est inversé</span>';
141         return false;
142       } else if (max == 0 && min == 0) {
143         range.innerHTML = 'L\'annonce est destinée à toutes les promotions';
144       } else if (max == 0) {
145         range.innerHTML = 'L\'annonce sera affichée aux promotions plus jeunes que ' + min + ' (incluse)';
146       } else if (min == 0) {
147         range.innerHTML = "L\'annonce sera affichée aux promotions plus anciennes que " + max + ' (incluse)';
148       } else {
149         range.innerHTML = "L\'annonce sera affichées aux promotions de " + min + " à " + max + ' (incluses)';
150       }
151       return true;
152     }
153     {/literal}
154   //]]></script>
155
156   <table class="bicol">
157     <tr>
158       <th colspan="2">Informations complémentaires</th>
159     </tr>
160     <tr class="pair">
161       <td colspan="2">
162         Tu peux limiter la visibilité de ton annonce aux camarades de certaines promotions :
163       </td>
164     </tr>
165     <tr class="impair">
166       <td class="titre">Promotion la plus ancienne</td>
167       <td>
168         <input type="text" name="promo_min" id="promo_min" size="4" maxlength="4" value="{$promo_min}"
169                onkeyup="return updateRange(null, null);" /> incluse
170         &nbsp;<em>(ex : 1980, 0 signifie pas de minimum)</em>
171       </td>
172     </tr>
173     <tr class="impair">
174       <td class="titre">Promotion la plus jeune</td>
175       <td>
176         <input type="text" name="promo_max" id="promo_max" size="4" maxlength="4" value="{$promo_max}"
177                onkeyup="return updateRange(null, null);" /> incluse
178         &nbsp;<em>(ex : 2000, 0 signifie pas de maximum)</em>
179       </td>
180     </tr>
181     <tr class="impair">
182       <td colspan="2" id="range" class="smaller">
183         <script type="text/javascript">updateRange({$promo_min}, {$promo_max});</script>
184       </td>
185     </tr>
186     <tr class="pair">
187       <td colspan="2">
188         Choisis la date d'expiration de ton annonce :
189       </td>
190     </tr>
191     <tr>
192       <td class="titre">
193         Dernier jour d'affichage
194       </td>
195       <td>
196         <select name="peremption">
197           {$select|smarty:nodefaults}
198         </select>
199       </td>
200     </tr>
201     {if $admin_evts}
202     <tr>
203       <td class="titre">
204         Importance
205       </td>
206       <td>
207         <input type="checkbox" name="important" {if $important}checked="checked"{/if}/> Marquer cette annonce comme très importante
208       </td>
209     </tr>
210     {/if}
211   </table>
212
213   <div class="center" {if !trim($texte) || !trim($titre)}style="display: none"{/if} id="valid">
214     <input type="hidden" name="evt_id" value="{$smarty.post.evt_id}" />
215     <input type="submit" name="action" value="Proposer" />
216   </div>
217
218 </form>
219
220 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}