<%# Settings for redmine_qbo_reminders (Administration » Plugins » Configure) %> <% s = RedmineQboReminders::Settings.new(settings) %> <% field = ->(key) { "settings[#{key}]" } %>
<%= l(:label_reminders_sending) %>

<%= hidden_field_tag field.call('enabled'), '0', id: nil %> <%= check_box_tag field.call('enabled'), '1', s.enabled?, id: 'reminders_enabled' %> <%= l(:text_reminders_enabled) %>

<%= text_field_tag field.call('from_name'), s['from_name'], id: 'reminders_from_name', size: 40, placeholder: s['shop_name'] %>

<%= email_field_tag field.call('from_address'), s['from_address'], id: 'reminders_from_address', size: 40, placeholder: Setting.mail_from %> <%= l(:text_reminders_from_address) %>

<%= email_field_tag field.call('reply_to'), s['reply_to'], id: 'reminders_reply_to', size: 40 %> <%= l(:text_reminders_reply_to) %>


<%= text_field_tag field.call('smtp_address'), s['smtp_address'], id: 'reminders_smtp_address', size: 30 %> <%= l(:label_reminders_smtp_port) %> <%= number_field_tag field.call('smtp_port'), s['smtp_port'], id: 'reminders_smtp_port', min: 1, max: 65535, style: 'width: 6em' %> <%= l(:text_reminders_smtp_address) %>

<%= text_field_tag field.call('smtp_domain'), s['smtp_domain'], id: 'reminders_smtp_domain', size: 30, placeholder: s.mail_domain %> <%= l(:text_reminders_smtp_domain) %>

<%= text_field_tag field.call('smtp_user_name'), s['smtp_user_name'], id: 'reminders_smtp_user_name', size: 30, autocomplete: 'off' %>

<%= password_field_tag field.call('smtp_password'), s['smtp_password'], id: 'reminders_smtp_password', size: 30, autocomplete: 'new-password' %> <%= l(:text_reminders_smtp_auth) %>

<%= l(:label_reminders_schedule) %>

<%= number_field_tag field.call('days_before'), s['days_before'], id: 'reminders_days_before', min: 0, max: 14, style: 'width: 4em' %> <%= l(:label_reminders_days_before_at) %> <%= time_field_tag field.call('send_at'), s['send_at'], id: 'reminders_send_at' %> <%= l(:text_reminders_send) %>

<%= time_field_tag field.call('window_start'), s['window_start'], id: 'reminders_window_start' %> – <%= time_field_tag field.call('window_end'), s['window_end'], id: 'reminders_window_end' %> <%= l(:text_reminders_window) %>

<%= number_field_tag field.call('min_lead_hours'), s['min_lead_hours'], id: 'reminders_min_lead_hours', min: 0, max: 48, step: 0.5, style: 'width: 5em' %> <%= l(:label_reminders_hours) %>

<%= select_tag field.call('time_zone'), options_for_select(ActiveSupport::TimeZone.all.map { |z| [z.to_s, z.name] }, s.zone.name), id: 'reminders_time_zone' %> <%= l(:text_reminders_time_zone) %>

<%= hidden_field_tag "#{field.call('statuses')}[]", '', id: nil %> <% CustomerAppointment::STATUSES.each do |status| %> <% end %>

<%= hidden_field_tag field.call('check_on_page_loads'), '0', id: nil %> <%= check_box_tag field.call('check_on_page_loads'), '1', s.check_on_page_loads?, id: 'reminders_check_on_page_loads' %> <%= l(:text_reminders_check_on_page_loads) %>

<%= l(:label_reminders_message) %>

<%= text_field_tag field.call('shop_name'), s['shop_name'], id: 'reminders_shop_name', size: 40 %>

<%= text_field_tag field.call('shop_phone'), s['shop_phone'], id: 'reminders_shop_phone', size: 20 %>

<%= text_field_tag field.call('shop_address'), s['shop_address'], id: 'reminders_shop_address', size: 60 %>

<%= text_field_tag field.call('subject'), s['subject'], id: 'reminders_subject', size: 70 %>

<%= text_area_tag field.call('body'), s['body'], id: 'reminders_body', rows: 14, cols: 70, class: 'reminders-body' %> <%= l(:text_reminders_placeholders) %> <% RedmineQboReminders::Template::PLACEHOLDERS.each do |name| %>{{<%= name %>}} <% end %>
<%= l(:text_reminders_sections) %>

<%= hidden_field_tag field.call('attach_calendar'), '0', id: nil %> <%= check_box_tag field.call('attach_calendar'), '1', s.attach_calendar?, id: 'reminders_attach_calendar' %> <%= l(:text_reminders_attach_calendar) %>

<%= email_field_tag 'email', User.current.mail, id: 'reminders_test_email', size: 30 %> <%= button_tag l(:button_reminders_send_test), type: 'submit', formaction: test_appointment_reminder_path, formmethod: 'post', name: nil, id: 'reminders-send-test' %> <%= l(:text_reminders_test) %>

<%= l(:label_reminders_recent) %> <% recent = AppointmentReminder.recent.includes(customer_appointment: :customer).limit(15) %> <% if recent.empty? %>

<%= l(:label_no_data) %>

<% else %> <% recent.each do |r| %> <% appointment = r.customer_appointment %> <% end %>
<%= l(:label_appointment_reminder_appointment) %> <%= l(:label_reminders_customer) %> <%= l(:field_mail) %> <%= l(:field_status) %> <%= l(:label_reminders_sent_at) %>
<% if appointment %><%= link_to "#{format_time(r.appointment_date)} – #{appointment.subject}", customer_appointment_path(appointment) %><% end %> <%= appointment&.customer&.name %> <%= r.email %> <%= l("label_reminder_status_#{r.status}") %> <% if r.error.present? %>
<%= r.error.truncate(140) %><% end %>
<%= format_time(r.sent_at) if r.sent_at %>
<% end %>

<%= button_tag l(:button_reminders_run), type: 'submit', formaction: run_appointment_reminders_path, formmethod: 'post', name: nil, id: 'reminders-run' %> <%= l(:text_reminders_run) %>

<%= javascript_tag do %> $(function() { // The SMTP server settings only matter when sending through it var toggle = function() { $('#reminders-smtp').toggle($('#reminders_delivery_smtp').is(':checked')); }; $('input[name="settings[delivery]"]').on('change', toggle); toggle(); }); <% end %>