5.5 KiB
5.5 KiB
Copilot Instructions
Project shape
- Legacy PHP 5.x site generated with Artisteer templates; public pages live at the repo root (
index.php,home.php, etc.) and sharestyle.css,script.js, andmenumain.php/menugrower.phpincludes for navigation. - Grower self-service lives under
grower-login.phpand per-grower folders ingrowers/(e.g.growers/999/). Each grower folder wraps shared includes but serves files and PDF listings viadtrlist.php. - Reporting utilities are under
loaddata/, mixing PHP views with SQL Server queries. Shared helper includes, credentials, and menu snippets sit ininc/. lasucadev/contains vendor-style experiments (e.g.ping/) that normally stay untouched; treat as third-party source.- Modernized theme assets live under
inc/theme-header.php,inc/theme-footer.php, andinc/theme-toggle.php; they pull in Bootstrap-based styles fromnew/css/and behaviour fromnew/js/scripts.js. - Custom styling bundles include
new/css/lasuca-theme.cssfor global look-and-feel,new/css/grower-portal.cssfor authenticated pages, andnew/css/farmdata.cssfor the load-data explorer.
Recent updates
- Grower portal pages (
grower-dashboard.php,grower-files.php,grower-account.php, etc.) now use the shared theme header/footer, the protected navigation, and quick-link tiles; keep using those includes for any new grower tools. - The dashboard greeting reads from the
growernamecolumn; profile edits persist viaauth_update_profile. Avoid reverting to the oldfirstnamefallback. - Factory data cards on the dashboard reuse the query logic from
milldata.php; ensure any future tweaks go through the shared helper ininc/grower_dashboard.php. - A light/dark mode toggle is available site-wide through
inc/theme-toggle.phpandnew/js/scripts.js, persisting state vialocalStorageand body classes (theme-darkdefault,theme-lightoverride). - Branding updates place
images/header.pngbehind the navbar, add subtle drop shadows, and give the logo depth—mirror that pattern if new headers are introduced. farmdata/index.phphas been rebuilt with the new theme, richer filters (grower, crop day, vehicle, tract, load, overload threshold), query helpers, and SQLSRV stubs for environments lacking the driver.
Runtime & tooling
- Target PHP ≤5.6: the code relies on deprecated
mysql_*APIs and short open tags in places (<?). Do not replace withmysqli/PDO unless coordinating a full migration. - Development happens by serving the repo root through Apache/PHP or via
php -S localhost:8000(requires thesqlsrvextension and Microsoft drivers if exercising scale reports). - There are no automated tests; validate changes by hitting the relevant PHP endpoint in a browser.
Application flows
- Public site: static-like pages include
menumain.phpand echo content blocks. Follow the pattern inindex.phpwhen adding pages. - Grower portal:
grower-login.phpauthenticates against thescdb.memberstable and redirects to a directory matching the username. Any new grower assets must be placed inside that username folder and linked throughdtrlist.phporloads.php. - Load data reports (
loaddata/index.php) connect to SQL Server (CBM2K12\SQLEXPRESS, databaseSugarCaneScale) and display tabular results while accumulating totals. Reuse that query pattern when adding filters or exports.
Data access patterns
- MySQL credentials live in
inc/dbconfig.phpand are consumed byinc/opendb.php; pages using MySQL typicallyincludeboth and callmysql_query. Maintain that include order so globals ($dbhost,$dbuser, …) are defined. - SQL Server access always happens inline with
sqlsrv_connect+sqlsrv_query(seeloaddata/index.php). Remember to free statements and close connections when you introduce long-running loops. - Directory-based reports rely on
inc/dtrlistconfig.phpandinc/dtrlistfunctions.php; expose new report folders by placing files under the appropriategrowers/<id>/<year>/path and lettingdtrlist.phppick them up.
UI conventions
- Theme pages should load through
inc/theme-header.php/inc/theme-footer.php, which already enqueue Bootstrap, the theme palette, and the light/dark toggle. Only fall back to Artisteer layouts when touching untouched legacy pages. - Prefer the utility classes defined in
new/css/lasuca-theme.cssandnew/css/grower-portal.cssbefore adding inline styles. When legacy Artisteer selectors such as thevtitleID remain, leave them in place until that page is fully migrated. - Front-end behaviour now lives primarily in
new/js/scripts.js; keep scripts simple, avoid module loaders, and update the toggle helpers if you add new theme-aware widgets.
Security & legacy quirks
- Session gating uses
$_SESSION['ena']alone (session.php); when adding new protected pages, include that file first to preserve the redirect-on-failure behavior. - Input sanitization is minimal (manual
mysql_real_escape_string); mimic the existing approach and note any improvements separately rather than mixing refactors into feature work. - Credentials are hard-coded throughout; do not rotate them casually—coordinate with ops and document any changes prominently.
When in doubt
- Mirror the structure of a neighboring file before introducing new patterns.
- Keep compatibility front-of-mind: new PHP features or libraries can break production if the runtime remains on PHP 5.x.
- Document any new data sources, includes, or cron assumptions inside this file so future agents stay oriented.