* Plugin Name: GLM Associate - Events Add-On
* Plugin URI: http://www.gaslightmedia.com/
* Description: Gaslight Media Members Database.
- * Version: 1.7.10
+ * Version: 1.7.11
* Author: Chuck Scott
* Author URI: http://www.gaslightmedia.com/
* License: GPL2
* @package glmMembersDatabaseEventsAddOn
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.7.10
+ * @version 1.7.11
*/
// Check that we're being called by WordPress.
* so that we're sure the other add-ons see an up to date
* version from this plugin.
*/
-define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.7.10');
+define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.7.11');
define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.10');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
var formErrors = [];
{foreach $event.fieldRequired as $fieldName => $fValue}
{if $fieldName != 'status' && $fieldName != 'descr' && $fieldName != 'name_slug'}
- if ( {if $fValue}true{else}false{/if} ) {
- // console.log('{$fieldName}', $('input[name="{$fieldName}"]'));
- // console.log('{$fieldName}.val()', $('input[name="{$fieldName}"]').val());
- if ( !$('input[name="{$fieldName}"]').val() ) {
- formErrors.push('{$fieldName}');
- }
- }
+ if ( {if $fValue}true{else}false{/if} ) {
+ // console.log('{$fieldName}', $('input[name="{$fieldName}"]'));
+ // console.log('{$fieldName}.val()', $('input[name="{$fieldName}"]').val());
+ if ( !$('input[name="{$fieldName}"]').val() ) {
+ formErrors.push('{$fieldName}');
+ }
+ }
{else if $fieldName == 'descr'}
- if ( {if $fValue}true{else}false{/if} ) {
- descr = get_tinymce_content();
- // console.log( 'descr', descr );
- if ( !descr ) {
- formErrors.push('{$fieldName}');
- }
- }
+ if ( {if $fValue}true{else}false{/if} ) {
+ descr = get_tinymce_content();
+ // console.log( 'descr', descr );
+ if ( !descr ) {
+ formErrors.push('{$fieldName}');
+ }
+ }
{/if}
{/foreach}
+
+ // This is for the location if the $settings.michigan_org_requirements is set to true.
+ {if $settings.michigan_org_requirements && $lockedToMember}
+ var hasAddress = false;
+ // If this event is new and location is new.
+ if ( $('#address_nLoc1').length ) {
+ if ( $('#address_nLoc1').val() && $('#city_nLoc1').val() != '0' && $('#state_nLoc1').val() && $('#zip_nLoc1').val()) {
+ hasAddress = true;
+ }
+ }
+ if ( $('.eLocation').length ) {
+ $('.eLocation').each(function(){
+ var locId = $(this).data('id');
+ if ( $('#address_' + locId).val() && $('#city_' + locId).val() != '0' && $('#state_' + locId).val() && $('#zip_' + locId).val()) {
+ hasAddress = true;
+ }
+ });
+ }
+ if ( !hasAddress ) {
+ formErrors.push( 'Location: Address, City, State, ZIP/Postal Code' );
+ }
+ {/if}
+
var numErrors = formErrors.length;
if ( numErrors > 0 ) {
// console.log('formErrors: ', formErrors);
msg += formErrors[i] + "\n";
}
alert(msg);
- // move to first tab
- $('#glm-event-descr').trigger('click');
+ // move to first tab unless location is required.
+ {if $settings.michigan_org_requirements && $lockedToMember}
+ if ( hasAddress ) {
+ $('#glm-event-descr').trigger('click');
+ }
+ {else}
+ $('#glm-event-descr').trigger('click');
+ {/if}
return false;
} else {
return true;
<tr id="location_{$loc.id}" data-id="{$loc.id}" class="location_{$loc.id} location-form">
<td>
<input type="hidden" name="locID[{$loc.id}]" value="Loc{$loc.id}">
- <input type="hidden" name="loc{$loc.id}_id" value="{$loc.id}">
+ <input type="hidden" class="eLocation" data-id="{$loc.id}" name="loc{$loc.id}_id" value="{$loc.id}">
<input type="hidden" name="Loc{$loc.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
<table width="100%">
<tr>
</td>
</tr>
<tr>
- <th>Address:</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>Address:</th>
<td>
<input id="address_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
- <th>City</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>City</th>
<td class="glm-item-container">
<!-- Add new city dialog -->
<div data-id="{$loc.id}" class="button button-secondary glm-right new-city-button">Add a new City</div>
</td>
</tr>
<tr>
- <th>State:</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>State:</th>
<td>
<select id="state_{$loc.id}" data-id="{$loc.id}" class="" name="Loc{$loc.id}_state">
<option value=""></option>
</td>
</tr>
<tr>
- <th>ZIP / Postal Code:</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>ZIP / Postal Code:</th>
<td>
<input id="zip_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium zipcode-input">
</td>
</td>
</tr>
<tr>
- <th>Address:</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>Address:</th>
<td>
<input id="address_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_address" value="{$newLocation.fieldData.address}" class="glm-form-text-input-medium">
</td>
</tr>
<tr>
- <th>City</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>City</th>
<td class="glm-item-container">
<!-- Add new city dialog -->
<div data-id="{ newLocID }" class="button button-secondary glm-right new-city-button">Add a new City</div>
</td>
</tr>
<tr>
- <th>State:</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>State:</th>
<td>
<select id="state_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_state">
{foreach from=$newLocation.fieldData.state.list item=v}
</td>
</tr>
<tr>
- <th>ZIP / Postal Code:</th>
+ <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>ZIP / Postal Code:</th>
<td>
<input id="zip_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_zip" value="{$newLocation.fieldData.zip}" class="glm-form-text-input-medium zipcode-input">
</td>
<tr>
<th>Admin Options</th>
<td>
- <label> <input type="checkbox" name="michigan_org_requirements" {if $eventsSettings.fieldData.michigan_org_requirements.value}checked{/if}> Require URL, Contact email and phone. (Michigan.org)</label><br><br>
+ <label> <input type="checkbox" name="michigan_org_requirements" {if $eventsSettings.fieldData.michigan_org_requirements.value}checked{/if}> Require URL, Contact email, phone and Street Address. (Michigan.org)</label><br><br>
</td>
</tr>