typo
[platal.git] / templates / emails / send.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 <h1>Envoyer un mail</h1>
24
25 <script type="text/javascript">//<![CDATA[
26   {literal}
27   function _selectAll(id) {
28     var list = document.getElementById(id);
29     for (i = 0 ; i < list.length ; i++) {
30       list.options[i].selected = true;
31     }
32   }
33
34   function check(form)
35   {
36     var send = true;
37     _selectAll('to_contacts');
38     _selectAll('cc_contacts');
39     if(form.sujet.value == "" && !confirm("Le sujet du mail est vide, veux-tu continuer ?")) {
40         form.sujet.focus();
41         return false;
42     }
43     if (form.to.value == "" && form.cc.value == ""
44         && document.getElementById('to_contacts').length == 0 && document.getElementById('cc_contacts').length == 0) {
45       if (form.bcc.value == "") {
46         alert("Il faut définir au moins un destinataire au mail.");
47         return false;
48       }
49       if (!confirm("Tous les destinataires sont en copie cachée, veux-tu continuer ?")) {
50         form.to.focus();
51         return false;
52       }
53     }
54     return true;
55   }
56
57   var doAuth = true;
58   function _keepAuth() {
59     doAuth = true;
60   }
61
62   function keepAuth() {
63     if (doAuth) {
64       Ajax.update_html(null, "login", null);
65       doAuth = false;
66       setTimeout("_keepAuth()", 10000);
67     }
68   }
69
70   function _move(idFrom, idTo) {
71     var from = document.getElementById(idFrom);
72     var to   = document.getElementById(idTo);
73
74     var index = new Array();
75     var j = 0;
76     for (i = 0 ; i < from.length ; i++) {
77       if (from.options[i].selected) {
78         var option = document.createElement('option');
79         option.value = from.options[i].value;
80         option.text  = from.options[i].text;
81         try {
82           to.add(option, null);
83         } catch(ex) {
84           to.add(option);
85         }
86         index[j++] = i;
87       }
88     }
89     for (i = index.length - 1 ; i >= 0 ; i--) {
90       from.remove(index[i]);
91     }
92   }
93
94   function addTo() {
95     _move('contacts', 'to_contacts');
96   }
97
98   function removeTo() {
99     _move('to_contacts', 'contacts');
100   }
101
102   function addCc() {
103     _move('contacts', 'cc_contacts');
104   }
105
106   function removeCc() {
107     _move('cc_contacts', 'contacts');
108   }
109
110   function updateWikiView(box) {
111     if (box.checked) {
112       document.getElementById("preview_bt").style.display = "none";
113       document.getElementById("preview").style.display = "none";
114     } else {
115       document.getElementById("preview_bt").style.display = "";
116     }
117   }
118   {/literal}
119 //]]>
120 </script>
121
122 <form action="emails/send" method="post" enctype="multipart/form-data" onsubmit="return check(this);">
123   <table class="bicol" cellpadding="2" cellspacing="0">
124     <tr> 
125       <th colspan="2">Destinataires</th>
126     </tr>
127     <tr> 
128       <td class="titre">de&nbsp;:</td>
129       <td>
130         <input type='hidden' name='signature' value='1' />
131         <input type='text' name='from' size='60' value='{if $smarty.request.from}
132 {$smarty.request.from}
133 {else}
134 "{$smarty.session.prenom} {$smarty.session.nom_usage|default:$smarty.session.nom}" &lt;{$smarty.session.bestalias}@{#globals.mail.domain#}&gt;
135 {/if}' />
136       </td>
137     </tr>
138     <tr> 
139       <td class="titre">à&nbsp;:</td>
140       <td>
141         <input type='text' name='to' size='60' value="{$smarty.request.to}" />
142       </td>
143     </tr>
144     <tr> 
145       <td class="titre">copie&nbsp;:</td>
146       <td>
147         <input type='text' name='cc' size='60' value="{$smarty.request.cc}" />
148       </td>
149     </tr>
150     <tr> 
151       <td class="titre">copie cachée&nbsp;:</td>
152       <td>
153         <input type='text' name='bcc' size='60' value="{$smarty.request.bcc}" />
154       </td>
155     </tr>
156     <tr class="pair">
157       <td colspan="2" class="smaller">
158         &bull;&nbsp;Les destinataires sont simplement séparés par des virgules.<br />
159         &bull;&nbsp;Pense à te mettre en copie cachée du mail pour en avoir une trace.
160       </td>
161     </tr>
162     {if $contacts|@count}
163     <tr>
164       <th colspan="2">
165         Destinataires parmi tes contacts
166       </th>
167     </tr>
168     <tr>
169       <td colspan="2" style="padding: 4px">
170         <div style="float: right; width: 40%;">
171           <select id="to_contacts" name="to_contacts[]" multiple="multiple" style="width: 100%; height: 5em">
172           {foreach key=key item=contact from=$contacts}
173           {if in_array($contact.forlife, $smarty.request.to_contacts)}
174           <option value="{$contact.forlife}">
175             {$contact.prenom} {$contact.nom} (X{$contact.promo})
176           </option>
177           {/if}
178           {/foreach}
179           </select><br />
180           <select id="cc_contacts" name="cc_contacts[]" multiple="multiple" style="width: 100%; height: 5em">
181           {foreach key=key item=contact from=$contacts}
182           {if in_array($contact.forlife, $smarty.request.cc_contacts)}
183           <option value="{$contact.forlife}">
184             {$contact.prenom} {$contact.nom} (X{$contact.promo})
185           </option>
186           {/if}
187           {/foreach}
188           </select>
189         </div>
190         <div style="width: 19%; text-align: center; height: 8em; float: right;">
191           <div style="height: 4em">
192               Destinataires<br />
193               <a href="" onclick="addTo(); return false" style="text-decoration: none">&gt;&gt; &gt;&gt;</a><br />
194               <a href="" onclick="removeTo(); return false" style="text-decoration: none">&lt;&lt; &lt;&lt;</a>
195           </div>
196           <div style="height: 4em">
197               En copie<br />
198               <a href="" onclick="addCc(); return false" style="text-decoration: none">&gt;&gt; &gt;&gt;</a><br />
199               <a href="" onclick="removeCc(); return false" style="text-decoration: none">&lt;&lt; &lt;&lt;</a>
200           </div>
201         </div>
202         <div style="float: right; width: 40%">
203           <select id="contacts" name="all_contacts[]" multiple="multiple" style="height: 10em; width: 100%">
204             {foreach item=contact from=$contacts}
205             {if !in_array($contact.forlife, $smarty.request.to_contacts) && !in_array($contact.forlife, $smarty.request.cc_contacts)}
206             <option value="{$contact.forlife}">
207               {$contact.prenom} {$contact.nom} (X{$contact.promo})
208             </option>
209             {/if}
210             {/foreach}
211           </select>
212         </div>
213         {foreach item=contact from=$contacts}
214         <input type="hidden" name="contacts[{$contact.forlife}]" value="{$contact.prenom} {$contact.nom} &lt;{$contact.forlife}@{#globals.mail.domain#}&gt;" />
215         {/foreach}
216       </td>
217     </tr>
218     {/if}
219   </table>
220   <fieldset>
221     <legend>Sujet&nbsp;:&nbsp;<input type='text' name='sujet' size='60' value="{$smarty.request.sujet}" /></legend>
222     <div class="center">
223       Tu peux utiliser des <a href="wiki_help" class="popup3">{icon name=information title="Syntaxe wiki"} marqueurs wiki</a> pour formatter ton texte.<br />
224       <small><input type="checkbox" name="nowiki" value="1" {if $smarty.request.nowiki}checked="checked"{/if} onchange="updateWikiView(this);" />
225       coche cette case pour envoyer le mail en texte brut, sans formattage</small>
226     </div>
227     <div id="preview" style="display: none">
228       <strong>Aperçu du mail :</strong>
229       <div id="mail_preview">
230       </div>
231       <div class="center">
232         <input type="submit" name="submit" value="Envoyer" />
233       </div>
234     </div>
235     <textarea name='contenu' rows="30" cols="75" id="mail_text" onkeyup="keepAuth()">
236 {$smarty.request.contenu}
237 {if !$smarty.request.contenu}
238 -- 
239 {$smarty.session.prenom} {$smarty.session.nom}
240 {/if}</textarea>
241     <script type="text/javascript">//<![CDATA[
242       {literal}
243       function removeAttachments()
244       {
245           Ajax.update_html(null, 'emails/send', null);
246           document.getElementById('att_already').style.display = 'none';
247           document.getElementById('att_form').style.display = '';
248       }
249       {/literal}
250     //]]></script>
251     {if $uploaded_f|@count}
252     <div id="att_already">
253       <strong>{icon name=email_attach}&nbsp;Pièce jointe&nbsp;:&nbsp;</strong>
254       {$uploaded_f[0]}
255       <a href="javascript:removeAttachments()">
256         {icon name=cross alt="Supprimer" title="Supprimer la pièce jointe"}
257       </a>
258     </div>
259     {/if}
260     <div id="att_form" {if $uploaded_f|@count neq 0}style="display: none"{/if}>
261       <strong>{icon name=email_attach}&nbsp;Ajouter une pièce jointe (max. {$maxsize})&nbsp;:&nbsp;</strong>
262       <input type="file" name="uploaded" />
263     </div>
264     <div class="center">
265       <input type="submit" name="preview" id="preview_bt" value="Aperçu" onclick="previewWiki('mail_text', 'mail_preview', true, 'preview'); return false;" />
266       <input type="submit" name="submit" value="Envoyer" />
267     </div>
268   </fieldset>
269 </form>
270
271
272 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}