0d00ab24 by Jeff Balicki

done wisiwig

1 parent c76db123
...@@ -72,6 +72,45 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -72,6 +72,45 @@ use Tz\WordPress\Tools\Notifications\Settings;
72 <?php endif; ?> 72 <?php endif; ?>
73 </tr> 73 </tr>
74 <?php endforeach; ?> 74 <?php endforeach; ?>
75 <?php foreach ($notifications['newsletter'] as $entry):
76 $sendto = $entry->sendto;
77 if (is_numeric($sendto)) {
78 $sendto = Notifications\getGroups($sendto)." Group";
79 } else {
80 $sendto = Notifications\get_field_lookup($sendto);
81 }
82 ?>
83 <tr>
84 <td><?php echo $entry->post_title; ?></td>
85 <td><?php echo date('M j, Y @ h:i A', strtotime($entry->execute_date)); ?></td>
86 <td><?php echo ucwords($sendto); ?></td>
87 <td>
88 <?php if ($entry->is_email): ?>
89 <img src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>"/>
90 <?php endif;?>
91 </td>
92 <td>
93 <?php if ($entry->is_system): ?>
94 <img src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>"/>
95 <?php endif;?>
96 </td>
97 <td>
98 <?php
99 if (strtotime($entry->execute_date) > current_time('timestamp')):?>
100 <a class="edit" href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">
101 edit
102 </a>
103 | <a class="delete"
104 href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>"
105 onclick="return confirm('Are you sure?');">delete</a>
106 </td>
107
108 <?php else: ?>
109 <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> |
110 <em>In progress....</em>
111 <?php endif; ?>
112 </tr>
113 <?php endforeach; ?>
75 </tbody> 114 </tbody>
76 </table> 115 </table>
77 116
......
...@@ -48,8 +48,10 @@ function getInputFormValues($validation, $name) { ...@@ -48,8 +48,10 @@ function getInputFormValues($validation, $name) {
48 <option value="scheduled" <?php echo ($validation->set_value('type') == "scheduled" || $_POST['type'] == 'scheduled') 48 <option value="scheduled" <?php echo ($validation->set_value('type') == "scheduled" || $_POST['type'] == 'scheduled')
49 ? 'selected="selected"' : ""; ?>>Scheduled Notification 49 ? 'selected="selected"' : ""; ?>>Scheduled Notification
50 </option> 50 </option>
51 51 <option value="newsletter" <?php echo ($validation->set_value('type') == "newsletter" || $_POST['type'] == 'newsletter')
52 <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> 52 ? 'selected="selected"' : ""; ?>>Newsletter
53 </option>
54 <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
53 <option value="triggered" <?php echo ($validation->set_value('type') == "triggered" || $_POST['type'] == 'triggered') 55 <option value="triggered" <?php echo ($validation->set_value('type') == "triggered" || $_POST['type'] == 'triggered')
54 ? 'selected="selected"' : ""; ?>>System Triggered Notification 56 ? 'selected="selected"' : ""; ?>>System Triggered Notification
55 </option> 57 </option>
...@@ -135,11 +137,11 @@ function getInputFormValues($validation, $name) { ...@@ -135,11 +137,11 @@ function getInputFormValues($validation, $name) {
135 <?php echo $validation->form_error($lang.'_subject'); ?> 137 <?php echo $validation->form_error($lang.'_subject'); ?>
136 </td> 138 </td>
137 </tr> 139 </tr>
138 <tr> 140 <tr class="text_verson">
139 <td>Text Version</td> 141 <td>Text Version</td>
140 <td> 142 <td>
141 <textarea name="<?php echo $lang; ?>_text" 143 <textarea name="<?php echo $lang; ?>_text"
142 class="wide-input-field" rows="10" 144 class="wide-input-field text_verson" rows="10"
143 style="width: 100%;"><?php echo getInputFormValues($validation, $lang . '_text'); ?> 145 style="width: 100%;"><?php echo getInputFormValues($validation, $lang . '_text'); ?>
144 </textarea><?php echo $validation->form_error($lang.'_text'); ?> 146 </textarea><?php echo $validation->form_error($lang.'_text'); ?>
145 </td> 147 </td>
...@@ -147,14 +149,16 @@ function getInputFormValues($validation, $name) { ...@@ -147,14 +149,16 @@ function getInputFormValues($validation, $name) {
147 <tr> 149 <tr>
148 <td>HTML Version (optional)</td> 150 <td>HTML Version (optional)</td>
149 <td> 151 <td>
150 <textarea name="<?php echo $lang; ?>_html" 152 <?php
151 id="htmlversion" class="wide-input-field" rows="10" 153 $content = getInputFormValues($validation, $lang . '_html');
152 style="width: 100%;"><?php echo getInputFormValues($validation, $lang . '_html'); ?> 154 $settings = array('textarea_name' => $lang.'_html' , "media_buttons" => true );
153 </textarea><?php echo $validation->form_error($lang.'_html'); ?> 155 wp_editor($content, $lang .'_html', $settings );
156 ?><?php echo $validation->form_error($lang.'_html'); ?>
157
154 </td> 158 </td>
155 </tr> 159 </tr>
156 160
157 <tr> 161 <tr class="attachments">
158 <td width="150">Attachments</td> 162 <td width="150">Attachments</td>
159 <td>&nbsp;</td> 163 <td>&nbsp;</td>
160 </tr> 164 </tr>
...@@ -178,7 +182,7 @@ function getInputFormValues($validation, $name) { ...@@ -178,7 +182,7 @@ function getInputFormValues($validation, $name) {
178 ?> 182 ?>
179 183
180 <?php for ($a = 1; $a <= $allowedAttachments; $a++): ?> 184 <?php for ($a = 1; $a <= $allowedAttachments; $a++): ?>
181 <tr> 185 <tr class="attachments">
182 <td>&nbsp;</td> 186 <td>&nbsp;</td>
183 <td><input type="file" name="<?php echo $lang; ?>_attachment[]"/></td> 187 <td><input type="file" name="<?php echo $lang; ?>_attachment[]"/></td>
184 </tr> 188 </tr>
...@@ -270,11 +274,11 @@ function getInputFormValues($validation, $name) { ...@@ -270,11 +274,11 @@ function getInputFormValues($validation, $name) {
270 }).change(); 274 }).change();
271 275
272 // 276 //
273 // jQuery('#execute_date').datetimepicker({ 277 jQuery('#execute_date').datetimepicker({
274 // stepMinute: 30, 278 stepMinute: 05,
275 // dateFormat: 'yy-mm-dd', 279 dateFormat: 'yy-mm-dd',
276 // timeFormat: 'hh:mm:ss' 280 timeFormat: 'hh:mm:ss'
277 // }); 281 });
278 282
279 updateNotificationType(); 283 updateNotificationType();
280 284
...@@ -323,16 +327,39 @@ function getInputFormValues($validation, $name) { ...@@ -323,16 +327,39 @@ function getInputFormValues($validation, $name) {
323 327
324 function updateNotificationType() { 328 function updateNotificationType() {
325 var type = jQuery('#notif_type').val(); 329 var type = jQuery('#notif_type').val();
330 var date = new Date().toLocaleDateString("en-US", {year: 'numeric', month: 'long', day: 'numeric'});
331
332 var header ='<div><span style="font-size: 9.5pt;">If you are unable to clearly view the below E-Flash, please click<b><a><span style="font-weight: normal;"> here</span></a></b></span><hr /><img class="&quot;alignnone" src="https://cbvinstitute.com/wp-content/uploads/2019/02/email_logo.png" alt="Logo" width="81" height="57" align="left" /><span style="font-size: 9.5pt; line-height: 115%; float: right;">'+date+'</span><div>';
333
334 var footer ='<div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><p class="footer"><strong><span style="font-family: GothamLight; font-size: 12px;"> To opt out, please:<br />1. Log in to cicbv.ca<br />2. Click on your name<br />3. From the drop down menu select profile<br />4. Edit E-flash settings<br />If you have any questions, please contact us: admin@cicbv.ca<br /></span></strong></p>'
335
336 var header_fr ='<div><span style="font-size: 9.5pt;">If you are unable to clearly view the below E-Flash, please click<b><a><span style="font-weight: normal;"> here</span></a></b></span><hr /><img class="&quot;alignnone" src="https://cbvinstitute.com/wp-content/uploads/2019/02/email_logo_fr.png" alt="Logo" width="81" height="57" align="left" /><span style="font-size: 9.5pt; line-height: 115%; float: right;">'+date+'</span><div>';
337
338 var footer_fr ='<div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><p class="footer"><strong><span style="font-family: GothamLight; font-size: 12px;"> To opt out, please:<br />1. Log in to cicbv.ca<br />2. Click on your name<br />3. From the drop down menu select profile<br />4. Edit E-flash settings<br />If you have any questions, please contact us: admin@cicbv.ca<br /></span></strong></p>'
339
340
326 341
327 if (type == "triggered") { 342 if (type == "triggered") {
328 jQuery('.scheduled-extended').hide(); 343 jQuery('.scheduled-extended').hide();
329 jQuery('.scheduled_sendto').hide(); 344 jQuery('.scheduled_sendto').hide();
330 jQuery('.trigger-extended').show(); 345 jQuery('.trigger-extended').show();
346 }else if (type == "newsletter") {
347 jQuery('.scheduled-extended').show();
348 jQuery('.trigger-extended').hide();
349 jQuery(".text_verson").hide();
350 jQuery('.attachments').hide();
351 jQuery('.scheduled_sendto').show();
352 $(tinymce.get('en_html').getBody()).html(header+footer);
353 $(tinymce.get('fr_html').getBody()).html(header_fr+footer_fr);
354 jQuery('#execute_date').datetimepicker({
355 format: 'Y-m-d, H:i',
356 defaultDate: new Date()
357 });
358
331 } else { 359 } else {
332 jQuery('.scheduled-extended').show(); 360 jQuery('.scheduled-extended').show();
333 jQuery('.trigger-extended').hide(); 361 jQuery('.trigger-extended').hide();
334 jQuery('.scheduled_sendto').show(); 362 jQuery('.scheduled_sendto').show();
335
336 jQuery('#execute_date').datetimepicker({ 363 jQuery('#execute_date').datetimepicker({
337 format: 'Y-m-d, H:i', 364 format: 'Y-m-d, H:i',
338 defaultDate: new Date() 365 defaultDate: new Date()
......
...@@ -45,12 +45,19 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -45,12 +45,19 @@ use Tz\WordPress\Tools\Notifications\Settings;
45 <td> 45 <td>
46 <select name="type" id="notif_type" class="wide-input-field" 46 <select name="type" id="notif_type" class="wide-input-field"
47 onchange="updateNotificationType();"> 47 onchange="updateNotificationType();">
48
48 <option value="scheduled" <?php echo ($validation->set_value( 49 <option value="scheduled" <?php echo ($validation->set_value(
49 'type', 50 'type',
50 $entry->details['type'] 51 $entry->details['type']
51 ) == 'scheduled') ? 'selected="selected"' : ''; ?>> 52 ) == 'scheduled') ? 'selected="selected"' : ''; ?>>
52 Scheduled Notification 53 Scheduled Notification
53 </option> 54 </option>
55 <option value="newsletter" <?php echo ($validation->set_value(
56 'type',
57 $entry->details['type']
58 ) == 'newsletter') ? 'selected="selected"' : ''; ?>>
59 Newsletter
60 </option>
54 <?php if (current_user_can( 61 <?php if (current_user_can(
55 Settings\MANAGE_SYSTEM_NOTIFICATIONS 62 Settings\MANAGE_SYSTEM_NOTIFICATIONS
56 ) || ($_GET['action'] == 'edit' && $entry->details['type'] == 'triggered') 63 ) || ($_GET['action'] == 'edit' && $entry->details['type'] == 'triggered')
...@@ -62,6 +69,7 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -62,6 +69,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
62 System Triggered Notification 69 System Triggered Notification
63 </option> 70 </option>
64 <?php endif; ?> 71 <?php endif; ?>
72
65 </select> 73 </select>
66 <?php echo $validation->form_error('type'); ?> 74 <?php echo $validation->form_error('type'); ?>
67 </td> 75 </td>
...@@ -179,7 +187,7 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -179,7 +187,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
179 ); ?>"/><?php echo $validation->form_error($lang.'_subject'); ?> 187 ); ?>"/><?php echo $validation->form_error($lang.'_subject'); ?>
180 </td> 188 </td>
181 </tr> 189 </tr>
182 <tr> 190 <tr class="text_verson">
183 <td>Text Version</td> 191 <td>Text Version</td>
184 <td> 192 <td>
185 <textarea name="<?php echo $lang; ?>_text" 193 <textarea name="<?php echo $lang; ?>_text"
...@@ -193,16 +201,16 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -193,16 +201,16 @@ use Tz\WordPress\Tools\Notifications\Settings;
193 <tr> 201 <tr>
194 <td>HTML Version (optional)</td> 202 <td>HTML Version (optional)</td>
195 <td> 203 <td>
196 <textarea name="<?php echo $lang; ?>_html" 204 <?php
197 id="htmlversion" class="wide-input-field" rows="10" 205 $content = $validation->set_value( $lang.'_html', $entry->email[$lang.'_html']);
198 style="width: 100%;"><?php echo $validation->set_value( 206 $settings = array('textarea_name' => $lang.'_html' , "media_buttons" => true );
199 $lang.'_html', 207 wp_editor($content, $lang .'_html', $settings );
200 $entry->email[$lang.'_html'] 208
201 ); ?></textarea><?php echo $validation->form_error($lang.'_html'); ?> 209 ?><?php echo $validation->form_error($lang.'_html'); ?>
202 </td> 210
203 </tr> 211 </tr>
204 212
205 <tr> 213 <tr class="attachments">
206 <td width="150">Attachments</td> 214 <td width="150">Attachments</td>
207 <td>&nbsp;</td> 215 <td>&nbsp;</td>
208 </tr> 216 </tr>
...@@ -216,7 +224,7 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -216,7 +224,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
216 <td> 224 <td>
217 <?php echo $attachment; ?> &nbsp; (<a href="#" 225 <?php echo $attachment; ?> &nbsp; (<a href="#"
218 entry_id="<?php echo $_GET['page_id'] ?>" 226 entry_id="<?php echo $_GET['page_id'] ?>"
219 class="attachment" 227 class="attachment attachments"
220 rel="<?php echo $attachment; ?>">remove</a>) 228 rel="<?php echo $attachment; ?>">remove</a>)
221 </td> 229 </td>
222 </tr> 230 </tr>
...@@ -226,7 +234,7 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -226,7 +234,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
226 ?> 234 ?>
227 235
228 <?php for ($a = 1; $a <= $allowedAttachments; $a++): ?> 236 <?php for ($a = 1; $a <= $allowedAttachments; $a++): ?>
229 <tr> 237 <tr class="attachments">
230 <td>&nbsp;</td> 238 <td>&nbsp;</td>
231 <td><input type="file" name="<?php echo $lang; ?>_attachment[]"/></td> 239 <td><input type="file" name="<?php echo $lang; ?>_attachment[]"/></td>
232 </tr> 240 </tr>
...@@ -367,16 +375,27 @@ use Tz\WordPress\Tools\Notifications\Settings; ...@@ -367,16 +375,27 @@ use Tz\WordPress\Tools\Notifications\Settings;
367 375
368 function updateNotificationType() { 376 function updateNotificationType() {
369 var type = jQuery('#notif_type').val(); 377 var type = jQuery('#notif_type').val();
378
370 379
371 if (type == 'triggered') { 380 if (type == "triggered") {
372 jQuery('.scheduled-extended').hide(); 381 jQuery('.scheduled-extended').hide();
373 jQuery('.trigger-extended').show();
374 jQuery('.scheduled_sendto').hide(); 382 jQuery('.scheduled_sendto').hide();
383 jQuery('.trigger-extended').show();
384 }else if (type == "newsletter") {
385 jQuery('.scheduled-extended').show();
386 jQuery('.trigger-extended').hide();
387 jQuery(".text_verson").hide();
388 jQuery('.attachments').hide();
389 jQuery('.scheduled_sendto').show();
390 jQuery('#execute_date').datetimepicker({
391 format: 'Y-m-d, H:i',
392 defaultDate: new Date()
393 });
394
375 } else { 395 } else {
376 jQuery('.scheduled-extended').show(); 396 jQuery('.scheduled-extended').show();
377 jQuery('.trigger-extended').hide(); 397 jQuery('.trigger-extended').hide();
378 jQuery('.scheduled_sendto').show(); 398 jQuery('.scheduled_sendto').show();
379
380 jQuery('#execute_date').datetimepicker({ 399 jQuery('#execute_date').datetimepicker({
381 format: 'Y-m-d, H:i', 400 format: 'Y-m-d, H:i',
382 defaultDate: new Date() 401 defaultDate: new Date()
......