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