nhance/public/dev_logs/2026-03-24.md
2026-03-31 12:04:35 +05:30

4.5 KiB

Dev Log — 2026-03-24

Feature: Non EB Terms & Non EB Rack Rate in Client Policy List

Objective

Introduce "Non EB Terms" and "Non EB Rack Rate" menu items in the client policy table hamburger dropdown. These menus replace the existing "Terms" and "Rack Rate" menus when the policy type's allocg field is Non-EB or Marine.


Files Changed

1. app/Models/ClientPolicyModel.php

  • getClientPolicyByClientId() — Added two new selects:
    • policy_type.allocg as allocg (policy_type table was already joined)
    • leads.misc as lead_misc (leads table was already joined via client_policy.is_from_lead = leads.id)
  • $allowedFields — Added non_eb_rack_rate_files to allow updating the new JSON column.

2. app/Controllers/ClientController.php

  • editClientOnboarding() — Added allocg and lead_misc to the policy data mapping array passed to the view.
  • Added 3 new methods:
    • getNonEbRackRateFiles() — GET endpoint, reads non_eb_rack_rate_files JSON from client_policy table and returns parsed file list.
    • uploadNonEbRackRateFile() — POST endpoint, uploads file to writable/uploads/non_eb_rack_rate/, appends file entry to non_eb_rack_rate_files JSON column.
    • removeNonEbRackRateFile() — POST endpoint, removes file entry from JSON column and deletes physical file from disk.

3. app/Config/Routes.php

  • Added 3 new routes under client/policy group:
    • GET getNonEbRackRateFiles
    • POST uploadNonEbRackRateFile
    • POST removeNonEbRackRateFile

4. app/Config/Constants.php

  • Added UPLOAD_EXT_NON_EB_RACK_RATE constant: ['pdf', 'xls', 'xlsx']

5. app/Views/client_policy.php

  • Dropdown menus (4 locations: ~lines 530, 808, 2596, 2642):
    • Added allocg check: item.allocg === 'Non-EB' || item.allocg === 'Marine'
    • If true → shows "Non EB Terms" + "Non EB Rack Rate", hides "Terms" + "Rack Rate"
    • If false → shows "Terms" + "Rack Rate" (original behavior)
  • Non EB Terms click handler (btnNonEbTerms):
    • Parses lead_misc JSON from data attribute
    • If placement_sheet_id key exists → opens Google Sheet (https://docs.google.com/spreadsheets/d/{id}) in new tab
    • Otherwise → alert('No terms found')
  • Non EB Rack Rate click handler (btnNonEbRackRateModal):
    • Opens #nonEbRackRateModal using new bootstrap.Modal() (BS5 API, stored on window._nonEbModal)
    • Loads existing files via AJAX getNonEbRackRateFiles
  • Upload handler (#btnUploadNonEbFile):
    • Validates file extension (pdf/xlsx/xls) client-side
    • Uploads via AJAX uploadNonEbRackRateFile with FormData
    • Appends uploaded file to list on success
  • Delete handler (btnRemoveNonEbFile):
    • SweetAlert confirmation
    • Calls removeNonEbRackRateFile via AJAX
    • Removes file row from DOM on success

6. app/Views/client_onboarding.php

  • Added modal HTML (#nonEbRackRateModal) at line ~457, placed outside tab-pane containers (same level as autoFetchBranchModal) to avoid Bootstrap stacking issues.
  • Scoped CSS for compact modal: forced max-width: 420px, min-height: auto on modal-body, reduced padding on header/body/footer.
  • Close buttons use onclick="if(window._nonEbModal) window._nonEbModal.hide();" — inline JS referencing the global BS5 Modal instance to avoid jQuery binding/timing issues.

7. app/Controllers/EmployeeRestController.php

  • Line ~2257 query — Added LEFT JOIN with policy_type table and a CASE WHEN select:
    CASE WHEN policy_type.allocg IN ('Non-EB', 'Marine') THEN 'Non-EB' ELSE 'EB' END as allocg
    

DDL Required (Manual)

ALTER TABLE `client_policy` ADD COLUMN `non_eb_rack_rate_files` JSON NULL DEFAULT NULL AFTER `wellness_vendor_id`;

Key Technical Decisions

  • Bootstrap version conflict: Project loads BS5 via vendor.min.js and BS3.4.1 via footer CDN. $.fn.modal() uses BS3 (broken), so all modal operations use new bootstrap.Modal() (BS5 native API). Modal instance stored on window._nonEbModal for close button access.
  • Modal placement: Modal HTML must be outside tab-pane containers in client_onboarding.php to avoid visibility/stacking issues.
  • File storage: Rack rate files stored physically in writable/uploads/non_eb_rack_rate/ and tracked as JSON array in client_policy.non_eb_rack_rate_files column. Each entry: {name, original_name, type, uploaded_at}.
  • Menu visibility: Driven by policy_type.allocg field — Non-EB/Marine shows Non EB menus, everything else shows standard Terms/Rack Rate menus.