This is the easiest and most minimal way, I could think to add location support without adding a Locations_model, view, database table, etc...
Create services with locations (ex: haircut @ chair 1) or just create a new service for a location (ex: Room 1 @ Room 1) then change the appointment view to show a select box for all predefined service locations
.
<from installation root directory>
in `/application/views/backend/calendar.php`
remove line for text input
`<input id="appointment-location" class="form-control">`
replace with service location select field
`
<select id="appointment-location" class="required form-control">
<?php
// Place all service locations in a select field
// sort and remove duplicates
foreach ($available_services as $service)
{
$available_locations[] = $service['location'];
}
$available_locations = array_unique($available_locations);
foreach ($available_locations as $location)
{
echo '<option value="' . $location . '">'
. $location . '</option>';
}
?>
</select>
`
If you want to prevent duplicate appointment entry for the same location at a given time. Adjust the `Appointments_model` `validate($appointment)` function to check for it before it adds an appointment to the database.
in `/application/models/Appointments_model.php`
add validation code to this old code
`
if ($num_rows === 0)
{
throw new Exception('Appointment service id is invalid.');
}
<----- NEW CODE GOES IN THIS LINE SPACE---->
}
`
This is the new code to add
`
// Check if the location is in use.
$num_rows = $this->db
->select('*')
->from('appointments')
->where('start_datetime <=', $appointment['start_datetime'])
->where('end_datetime >=', $appointment['start_datetime'])
->where('location', $appointment['location'])
->get()->num_rows();
if ($num_rows !== 0)
{
throw new Exception('That location has an unfinished event.');
}
$num_rows = $this->db
->select('*')
->from('appointments')
->where('start_datetime <=', $appointment['end_datetime'])
->where('end_datetime >=', $appointment['end_datetime'])
->where('location', $appointment['location'])
->get()->num_rows();
if ($num_rows !== 0)
{
throw new Exception('That location has an upcoming event.');
}
`
Remember your appointment locations cant overlap at all so it is best to change your reduce your services by 1 minute (ex: prior 60 min to 59 min duration)
With this mod you can maintain a 100% compatible install and database with the official release.
if you want to see the code or download it via git clone I have put it on my github here.