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