Add new setting for the trip planner.
Add send_itinerary_form_id for setting the gravity form id.
Will be used for submitting the form to the members.
'use' => 'a',
),
+ // Form id for Trip Planner Form
+ 'send_itinerary_form_id' => array(
+ 'field' => 'send_itinerary_form_id',
+ 'type' => 'integer',
+ 'use' => 'a',
+ ),
+
// Page id for Trip Planner Page
'itinerary_page' => array(
'field' => 'itinerary_page',
* version from this plugin.
*/
define('GLM_MEMBERS_ITINERARY_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_ITINERARY_PLUGIN_DB_VERSION', '0.0.1');
+define('GLM_MEMBERS_ITINERARY_PLUGIN_DB_VERSION', '0.0.2');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
define('GLM_MEMBERS_ITINERARY_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0');
}
return false;
});
+jQuery('.glm-itinerary-request-delete').on('click', function(e){
+ e.preventDefault();
+ var member_id = jQuery(this).data('id');
+ var base_url = jQuery(this).data('baseurl');
+ var button = jQuery(this);
+ if ( member_id ) {
+ jQuery.ajax({
+ url: base_url + '/wp-admin/admin-ajax.php',
+ cache: false,
+ data: {
+ action: 'glm_members_admin_ajax',
+ glm_action: 'itineraryList',
+ member_id: member_id,
+ del: true
+ },
+ success: function(){
+ window.location.href = glm_itinerary_page_url + '?option=moreinfo';
+ // button.parent('td').parent('tr.glm-itinerary-request-item').remove();
+ }
+ });
+ }
+ return false;
+});
*/
class GlmMembersFront_itinerary_list // extends GlmMembersFront_events_baseAction
{
+ /**
+ * Constructor
+ *
+ * This constructor performs the work for this model. This model returns
+ * an array containing the following.
+ *
+ * 'status'
+ *
+ * True if successful and false if there was a fatal failure.
+ *
+ * 'view'
+ *
+ * A suggested view name that the contoller 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.
+ *
+ * @wpdb object WordPress database object
+ *
+ * @return array Array containing status, suggested view, and any data
+ */
+ 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);
+
+ }
+
/**
* modelAction
*
*/
public function modelAction( $actionData = false )
{
- $status = true;
- $view = 'list.html';
- $members = array();
+ $status = true;
+ $view = 'list.html';
+ $members = array();
+ $option = 'list';
+ $form_contents = '';
+ $userLoggedIn = false;
+ $membersWithEmails =
+ $memberEmails =
+ $states =
+ $membersNoEmails = array();
if ( isset( $_SESSION['travel-list'] ) ) {
foreach ( $_SESSION['travel-list'] as $item ) {
}
}
+ // echo '<pre>$_SESSION: ' . print_r( $_SESSION, true ) . '</pre>';
+
+ if ( isset( $_REQUEST['option'] ) ) {
+ $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING );
+ }
+
+ if ( isset( $_SESSION['itinerary-auth'] ) && filter_var( $_SESSION['itinerary-auth'], FILTER_VALIDATE_INT ) ) {
+ $userLoggedIn = true;
+ }
+
+ switch ( $option ) {
+ case 'addAccount':
+ // Add the account
+ // Unless email already exists
+ // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+ $password = md5( filter_var( $_REQUEST['password'], FILTER_SANITIZE_STRING ) );
+ $this->wpdb->insert(
+ GLM_MEMBERS_ITINERARY_PLUGIN_DB_PREFIX . 'user',
+ array(
+ 'fname' => filter_var( $_REQUEST['fname'], FILTER_SANITIZE_STRING ),
+ 'lname' => filter_var( $_REQUEST['lname'], FILTER_SANITIZE_STRING ),
+ 'addr1' => filter_var( $_REQUEST['addr1'], FILTER_SANITIZE_STRING ),
+ 'addr2' => filter_var( $_REQUEST['addr2'], FILTER_SANITIZE_STRING ),
+ 'city' => filter_var( $_REQUEST['city'], FILTER_SANITIZE_STRING ),
+ 'state' => filter_var( $_REQUEST['state'], FILTER_SANITIZE_STRING ),
+ 'zip' => filter_var( $_REQUEST['zip'], FILTER_SANITIZE_STRING ),
+ 'email' => filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL ),
+ 'password' => $password,
+ ),
+ array(
+ '%s', // fname
+ '%s', // lname
+ '%s', // addr1
+ '%s', // addr2
+ '%s', // city
+ '%s', // state
+ '%s', // zip
+ '%s', // email
+ '%s', // password
+ )
+ );
+ $view = 'create.html';
+ break;
+ case 'create':
+ // Get list of states
+ $states = $this->config['states'];
+ // echo '<pre>$states: ' . print_r( $states, true ) . '</pre>';
+ $view = 'create.html';
+ break;
+ case 'login':
+ $email = filter_var( $_REQUEST['username'], FILTER_VALIDATE_EMAIL );
+ $password = filter_var( $_REQUEST['password'] );
+ $user_id = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT id
+ FROM " . GLM_MEMBERS_ITINERARY_PLUGIN_DB_PREFIX . "user
+ WHERE email = %s
+ AND password = md5(%s)",
+ $email,
+ $password
+ )
+ );
+ if ( $user_id ) {
+ // Success login
+ $_SESSION['itinerary-auth'] = $user_id;
+ $userLoggedIn = true;
+ }
+ global $wp;
+ $tripPlannerPage = get_permalink( $this->config['settings']['itinerary_page'] );
+ // Redirect to trip planner page
+ // if ( $tripPlannerPage ) {
+ // wp_redirect( $tripPlannerPage );
+ // exit;
+ // }
+ // $view = 'login.html';
+ break;
+ case 'forgot':
+ $view = 'forgot.html';
+ break;
+ case 'moreinfo':
+ // Need to create two list one with emails and one without.
+ foreach ( $members as $member ) {
+ if ( $member['email'] && filter_var( $member['email'], FILTER_VALIDATE_EMAIL ) ) {
+ $membersWithEmails[] = $member;
+ $memberEmwails[] = $member['email'];
+ } else if ( $member['phone'] ) {
+ $membersNoEmails[] = $member;
+ }
+ }
+ if ( count( $membersNoEmails ) == 0 && count( $membersWithEmails ) == 0 ) {
+ $view = 'list.html';
+ } else {
+ $view = 'moreinfo.html';
+ }
+ if ( count( $membersWithEmails ) > 0 ) {
+ $_GET['member_emails'] = implode( ',', $memberEmwails );
+ $form_id = $this->config['settings']['send_itinerary_form_id'];
+ if ( isset( $form_id ) && filter_var( $form_id, FILTER_VALIDATE_INT ) ) {
+ $form_contents = do_shortcode( '[gravityform id="' . $form_id . '" title="false" description="false"]' );
+ }
+ } else {
+ $form_contents = '';
+ }
+ break;
+ case 'list':
+ $view = 'list.html';
+ default:
+ break;
+ }
$templateData = array(
- 'baseurl' => get_bloginfo( 'url' ),
- 'members' => $members,
+ 'baseurl' => get_bloginfo( 'url' ),
+ 'members' => $members,
+ 'membersWithEmails' => $membersWithEmails,
+ 'membersNoEmails' => $membersNoEmails,
+ 'formContents' => $form_contents,
+ 'states' => $states,
+ 'userLoggedIn' => $userLoggedIn,
);
error_reporting(E_ALL ^ E_NOTICE);
+++ /dev/null
--- Gaslight Media Staff Add On
--- File Created: 2018-10-24
--- Database Version: 0.0.1
--- Database Creation Script
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
--- Itinerary Session
-CREATE TABLE {prefix}session (
- id INT NOT NULL AUTO_INCREMENT,
- ref_type INT NOT NULL, -- Reference Type (see plugin.ini for ref_types)
- ref_dest INT NOT NULL, -- Id from the Reference
- contact_type INT NOT NULL, -- Contact Type (see plugin.ini for contact_types)
- contact_dest INT NOT NULL, -- Id of the Contact Type
- page_url TEXT NOT NULL, -- Page url when this was added.
- PRIMARY KEY (id),
- INDEX(ref_dest),
- INDEX(contact_dest)
-);
-
-----
-
--- Itinerary User
-CREATE TABLE {prefix}user (
- id INT NOT NULL AUTO_INCREMENT,
- fname TINYTEXT NULL,
- lname TINYTEXT NULL,
- addr1 TINYTEXT NULL,
- addr2 TINYTEXT NULL,
- city TINYTEXT NULL,
- state TINYTEXT NULL,
- zip TINYTEXT NULL,
- email TINYTEXT NULL,
- phone TINYTEXT NULL,
- fax TINYTEXT NULL,
- password TINYTEXT NULL,
- PRIMARY KEY (id),
- INDEX(email(20))
-);
-
-----
-
--- Management
-CREATE TABLE {prefix}management (
- id INT NOT NULL AUTO_INCREMENT,
- itinerary_page INT NULL,
- itinerary_page_content TEXT NULL,
- add_label TINYTEXT NULL,
- view_label TINYTEXT NULL,
- PRIMARY KEY (id)
-);
-
-----
-
--- Add record to management table
-INSERT INTO {prefix}management (id, add_label, view_label) VALUES (1, 'Add to Trip Planner', 'View Trip Planner');
--- /dev/null
+-- Gaslight Media Staff Add On
+-- File Created: 2018-10-24
+-- Database Version: 0.0.1
+-- Database Creation Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Itinerary Session
+CREATE TABLE {prefix}session (
+ id INT NOT NULL AUTO_INCREMENT,
+ ref_type INT NOT NULL, -- Reference Type (see plugin.ini for ref_types)
+ ref_dest INT NOT NULL, -- Id from the Reference
+ contact_type INT NOT NULL, -- Contact Type (see plugin.ini for contact_types)
+ contact_dest INT NOT NULL, -- Id of the Contact Type
+ page_url TEXT NOT NULL, -- Page url when this was added.
+ PRIMARY KEY (id),
+ INDEX(ref_dest),
+ INDEX(contact_dest)
+);
+
+----
+
+-- Itinerary User
+CREATE TABLE {prefix}user (
+ id INT NOT NULL AUTO_INCREMENT,
+ fname TINYTEXT NULL,
+ lname TINYTEXT NULL,
+ addr1 TINYTEXT NULL,
+ addr2 TINYTEXT NULL,
+ city TINYTEXT NULL,
+ state TINYTEXT NULL,
+ zip TINYTEXT NULL,
+ email TINYTEXT NULL,
+ phone TINYTEXT NULL,
+ fax TINYTEXT NULL,
+ password TINYTEXT NULL,
+ PRIMARY KEY (id),
+ INDEX(email(20))
+);
+
+----
+
+-- Management
+CREATE TABLE {prefix}management (
+ id INT NOT NULL AUTO_INCREMENT,
+ send_itinerary_form_id INT NULL,
+ itinerary_page INT NULL,
+ itinerary_page_content TEXT NULL,
+ add_label TINYTEXT NULL,
+ view_label TINYTEXT NULL,
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Add record to management table
+INSERT INTO {prefix}management (id, add_label, view_label) VALUES (1, 'Add to Trip Planner', 'View Trip Planner');
$glmMembersItineraryDbVersions = array(
'0.0.1' => array('version' => '0.0.1', 'tables' => 3, 'date' => '10/31/2018'),
+ '0.0.2' => array('version' => '0.0.2', 'tables' => 3, 'date' => '11/13/2018'),
);
--- /dev/null
+-- Gaslight Media Members Database - Itinerary Add-On
+-- File Created: 2018-11-13
+-- Database Version: 0.0.2
+-- 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 for Itinerary
+ALTER TABLE {prefix}management ADD COLUMN send_itinerary_form_id INT NULL;
+
session_start();
}
});
+
+$form_id = ( isset( $config['settings']['send_itinerary_form_id'] ) ) ? $config['settings']['send_itinerary_form_id']: null;
+if ( isset( $form_id ) && filter_var( $form_id, FILTER_VALIDATE_INT ) ) {
+ // Send Trip Planner Form action after submission
+ add_action( 'gform_after_submission_' . $form_id, function(){
+ unset( $_SESSION['travel-list'] );
+ }, 10, 2);
+}
<input type="hidden" name="option2" value="submit">
<table class="glm-admin-table">
+ <tr>
+ <th {if $itinerarySettings.fieldRequired.send_itinerary_form_id} class="glm-required"}{/if}>Gravity Form Id For Trip Planner Form</th>
+ <td {if $itinerarySettings.fieldFail.send_itinerary_form_id}class="glm-form-bad-input" data-tabid="glm-send-itinerary-form-id"{/if}>
+ <input type="text" name="send_itinerary_form_id" value="{$itinerarySettings.fieldData.send_itinerary_form_id}" class="glm-form-text-input-small">
+ {if $itinerarySettings.fieldFail.send_itinerary_form_id}<p>{$itinerarySettings.fieldFail.send_itinerary_form_id}</p>{/if}<br>
+ </td>
+ </tr>
+
<tr>
<th {if $itinerarySettings.fieldRequired.itinerary_page} class="glm-required"}{/if}>Trip Planner Page Id</th>
<td {if $itinerarySettings.fieldFail.itinerary_page}class="glm-form-bad-input" data-tabid="glm-ititenary-page"{/if}>
--- /dev/null
+{* Create Account Form *}
+
+<!-- Compiled and minified CSS -->
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
+
+<!-- Compiled and minified JavaScript -->
+<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
+
+
+<h1>Create an Account to Save your Trip Planner</h1>
+
+<div class="row">
+ <form class="col s12" action="{$hisUrl}" method="post">
+ <input type="hidden" name="option" value="addAccount" />
+
+ <div class="row">
+ <div class="input-field col s6">
+ <input id="fname" name="fname" type="text" />
+ <label for="fname">First Name </label>
+ </div>
+ <div class="input-field col s6">
+ <input id="lname" name="lname" type="text" />
+ <label for="lname">Last Name </label>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="input-field col s6">
+ <input id="addr1" name="addr1" type="text" />
+ <label for="addr1">Address 1 </label>
+ </div>
+ <div class="input-field col s6">
+ <input id="addr2" name="addr2" type="text" />
+ <label for="addr2">Address 2 </label>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="input-field col s4">
+ <input id="city" name="city" type="text" />
+ <label for="city">City </label>
+ </div>
+ <div class="input-field col s4">
+ <select id="state" name="state">
+ <option value="">Select a State</option>
+ {foreach $states as $state_abbr => $state_name}
+ <option value="{$state_abbr}">{$state_name}</option>
+ {/foreach}
+ </select>
+ <label for="state">State </label>
+ </div>
+ <div class="input-field col s4">
+ <input id="vip" name="zip" type="text" />
+ <label for="zip">Zip </label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col s6">
+ <input id="email" type="email" name="email" required class="validate" />
+ <label for="email">Email </label>
+ <span class="helper-text" data-error="Not a valid email address!" data-success="Valid Email"></span>
+ </div>
+ <div class="input-field col s6">
+ <input id="password" type="password" name="password" required class="validate" />
+ <label for="password">Password </label>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="input-field col s12">
+ <button class="btn waves-effect waves-light" type="submit" name="action"> Create Account
+ </button>
+ </div>
+ </div>
+
+ </form>
+</div>
+
+<script>
+jQuery(document).ready(function($){
+ $('#state').formSelect();
+});
+</script>
{* Trip Planner (Itinerary) List page *}
+{if $members}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.3/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.3/dist/leaflet.js" integrity="sha512-tAGcCfR4Sc5ZP5ZoVz0quoZDYX5aCtEm/eu1KhSLj2c9eFrylXZknQYmxUssFaVJKvvc0dJQixhGjG2yXWiV9Q==" crossorigin=""></script>
<link rel="stylesheet" href="{$jsUrl}/LeafletMarkerCluster/dist/MarkerCluster.Default.css" />
<script src="{$jsUrl}/LeafletMarkerCluster/dist/leaflet.markercluster-src.js"></script>
<link rel="stylesheet" href="{$jsUrl}/Leaflet.loading/src/Control.Loading.css" />
<script src="{$jsUrl}/Leaflet.loading/src/Control.Loading.js"></script>
+{/if}
<p>{$settings.itinerary_page_content}</p>
<div style="width: 100%; padding: 20px;">
- <form>
+ {if !$userLoggedIn}
+ <form action="{$thisUrl}" method="post">
+ <input type="hidden" name="option" value="login" />
<div style="width: 30%; float: left; padding: 5px;">
<h2>Sign In:</h2>
- <input type="text" name="username" />
- <input type="password" name="password" />
- <input type="submit" value="Log in" class="button" />
+ <input type="text" name="username" />
+ <input type="password" name="password" />
+ <input type="submit" value="Log in" class="button" />
- <a href="#">Forgot your Password?</a>
+ <a href="{$thisUrl}?option=forgot">Forgot your Password?</a>
</div>
</form>
<div style="width: 30%; float: left; padding: 5px;">
<h2>If you do not have an account</h2>
- <button> Create Account </button><br>
+ <a href="{$thisUrl}?option=create"> Create Account </a><br>
By creating an account, you'll be able to save your list for later.
</div>
+ {else}
+ <div style="width: 60%; float: left; padding: 5px;">
+ <p>Logged in as ...</p>
+ </div>
+ {/if}
+ {if $members}
<div style="width: 30%; float: left; padding: 5px;">
<ul>
- <li> <a href="#">Get more info</a> </li>
+ <li> <a href="{$thisUrl}?option=moreinfo">Get more info</a> </li>
<li> <a href="#" class="list-print" data-areaToPrint="PrintArea">Print this list</a> </li>
<li> <a href="#">View Map</a> </li>
<li> <a href="#">Help</a> </li>
</ul>
</div>
+ {/if}
</div>
<br clear="all">
-<div id="glm-locationMap-container">
- <div id="LeafletMapContainer" style="height: 400px; width: 90%; border: 1px black solid; z-index: +0; margin: 0 auto;"></div>
-</div>
-
{if $members}
+ <div id="glm-locationMap-container">
+ <div id="LeafletMapContainer" style="height: 400px; width: 90%; border: 1px black solid; z-index: +0; margin: 0 auto;"></div>
+ </div>
+
{foreach $members as $data}
<div id="map_info_{$data.id}" class="glm-hidden">
<strong>{$data.member_name}</strong>
</div>
{/foreach}
</div>
-{/if}
<script src="{$jsUrl}/PrintArea/jquery.PrintArea.js" type="text/JavaScript" language="javascript"></script>
<script>
jQuery(document).ready(function($){
});
</script>
+{/if}
--- /dev/null
+<h1>Your Trip Planner List</h1>
+
+<p>Below is the list of businesses you have added to your Trip Planner. The
+form below will be sent to each individual business listing that has an email
+address listed with their business listing. For those businesses with no
+email address, we have included their phone numbers for you to call directly
+and request additional information.</p>
+<p>These business listings have no current email address on file. To receive
+additional information please call the phone numbers listed next to each
+business name.</p>
+
+{if count($membersNoEmails) > 0}
+ <h2>Request Information by Phone From:</h2>
+ <p>These business listings have no current email address on file. To receive
+ additional information please call the phone numbers listed next to each
+ business name.</p>
+ <table>
+ {foreach $membersNoEmails as $data}
+ <tr class="glm-itinerary-request-item">
+ <td>
+ {if !$data.has_no_profile}<a href="{$siteBaseUrl}{$settings.canonical_member_page}/{$data.member_slug}/{if $settings.enable_multiple_profiles}{$data.id}/{/if}">{/if}
+ {$data.member_name}
+ {if !$data.has_no_profile}</a>{/if}
+
+ </td>
+ <td> <a href="tel:{apply_filters('glm_associate_phone_filter_tel', $data.phone)}">{apply_filters('glm_associate_phone_filter', $data.phone)}</a> </td>
+ <td>
+ <a href="#" class="dashicons dashicons-trash glm-itinerary-request-delete" data-id="{$data.member}" data-baseurl="{$baseurl}" style="float:right;" alt="Remove"></a>
+ </td>
+ </tr>
+ {/foreach}
+ </table>
+{/if}
+
+{if count($membersWithEmails) > 0}
+ <h2>Request Information by Email From:</h2>
+ <p>This list of businesses will receive the following information form directly
+ to their email account.</p>
+ <table>
+ {foreach $membersWithEmails as $data}
+ <tr class="glm-itinerary-request-item">
+ <td>
+ {if !$data.has_no_profile}<a href="{$siteBaseUrl}{$settings.canonical_member_page}/{$data.member_slug}/{if $settings.enable_multiple_profiles}{$data.id}/{/if}">{/if}
+ {$data.member_name}
+ {if !$data.has_no_profile}</a>{/if}
+ </td>
+ <td>
+ <a href="#" class="dashicons dashicons-trash glm-itinerary-request-delete" data-id="{$data.member}" data-baseurl="{$baseurl}" style="float:right;" alt="Remove"></a>
+ </td>
+ </tr>
+ {/foreach}
+ </table>
+
+ {$formContents}
+
+{/if}
+
+
+<script>
+var glm_itinerary_page_url = '{$thisUrl}';
+</script>