Update the member info contact part for new mailing fields.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 29 Dec 2016 18:38:52 +0000 (13:38 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 3 Jan 2017 18:37:10 +0000 (13:37 -0500)
Adding the mailing address fields into the view files and adding new
mailing city into javascript parts and the model.

classes/data/dataMemberInfo.php
models/admin/member/memberInfo.php
views/admin/member/memberInfo.html
views/admin/member/memberInfo/editContact.html

index eabfb30..22bd0db 100644 (file)
@@ -424,6 +424,47 @@ class GlmDataMemberInfo extends GlmDataAbstract
                 'use' => 'a'
             ),
 
+            // Mailing Address Line 1
+            'mailing_addr1' => array (
+                'field' => 'mailing_addr1',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Mailing Address Line 2
+            'mailing_addr2' => array (
+                'field' => 'mailing_addr2',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Mailing City
+            'mailing_city' => array (
+                'field' => 'mailing_city',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                'use' => 'a'
+            ),
+
+            // Mailing State
+            'mailing_state' => array (
+                'field' => 'mailing_state',
+                'type' => 'list',
+                'list' => $this->config['states'],
+                'default'  => $this->config['settings']['default_state'],
+                'use' => 'a'
+            ),
+
+            // Mailing ZIP / Postal Code
+            'mailing_zip' => array (
+                'field' => 'mailing_zip',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+
             // Notes
             'notes' => array (
                     'field' => 'notes',
index 3c4bd49..779d7b8 100644 (file)
@@ -532,6 +532,33 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
 
             }
         }
+        // If we have a member ID and this was a submission with a new mailing_city (id < 0)
+        if ($this->memberID && isset($_REQUEST['mailing_city']) && $_REQUEST['mailing_city'] == -1 && isset($_REQUEST['newMailingCityName']) && trim($_REQUEST['newMailingCityName']) != '') {
+
+            // Clean up mailing_city name
+            $cName = trim(filter_var($_REQUEST['newMailingCityName']));
+
+            // Try to add the mailing_city
+            require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php';
+            $Cities = new GlmDataCities($this->wpdb, $this->config);
+            $cID = $Cities->addCity($cName);
+
+            // If we got a mailing_city id back
+            if (is_int($cID) && $cID > 0) {
+
+                // Update the mailing_city selected for this member record
+                $sql = "
+                        UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member
+                            SET mailing_city = $cID
+                            WHERE id = ".$this->memberID."
+                            ;";
+                $this->wpdb->query($sql);
+
+                // Update submitted mailing_city value to use the new ID
+                $_REQUEST['mailing_city'] = $cID;
+
+            }
+        }
     }
 
     /*
index 6617b74..cfc350d 100644 (file)
@@ -9,7 +9,7 @@
     <![endif]-->
 
 {if apply_filters('glm_members_permit_admin_member_info_edit', true)}
-    
+
     {if $memberInfoID && $memberInfo}
         <!--  Delete Member Profile dialog -->
         <div id="deleteMemberInfoButton" class="button button-primary glm-right">Delete this {$terms.term_member_cap} Profile Version</div>
       {if $memberInfo.fieldData.status.value == 10}
             <p><a id="deleteMemberInfoCancel" class="button button-primary">Cancel</a></p>
             <p>
-                <span class="glm-notice">NOTE:</span> This {$terms.term_member} profile is the <b>currently active</b> version! You may not delete an active profile version. 
+                <span class="glm-notice">NOTE:</span> This {$terms.term_member} profile is the <b>currently active</b> version! You may not delete an active profile version.
                 To delete this version, please select another version to be active or change the "Profile Status" on this page to something
                 other than "Active".
             </p>
             <p>
-                If you change this version to something other than "Active" without selecting another version as active, there will be no active 
+                If you change this version to something other than "Active" without selecting another version as active, there will be no active
                     profile for this {$terms.term_member}. {$terms.term_member_cap} without an active profile will not be displayed on the front-end of this Web site.
             </p>
             <p>
@@ -37,7 +37,7 @@
             <div class="glm-item-container">
                 <p><center><span class="glm-error">WARNING:</span></center></p>
                 <p>
-                    <span class="glm-warning">Clicking the "Delete this {$terms.term_member_cap} Profile Version" button above will 
+                    <span class="glm-warning">Clicking the "Delete this {$terms.term_member_cap} Profile Version" button above will
                     delete all of the data and images displayed on this page and any other information in the tabs that may show to the right of the "{$terms.term_member_cap} Profile"
                     tab above.</span>
                 </p>
             </div>
             <p>
                 This {$terms.term_member} may also have other {$terms.term_member} profile records. Click the "{$terms.term_member_cap} Dashboard" Tab above to view a list of all profile version
-                records for this {$terms.term_member}. 
+                records for this {$terms.term_member}.
             </p>
             <p>
-                Only this {$terms.term_member} profile version will be deleted. Other {$terms.term_member} profile versions listed under the "{$terms.term_member_cap} Dashboard" tab 
-                above will not be deleted. 
+                Only this {$terms.term_member} profile version will be deleted. Other {$terms.term_member} profile versions listed under the "{$terms.term_member_cap} Dashboard" tab
+                above will not be deleted.
             </p>
             <p>
-                There may also be "Archived" versions that will not normally show up in the "{$terms.term_member_cap} Dashboard". Click the 
+                There may also be "Archived" versions that will not normally show up in the "{$terms.term_member_cap} Dashboard". Click the
                 "Show Archiived Profile Versions" checkbox at the top right of the versions list on that page to include archived versions.
             </p>
 
             <tr>
                 <th>Access:</th>
                 <td>{$member.access.name}</td>
-            </tr>                        
-      {/if}            
+            </tr>
+      {/if}
         </table>
-            
+
     <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
         <a id="glm-member-info-descr" data-show-table="glm-table-descr" class="glm-member-info-tab nav-tab nav-tab-active">Status & Description</a>
         <a id="glm-member-info-address" data-show-table="glm-table-address" class="glm-member-info-tab nav-tab">Address & Location</a>
         {if $memberUpdated}<span class="glm-notice glm-flash-updated glm-right">{$terms.term_member_cap} Profile Updated</span>{/if}
         {if $memberUpdateError}<span class="glm-error glm-flash-updated glm-right">{$terms.term_member_cap} Profile Update Error</span>{/if}
     </h2>
-            
+
         <!-- Profile Status & Description -->
-        
+
         {include file='admin/member/memberInfo/editStatus.html'}
-        
+
         <!-- **** Address and Location **** -->
 
         {include file='admin/member/memberInfo/editLocation.html'}
         {include file='admin/member/memberInfo/editContact.html'}
 
         <!-- **** Category & Amenities **** -->
-        
+
         {include file='admin/member/memberInfo/editCategory.html'}
-        
+
         <!-- **** Images **** -->
-         
+
         {include file='admin/member/memberInfo/editImages.html'}
-        
+
         <!-- **** Video **** -->
-        
+
         {include file='admin/member/memberInfo/editVideo.html'}
-        
+
         <!-- **** Live Cam **** -->
-        
+
         {include file='admin/member/memberInfo/editCamera.html'}
-        
+
         <!-- **** Credit Cards **** -->
-        
+
         {include file='admin/member/memberInfo/editCreditCards.html'}
 
     </form>
-    
+
 {else} <!-- No - glm_members_permit_admin_member_info_edit -->
         <script type="text/javascript">var enableDraggable = false;</script>
 
         <table class="glm-admin-table">
-            
+
             <tr><th>{$terms.term_member_cap} Name:</th><td>{$member.name}</td></tr>
-            <tr><th>{$terms.term_member_cap} Type:</th><td>{$member.member_type.name}</td></tr>            
-            <tr><th>Access:</th><td>{$member.access.name}</td></tr>                        
-            <tr><th>Created:</th><td>{$memberInfo.fieldData.create_time.datetime}</td></tr>            
+            <tr><th>{$terms.term_member_cap} Type:</th><td>{$member.member_type.name}</td></tr>
+            <tr><th>Access:</th><td>{$member.access.name}</td></tr>
+            <tr><th>Created:</th><td>{$memberInfo.fieldData.create_time.datetime}</td></tr>
             <tr><th>Last Updated:</th><td>{$memberInfo.fieldData.modify_time.datetime}</td></tr>
             <tr><th>{$terms.term_member_cap} Info Status:</th><td>{$memberInfo.fieldData.status.name}</option></td></tr>
             <tr><th>Reference Name:</th><td>{$memberInfo.fieldData.reference_name}</td></tr>
                     <!-- Amenity Selection -->
                 {if isset($memberInfo.fieldData.amenities) && $memberInfo.fieldData.amenities}
                    {foreach from=$memberInfo.fieldData.amenities item=c}
-                    <div data-id="{$c.id}" class="glm-dynSelect-item glm-members-amenity"> 
-                        {$c.name} 
+                    <div data-id="{$c.id}" class="glm-dynSelect-item glm-members-amenity">
+                        {$c.name}
                         <input type="hidden" name="amenity[{$c.id}]" value="{$c.id}">
-                    </div>                    
+                    </div>
                     {/foreach}
-                {/if}                    
+                {/if}
                 </td>
             </tr>
             <tr><th>Notes:</th><td>{$memberInfo.fieldData.notes}</td></tr>
                 <th>Image Gallery</th>
                 <td class="glm-item-container glm-imageGalleryContainer">
                     <ul class="glm-galleryImages">
-                    {if $haveImageGallery}     
+                    {if $haveImageGallery}
                         {foreach $imageGallery as $i}
                             {if $i.file_name}
                             <li id="{$i.id}" class="glm-galleryContainer">
                                 </div>
                                 <div id="glm-galleryImageLarger_{$i.id}" class="glm-imageDialog"><img src="{$glmPluginMediaUrl}/images/large/{$i.file_name}"></div>
                             {/if}
-                            </li>           
+                            </li>
                         {/foreach}
                     {/if}
                     </div>
 
             // Do inital setup on load for first tab
             glmSetupAreaTab($('#glm-member-info-descr'));
-            
+
             // Setup edit area selected
             function glmSetupAreaTab(t) {
-                
+
                 // Clear tabl highlights and hide all tables
                 $('.glm-member-info-tab').removeClass('nav-tab-active');
                 $('.glm-member-info-table').addClass('glm-hidden');
-                
+
                 // Highlight selected tab
                 t.addClass('nav-tab-active');
-                
+
                 // Show selected table
                 var table = t.attr('data-show-table');
                 $('#' + table).removeClass('glm-hidden');
-                
-                
+
+
                 if (table == 'glm-table-address') {
                     initMap();
                 }
-                
+
                 // Listen for changes in the lat/lon inputs
                 $('#latLonRecenter').on('click', function() {
 
                     // Get lat and lon from the input fields
                     var glmLat = $('#glmLat').val();
                     var glmLng = $('#glmLng').val();
-                    
+
                     location = new google.maps.LatLng(glmLat, glmLng);
                     initMap();
                     return false;
-                    
+
                 });
-                
+
                 // Listen for changes to video type
                 $('#glm-video-type').change( function() {
                     glmSetVideoTypeInput();
                 });
                 glmSetVideoTypeInput();
-                
+
 
                 // Count remaining characters in field
                 $('.glm-char-count').keyup( function() {
                     glmCharsRemaining($(this));
                 });
-                
+
                 $('.glm-char-count').each( function() {
                     glmCharsRemaining($(this));
                 });
-                                
+
             }
-            
+
             // Display number of characters remaining in limited field
             function glmCharsRemaining(f) {
                 var maxChar = f.attr('maxlength');
                     $('#' + msgArea).html('Characters remaining: ' + rem);
                 }
             }
-            
+
             // Display input field for selected video type
-            function glmSetVideoTypeInput() {                     
-                
+            function glmSetVideoTypeInput() {
+
                 var videoType = $('#glm-video-type').val();
-                
+
                 // If using URL type - Ask for URL
                 if (videoType < 20) {
                     $('#glm-video-url').removeClass('glm-hidden');
                     $('#glm-video-file').addClass('glm-hidden');
-                    
+
                 // Otherwise it's a file type - Ask for File
                 } else {
                     $('#glm-video-url').addClass('glm-hidden');
                 }
 
             }
-            
+
             /*
              * Action to select an Amenity
              */
             $('#amenitySelect').change( function() {
-                
+
                 // Get the ID, name
-                var amenValue = $('#amenitySelect').val();       
+                var amenValue = $('#amenitySelect').val();
                 var amenName = $('#amenitySelect').find(':selected').text();
-                
+
                 if (amenValue == '') {
                        return;
                 }
-                
+
                 // Check if the amenity has already been added
-                var found = false;              
+                var found = false;
                 $(".glm-members-amenity").each( function() {
                     var id = $(this).attr('data-id');
                     if (id == amenValue) {
                         found = true;
                     }
                 });
-                
+
                 // If not found, Add the amenity
                 if (!found) {
-                    $('#activeAmenities').append('<div data-id="' + amenValue 
+                    $('#activeAmenities').append('<div data-id="' + amenValue
                             + '" class="glm-dynSelect-item glm-members-amenity">' + amenName
                             + ' <span class="glm-dynSelect-delete amenityDelete">X</span>'
                             + '<input type="hidden" name="amenity[' + amenValue + ']" value="' + amenValue + '"></div>');
             // Action to de-select an Amenity
             $('.amenityDelete').live('click', function() {
                 $(this).parent().remove();
-                // Also set unload warning 
+                // Also set unload warning
                 glmPageUpdateRequired();
             });
 
-    {if $memberInfoID && $memberInfo}            
+    {if $memberInfoID && $memberInfo}
             // Delete Member Info dialog
             $("#deleteMemberInfoDialog").dialog({
                 autoOpen: false,
             });
             $('#deleteMemberInfoCancel').click( function() {
                 $("#deleteMemberInfoDialog").dialog("close");
-            });            
+            });
             $('#deleteMemberInfoSubmit').click( function() {
                window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=index&member={$memberID}&deleteID={$memberInfo.fieldData.id}");
             });
-    {/if}        
+    {/if}
             /*
              * Category Selection
              */
-             
+
             // Action to select a category
             $('#categorySelect').change( function() {
-                
+
                 // Get the ID, name, and parent of the category
-                var catValue = $('#categorySelect').val();       
+                var catValue = $('#categorySelect').val();
                 var catName = $('#categorySelect').find(':selected').text();
                 var catParent = $('#categorySelect').find(':selected').attr('data-parent');
-                
+
                 // Check if the category has already been added
-                var found = false;              
+                var found = false;
                 $(".glm-members-catgegory").each( function() {
                     var id = $(this).attr('data-id');
                     if (id == catValue) {
                         found = true;
                     }
                 });
-    
+
                 // Check if there's a parent
                 parentName = '';
                 if (catParent != '') {
                     parentName = catParent + ': ';
                 }
-                
+
                 // If not found, Add the category
                 if (!found) {
-                    $('#activeCategories').append('<div data-id="' + catValue 
-                            + '" class="glm-dynSelect-item glm-members-catgegory">' 
+                    $('#activeCategories').append('<div data-id="' + catValue
+                            + '" class="glm-dynSelect-item glm-members-catgegory">'
                             + parentName + catName.trim() + ' <span class="glm-dynSelect-delete catDelete">X</span>'
                             + '<input type="hidden" name="category[' + catValue + ']" value="' + catValue + '"></div>');
                 }
-    
+
                 // Reset picklist
                 $('#categorySelect').val('');
-    
+
             });
-    
+
             // Action to de-select a category
             $('.catDelete').live('click', function() {
                 $(this).parent().remove();
             });
-    
+
             /*
              * New Category Dialog
              */
-             
+
             var newCat = 0;    // Used for new category numbering (new cats are negative numbers)
-            
+
             // Setup dialog box for adding a new category
             $("#newCategoryDialog").dialog({
                 autoOpen: false,
                 minWidth: 400,
                 dialogClass: "glm-dialog-no-close"
             });
-    
+
             // Ad a new category button action - pop-up dialog
             $('#newCategoryButton').click( function() {
                 $("#newCategoryDialog").dialog("open");
             });
-    
+
             // Submit new category
              $('#newCategorySubmit').click( function() {
-                
+
                 // Assign new cat number
                 newCat--;
-                
+
                 // Get new category information
                 var newCatName = $('#newCatName').val();
                 var newCatParent = $('#newCatParent').val();
                 var catParent = $('#newCatParent').find(':selected').attr('data-parent');
                 var newCatParentName = $('#newCatParentName').val();
-                
+
                 // If there's no name, tell the user we need one.
                 if (newCatName == '') {
                     $('#newCatNameTD').addClass('glm-form-bad-input');
                     $('#newCatNameRequired').text('A catogory name is required!');
                     return false;
                 }
-                
+
                 // Check if there's a parent, get the name - new parent name overrides selected parent
                 parentName = '';
                 if (newCatParentName && newCatParentName != '') {
                 } else if (catParent && catParent != '') {
                     parentName = catParent + ': ';
                 }
-                
+
                 // Add the new category to the active categories list
-                $('#activeCategories').append('<div data-id="' + newCat 
-                        + '" class="glm-dynSelect-item glm-members-catgegory">' 
+                $('#activeCategories').append('<div data-id="' + newCat
+                        + '" class="glm-dynSelect-item glm-members-catgegory">'
                         + parentName + newCatName.trim() + ' <span data-id="' + newCat + '" class="glm-dynSelect-delete catDelete">X</span>'
                         + '<input type="hidden" name="category[' + newCat + ']" value="' + newCat + '">'
                         + '<input type="hidden" name="newCategory[' + newCat + ']" value="' + newCatName + '">'
                         + '<input type="hidden" name="newCatParent[' + newCat + ']" value="' + newCatParent + '">'
                         + '<input type="hidden" name="newCatParentName[' + newCat + ']" value="' + newCatParentName + '">'
                         + '</div>');
-    
+
                 // Clear the dialog input fields
                 $('#newCatName').val('');
-                $('#newCatParent').val('');  
-                $('#newCatParentName').val('');  
-    
+                $('#newCatParent').val('');
+                $('#newCatParentName').val('');
+
                 $("#newCategoryDialog").dialog("close");
-    
+
             });
             $('#newCategoryCancel').click( function() {
                 $("#newCategoryDialog").dialog("close");
             });
-    
+
             // Setup dialog box for adding a new category
             $("#newCategoryDialog").dialog({
                 autoOpen: false,
                 minWidth: 400,
                 dialogClass: "glm-dialog-no-close"
             });
-            
+
             /*
              * New City Dialog
              */
-    
+
             // Setup dialog box for adding a new city
             $("#newCityDialog").dialog({
                 autoOpen: false,
             $('#newCityCancel').click( function() {
                 $("#newCityDialog").dialog("close");
             });
-             
+
             // Ad a new city button action - pop-up dialog
             $('#newCityButton').click( function() {
                 $("#newCityDialog").dialog("open");
             });
-    
+
             // Submit new city
             var newCityAdded = false;
             $('#newCitySubmit').click( function() {
-                
+
                 // Get new city name
                 var newCityName = $('#newCityName').val();
-    
+
                 // If no name is supplied, notify used it's required
                 if (newCityName == '') {
                     $('#newCityNameTD').addClass('glm-form-bad-input');
                     $('#newCityNameRequired').text('A city name is required!');
                     return false;
                 }
-    
+
                 // Add new city name to the hidden field that will pass the new name to PHP.
                 $('#cityName').val(newCityName);
-                
+
                 // Add new city name to picklist and for storing - Only one permitted per submission
                 if (newCityAdded) {
-                    
+
                     // New city already added, so just update the name and select that one
                     $('#city').val(-1);
                     $('#city option:selected').text(newCityName);
-                    
+
                 } else {
-                    
+
                     // Add the new city name to the city picklist
                     $('#city').append('<option value="-1">' + newCityName + '</option>');
                     $('#city').val(-1);
                     $('#newCityNameTD').append('<input type="hidden" name="newCity" value="' + newCityName + '">');
                     newCityAdded = true;
-    
+
                 }
-      
+
                 // Clear new city name from form
                 $('#newCityName').val('');
-                
+
                 $("#newCityDialog").dialog("close");
-    
-                glmGeocode();   
-    
+
+                glmGeocode();
+
             });
-            
+
+            /*
+             * New Mailing City Dialog
+             */
+
+            // Setup dialog box for adding a new city
+            $("#newMailingCityDialog").dialog({
+                autoOpen: false,
+                minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+            $('#newMailingCityCancel').click( function() {
+                $("#newMailingCityDialog").dialog("close");
+            });
+
+            // Ad a new city button action - pop-up dialog
+            $('#newMailingCityButton').click( function() {
+                $("#newMailingCityDialog").dialog("open");
+            });
+
+            // Submit new city
+            var newMailingCityAdded = false;
+            $('#newMailingCitySubmit').click( function() {
+
+                // Get new city name
+                var newMailingCityName = $('#newMailingCityName').val();
+
+                // If no name is supplied, notify used it's required
+                if (newMailingCityName == '') {
+                    $('#newMailingCityNameTD').addClass('glm-form-bad-input');
+                    $('#newMailingCityNameRequired').text('A city name is required!');
+                    return false;
+                }
+
+                // Add new city name to the hidden field that will pass the new name to PHP.
+                $('#mailingCityName').val(newMailingCityName);
+
+                // Add new city name to picklist and for storing - Only one permitted per submission
+                if (newMailingCityAdded) {
+
+                    // New city already added, so just update the name and select that one
+                    $('#mailing_city').val(-1);
+                    $('#mailing_city option:selected').text(newMailingCityName);
+
+                } else {
+
+                    // Add the new city name to the city picklist
+                    $('#mailing_city').append('<option value="-1">' + newMailingCityName + '</option>');
+                    $('#mailing_city').val(-1);
+                    $('#newMailingCityNameTD').append('<input type="hidden" name="newMailingCity" value="' + newMailingCityName + '">');
+                    newMailingCityAdded = true;
+
+                }
+
+                // Clear new city name from form
+                $('#newMailingCityName').val('');
+
+                $("#newMailingCityDialog").dialog("close");
+
+                glmGeocode();
+
+            });
+
             /*
              * Map operations
              */
-    
+
            //show error if location can't be found
            function showError() {
                alert("Location can't be found");
            }
-    
+
             /*
              * Google Maps
              *  API reference: https://developers.google.com/maps/documentation/javascript/reference
              */
-    
+
             // Set default - Need to make this configurable
             var startLat = $('#glmLat').val();
             var startLon = $('#glmLng').val();
             var marker;
 
             function initMap() {
-                var map = new google.maps.Map(document.getElementById('locationMap'), {  
-                    zoom: 15,  
-                    disableDefaultUI: false,   
-                    mapTypeId: google.maps.MapTypeId.MAP,  
-                });  
+                var map = new google.maps.Map(document.getElementById('locationMap'), {
+                    zoom: 15,
+                    disableDefaultUI: false,
+                    mapTypeId: google.maps.MapTypeId.MAP,
+                });
                 var geocoder = new google.maps.Geocoder();
-                var marker = new google.maps.Marker({  
-                    map: map,  
-                    position: location,  
+                var marker = new google.maps.Marker({
+                    map: map,
+                    position: location,
                     draggable: enableDraggable,
-                    animation: google.maps.Animation.DROP,  
-                    title: "This is your location"  
-                });  
+                    animation: google.maps.Animation.DROP,
+                    title: "This is your location"
+                });
                 map.setCenter(location);
-    
-                // Listen for an end of drag event for the map marker            
+
+                // Listen for an end of drag event for the map marker
                 google.maps.event.addListener(marker,'dragend',function(event) {
-                    
+
                     // Get the end postion
                     glmLat = this.position.lat();
                     glmLng = this.position.lng();
-                    
+
                     // Assign it to the lat/lon fields for submission
                     $('#glmLat').val(glmLat.toFixed(6));
                     $('#glmLng').val(glmLng.toFixed(6));
-                    
+
                 });
 
                 // When estimate location button is clicked, geocode using address
                 $('#glm-estimate-location').on('click', function() {
-    
+
                     // Get all address parts
                     var geoAddr1 = $('#addr1').val().trim();
                     var geoAddr2 = $('#addr2').val().trim();
                     var geoState = $('#state').find('option:selected').text().trim();
                     var geoZIP = $('#zip').val().trim();
                     var geoCountry = $('#country').find('option:selected').text().trim();
-                    
-                    // Assemble address string for 
+
+                    // Assemble address string for
                     var geoAddress = geoAddr1 + ', ' + geoAddr2 + ', ' + geoCity + ', ' + geoState + ' ' + geoZIP + ', ' + geoCountry;
-                    
+
                     // Send to Google Geocoder
                     geocoder.geocode( { 'address': geoAddress }, function(results, status) {
-    
+
                         // If we have a geocode solution
                         if (status == google.maps.GeocoderStatus.OK) {
-    
+
                             // Center the map and locate the marger to the new location
                             map.setCenter(results[0].geometry.location);
                             marker.setPosition( results[0].geometry.location );
-                            
+
                             // Assign the new position to the hidden fields for submission
                             glmLat = results[0].geometry.location.lat();
                             glmLng = results[0].geometry.location.lng();
                             $('#glmLat').val(glmLat.toFixed(6));
                             $('#glmLng').val(glmLng.toFixed(6));
-    
+
                             // Also display it to the user
                             $('#mapPosition').html('Lat ' + glmLat.toFixed(4) + ', Lon ' + glmLng.toFixed(4));
-    
-                            // Otherwise tell the user. 
-                        } else {                        
+
+                            // Otherwise tell the user.
+                        } else {
                             alert('Not able to estimate position from the current address.');
                         }
                     });
-    
+
                 });
-    
+
             }
-    
+
             // Resubmit geocoding when map location button is clicked
             function glmGeocode() {
-                
+
                 // Get all address parts
                 var geoAddr1 = $('#addr1').val().trim();
                 var geoAddr2 = $('#addr2').val().trim();
                 var geoState = $('#state').find('option:selected').text().trim();
                 var geoZIP = $('#zip').val().trim();
                 var geoCountry = $('#country').find('option:selected').text().trim();
-                
-                // Assemble address string for 
+
+                // Assemble address string for
                 var geoAddress = geoAddr1 + ', ' + geoAddr2 + ', ' + geoCity + ', ' + geoState + ' ' + geoZIP + ', ' + geoCountry;
-                
+
                 // Send to Google Geocoder
                 geocoder.geocode( { 'address': geoAddress }, function(results, status) {
-    
+
                     // If we have a geocode solution
                     if (status == google.maps.GeocoderStatus.OK) {
-    
+
                         // Center the map and locate the marger to the new location
                         map.setCenter(results[0].geometry.location);
                         marker.setPosition( results[0].geometry.location );
-                        
+
                         // Assign the new position to the lat/lon fields for submission
                         glmLat = results[0].geometry.location.lat();
                         glmLng = results[0].geometry.location.lng();
                         $('#glmLat').val(glmLat);
                         $('#glmLng').val(glmLng);
-    
+
                         // Also display it to the user
                         $('#mapPosition').html('Lat ' + glmLat.toFixed(4) + ', Lon ' + glmLng.toFixed(4));
-    
-                        // Otherwise tell the user. 
-                    } else {                        
+
+                        // Otherwise tell the user.
+                    } else {
                         alert('Not able to estimate position from the current address.');
                     }
                 });
             }
-            
-            // Flash certain elements for a short time after display      
+
+            // Flash certain elements for a short time after display
             $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
-           
+
             /*
              * Check for bad input or input changes
              */
-             
+
             // Check for any field errors and if found change related tab to error color.
 
             $('.glm-form-bad-input').each( function(index) {
 
                 tab = $(this).attr('data-tabid');
-                
+
                 if (!$('#' + tab).hasClass('glm-bad-input-area')) {
                     $('#' + tab).addClass('glm-bad-input-area');
                 }
             });
-            
+
             // Check for most input changes
             $('input, textarea, select').on( 'change', function() {
                 glmPageUpdateRequired();
-            }); 
+            });
 
             /*
              * Checks for leaving the page
              */
             var glmSubmitRequired = false;
-             
+
             // Flag submit button when updates are required.
             function glmPageUpdateRequired() {
                 $('#updateMemberProfile').addClass('glm-bad-input-area');
                 glmSubmitRequired = false;
                 return true;
             });
-            
+
             // If submit is required and we're laving the page, alert the user
             $(window).bind('beforeunload', function() {
                 if (glmSubmitRequired) {
                     return true;
                 }
             });
-            
+
             // Set masking for phone number fields - see http://digitalbush.com/projects/masked-input-plugin/
             $.mask.definitions['e'] = "[A-Za-z0-9: ]";
             $(".glm-phone-input").mask("999{$settings.phone_infix}999{$settings.phone_infix}9999? eeeeeeeeeee");
-            
+
             $('#glm-live-cam-type').on("change", function() {
                 checkLiveCamType();
             });
             function checkLiveCamType() {
                 var camType = $('#glm-live-cam-type').val();
                 if (camType == 1) {
-                    $('.not-with-url-type').addClass('glm-hidden');                    
+                    $('.not-with-url-type').addClass('glm-hidden');
                 } else {
                     $('.not-with-url-type').removeClass('glm-hidden');
                 }
             }
             checkLiveCamType();
-            
+
         });
     </script>
-            
-            
+
+
 {include file='admin/footer.html'}
index f23c4f1..69b0d9e 100644 (file)
-
-                
-        <table id="glm-table-contact" class="glm-admin-table glm-hidden glm-member-info-table">
-            <tr>
-                <th {if $memberInfo.fieldRequired.phone}class="glm-required"{/if}>Phone #:</th>
-                <td {if $memberInfo.fieldFail.phone}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
-                    <input type="text" name="phone" value="{$memberInfo.fieldData.phone}" class="glm-form-text-input-short glm-phone-input" >
-                    {if $memberInfo.fieldFail.phone}<p>{$memberInfo.fieldFail.phone}</p>{/if}
-                </td>
-            </tr>
-            <tr>
-                <th {if $memberInfo.fieldRequired.toll_free}class="glm-required"{/if}>Toll Free #:</th>
-                <td {if $memberInfo.fieldFail.toll_free}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
-                    <input type="text" name="toll_free" value="{$memberInfo.fieldData.toll_free}" class="glm-form-text-input-short glm-phone-input" placeholder="ex: 800.123.4567 [ext 123]">
-                    {if $memberInfo.fieldFail.toll_free}<p>{$memberInfo.fieldFail.toll_free}</p>{/if}
-                </td>
-            </tr>
-            <tr>
-                <th {if $memberInfo.fieldRequired.email}class="glm-required"{/if}>E-Mail Address:</th>
-                <td {if $memberInfo.fieldFail.email}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
-                    <input type="text" name="email" value="{$memberInfo.fieldData.email}" class="glm-form-text-input-short" placeholder="ex: info@gaslightmedia.com">
-                    {if $memberInfo.fieldFail.email}<p>{$memberInfo.fieldFail.email}</p>{/if}
-                </td>
-            </tr>
-            <tr>
-                <th {if $memberInfo.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
-                <td {if $memberInfo.fieldFail.url}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+<table id="glm-table-contact" class="glm-admin-table glm-hidden glm-member-info-table">
+    <tr>
+        <th {if $memberInfo.fieldRequired.phone}class="glm-required"{/if}>Phone #:</th>
+        <td {if $memberInfo.fieldFail.phone}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+            <input type="text" name="phone" value="{$memberInfo.fieldData.phone}" class="glm-form-text-input-short glm-phone-input" >
+            {if $memberInfo.fieldFail.phone}<p>{$memberInfo.fieldFail.phone}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.toll_free}class="glm-required"{/if}>Toll Free #:</th>
+        <td {if $memberInfo.fieldFail.toll_free}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+            <input type="text" name="toll_free" value="{$memberInfo.fieldData.toll_free}" class="glm-form-text-input-short glm-phone-input" placeholder="ex: 800.123.4567 [ext 123]">
+            {if $memberInfo.fieldFail.toll_free}<p>{$memberInfo.fieldFail.toll_free}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.email}class="glm-required"{/if}>E-Mail Address:</th>
+        <td {if $memberInfo.fieldFail.email}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+            <input type="text" name="email" value="{$memberInfo.fieldData.email}" class="glm-form-text-input-short" placeholder="ex: info@gaslightmedia.com">
+            {if $memberInfo.fieldFail.email}<p>{$memberInfo.fieldFail.email}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
+        <td {if $memberInfo.fieldFail.url}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
         {if $memberInfo.fieldData.url}
-                    <a class="button button-secondary glm-right" href="{$memberInfo.fieldData.url}" target="urlTarget">Test Link</a>
+            <a class="button button-secondary glm-right" href="{$memberInfo.fieldData.url}" target="urlTarget">Test Link</a>
         {/if}
-                    <input type="text" name="url" value="{$memberInfo.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: http://www.gaslightmedia.com">
-                    {if $memberInfo.fieldFail.url}<p>{$memberInfo.fieldFail.url}</p>{/if}
-                </td>
-            </tr>
-        </table>
+            <input type="text" name="url" value="{$memberInfo.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: http://www.gaslightmedia.com">
+            {if $memberInfo.fieldFail.url}<p>{$memberInfo.fieldFail.url}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.mailing_addr1}class="glm-required"{/if}>Mailing Address 1:</th>
+        <td {if $memberInfo.fieldFail.mailing_addr1}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+            <input type="text" name="mailing_addr1" value="{$memberInfo.fieldData.mailing_addr1}" class="glm-form-text-input-short">
+            {if $memberInfo.fieldFail.mailing_addr1}<p>{$memberInfo.fieldFail.mailing_addr1}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.mailing_addr2}class="glm-required"{/if}>Mailing Address 2:</th>
+        <td {if $memberInfo.fieldFail.mailing_addr2}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+            <input type="text" name="mailing_addr2" value="{$memberInfo.fieldData.mailing_addr2}" class="glm-form-text-input-short">
+            {if $memberInfo.fieldFail.mailing_addr2}<p>{$memberInfo.fieldFail.mailing_addr2}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.mailing_city}class="glm-required"{/if}>Mailing City:</th>
+        <td {if $memberInfo.fieldFail.mailing_city}class="glm-item-container glm-form-bad-input" data-tabid="glm-member-info-contact"{else}class="glm-item-container"{/if}>
+            <!--  Add new city dialog -->
+            <div id="newMailingCityButton" class="button button-secondary glm-right">Add a new City</div>
+            <div id="newMailingCityDialog" class="glm-dialog-box" title="Enter a New City">
+                <table class="glm-admin-table">
+                    <tr>
+                        <th class="glm-required">City Name:</th>
+                        <td id="newMailingCityNameTD">
+                            <input id="newMailingCityName" type="text" name="newMailingCityName" class="glm-form-text-input">
+                            <div id="newMailingCityNameRequired"></div>
+                        </td>
+                    </tr>
+                </table>
+                <p><span class="glm-required">*</span> Required</p>
+                <a id="newMailingCityCancel" class="button button-primary glm-right">Cancel</a>
+                <input id="newMailingCitySubmit" type="submit" value="Add new City">
+            </div>
+            <input id="mailingCityName" type="hidden" name="newMailingCityName" value=""><!-- this field is only used if adding a new mailing city to pass the new name -->
+            <select name="mailing_city" id="mailing_city">
+                <option value="0"></option>
+                {foreach from=$memberInfo.fieldData.mailing_city.list item=v}
+                    <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                        {$v.name}
+                    </option>
+                {/foreach}
+            </select>
+            {if $memberInfo.fieldFail.mailing_city}<p>{$memberInfo.fieldFail.mailing_city}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.mailing_state}class="glm-required"{/if}>Mailing State:</th>
+        <td {if $memberInfo.fieldFail.mailing_state}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+            <select id="mailing_state" name="mailing_state">
+                <option value=""></option>
+                {foreach from=$memberInfo.fieldData.mailing_state.list item=v}
+                    <option value="{$v.value}"{if $memberInfo.fieldData.mailing_state.value == $v.value} selected="selected"{/if}>
+                        {$v.name}
+                    </option>
+                {/foreach}
+            </select>
+            {if $memberInfo.fieldFail.mailing_state}<p>{$memberInfo.fieldFail.mailing_state}</p>{/if}
+        </td>
+    </tr>
+    <tr>
+        <th {if $memberInfo.fieldRequired.mailing_zip}class="glm-required"{/if}>Mailing Zip:</th>
+        <td {if $memberInfo.fieldFail.mailing_zip}class="glm-form-bad-input" data-tabid="glm-member-info-contact"{/if}>
+            <input type="text" name="mailing_zip" value="{$memberInfo.fieldData.mailing_zip}" class="glm-form-text-input-short">
+            {if $memberInfo.fieldFail.mailing_zip}<p>{$memberInfo.fieldFail.mailing_zip}</p>{/if}
+        </td>
+    </tr>
+</table>