~eventum-developers/eventum/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
{extends "base.tpl.html"}
{block "title"}Issue #{$issue_id} - Reply{/block}

{block "content"}
{if $send_result|default:'' != ''}
<br />
<center>
{if $send_result == -1}
  <span>{t}An error occurred while trying to run your query{/t}</span>
{elseif $send_result == -2}
  <span>{t}Sorry, but the email could not be queued. This might be related to problems with your SMTP account settings.{/t}<br />
 {t}Please contact the administrator of this application for further assistance.{/t}</span>
{elseif $send_result == 1}
  <span>{t}Thank you, the email was queued to be sent successfully.{/t}</span>
  {include file="app_messages.tpl.html"}
{/if}

</center>
<script type="text/javascript">
<!--
{if $current_user_prefs.close_popup_windows}
setTimeout('Eventum.close_and_refresh()', 2000);
{/if}
//-->
</script>
<br />
{if not $current_user_prefs.close_popup_windows}
  <center>
    <span><a href="javascript:void(null);" onClick="Eventum.close_and_refresh();">{t}Continue{/t}</a></span>
  </center>
{/if}
{elseif $draft_result|default:'' != ''}
<br />
<center>
  <span>
{if $draft_result|default:'' == -1}
  {t}An error occurred while trying to run your query{/t}
{elseif $draft_result|default:'' == 1}
  {t}Thank you, the email message was saved as a draft successfully.{/t}
{/if}
  </span>
</center>
<script type="text/javascript">
<!--
{if $current_user_prefs.close_popup_windows == '1'}
setTimeout('Eventum.close_and_refresh()', 2000);
{/if}
//-->
</script>
<br />
{if not $current_user_prefs.close_popup_windows}
  <center>
    <span><a href="javascript:void(null);" onClick="Eventum.close_and_refresh();">{t}Continue{/t}</a></span>
  </center>
{/if}
{else}
<script type="text/javascript">
<!--
$(function() {
    Eventum.checkWindowClose('{t}If you close this window, you will lose your message{/t}');
});

{if not $core.is_current_user_partner}
var contact_list = new Array();
{section name="i" loop=$assoc_emails}
contact_list[contact_list.length] = '{$assoc_emails[i]|replace:"'":"\\'"}';
{/section}
{/if}

var email_responses = new Array();
{section name="i" loop=$js_canned_responses}
email_responses[{$js_canned_responses[i].ere_id}] = "{$js_canned_responses[i].ere_response_body}";
{/section}
{literal}
function validateForm()
{
    var to_field = Eventum.getField('to');
    if (to_field.length > 0) {
        if (Validation.isFieldWhitespace(to_field)) {
            Validation.errors[Validation.errors.length] = new Option('{/literal}{t escape=js}To{/t}{literal}', 'to');
        }
    }
    if (Validation.isFieldWhitespace('subject')) {
        Validation.errors[Validation.errors.length] = new Option('{/literal}{t escape=js}Subject{/t}{literal}', 'subject');
    }
    if (Validation.isFieldWhitespace('message')) {
        Validation.errors[Validation.errors.length] = new Option('{/literal}{t escape=js}Message{/t}{literal}', 'message');
    }

{/literal}
{if $core.current_role != $core.roles.customer and $issue_id != 0}
    {if !$can_send_email}
    var warning_msg = "{t}WARNING: You are not assigned to this issue so your email will be blocked.\\nYour blocked email will be converted to a note that can be recovered later.\\nFor more information, please see the topic 'email blocking' in help.{/t}";
    {elseif $core.has_crm}
    var warning_msg = "{t}WARNING: This email will be sent to all names on this issue's Notification List, including CUSTOMERS.\\nIf you want the CUSTOMER to receive your message now, press OK.\\nOtherwise, to return to your editing window, press CANCEL.{/t}";
    {else}
    var warning_msg = "{t}WARNING: This email will be sent to all names on this issue's Notification List.\\nIf you want all users to receive your message now, press OK.\\nOtherwise, to return to your editing window, press CANCEL.{/t}";
    {/if}
{literal}
    if ((Validation.errors.length > 1) || !confirm(warning_msg)) {
        return false;
    } else {
        Eventum.checkWindowClose(false);
        return true;
    }
{/literal}
{else}
    Eventum.checkWindowClose(false);
    return true;
{/if}
{literal}
}
function setResponseBody()
{
    var response_id = Eventum.getField('email_response').val();
    if (email_responses[response_id]) {
        Eventum.getField('message').val(email_responses[response_id]);
    }
}
function saveDraft()
{
    Eventum.checkWindowClose(false);
    Eventum.getField('cat').val('save_draft');
    Eventum.getField('send_email_form').submit();
}
function updateDraft(f)
{
    Eventum.checkWindowClose(false);
    Eventum.getField('cat').val('update_draft');
    Eventum.getField('send_email_form').submit();
}
var old_message = '';
function setSignature(f)
{
{/literal}
    var signature = "{$current_user_prefs.email_signature|replace:'"':'\"'|replace:"\r":""|replace:"\n":'\n'}";
{literal}
    if (f.add_email_signature.checked) {
        old_message = f.message.value;
        f.message.value += "\n";
        f.message.value += signature;
    } else {
        f.message.value = old_message;
    }
}

