0d00ab24 by Jeff Balicki

done wisiwig

1 parent c76db123
......@@ -72,6 +72,45 @@ use Tz\WordPress\Tools\Notifications\Settings;
<?php endif; ?>
</tr>
<?php endforeach; ?>
<?php foreach ($notifications['newsletter'] as $entry):
$sendto = $entry->sendto;
if (is_numeric($sendto)) {
$sendto = Notifications\getGroups($sendto)." Group";
} else {
$sendto = Notifications\get_field_lookup($sendto);
}
?>
<tr>
<td><?php echo $entry->post_title; ?></td>
<td><?php echo date('M j, Y @ h:i A', strtotime($entry->execute_date)); ?></td>
<td><?php echo ucwords($sendto); ?></td>
<td>
<?php if ($entry->is_email): ?>
<img src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>"/>
<?php endif;?>
</td>
<td>
<?php if ($entry->is_system): ?>
<img src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>"/>
<?php endif;?>
</td>
<td>
<?php
if (strtotime($entry->execute_date) > current_time('timestamp')):?>
<a class="edit" href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">
edit
</a>
| <a class="delete"
href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>"
onclick="return confirm('Are you sure?');">delete</a>
</td>
<?php else: ?>
<a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> |
<em>In progress....</em>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
......
......@@ -48,8 +48,10 @@ function getInputFormValues($validation, $name) {
<option value="scheduled" <?php echo ($validation->set_value('type') == "scheduled" || $_POST['type'] == 'scheduled')
? 'selected="selected"' : ""; ?>>Scheduled Notification
</option>
<?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
<option value="newsletter" <?php echo ($validation->set_value('type') == "newsletter" || $_POST['type'] == 'newsletter')
? 'selected="selected"' : ""; ?>>Newsletter
</option>
<?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
<option value="triggered" <?php echo ($validation->set_value('type') == "triggered" || $_POST['type'] == 'triggered')
? 'selected="selected"' : ""; ?>>System Triggered Notification
</option>
......@@ -135,11 +137,11 @@ function getInputFormValues($validation, $name) {
<?php echo $validation->form_error($lang.'_subject'); ?>
</td>
</tr>
<tr>
<tr class="text_verson">
<td>Text Version</td>
<td>
<textarea name="<?php echo $lang; ?>_text"
class="wide-input-field" rows="10"
class="wide-input-field text_verson" rows="10"
style="width: 100%;"><?php echo getInputFormValues($validation, $lang . '_text'); ?>
</textarea><?php echo $validation->form_error($lang.'_text'); ?>
</td>
......@@ -147,14 +149,16 @@ function getInputFormValues($validation, $name) {
<tr>
<td>HTML Version (optional)</td>
<td>
<textarea name="<?php echo $lang; ?>_html"
id="htmlversion" class="wide-input-field" rows="10"
style="width: 100%;"><?php echo getInputFormValues($validation, $lang . '_html'); ?>
</textarea><?php echo $validation->form_error($lang.'_html'); ?>
<?php
$content = getInputFormValues($validation, $lang . '_html');
$settings = array('textarea_name' => $lang.'_html' , "media_buttons" => true );
wp_editor($content, $lang .'_html', $settings );
?><?php echo $validation->form_error($lang.'_html'); ?>
</td>
</tr>
<tr>
<tr class="attachments">
<td width="150">Attachments</td>
<td>&nbsp;</td>
</tr>
......@@ -178,7 +182,7 @@ function getInputFormValues($validation, $name) {
?>
<?php for ($a = 1; $a <= $allowedAttachments; $a++): ?>
<tr>
<tr class="attachments">
<td>&nbsp;</td>
<td><input type="file" name="<?php echo $lang; ?>_attachment[]"/></td>
</tr>
......@@ -270,11 +274,11 @@ function getInputFormValues($validation, $name) {
}).change();
//
// jQuery('#execute_date').datetimepicker({
// stepMinute: 30,
// dateFormat: 'yy-mm-dd',
// timeFormat: 'hh:mm:ss'
// });
jQuery('#execute_date').datetimepicker({
stepMinute: 05,
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm:ss'
});
updateNotificationType();
......@@ -323,16 +327,39 @@ function getInputFormValues($validation, $name) {
function updateNotificationType() {
var type = jQuery('#notif_type').val();
var date = new Date().toLocaleDateString("en-US", {year: 'numeric', month: 'long', day: 'numeric'});
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>';
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>'
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>';
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>'
if (type == "triggered") {
jQuery('.scheduled-extended').hide();
jQuery('.scheduled_sendto').hide();
jQuery('.trigger-extended').show();
}else if (type == "newsletter") {
jQuery('.scheduled-extended').show();
jQuery('.trigger-extended').hide();
jQuery(".text_verson").hide();
jQuery('.attachments').hide();
jQuery('.scheduled_sendto').show();
$(tinymce.get('en_html').getBody()).html(header+footer);
$(tinymce.get('fr_html').getBody()).html(header_fr+footer_fr);
jQuery('#execute_date').datetimepicker({
format: 'Y-m-d, H:i',
defaultDate: new Date()
});
} else {
jQuery('.scheduled-extended').show();
jQuery('.trigger-extended').hide();
jQuery('.scheduled_sendto').show();
jQuery('#execute_date').datetimepicker({
format: 'Y-m-d, H:i',
defaultDate: new Date()
......
......@@ -45,12 +45,19 @@ use Tz\WordPress\Tools\Notifications\Settings;
<td>
<select name="type" id="notif_type" class="wide-input-field"
onchange="updateNotificationType();">
<option value="scheduled" <?php echo ($validation->set_value(
'type',
$entry->details['type']
) == 'scheduled') ? 'selected="selected"' : ''; ?>>
Scheduled Notification
</option>
<option value="newsletter" <?php echo ($validation->set_value(
'type',
$entry->details['type']
) == 'newsletter') ? 'selected="selected"' : ''; ?>>
Newsletter
</option>
<?php if (current_user_can(
Settings\MANAGE_SYSTEM_NOTIFICATIONS
) || ($_GET['action'] == 'edit' && $entry->details['type'] == 'triggered')
......@@ -62,6 +69,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
System Triggered Notification
</option>
<?php endif; ?>
</select>
<?php echo $validation->form_error('type'); ?>
</td>
......@@ -179,7 +187,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
); ?>"/><?php echo $validation->form_error($lang.'_subject'); ?>
</td>
</tr>
<tr>
<tr class="text_verson">
<td>Text Version</td>
<td>
<textarea name="<?php echo $lang; ?>_text"
......@@ -193,16 +201,16 @@ use Tz\WordPress\Tools\Notifications\Settings;
<tr>
<td>HTML Version (optional)</td>
<td>
<textarea name="<?php echo $lang; ?>_html"
id="htmlversion" class="wide-input-field" rows="10"
style="width: 100%;"><?php echo $validation->set_value(
$lang.'_html',
$entry->email[$lang.'_html']
); ?></textarea><?php echo $validation->form_error($lang.'_html'); ?>
</td>
<?php
$content = $validation->set_value( $lang.'_html', $entry->email[$lang.'_html']);
$settings = array('textarea_name' => $lang.'_html' , "media_buttons" => true );
wp_editor($content, $lang .'_html', $settings );
?><?php echo $validation->form_error($lang.'_html'); ?>
</tr>
<tr>
<tr class="attachments">
<td width="150">Attachments</td>
<td>&nbsp;</td>
</tr>
......@@ -216,7 +224,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
<td>
<?php echo $attachment; ?> &nbsp; (<a href="#"
entry_id="<?php echo $_GET['page_id'] ?>"
class="attachment"
class="attachment attachments"
rel="<?php echo $attachment; ?>">remove</a>)
</td>
</tr>
......@@ -226,7 +234,7 @@ use Tz\WordPress\Tools\Notifications\Settings;
?>
<?php for ($a = 1; $a <= $allowedAttachments; $a++): ?>
<tr>
<tr class="attachments">
<td>&nbsp;</td>
<td><input type="file" name="<?php echo $lang; ?>_attachment[]"/></td>
</tr>
......@@ -367,16 +375,27 @@ use Tz\WordPress\Tools\Notifications\Settings;
function updateNotificationType() {
var type = jQuery('#notif_type').val();
if (type == 'triggered') {
if (type == "triggered") {
jQuery('.scheduled-extended').hide();
jQuery('.trigger-extended').show();
jQuery('.scheduled_sendto').hide();
jQuery('.trigger-extended').show();
}else if (type == "newsletter") {
jQuery('.scheduled-extended').show();
jQuery('.trigger-extended').hide();
jQuery(".text_verson").hide();
jQuery('.attachments').hide();
jQuery('.scheduled_sendto').show();
jQuery('#execute_date').datetimepicker({
format: 'Y-m-d, H:i',
defaultDate: new Date()
});
} else {
jQuery('.scheduled-extended').show();
jQuery('.trigger-extended').hide();
jQuery('.scheduled_sendto').show();
jQuery('#execute_date').datetimepicker({
format: 'Y-m-d, H:i',
defaultDate: new Date()
......