From: Laury GvR Date: Mon, 24 Sep 2018 21:09:17 +0000 (-0400) Subject: entityAmount view, lists, filter adjusted, where/order X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=939b72e58614cc292f2552464164aba818c23bfa;p=WP-Plugins%2Fglm-member-db.git entityAmount view, lists, filter adjusted, where/order - Entity amount views added - Using 'url' instead of 'resultUrl' for the list anchors - Implemented Bad Location data list - Implemented Pending Member Profiles - Changed model to respect ORDER BY, and do proper counts - Commented code, removed unneeded comments, fixed spacing --- diff --git a/models/admin/newDashboard/index.php b/models/admin/newDashboard/index.php index a5271806..57cf222e 100644 --- a/models/admin/newDashboard/index.php +++ b/models/admin/newDashboard/index.php @@ -198,50 +198,47 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers $haveInfoRecords = true; } - // Not sure how to make the 'callback' use $this-> or this could get pulled out - // function orderSort ($a, $b) { return (strcmp ($a['order'],$b['order'])); } - - // In case we want to treat the widget data before sending it to the viewfile. - // May be able to avoid sending the (huge) Config array to the view + // Create a set of useful data for each registered plugin that has a filter + // Use that filter to retrieve table information, then run query for each 'list' field. foreach ( $this->config[ 'addOns' ] as $a ) { if ( has_filter( $a['slug'] . "-dashboard-widget") ) { - //var_dump($a); $addons[$a['slug']]['name'] = $a['short_name']; $addons[$a['slug']]['slug'] = $a['slug']; - $addons[$a['slug']]['index'] = $a['index']; + // $addons[$a['slug']]['index'] = $a['index']; + // echo $a['index']; $addons[$a['slug']]['widgetData'] = apply_filters($a['slug'] . "-dashboard-widget", ""); $addons[$a['slug']]['widgetData'] = $this->queryWidgetLists($addons[$a['slug']]['widgetData']); // Sort the component list based on the 'order' uasort($addons[$a['slug']]['widgetData']['components'], array($this, 'orderSort') ) ; } else { - echo "
" . $a['slug'] . " has no filter called " . $a['slug'] . "-dashboard-widget"; + // For testing + // echo "
" . $a['slug'] . " has no filter called " . $a['slug'] . "-dashboard-widget"; } } // Compile template data. $templateData = array( - 'lockedToMember' => $lockedToMember, - 'member' => $actionData, - 'showArchived' => $showArchived, - 'statusTypeNumbers' => $this->config['status_numb'], - 'memberID' => $memberID, - 'haveInfoRecords' => $haveInfoRecords, - 'memberInfoRecords' => $memberInfoRecords, - 'clickThroughCounts' => $clickThroughCounts, - 'detailViewCounts' => $detailViewCounts, - 'statusPending' => $this->config['status_numb']['Pending'], - //'widgetData' => $addons['widgetData'], - 'addons' => $addons, + 'lockedToMember' => $lockedToMember, + 'member' => $actionData, + 'showArchived' => $showArchived, + 'statusTypeNumbers' => $this->config['status_numb'], + 'memberID' => $memberID, + 'haveInfoRecords' => $haveInfoRecords, + 'memberInfoRecords' => $memberInfoRecords, + 'clickThroughCounts' => $clickThroughCounts, + 'detailViewCounts' => $detailViewCounts, + 'statusPending' => $this->config['status_numb']['Pending'], + 'addons' => $addons, ); // Return status, suggested view, and data to controller. return array( - 'status' => $success, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/newDashboard/index.html', - 'data' => $templateData + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/newDashboard/index.html', + 'data' => $templateData ); } @@ -251,16 +248,21 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers public function queryWidgetLists( &$widgetData = false ) { foreach ( $widgetData['components'] as &$widgetComponent ) { + $where = " TRUE "; + $order = ""; + $limit = "5"; + if ( isset($widgetComponent['where']) && $widgetComponent['where'] !== "" ) { + $where .= " AND " . $widgetComponent['where']; + } + if ( isset($widgetComponent['orderBy']) && $widgetComponent['orderBy'] !== "" ) { + $order .= " ORDER BY " . $widgetComponent['orderBy']; + } if ( $widgetComponent['template'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) { - - if ( isset($widgetComponent['where']) && $widgetComponent['where'] !== "" ) { - $where = $widgetComponent['where']; - } else { - $where = " TRUE "; - } - - $resultsQuery = "SELECT " . $widgetComponent['fields'] . " FROM " . $widgetComponent['table'] . " WHERE " . $where . " LIMIT 5;"; + $table = $widgetComponent['table']; + $fields = $widgetComponent['fields']; + $resultsQuery = "SELECT " . $fields . " FROM " . $table . " WHERE" . $where . $order . " LIMIT " . $limit . ";"; + //echo "
" .$resultsQuery; $widgetComponent['sql'] = $resultsQuery; $widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery); @@ -271,14 +273,18 @@ 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(" . $widgetComponent['entityID'] . ") FROM " . $widgetComponent['table'] . " WHERE " . $where . ";"; + // $widgetComponent['count'] = $this->wpdb->get_var($countQuery); + + } + if ( isset($widgetComponent['table']) && ($widgetComponent['template'] == 'list' || $widgetComponent['template'] == 'entityAmount') ) { + $table = $widgetComponent['table']; $countQuery = "SELECT COUNT(id) FROM " . $widgetComponent['table'] . " WHERE " . $where . ";"; + //echo "
" .$countQuery; $widgetComponent['count'] = $this->wpdb->get_var($countQuery); - + //echo "
" . var_dump($widgetComponent['count']) . "
"; } } return $widgetData; diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 8cf7b546..2177b3e8 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -409,7 +409,7 @@ add_filter( 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"; + $membersTable = GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info"; $membersEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=memberInfo'; /* @@ -454,6 +454,7 @@ add_filter( ], [ 'id' => 'entityAmount', + 'title' => 'Number of ' . $this->config['terms']['term_member_plur_cap'], 'order' => 1, 'template' => 'entityAmount', 'table' => $membersTable, @@ -471,27 +472,27 @@ add_filter( ], [ 'id' => 'pending', - 'title' => "Pending Members", - 'slug' => "pending-members", + 'title' => "Pending Member Profiles", + 'slug' => "pending-member-profiles", 'order' => 3, 'template' => 'list', - 'entityID' => 'id', + 'entityID' => 'memberInfo', 'table' => $membersTable, - 'fields' => "id, title, ref_type, ref_dest", + 'fields' => "id, reference_name as title, member as ref_dest, '10' as ref_type, status", 'where' => 'status='.$this->config['status_numb']['Pending'], - 'resultUrl' => $membersIndexPage, + 'url' => $membersEditPage, ], [ - 'id' => 'active', - 'title' => "Bad Locaction Data", + 'id' => 'bad-location-data', + 'title' => "Bad Location Data", 'slug' => "bad-location-data", 'order' => 4, 'template' => 'list', - 'entityID' => 'id', + 'entityID' => 'memberInfo', 'table' => $membersTable, - 'fields' => "id, title, ref_type, ref_dest", - 'where' => 'status='.$this->config['status_numb']['Active'], - 'resultUrl' => $membersIndexPage, + 'fields' => "id, reference_name as title, member as ref_dest, '10' as ref_type, status", + 'where' => "has_no_map_data='1'", + 'url' => $membersEditPage, ], ] ]; diff --git a/views/admin/newDashboard/components/entityAmount.html b/views/admin/newDashboard/components/entityAmount.html index d980c078..a44ddcd6 100644 --- a/views/admin/newDashboard/components/entityAmount.html +++ b/views/admin/newDashboard/components/entityAmount.html @@ -1 +1,9 @@ -entityAmount \ No newline at end of file +
{if $component.title}{$component.title}:{/if} + {if $component.url} + +
{$component.count}
+ + {else} + {$component.count} + {/if} +
\ No newline at end of file diff --git a/views/admin/newDashboard/components/list.html b/views/admin/newDashboard/components/list.html index 991315b6..0e506996 100644 --- a/views/admin/newDashboard/components/list.html +++ b/views/admin/newDashboard/components/list.html @@ -3,7 +3,7 @@ {foreach $component['listItems'] as $listItem} {if isset($listItem)}
  • - + {$listItem->title}{if isset($listItem->expire_date)} - expired: {date( "m/d/Y", strtotime($listItem->expire_date))}{/if}