Add filter for db widget. Start of expired list item handling
authorLaury GvR <laury@gaslightmedia.com>
Fri, 21 Sep 2018 22:04:46 +0000 (18:04 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Fri, 21 Sep 2018 22:04:46 +0000 (18:04 -0400)
models/admin/newDashboard/index.php
setup/adminHooks.php
views/admin/newDashboard/components/list.html
views/admin/newDashboard/summaryWidget.html

index 16e1bf1..a527180 100644 (file)
@@ -251,8 +251,6 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
     public function queryWidgetLists( &$widgetData = false ) {
         
         foreach ( $widgetData['components'] as &$widgetComponent ) {
-            echo "<br>Order: ";
-            var_dump($widgetComponent['order']);
 
             if ( $widgetComponent['template'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) {
                 
@@ -261,6 +259,7 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
                 } else {
                     $where = " TRUE ";
                 }
+                
                 $resultsQuery = "SELECT " . $widgetComponent['fields'] . " FROM " . $widgetComponent['table'] . " WHERE " . $where . " LIMIT 5;";
                 $widgetComponent['sql'] = $resultsQuery;
                 $widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery);
@@ -272,6 +271,9 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
                             // in url vs config array reference to ref_type (e.g. member vs Member, and member vs members)
                             $listItem->ref_type = strtolower($this->config['ref_type'][$listItem->ref_type]);
                         }
+                        if ( isset($listItem->expire_date)) {
+                            
+                        }
                     }
                 }
                 $countQuery = "SELECT COUNT(id) FROM " . $widgetComponent['table'] . " WHERE " . $where . ";";
index 2886dbd..8cf7b54 100644 (file)
@@ -403,3 +403,101 @@ add_action( 'init', function(){
         session_start();
     }
 });
+
+add_filter(
+    GLM_MEMBERS_PLUGIN_SLUG .'-dashboard-widget',
+    function ( $member = null ) {
+        $membersIndexPage = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-members';
+        $memberIndexPage = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member';
+        $membersTable = GLM_MEMBERS_PLUGIN_PREFIX . "members";
+        $membersEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=memberInfo';
+
+        /*
+        * For list components: pass ref_type and ref_dest as part of the 'fields' string if you want to
+        * make these options part of the href of each <li> link
+        * 
+        */
+
+        $content = [
+            'title'         => 'Members',
+            'components'    => [
+                [
+                    'id'        => 'topButtons',
+                    'order'     => -1,
+                    'template'  => 'buttons',
+                    'buttons'   => [
+                        'add-member' => [
+                            'content'   => 'Add Member',
+                            'url'       => $memberIndexPage . "&glm_action=memberEdit&option=add",
+                            'classes'   => '',
+                        ],
+                    ],
+                ],
+                [
+                    'id'         => 'quickLinks',
+                    'order'      => 0,
+                    'template'   => 'quickLinks',
+                    'quickLinks' => [
+                        'dashboard' => [
+                            'content' => 'Dashboard',
+                            'url'     => $membersIndexPage . "&option=dashboard",
+                        ],
+                        'search' => [
+                            'content' => 'Advanced Search',
+                            'url'     => $membersIndexPage . "&option=search",
+                        ],
+                        'settings' => [
+                            'content'   => 'Settings',
+                            'url'       => '#set',
+                        ]
+                    ],
+                ],
+                [
+                    'id'       => 'entityAmount',
+                    'order'    => 1,
+                    'template' => 'entityAmount',
+                    'table'    => $membersTable,
+                    'url'      => $membersIndexPage . "&option=search",
+                ],
+                [
+                    'id'        => 'textSearch',
+                    'order'     => 2,
+                    'template'  => 'textSearch',
+                    'entityID'  => 'id',
+                    'table'     => $membersTable,
+                    'fields'    => "id, title as name, image",
+                    'where'     => 'title',
+                    'resultUrl' => $memberIndexPage . "&option=edit",
+                ],
+                [
+                    'id'        => 'pending', 
+                    'title'     => "Pending Members",
+                    'slug'      => "pending-members",
+                    'order'     => 3,
+                    'template'  => 'list',
+                    'entityID'  => 'id',
+                    'table'     => $membersTable,
+                    'fields'    => "id, title, ref_type, ref_dest",
+                    'where'     => 'status='.$this->config['status_numb']['Pending'],
+                    'resultUrl' => $membersIndexPage,
+                ],
+                [
+                    'id'        => 'active',
+                    'title'     => "Bad Locaction Data",
+                    'slug'      => "bad-location-data",
+                    'order'     => 4,
+                    'template'  => 'list',
+                    'entityID'  => 'id',
+                    'table'     => $membersTable,
+                    'fields'    => "id, title, ref_type, ref_dest",
+                    'where'     => 'status='.$this->config['status_numb']['Active'],
+                    'resultUrl' => $membersIndexPage,
+                ],
+            ]
+        ];
+
+         return $content;
+    },
+    13,
+    1
+);
\ No newline at end of file
index e103570..991315b 100644 (file)
@@ -4,7 +4,7 @@
     {if isset($listItem)}
         <li class="collection-item" style="line-height: 1;padding : 5px 15px;">
             <a href='{$component.resultUrl}{if isset($listItem->ref_dest) && isset($listItem->ref_type)}&{$listItem->ref_type}={$listItem->ref_dest}{/if}&{$component.entityID}={$listItem->id}'>
-                {$listItem->title}
+                {$listItem->title}{if isset($listItem->expire_date)} - expired: {date( "m/d/Y", strtotime($listItem->expire_date))}{/if}
             </a>
         </li>
     {/if}
index 4dff170..1df691b 100644 (file)
@@ -9,11 +9,6 @@
                     {**if file_exists("./components/$component.component.html") // wouldn't it be great if this worked?**}
 
                         {** This will throw a serious error if the file does not exist **}
-                        {if isset($component['order']) && $component['order'] !== ''}
-                        <br>====<span>Throwing this component '{$component.template}'' in position {$component.order}</span>====<br>
-                        {else}
-                        <br>====<span>No order for this component '{$component.template}', thrown to the top</span>====<br>
-                        {/if}
                         {include file="./components/{$component.template}.html"}
 
                     {**/if**}