1 {% extends 'page.html.twig' %}
4 {% if preferences.pref_mail_method == constant('Galette\\Core\\Mailing::METHOD_DISABLED') and constant('GALETTE_MODE') != 'DEMO' %}
5 <div id="errorbox" class="ui red message">
6 <h1>{{ _T("- ERROR -") }}</h1>
7 <p>{{ _T("Email sent is disabled in the preferences. Ask galette admin") }}</p>
9 {% elseif mailing_saved is not defined %}
10 <form action="{{ path_for('doMailing') }}" id="listform" method="post" enctype="multipart/form-data" class="ui form">
11 <div class="ui basic fitted segment">
12 <div class="ui styled fluid accordion row">
13 <div class="active title">
14 <i class="jsonly hidden icon dropdown"></i>
15 {{ _T("Mailing information") }}
17 <div class="active content field">
18 {% include "elements/mailing_recipients.html.twig" %}
19 {% if mailing.current_step == constant('Galette\\Core\\Mailing::STEP_SENT') %}
20 {% set path = path_for('members') %}
21 {% set text = _T("Go back to members list") %}
24 {% set text = _T("Manage selected members") %}
29 class="jsonly disabled ui labeled icon button"
31 <i class="users icon"></i>
35 <div class="ui message">{{ _T("This feature requires javascript.") }}</div>
40 {% if mailing.current_step == constant('Galette\\Core\\Mailing::STEP_START') %}
41 <div class="ui basic fitted segment">
42 <div class="ui styled fluid accordion row">
43 <div class="active title">
44 <i class="jsonly hidden icon dropdown"></i>
45 {{ _T("Attachments") }}
47 <div class="active content field">
48 {% if attachments|length > 0 %}
50 {{ _T("Existing attachments:") }}
52 <ul id="existing_attachments">
53 {% for attachment in attachments %}
56 href="?remove_attachment={{ attachment.getFileName() }}"
57 class="rm_attachement tooltip delete"
59 <i class="ui trash alt red icon"></i>
60 <span class="sr-only">{{ _T("Remove attachment") }}</span>
62 {{ attachment.getFileName() }}
67 <label for="attachment" title="{{ _T("Select attachments") }}">{{ _T("Add attachment") }}</label>
68 <div class="ui right corner labeled input">
69 <div class="ui corner label">
70 <i class="circular inverted primary link icon info tooltip" title="{{ _T("Select files to add as attachments.<br/>Multiple file selection using 'ctrl' or 'shift' keys are only available on compatible browsers.") }}"></i>
72 <input type="file" name="attachment[]" id="attachment" multiple="multiple">
78 <div class="ui basic fitted segment">
79 <div class="ui styled fluid accordion row">
80 <div class="active title">
81 <i class="jsonly hidden icon dropdown"></i>
82 {{ _T("Write your mailing") }}
84 <div class="active content field">
85 <div class="inline field">
86 <label for="sender">{{ _T("Sender") }}</label>
87 <select name="sender" id="sender" class="ui dropdown nochosen">
88 <option value="{{ constant('Galette\\Core\\GaletteMail::SENDER_PREFS') }}">{{ _T("from preferences") }}</option>
89 {% if not login.isSuperAdmin() %}
90 <option value="{{ constant('Galette\\Core\\GaletteMail::SENDER_CURRENT') }}">{{ _T("current logged in user") }}</option>
92 <option value="{{ constant('Galette\\Core\\GaletteMail::SENDER_OTHER') }}">{{ _T("other") }}</option>
95 <div class="field required">
96 <label for="sender_name">{{ _T("Name") }}</label>
97 <input type="text" name="sender_name" id="sender_name" value="{{ preferences.pref_email_nom }}" disabled="disabled"/>
99 <div class="field required">
100 <label for="sender_address">{{ _T("Address") }}</label>
101 <input type="text" name="sender_address" id="sender_address" value="{{ preferences.pref_email }}" disabled="disabled"/>
103 <div class="field required">
104 <label for="mailing_objet">{{ _T("Object:") }}</label>
105 <input type="text" name="mailing_objet" id="mailing_objet" value="{{ mailing.subject }}" size="80" required/>
107 <div class="field required">
108 <label for="mailing_corps">{{ _T("Message:") }}</label>
109 <textarea name="mailing_corps" id="mailing_corps" cols="80" rows="15" required>{% if mailing.message %}{{ mailing.message|escape }}{% endif %}</textarea>
110 <input type="hidden" name="html_editor_active" id="html_editor_active" value="{% if html_editor_active %}1{% else %}0{% endif %}"/>
112 <div id="summernote_toggler" class="jsonly hidden ui basic right aligned fitted segment">
113 <a class="ui blue tertiary button" href="javascript:activateMailingEditor('mailing_corps');" id="activate_editor">{{ _T("Activate HTML editor") }}</a>
115 <div class="inline field">
116 <input type="checkbox" name="mailing_html" id="mailing_html" value="1" {% if mailing.html == 1 or preferences.pref_editor_enabled == 1 %}checked="checked"{% endif %}/><label for="mailing_html">{{ _T("Interpret HTML") }}</label>
122 <div class="ui basic center aligned segment">
123 <button type="submit" name="mailing_go" id="btnpreview" class="ui labeled icon button">
124 <i class="eye icon" aria-hidden="true"></i>
127 <button type="submit" name="mailing_save" class="ui labeled icon button action">
128 <i class="save icon" aria-hidden="true"></i>
131 <button type="submit" name="mailing_confirm" class="ui labeled icon button {% if constant('GALETTE_MODE') == 'DEMO' %} disabled" disabled="disabled{% endif %}">
132 <i class="rocket icon" aria-hidden="true"></i>
135 <button type="submit" name="mailing_cancel" formnovalidate class="ui labeled icon button">
136 <i class="trash icon" aria-hidden="true"></i>
137 {{ _T("Cancel mailing") }}
141 {% if mailing.current_step == constant('Galette\\Core\\Mailing::STEP_PREVIEW') %}
142 <section class="mailing_write" id="mail_preview">
143 <header class="ui-state-default ui-state-active">{{ _T("Preview your mailing") }}</header>
145 <p><span class="bline">{{ _T("Object:") }}</span>{{ mailing.subject }}</p>
147 <span class="bline">{{ _T("Message:") }}</span><br/>
148 {% if mailing.html %}
149 {{ mailing.message }}
151 <pre>{{ mailing.wrapped_message }}</pre>
157 <button type="submit" name="mailing_reset" class="ui labeled icon button">
158 <i class="backward icon"></i>
159 {{ _T("Modifiy mailing") }}
161 <button type="submit" name="mailing_confirm"{% if constant('GALETTE_MODE') == 'DEMO' %} class="ui labeled icon button disabled" disabled="disabled"{% else %} class="ui labeled icon button"{% endif %}>
162 <i class="rocket icon" aria-hidden="true"></i>
165 <button type="submit" name="mailing_cancel" formnovalidate class="ui labeled icon button">
166 <i class="trash red icon" aria-hidden="true"></i>
167 {{ _T("Cancel mailing") }}
170 <input type="hidden" name="mailing_objet" value="{{ mailing.subject }}"/>
171 <input type="hidden" name="mailing_corps" value="{% if mailing.message %}{{ mailing.message|escape }}{% endif %}"/>
176 {% include "components/forms/csrf.html.twig" %}
181 {% block javascripts %}
182 {% if (preferences.pref_mail_method != constant('Galette\\Core\\Mailing::METHOD_DISABLED') or constant('GALETTE_MODE') != 'DEMO') and mailing_saved is not defined %}
183 {% if mailing.current_step != constant('Galette\\Core\\Mailing::STEP_SENT') %}
184 <script type="text/javascript">
187 $('#btnpreview').click(function(){
188 var _sender = $('#sender').val();
189 var _sender_name = $('#sender_name').val();
190 var _sender_address = $('#sender_address').val();
191 var _subject = $('#mailing_objet').val();
192 var _body = $('#mailing_corps').val();
193 var _html = $('#mailing_html').is(':checked');
194 var _attachments = [];
195 $('#existing_attachments li').each(function(){
196 _attachments[_attachments.length] = $(this).text();
199 url: '{{ path_for('mailingPreview') }}',
203 sender_name: _sender_name,
204 sender_address: _sender_address,
208 attachments: _attachments
210 {% include "elements/js/loader.js.twig" %},
211 success: function(res){
212 _preview_dialog(res);
215 alert("{{ _T("An error occurred displaying preview :(")|e("js") }}");
221 var _preview_dialog = function(res){
223 title: '{{ _T("Mailing preview")|e("js") }}',
227 text : '{{ _T("Close")|e('js') }}',
234 $('#btnusers').click(function(){
236 url: '{{ path_for('ajaxMembers') }}',
241 {% include "elements/js/loader.js.twig" with {
242 selector: '#btnusers',
245 success: function(res){
246 _members_dialog(res);
249 alert("{{ _T("An error occurred displaying members interface :(")|e("js") }}");
255 var _members_dialog = function(res){
257 title: '{{ _T("Members selection")|e("js") }}',
258 class: 'members-selection fullscreen scrolling',
261 text : '{{ _T("Close")|e('js') }}',
265 _members_ajax_mapper(res);
268 var _members_ajax_mapper = function(res){
269 $('#btnvalid').click(function(){
270 //first, let's store new recipients in mailing object
271 var _recipients = new Array();
272 $('li[id^="member_"]').each(function(){
273 _recipients[_recipients.length] = this.id.substring(7, this.id.length);
276 url: '{{ path_for('mailingRecipients') }}',
279 recipients: _recipients
281 {% include "elements/js/loader.js.twig" with {
282 selector: '#btnvalid',
285 success: function(res){
286 $('#unreachables_count').remove();
287 $('#recipients_count').replaceWith(res);
288 $('.members-selection').modal('hide');
291 alert("{{ _T("An error occurred displaying members interface :(")|e("js") }}");
296 var _none = $('#none_selected').clone();
297 $('li[id^="member_"]').click(function(){
299 if ( $('#selected_members ul li').length == 0 ) {
300 $('#selected_members ul').append(_none);
303 $('.members-selection a.choice').click(function(e){
305 var _mid = this.href.match(/.*\/(\d+)$/)[1];
306 var _mname = $(this).text();
307 $('#none_selected').remove()
308 if ( $('#member_' + _mid).length == 0 ) {
309 var _li = '<li id="member_' + _mid + '" class="item"><i class="user minus icon"></i><span class="ui content">' + _mname + '</span></li>';
310 $('#selected_members ul').append(_li);
311 $('#member_' + _mid).click(function(){
313 if ( $('#selected_members ul li').length == 0 ) {
314 $('#selected_members ul').append(_none);
321 $('.members-selection .pagination a').click(function(){
322 var _members = new Array();
323 var _unreach = new Array();
324 $('li[id^="member_"]').each(function(){
325 var _mid = this.id.substring(7, this.id.length);
326 if ($(this).hasClass('unreachables')) {
327 _unreach[_unreach.length] = _mid;
329 _members[_members.length] = _mid;
339 unreachables: _unreach
341 {% include "elements/js/loader.js.twig" with {
344 success: function(res){
345 $('#listing').remove();
346 var _listing = $($.parseHTML(res)).find('#listing');
347 $('.members-selection .eleven.wide.column').append(_listing);
348 _members_ajax_mapper(res);
351 alert("{{ _T("An error occurred displaying members interface :(")|e("js") }}");
358 $('.rm_attachement').click(function(){
361 title: '{{ _T("Remove attachment") }}',
362 class: 'fullscreen scrolling',
363 content: '{{ _T("Are you sure you want to remove this attachment?") }}<br/>{{ _T("This will immediately remove attachment from disk and cannot be undo.") }}',
365 text : '{{ _T("Remove")|e('js') }}',
366 class : 'red approve',
368 window.location.href = '{{ path_for('mailing') }}' + _link.attr('href');
371 text : '{{ _T("Cancel")|e('js') }}',
378 $('#sender').on('change', function() {
380 var _sender_name = $('#sender_name');
381 var _sender_address = $('#sender_address');
382 var _editable = false;
383 var _val = _this.val();
385 case '{{ constant('Galette\\Core\\GaletteMail::SENDER_PREFS') }}':
386 _sender_name.val('{{ preferences.pref_email_nom|e('js') }}');
387 _sender_address.val('{{ preferences.pref_email|e('js') }}');
390 {% if not login.isSuperAdmin() %}
391 case '{{ constant('Galette\\Core\\GaletteMail::SENDER_CURRENT') }}':
392 _sender_name.val('{{ sender_current['name']|e('js') }}');
393 _sender_address.val('{{ sender_current['email']|e('js') }}');
396 case '{{ constant('Galette\\Core\\GaletteMail::SENDER_OTHER') }}':
397 _sender_name.val('');
398 _sender_address.val('');
404 _sender_name.removeAttr('disabled');
405 _sender_address.removeAttr('disabled');
406 $('#sender + span').removeClass('disabled');
408 _sender_name.attr('disabled', 'disabled');
409 _sender_address.attr('disabled', 'disabled');
410 $('#sender + span').addClass('disabled');