mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-10-04 04:40:43 -04:00
Add customer show hook to display upcoming appointments and refactor appointment list rendering
This commit is contained in:
1 parent
048b7d4198
commit
3c65700b52
5 files changed
+172
-73
No files matched your search
@@ -0,0 +1,73 @@
|
|||||||
|
<table class="list">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th><%= l(:label_customer) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_vehicle) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_appointment) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_user) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_date) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_status) %></th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<% appointments.each do |appointment| %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= link_to appointment.customer unless appointment.customer.nil? %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= link_to appointment.vehicle unless appointment.vehicle.nil? %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= link_to appointment %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= link_to appointment.user unless appointment.user.nil? %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= format_date(
|
||||||
|
appointment.date
|
||||||
|
) %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= appointment.status %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<table class="list">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th><%= l(:label_appointment) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_user) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_date) %></th>
|
||||||
|
|
||||||
|
<th><%= l(:label_status) %></th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<% appointments.each do |appointment| %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= link_to appointment %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= link_to appointment.user unless appointment.user.nil? %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= format_date(
|
||||||
|
appointment.date
|
||||||
|
) %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= appointment.status %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
@@ -11,76 +11,4 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="list">
|
<%= render partial: "list", locals: { appointments: @appointments } %>
|
||||||
|
|
||||||
<thead>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<th><%= l(:label_customer) %></th>
|
|
||||||
|
|
||||||
<th><%= l(:label_vehicle) %></th>
|
|
||||||
|
|
||||||
<th><%= l(:label_appointment) %></th>
|
|
||||||
|
|
||||||
<th><%= l(:label_user) %></th>
|
|
||||||
|
|
||||||
<th><%= l(:label_date) %></th>
|
|
||||||
|
|
||||||
<th><%= l(:label_status) %></th>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
<% @appointments.each do |appointment| %>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= link_to appointment.customer unless appointment.customer.nil? %>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= link_to appointment.vehicle unless appointment.vehicle.nil? %>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= link_to appointment %>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= link_to appointment.user unless appointment.user.nil? %>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= format_date(
|
|
||||||
appointment.date
|
|
||||||
) %>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= appointment.status %>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
@@ -18,5 +18,6 @@ module RedmineQboCalendar
|
|||||||
# Hooks
|
# Hooks
|
||||||
RedmineQboCalendar::Hooks::ViewHookListener
|
RedmineQboCalendar::Hooks::ViewHookListener
|
||||||
RedmineQboCalendar::Hooks::CustomerActionsHookListener
|
RedmineQboCalendar::Hooks::CustomerActionsHookListener
|
||||||
|
RedmineQboCalendar::Hooks::CustomerShowHookListener
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2016 - 2026 rick barrette
|
||||||
|
#
|
||||||
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
module RedmineQboCalendar
|
||||||
|
module Hooks
|
||||||
|
|
||||||
|
class CustomerShowHookListener < Redmine::Hook::ViewListener
|
||||||
|
|
||||||
|
include IssuesHelper
|
||||||
|
|
||||||
|
# Display vehicle information on the customer show view (right side)
|
||||||
|
def show_customer_view_right(context={})
|
||||||
|
log "show_customer_view_right called"
|
||||||
|
|
||||||
|
customer = context[:customer]
|
||||||
|
appointments = customer.customer_appointments.where('date >= ?', Date.today).order(date: :asc)
|
||||||
|
|
||||||
|
return if appointments.nil?
|
||||||
|
|
||||||
|
context[:controller].send(:render_to_string, {
|
||||||
|
partial: 'customer_appointments/list_simple', locals: { appointments: appointments }
|
||||||
|
})
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def log(msg)
|
||||||
|
Rails.logger.info "[CustomerShowHookListener] #{msg}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in new issue
Block a user