'use' => 'a',
),
+ 'members' => array(
+ 'field' => 'members',
+ 'type' => 'checkbox',
+ 'use' => 'a',
+ ),
+
);
* version from this plugin.
*/
define('GLM_MEMBERS_LEADS_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_LEADS_PLUGIN_DB_VERSION', '0.0.2');
+define('GLM_MEMBERS_LEADS_PLUGIN_DB_VERSION', '0.0.3');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
define('GLM_MEMBERS_LEADS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.0.5');
// Fetch the groupData.
$groupData = new GlmDataInterestGroups( $this->wpdb, $this->config );
- $groups = $groupData->getList();
+ if ( $user_can_edit_leads ) {
+ $groups = $groupData->getList();
+ } else {
+ $groups = $groupData->getList( "T.members = 1" );
+ }
// Initialize the grouped_interests array
$grouped_interests = array();
'fname' => $lead['fname'],
'lname' => $lead['lname'],
'email' => $lead['lead_id']['name'],
- 'org' => $lead['org'],
'addr1' => $lead['addr1'],
'addr2' => $lead['addr2'],
'city' => $lead['city'],
'date_submitted' => $lead['date_submitted'],
'source' => $lead['source_id']['name'],
);
+ if ( !$user_can_edit_leads ) {
+ unset(
+ $out['source']
+ );
+ }
$interest_by_groups = array();
/*
* Setup the interests so they are comma separated into a
* grouped field. Group name will be the field name header.
*/
+ $lead_interests_where
+ = ( !$user_can_edit_leads )
+ ? " AND g.members = true"
+ : '';
$lead_interests = $this->wpdb->get_results(
$this->wpdb->prepare(
"SELECT li.interest_id, g.title as 'group', i.title
- FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_interests li
- LEFT OUTER JOIN " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "interests i ON (i.id = li.interest_id)
- LEFT OUTER JOIN " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "interest_groups g ON (i.group_id = g.id)
- WHERE lead_entry_id = %d",
+ FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_interests li,
+ " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "interests i,
+ " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "interest_groups g
+ WHERE i.id = li.interest_id
+ AND i.group_id = g.id
+ $lead_interests_where
+ AND lead_entry_id = %d",
$lead['id']
),
ARRAY_A
+++ /dev/null
--- Gaslight Media Members Database - Leads
--- File Created: 12/02/15 15:27:15
--- Database Version: 0.0.1
--- Database Creation Script
---
--- This file is called to create a new set of tables for this
--- add-on for the most receint database version for this add-on.
---
--- There should only be one such file in this directory
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
-
--- Leads
-CREATE TABLE {prefix}leads (
- id INT NOT NULL AUTO_INCREMENT,
- email TINYTEXT NULL, -- Email address of lead
- mail_ok BOOLEAN NULL, -- OK to send them E-Mail
- member_ok BOOLEAN NULL, -- OK to have members contact lead
- created DATETIME NULL, -- Timestamp lead was first added
- PRIMARY KEY (id),
- INDEX (email(20))
-);
-
-----
-
--- Sources - info on form or method via which lead can be submitted
-CREATE TABLE {prefix}sources (
- id INT NOT NULL AUTO_INCREMENT,
- title TINYTEXT NULL, -- Title/Name of source for reference
- code TINYTEXT NULL, -- Code supplied by form to indicate source
- form_id INT NULL,
- enabled BOOLEAN NULL,
- PRIMARY KEY (id),
- INDEX (code(20))
-);
-
-----
-
--- Lead Entry - Information on a single submission of lead information
-CREATE TABLE {prefix}lead_entry (
- id INT NOT NULL AUTO_INCREMENT,
- source_id SMALLINT NULL, -- Pointer to sources entry - Form used to submit lead data
- lead_id INTEGER NULL, -- Pointer to lead - all submissions for same E-Mail address point to same leads entry
- fname TINYTEXT NULL, -- First Name
- lname TINYTEXT NULL, -- Last Name
- org TINYTEXT NULL, -- Organization name
- addr1 TINYTEXT NULL, -- Address line 1
- addr2 TINYTEXT NULL, -- Address line 2
- city TINYTEXT NULL, -- City name
- state TINYTEXT NULL, -- State/Province - as submitted by Gravityforms or whatever (not state code)
- zip TINYTEXT NULL, -- ZIP/Postal code
- country TINYTEXT NULL, -- Country name - as submitted by form (not country code)
- phone TINYTEXT NULL, -- Primary phone #
- phone2 TINYTEXT NULL, -- Alternate phone #
- fax TINYTEXT NULL, -- Fax #
- how_heard SMALLINT NULL, -- Pointer to how_heard table entry
- visit_date DATE NULL, -- Anticipated date of visit
- date_submitted DATE NULL, -- Date this information was submitted
- user_trace_info TINYTEXT NULL, -- User IP address and other identifying network info (pos referrer)
- PRIMARY KEY (id),
- INDEX (source_id),
- INDEX (lead_id),
- INDEX (fname(20)),
- INDEX (lname(20)),
- INDEX (visit_date),
- INDEX (date_submitted)
-);
-
-----
-
--- Interest Groups
-CREATE TABLE {prefix}interest_groups (
- id INT NOT NULL AUTO_INCREMENT,
- title TINYTEXT NULL, -- Group name
- PRIMARY KEY (id)
-);
-
-----
-
--- Interests - Used to buil Interest fields in forms - Forms use ID as value
-CREATE TABLE {prefix}interests (
- id INT NOT NULL AUTO_INCREMENT,
- title TINYTEXT NULL, -- Title
- group_id SMALLINT NULL, -- Pointer to interest group
- PRIMARY KEY (id),
- INDEX (group_id)
-);
-
-----
-
--- Lead Interests - many to one links to lead-entry table
-CREATE TABLE {prefix}lead_interests (
- id INT NOT NULL AUTO_INCREMENT,
- interest_id SMALLINT NULL, -- Pointer to Interest table
- lead_entry_id INTEGER NULL, -- Pointer to lead_entry table
- PRIMARY KEY (id),
- INDEX (interest_id),
- INDEX (lead_entry_id)
-);
-
-----
-
--- lead_searches - Memorized search configurations
-CREATE TABLE {prefix}searches (
- id INT NOT NULL AUTO_INCREMENT,
- user_id INT NOT NULL, -- The wordpress user id
- title TINYTEXT NULL, -- Title for this search configuration
- search TEXT NULL, -- Serialized array of search parameters
- date_created DATE NULL, -- Date the search type was created
- PRIMARY KEY (id)
-);
-
-----
-
--- Lead Stats Date Data - Totals of lead stats for 1 day - Preserved for 2 years
-CREATE TABLE {prefix}lead_stats_date (
- id INT NOT NULL AUTO_INCREMENT,
- stat_date DATE NULL, -- Date for which these stats are accumulated
- leads_count INTEGER NULL, -- Number of leads
- PRIMARY KEY (id),
- INDEX (stat_date)
-);
-
-----
-
--- Lead Stats Week Data - Totals of lead stats for 1 week - Preserved for 2 years - (generated daily?)
-CREATE TABLE {prefix}lead_stats_week (
- id INT NOT NULL AUTO_INCREMENT,
- stat_week DATE NULL, -- First date of week for which these stats are accumulated
- leads_count INTEGER NULL, -- Number of leads
- PRIMARY KEY (id),
- INDEX (stat_week)
-);
-
-----
-
--- Lead Stats Month Data - Totals of lead stats for 1 month - Preserved indefinately - (generated daily?)
-CREATE TABLE {prefix}lead_stats_month (
- id INT NOT NULL AUTO_INCREMENT,
- stat_month DATE NULL, -- First date of month for which these stats are accumulated
- leads_count INTEGER NULL, -- Number of leads
- PRIMARY KEY (id),
- INDEX (stat_month)
-);
--- /dev/null
+-- Gaslight Media Members Database - Leads
+-- File Created: 16/07/19 16:16:16
+-- Database Version: 0.0.3
+-- Database Creation Script
+--
+-- This file is called to create a new set of tables for this
+-- add-on for the most receint database version for this add-on.
+--
+-- There should only be one such file in this directory
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+
+-- Leads
+CREATE TABLE {prefix}leads (
+ id INT NOT NULL AUTO_INCREMENT,
+ email TINYTEXT NULL, -- Email address of lead
+ mail_ok BOOLEAN NULL, -- OK to send them E-Mail
+ member_ok BOOLEAN NULL, -- OK to have members contact lead
+ created DATETIME NULL, -- Timestamp lead was first added
+ PRIMARY KEY (id),
+ INDEX (email(20))
+);
+
+----
+
+-- Sources - info on form or method via which lead can be submitted
+CREATE TABLE {prefix}sources (
+ id INT NOT NULL AUTO_INCREMENT,
+ title TINYTEXT NULL, -- Title/Name of source for reference
+ code TINYTEXT NULL, -- Code supplied by form to indicate source
+ form_id INT NULL,
+ enabled BOOLEAN NULL,
+ PRIMARY KEY (id),
+ INDEX (code(20))
+);
+
+----
+
+-- Lead Entry - Information on a single submission of lead information
+CREATE TABLE {prefix}lead_entry (
+ id INT NOT NULL AUTO_INCREMENT,
+ source_id SMALLINT NULL, -- Pointer to sources entry - Form used to submit lead data
+ lead_id INTEGER NULL, -- Pointer to lead - all submissions for same E-Mail address point to same leads entry
+ fname TINYTEXT NULL, -- First Name
+ lname TINYTEXT NULL, -- Last Name
+ org TINYTEXT NULL, -- Organization name
+ addr1 TINYTEXT NULL, -- Address line 1
+ addr2 TINYTEXT NULL, -- Address line 2
+ city TINYTEXT NULL, -- City name
+ state TINYTEXT NULL, -- State/Province - as submitted by Gravityforms or whatever (not state code)
+ zip TINYTEXT NULL, -- ZIP/Postal code
+ country TINYTEXT NULL, -- Country name - as submitted by form (not country code)
+ phone TINYTEXT NULL, -- Primary phone #
+ phone2 TINYTEXT NULL, -- Alternate phone #
+ fax TINYTEXT NULL, -- Fax #
+ how_heard SMALLINT NULL, -- Pointer to how_heard table entry
+ visit_date DATE NULL, -- Anticipated date of visit
+ date_submitted DATE NULL, -- Date this information was submitted
+ user_trace_info TINYTEXT NULL, -- User IP address and other identifying network info (pos referrer)
+ PRIMARY KEY (id),
+ INDEX (source_id),
+ INDEX (lead_id),
+ INDEX (fname(20)),
+ INDEX (lname(20)),
+ INDEX (visit_date),
+ INDEX (date_submitted)
+);
+
+----
+
+-- Interest Groups
+CREATE TABLE {prefix}interest_groups (
+ id INT NOT NULL AUTO_INCREMENT,
+ title TINYTEXT NULL, -- Group name
+ members BOOLEAN false,
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Interests - Used to buil Interest fields in forms - Forms use ID as value
+CREATE TABLE {prefix}interests (
+ id INT NOT NULL AUTO_INCREMENT,
+ title TINYTEXT NULL, -- Title
+ group_id SMALLINT NULL, -- Pointer to interest group
+ PRIMARY KEY (id),
+ INDEX (group_id)
+);
+
+----
+
+-- Lead Interests - many to one links to lead-entry table
+CREATE TABLE {prefix}lead_interests (
+ id INT NOT NULL AUTO_INCREMENT,
+ interest_id SMALLINT NULL, -- Pointer to Interest table
+ lead_entry_id INTEGER NULL, -- Pointer to lead_entry table
+ PRIMARY KEY (id),
+ INDEX (interest_id),
+ INDEX (lead_entry_id)
+);
+
+----
+
+-- lead_searches - Memorized search configurations
+CREATE TABLE {prefix}searches (
+ id INT NOT NULL AUTO_INCREMENT,
+ user_id INT NOT NULL, -- The wordpress user id
+ title TINYTEXT NULL, -- Title for this search configuration
+ search TEXT NULL, -- Serialized array of search parameters
+ date_created DATE NULL, -- Date the search type was created
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Lead Stats Date Data - Totals of lead stats for 1 day - Preserved for 2 years
+CREATE TABLE {prefix}lead_stats_date (
+ id INT NOT NULL AUTO_INCREMENT,
+ stat_date DATE NULL, -- Date for which these stats are accumulated
+ leads_count INTEGER NULL, -- Number of leads
+ PRIMARY KEY (id),
+ INDEX (stat_date)
+);
+
+----
+
+-- Lead Stats Week Data - Totals of lead stats for 1 week - Preserved for 2 years - (generated daily?)
+CREATE TABLE {prefix}lead_stats_week (
+ id INT NOT NULL AUTO_INCREMENT,
+ stat_week DATE NULL, -- First date of week for which these stats are accumulated
+ leads_count INTEGER NULL, -- Number of leads
+ PRIMARY KEY (id),
+ INDEX (stat_week)
+);
+
+----
+
+-- Lead Stats Month Data - Totals of lead stats for 1 month - Preserved indefinately - (generated daily?)
+CREATE TABLE {prefix}lead_stats_month (
+ id INT NOT NULL AUTO_INCREMENT,
+ stat_month DATE NULL, -- First date of month for which these stats are accumulated
+ leads_count INTEGER NULL, -- Number of leads
+ PRIMARY KEY (id),
+ INDEX (stat_month)
+);
$glmMembersLeadsDbVersions = array(
'0.0.1' => array('version' => '0.0.1', 'tables' => 10, 'date' => '6/8/2016'),
'0.0.2' => array('version' => '0.0.2', 'tables' => 10, 'date' => '7/12/2016'),
+ '0.0.3' => array('version' => '0.0.3', 'tables' => 10, 'date' => '7/19/2016'),
);
-- Gaslight Media Members Database - Events Add-On
--- File Created: 12/09/14 15:27:15
--- Database Version: 0.0.9
+-- File Created: 16/07/12 15:27:15
+-- Database Version: 0.0.2
-- Database Update From Previous Version Script
--
-- To permit each query below to be executed separately,
--- /dev/null
+-- Gaslight Media Members Database - Events Add-On
+-- File Created: 16/07/19 16:16:16
+-- Database Version: 0.0.3
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+
+-- Add form_id
+ALTER TABLE {prefix}interest_groups ADD COLUMN members BOOLEAN DEFAULT false;
<a class="button button-primary glm-button glm-right" href="{$thisUrl}?page={$thisPage}&option=add">Add New Lead</a>
{/if}
{if $searching}
-<button id="search-form-toggle">Show / Hide Search Form</button>
+<button id="search-form-toggle" class="button">Show / Hide Search Form</button>
{/if}
<form action="{$thisUrl}?page={$thisPage}" method="post">
<input type="hidden" name="search" value="1" />
<input type="hidden" name="nextStart" value="{$nextStart}" />
<input type="hidden" name="limit" value="{$limit}" />
<table style="width: 500px;" id="lead-search-form"{if $searching} class="hide"{/if}>
+ {if $user_can_edit_leads}
<tr>
<td style="text-align: right;"><label for="glm-form-source_id">Source</label></td>
<td>
</td>
</tr>
<tr>
- <td style="text-align: right;"><label for="glm-form-company">Company</label></td>
- <td><input type="text" id="glm-form-company" name="company" value="{$search_params.company}"></td>
- </tr>
- <tr>
- <td style="text-align: right;"><label for="glm-form-contact">Contact</label></td>
+ <td style="text-align: right;"><label for="glm-form-contact">Name</label></td>
<td><input type="text" id="glm-form-contact" name="contact" value="{$search_params.contact}"></td>
</tr>
+ {/if}
<tr>
<th colspan="2">Date Range</th>
</tr>
<td style="text-align: right;"><label for="glm-form-to_date">To</label></td>
<td><input type="text" id="glm-form-to_date" name="to_date" value="{$search_params.to_date}"></td>
</tr>
+ {if $user_can_edit_leads}
<tr>
<td style="text-align: right;"><label>Mail Ok</label></td>
<td>
</select>
</td>
</tr>
- {if $user_can_edit_leads}
<tr>
<td style="text-align: right;"><label>Member Ok</label></td>
<td>
<input type="text" name="title" class="glm-form-text-input">
</td>
</tr>
+ <tr>
+ <th>For members?</th>
+ <td>
+ <input type="hidden" name="members" value="0">
+ <label>
+ <input type="checkbox" name="members" value="1">
+ Yes
+ </label>
+ </td>
+ </tr>
</table>
<p><span class="glm-required">*</span> Required</p>
<a id="newGroupCancel" class="button button-primary glm-right">Cancel</a>
<input id="editGroupName" type="text" name="title" class="glm-form-text-input">
</td>
</tr>
+ <tr>
+ <th>For members?</th>
+ <td>
+ <input type="hidden" name="members" value="0">
+ <label>
+ <input id="editGroupMembers" type="checkbox" name="members" value="1">
+ Yes
+ </label>
+ </td>
+ </tr>
</table>
<p><span class="glm-required">*</span> Required</p>
<tr class="alternate">
{/if}
<td>
- <a class="editGroup" data-groupID="{$t.id}" data-refTypeID="{$t.ref_type.value}">{$t.title}</a>
+ <a class="editGroup" data-groupID="{$t.id}" data-refTypeID="{$t.ref_type.value}" data-members="{$t.members.value}">{$t.title}</a>
</td>
<td>
<div class="deleteGroupButton button button-secondary glm-button-small glm-right" data-groupID="{$t.id}">Delete</div>
$("#newGroupDialog").dialog("open");
});
$('.editGroup').click( function() {
- var groupID = $(this).attr('data-groupID');
- var groupName = $(this).text();
+ var groupID = $(this).attr('data-groupID');
+ var groupName = $(this).text();
+ var groupMembers = $(this).attr('data-members');
$('#editGroupID').val(groupID);
$('#editGroupName').val(groupName.trim());
+ if ( groupMembers === '1' ) {
+ $('#editGroupMembers').prop( 'checked', 'checked' );
+ } else {
+ $('#editGroupMembers').prop( 'checked', null );
+ }
$("#editGroupDialog").dialog("open");
});
$('#editGroupCancel').click( function() {