From: Steve Sutton Date: Fri, 25 May 2018 19:20:26 +0000 (-0400) Subject: Updating the leads admin side. X-Git-Tag: v1.0.0^2~25 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=18fe4c73aa168d4344643e0a389a8214ffb213a4;p=WP-Plugins%2Fglm-member-db-travel.git Updating the leads admin side. Most of the functionality is working now. Currently: edit works delete works adding contacts adding notes adding updating deleting referred by --- diff --git a/classes/data/dataLeads.php b/classes/data/dataLeads.php index 8aadd80..0875226 100644 --- a/classes/data/dataLeads.php +++ b/classes/data/dataLeads.php @@ -118,14 +118,14 @@ class GlmDataTravelLeads extends GlmDataAbstract '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', ), diff --git a/classes/data/dataLeadsReferredBy.php b/classes/data/dataLeadsReferredBy.php index e4e2b0f..1218f3f 100644 --- a/classes/data/dataLeadsReferredBy.php +++ b/classes/data/dataLeadsReferredBy.php @@ -130,8 +130,8 @@ class GlmDataTravelLeadsReferredBy extends GlmDataAbstract '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', diff --git a/css/admin.css b/css/admin.css index e11a094..28d27bc 100644 --- a/css/admin.css +++ b/css/admin.css @@ -1,5 +1,5 @@ .glm-travel-edit { - max-width: 600px; + max-width: 750px; } .glm-travel-edit .tsLog { @@ -33,3 +33,305 @@ #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; +} diff --git a/models/admin/ajax/travelContacts.php b/models/admin/ajax/travelContacts.php index 9bf197c..419a7c2 100644 --- a/models/admin/ajax/travelContacts.php +++ b/models/admin/ajax/travelContacts.php @@ -78,14 +78,54 @@ class GlmMembersAdmin_ajax_travelContacts extends GlmDataTravelContacts $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 '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + $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 '
$contacts: ' . print_r( $contacts, true ) . '
'; $view = 'list.html'; break; @@ -93,7 +133,8 @@ class GlmMembersAdmin_ajax_travelContacts extends GlmDataTravelContacts // Compile template data $templateData = array( - 'data' => $return, + 'lead_id' => $lead_id, + 'contacts' => $contacts, ); // Return status, suggested view, and data to controller diff --git a/models/admin/ajax/travelNotes.php b/models/admin/ajax/travelNotes.php index 24ac5c0..a31cf55 100644 --- a/models/admin/ajax/travelNotes.php +++ b/models/admin/ajax/travelNotes.php @@ -83,9 +83,8 @@ class GlmMembersAdmin_ajax_travelNotes extends GlmDataTravelNotes 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 ) ) { @@ -107,7 +106,7 @@ class GlmMembersAdmin_ajax_travelNotes extends GlmDataTravelNotes } // 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': @@ -118,18 +117,19 @@ class GlmMembersAdmin_ajax_travelNotes extends GlmDataTravelNotes ) { $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 '
$notes: ' . print_r( $notes, true ) . '
'; $view = 'list.html'; break; diff --git a/models/admin/ajax/travelReferredby.php b/models/admin/ajax/travelReferredby.php index 738ab45..7700459 100644 --- a/models/admin/ajax/travelReferredby.php +++ b/models/admin/ajax/travelReferredby.php @@ -15,14 +15,14 @@ // 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 { /** @@ -59,7 +59,7 @@ class GlmMembersAdmin_ajax_travelReferredBy // extends GlmDataReferredBy $this->config = $config; // Run constructor for data class - // parent::__construct(false, false); + parent::__construct(false, false); } @@ -76,62 +76,71 @@ class GlmMembersAdmin_ajax_travelReferredBy // extends GlmDataReferredBy */ 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 '
$allReferredBy: ' . print_r( $allReferredBy, true ) . '
'; + $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; @@ -139,9 +148,10 @@ class GlmMembersAdmin_ajax_travelReferredBy // extends GlmDataReferredBy // 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 diff --git a/models/admin/ajax/travelSearch.php b/models/admin/ajax/travelSearch.php new file mode 100644 index 0000000..fad50bf --- /dev/null +++ b/models/admin/ajax/travelSearch.php @@ -0,0 +1,118 @@ + + * @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; + } +} diff --git a/models/admin/travel/index.php b/models/admin/travel/index.php index fc0f2f7..2bb55e1 100644 --- a/models/admin/travel/index.php +++ b/models/admin/travel/index.php @@ -108,17 +108,13 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads $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'])) { @@ -142,82 +138,25 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads } } - 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 '
$search_params: ' . print_r( $search_params, true ) . '
'; 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. @@ -234,125 +173,7 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads $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 '
$leads: ' . print_r( $leads, true ) . '
'; - //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 @@ -413,8 +234,12 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads if ( $this->config['loggedInUser']['contactUser'] ) { break; } + $_REQUEST['updated'] = date( 'Y-m-d H:i:s' ); $entry = $this->updateEntry( $this->entryId ); - $view = 'index.html'; + // echo '
$entry: ' . print_r( $entry, true ) . '
'; + // $view = 'index.html'; + $entry = $this->editEntry( $this->entryId ); + $view = 'edit.html'; break; @@ -466,10 +291,15 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads break; default: + if ( ( isset( $search ) && $search ) || $searching ) { + // echo '
$where_parts: ' . print_r( $where_parts, true ) . '
'; + if ( isset( $where_parts ) && !empty( $where_parts ) ) { + $where .= ' AND ' . implode( ' AND ', $where_parts ); + } + $order = "T.lname, T.fname"; + } - $entry = $this->getList(); - - // echo '
$entry: ' . print_r( $entry, true ) . '
'; + $entry = $this->getList( $where ); $view = 'index.html'; diff --git a/setup/validActions.php b/setup/validActions.php index d7e9f17..9b48f69 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -62,6 +62,7 @@ $glmMembersTravelAddOnValidActions = array( '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( diff --git a/views/admin/ajax/contacts/list.html b/views/admin/ajax/contacts/list.html index 5a3487a..92516f2 100644 --- a/views/admin/ajax/contacts/list.html +++ b/views/admin/ajax/contacts/list.html @@ -1,16 +1,45 @@ +
+
+ + + + +
+ Add New Contact + + + + +
+
-
-
- Add New Contact - - - - -
-
+ {* List of contacts *} + + + + + + + + + {if $contacts} + {foreach $contacts as $c} + + + + + + + {/foreach} + {/if} + +
Name Phone Email
{$c.name}{$c.phone}{$c.email} + Delete +
+
diff --git a/views/admin/ajax/notes/list.html b/views/admin/ajax/notes/list.html index 15a56e2..d5b9bc8 100644 --- a/views/admin/ajax/notes/list.html +++ b/views/admin/ajax/notes/list.html @@ -8,11 +8,13 @@ - {foreach $notes as $n} -
-

{$n.updated.datetime}

-

{$n.notes|nl2br}

- Delete -
- {/foreach} + {if $notes} + {foreach $notes as $n} +
+

{$n.updated.datetime}

+

{$n.notes|nl2br}

+ Delete +
+ {/foreach} + {/if} diff --git a/views/admin/ajax/referredby/list.html b/views/admin/ajax/referredby/list.html new file mode 100644 index 0000000..5e41481 --- /dev/null +++ b/views/admin/ajax/referredby/list.html @@ -0,0 +1,55 @@ +
+
+ + + + + + + + + + + + + + + + + + +
Referred By
+ {foreach $referredby as $r} + + {/foreach} +
+ +
+
+
+ diff --git a/views/admin/travel/edit.html b/views/admin/travel/edit.html index 022a8b7..fc30e8a 100644 --- a/views/admin/travel/edit.html +++ b/views/admin/travel/edit.html @@ -1,17 +1,22 @@ {include file='admin/travel/header.html'}

Lead

-{if isset($lead.fieldData) && isset($lead.fieldData.id)} -
- Delete Contact -
-{/if} -
+ {if isset($lead.fieldData) && isset($lead.fieldData.id)} + + + {/if} + +
-
+ + {if isset($lead.fieldData) && isset($lead.fieldData.id)} @@ -32,6 +38,12 @@ {/if} + + @@ -171,6 +183,17 @@ } } }); + $('#submitEditForm').click(function(){ + $("#edit_lead").submit(); + }); + $('#edit_lead').each(function(){ + $(this).keyup(function(){ + $('#change-1').show(); + }); + $(this).change(function(){ + $('#change-1').show(); + }); + }); }); diff --git a/views/admin/travel/index.html b/views/admin/travel/index.html index fd3a043..aedc873 100644 --- a/views/admin/travel/index.html +++ b/views/admin/travel/index.html @@ -2,30 +2,33 @@ {include file='admin/travel/searchForm.html'} - -
- - - - - - - - - - - - {foreach $lead as $e} - - - - - - - - - {/foreach} - -
Edit Company First Name Last Name Updated Status
Edit {$e.company} {$e.fname} {$e.lname} {$e.updated.datetime} {$e.status.name}
+{if $lead} + + + + + + + + + + + + + {foreach $lead as $e} + + + + + + + + + {/foreach} + +
Edit Company First Name Last Name Updated Status
Edit {$e.company} {$e.fname} {$e.lname} {$e.updated.datetime} {$e.status.name}
+{else} + No search results! +{/if} {include file='admin/travel/footer.html'} diff --git a/views/admin/travel/searchForm.html b/views/admin/travel/searchForm.html index cbfd15d..410fba4 100644 --- a/views/admin/travel/searchForm.html +++ b/views/admin/travel/searchForm.html @@ -3,28 +3,85 @@ Home > Search Result
{/if} -
-
-

Find Company

- -
- - -
- -
-
-

Find Contact

-
-
- - -
-
-
-
-

Quick Links

- New Lead -
-
+
+
+
+

Find Company

+
+ + + +
+ + +
+
+
+
+

Find Contact

+
+ + + +
+ + +
+
+
+
+

Quick Links

+ New Lead +
+
+
+ +