added ability to add a declined message that is sent to the user who submitted the event
in the event that the event is declined or approved after being submitted
$haveEvent = false;
$event = false;
}
-
+
$view = 'edit';
break;
}
}
+
+
}
+ // DECLINED & APPROVED EVENT EMAIL FUNCTIONALITY ///////
+ $sql = "SELECT from_email FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "management";
+ $from_email = $this->wpdb->get_var($sql);
+
+ $to_email = (isset($event['fieldData']['admin_email']) ? $event['fieldData']['admin_email'] : '' );
+
+ $header[] = 'From:' . $from_email;
+ $header[] = 'Reply-To:' . $from_email;
+
+ // change the default wordpress from name when sending mail
+ function set_content_type(){
+ return "text/html";
+ }
+
+ add_filter(
+ 'wp_mail_from_name',
+ function ( $name ) {
+ $siteName = get_bloginfo( 'name' );
+ return $siteName;
+ }
+ );
+
+ // Send confirmation email, set the content type to allow html by using this filter
+ add_filter( 'wp_mail_content_type', 'set_content_type' );
+
+ $declined_msg = '';
+ $current_status = $event['fieldData']['status']['value'];
+
+ if($to_email){
+ if($old_event_status === '20' && $current_status === '10' ) {
+
+ $subject = 'Event Approved';
+ $message = 'Your event has been approved';
+ wp_mail( $to_email, $subject, $message, $header );
+
+ } else if($old_event_status === '20' && $current_status === '40' ){
+
+ // $event_notes = (isset($event['fieldData']['notes']) ? filter_var($event['fieldData']['notes'], FILTER_SANITIZE_STRING) : '' );
+ // $offset = "DENIED REASON:";
+ // $declined_msg = substr($event_notes, strpos($event_notes, 'DENIED REASON:') + strlen($offset));
+ $declined_msg = (isset($_REQUEST['deniedText']) ? filter_var(($_REQUEST['deniedText']), FILTER_SANITIZE_STRING) : '' );
+
+ $subject = 'Event Declined';
+ $message = "Your event has been declined for the following reason(s): $declined_msg";
+
+ wp_mail( $to_email, $subject, $message, $header );
+ }
+ }
+ remove_filter( 'wp_mail_content_type', 'set_content_type' );
+ // END DECLINED & APPROVED EVENT EMAIL FUNCTIONALITY ////////
+
+
if (!$this->config['settings']['event_default_state']) {
$this->config['settings']['event_default_state'] = $this->config['settings']['default_state'];
}
'limit' => $limit,
'namesList' => $namesList,
'eventDefaultState' => $this->config['settings']['event_default_state'],
- 'currentTab' => $currentTab,
-
+ 'currentTab' => $currentTab
);
// Return status, any suggested view, and any data to controller
if($memberId){
if($current_year == $year){
$sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';
- $sql .= "WHERE event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE ref_dest = $memberId )";
+ $sql .= "WHERE event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE ref_dest = $memberId AND status = 10)";
$sql .= " AND YEAR(start_time) = $year AND MONTH(start_time) >= MONTH(CURDATE()) GROUP BY month";
$results[$year] = $wpdb->get_results($sql, ARRAY_A);
} else {
$sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';
- $sql .= "WHERE event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE ref_dest = $memberId )";
+ $sql .= "WHERE event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE ref_dest = $memberId AND status = 10)";
$sql .= " AND YEAR(start_time) = $year GROUP BY month";
$results[$year] = $wpdb->get_results($sql, ARRAY_A);
}
} else {
if($current_year == $year){
+
$sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';
- $sql .= "WHERE YEAR(start_time) = $year AND MONTH(start_time) >= MONTH(CURDATE()) GROUP BY month";
+ $sql .= "WHERE YEAR(start_time) = $year ";
+ $sql .= "AND MONTH(start_time) >= MONTH(CURDATE()) ";
+ $sql .= "AND event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10) ";
+ $sql .= "GROUP BY month";
+
$results[$year] = $wpdb->get_results($sql, ARRAY_A);
} else {
- $sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';
- $sql .= "WHERE YEAR(start_time) = $year GROUP BY month";
+ $sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';
+ $sql .= "WHERE YEAR(start_time) = $year ";
+ $sql .= "AND event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10)";
+ $sql .= " GROUP BY month";
$results[$year] = $wpdb->get_results($sql, ARRAY_A);
}
}
-
}
+
foreach($results as $year => $month){
foreach($month as $key=>$value){
if($count < 18){
minWidth: 400,
dialogClass: "glm-dialog-no-close"
});
-
+
// Ad a new category button action - pop-up dialog
$('#newCategoryButton').click( function() {
$("#newCategoryDialog").dialog("open");
if ( $('input[name=currentTab]').val() != 'glm-table-descr' ) {
initCurrentTab();
}
-
+ $("#deniedReason").dialog({
+ autoOpen: false,
+ minWidth: 400,
+
+ });
+
+ // declined event dialog
+ (function(){
+ var notes = $('[name="notes"');
+ var reason = $("#deniedText");
+
+ $('[name="status"]').on("change", function(){
+ var status = $(this).val();
+ if(status === '40'){
+ $("#deniedReason").dialog("open");
+ }
+ });
+ $("#deniedReasonSubmit").on("click", function(){
+
+ var reason_text = reason.val();
+
+ if(reason_text){
+ $("#deniedReason").dialog("close");
+ notes.append(" DENIED REASON: " + reason_text)
+ $('#declinedMsg').val(reason_text);
+ } else {
+ reason.next().css("display", "block");
+ }
+ });
+ })();
});
</script>
</tr>
{/if}
-
-
<tr>
<th>Categories</th>
<td class="glm-item-container">
-
+ <div id="deniedReason" title="Event Declined Reason">
+ <input id="deniedText" type="text" class="glm-form-text-input">
+ <div style="color: red; display: none;"> Please Enter a Reason </div>
+ <input style="margin-top: 35px;" id="deniedReasonSubmit" type="submit" value="Add Reason">
+ </div>
+ <input id="declinedMsg" type="hidden" name="deniedText">
<!-- Add new category dialog -->
-
+
<div id="newCategoryButton" class="button button-secondary glm-right">Add a new Category</div>
<div id="newCategoryDialog" class="glm-dialog-box" title="Enter a New Category">
<table class="glm-admin-table">
</div>
{assign var="current_year" value=$smarty.now|date_format:"%Y"}
{assign var="current_month" value=$smarty.now|date_format:"%m"}
-
<div id="event-date-toggle-container">
<label class="date-toggle-label" for="#event-date-toggle"> Select a Date <label>
<select id="event-date-toggle">
+ <option value="" disabled selected> Select Month</option>
{foreach $months as $year=>$month}{
{foreach $month as $m=>$value}
{if $current_month == $value.date && $current_year == $year}