Moving to GitHub.
[platal.git] / templates / emails / send.tpl
CommitLineData
0337d704 1{**************************************************************************}
2{* *}
c441aabe 3{* Copyright (C) 2003-2014 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
faefdbb7 23<h1>Envoyer un email</h1>
0337d704 24
0337d704 25<script type="text/javascript">//<![CDATA[
26 {literal}
91a14f73 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
3360c04f 34 var sent = false;
f3fb8eda 35 function check(form)
36 {
91a14f73 37 _selectAll('to_contacts');
38 _selectAll('cc_contacts');
71ff2e11 39 if(form.sujet.value == "" && !confirm("Le sujet de l'email est vide, veux-tu continuer ?")) {
f3fb8eda 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 == "") {
faefdbb7 46 alert("Il faut définir au moins un destinataire.");
f3fb8eda 47 return false;
48 }
71ff2e11 49 if (!confirm("Tous les destinataires sont en copie cachée, veux-tu continuer ?")) {
f3fb8eda 50 form.to.focus();
51 return false;
52 }
0337d704 53 }
3360c04f 54 sent = true;
0337d704 55 return true;
56 }
91a14f73 57
440a32c3
FB
58 function saveMessage() {
59 var form = document.forms.form_mail;
60 var toc = "";
61 var ccc = "";
b0cac82e
RB
62 if (form['to_contacts[]'] != undefined) {
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 }
440a32c3 69 }
63c89179 70 $.xpost("emails/send",
440a32c3 71 { save: true,
30e7b416 72 token: {/literal}'{xsrf_token}'{literal},
440a32c3
FB
73 from: form.from.value,
74 to_contacts: toc,
75 cc_contacts: ccc,
76 contenu: form.contenu.value,
77 to: form.to.value,
78 sujet: form.sujet.value,
79 cc: form.cc.value,
80 bcc: form.bcc.value });
81 }
82
0938c545 83 var doAuth = true;
84 function _keepAuth() {
85 doAuth = true;
86 }
87
88 function keepAuth() {
89 if (doAuth) {
440a32c3 90 saveMessage();
0938c545 91 doAuth = false;
92 setTimeout("_keepAuth()", 10000);
93 }
94 }
95
91a14f73 96 function _move(idFrom, idTo) {
97 var from = document.getElementById(idFrom);
98 var to = document.getElementById(idTo);
99
100 var index = new Array();
101 var j = 0;
102 for (i = 0 ; i < from.length ; i++) {
103 if (from.options[i].selected) {
104 var option = document.createElement('option');
105 option.value = from.options[i].value;
106 option.text = from.options[i].text;
107 try {
108 to.add(option, null);
109 } catch(ex) {
110 to.add(option);
111 }
112 index[j++] = i;
113 }
114 }
115 for (i = index.length - 1 ; i >= 0 ; i--) {
116 from.remove(index[i]);
117 }
118 }
119
120 function addTo() {
121 _move('contacts', 'to_contacts');
122 }
123
124 function removeTo() {
125 _move('to_contacts', 'contacts');
126 }
127
128 function addCc() {
129 _move('contacts', 'cc_contacts');
130 }
131
132 function removeCc() {
133 _move('cc_contacts', 'contacts');
134 }
fdbeba4f 135
136 function updateWikiView(box) {
137 if (box.checked) {
138 document.getElementById("preview_bt").style.display = "none";
139 document.getElementById("preview").style.display = "none";
3360c04f 140 document.getElementById("preview_pv").style.display = "none";
fdbeba4f 141 } else {
142 document.getElementById("preview_bt").style.display = "";
3360c04f 143 document.getElementById("preview").style.display = "";
fdbeba4f 144 }
145 }
3360c04f 146
40279e62
SJ
147 function toggleWiki()
148 {
149 if ($('[name="wiki"]').val() == 'text') {
150 $('[name="wiki"]').val('wiki');
151 } else {
152 $('[name="wiki"]').val('text');
153 }
154 }
155
3360c04f
FB
156 $(window).unload(
157 function() {
158 if (sent) {
159 return true;
160 }
440a32c3 161 saveMessage();
3360c04f
FB
162 return true;
163 });
4171c0bf 164 $(
7a5719a2
PC
165 function() {
166 // Remove empty options in select (they were added only for HTML
167 // compatibility).
168 $('#to_contacts option[value=""]').remove();
169 $('#cc_contacts option[value=""]').remove();
170 });
7774a3e6 171
4171c0bf 172 $(function() {
7774a3e6
SJ
173 $("[name='to']").focus();
174 });
0337d704 175 {/literal}
176//]]>
177</script>
178
9fcffac6 179<p>
faefdbb7 180 <small>{icon name=information title="Envoi d'email"} Pour envoyer un email, tu peux soit le faire depuis l'interface
57a29e19 181 ci-dessous, soit utiliser <a href="Xorg/SMTPSecurise">notre serveur d'envoi SMTP</a>.</small>
9fcffac6
SJ
182</p>
183
3360c04f 184<form action="emails/send" method="post" enctype="multipart/form-data" id="form_mail" onsubmit="return check(this);">
46504fb3 185 {xsrf_token_field}
0337d704 186 <table class="bicol" cellpadding="2" cellspacing="0">
aab2ffdd 187 <tr>
0337d704 188 <th colspan="2">Destinataires</th>
189 </tr>
aab2ffdd 190 <tr>
0337d704 191 <td class="titre">de&nbsp;:</td>
192 <td>
193 <input type='hidden' name='signature' value='1' />
40279e62
SJ
194 <input type='text' name='from' size='60'
195 value="{if $smarty.request.from}{$smarty.request.from}{else}{$preferences.from_email}{/if}" />
0337d704 196 </td>
197 </tr>
aab2ffdd 198 <tr>
a7de4ef7 199 <td class="titre">à&nbsp;:</td>
0337d704 200 <td>
201 <input type='text' name='to' size='60' value="{$smarty.request.to}" />
202 </td>
203 </tr>
aab2ffdd 204 <tr>
0337d704 205 <td class="titre">copie&nbsp;:</td>
206 <td>
207 <input type='text' name='cc' size='60' value="{$smarty.request.cc}" />
208 </td>
209 </tr>
aab2ffdd 210 <tr>
a7de4ef7 211 <td class="titre">copie cachée&nbsp;:</td>
0337d704 212 <td>
213 <input type='text' name='bcc' size='60' value="{$smarty.request.bcc}" />
214 </td>
215 </tr>
91a14f73 216 <tr class="pair">
217 <td colspan="2" class="smaller">
9e92370d 218 &bull;&nbsp;Les destinataires sont simplement séparés par des virgules.<br />
faefdbb7 219 &bull;&nbsp;Pense à te mettre en copie cachée de l'email pour en avoir une trace.
0337d704 220 </td>
221 </tr>
91a14f73 222 {if $contacts|@count}
223 <tr>
224 <th colspan="2">
225 Destinataires parmi tes contacts
0337d704 226 </th>
227 </tr>
91a14f73 228 <tr>
229 <td colspan="2" style="padding: 4px">
230 <div style="float: right; width: 40%;">
231 <select id="to_contacts" name="to_contacts[]" multiple="multiple" style="width: 100%; height: 5em">
232 {foreach key=key item=contact from=$contacts}
51fb3b6f 233 {if t($smarty.request.to_contacts) && in_array($contact->hrpid,$smarty.request.to_contacts)}
a289e967 234 <option value="{$contact->hrpid}">
48e683dd 235 {$contact->full_name}
91a14f73 236 </option>
7a5719a2 237 {assign var="to_not_empty" value="true"}
91a14f73 238 {/if}
239 {/foreach}
7a5719a2
PC
240 {if !$to_not_empty}
241 {* HTML compatibility *}
242 <option value="">&nbsp;</option>
243 {/if}
244 </select>
245 {if !$to_not_empty}
246 {/if}
247 <br />
91a14f73 248 <select id="cc_contacts" name="cc_contacts[]" multiple="multiple" style="width: 100%; height: 5em">
249 {foreach key=key item=contact from=$contacts}
51fb3b6f 250 {if t($smarty.request.cc_contacts) && in_array($contact->hrpid,$smarty.request.cc_contacts)}
a289e967 251 <option value="{$contact->hrpid}">
48e683dd 252 {$contact->full_name}
91a14f73 253 </option>
7a5719a2 254 {assign var="cc_not_empty" value="true"}
91a14f73 255 {/if}
256 {/foreach}
7a5719a2
PC
257 {if !$cc_not_empty}
258 {* HTML compatibility *}
259 <option value="">&nbsp;</option>
260 {/if}
91a14f73 261 </select>
262 </div>
263 <div style="width: 19%; text-align: center; height: 8em; float: right;">
264 <div style="height: 4em">
265 Destinataires<br />
7a5719a2
PC
266 <a href="emails/send/addTo" onclick="addTo(); return false" style="text-decoration: none">&gt;&gt; &gt;&gt;</a><br />
267 <a href="emails/send/removeTo" onclick="removeTo(); return false" style="text-decoration: none">&lt;&lt; &lt;&lt;</a>
91a14f73 268 </div>
269 <div style="height: 4em">
270 En copie<br />
7a5719a2
PC
271 <a href="emails/send/addCc" onclick="addCc(); return false" style="text-decoration: none">&gt;&gt; &gt;&gt;</a><br />
272 <a href="emails/send/removeCc" onclick="removeCc(); return false" style="text-decoration: none">&lt;&lt; &lt;&lt;</a>
91a14f73 273 </div>
274 </div>
275 <div style="float: right; width: 40%">
276 <select id="contacts" name="all_contacts[]" multiple="multiple" style="height: 10em; width: 100%">
277 {foreach item=contact from=$contacts}
51fb3b6f
SJ
278 {if !(isset($smarty.request.to_contacts|smarty:nodefaults) && isset($smarty.request.cc_contacts|smarty:nodefaults)) ||
279 (!in_array($contact->hrpid,$smarty.request.to_contacts) && !in_array($contact->hrpid,$smarty.request.cc_contacts))}
a289e967 280 <option value="{$contact->hrpid}">
48e683dd 281 {$contact->full_name}
91a14f73 282 </option>
283 {/if}
284 {/foreach}
285 </select>
286 </div>
91a14f73 287 </td>
288 </tr>
289 {/if}
290 </table>
f25e85b8
NI
291 {if $contacts|@count eq 0}
292 {* Current Javascript code needs some elements to exist. *}
293 {* TODO: rewrite the code to accept non-existent elements without raising exceptions *}
294 <select id="to_contacts" name="to_contacts[]" multiple="multiple" style="display: none;">
295 <option value="">&nbsp;</option>
296 </select>
297 <select id="cc_contacts" name="cc_contacts[]" multiple="multiple" style="display: none;">
298 <option value="">&nbsp;</option>
299 </select>
300 <select id="contacts" name="all_contacts[]" multiple="multiple" style="display: none;">
301 <option value="">&nbsp;</option>
302 </select>
303 {/if}
91a14f73 304 <fieldset>
305 <legend>Sujet&nbsp;:&nbsp;<input type='text' name='sujet' size='60' value="{$smarty.request.sujet}" /></legend>
5b21237d 306 <div class="center">
72b2f8bb 307 Tu peux utiliser des <a href="wiki_help" class="popup3">{icon name=information title="Syntaxe wiki"} marqueurs wiki</a> pour formatter ton texte.<br />
40279e62
SJ
308 <small><label>
309 <input type="hidden" name="wiki" value="{$smarty.request.wiki|default:$preferences.from_format}" />
310 <input type="checkbox" {if $smarty.request.wiki eq "text" || (!$smarty.request.wiki && $preferences.from_format eq "text")}checked="checked"{/if}
311 onchange="updateWikiView(this); toggleWiki();" />
312 coche cette case pour envoyer l'email en texte brut, sans formattage
313 </label></small>
5b21237d 314 </div>
3360c04f
FB
315 <div id="preview">
316 <div id="preview_pv" style="display: none">
faefdbb7 317 <strong>Aperçu de l'email&nbsp;:</strong>
3360c04f
FB
318 <div id="mail_preview">
319 </div>
320 <div class="center">
321 <input type="submit" name="submit" value="Envoyer" />
322 </div>
fdbeba4f 323 </div>
324 <div class="center">
3360c04f
FB
325 <input type="submit" name="preview" id="preview_bt_top" value="Aperçu"
326 onclick="previewWiki('mail_text', 'mail_preview', true, 'preview_pv'); return false;" />
fdbeba4f 327 </div>
328 </div>
0938c545 329 <textarea name='contenu' rows="30" cols="75" id="mail_text" onkeyup="keepAuth()">
0337d704 330{$smarty.request.contenu}
331{if !$smarty.request.contenu}
332--
48e683dd 333{$smarty.session.user->full_name}
0337d704 334{/if}</textarea>
da419622 335 <script type="text/javascript">//<![CDATA[
336 {literal}
337 function removeAttachments()
338 {
b0e935d6
FB
339 $.xget('email/send');
340 $('#att_already').hide();
341 $('#att_form').show();
da419622 342 }
343 {/literal}
344 //]]></script>
345 {if $uploaded_f|@count}
346 <div id="att_already">
347 <strong>{icon name=email_attach}&nbsp;Pièce jointe&nbsp;:&nbsp;</strong>
348 {$uploaded_f[0]}
349 <a href="javascript:removeAttachments()">
5124d583 350 {icon name=cross alt="Supprimer" title="Supprimer la pièce jointe"}
da419622 351 </a>
352 </div>
353 {/if}
354 <div id="att_form" {if $uploaded_f|@count neq 0}style="display: none"{/if}>
f3fb8eda 355 <strong>{icon name=email_attach}&nbsp;Ajouter une pièce jointe (max. {$maxsize})&nbsp;:&nbsp;</strong>
91a14f73 356 <input type="file" name="uploaded" />
357 </div>
358 <div class="center">
3360c04f
FB
359 <input type="submit" name="preview" id="preview_bt" value="Aperçu"
360 onclick="previewWiki('mail_text', 'mail_preview', true, 'preview_pv'); return false;" />
91a14f73 361 <input type="submit" name="submit" value="Envoyer" />
362 </div>
363 </fieldset>
0337d704 364</form>
365
366
448c8cdc 367{* vim:set et sw=2 sts=2 sws=2 fenc=utf-8: *}