// 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);
* Exp $
* @link http://www.visitgreatlakesbay.org/
*/
-class GlmDataMemberInfo extends GlmDataAbstract {
+class GlmDataMemberInfo extends GlmDataAbstract
+{
/**
* WordPress Database Object
'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',
* 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, ...)
;";
$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
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
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;
/**
* 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.
*/
public function getList($where = '', $order = '', $fieldVals = true, $idField = 'id')
{
+
// NOTE: $fieldVals not yet implemented
// Get field specifications for this instance
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,
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
-<?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 (
'1be35689c5d30d774f40ebc45e387f5f95c45e90' =>
array (
0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html',
- 1 => 1426429308,
+ 1 => 1426784332,
2 => 'file',
),
),
<?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 }?>>
}
// 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');
// 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;
// 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;
$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']);
public function modelAction ($actionData = false)
{
- $where = ' TRUE';
+ $where = '';
+ $whereSep = '';
$filterPending = false;
$filterArchived = false;
$filterName = false;
// 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
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');
'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
{/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}>
<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) {
{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} {/if}{$v.name}
</option>
{/foreach}
{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}