<% if @issues.any? { |i| i.pending? || i.admin_rejected? } %> <% end %>
<% if @customer.customer_name.present? %> <%= @customer.customer_name.first.upcase %> <% else %> <%= @customer.firstname.first.upcase %> <% end %>

<%= @customer.customer_name %>

<% if @customer.verified? %> Approved <% else %> Pending Approval <% end %>

<% if @customer.verified? && @customer.approved_by.present? %> Approved by <%= @customer.approved_by.email %> on <%= @customer.approved_at&.strftime("%d %b %Y %H:%M") %> <% else %> Customer Not Approved <% end %>

<%= @customer.reservations.count %>
Reservations
<%= @customer.proof_of_payments.count %>
Payments
<%= @customer.documents.count %>
Documents
<%= link_to "Edit Customer Details", edit_agent_portal_customer_path(@customer), class: "btn btn-primary rounded-pill px-4 py-2 shadow-sm" %> <%= link_to "Back", agent_portal_customers_path, class: "btn btn-outline-secondary rounded-pill px-4 py-2 shadow-sm" %>
Basic Info
  • ID Number: <%= @customer.idnumber %>
  • Email: <%= @customer.email %>
  • Phone / Mobile: <%= [@customer.phone, @customer.mobile_1, @customer.mobile_2].compact.join(" / ") %>
  • City: <%= @customer.city %>
  • Address: <%= [@customer.address_1, @customer.address_2, @customer.customer_address].compact.join(", ") %>
  • Country: <%= @customer.country %>
  • Stand Number: <%= @customer.stand_number %>
  • Customer Type: <%= @customer.customer_type&.name %>
  • Customer Group: <%= @customer.customer_group&.name %>
  • Individual? <%= @customer.is_individual ? "Yes" : "No" %>
Employment & Financial
  • Employment Type: <%= @customer.employment_type %>
  • Employer Name: <%= @customer.employer_name %>
  • Salary: <%= number_to_currency(@customer.salary) %>
  • Referral: <%= @customer.referral %>
Other Details
  • DOB: <%= @customer.dob %>
  • Sex: <%= @customer.sex ? "Male" : "Female" %>
  • Registration Date: <%= @customer.registration_date %>
  • File Number: <%= @customer.file_number %>
  • VAT Number: <%= @customer.vat_number %>
  • TIN Number: <%= @customer.tin_number %>
  • Prefix No: <%= @customer.prefix_no %>
  • Country Based: <%= @customer.country_based %>
  • API Customer ID: <%= @customer.api_customerid %>
Uploaded Documents (<%= @customer.documents.count %>)
<% if @customer.documents.any? %>
<% @customer.documents.each do |document| %> <% file = document.file %> <% next unless file.attached? %> <% icon_class = if file.image? "fa-file-image text-primary" elsif file.content_type.include?("pdf") "fa-file-pdf text-danger" elsif file.content_type.include?("word") "fa-file-word text-info" elsif file.content_type.include?("excel") || file.content_type.include?("spreadsheet") "fa-file-excel text-success" elsif file.content_type.include?("text") "fa-file-alt text-secondary" else "fa-file text-muted" end %>

<%= document.title.presence || file.filename.to_s %>

<% if file.image? %> <%= image_tag file.variant(resize_to_limit: [300, 300]), class: "img-fluid rounded shadow-sm mb-2 mt-2 cursor-pointer", data: { bs_toggle: "modal", bs_target: "#previewModal-#{document.id}" } %> <% elsif file.content_type.include?("pdf") %>

View PDF Preview

<% else %>

Preview not available for this file type.

<% end %>
<%= link_to "🔍 Preview", "#", class: "btn btn-outline-secondary btn-sm", data: { bs_toggle: "modal", bs_target: "#previewModal-#{document.id}" } %> <%= link_to "⬇ Download", rails_blob_url(file, disposition: "attachment"), class: "btn btn-primary btn-sm", target: "_blank" %>
<% end %>
<% else %>

No documents uploaded yet.

<% end %>

Reservations Summary

<% if @customer.reservations.any? %>
<% @customer.reservations.order(created_at: :desc).each do |r| %>
Property: <%= r.property.property_number %>

Status: <%= r.status.humanize %>

Total Amount: <%= number_to_currency(r.total_amount || 0) %>

Total Paid: <%= number_to_currency(r.amount_paid || 0) %>

Amount Due: <% if r.amount_due.to_f <= 0 %> Fully Paid <% else %> <%= number_to_currency(r.amount_due) %> <% end %>

<%= link_to "View", agent_portal_reservation_path(r), class: "btn btn-outline-primary btn-sm rounded-pill px-3 py-1 shadow-sm" %>
<% end %>
<% else %>
No reservations for this customer yet.
<% end %>
<% if @customer.verified? %>

Upload Proof of Payment

