diff --git a/README.md b/README.md index 190df2e..9fccf5d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Emails customers a reminder before their appointments in [redmine_qbo_calendar](https://github.com/rickbarrette/redmine_qbo_calendar), at the email address on their QuickBooks Online customer ([redmine_qbo](https://github.com/rickbarrette/redmine_qbo)). The email comes from your own mailbox (for example sales@yourdomain.com through Google Workspace), so there's nothing extra to pay for, and customers can reply to confirm or reschedule. * **When**: a set number of days before the appointment at a set time (default: the day before at 4 PM), only between set hours (default 8 AM–8 PM), and not within a set number of hours of the appointment (default 2). An appointment booked after its reminder time gets one right away. Rescheduling an appointment sends a reminder for the new time. -* **Which**: appointments with the chosen statuses (default: Scheduled), with a customer who has an email address in QuickBooks and hasn't had reminders turned off. +* **Which**: appointments with the chosen statuses (default: Scheduled; the statuses are set up in redmine_qbo_calendar's settings), not employee call-outs, with a customer who has an email address in QuickBooks and hasn't had reminders turned off. * **What**: a short plain-text and HTML email in your words (placeholders for the customer, vehicle, day, time and shop details), with the appointment attached as a calendar file. A footer says why they got it and to reply if they'd rather not get reminders. * **Appointment page**: whether the reminder was sent (when, to whom), when it will be, or why it won't be, with **Send now** / **Send again**. * **Customer page**: turn reminders off (or back on) for a customer. diff --git a/app/views/appointment_reminders/_appointment.html.erb b/app/views/appointment_reminders/_appointment.html.erb index e29d42d..91477c1 100644 --- a/app/views/appointment_reminders/_appointment.html.erb +++ b/app/views/appointment_reminders/_appointment.html.erb @@ -1,6 +1,7 @@ <%# The reminder's status on an appointment's page (redmine_qbo_calendar's show_customer_appointment hook) %> <% appointment = local_assigns[:appointment] %> -<% if appointment %> +<%# Not on an employee's call-out (redmine_qbo_calendar), which has no customer to remind %> +<% if appointment && !(appointment.respond_to?(:call_out?) && appointment.call_out?) %> <% rs = RedmineQboReminders::ReminderStatus.for(appointment) %> <% can_send = User.current.allowed_to?(:send_appointment_reminders, nil, global: true) %>
<%= hidden_field_tag "#{field.call('statuses')}[]", '', id: nil %> - <% CustomerAppointment::STATUSES.each do |status| %> + <%# The statuses set up in redmine_qbo_calendar's settings (older versions had a fixed list) %> + <% status_options = CustomerAppointment.respond_to?(:status_options) ? CustomerAppointment.status_options : CustomerAppointment::STATUSES.map { |st| [st.humanize, st] } %> + <% status_options.each do |label, status| %> <% end %>
diff --git a/lib/redmine_qbo_reminders/sender.rb b/lib/redmine_qbo_reminders/sender.rb index c9749a9..1e652e9 100644 --- a/lib/redmine_qbo_reminders/sender.rb +++ b/lib/redmine_qbo_reminders/sender.rb @@ -37,7 +37,8 @@ module RedmineQboReminders return result unless schedule.in_window?(now) from, to = schedule.lookahead(now) - CustomerAppointment.where(date: from..to).includes(:customer).find_each do |appointment| + # Customer appointments only: employee call-outs (redmine_qbo_calendar) are kept in the same table + CustomerAppointment.where(date: from..to, event_type: [nil, '']).includes(:customer).find_each do |appointment| consider(appointment, schedule) end log "Run finished: #{result}" if result.sent + result.failed > 0