$().ready(function() {
   Eventum.getField('message').focus();
});
//-->
</script>
{/literal}
<form  class="validate" data-validation-function='validateForm' name="send_email_form" method="post" action="{$smarty.server.PHP_SELF}" enctype="multipart/form-data">
<input type="hidden" name="cat" value="send_email">
<input type="hidden" name="parent_id" value="{$parent_email_id|default:''}">
<input type="hidden" name="ema_id" value="{$ema_id|default:''}">
<input type="hidden" name="issue_id" value="{$issue_id|default:''}">
{if $smarty.get.cat|default:'' == 'view_draft'}
<input type="hidden" name="draft_id" value="{$draft_id|default:''}">
{/if}
{if $draft_status|default:'' == 'sent'}
    <br /><center class="banner_red"><img src="images/icons/error.gif"> {t}Warning: This draft has already been sent. You cannot resend it.{/t}</center>
{elseif $draft_status|default:'' == 'edited'}
    <br /><center class="banner_red"><img src="images/icons/error.gif"> {t}Warning: This draft has already been edited. You cannot send or edit it.{/t}</center>
{/if}
  <table class="bordered">
    <tr class="title">
      <th colspan="2">
        {if $smarty.get.cat|default:'' == 'create_draft'}
            {t}Create Draft{/t}
        {else}
            {t}Send Email{/t}
        {/if}
      </th>
    </tr>
    <tr>
      <th width="120">
        {t}From{/t}
      </th>
      <td>
        <input type="hidden" name="from" value="{$from|escape:"html"}">
        {$from|escape:"html"}
      </td>
    </tr>
    <tr>
      <th width="120">
        {t}To{/t} *
      </th>
      <td>
        {if $issue_id == ''}
            <input type="text" name="to" size="50" value="{$email.sup_from|escape:"html"}">
            {include file="error_icon.tpl.html" field="to"}
        {else}
            <span>{t}Issue{/t} #{$issue_id} {t}Notification List{/t} ({t}Members{/t}: {$subscribers.staff|replace:"<":"&lt;"|replace:">":"&gt;"}{if $subscribers.customers != ''}, {$subscribers.customers|replace:"<":"&lt;"|replace:">":"&gt;"}{/if})</span>
        {/if}
      </td>
    </tr>
    <tr>
      <th width="120">
        {t}Cc{/t}
      </th>
      <td>
        <input type="text" name="cc" size="50" value="{$email.cc|default:''|escape:"html"}" {if $read_only|default:'' == 1}readonly{/if}>
          {include file="error_icon.tpl.html" field="cc"}<br />
        {if $issue_id and $core.current_role != $core.roles.customer and $read_only|default:'' != 1}
        <label>
            <input type="checkbox" name="add_unknown" value="yes">
            {t}Add Unknown Recipients to Issue Notification List{/t}
        </label>
        {else}
        <input type="hidden" name="add_unknown" value="no">
        {/if}
      </td>
    </tr>
    <tr>
      <th width="120">
        {t}Subject{/t} *
      </th>
      <td>
        <input type="text" name="subject" size="50" value="{if $smarty.get.cat|default:'' == 'view_draft'}{$email.sup_subject|escape:"html"}{else}{$email.reply_subject|default:''|escape:"html"}{/if}" {if $read_only|default:'' == 1}readonly{/if}>
        {include file="error_icon.tpl.html" field="subject"}
      </td>
    </tr>
    {if $core.current_role != $core.roles.customer and $canned_responses|@count > 0 and $read_only|default:'' != 1}
    <tr class="internal">
      <th>
        {t}Canned Responses{/t} {$canned_responses}
      </th>
      <td>
        <select name="email_response">
          {html_options options=$canned_responses}
        </select>&nbsp;<input type="button" class="shortcut" value="{t}Use Canned Response{/t}" onClick="setResponseBody(this.form);"><br />
      </td>
    </tr>
    {/if}
    <tr>
      <td colspan="2">
        <textarea name="message" rows="15" style="width: 97%" {if $read_only|default:'' == 1}readonly{/if}>{$email.seb_body|escape:"html"|default:''}{if $current_user_prefs.auto_append_email_sig == 1 && $body_has_sig_already != 1}


