From: Steve Sutton Date: Tue, 29 May 2018 20:55:17 +0000 (-0400) Subject: WIP work on searching and member leads section. X-Git-Tag: v1.0.0^2~22 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=465b598cdf534a9fd4d74466b899db68360686e4;p=WP-Plugins%2Fglm-member-db-travel.git WIP work on searching and member leads section. Adding member travel leads section with their search form. working on saving page with admin search. --- diff --git a/css/admin.css b/css/admin.css index 5b4ab2b..690a4cc 100644 --- a/css/admin.css +++ b/css/admin.css @@ -3,31 +3,31 @@ } .glm-travel-edit .tsLog { - margin: 10px 0; - border-top: 1px dotted #369; - border: 1px solid #eee; - height: 1%; - overflow: hidden; + margin: 10px 0; + border-top: 1px dotted #369; + border: 1px solid #eee; + height: 1%; + overflow: hidden; } .glm-travel-edit .tsLog h2 { - font-family: Georgia, arial, sans-serif; - font-size: 16px; - padding: 5px 10px; - background: #eee; - font-weight: normal; - margin: 0 0 1em 0 ; + font-family: Georgia, arial, sans-serif; + font-size: 16px; + padding: 5px 10px; + background: #eee; + font-weight: normal; + margin: 0 0 1em 0 ; } .glm-travel-edit .tsLog p { - margin: 0 10px; + margin: 0 10px; } .glm-travel-edit .tlDelete { - display: block; - float: right; - width: 16px; - height: 16px; - background: url(../assets/cancel.png) no-repeat; - text-indent: -9000px; - margin: 10px; + display: block; + float: right; + width: 16px; + height: 16px; + background: url(../assets/cancel.png) no-repeat; + text-indent: -9000px; + margin: 10px; } #addLog textarea { @@ -52,10 +52,10 @@ text-indent: -1000px; width: 198px; height: 30px; - float: right; - background-image: url(../assets/tlSave.png); - margin-right: 5px; - margin-top: 5px; + float: right; + background-image: url(../assets/tlSave.png); + margin-right: 5px; + margin-top: 5px; } #change-1, #change-2 { @@ -69,269 +69,296 @@ p#chg-msg { } /* Travel Leads style framework */ #travel-admin .tlRounded { - border-radius: 5px; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - } + 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); - } + -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; - } + border: 1px solid #999; + } #travel-admin .tlTrans1 { - background: #fff; - background: rgba(255, 255, 255, .9); - } + background: #fff; + background: rgba(255, 255, 255, .9); + } #travel-wrapper { - padding: 25px; - width: 720px; + padding: 25px; + width: 720px; min-height: 400px; - background: rgba(255, 255, 255, .7); - } - /* main page fieldsets */ + background: rgba(255, 255, 255, .7); + } + /* main page fieldsets */ #fieldsets { - height: 1%; - overflow: hidden; - } + height: 1%; + overflow: hidden; + } #travel-admin fieldset { - display: block; - float: left; - margin-right: 20px; - height: 9em; + display: block; + float: left; + margin-right: 20px; + height: 9em; padding: 10px; - } + } #travel-admin fieldset:last-child { - margin-right: 0; - } + 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; - } + 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; - } + margin: 0 0 10px 0; + } #findLeads label { - width: 100px; - display: block; - float: left; - line-height: 30px; - } + 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%; - } + 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; - } + 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; - } + 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; - } + 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); - } + background-image: url(../assets/goCompany.png); + } #travel-admin fieldset form #leadContactSearch { - background-image: url(../assets/goContact.png); - } + background-image: url(../assets/goContact.png); + } #travelToList { - background-image: url(../assets/travelToList.png); - } + background-image: url(../assets/travelToList.png); + } #newLead { - background-image: url(../assets/newLead.png); - } + background-image: url(../assets/newLead.png); + } /* Pagination */ #travel-admin .paging { - display: block; - } + 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; - } + 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; - } + 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; - } + 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; - } + 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; - } + border: 1px solid #2e8d32; + background: #eee; + } /* Table Grid */ #dataGrid { - margin: 0.5em 0 1em 0; - background: rgba(255, 255, 255, 0.0); - } + 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; - } + border: 1px solid #999; + border-collapse: collapse; + } #dataGrid th, #dataGrid td { - padding: 10px 20px; - } + padding: 10px 20px; + } #dataGrid th { - background: #fff; - } + background: #fff; + } #dataGrid tr:nth-child(even) { - background: rgba(231, 231, 231, .9); - } + background: rgba(231, 231, 231, .9); + } #dataGrid tr:nth-child(odd) { - background: rgba(248, 248, 248, .9);; - } + background: rgba(248, 248, 248, .9);; + } #dataGrid tr:hover { - background: #fff; - cursor: pointer; - } + background: #fff; + cursor: pointer; + } +#dataGrid tr.nohand:hover{ + cursor: initial !important; +} #dataGrid a { - text-decoration: none; - color: black; - } + text-decoration: none; + color: black; + } #dataGrid th a { - text-decoration: underline; - font-family: Georgia, arial, sans-serif; - white-space: nowrap; - } + text-decoration: underline; + font-family: Georgia, arial, sans-serif; + white-space: nowrap; + } /* Breadcrumbs */ #breadcrumbs { - background: white; - color: #000; - padding: 10px 15px; - margin-bottom: 1em; + background: white; + color: #000; + padding: 10px 15px; + margin-bottom: 1em; max-width: 700px; - } + } #breadcrumbs i { - font-weight: bold; - font-style: normal; - } + font-weight: bold; + font-style: normal; + } #lead-delete { - float: right; - margin-top: 10px; - } + 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; - } + 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); + background: red; + background: rgba(204, 0, 0, 1.0); } /* Overriding Form Framework */ div.webform td { - font-size: 13px !important; - font-size: 1.3rem !important; - } + font-size: 13px !important; + font-size: 1.3rem !important; + } div.webform table, div.webform td { - border: 1px solid #aaa !important; - } + border: 1px solid #aaa !important; + } /* Overriding JqueryUI */ /* #travel-admin .ui-state-highlight { */ -/* margin-bottom: .5em; */ -/* padding: 15px; */ -/* } */ +/* margin-bottom: .5em; */ +/* padding: 15px; */ +/* } */ /* #travel-admin .ui-state-highlight p { */ -/* margin: 0; */ -/* } */ +/* margin: 0; */ +/* } */ /* #travel-admin .ui-icon { */ -/* float: left; */ -/* margin-right: .3em; */ -/* display: block; */ -/* } */ +/* float: left; */ +/* margin-right: .3em; */ +/* display: block; */ +/* } */ /* #tabs li a { */ -/* font-size: 13px; */ -/* font-size: 1.3rem; */ -/* } */ +/* 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; - } + 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 ; - } + 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; - } + 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; - } + 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; } + +/* Member travel leads */ +#file_export fieldset { + border-width: 2px; + border-style: groove; + border-color: grey; + position: relative; + width: 90%; +} +.clearfix:after { + content: ""; + display: block; + clear: both; + height: 0; + line-height: 0; + visibility: hidden; +} + +#file_export .field-container { + display: block; + position: relative; + float: left; + width: 48%; +} diff --git a/models/admin/ajax/travelNotes.php b/models/admin/ajax/travelNotes.php index 765dede..e00e733 100644 --- a/models/admin/ajax/travelNotes.php +++ b/models/admin/ajax/travelNotes.php @@ -82,6 +82,25 @@ class GlmMembersAdmin_ajax_travelNotes extends GlmDataTravelNotes trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) ); switch ( $option ) { + case 'update': + $lead_id = (isset($_REQUEST['id'])) ? filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) : false; + $note_id = (isset($_REQUEST['note_id'])) ? filter_var( $_REQUEST['note_id'], FILTER_VALIDATE_INT ) : false; + $note_entry = (isset($_REQUEST['note_entry'])) ? filter_var( $_REQUEST['note_entry'], FILTER_SANITIZE_STRING ) : false; + if ( $lead_id && $note_id && $note_entry ) { + $this->wpdb->update( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes', + array( + 'lead' => $lead_id, + 'updated' => date( 'Y-m-d H:i:s' ), + 'notes' => $note_entry + ), + array( 'id' => $note_id ), + array( '%d', '%s', '%s' ), + array( '%d' ) + ); + } + wp_redirect( admin_url() . 'admin.php?page=glm-members-admin-menu-glm-travel&glm_action=index&option=edit&id=' . $lead_id . '#ui-id-7' ); + break; case 'add': $lead_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ); if ( isset( $_REQUEST['new_log'] ) && $lead_id diff --git a/models/admin/travel/index.php b/models/admin/travel/index.php index 53054ce..d6113d6 100644 --- a/models/admin/travel/index.php +++ b/models/admin/travel/index.php @@ -139,6 +139,17 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads } } + // If we have a back request then go through the PHP_SESSION + // and extract them into the REQUEST array. + if ( isset( $_REQUEST['back'] ) && filter_var( $_REQUEST['back'], FILTER_VALIDATE_BOOLEAN ) ) { + if ( isset( $_SESSION['search'] ) && is_array( $_SESSION['search'] ) ) { + foreach ( $_SESSION['search'] as $varName => $sessValue ) { + $_REQUEST[$varName] = $sessValue; + } + $search = true; + } + } + if ( ( isset( $search ) && $search ) ) { if ( isset( $search ) && $search ) { $searching = true; @@ -256,33 +267,53 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads break; default: + // Check for paging + if ( isset( $_REQUEST['pageSelect'] ) ) { + $_SESSION['search']['pageSelect'] = $_REQUEST['pageSelect']; + } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['pageSelect'] ) ) { + unset( $_SESSION['search']['pageSelect'] ); + } + if ( isset( $_REQUEST['nextStart'] ) ) { + $_SESSION['search']['nextStart'] = $_REQUEST['nextStart']; + } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['nextStart'] ) ) { + unset( $_SESSION['search']['nextStart'] ); + } + if ( isset( $_REQUEST['prevStart'] ) ) { + $_SESSION['search']['prevStart'] = $_REQUEST['prevStart']; + } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['prevStart'] ) ) { + unset( $_SESSION['search']['prevStart'] ); + } + 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"; } - // Check if we're doing paging - if (isset($_REQUEST['pageSelect'])) { - // If request is for Next - if ($_REQUEST['pageSelect'][0] == 'N') { - $newStart = $_REQUEST['nextStart'] - 0; - - // Otherwise it must be Previous - } else { - $newStart = $_REQUEST['prevStart'] - 0; - } - - if ($newStart > 0) { - $start = $newStart; - } + echo '
$where: ' . print_r( $where, true ) . '
'; + echo '
$order: ' . print_r( $order, true ) . '
'; + // Check if we're doing paging + if (isset($_REQUEST['pageSelect'])) { + // If request is for Next + if ($_REQUEST['pageSelect'][0] == 'N') { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; } + } + // $entry = $this->getList( $where ); $orderBy = 'T.company ASC,T.lname ASC,T.fname ASC,T.updated DESC'; $entryResults = $this->getList( $where, $orderBy, true, 'id', $start, $limit ); // Get paging results + $params = ''; $numbDisplayed = $entryResults['returned']; $leadCount = $numbDisplayed; $lastDisplayed = $entryResults['last']; diff --git a/models/admin/travel/members.php b/models/admin/travel/members.php new file mode 100644 index 0000000..d3c91c6 --- /dev/null +++ b/models/admin/travel/members.php @@ -0,0 +1,312 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Leads data abstract +require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH.'/data/dataLeads.php'; +require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataContacts.php'; +require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataNotes.php'; + +class GlmMembersAdmin_travel_members extends GlmDataTravelLeads +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + public $entryId = false; + /* + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull 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 the data class + * + * Note, the third parameter is a flag that indicates to the + * data class that it should flag a group of fields as 'view_only'. + */ + parent::__construct(false, false, true); + + + } + + public function modelAction($actionData = false) + { + $where = ' true '; + $option = false; + $user_can_edit_leads = false; + $wpUser = $this->config['loggedInUser']['wpUser']; + $search_id = false; + $numbDisplayed = false; + $lastDisplayed = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $haveLeads = false; + $leadCount = 0; + $addingLead = false; + $searching = false; + $updating = false; + $updating_error = false; + $inserting = false; + $inserting_error = false; + $groups = false; + $sources = false; + $entry = false; + $hasSearch = false; + $tab = 0; + $params = false; + + // Get any provided option + if ( isset( $_REQUEST['option'] ) ) { + $option = $_REQUEST['option']; + } + + // Get entry ID if supplied + if (isset($_REQUEST['id'])) { + + // Make sure it's numeric + $this->entryId = ( $_REQUEST['id'] - 0 ); + + if ( $this->entryId <= 0 ) { + $this->entryId = false; + } + + } + + // Check for a search being done. + if ( isset( $_REQUEST['search'] ) ) { + $search = filter_var( $_REQUEST['search'], FILTER_VALIDATE_BOOLEAN); + } + if ( isset( $_REQUEST['back'] ) ) { + $back = filter_var( $_REQUEST['back'], FILTER_VALIDATE_BOOLEAN); + if ( $back ) { + $searching = true; + } + } + + // If we have a back request then go through the PHP_SESSION + // and extract them into the REQUEST array. + if ( isset( $_REQUEST['back'] ) && filter_var( $_REQUEST['back'], FILTER_VALIDATE_BOOLEAN ) ) { + if ( isset( $_SESSION['search'] ) && is_array( $_SESSION['search'] ) ) { + foreach ( $_SESSION['search'] as $varName => $sessValue ) { + $_REQUEST[$varName] = $sessValue; + } + $search = true; + } + } + + $where_parts = array( 'T.status = 10' ); + + 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. + $search_params = filter_var_array( + $_REQUEST, + array( + 'company' => FILTER_SANITIZE_STRING, + 'contact' => FILTER_SANITIZE_STRING, + ) + ); + + // build the $where part + // echo '
$search_params: ' . print_r( $search_params, true ) . '
'; + if ( $search_params['company'] ) { + $where_parts[] = "T.company like '%" . esc_sql( $search_params['company'] ) . "%'"; + } + if ( $search_params['contact'] ) { + // Search for name. + // Could be in these formats: + // fname lname + // lname, fname + // lname fname + // lname + // fname + $name_parts = array(); + $name_parts[] = "SOUNDEX(CONCAT_WS(' ', fname, lname)) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')"; + $name_parts[] = "SOUNDEX(CONCAT_WS(' ', lname, fname)) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')"; + $name_parts[] = "SOUNDEX(fname) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')"; + $name_parts[] = "SOUNDEX(lname) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')"; + $where_parts[] = implode( ' OR ', $name_parts ); + } + + } + + // Initialize the interests array + $interests = array(); + + // Initialize the grouped_interests array + $grouped_interests = array(); + + switch ( $option ) { + default: + // Check for paging + if ( isset( $_REQUEST['pageSelect'] ) ) { + $_SESSION['search']['pageSelect'] = $_REQUEST['pageSelect']; + } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['pageSelect'] ) ) { + unset( $_SESSION['search']['pageSelect'] ); + } + if ( isset( $_REQUEST['nextStart'] ) ) { + $_SESSION['search']['nextStart'] = $_REQUEST['nextStart']; + } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['nextStart'] ) ) { + unset( $_SESSION['search']['nextStart'] ); + } + if ( isset( $_REQUEST['prevStart'] ) ) { + $_SESSION['search']['prevStart'] = $_REQUEST['prevStart']; + } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['prevStart'] ) ) { + unset( $_SESSION['search']['prevStart'] ); + } + + if ( isset( $where_parts ) && !empty( $where_parts ) ) { + $where .= ' AND ' . implode( ' AND ', $where_parts ); + } + $order = "T.lname, T.fname"; + + // echo '
$where_parts: ' . print_r( $where_parts, true ) . '
'; + // echo '
$where: ' . print_r( $where, true ) . '
'; + + // Check if we're doing paging + if (isset($_REQUEST['pageSelect'])) { + // If request is for Next + if ($_REQUEST['pageSelect'][0] == 'N') { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; + } + } + + // $entry = $this->getList( $where ); + $orderBy = 'T.company ASC,T.lname ASC,T.fname ASC,T.updated DESC'; + $entryResults = $this->getList( $where, $orderBy, true, 'id', $start, $limit ); + + // Get paging results + $params = ''; + $numbDisplayed = $entryResults['returned']; + $leadCount = $numbDisplayed; + $lastDisplayed = $entryResults['last']; + if ( $start == 1 ) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ( $start < 1 ) { + $start = 1; + } + } + if ( $entryResults['returned'] == $limit ) { + $nextStart = $start + $limit; + } + $entry = $entryResults['list']; + if ( count( $entry ) > 0 ) { + $haveLeads = true; + } + + $leadCount = count( $entry ); + + $view = 'members.html'; + + break; + } + + // Enqueue the scripts for jqueryui + wp_enqueue_script( 'jquery-ui-tabs' ); + wp_enqueue_style( 'jquery-ui-smoothness', 'https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.min.css' ); + + // Common things to place into the $templateData array + $templateData = array( + 'hasSearch' => $hasSearch, + 'params' => $params, + 'lead' => $entry, + 'haveLeads' => $haveLeads, + 'leadCount' => $leadCount, + 'numbDisplayed' => $numbDisplayed, + 'lastDisplayed' => $lastDisplayed, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'prev' => ( isset( $_REQUEST['prevStart'] ) ? $_REQUEST['prevStart'] : ''), + 'next' => ( isset( $_REQUEST['nextStart'] ) ? $_REQUEST['nextStart'] : ''), + 'pageSelect' => ( isset( $_REQUEST['pageSelect'] ) ? $_REQUEST['pageSelect'] : ''), + 'start' => $start, + 'limit' => $limit, + 'paging' => $paging, + 'searching' => $searching, + 'updating' => $updating, + 'updating_error' => $updating_error, + 'inserting' => $inserting, + 'inserting_error' => $inserting_error, + ); + + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/travel/' . $view, + 'data' => $templateData + ); + + } + +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 793b4a4..4836ab1 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -67,11 +67,11 @@ if ( isset( $this->config['loggedInUser']['contactUser'] ) && $this->config['log // if ( $memberCanAccessLeads ) { add_submenu_page( $mainMenuSlug, - 'Leads', - 'Leads', + 'Travel Leads', + 'Travel Leads', 'glm_members_edit_my_entity', - 'glm-members-admin-menu-travel-index', - function() {$this->controller('travel');} + 'glm-members-admin-menu-glm-travel', + function() {$this->controller('travel', 'members');} ); // } } diff --git a/setup/validActions.php b/setup/validActions.php index 9b48f69..6090391 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -69,8 +69,9 @@ $glmMembersTravelAddOnValidActions = array( 'referredBy' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, ), 'travel' => array( - 'index' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, - ) + 'index' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, + 'members' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, + ), ), 'frontActions' => array( ) diff --git a/views/admin/ajax/notes/list.html b/views/admin/ajax/notes/list.html index f9c253e..c1c5255 100644 --- a/views/admin/ajax/notes/list.html +++ b/views/admin/ajax/notes/list.html @@ -10,11 +10,35 @@ {if $notes} {foreach $notes as $n} -
+

{$n.updated.datetime}

-

{$n.notes|nl2br}

+

{$n.notes|nl2br}

Delete
+
+ + + + + + +
{/foreach} {/if}
+ + diff --git a/views/admin/travel/edit.html b/views/admin/travel/edit.html index 3e08302..4533331 100644 --- a/views/admin/travel/edit.html +++ b/views/admin/travel/edit.html @@ -4,7 +4,7 @@
{if isset($lead.fieldData) && isset($lead.fieldData.id)} -
+
Delete {$lead.fieldData.fname} {$lead.fieldData.lname} @@ -12,6 +12,8 @@ {/if} diff --git a/views/admin/travel/index.html b/views/admin/travel/index.html index 3a96c1b..bbfb9a1 100644 --- a/views/admin/travel/index.html +++ b/views/admin/travel/index.html @@ -12,6 +12,9 @@

Total found: {$leadCount}  

{if $paging} + + {if isset($smarty.request.company)}{/if} + {if isset($smarty.request.contact)}{/if} {/if} @@ -30,7 +33,7 @@ {foreach $lead as $e} - Edit + Edit {$e.company} {$e.fname} {$e.lname} diff --git a/views/admin/travel/memberSearchForm.html b/views/admin/travel/memberSearchForm.html new file mode 100644 index 0000000..7ba1336 --- /dev/null +++ b/views/admin/travel/memberSearchForm.html @@ -0,0 +1,44 @@ +
+
+ + + +
+ Search for Group Tour Leads +
+ + +
+
+ + +
+

Date Range

+
+ + +
+
+ + +
+

Locations

+
+ states +
+
+
+
+
+
+ +
+
+
+
+ + diff --git a/views/admin/travel/members.html b/views/admin/travel/members.html new file mode 100644 index 0000000..74d4de1 --- /dev/null +++ b/views/admin/travel/members.html @@ -0,0 +1,52 @@ +{include file='admin/travel/header.html'} + +{include file='admin/travel/memberSearchForm.html'} + +{if $lead} +
+ + + + + +
+

Total found: {$leadCount}  

+ {if $paging} + + {if isset($smarty.request.company)}{/if} + {if isset($smarty.request.contact)}{/if} + + + {/if} + + + + + + + + + + + + {foreach $lead as $e} + + + + + + + {/foreach} + +
Company First Name Last Name Updated
{$e.company} {$e.fname} {$e.lname} {$e.updated.datetime}
+ + {if $paging} + + + {/if} +
+{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 410fba4..eea5ae7 100644 --- a/views/admin/travel/searchForm.html +++ b/views/admin/travel/searchForm.html @@ -12,7 +12,7 @@
- +
@@ -24,7 +24,7 @@
- +