--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Members Dashboard
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ *
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php';
+
+/**
+ * Dashboard Class Model
+ *
+ * Each Add-On can have one or more dashboards.
+ */
+
+class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
+{
+ /**
+ * Word Press Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /**
+ * Constructor
+ *
+ * This contructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Run constructor for members data class
+ parent::__construct(false, false);
+
+ }
+
+ /**
+ * Perform Model Action
+ *
+ * This method does the work for this model and returns any resulting data
+ *
+ * @return array Status and data array
+ *
+ * 'status'
+ *
+ * True if successful and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * 'view'
+ *
+ * A suggested view name that the controller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ */
+ public function modelAction ( $actionData = false )
+ {
+
+ $success = true;
+ $text = 'text';
+ $haveInfoRecords = false;
+ $memberInfoRecords = false;
+ $noActive = false;
+ $showArchived = false;
+ $memberID = 0;
+ $clickThroughCounts = array('day' => 0, 'week' => 0, 'month' => 0);
+ $detailViewCounts = array('day' => 0, 'week' => 0, 'month' => 0);
+
+ // Enqueue Materialize
+ wp_register_script(
+ 'materialize',
+ GLM_MEMBERS_PLUGIN_URL . 'js/materialize/materialize.min.js',
+ array(
+ 'jquery'
+ ),
+ GLM_MEMBERS_PLUGIN_VERSION
+ );
+ wp_register_script(
+ 'autoComplete',
+ GLM_MEMBERS_PLUGIN_URL . 'js/materialize/autoComplete.min.js',
+ array(
+ 'jquery'
+ ),
+ GLM_MEMBERS_PLUGIN_VERSION
+ );
+ wp_enqueue_script('materialize', false, array('jquery'), false, true);
+ wp_enqueue_script('autoComplete', false, array('jquery'), false, true);
+ wp_enqueue_style('materialize-css', GLM_MEMBERS_PLUGIN_URL . 'css/materialize.min.css');
+ wp_enqueue_style('autoComplete', GLM_MEMBERS_PLUGIN_URL . 'css/autoComplete.css');
+ wp_enqueue_style('admin-css', GLM_MEMBERS_PLUGIN_URL . 'css/glma-admin-sass.css');
+ wp_enqueue_style('css-icons', "https://fonts.googleapis.com/icon?family=Material+Icons");
+
+ // Check if there's a logged in user who is locked to their own entity.
+ $lockedToMember = apply_filters( 'glm_members_locked_to_member_id', false );
+ $memberID = $lockedToMember;
+
+ // Get the current date, first date of this week, and first date of this month
+ $today = date('Y-m-d');
+ $thisWeek = date('Y-m-d', strtotime('-'.date('w').' days'));
+ $thisMonth = date('Y-m-d', strtotime('-'.(date('j')-1).' days'));
+
+
+ // 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") ) {
+ $addons[$a['slug']]['name'] = $a['short_name'];
+ $addons[$a['slug']]['slug'] = $a['slug'];
+ $addons[$a['slug']]['widgetData'] = apply_filters($a['slug'] . "-dashboard-search", "");
+ // Sort the component list based on the 'order'
+ uasort($addons[$a['slug']]['widgetData']['components'], array($this, 'orderSort') ) ;
+
+ }
+ }
+
+ // Compile template data.
+ $templateData = array(
+ 'lockedToMember' => $lockedToMember,
+ 'member' => $actionData,
+ 'showArchived' => $showArchived,
+ 'statusTypeNumbers' => $this->config['status_numb'],
+ 'memberID' => $memberID,
+ 'haveInfoRecords' => $haveInfoRecords,
+ 'memberInfoRecords' => $memberInfoRecords,
+ 'statusPending' => $this->config['status_numb']['Pending'],
+ 'addons' => $addons,
+ 'baseUrl' => GLM_MEMBERS_PLUGIN_URL
+ );
+
+ // Return status, suggested view, and data to controller.
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/newDashboard/index.html',
+ 'data' => $templateData
+ );
+
+ }
+
+ public function orderSort ($a, $b) { return (strcmp ($a['order'],$b['order'])); }
+}
if ( has_filter( $a['slug'] . "-dashboard-widget") ) {
$addons[$a['slug']]['name'] = $a['short_name'];
$addons[$a['slug']]['slug'] = $a['slug'];
+ // $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 {
+ // For testing
+ // echo "<br>" . $a['slug'] . " has no filter called " . $a['slug'] . "-dashboard-widget";
}
}
$content = [
'title' => 'Members',
- 'widgetButtons' => [
+ 'listButtons' => [
[
'id' => 'add-member',
'content' => 'Add',
'id' => 'export-button',
'content' => 'Export',
'url' => '#',
- 'classes' => 'btn-small widget-export-btn waves-effect waves-light btn modal-trigger',
+ 'classes' => 'btn-small waves-effect waves-light btn modal-trigger',
'styles' => '',
'data' => 'membersExportModal'
],
],
'components' => [
- [
- 'id' => 'quickLinks',
- 'order' => -1,
- 'template' => 'quickLinks',
- 'quickLinks' => [
- 'dashboard' => [
- 'content' => 'Dashboard',
- 'url' => $membersIndexPage . "&option=dashboard",
- ],
- 'search' => [
- 'content' => 'Advanced Search',
- 'url' => $membersIndexPage . "&option=search",
- ],
- 'settings' => [
- 'content' => 'Settings',
- 'url' => $membersSettingsPage,
- ]
- ],
- ],
- [
- 'id' => 'entityAmount',
- 'title' => 'Number of ' . $this->config['terms']['term_member_plur_cap'],
- 'order' => 1,
- 'template' => 'entityAmount',
- 'url' => $membersIndexPage . "&option=search",
- 'result' => $MemberInfo->getStats(),
- ],
[
'id' => 'membersExportModal',
'template' => 'modal',
'resultUrl' => $memberIndexPage . "&glm_action=index&member=",
],
[
- 'id' => 'pending-' . $this->config['terms']['term_member_cap'] . '-profiles',
- 'title' => 'Pending ' . $this->config['terms']['term_member_cap'] . ' Profiles',
- 'slug' => 'pending-' . $this->config['terms']['term_member'] . '-profiles',
- 'order' => 3,
- 'template' => 'list',
- 'entityID' => 'memberInfo',
- 'defaultRefType'=> 'member',
- 'refLink' => $membersRefLink,
- 'url' => $membersEditPage,
- 'countUrl' => $membersIndexPage . '&glm_action=list&filterPending=true',
- 'result' => $MemberInfo->getList('status='.$MemberInfo->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit),
- 'count' => $MemberInfo->getStats('status='.$MemberInfo->config['status_numb']['Pending']),
- 'fieldMap' => [
- 'ID' => 'id',
- 'name' => 'reference_name',
- 'status' => 'status',
- 'refDestID' => 'member_pointer',
- 'refDestName' => 'member',
- //'ref_type' => 'ref_type', // membersInfo has no ref_type field yet
- ],
+ 'id' => 'dateSearch',
+ 'order' => 3,
+ 'fromDate' => 'fromDate',
+ 'toDate' => 'toDate',
+ 'template' => 'dateSearch',
+ 'entityID' => 'members',
+ 'defaultFromDate' => date('m/d/Y'),
+ 'resultUrl' => $eventsListPage.'&event=',
],
[
- 'id' => 'bad-location-data',
- 'title' => "Bad Location Data",
- 'slug' => "bad-location-data",
- 'order' => 4,
- 'template' => 'list',
- 'entityID' => 'memberInfo',
- 'defaultRefType'=> 'member',
- 'refLink' => $membersRefLink,
- 'url' => $membersEditPage,
- 'countUrl' => $membersIndexPage . '&glm_action=list&filterBadLocation=true',
- 'result' => $MemberInfo->getList("has_no_map_data='1'", $order, $fieldVals, $idField, $start, $limit),
- 'count' => $MemberInfo->getStats("has_no_map_data='1'"),
- 'fieldMap' => [
- 'ID' => 'id',
- 'name' => 'reference_name',
- 'status' => 'status',
- 'refDestID' => 'member_pointer',
- 'refDestName' => 'member',
- //'ref_type' => 'ref_type', // membersInfo has no ref_type field yet
- ],
+ 'id' => 'categorySearch',
+ 'order' => 4,
+ 'categories' => ['cat 1', 'cat 2', 'cat 3'],
+ 'template' => 'category',
+ 'entityID' => 'members',
+ 'defaultFromDate' => date('m/d/Y'),
+ ],
+ [
+ 'id' => 'memberTypeSearch',
+ 'order' => 5,
+ 'template' => 'dropdown',
+ 'entityID' => 'members',
+ 'defaultFromDate' => date('m/d/Y'),
+ 'resultUrl' => $eventsListPage.'&event=',
+ ],
+ [
+ 'id' => 'archiveSearch',
+ 'order' => 6,
+ 'template' => 'checkbox',
+ 'entityID' => 'members',
+ 'defaultFromDate' => date('m/d/Y'),
+ 'resultUrl' => $eventsListPage.'&event=',
+ ],
+ [
+ 'id' => 'featuredSearch',
+ 'order' => 7,
+ 'template' => 'checkbox',
+ 'entityID' => 'event',
+ 'defaultFromDate' => date('m/d/Y'),
+ 'resultUrl' => $eventsListPage.'&event=',
],
]
];