ed321741 by Jeff Balicki

w

1 parent b8378740
......@@ -328,6 +328,13 @@ function create_notification()
$emailData = [];
$systemMessageData = [];
foreach (['en', 'fr'] as $lang) {
// email
$subject = $_POST[$lang.'_subject'];
......@@ -346,6 +353,56 @@ function create_notification()
}
}
if($style == 'newsletter'){
$newletter_id = -1;
$author_id = 1;
$slug = strtolower($subject);
if( null == get_page_by_title( $title ) ) {
// Set the page ID so that we know the page was created successfully
$post_id = wp_insert_post(
array(
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_author' => '1',
'post_name' => $slug,
'post_title' => $subject,
'post_status' => 'publish',
'post_type' => 'newsLetter',
'post_content' => '<div id="newsletter">'.$html.'</div>' ,
)
);
if ($post_id) {
// https://wpml.org/wpml-hook/wpml_element_type/
$wpml_element_type = apply_filters( 'wpml_element_type', 'newsletter' );
// get the language info of the original post
// https://wpml.org/wpml-hook/wpml_element_language_details/
$get_language_args = array('element_id' => $post_id, 'element_type' => 'post_product' );
$original_post_language_info = apply_filters( 'wpml_element_language_details', null, $get_language_args );
$set_language_args = array(
'element_id' => $post_id,
'element_type' => $wpml_element_type,
'trid' => $original_post_language_info->trid,
'language_code' => $lang,
'source_language_code' => $original_post_language_info->language_code
);
do_action( 'wpml_set_element_language_details', $set_language_args );
}
} else {
$post_id = -2;
}
}
// system
$systemMessageType = $_POST['system_message_type'];
$system = $_POST[$lang.'_system'];
......@@ -356,7 +413,8 @@ function create_notification()
$lang.'_subject' => $subject,
$lang.'_text' => $text,
$lang.'_html' => $html,
$lang.'_attachments' => $attachments
$lang.'_attachments' => $attachments,
]
);
$systemMessageData = array_merge(
......@@ -366,8 +424,14 @@ function create_notification()
$lang.'_message' => $system
]
);
$links[$lang] = get_permalink($post_id);
}
// make post...
$notification = new PostTemplate();
$notification->post_title = $title;
......@@ -378,6 +442,10 @@ function create_notification()
$id = wp_insert_post((array)$notification);
if($style == 'newsletter'){
update_post_meta($id, 'links', $links);
}
update_post_meta(
$id,
'details',
......@@ -397,12 +465,19 @@ function create_notification()
update_post_meta($id, 'trigger', $trigger);
update_post_meta($id, 'email', $emailData);
update_post_meta($id, 'style', $style);
update_post_meta($id, 'system', $systemMessageData);
$flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
require_once(__DIR__.'/views/create.php');
} else {
require_once(__DIR__.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'create.php');
}
......
......@@ -330,13 +330,13 @@ function getInputFormValues($validation, $name) {
var type = jQuery('#notif_type').val();
var date = new Date().toLocaleDateString("en-US", {year: 'numeric', month: 'long', day: 'numeric'});
var header ='<div class="content"><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="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><br/><br/>';
var footer ='</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</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 class="content"><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="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>><br/><br/></div>';
var footer_fr ='</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</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 ='<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="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><br/><br/>';
//
// var footer ='<div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</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 class="content"><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="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>><br/><br/>';
//
// var footer_fr ='</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</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>';
......@@ -353,8 +353,8 @@ function getInputFormValues($validation, $name) {
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);
//$(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',
......