When configuring the location for an event, users should have the option to either "Create a new location" or "Use an existing location".
NOTE: This is a revised spec / re-implementation of the work initially committed under this issue.
1. In CRM/Event/Form/ManageEvent/Location - replace the Choose Location radio button field (option_type) with a location_option radio button.
- options are "Create new location" and "Use existing location"
- if there are no event locations (e.g. select count(id) from civicrm_event where loc_block_id IS NOT NULL = 0) - then the field is hidden or suppressed (since "Create new location" is the only choice)
- If the event being configured does not have a loc_block_id - default for this field is "Create new location"
- If the event HAS a loc_block_id - default is "Use existing location" AND that location is selected in loc_event_id dropdown
- change onclick behavior for this radio button: location fields (address, phone, email) are never hidden
However, clicking "Use existing ..." should still "show" the loc_event_id dropdown, clicking "Create new ..." hides loc_event_id
2. Modify loc_event_id <select> on this form:
- remove "event title" from the end of the option labels
- option labels are constructed as a :: separate list, following address display format from config, to include the following elements (omit empty elements in the "list"):
$address.name :: $street_address :: $city :: $state_province
3. When a loc_event_id is selected (onchange), use ajax to dynamically load values into all location fields (address, email, phone...). We also want to conditionally notify the user if the selected location is used by one or more active (not disabled) events OTHER than the current event - so the ajax query should return a used-by counter (excluding current event_id). If used by > 0, then we also include a status message div just above address fieldset with the following text:
"This location is used by multiple events. Modifying location information will change values for all events."
4. Modify postProcess for this form:
- if location_option is "create new" - insert address, email, phone, loc_block etc records with form values, insert loc_block record, set event.loc_block_id
- if location_option is "use existing" - set event.loc_block_id, then update the address, email, phone records associated with the selected loc_block using form values
5. Remove ON DELETE CASCADE property from civicrm_event.loc_block_id. Add code to event delete to check if the associated loc_block is used by ANY other events (doesn't matter if they're active or past) [select count(id) from civicrm_event where id != $this->_id AND loc_block_id = $this->_loc_block_id] . If count = 0, then delete the loc_block record.
6. Check if civicrm_loc_block.name is used anywhere in the codebase. If not, drop it from the schema. (We use civicrm.address_name here - so not sure where else loc_bloc.name would be used / needed).
– original post from Elin Waring ----
It would save a lot of typing if the event location field could be entered either through a drop down menu in addition to a fill in the blank field. I suspect that most organizations have certain locations that they use repeatedly.