1 {% extends 'page.html.twig' %}
4 {% if preferences.pref_mail_method == constant('Galette\\Core\\Mailing::METHOD_DISABLED') and not callstatic('\\Galette\\Core\\Galette', 'isDemo') %}
5 <div id="errorbox" class="ui negative icon message">
6 <i class="ban icon" aria-hidden="true"></i>
8 <p>{{ _T("Email sent is disabled in the preferences. Ask galette admin") }}</p>
11 {% elseif mailing_saved is not defined %}
12 <form action="{{ url_for('doMailing') }}" id="listform" method="post" enctype="multipart/form-data" class="ui form">
13 <div class="ui basic fitted segment">
14 <div class="ui styled fluid accordion row">
15 <div class="active title">
16 <i class="jsonly displaynone icon dropdown" aria-hidden="true"></i>
17 {{ _T("Mailing information") }}
19 <div class="active content field">
20 <div class="three fields">
22 <label for="sender">{{ _T("Sender") }}</label>
23 <select name="sender" id="sender" class="ui dropdown">
24 <option value="{{ constant('Galette\\Core\\GaletteMail::SENDER_PREFS') }}">{{ _T("from preferences") }}</option>
25 {% if not login.isSuperAdmin() %}
26 <option value="{{ constant('Galette\\Core\\GaletteMail::SENDER_CURRENT') }}">{{ _T("current logged in user") }}</option>
28 <option value="{{ constant('Galette\\Core\\GaletteMail::SENDER_OTHER') }}">{{ _T("other") }}</option>
31 <div class="field required">
32 <label for="sender_name">{{ _T("Name") }}</label>
33 <input type="text" name="sender_name" id="sender_name" value="{{ preferences.pref_email_nom }}" disabled="disabled"/>
35 <div class="field required">
36 <label for="sender_address">{{ _T("Address") }}</label>
37 <input type="text" name="sender_address" id="sender_address" value="{{ preferences.pref_email }}" disabled="disabled"/>
40 <div class="ui section divider"></div>
41 <div class="two fields">
43 <label>{{ _T("Recipients") }}</label>
44 {% include "elements/mailing_recipients.html.twig" %}
45 {% if mailing.current_step == constant('Galette\\Core\\Mailing::STEP_SENT') %}
46 {% set path = url_for('members') %}
47 {% set text = _T("Go back to members list") %}
50 {% set text = _T("Manage selected members") %}
55 class="jsonly disabled ui labeled icon button"
57 <i class="blue users icon" aria-hidden="true"></i>
61 <div class="ui compact message">{{ _T("This feature requires javascript.") }}</div>
64 {% if mailing.current_step == constant('Galette\\Core\\Mailing::STEP_START') %}
66 {% if attachments|length > 0 %}
67 <div class="ui tiny header">
68 <i class="paperclip icon" aria-hidden="true"></i>
69 <div class="content">{{ _T("Existing attachments:") }}</div>
71 <div id="existing_attachments" class="ui middle aligned divided selection list">
72 {% for attachment in attachments %}
76 href="?remove_attachment={{ attachment.getFileName() }}"
77 class="rm_attachement delete"
79 <i class="ui trash alt red icon tooltip" aria-hidden="true"></i>
80 <span class="ui special popup">{{ _T("Remove attachment") }}</span>
82 {{ attachment.getFileName() }}
88 <div class="ui tiny header">
89 <i class="paperclip icon" aria-hidden="true"></i>
90 <div class="content">{{ _T("Attachments") }}</div>
93 <div class="ui file action input">
94 <div class="ui corner labeled input">
95 <input type="file" name="attachment[]" id="attachment" multiple="multiple"/>
96 <div class="ui corner label">
97 <i class="circular inverted primary icon info tooltip" data-html="{{ _T("Select files to add as attachments.<br/>Multiple file selection using 'ctrl' or 'shift' keys are only available on compatible browsers.") }}" aria-hidden="true"></i>
100 <label for="attachment" class="ui button">
101 <i class="blue upload icon" aria-hidden="true"></i>
102 {{ _T("Add attachment") }}
111 {% if mailing.current_step == constant('Galette\\Core\\Mailing::STEP_START') %}
113 <div class="ui basic fitted segment">
114 <div class="ui styled fluid accordion row">
115 <div class="active title">
116 <i class="jsonly displaynone icon dropdown" aria-hidden="true"></i>
117 {{ _T("Write your mailing") }}
119 <div class="active content field">
120 <div class="field required">
121 <label for="mailing_objet">{{ _T("Object:") }}</label>
122 <input type="text" name="mailing_objet" id="mailing_objet" value="{{ mailing.subject }}" size="80" required/>
124 <div class="field required">
125 <label for="mailing_corps">{{ _T("Message:") }}</label>
126 <textarea name="mailing_corps" id="mailing_corps" cols="80" rows="15" required>{% if mailing.message %}{{ mailing.message|escape }}{% endif %}</textarea>
127 <input type="hidden" name="html_editor_active" id="html_editor_active" value="{% if html_editor_active %}1{% else %}0{% endif %}"/>
129 <div class="ui basic horizontal equal width segments">
130 <div class="ui basic fitted segment">
131 <div class="ui toggle checkbox">
132 <input type="checkbox" name="mailing_html" id="mailing_html" value="1" {% if mailing.html == 1 or preferences.pref_editor_enabled == 1 %}checked="checked"{% endif %}/>
133 <label for="mailing_html">{{ _T("Interpret HTML") }}</label>
136 <div id="summernote_toggler" class="jsonly hidden ui basic fitted right aligned segment">
137 <a class="ui blue tertiary button" href="javascript:activateMailingEditor('mailing_corps');" id="activate_editor">{{ _T("Activate HTML editor") }}</a>
140 <div class="inline field">
146 <div class="ui basic center aligned segment">
147 <div class="ui wrapping spaced buttons">
148 <button type="submit" name="mailing_go" id="btnpreview" class="ui labeled icon button">
149 <i class="eye blue icon" aria-hidden="true"></i>
152 <button type="submit" name="mailing_save" class="ui labeled icon button action">
153 <i class="save green icon" aria-hidden="true"></i>
156 <button type="submit" name="mailing_confirm" class="ui labeled icon button {% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} disabled" disabled="disabled{% endif %}">
157 <i class="rocket red icon" aria-hidden="true"></i>
160 <button type="submit" name="mailing_cancel" formnovalidate class="ui labeled icon button">
161 <i class="times icon" aria-hidden="true"></i>
162 {{ _T("Cancel mailing") }}
167 {% if mailing.current_step == constant('Galette\\Core\\Mailing::STEP_PREVIEW') %}
168 <div class="ui basic fitted segment">
169 <div class="ui styled fluid accordion row">
170 <div class="active title">
171 <i class="jsonly hidden icon dropdown" aria-hidden="true"></i>
172 {{ _T("Preview your mailing") }}
174 <div class="active content field">
175 <table class="ui very basic striped unstackable table">
178 <th class="two wide">{{ _T("Subject:") }}</th>
179 <td>{{ mailing.subject }}</td>
182 <th class="two wide">{{ _T("Message:") }}</th>
184 {% if mailing.html %}
185 {{ mailing.message }}
187 <pre>{{ mailing.wrapped_message }}</pre>
198 <div class="ui basic center aligned segment">
199 <div class="ui wrapped wrapping spaced buttons">
200 <button type="submit" name="mailing_reset" class="ui labeled icon button">
201 <i class="backward icon" aria-hidden="true"></i>
202 {{ _T("Modifiy mailing") }}
204 <button type="submit" name="mailing_confirm"{% if callstatic('\\Galette\\Core\\Galette', 'isDemo') %} class="ui labeled icon button disabled" disabled="disabled"{% else %} class="ui labeled icon button"{% endif %}>
205 <i class="rocket icon" aria-hidden="true"></i>
208 <button type="submit" name="mailing_cancel" formnovalidate class="ui labeled icon button">
209 <i class="trash red icon" aria-hidden="true"></i>
210 {{ _T("Cancel mailing") }}
213 <input type="hidden" name="mailing_objet" value="{{ mailing.subject }}"/>
214 <input type="hidden" name="mailing_corps" value="{% if mailing.message %}{{ mailing.message|escape }}{% endif %}"/>
218 {% include "components/forms/csrf.html.twig" %}
223 {% block javascripts %}
224 {% if (preferences.pref_mail_method != constant('Galette\\Core\\Mailing::METHOD_DISABLED') or not callstatic('\\Galette\\Core\\Galette', 'isDemo')) and mailing_saved is not defined %}
225 {% if mailing.current_step != constant('Galette\\Core\\Mailing::STEP_SENT') %}
226 <script type="text/javascript">
229 $('#btnpreview').click(function(){
230 var _sender = $('#sender').val();
231 var _sender_name = $('#sender_name').val();
232 var _sender_address = $('#sender_address').val();
233 var _subject = $('#mailing_objet').val();
234 var _body = $('#mailing_corps').val();
235 var _html = $('#mailing_html').is(':checked');
236 var _attachments = [];
237 $('#existing_attachments .item').each(function(){
238 _attachments[_attachments.length] = $(this).text();
241 url: '{{ url_for('mailingPreview') }}',
245 sender_name: _sender_name,
246 sender_address: _sender_address,
250 attachments: _attachments
252 {% include "elements/js/loader.js.twig" with {
253 selector: '#btnpreview',
256 success: function(res){
257 _preview_dialog(res);
260 {% include "elements/js/modal.js.twig" with {
261 modal_title_twig: _T("An error occurred displaying preview :(")|e("js"),
262 modal_without_content: true,
264 modal_deny_only: true,
265 modal_cancel_text: _T("Close")|e("js"),
266 modal_classname: "redalert",
273 var _preview_dialog = function(res){
274 {% include "elements/js/modal.js.twig" with {
275 modal_title_twig: _T("Mailing preview")|e("js"),
276 modal_content: "res",
277 modal_class: "scrolling",
278 modal_deny_only: true,
279 modal_cancel_text: _T("Close")|e("js")
284 $('#btnusers').click(function(){
286 url: '{{ url_for('ajaxMembers') }}',
291 {% include "elements/js/loader.js.twig" with {
292 selector: '#btnusers',
295 success: function(res){
296 _members_dialog(res);
299 {% include "elements/js/modal.js.twig" with {
300 modal_title_twig: _T("An error occurred displaying members interface :(")|e("js"),
301 modal_without_content: true,
303 modal_deny_only: true,
304 modal_cancel_text: _T("Close")|e("js"),
305 modal_classname: "redalert",
312 var _members_dialog = function(res){
313 {% include "elements/js/modal.js.twig" with {
314 modal_title_twig: _T("Members selection")|e("js"),
315 modal_content: "res",
316 modal_class: "members-selection fullscreen",
317 modal_content_class: "scrolling",
318 modal_deny_only: true,
319 modal_cancel_text: _T("Close")|e("js")
321 _members_ajax_mapper(res);
324 var _members_ajax_mapper = function(res){
325 $('#btnvalid').click(function(){
326 //first, let's store new recipients in mailing object
327 var _recipients = new Array();
328 $('li[id^="member_"]').each(function(){
329 _recipients[_recipients.length] = this.id.substring(7, this.id.length);
332 url: '{{ url_for('mailingRecipients') }}',
335 recipients: _recipients
337 {% include "elements/js/loader.js.twig" with {
338 selector: '#btnvalid',
341 success: function(res){
342 $('#unreachables_count').remove();
343 $('#recipients_count').replaceWith(res);
344 $('.members-selection').modal('hide');
347 {% include "elements/js/modal.js.twig" with {
348 modal_title_twig: _T("An error occurred displaying members interface :(")|e("js"),
349 modal_without_content: true,
351 modal_deny_only: true,
352 modal_cancel_text: _T("Close")|e("js"),
353 modal_classname: "redalert",
359 var _none = $('#none_selected').clone();
360 $('li[id^="member_"]').click(function(){
362 if ( $('#selected_members ul li').length == 0 ) {
363 $('#selected_members ul').append(_none);
366 $('#listing tbody tr').click(function(event){
367 event.preventDefault();
368 var _mlink = $(this).find('.username_row a');
369 var _mid = _mlink[0].href.match(/.*\/(\d+)$/)[1];
370 var _mname = _mlink.text();
371 $('#none_selected').remove()
372 if ( $('#member_' + _mid).length == 0 ) {
373 var _li = '<li id="member_' + _mid + '" class="item"><i class="ui user minus icon" aria-hidden="true"></i><span class="ui content">' + _mname + '</span></li>';
374 $('#selected_members ul').append(_li);
375 $('#member_' + _mid).click(function(){
377 if ( $('#selected_members ul li').length == 0 ) {
378 $('#selected_members ul').append(_none);
383 }).css('cursor', 'pointer').attr('title', '{{ _T("Click on a row to select a member")|e('js') }}');
385 $('.members-selection .pagination a').click(function(){
386 var _members = new Array();
387 var _unreach = new Array();
388 $('li[id^="member_"]').each(function(){
389 var _mid = this.id.substring(7, this.id.length);
390 if ($(this).hasClass('unreachables')) {
391 _unreach[_unreach.length] = _mid;
393 _members[_members.length] = _mid;
403 unreachables: _unreach
405 {% include "elements/js/loader.js.twig" with {
408 success: function(res){
409 $('#listing').remove();
410 var _listing = $($.parseHTML(res)).find('#listing');
411 $('.members-selection .eleven.wide.column').append(_listing);
412 _members_ajax_mapper(res);
415 {% include "elements/js/modal.js.twig" with {
416 modal_title_twig: _T("An error occurred displaying members interface :(")|e("js"),
417 modal_without_content: true,
419 modal_deny_only: true,
420 modal_cancel_text: _T("Close")|e("js"),
421 modal_classname: "redalert",
429 {% set modal_onapprove = "window.location.href = '" ~ url_for('mailing') ~ "' + _link.attr('href');" %}
430 $('.rm_attachement').click(function(event){
431 event.preventDefault();
433 {% set modal_content = _T("Are you sure you want to remove this attachment?") ~ '<br/>' ~ _T("This will immediately remove attachment from disk and cannot be undone.") %}
434 {% include "elements/js/modal.js.twig" with {
435 modal_title_twig: _T("Remove attachment")|e("js"),
436 modal_content_twig: modal_content|e("js"),
438 modal_onapprove: modal_onapprove,
439 modal_approve_text: _T("Remove")|e('js'),
440 modal_approve_icon: "trash",
441 modal_approve_color: "red",
442 modal_cancel_text: _T("Cancel")|e("js"),
443 modal_classname: "redalert",
447 $('#sender').on('change', function() {
449 var _sender_name = $('#sender_name');
450 var _sender_address = $('#sender_address');
451 var _editable = false;
452 var _val = _this.val();
454 case '{{ constant('Galette\\Core\\GaletteMail::SENDER_PREFS') }}':
455 _sender_name.val('{{ preferences.pref_email_nom|e('js') }}');
456 _sender_address.val('{{ preferences.pref_email|e('js') }}');
459 {% if not login.isSuperAdmin() %}
460 case '{{ constant('Galette\\Core\\GaletteMail::SENDER_CURRENT') }}':
461 _sender_name.val('{{ sender_current['name']|e('js') }}');
462 _sender_address.val('{{ sender_current['email']|e('js') }}');
465 case '{{ constant('Galette\\Core\\GaletteMail::SENDER_OTHER') }}':
466 _sender_name.val('');
467 _sender_address.val('');
473 _sender_name.removeAttr('disabled');
474 _sender_address.removeAttr('disabled');
475 $('#sender + span').removeClass('disabled');
477 _sender_name.attr('disabled', 'disabled');
478 _sender_address.attr('disabled', 'disabled');
479 $('#sender + span').addClass('disabled');