Most of the functionality is working now.
Currently:
edit works
delete works
adding contacts
adding notes
adding updating deleting referred by
'create_date' => array(
'field' => 'create_date',
'type' => 'date',
- 'required' => true,
+ 'required' => false,
'use' => 'a',
),
'updated' => array(
'field' => 'updated',
'type' => 'datetime',
- 'required' => true,
+ 'required' => false,
'use' => 'a',
),
'field' => 'referredby',
'type' => 'pointer',
'p_table' => GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'referredby',
- 'p_field' => 'name',
- 'p_orderby' => 'name',
+ 'p_field' => 'id',
+ 'p_orderby' => 'id',
'p_blank' => true,
'required' => true,
'use' => 'a',
.glm-travel-edit {
- max-width: 600px;
+ max-width: 750px;
}
.glm-travel-edit .tsLog {
#addLog textarea {
width: 500px;
}
+.glmCheckBox {
+ display: block;
+ width: 315px;
+ border: 1px solid white;
+ float: left;
+ margin: 0 5px;
+ padding: 2px;
+ position: relative;
+
+}
+.glmCheckBox:hover {
+ border: 1px dashed #CBCBAA;
+ background: #FFFFEF;
+}
+
+.tlSave {
+ text-indent: -1000px;
+ width: 198px;
+ height: 30px;
+ float: right;
+ background-image: url(../assets/tlSave.png);
+ margin-right: 5px;
+ margin-top: 5px;
+}
+
+#change-1, #change-2 {
+ height: 35px;
+ padding: 7px 5px;
+}
+
+p#chg-msg {
+ margin: 0px !important;
+ display: inline;
+}
+/* Travel Leads style framework */
+#travel-admin .tlRounded {
+ border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ }
+#travel-admin .tlShadow {
+ -moz-box-shadow:inset 0 0 7px #fff,1px 1px 7px rgba(153, 153, 153, 0.2);
+ -webkit-box-shadow:inset 0 0 7px #fff,1px 1px 7px rgba(153, 153, 153, 0.2);
+ box-shadow:inset 0 0 7px #fff,1px 1px 7px rgba(153, 153, 153, 0.2);
+ }
+#travel-admin .tlBorder {
+ border: 1px solid #999;
+ }
+#travel-admin .tlTrans1 {
+ background: #fff;
+ background: rgba(255, 255, 255, .9);
+ }
+#travel-wrapper {
+ padding: 25px;
+ width: 720px;
+ min-height: 400px;
+ background: rgba(255, 255, 255, .7);
+ }
+ /* main page fieldsets */
+#fieldsets {
+ height: 1%;
+ overflow: hidden;
+ }
+#travel-admin fieldset {
+ display: block;
+ float: left;
+ margin-right: 20px;
+ height: 9em;
+ padding: 10px;
+ }
+#travel-admin fieldset:last-child {
+ margin-right: 0;
+ }
+#travel-admin fieldset p {
+ font-weight: bold;
+ font-family: Georgia, arial, sans-serif;
+ font-size: 16px;
+ font-size: 1.2rem;
+ margin: 0.5em 0;
+ }
+#findLeads div {
+ margin: 0 0 10px 0;
+ }
+#findLeads label {
+ width: 100px;
+ display: block;
+ float: left;
+ line-height: 30px;
+ }
+#travel-admin fieldset form input {
+ height: 28px;
+ padding: 0;
+ margin: 0;
+ border-width: 1px;
+ font-size: 14px;
+ font-size: 1.0rem;
+ display: block;
+ width: 99%;
+ }
+/* Buttons */
+#travel-admin .button {
+ width: 198px;
+ height: 30px;
+ text-indent: -9000px;
+ display: block;
+ cursor: pointer;
+ margin-top: 10px;
+ border-right: 1px solid #aaa;
+ border-bottom: 1px solid #aaa;
+ border-left: 1px solid #eee;
+ border-top: 1px solid #eee;
+ }
+#travel-admin .button:hover {
+ border-right: 1px solid #888;
+ border-bottom: 1px solid #888;
+ border-left: 1px solid #ccc;
+ border-top: 1px solid #ccc;
+ }
+/* Save Button */
+#travel-admin .tlSave {
+ float: right;
+ background-image: url(../assets/tlSave.png);
+ margin-right: 5px;
+ margin-top: -5px;
+ }
+#travel-admin fieldset form #leadCompanySearch {
+ background-image: url(../assets/goCompany.png);
+ }
+#travel-admin fieldset form #leadContactSearch {
+ background-image: url(../assets/goContact.png);
+ }
+#travelToList {
+ background-image: url(../assets/travelToList.png);
+ }
+#newLead {
+ background-image: url(../assets/newLead.png);
+ }
+/* Pagination */
+
+#travel-admin .paging {
+ display: block;
+ }
+#travel-admin .paging,
+#travel-admin .business-first-letter {
+ clear: both;
+ margin: 1em 0;
+ padding: 1em 0 0 0;
+ height: 1%;
+ overflow: hidden;
+ margin-left: 2px;
+ }
+#travel-admin .business-first-letter {
+ margin-bottom: 1em;
+ border-bottom: 1px dotted #369;
+ padding-bottom: 1em;
+ }
+#travel-admin .paging b,
+#travel-admin .business-first-letter a.curr {
+ padding: 0.2em 0.4em;
+ background: #eee;
+ border: 1px solid #9AAFE5;
+ margin-left: 0.2em;
+ display: block;
+ float: left;
+ }
+#travel-admin .paging a,
+#travel-admin .business-first-letter a {
+ margin-left: 0.2em;
+ color: #036;
+ padding: 0.2em 0.4em;
+ border: 1px solid #9AAFE5;
+ text-decoration: none;
+ background: white;
+ display: block;
+ float: left;
+ }
+#travel-admin .paging a:hover,
+#travel-admin .business-first-letter a:hover {
+ border: 1px solid #2e8d32;
+ background: #eee;
+ }
+/* Table Grid */
+#dataGrid {
+ margin: 0.5em 0 1em 0;
+ background: rgba(255, 255, 255, 0.0);
+ }
+#dataGrid, #dataGrid tr, #dataGrid th, #dataGrid td {
+ border: 1px solid #999;
+ border-collapse: collapse;
+ }
+#dataGrid th, #dataGrid td {
+ padding: 10px 20px;
+ }
+#dataGrid th {
+ background: #fff;
+ }
+#dataGrid tr:nth-child(even) {
+ background: rgba(231, 231, 231, .9);
+ }
+#dataGrid tr:nth-child(odd) {
+ background: rgba(248, 248, 248, .9);;
+ }
+#dataGrid tr:hover {
+ background: #fff;
+ cursor: pointer;
+ }
+#dataGrid a {
+ text-decoration: none;
+ color: black;
+ }
+#dataGrid th a {
+ text-decoration: underline;
+ font-family: Georgia, arial, sans-serif;
+ white-space: nowrap;
+ }
+/* Breadcrumbs */
+#breadcrumbs {
+ background: white;
+ color: #000;
+ padding: 10px 15px;
+ margin-bottom: 1em;
+ max-width: 700px;
+ }
+#breadcrumbs i {
+ font-weight: bold;
+ font-style: normal;
+ }
+#lead-delete {
+ float: right;
+ margin-top: 10px;
+ }
+#lead-delete a {
+ margin: 5px;
+ background: red;
+ background: rgba(204, 0, 0, .4);
+ padding: 5px;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ color: white;
+ text-shadow: 1px 1px 1px #888;
+ text-decoration: none;
+ }
+#lead-delete a:hover {
+ background: red;
+ background: rgba(204, 0, 0, 1.0);
+}
+/* Overriding Form Framework */
+div.webform td {
+ font-size: 13px !important;
+ font-size: 1.3rem !important;
+ }
+div.webform table, div.webform td {
+ border: 1px solid #aaa !important;
+ }
+/* Overriding JqueryUI */
+/* #travel-admin .ui-state-highlight { */
+/* margin-bottom: .5em; */
+/* padding: 15px; */
+/* } */
+/* #travel-admin .ui-state-highlight p { */
+/* margin: 0; */
+/* } */
+/* #travel-admin .ui-icon { */
+/* float: left; */
+/* margin-right: .3em; */
+/* display: block; */
+/* } */
+/* #tabs li a { */
+/* font-size: 13px; */
+/* font-size: 1.3rem; */
+/* } */
+#travel-admin .tsLog {
+ margin: 10px 0;
+ border-top: 1px dotted #369;
+ border: 1px solid #eee;
+ height: 1%;
+ overflow: hidden;
+ }
+#travel-admin .tsLog h2 {
+ font-family: Georgia, arial, sans-serif;
+ font-size: 16px;
+ font-size: 1.6rem;
+ padding: 5px 10px;
+ background: #eee;
+ font-weight: normal;
+ margin: 0 0 1em 0 ;
+ }
+#travel-admin .tsLog p {
+ margin: 0 10px;
+ }
+#travel-admin .tlDelete {
+ display: block;
+ float: right;
+ width: 16px;
+ height: 16px;
+ background: url(../assets/cancel.png) no-repeat;
+ text-indent: -9000px;
+ margin: 10px;
+ }
+#travel-list {
+ max-width: 800px;
+}
$return = false;
$success = true;
- $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING );
+ $option = isset( $_REQUEST['option'] ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+ $lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT );
+
switch ( $option ) {
+ case 'delete':
+ if ( isset( $_REQUEST['contact_id'] ) && $lead_id
+ && $contact_id = filter_var( $_REQUEST['contact_id'], FILTER_VALIDATE_INT )
+ ) {
+ $this->wpdb->delete(
+ GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_contacts',
+ array( 'lead' => $lead_id, 'id' => $contact_id ),
+ array( '%d', '%d' )
+ );
+ }
+ // Redirect back to the edit page
+ wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-id-3' );
+ exit;
+ break;
+ case 'add':
+ // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+ $this->wpdb->insert(
+ GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_contacts',
+ array(
+ 'updated' => date( 'Y-m-d H:i:s' ),
+ 'lead' => $lead_id,
+ 'name' => filter_var( $_REQUEST['name'] ),
+ 'email' => filter_var( $_REQUEST['email'] ),
+ 'phone' => filter_var( $_REQUEST['phone'] ),
+
+ ),
+ array(
+ '%s', // updated
+ '%d', // lead
+ '%s', // name
+ '%s', // email
+ '%s', // phone
+ )
+ );
+ // Redirect back to the edit page
+ wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-id-3' );
+ exit;
+ break;
case 'list':
default:
- $lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT );
- $return = $this->getList( "T.lead = $lead_id" );
+ $contacts = $this->getList( "T.lead = $lead_id" );
+ // echo '<pre>$contacts: ' . print_r( $contacts, true ) . '</pre>';
$view = 'list.html';
break;
// Compile template data
$templateData = array(
- 'data' => $return,
+ 'lead_id' => $lead_id,
+ 'contacts' => $contacts,
);
// Return status, suggested view, and data to controller
switch ( $option ) {
case 'add':
- if ( isset( $_REQUEST['id'] )
- && isset( $_REQUEST['new_log'] )
- && $lead_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT )
+ $lead_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT );
+ if ( isset( $_REQUEST['new_log'] ) && $lead_id
&& $new_note = filter_var( $_REQUEST['new_log'], FILTER_SANITIZE_STRING )
) {
}
// Redirect back to the edit page
- wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-tabs-3' );
+ wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-id-7' );
exit;
break;
case 'delete':
) {
$this->wpdb->delete(
GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes',
- array( 'lead' => $lead_id, 'id' => $note_id ),
+ array( 'lead' => $lead_id, 'id' => $note_id ),
array( '%d', '%d' )
);
}
// Redirect back to the edit page
- wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-tabs-3' );
+ wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-id-7' );
exit;
break;
case 'list':
default:
$lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT );
$notes = $this->getList( "T.lead = $lead_id", "T.created DESC" );
+ // echo '<pre>$notes: ' . print_r( $notes, true ) . '</pre>';
$view = 'list.html';
break;
// Load Members data abstract
require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataReferredBy.php';
-require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataLeadReferredBy.php';
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataLeadsReferredBy.php';
/**
* This class performs the work of handling images passed to it via
* an AJAX call that goes through the WorPress AJAX Handler.
*
*/
-class GlmMembersAdmin_ajax_travelReferredBy // extends GlmDataReferredBy
+class GlmMembersAdmin_ajax_travelReferredBy extends GlmDataReferredBy
{
/**
$this->config = $config;
// Run constructor for data class
- // parent::__construct(false, false);
+ parent::__construct(false, false);
}
*/
public function modelAction( $actionData = false )
{
- $return = false;
- $success = true;
+ $return = false;
+ $success = true;
+ $refs = false;
+ $referredby = false;
$option = isset($_REQUEST['option']) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
switch ( $option ) {
- case 'add':
- if ( isset( $_REQUEST['id'] )
- && isset( $_REQUEST['new_log'] )
- && $lead_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT )
- && $new_note = filter_var( $_REQUEST['new_log'], FILTER_SANITIZE_STRING )
- ) {
-
- $this->wpdb->insert(
- GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes',
- array(
- 'lead' => $lead_id,
- 'created' => date( 'Y-m-d H:i:s' ),
- 'updated' => date( 'Y-m-d H:i:s' ),
- 'notes' => $new_note
- ),
- array(
- '%d',
- '%s',
- '%s',
- '%s'
- )
- );
+ case 'update':
+ if ( isset( $_REQUEST['id'] ) && $lead_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
+ $LeadReferredBy = new GlmDataTravelLeadsReferredBy( $this->wpdb, $this->config );
+ $leadReferredByData = $LeadReferredBy->getList( "T.lead = $lead_id" );
+ if ( $leadReferredByData ) {
+ foreach ( $leadReferredByData as $leadRef ) {
+ $refs[$leadRef['referredby']] = true;
+ }
+ }
+ $update_refs = is_array( $_REQUEST['referredby'] ) ? array_keys( $_REQUEST['referredby'] ) : array();
+ $current_refs = is_array( $refs ) ? array_keys( $refs ) : array();
+ // check with array_diff
+ $diff_delete = array_diff( $current_refs, $update_refs );
+ $diff_insert = array_diff( $update_refs, $current_refs );
+ // Update the leads referred by
+ if ( $diff_delete ) {
+ foreach ( $diff_delete as $delete_ref ) {
+ $this->wpdb->delete(
+ GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'leads_referredby',
+ array( 'lead' => $lead_id, 'referredby' => $delete_ref ),
+ array( '%d', '%d' )
+ );
+ }
+ }
+ if ( $diff_insert ) {
+ foreach ( $diff_insert as $redId ) {
+ $this->wpdb->replace(
+ GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'leads_referredby',
+ array(
+ 'lead' => $lead_id,
+ 'referredby' => $redId
+ ),
+ array(
+ '%d',
+ '%d'
+ )
+ );
+ }
+ }
}
- // Redirect back to the edit page
- wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-tabs-3' );
- exit;
- break;
- case 'delete':
- if ( isset( $_REQUEST['id'] )
- && isset( $_REQUEST['note_id'] )
- && $lead_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT )
- && $note_id = filter_var( $_REQUEST['note_id'], FILTER_VALIDATE_INT )
- ) {
- $this->wpdb->delete(
- GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes',
- array( 'lead' => $lead_id, 'id' => $note_id ),
- array( '%d', '%d' )
- );
- }
- // Redirect back to the edit page
- wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-tabs-3' );
+ wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-id-5' );
exit;
break;
case 'list':
default:
$lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT );
- // $allReferredBy = $this->getList();
- // $leadReferredBy = $this->getList( 'T.' );
+ $allReferredBy = $this->getList();
+ // echo '<pre>$allReferredBy: ' . print_r( $allReferredBy, true ) . '</pre>';
+ $LeadReferredBy = new GlmDataTravelLeadsReferredBy( $this->wpdb, $this->config );
+ $leadReferredByData = $LeadReferredBy->getList( "T.lead = $lead_id" );
+ if ( $leadReferredByData ) {
+ foreach ( $leadReferredByData as $leadRef ) {
+ $refs[$leadRef['referredby']] = true;
+ }
+ }
$view = 'list.html';
break;
// Compile template data
$templateData = array(
- 'lead_id' => $lead_id,
- 'notes' => $notes,
- 'editPage' => 'glm-members-admin-menu-glm-travel',
+ 'lead_id' => $lead_id,
+ 'referredby' => $allReferredBy,
+ 'refs' => $refs,
+ 'editPage' => 'glm-members-admin-menu-glm-travel',
);
// Return status, suggested view, and data to controller
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Members data abstract
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataContacts.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_travelSearch // extends GlmDataTravelContacts
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This constructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Run constructor for data class
+ // parent::__construct(false, false);
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This model checks to see if the credentials passed in are correct.
+ *
+ * This model action does not return, it simply does it's work then calls die();
+ *
+ * @param $actionData
+ *
+ * Output JSON string as response and does not return
+ */
+ public function modelAction( $actionData = false )
+ {
+ $return = false;
+ $success = true;
+ $return = array();
+
+ $option = isset( $_REQUEST['option'] ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
+ $term = isset( $_REQUEST['term'] ) ? filter_var( $_REQUEST['term'], FILTER_SANITIZE_STRING ) : '';
+ trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+
+ switch ( $option ) {
+ case 'company':
+ $return = $this->wpdb->get_results(
+ $this->wpdb->prepare(
+ "SELECT distinct( company ) as company,company as id,company as value, company as label
+ FROM " . GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . "leads
+ WHERE company like %s",
+ '%'.$term.'%'
+ ),
+ ARRAY_A
+ );
+ break;
+ case 'contact':
+ $return = $this->wpdb->get_results(
+ $this->wpdb->prepare(
+ "SELECT distinct( id ),CONCAT( fname, ' ', lname ) as id,CONCAT( fname, ' ', lname ) as value, CONCAT( fname, ' ', lname ) as label
+ FROM " . GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . "leads
+ WHERE CONCAT( fname, ' ', lname ) like %s",
+ '%'.$term.'%'
+ ),
+ ARRAY_A
+ );
+ break;
+ default:
+ break;
+ }
+
+ header('Content-type:application/json;charset=utf-8', true);
+ echo json_encode( $return );
+
+ exit;
+ }
+}
$sources = false;
$entry = false;
$hasSearch = false;
+ $tab = 0;
// Get any provided option
if ( isset( $_REQUEST['option'] ) ) {
$option = $_REQUEST['option'];
}
- if ( isset( $_REQUEST['glm_action'] ) && $_REQUEST['glm_action'] === 'csvExport' ) {
- $search = true;
- $option = 'csv';
- }
-
// Get entry ID if supplied
if (isset($_REQUEST['id'])) {
}
}
- if ( isset( $this->config['loggedInUser']['contactUser'] ) && empty( $this->config['loggedInUser']['contactUser'] ) ) {
- $user_can_edit_leads = true;
- }
-
- if ( ( isset( $search ) && $search ) || isset( $search_params ) && $search_params ) {
+ if ( ( isset( $search ) && $search ) ) {
if ( isset( $search ) && $search ) {
$searching = true;
}
// Filter the $_POST variables from the search form.
// Verify mm/dd/YYYY date format for the from and to dates.
- if ( !isset( $search_params ) ) {
- $search_params = filter_var_array(
- $_POST,
- array(
- 'source_id' => FILTER_VALIDATE_INT,
- 'company' => FILTER_SANITIZE_STRING,
- 'contact' => FILTER_SANITIZE_STRING,
- 'from_date' => array(
- 'filter' => FILTER_VALIDATE_REGEXP,
- 'options' => array(
- 'regexp' => '%([0-9]{2})/([0-9]{2})/([0-9]{4})%'
- )
- ),
- 'to_date' => array(
- 'filter' => FILTER_VALIDATE_REGEXP,
- 'options' => array(
- 'regexp' => '%([0-9]{2})/([0-9]{2})/([0-9]{4})%'
- )
- ),
- 'mail_ok' => FILTER_VALIDATE_BOOLEAN,
- 'member_ok' => FILTER_VALIDATE_BOOLEAN,
- 'interests' => array(
- 'filter' => FILTER_VALIDATE_BOOLEAN,
- 'flags' => FILTER_FORCE_ARRAY
- )
- )
- );
- }
- // checking the booleans for empty or false
- if ( isset( $_REQUEST['mail_ok'] ) && $_REQUEST['mail_ok'] === '0' ) {
- $search_params['mail_ok'] = (int)0;
- }
- if ( isset( $_REQUEST['member_ok'] ) && $_REQUEST['member_ok'] === '0' ) {
- $search_params['member_ok'] = (int)0;
- }
-
+ $search_params = filter_var_array(
+ $_REQUEST,
+ array(
+ 'company' => FILTER_SANITIZE_STRING,
+ 'contact' => FILTER_SANITIZE_STRING,
+ )
+ );
// build the $where part
$where_parts = array();
- if ( isset( $search_params['member_ok'] ) && $search_params['member_ok'] !== false ) {
- $member_ok = ( $search_params['member_ok'] === true ) ? 'true' : 'false';
- $where_parts[] = "T.lead_id IN (
- SELECT id
- FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads
- WHERE member_ok = $member_ok)";
- }
- if ( isset( $search_params['mail_ok'] ) && $search_params['mail_ok'] !== false ) {
- $mail_ok = ( $search_params['mail_ok'] === true ) ? 'true' : 'false';
- $where_parts[] = "T.lead_id IN (
- SELECT id
- FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads
- WHERE mail_ok = $mail_ok)";
- }
- if ( isset( $this->config['loggedInUser']['contactUser'] ) && !empty( $this->config['loggedInUser']['contactUser'] ) ) {
- $where_parts[] = "T.lead_id IN (
- SELECT id
- FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads
- WHERE member_ok = true)";
- } else {
- $user_can_edit_leads = true;
- }
- if ( $search_params['source_id'] ) {
- $where_parts[] = "source_id = {$search_params['source_id']}";
- }
+ // echo '<pre>$search_params: ' . print_r( $search_params, true ) . '</pre>';
if ( $search_params['company'] ) {
- $where_parts[] = "org = '" . esc_sql( $search_params['company'] ) . "'";
+ $where_parts[] = "T.company like '%" . esc_sql( $search_params['company'] ) . "%'";
}
if ( $search_params['contact'] ) {
// Search for name.
$name_parts[] = "SOUNDEX(lname) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')";
$where_parts[] = implode( ' OR ', $name_parts );
}
- if ( $search_params['interests'] ) {
- /*
- * Search for the interest.
- * Checks the tables for lead_interests.
- */
- // $where_parts[] = " T.id IN (
- // SELECT lead_entry_id
- // FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_interests
- // WHERE interest_id IN ( " . implode( ", ", array_keys( $search_params['interests'] ) ) . " ) ) ";
- }
- if ( $search_params['from_date'] && $search_params['to_date'] ) {
- /*
- * We get a date from the form in mm/dd/YYYY format.
- * Here in mysql we reformat the date using STR_TO_DATE function.
- */
- $where_parts[] = "T.date_submitted BETWEEN STR_TO_DATE('{$search_params['from_date']}', '%m/%d/%Y') "
- . "AND STR_TO_DATE('{$search_params['to_date']}', '%m/%d/%Y')";
- } else if ( $search_params['from_date'] ) {
- $where_parts[] = "T.date_submitted >= STR_TO_DATE('{$search_params['from_date']}', '%m/%d/%Y')";
- } else if ( $search_params['to_date'] ) {
- $where_parts[] = "T.date_submitted <= STR_TO_DATE('{$search_params['to_date']}', '%m/%d/%Y')";
- }
- if ( ( isset( $search ) && $search ) || $searching ) {
- if ( isset( $where_parts ) && !empty( $where_parts ) ) {
- $where .= ' AND ' . implode( ' AND ', $where_parts );
- }
- $order = "T.lname, T.fname";
-
- // Check if we're doing paging
- if (isset($_REQUEST['pageSelect'])) {
-
- // If request is for Next
- if ( isset( $_REQUEST['pageSelect'][0] ) && $_REQUEST['pageSelect'][0] == 'N') {
- $newStart = $_REQUEST['nextStart'] - 0;
-
- // Otherwise it must be Previous
- } else {
- $newStart = $_REQUEST['prevStart'] - 0;
- }
-
- if ($newStart > 0) {
- $start = $newStart;
- }
- }
-
- // Get count of members listed
- $leadCount = $this->getStats($where);
-
- // If the number of members is less than a page, don't do paging
- if ($leadCount <= $limit) {
- $paging = false;
- }
-
-
- switch ( $option ) {
- case 'csv':
- // $sql = "
- // SELECT T.*,L.email
- // FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_entry T,
- // " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads L
- // WHERE $where
- // AND T.lead_id = L.id
- // ORDER BY $order";
- $leads = $this->wpdb->get_results( $sql, ARRAY_A );
- break;
- default:
- $listResult = $this->getSimpleEntriesList( $where, $order, true, 'id', $start, $limit );
- // Get paging results
- $numbDisplayed = $listResult['returned'];
- $lastDisplayed = $listResult['last'];
- if ($start == 1) {
- $prevStart = false;
- } else {
- $prevStart = $start - $limit;
- if ($start < 1) {
- $start = 1;
- }
- }
- if ($listResult['returned'] == $limit) {
- $nextStart = $start + $limit;
- }
-
- // since we're doing paging, we have to break out just the member data
- $leads = $listResult['list'];
- //echo '<pre>$leads: ' . print_r( $leads, true ) . '</pre>';
- //exit;
- unset($listResult);
-
- // If we have list entries - even if it's an empty list
- break;
- }
- $success = true;
- $haveLeads = false;
- if ($leads !== false) {
- $success = true;
-
- // If we have any entries
- if (count($leads) > 0) {
- $haveLeads = true;
- }
- }
-
-
-
- } else {
- $leads = false;
- }
- } else {
- $leads = '';
- $search_params = array(
- 'mail_ok' => null,
- 'member_ok' => null,
- 'company' => '',
- 'contact' => '',
- 'from_date' => '',
- 'to_date' => '',
- 'interests' => array(),
- );
}
// Initialize the interests array
if ( $this->config['loggedInUser']['contactUser'] ) {
break;
}
+ $_REQUEST['updated'] = date( 'Y-m-d H:i:s' );
$entry = $this->updateEntry( $this->entryId );
- $view = 'index.html';
+ // echo '<pre>$entry: ' . print_r( $entry, true ) . '</pre>';
+ // $view = 'index.html';
+ $entry = $this->editEntry( $this->entryId );
+ $view = 'edit.html';
break;
break;
default:
+ if ( ( isset( $search ) && $search ) || $searching ) {
+ // echo '<pre>$where_parts: ' . print_r( $where_parts, true ) . '</pre>';
+ if ( isset( $where_parts ) && !empty( $where_parts ) ) {
+ $where .= ' AND ' . implode( ' AND ', $where_parts );
+ }
+ $order = "T.lname, T.fname";
+ }
- $entry = $this->getList();
-
- // echo '<pre>$entry: ' . print_r( $entry, true ) . '</pre>';
+ $entry = $this->getList( $where );
$view = 'index.html';
'ajax' => array(
'travelContacts' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
'travelReferredby' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'travelSearch' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
'travelNotes' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
),
'settings' => array(
+<div id="ui-tabs-1">
+ <form action="{$ajaxUrl}">
+ <input type="hidden" name="action" value="glm_members_admin_ajax" />
+ <input type="hidden" name="glm_action" value="travelContacts" />
+ <input type="hidden" name="lead_id" value="{$lead_id}" />
+ <input type="hidden" name="option" value="add" />
+ <fieldset>
+ <legend>Add New Contact</legend>
+ <label>
+ Name <input type="text" name="name" value="">
+ </label>
+ <label>
+ Phone <input type="tel" name="phone" value="">
+ </label>
+ <label>
+ Email <input type="email" name="email" value="">
+ </label>
+ <input class="button" type="submit" value="Add Contact" >
+ </fieldset>
+ </form>
-<form action="{$ajaxUrl}">
- <fieldset>
- <legend>Add New Contact</legend>
- <label>
- Name <input type="text" name="name" value="">
- </label>
- <label>
- Phone <input type="tel" name="phone" value="">
- </label>
- <label>
- Email <input type="email" name="email" value="">
- </label>
- <input class="button" type="submit" value="Add Contact" >
- </fieldset>
-</form>
+ {* List of contacts *}
+ <table width="100%" class="wp-list-table striped glm-admin-table-single">
+ <thead>
+ <th> Name </th>
+ <th> Phone </th>
+ <th> Email </th>
+ <th></th>
+ </thead>
+ <tbody>
+ {if $contacts}
+ {foreach $contacts as $c}
+ <tr {if $c@iteration is div by 2}class="alternate"{/if}>
+ <td>{$c.name}</td>
+ <td>{$c.phone}</td>
+ <td>{$c.email}</td>
+ <td>
+ <a class="tlDelete" href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelContacts&option=delete&lead_id={$lead_id}&contact_id={$c.id}" title="Delete this entry">Delete</a>
+ </td>
+ </tr>
+ {/foreach}
+ {/if}
+ </tbody>
+ </table>
+</div>
<input type="submit" class="button" value="New Note Entry" />
</form>
- {foreach $notes as $n}
- <div class="tsLog">
- <h2>{$n.updated.datetime}</h2>
- <p>{$n.notes|nl2br}</p>
- <a class="tlDelete" href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelNotes&option=delete&id={$lead_id}¬e_id={$n.id}" title="Delete this entry">Delete</a>
- </div>
- {/foreach}
+ {if $notes}
+ {foreach $notes as $n}
+ <div class="tsLog">
+ <h2>{$n.updated.datetime}</h2>
+ <p>{$n.notes|nl2br}</p>
+ <a class="tlDelete" href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelNotes&option=delete&id={$lead_id}¬e_id={$n.id}" title="Delete this entry">Delete</a>
+ </div>
+ {/foreach}
+ {/if}
</div>
--- /dev/null
+<div id="ui-tabs-2">
+ <form id="edit_interest" action="{$ajaxUrl}">
+ <input type="hidden" name="action" value="glm_members_admin_ajax" />
+ <input type="hidden" name="glm_action" value="travelReferredby" />
+ <input type="hidden" name="id" value="{$lead_id}" />
+ <input type="hidden" name="option" value="update" />
+
+
+ <div style="display:none;" id="change-2" class="ui-state-highlight ui-corner-all">
+ <span class="ui-icon ui-icon-info"></span>
+ <a id="submitInterestForm" class="tlSave">Save</a>
+ <p id="chg-msg"> Changes not saved yet. </p>
+ </div>
+
+ <table>
+ <tr>
+ <td>Referred By</td>
+ </tr>
+ <tr>
+ <td>
+ {foreach $referredby as $r}
+ <label class="glmCheckBox">
+ <input
+ type="checkbox"
+ name="referredby[{$r.id}]"
+ value="1"
+ {if isset($refs[$r.id]) && $refs[$r.id]}checked{/if} />
+ {$r.name}
+ </label>
+ {/foreach}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input class="button" type="submit" value="Save" />
+ </td>
+ </tr>
+ </table>
+ </form>
+</div>
+<script>
+ jQuery( function($) {
+ $('#submitInterestForm').click(function(){
+ $("#edit_interest").submit();
+ });
+ $('#edit_interest').each(function(){
+ $(this).keyup(function(){
+ $('#change-2').show();
+ });
+ $(this).change(function(){
+ $('#change-2').show();
+ });
+ });
+ });
+</script>
{include file='admin/travel/header.html'}
<h2>Lead</h2>
-{if isset($lead.fieldData) && isset($lead.fieldData.id)}
-<div id="lead-delete">
- <a
- class="button"
- onclick="return confirm('This will delete this lead and cannot be undone. Are You Sure?');"
- href="{$thisUrl}?page={$thisPage}&glm_action=index&option=delete&id={$lead.fieldData.id}">Delete Contact</a>
-</div>
-{/if}
-
<div id="tabs" class="glm-travel-edit">
+ {if isset($lead.fieldData) && isset($lead.fieldData.id)}
+ <div id="lead-delete" flexy:if="deleteUrl">
+ <a
+ href="{$thisUrl}?page={$thisPage}&glm_action=index&option=delete&id={$lead.fieldData.id}"
+ onClick="return confirm('This will delete this lead!\nAre You Sure?');">Delete {$lead.fieldData.fname} {$lead.fieldData.lname}</a>
+ </div>
+ <div id="breadcrumbs" class="tlShadow tlBorder tlRounded tlTrans1">
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=index">Home</a>
+ >
+ <i>{$lead.fieldData.fname} {$lead.fieldData.lname}</i>
+ </div>
+ {/if}
+
+
<ul>
<li><a href="#tabs-1">Lead</a></li>
{if isset($lead.fieldData) && isset($lead.fieldData.id)}
</ul>
<div id="tabs-1">
- <form action="{$thisUrl}?page={$thisPage}" method="post">
+
+ <form id="edit_lead" action="{$thisUrl}?page={$thisPage}" method="post">
<input type="hidden" name="page" value="{$thisPage}" />
<input type="hidden" name="glm_action" value="index" />
{if isset($lead.fieldData) && isset($lead.fieldData.id)}
<input type="hidden" name="option" value="insert" />
{/if}
+ <div style="display:none;" id="change-1" class="ui-state-highlight ui-corner-all">
+ <span class="ui-icon ui-icon-info"></span>
+ <a id="submitEditForm" class="tlSave">Save</a>
+ <p id="chg-msg"> Changes not saved yet. </p>
+ </div>
+
<table id="glm-table-desc" class="glm-admin-table glm-event-table">
<tr>
}
}
});
+ $('#submitEditForm').click(function(){
+ $("#edit_lead").submit();
+ });
+ $('#edit_lead').each(function(){
+ $(this).keyup(function(){
+ $('#change-1').show();
+ });
+ $(this).change(function(){
+ $('#change-1').show();
+ });
+ });
});
</script>
{include file='admin/travel/searchForm.html'}
-
-<table class="wp-list-table widefat fixed posts glm-admin-table">
- <thead>
- <tr>
- <th width="20"> Edit </th>
- <th> Company </th>
- <th> First Name </th>
- <th> Last Name </th>
- <th> Updated </th>
- <th> Status </th>
- </tr>
- </thead>
- <tbody>
- {foreach $lead as $e}
- <tr>
- <td> <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=edit&id={$e.id}">Edit</a></td>
- <td> {$e.company} </td>
- <td> {$e.fname} </td>
- <td> {$e.lname} </td>
- <td> {$e.updated.datetime} </td>
- <td> {$e.status.name} </td>
- </tr>
- {/foreach}
- </tbody>
-</table>
+{if $lead}
+ <table id="dataGrid" class="dataGrid">
+ <thead>
+ <tr>
+ <th width="20"> Edit </th>
+ <th> Company </th>
+ <th> First Name </th>
+ <th> Last Name </th>
+ <th> Updated </th>
+ <th> Status </th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach $lead as $e}
+ <tr class="{if $c@iteration is div by 2}even{else}odd{/if}">
+ <td> <a class="company_link" href="{$thisUrl}?page={$thisPage}&glm_action=index&option=edit&id={$e.id}">Edit</a></td>
+ <td> {$e.company} </td>
+ <td> {$e.fname} </td>
+ <td> {$e.lname} </td>
+ <td> {$e.updated.datetime} </td>
+ <td> <b>{$e.status.name}</b> </td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+{else}
+ No search results!
+{/if}
{include file='admin/travel/footer.html'}
<a href="leads.php">Home</a> > Search Result
</div>
{/if}
- <div id="fieldsets">
-<fieldset id="findCompany" class="tlRounded tlShadow tlBorder tlTrans1">
- <p>Find Company</p>
- <form name="companyForm" id="">
- <div>
- <input id="company" name="companySearch">
- <input type="submit" value="Go" id="leadCompanySearch" class="button">
- </div>
- </form>
-</fieldset>
-<fieldset class="tlRounded tlShadow tlBorder tlTrans1">
- <p>Find Contact</p>
- <form name="contactForm">
- <div>
- <input id="contact" name="contact">
- <input type="submit" value="Go" id="leadContactSearch" class="button">
- </div>
- </form>
-</fieldset>
-<fieldset class="tlRounded tlShadow tlBorder tlTrans1">
- <p>Quick Links</p>
- <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=add" id="newLead" class="button">New Lead</a>
-</fieldset>
-</div><!-- /#fieldsets -->
+<div id="travel-admin">
+ <div id="fieldsets">
+ <fieldset id="findCompany" class="tlRounded tlShadow tlBorder tlTrans1">
+ <p>Find Company</p>
+ <form name="companyForm" action="{$thisUrl}">
+ <input type="hidden" name="page" value="{$thisPage}" />
+ <input type="hidden" name="glm_action" value="index" />
+ <input type="hidden" name="search" value="1" />
+ <div>
+ <input id="company" name="company">
+ <input type="submit" value="Go" id="leadCompanySearch" class="button">
+ </div>
+ </form>
+ </fieldset>
+ <fieldset class="tlRounded tlShadow tlBorder tlTrans1">
+ <p>Find Contact</p>
+ <form name="contactForm" action="{$thisUrl}">
+ <input type="hidden" name="page" value="{$thisPage}" />
+ <input type="hidden" name="glm_action" value="index" />
+ <input type="hidden" name="search" value="1" />
+ <div>
+ <input id="contact" name="contact">
+ <input type="submit" value="Go" id="leadContactSearch" class="button">
+ </div>
+ </form>
+ </fieldset>
+ <fieldset class="tlRounded tlShadow tlBorder tlTrans1">
+ <p>Quick Links</p>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=add" id="newLead" class="button">New Lead</a>
+ </fieldset>
+ </div><!-- /#fieldsets -->
+</div>
+
+<script>
+jQuery(function($){
+ var cache = {},
+ cache2 = {},
+ lastXhr,
+ lastXhr2;
+ $( "#company" ).autocomplete({
+ minLength: 2,
+ source: function( request, response ) {
+ var term = request.term;
+ if ( term in cache ) {
+ response( cache[ term ] );
+ return;
+ }
+
+ lastXhr = $.getJSON( "{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelSearch&option=company", request, function( data, status, xhr ) {
+ cache[ term ] = data;
+ if ( xhr === lastXhr ) {
+ response( data );
+ }
+ });
+ }
+ });
+ $( "#contact" ).autocomplete({
+ minLength: 2,
+ source: function( request, response ) {
+ var term = request.term;
+ if ( term in cache2 ) {
+ response( cache2[ term ] );
+ return;
+ }
+
+ lastXhr2 = $.getJSON( "{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelSearch&option=contact", request, function( data, status, xhr ) {
+ cache2[ term ] = data;
+ if ( xhr === lastXhr2 ) {
+ response( data );
+ }
+ });
+ }
+ });
+ $('.company_link').each(function(){
+ var editUrl = $(this).attr('href');
+ $(this).parent('td').parent('tr').click(function(){
+ window.location = editUrl;
+ });
+ });
+});
+</script>