Azure D365 Customers Tab Fix
===========================

This ZIP contains the fixed Customers API and JavaScript handling.

What was fixed
--------------
1. public_html/d365_portal/api/customers.php
   - Now checks table columns dynamically.
   - Returns clear JSON errors instead of silent empty responses.
   - Returns both ok=true and success=true for compatibility.
   - Works even if optional columns are missing.

2. public_html/d365_portal/assets/js/app.js
   - Handles API errors safely.
   - Supports rows/data response formats.
   - Shows console errors if API fails.

3. public_html/d365_portal/customers.php
   - Checks if app.js is loaded before starting the customer grid.

4. public_html/d365_portal/api/debug_customers.php
   - New debug endpoint to confirm table count, columns and one sample row.

Upload instructions
-------------------
1. Backup your existing d365_portal folder and d365_private folder.
2. Upload/replace the contents of public_html/d365_portal from this ZIP.
3. Upload/replace d365_private/config.php only if you want to use the included config.
4. Clear browser cache with Ctrl + F5.

Important test URLs
-------------------
Open these after upload:

https://YOURDOMAIN.com/d365_portal/api/debug_customers.php
https://YOURDOMAIN.com/d365_portal/api/customers.php?page=1&pageSize=10
https://YOURDOMAIN.com/d365_portal/customers.php

If debug_customers.php shows count 95574 but customers.php is blank, open browser Developer Tools > Console and check the JavaScript error.

Security reminder
-----------------
The included config may contain test credentials. After confirming the portal works, change your Azure API key and Azure SQL password, then update d365_private/config.php and Azure App Service environment variables.
