fix – appointment limit calculation
Hi - we found a problem where adding attendee limits for services was behaving badly. There is an SQL logic issue in get_attendants_number_for_period() which should have an extra group_start()/group_end() pair and read:
public function get_attendants_number_for_period(DateTime $slot_start, DateTime $slot_end, $service_id)
{
return (int)$this->db
->select('count(*) AS attendants_number')
->from('ea_appointments')
->group_start()
->group_start()
->where('start_datetime <=', $slot_start->format('Y-m-d H:i:s'))
->where('end_datetime >', $slot_start->format('Y-m-d H:i:s'))
->group_end()
->or_group_start()
->where('start_datetime <', $slot_end->format('Y-m-d H:i:s'))
->where('end_datetime >=', $slot_end->format('Y-m-d H:i:s'))
->group_end()
->group_end()
->where('id_services', $service_id)
->get()
->row()
->attendants_number;
} Regards,
Malcolm
{
return (int)$this->db
->select('count(*) AS attendants_number')
->from('ea_appointments')
->group_start()
->group_start()
->where('start_datetime <=', $slot_start->format('Y-m-d H:i:s'))
->where('end_datetime >', $slot_start->format('Y-m-d H:i:s'))
->group_end()
->or_group_start()
->where('start_datetime <', $slot_end->format('Y-m-d H:i:s'))
->where('end_datetime >=', $slot_end->format('Y-m-d H:i:s'))
->group_end()
->group_end()
->where('id_services', $service_id)
->get()
->row()
->attendants_number;
} Regards,
Malcolm