Files
plottservice/app/views/operator/jobs/_job_tr.html.erb
2024-10-02 13:51:15 +02:00

105 lines
5.3 KiB
Plaintext

<tr id="<%= dom_id job %>" class="bg-status-<%= job.status %>-light odd:bg-opacity-25 even:bg-opacity-10 text-hsrm-gray whitespace-nowrap hover:bg-opacity-30" data-stream-enter-class="animate-flash-increase">
<td class="p-2 py-3 text-center">
<%= link_to operator_job_path(job) do %>
<span class="badge badge-xl text-status-<%= job.status %> bg-status-<%= job.status %>-light">
<%= job.id %>
</span>
<% end %>
</td>
<td class="p-2 py-3 text-center">
<% if job.pdf.attached? && job.pdf.previewable? %>
<%= link_to_if job.printing?, image_tag(url_for(job.pdf.preview(resize_to_limit: [100, 100])), class:"shadow-lg"), job.pdf, target: "_blank" %>
<!--<iframe src=<%= url_for(job.pdf) %> width="500" height="700" style="border: none;"></iframe>-->
<% end %>
</td>
<td class="p-2 py-3">
<%= job.customer_fullname %>
</td>
<td class="p-2 py-3">
<% if job.pdf.attached? %>
<%#= link_to job.pdf.filename, rails_blob_path(job.pdf, disposition: "attachment") %>
<%= link_to_if job.printing?, truncate(job.pdf.filename.to_s, length: 45), job.pdf, download:true %>
<% if job.printing? %>
<%= link_to job.pdf, download:true do %>
<span class="badge badge-hover">
<%= icon("document-arrow-down", class: "text-hsrm-gray size-6 inline", title: "Download") %>
<%=number_to_human_size job.pdf.blob.byte_size%>
</span>
<% end %>
<% end %>
<% end %>
</td>
<% Job::AVAILABLE_PAGE_FORMATS.each do |din| %>
<td class="p-1 py-3">
<% if job.printing? %>
<div class="flex flex-col items-center">
<span class="p-1 badge badge-hover">
<%= button_to icon("plus", class: "size-5 inline", title: "erhöhen"), increment_page_operator_job_path(job, din:), method: :patch, form_class: "inline" %>
</span>
<% end %>
<span class="badge">
<%= job.public_send("number_of_plans_#{din}") if job.respond_to? "number_of_plans_#{din}" %>
</span>
<% if job.printing? %>
<span class="p-1 badge badge-hover">
<%= button_to icon("minus", class: "size-5 inline", title: "verringern"), decrement_page_operator_job_path(job, din:), method: :patch, form_class: "inline" %>
</span>
</div>
<% end %>
</td>
<% end %>
<td class="p-2 py-3 text-right">
<% if job.printing? %>
<%= link_to edit_operator_job_path(job) do %>
<span class="badge badge-hover">
<%= number_with_delimiter job.costum_qm_plan.round(2) %> m²
</span>
<% end %>
<% else %>
<span class="badge">
<%= number_with_delimiter job.costum_qm_plan.round(2) %> m²
</span>
<% end %>
</td>
<td class="w-24 p-2 py-3 text-right">
<span class="badge">
<%= number_to_currency job.cost, locale: :de %>
</span>
</td>
<td class="p-2 py-3">
<span class="badge badge-status text-status-<%= job.status.to_sym %> bg-status-<%= job.status %>-light">
<%= job.status %>
</span>
</td>
<td class="p-2 py-3 text-right">
<!-- TODO: move logic to model -->
<% if job.printing? || job.canceled? || job.paid? %>
<%= button_to icon(status_icon(:open), class: "icon icon-hover", title: "Zurück in die Warteschlange"), operator_job_path(job), method: :patch, params: {:job => {status: :open}}, form_class: "inline" %>
<% else %>
<%= icon(status_icon(:open), class: "icon icon-disabled", title: "") %>
<% end %>
<% if job.open? || job.canceled? || job.paid? %>
<%= button_to icon(status_icon(:printing), class: "icon icon-hover", title: "Drucken"), operator_job_path(job), method: :patch, params: {:job => {status: :printing}}, form_class: "inline" %>
<% else %>
<%= icon(status_icon(:printing), class: "icon icon-disabled", title: "") %>
<% end %>
<% if job.printing? || job.paid? %>
<% job.printing? && turbo_confirm = 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?' %>
<%= button_to icon(status_icon(:pickup), class: "icon icon-hover", title: "Pläne sind fertig gedruckt und bereit abgeholt zu werden."), operator_job_path(job), method: :patch, params: {:job => {status: :pickup}}, form: {data: {turbo_confirm: turbo_confirm}}, form_class: "inline" %>
<% else %>
<%= icon(status_icon(:pickup), class: "icon icon-disabled", title: "") %>
<% end %>
<% if job.pickup? || job.printing? %>
<% job.printing? && turbo_confirm = 'Sind die Pläne gedruckt und die Seitenanzahl und QM korrekt?' %>
<%= button_to icon(status_icon(:paid), class: "icon icon-hover", title: "Bezahlt und abgeholt"), operator_job_path(job), method: :patch, params: {:job => {status: :paid}}, form: {data: {turbo_confirm: turbo_confirm}}, form_class: "inline" %>
<% else %>
<%= icon(status_icon(:paid), class: "icon icon-disabled ", title: "") %>
<% end %>
<% if job.open? || job.printing? || job.pickup? %>
<%= button_to icon(status_icon(:canceled), class: "icon icon-hover text-hsrm-red", title: "Abbrechen"), operator_job_path(job), method: :patch, params: {:job => {status: :canceled}}, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %>
<% else %>
<%= icon(status_icon(:canceled), class: "icon icon-disabled", title: "Kann nicht mehr abgebrochen werden") %>
<% end %>
</td>
</tr>