Cleaned up last of initial issues with Front End
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 19 Mar 2015 20:01:42 +0000 (16:01 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 19 Mar 2015 20:01:42 +0000 (16:01 -0400)
16 files changed:
classes/data/dataCategoryMemberInfo.php
classes/data/dataMemberInfo.php
config/plugin.ini
css/front.css
lib/GlmDataAbstract/DataAbstract.php
misc/databaseScripts/create_database_V0.1.sql
misc/notes.txt
misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php
models/admin/configure/categories.php
models/admin/member/index.php
models/admin/member/memberInfo.php
models/admin/members/index.php
models/front/members/list.php
views/admin/member/index.html
views/front/members/detail.html
views/front/members/list.html

index caceaed..55d7632 100644 (file)
@@ -277,7 +277,8 @@ class GlmDataCategoryMemberInfo extends GlmDataAbstract
                 // Add the category
                 $sql = "
                     DELETE FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info
-                     WHERE id = ".$val['id']."
+                     WHERE member_info = $memberInfoID
+                       AND id = ".$val['id']."
                 ;";
                 $this->wpdb->query($sql);
 
index 5cd019d..5dd38db 100644 (file)
@@ -25,7 +25,8 @@
  *          Exp $
  * @link http://www.visitgreatlakesbay.org/
  */
-class GlmDataMemberInfo extends GlmDataAbstract {
+class GlmDataMemberInfo extends GlmDataAbstract
+{
 
     /**
      * WordPress Database Object
@@ -125,6 +126,13 @@ class GlmDataMemberInfo extends GlmDataAbstract {
                                'use' => 'a'
                        ),
 
+                       // Member Name (stored by member updates) for sorting
+                       'member_name' => array(
+                        'field' => 'member_name',
+                               'type' => 'text',
+                               'use' => 'lg'
+                       ),
+
                        // Member Pointer index
                        'member_pointer' => array (
                                'field' => 'member',
@@ -346,7 +354,7 @@ class GlmDataMemberInfo extends GlmDataAbstract {
         * Perform post-processing for all result entries.
         *
         * In this case we're using it to append an array of category
-        * data to each member result.
+        * data to each member result and also sort by member name.
         *
         * @param array $r Array of field result data for a single entry
         * @param string $a Action being performed (l, i, g, ...)
@@ -379,10 +387,44 @@ class GlmDataMemberInfo extends GlmDataAbstract {
         ;";
            $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
 
-           // Required
            return $r;
        }
 
+       /*
+        * Get Apha list of first characters in member name
+        * for those members that have active info.
+        *
+        * @param string $where Where clause
+        *     Note the table refernces M and I.
+        * @param string $selected Optional selected alpha character
+        *
+        * @return object Class object
+        *
+        */
+       public function getAlphaList($where = '', $selected = '')
+       {
+
+           $sql = "
+              SELECT DISTINCT LEFT(M.name, 1) AS alpha
+                FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members M,
+                     ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info T
+               WHERE T.status = ".$this->config['status_numb']['Active']."
+                 AND M.id = T.member
+                     $where
+               ORDER BY alpha
+           ;";
+           $alphaData = $this->wpdb->get_results($sql, ARRAY_A);
+
+           // Set selected
+           foreach ($alphaData as $k=>$v) {
+               $alphaData[$k]['default'] = ($v['alpha'] == $selected);
+           }
+
+           return $alphaData;
+
+       }
+
+
 }
 
 ?>
\ No newline at end of file
index 685cbac..f942a5a 100644 (file)
@@ -66,7 +66,7 @@ front-config['list_show_search'] = true
 front-config['list_search_text'] = true
 front-config['list_search_category'] = true
 front-config['list_search_amenities'] = false
-front-config['list_search_alpha'] = false
+front-config['list_search_alpha'] = true
 ;    Front-end Member Listing Options
 front-config['list_show_detaillink'] = true
 front-config['list_show_logo'] = true
index d0d9241..3185406 100644 (file)
@@ -36,7 +36,6 @@
     width: 90%;
 }
 
-
 /* Member List */
 .glm-member-list-container {
     border: 1px #ccc solid;
     margin-top: .5em;
 }
 
-/* Map */
+/* Alpha Lists */
+.glm-alpha-links {
+    clear: both;
+}
+.glm-alpha-link {
+    border: 1px black solid;
+    padding: .1em .3em .1em .3em;
+    margin-right: .2em;    
+    font-weight: bold;
+    text-decoration: none !important;
+}
+.glm-alpha-link a:hover {
+}
+.glm-alpha-link-selected {
+    background-color: blue;
+    color: white;
+}
 
+/* Maps */
 .glm-map { 
     width: 100%; 
     height:400px; 
index 1e2422b..c3d30a8 100755 (executable)
@@ -2895,6 +2895,11 @@ abstract class GlmDataAbstract
     /**
      * List Entries Method
      *
+     * NOTE: Order by only works on the initial query, not on the target values of
+     * pointer fields because those fields are post-processed to get the target value
+     * after the query takes place. Calling code will have to sort the results to
+     * sort by those target values.
+     *
      * @param string $where Optional WHERE clause for selection of entries. Defaults to all.
      * @param string $order Optional ORDER BY clause for sorting of results.
      * @param boolean $fieldVals Optional flag requesting fields contain array of all possible values.
@@ -2905,6 +2910,7 @@ abstract class GlmDataAbstract
      */
     public function getList($where = '', $order = '', $fieldVals = true, $idField = 'id')
     {
+
         // NOTE: $fieldVals not yet implemented
 
         // Get field specifications for this instance
index f21f35f..b54b8b7 100644 (file)
@@ -382,6 +382,7 @@ CREATE TABLE {prefix}members (
 CREATE TABLE {prefix}member_info (
   id INT NOT NULL AUTO_INCREMENT,
   member INT NULL,
+  member_name TINYTEXT NULL,
   status INT NULL,
   reference_name TINYTEXT NULL,
   descr TEXT NULL,
index c030fe8..053e7aa 100644 (file)
@@ -3,6 +3,9 @@ Development Notes
 
 ADMIN AREA
 
+* Member Info Add/Edit
+    - When editing a member info record, if the user specifies a new main category more than once with the "Add a new Category" button, the category is created multiple times.
+
 * Consider paginating certain lists
 
 * On all admin lists - add sort order links to headers
index d9d4e4d..742809d 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-15 10:21:53
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-19 12:58:55
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html" */ ?>
 <?php /*%%SmartyHeaderCode:94073808254c05abfc4adf1-45287000%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->decodeProperties(array (
@@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array (
     '1be35689c5d30d774f40ebc45e387f5f95c45e90' => 
     array (
       0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html',
-      1 => 1426429308,
+      1 => 1426784332,
       2 => 'file',
     ),
   ),
@@ -71,8 +71,8 @@ $_valid = $_smarty_tpl->decodeProperties(array (
       <?php }?>
         
         <table class="glm-admin-table">
-            <tr><th>ID</th><td><?php echo $_smarty_tpl->tpl_vars['member']->value['fieldData']['id'];?>
-</td></tr>
+            <?php if ($_smarty_tpl->tpl_vars['haveMember']->value) {?><tr><th>ID</th><td><?php echo $_smarty_tpl->tpl_vars['member']->value['fieldData']['id'];?>
+</td></tr><?php }?>
             <tr>
                 <th <?php if ($_smarty_tpl->tpl_vars['member']->value['fieldRequired']['name']) {?>class="glm-required"<?php }?>>Member Name:</th>
                 <td <?php if ($_smarty_tpl->tpl_vars['member']->value['fieldFail']['name']) {?>class="glm-form-bad-input"<?php }?>>
index e582815..2be9fa0 100644 (file)
@@ -167,7 +167,7 @@ class GlmMembersAdmin_configure_categories extends GlmDataCategories
         }
 
         // Sort results by higherarchy (Parent/Child and Alpha)
-        $categories = glmMembersAdmin::sortParentChild($categories);
+        $categories = $this->sortParentChild($categories);
 
         if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
             glmMembersAdmin::addNotice($categories, 'DataBlock', 'Categories Data');
index b7ed4c0..8e26efb 100644 (file)
@@ -193,8 +193,18 @@ class GlmMembersAdmin_member_index extends GlmDataMembers
 
             // If update was successful then use editEntry() to setup for the edit again.
             if ($memberData['status']) {
+
                 $memberData = $this->editEntry($memberID);
                 $updated = true;
+
+                // Also update all member info records with any possible name change
+                $sql = "
+                    UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info
+                       SET member_name = '".addslashes($memberData['fieldData']['name'])."'
+                     WHERE member = $memberID
+                ;";
+                $this->wpdb->query($sql);
+
             }
 
             $haveMember = true;
index 76f2d00..b7cd233 100644 (file)
@@ -258,11 +258,22 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
             // Add the new member information record
             case 'addNew':
 
-                // Insert the new member into the database
+                // Insert the new member info into the database
+                $this->memberName = $memberData['name'];
                 $MemberInfo = $this->insertEntry();
                 if ($MemberInfo['status']) {
+
                     $memberInfoID = $MemberInfo['fieldData']['id'];
                     $haveMemberInfo = true;
+
+                    // Also store member name for reference and sorting
+                    $sql = "
+                        UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info
+                           SET member_name = '".addslashes($memberData['name'])."'
+                         WHERE id = $memberInfoID
+                    ;";
+                    $this->wpdb->query($sql);
+
                 }
 
                 break;
index 807302e..caee4bd 100644 (file)
@@ -133,6 +133,7 @@ class GlmMembersAdmin_members_index extends GlmDataMembers
         $membersPending = $MemberInfo->getStats('status = '.$this->config['status_numb']['Pending']);
 
         // If there's members with pending information, list them
+        $pendingList = false;
         if ($membersPending > 0) {
 
             $pendingList = $MemberInfo->getList('status = '.$this->config['status_numb']['Pending']);
index 0d0027f..46a5974 100644 (file)
@@ -99,7 +99,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
     public function modelAction ($actionData = false)
     {
 
-        $where = ' TRUE';
+        $where = '';
+        $whereSep = '';
         $filterPending = false;
         $filterArchived = false;
         $filterName = false;
@@ -109,7 +110,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
         // Apply any provided text search to name, description, short description, and street address
         if (isset($_REQUEST['textSearch']) && $_REQUEST['textSearch'] != '') {
             $textSearch = filter_input(INPUT_POST, 'textSearch', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
-            $where .= " AND (
+            $where .= $whereSep." (
                 (
                     SELECT true
                       FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members
@@ -121,22 +122,75 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                 T.addr1 LIKE '%$textSearch%' OR
                 T.addr2 LIKE '%$textSearch%'
             )";
+            $whereSep = ' AND ';
         }
 
-        // Apply any specified category filter
-        require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
-        $Categories = new GlmDataCategories($this->wpdb, $this->config);
-        $categoryData = $Categories->getListSortedParentChild();
-//*** HERE complete category filter ****
+        // Get category filter data
+        $categoryData = false;
+        $catSelected = '';
+        if ($this->config['front-config']['list_search_category']) {
+
+            // Get category data for search pick list
+            require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+            $Categories = new GlmDataCategories($this->wpdb, $this->config);
+            $categoryData = $Categories->getListSortedParentChild();
+
+            // Add default flag as false to all entries
+            foreach ($categoryData as $k=>$v) {
+                $categoryData[$k]['default'] = false;
+            }
+
+            // Check if a category has been submitted
+            if (isset($_REQUEST['categorySearch'])) {
+                $catSelected = $_REQUEST['categorySearch'] - 0;
+
+                // If we have a category ID
+                if ($catSelected > 0) {
+
+                    $where .= $whereSep." T.id in (
+                       SELECT DISTINCT(member_info)
+                         FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info M,
+                              ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories C
+                        WHERE M.category = $catSelected
+                           OR (C.parent = $catSelected AND M.category = C.id)
+                    )";
+                    $whereSep = ' AND ';
+
+                    // Set default to true for the selected category
+                    $categoryData[$catSelected]['default'] = true;
+
+                }
+            }
+
+        }
 
         // Only look at active member information
-        $where .= " AND T.status = ".$this->config['status_numb']['Active'];
+        $where .= $whereSep." T.status = ".$this->config['status_numb']['Active'];
+
+        // If doing alpha list
+        $alphaList = false;
+        $alphaWhere = '';
+        if ($this->config['front-config']['list_search_alpha']) {
+
+            $alphaSelected = false;
+
+            // Check for alpha selected
+            if (isset($_REQUEST['alpha']) && strlen($_REQUEST['alpha']) == 1) {
+                $alphaSelected = $_REQUEST['alpha'];
+                $alphaWhere .= " AND T.member_name LIKE '$alphaSelected%'";
+            }
+
+            // Get full list for all other filters, but not filtered by alpha (that would be silly)
+            $alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected);
+
+        }
 
         /*
          *  Get a current list of members
          */
 
-        $list = $this->getList($where);
+        // Get member list and sort
+        $list = $this->getList($where.$alphaWhere, 'member_name');
 
         if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
             glmMembersFront::addNotice($list, 'DataBlock', 'Member Data');
@@ -164,8 +218,10 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
             'filterPending' => $filterPending,
             'filterName' => stripslashes($filterName),
             'textSearch' => $textSearch,
-            'categories' => $categoryData
-//            'canEdit' => $canEdit
+            'categories' => $categoryData,
+            'catSelected' => $catSelected,
+            'alphaList' => $alphaList,
+            'alphaSelected' => $alphaSelected
         );
 
         // Return status, suggested view, and data to controller
index afe52b9..d801e61 100644 (file)
@@ -26,7 +26,7 @@
       {/if}
         
         <table class="glm-admin-table">
-            <tr><th>ID</th><td>{$member.fieldData.id}</td></tr>
+            {if $haveMember}<tr><th>ID</th><td>{$member.fieldData.id}</td></tr>{/if}
             <tr>
                 <th {if $member.fieldRequired.name}class="glm-required"{/if}>Member Name:</th>
                 <td {if $member.fieldFail.name}class="glm-form-bad-input"{/if}>
index 4e43aee..0741060 100644 (file)
             <div>
                 Enter address to show directions ...<br>
                 <input id="glm-startLocation" type="text" name="startLocation" class="glm-form-text-input" placeholder=""><br>
+                Directions type:
+                <select id="directionsType" name="directionsType">
+                    <option value="DRIVING">Driving</option>
+                    <option value="WALKING">Walking</option>
+                    <option value="BICYCLING">Bicycling</option>
+                    <!-- <option value="TRANSIT">Transit Services</option> - Doesn't seem to work -->
+                </select>
             </div>     
             <div>
                 <input type="submit" id="glm-showDirectionsButton" class="button button-secondary glm-button" value="Show Directions">
                 directionsMap = new google.maps.Map(document.getElementById("glm-directionsMap"), mapOptions);
                 directionsDisplay.setMap(directionsMap);
 
+                // Get directions type selected
+                var directionsType = $('#directionsType').find(':selected').val();
+                
                 // Specify origin and destination then get route
                 var request = {
                        origin: start,
                     destination: memberlocation,
-                    travelMode: google.maps.TravelMode.DRIVING
+                    travelMode: google.maps.TravelMode[directionsType]
                 };
                 directionsService.route(request, function(result, status) {
                     if (status == google.maps.DirectionsStatus.OK) {
index 03874af..2720419 100644 (file)
         {if $list_search_category}
                 <div>
                     Member Category: 
-                    <select name="categorySelect" id="categorySelect">
-                        <option id="categoryNone" value=""></option>
+                    <select name="categorySearch" id="categorySelect">
+                        <option value=""></option>
             {foreach from=$categories item=v}
-                        <option value="{$v.id}" data-parent="{$v.parent.name}">
+                        <option value="{$v.id}" data-parent="{$v.parent.name}"{if $v.default} selected="selected"{/if}>
                             {if $v.parent.value}&nbsp;&nbsp;&nbsp;&nbsp;{/if}{$v.name}
                         </option>
             {/foreach}
@@ -32,9 +32,6 @@
         {if $list_search_amenities}
                 <div>Amenity search goes here</div>
         {/if}    
-        {if $list_search_alpha}
-                <div>Alpha search goes here</div>
-        {/if}
                 <input type="submit" value="Search">        
             </div>
         </form>
 
 {if $list_show_list}    
     <h3>List of Members</h3>
-    
   {if $haveMembers}
-  
+
+    {if $list_search_alpha}
+        <div class="glm-alpha-links">
+            <a href="{$thisURL}?glm_action=list&textSearch={$textSearch}&categorySearch={$catSelected}" class="glm-alpha-link{if !$alphaSelected} glm-alpha-link-selected{/if}">All</a>
+        {foreach $alphaList as $a}
+            <a href="{$thisURL}?glm_action=list&alpha={$a.alpha}&textSearch={$textSearch}&categorySearch={$catSelected}" class="glm-alpha-link{if $a.default} glm-alpha-link-selected{/if}">{$a.alpha}</a>
+        {/foreach}
+        </div>
+    {/if}
+    
     <!-- Member information displayed in list -->
     {foreach $members as $m}
         <div class="glm-member-list-container">
-            {if $list_show_logo}<div class="glm-member-list-image"><img src="{$glmPluginMediaURL}/images/{$list_logo_size}/{$m.logo}"></div>{/if}
+            {if $m.logo && $list_show_logo}<div class="glm-member-list-image"><img src="{$glmPluginMediaURL}/images/{$list_logo_size}/{$m.logo}"></div>{/if}
             <div class="glm-member-list-nameAddress">
                 <h2>
                   {if $list_show_detaillink}