adding name and date search to the dashboard widget
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 18 Oct 2018 20:14:01 +0000 (16:14 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 18 Oct 2018 20:14:01 +0000 (16:14 -0400)
models/admin/leads/index.php
setup/adminHooks.php

index 6b32a12..ee73f13 100644 (file)
@@ -167,7 +167,7 @@ class GlmMembersAdmin_leads_index extends GlmDataLeadEntry
             // Verify mm/dd/YYYY date format for the from and to dates.
             if ( !isset( $search_params ) ) {
                 $search_params = filter_var_array(
-                    $_POST,
+                    $_REQUEST,
                     array(
                         'source_id' => FILTER_VALIDATE_INT,
                         'company'   => FILTER_SANITIZE_STRING,
index e6f55fb..0df8d44 100644 (file)
@@ -70,23 +70,23 @@ add_filter(
         $limit = false;
     
         // Save the current fields array and make a copy. Will be restored before the return.
-        $fSave = $Events->fields;
+        $fSave = $Leads->fields;
     
         // Remove what we don't want from the copy and get the list
-        $Events->fields = array(
-            'id'            => $fSave['id'],
-            'name'          => $fSave['name'],
-            'name_slug'     => $fSave['name_slug'],
-            'ref_type'      => $fSave['ref_type'],
-            'ref_dest'      => $fSave['ref_dest'],
-            'ref_dest_id'   => $fSave['ref_dest_id'],
-            'status'        => $fSave['status'],
-        );
+        // $Leads->fields = array(
+        //     'id'            => $fSave['id'],
+        //     'name'          => $fSave['name'],
+        //     'name_slug'     => $fSave['name_slug'],
+        //     'ref_type'      => $fSave['ref_type'],
+        //     'ref_dest'      => $fSave['ref_dest'],
+        //     'ref_dest_id'   => $fSave['ref_dest_id'],
+        //     'status'        => $fSave['status'],
+        // );
     
         $leadsIndexPage    = GLM_MEMBERS_LEADS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-leads-index&glm_action=edit';
         $leadsTable        = GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_entry";
         $leadsEditPage     = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'leads-index&glm_action=list&option=edit';
-        $leadsListPage     = GLM_MEMBERS_LEADS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-leads-list';
+        $leadsListPage     = GLM_MEMBERS_LEADS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-leads-index';
         $leadsRefLink      = GLM_MEMBERS_LEADS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member&glm_action=index';
         $content           = [
             'title' => 'Leads',
@@ -139,6 +139,16 @@ add_filter(
                     'url'       => $leadsIndexPage . "&option=search",
                     'result'    => $Leads->getStats()
                 ],
+                [
+                    'id'                => 'dateSearch', 
+                    'order'             => 3,
+                    'template'          => 'dateSearch',
+                    'entityID'          => 'lead',
+                    'fromDate'          => 'from_date',
+                    'toDate'            => 'to_date',
+                    'defaultFromDate'   => date('m/d/Y'),
+                    'resultUrl'         => $leadsListPage."&search=1"
+                ],
                 [
                     'id'        => 'textSearch', 
                     'order'     => 2,
@@ -146,14 +156,14 @@ add_filter(
                     'entityID'  => 'event',
                     'table'     => $leadsTable,
                     'fields'    => 'concat(fname," ",lname) as name,id',
-                    'resultUrl' => $leadsEditPage.'&lead=',
+                    'resultUrl' => $leadsEditPage,
                     'where'     => 'concat(fname," ",lname)'
                 ],
             ]
         ];
 
         // Restore the fields list
-        $Events->fields = $fSave;
+        $Leads->fields = $fSave;
 
         return $content;
     },