<%= form_with(model: [:agent_portal, @customer, ProofOfPayment.new], local: true, html: { multipart: true }) do |f| %>
<%= f.label :reservation_id, "Reservation", class: "form-label fw-semibold" %> <%= f.collection_select :reservation_id, @customer.reservations.approved.order(created_at: :desc), :id, ->(r) { "##{r.reservation_number} | Property: #{r.property.property_number} | Due: #{number_to_currency(r.amount_due)}" }, { prompt: "Select Reservation" }, class: "form-select rounded-3 shadow-sm", data: { "slim-select-target": "select" }, required: true %>
<%= f.label :file, "Upload Proof of Payment", class: "form-label fw-semibold" %> <%= f.file_field :file, required: true, class: "form-control rounded-3 shadow-sm" %>
<%= f.label :amount, "Amount Paid", class: "form-label fw-semibold" %> <%= f.number_field :amount, step: 0.01, required: true, class: "form-control rounded-3 shadow-sm" %>
<%= f.label :comment, "Comment (optional)", class: "form-label fw-semibold" %> <%= f.text_area :comment, rows: 2, class: "form-control rounded-3 shadow-sm" %>
<%= f.submit "Upload", data: { turbo: false }, class: "btn btn-primary rounded-pill px-4 py-2" %> <% end %>
<% if @customer.proof_of_payments.any? %>

Proofs of Payment

<% @customer.proof_of_payments.order(created_at: :desc).each do |pop| %>
<%= link_to pop.file.filename.to_s, rails_blob_path(pop.file, disposition: "attachment"), target: "_blank", class: "text-decoration-none text-dark" %>

Reservation: <%= pop.reservation&.reservation_number || "N/A" %>

Amount Paid: <%= number_to_currency(pop.amount || 0) %>

<% if pop.comment.present? %>

<%= pop.comment %>

<% end %>

Uploaded by: <%= pop.uploaded_by.full_name %> at <%= pop.created_at.strftime("%d-%b-%Y %H:%M") %>

<%= link_to "⬇ Download", rails_blob_url(pop.file, disposition: "attachment"), class: "btn btn-outline-primary btn-sm rounded-pill px-3 py-1", target: "_blank" %>
<% end %>
<% else %>
No proofs uploaded yet.
<% end %>
<% else %>
Customer is not verified yet. Proof of payment upload unavailable.
<% end %>
<% if @customer.representatives.any? %>
<% @customer.representatives.each do |rep| %>
Representative: <%= rep.firstname %> <%= rep.lastname %>
  • Firstname: <%= rep.firstname %>
  • Lastname: <%= rep.lastname %>
  • Relationship: <%= rep.relationship %>
  • ID Number: <%= rep.id_number %>
Uploaded Documents (<%= rep.documents.count %>)
<% if rep.documents.any? %>
<% rep.documents.each do |document| %> <% file = document.file %> <% next unless file.attached? %> <% icon_class = if file.image? "fa-file-image text-primary" elsif file.content_type.include?("pdf") "fa-file-pdf text-danger" elsif file.content_type.include?("word") "fa-file-word text-info" elsif file.content_type.include?("excel") || file.content_type.include?("spreadsheet") "fa-file-excel text-success" elsif file.content_type.include?("text") "fa-file-alt text-secondary" else "fa-file text-muted" end %>

<%= document.title.presence || file.filename.to_s %>

<% if file.image? %> <%= image_tag file.variant(resize_to_limit: [300, 300]), class: "img-fluid rounded shadow-sm mb-2 mt-2 cursor-pointer", data: { bs_toggle: "modal", bs_target: "#previewModal-#{document.id}" } %> <% elsif file.content_type.include?("pdf") %>

View PDF Preview

<% else %>

Preview not available for this file type.

<% end %>
<%= link_to "🔍 Preview", "#", class: "btn btn-outline-secondary btn-sm", data: { bs_toggle: "modal", bs_target: "#previewModal-#{document.id}" } %> <%= link_to "⬇ Download", rails_blob_url(file, disposition: "attachment"), class: "btn btn-primary btn-sm", target: "_blank" %>
<% end %>
<% else %>

No documents uploaded for this representative.

<% end %>
<% end %>
<% end %>
<% if @customer.next_of_kins.any? %>
Next of Kin
<% @customer.next_of_kins.each do |nok| %> <% end %>
Name Relation Mobile Email Immediate? Active?
<%= [nok.firstname, nok.middlename, nok.lastname].compact.join(" ") %> <%= nok.relation %> <%= nok.mobile_1 %> <%= nok.email %> <%= nok.immediate ? "Yes" : "No" %> <%= nok.active ? "Yes" : "No" %>
<% end %>

Pending Verification Issues

<% if @issues.any? %>
<% @issues.each do |issue| %>
<%= issue.title %>

<%= issue.description %>

<% if issue.document&.file&.attached? %> (<%= link_to "View Document", rails_blob_path(issue.document.file, disposition: "attachment"), target: "_blank", class: "text-decoration-underline" %>) <% end %> <% if issue.admin_rejected? %>

⚠ Admin rejected resolution: <%= issue.admin_note %>

<% end %>
<% if !issue.resolved? || issue.admin_rejected? %> <%= button_to "Mark Resolved", resolve_agent_portal_customer_customer_verification_issue_path(@customer, issue), method: :patch, class: "btn btn-sm btn-success rounded-pill px-3", data: { turbo: false } %> <% else %> ✅ Resolved <% end %>
<% end %>
<% else %>

No pending verification issues.

<% end %>
<% resolved_issues = @issues.select(&:resolved?) %> <% if resolved_issues.any? %>

Resolved Verification Issues

<% resolved_issues.each do |issue| %>
<%= issue.title %>

<%= issue.description %>

<% if issue.document&.file&.attached? %> (<%= link_to "View Document", rails_blob_path(issue.document.file, disposition: "attachment"), target: "_blank", class: "text-decoration-underline" %>) <% end %>
✅ Resolved
<% end %>
<% end %>