$success = true;
$memberID = false;
+ echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+ if ( isset( $_REQUEST['bulkAction'] ) && isset( $_REQUEST['bulkEdit'] ) && !empty( $_REQUEST['bulkEdit'] ) ) {
+ // Process the bulk edit events.
+ $bulkAction = filter_var( $_REQUEST['bulkAction'], FILTER_SANITIZE_STRING );
+ $bulkEdit = filter_var( $_REQUEST['bulkEdit'], FILTER_VALIDATE_INT, [ 'flags' => FILTER_FORCE_ARRAY ] );
+ echo '<pre>$bulkEdit: ' . print_r( $bulkEdit, true ) . '</pre>';
+ switch ( $bulkAction ) {
+ case 'Approve':
+ foreach ( $bulkEdit as $eventId ) {
+ $mId = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT ref_dest
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . ""
+ )
+ );
+ }
+ break;
+ case 'Decline':
+ break;
+ default:
+ break;
+ }
+ }
+
+
// Get list of member events.
if ( isset( $this->config['loggedInUser']['contactUser']['ref_dest'] )
&& $memberID = filter_var( $this->config['loggedInUser']['contactUser']['ref_dest'], FILTER_VALIDATE_INT)
}
} else {
$events = $this->wpdb->get_results(
- "SELECT E.id,E.name,E.ref_dest,T1.start_time as start,T2.end_time as end
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E,
- " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times T1,
- " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times T2
- WHERE E.status = " . $this->config['status_numb']['Pending'] . "
- AND T1.event = E.id AND T1.start_time IN (SELECT MIN(start_time)
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
- WHERE event = E.id)
- AND T2.event = E.id AND T2.end_time IN (SELECT MAX(end_time)
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
- WHERE event = E.id)
- ORDER BY E.status DESC,end DESC,start DESC",
+ "SELECT E.id,E.name,E.ref_dest,T1.start_time as start,T2.end_time as end,
+ E.admin_org, E.created
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E,
+ " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times T1,
+ " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times T2
+ WHERE E.status = " . $this->config['status_numb']['Pending'] . "
+ AND T1.event = E.id AND T1.start_time IN (
+ SELECT MIN(start_time)
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE event = E.id)
+ AND T2.event = E.id AND T2.end_time IN (
+ SELECT MAX(end_time)
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE event = E.id)
+ ORDER BY E.status DESC,end DESC,start DESC",
ARRAY_A
);
-<div class="glm-widget-container">
- <div class="glm-widget">
- <h2>
- <a href="{$thisUrl}?page=glm-members-admin-menu-events-list">Events</a> {if $memberID}(5 most recent){else}(Pending){/if}
+{*
+ Dashboard Widget for Events
- <a class="button glm-button glm-right" href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list&option=add">Add Event</a>
- </h2>
- <div class="glm-widget-content">
+ This is used for both member only events widget.
+ And the Admin/client Member Dashboard.
+*}
+<div class="glm-widget-container">
+ <form action="{$thisUrl}?page={$thisPage}" method="post">
+ <div class="glm-widget">
+ <h2>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-events-list">Events</a> {if $memberID}(5 most recent){else}(Pending){/if}
+ <a class="button glm-button glm-right" href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list&option=add">Add Event</a>
+ </h2>
+ <div class="glm-widget-content">
+ <div>
+ <select name="bulkAction">
+ <option value="">Bulk Actions</option>
+ <option value="Approve">Approve</option>
+ <option value="Decline">Decline</option>
+ </select>
+ <input type="submit" value="Apply" class="button">
+ </div>
{if $events}
- <table style="width: 100%">
- <thead>
- <tr>
- <th>Name</th>
- {if !$memberID}<th>Member</th>{/if}
- <th>Start</th>
- <th>End</th>
- {if $memberID}<th>Status</th>
- <th>Approved</th>{/if}
- </tr>
- </thead>
- <tbody>
- {foreach $events as $event}
- <tr>
- <td>
- <a href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list{if $memberID}&member={$memberID}{/if}&option=edit&event={$event.id}">
- {$event.name}
- </a>
- </td>
- {if !$memberID}
+ <table style="width: 100%">
+ <thead>
+ <tr>
+ {if !$memberID}
+ <td><label><input id="master-event-bulk" type="checkbox"> </label></td>
+ {/if}
+ <th style="text-align: left;">Name</th>
+ {if !$memberID}
+ <th style="text-align: left;">Member</th>
+ <th style="text-align: left;">Organization</th>
+ <th style="text-align: left;">Created</th>
+ {/if}
+ <th style="text-align: left;">Start</th>
+ <th style="text-align: left;">End</th>
+ {if $memberID}
+ <th>Status</th>
+ <th style="text-align: left;">Approved</th>
+ {/if}
+ </tr>
+ </thead>
+ <tbody>
+ {foreach $events as $event}
+ <tr {if $event@iteration is div by 2}class="alternate"{/if}>
+ {if !$memberID}
+ <td><label><input class="slave-event-bulk" type="checkbox" name="bulkEdit[]" value="{$event.id}"> </label></td>
+ {/if}
<td>
- {if $event.ref_dest}
- <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=index&member={$event.ref_dest}">{$event.member_name}</a>
- {/if}
+ <a href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list{if $memberID}&member={$memberID}{/if}&option=edit&event={$event.id}">
+ {$event.name}
+ </a>
</td>
- {/if}
- <td>{$event.start|date_format:"%m/%d/%Y"}</td>
- <td>{$event.end|date_format:"%m/%d/%Y"}</td>
- {if $memberID}<td>{$event.status}</td>
- <td>{$event.approved|date_format:"%m/%d/%Y"}</td>{/if}
- </tr>
- {/foreach}
- </tbody>
- </table>
- {/if}
+ {if !$memberID}
+ <td>
+ {if $event.ref_dest}
+ <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=index&member={$event.ref_dest}">{$event.member_name}</a>
+ {/if}
+ </td>
+ <td>
+ {$event.admin_org}
+ </td>
+ <td>
+ {$event.created|date_format:"%m/%d/%Y"}
+ </td>
+ {/if}
+ <td>{$event.start|date_format:"%m/%d/%Y"}</td>
+ <td>{$event.end|date_format:"%m/%d/%Y"}</td>
+ {if $memberID}
+ <td>{$event.status}</td>
+ <td>{$event.approved|date_format:"%m/%d/%Y"}</td>
+ {/if}
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ {/if}
+ </div>
</div>
- </div>
+ </form>
</div>
+
+<script>
+ jQuery(document).ready(function($){
+ $('#master-event-bulk').on( 'change', function(){
+ if ( $(this).is(':checked') ) {
+ $('.slave-event-bulk').each(function(){
+ $(this).prop('checked', true);
+ });
+ } else {
+ $('.slave-event-bulk').each(function(){
+ $(this).prop('checked', false);
+ });
+ }
+ });
+ $('.slave-event-bulk').on( 'change', function(){
+ updateMasterCheckBox();
+ });
+ // Go through all slave-event-bulk items and see if there checked.
+ // If they are then make the master one checked.
+ // If not then make the master one unchecked
+ function updateMasterCheckBox() {
+ var shouldMasterBeChecked = false;
+ var totalCheckBoxes = $('.slave-event-bulk').length;
+ var numberChecked = 0;
+ $('.slave-event-bulk').each(function(){
+ if ( $(this).is(':checked') ) {
+ numberChecked++;
+ }
+ });
+ if ( numberChecked === totalCheckBoxes ) {
+ $('#master-event-bulk').prop('checked', true);
+ } else {
+ $('#master-event-bulk').prop('checked', false);
+ }
+ }
+ });
+</script>