{$current_user_prefs.email_signature|escape:"html"}{/if}</textarea>
        {include file="error_icon.tpl.html" field="message"}
      </td>
    </tr>
    <tr>
      <th width="120">
        Attachment
      </th>
      <td >
        <input type="file" name="attachment[]" size="30"></input>
      </td>
    </tr>
    {if $issue_id and $core.current_role > $core.roles.customer and $read_only|default:'' != 1}
        {if $hide_email_buttons|default:'' != 'yes'}
    <tr>
      <th width="120">
        {t}New Status for Issue{/t} #{$issue_id}
      </th>
      <td>
        <select name="new_status">
          {html_options options=$statuses selected=$current_issue_status}
        </select>
      </td>
    </tr>
    {/if}
    <tr>
      <th width="120">
        {t}Time Spent{/t}
      </th>
      <td>
        <input type="text" size="5" name="time_spent"> <span><i>({t}in minutes{/t})</i></span>
      </td>
    </tr>
    {elseif $issue_id and $core.current_role == $core.roles.customer}
    <input type="hidden" name="new_status" value="{$new_status}">
    {/if}
    {if $hide_email_buttons|default:'' != 'yes'}
    <tr class="buttons">
      <td colspan="2">
          {if $read_only|default:'' != 1}
          <input type="submit" value="{t}Send Email{/t}">&nbsp;&nbsp;
          <input type="button" value="{t}Reset{/t}" onClick="resetForm(this.form);">&nbsp;&nbsp;
          {/if}
          <input type="button" value="{t}Cancel{/t}" onClick="confirmCloseWindow();">
            {if $core.app_setup.spell_checker|default:'' == 'enabled'}
              <input type="button" value="{t}Check Spelling{/t}" onClick="checkSpelling('send_email_form', 'message');">
            {/if}

          <div class="right">
            {if $current_user_prefs.email_signature != "" and $current_user_prefs.auto_append_email_sig != 1}
              <label>
              <input type="checkbox" name="add_email_signature" value="yes" onClick="setSignature(this.form);">
              {t}Add Email Signature{/t}
              </label>
            {/if}
          </div>
      </td>
    </tr>
    {/if}
    {if $issue_id and $core.current_role != $core.roles.customer}
    <tr class="buttons internal">
      <td colspan="2">
        {if $read_only|default:'' != 1}
        {if $smarty.get.cat|default:'' == 'view_draft'}
        <input type="button" value="{t}Save Draft Changes{/t}" onClick="updateDraft(this.form);">
        {else}
        <input type="button" value="{t}Save as Draft{/t}" onClick="saveDraft(this.form);">
        {/if}
        {/if}
      </td>
    </tr>
    {/if}
    <tr>
      <td colspan="2">
        * {t}Required fields{/t}
      </td>
    </tr>
  </table>
</form>
{/if}

{/block}