Update for output of the approved timestamp.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 7 Sep 2016 14:40:49 +0000 (10:40 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 7 Sep 2016 14:40:49 +0000 (10:40 -0400)
Because of change to a sql wpdb query instead of the dataAbstract type
of query.

models/admin/dashboard/events.php
views/admin/dashboard/events.html

index e910208..37b4591 100644 (file)
@@ -104,7 +104,36 @@ class GlmMembersAdmin_dashboard_events extends GlmDataEvents
         if ( isset( $this->config['loggedInUser']['contactUser']['ref_dest'] )
             && $memberID = filter_var( $this->config['loggedInUser']['contactUser']['ref_dest'], FILTER_VALIDATE_INT)
         ) {
-            $events = $this->getList( "T.ref_dest = {$memberID}" );
+            $events = $this->wpdb->get_results(
+                $this->wpdb->prepare(
+                    "SELECT id,name,status,approved
+                       FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
+                      WHERE ref_dest = %d
+                        AND id IN (
+                        SELECT event
+                          FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+                         WHERE active
+                    )",
+                    $memberID
+                ),
+                ARRAY_A
+            );
+            foreach ( $events as &$event ) {
+                // set the status
+                $event['status'] = $this->config['status'][$event['status']];
+                // set the start and end times
+                $event_times = $this->wpdb->get_results(
+                    $this->wpdb->prepare(
+                        "SELECT MIN(start_time) as start, MAX(end_time) as end
+                           FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+                          WHERE event = %d",
+                        $event['id']
+                    ),
+                    ARRAY_A
+                );
+                $event['start'] = strtotime( $event_times[0]['start'] );
+                $event['end']   = strtotime( $event_times[0]['end'] );
+            }
         }
 
         // Compile template data.
index 42d7a4d..14f0934 100644 (file)
@@ -8,15 +8,32 @@
                 Add Event
             </a><br>
                 {if $events}
-            <ul >
-                {foreach $events as $event}
-                <li>
+                <table style="width: 100%">
+                    <thead>
+                        <tr>
+                            <th>Name</th>
+                            <th>Start</th>
+                            <th>End</th>
+                            <th>Status</th>
+                            <th>Approved</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        {foreach $events as $event}
+                        <tr>
+                            <td>
                     <a href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list&member={$memberID}&option=edit&event={$event.id}">
-                        {$event.name}
-                    </a> ({$event.status.name})
-                </li>
-                {/foreach}
-            </ul>
+                                {$event.name}
+                    </a>
+                            </td>
+                            <td>{$event.start|date_format:"%m/%d/%Y"}</td>
+                            <td>{$event.end|date_format:"%m/%d/%Y"}</td>
+                            <td>{$event.status}</td>
+                            <td>{$event.approved|date_format:"%m/%d/%Y"}</td>
+                        </tr>
+                        {/foreach}
+                    </tbody>
+                </table>
             {/if}
         </div>
     </div>