PETHUB SRI LANKA — PHP + MYSQL WEBSITE
====================================

QUICK START (XAMPP / WINDOWS)
1. Extract this ZIP. Copy the pethub folder into C:\xampp\htdocs\
2. Start Apache and MySQL in XAMPP.
3. Open http://localhost/phpmyadmin
4. Choose Import. Select pethub\database\pethub.sql and click Go.
   The SQL creates the pethub database and its tables. Existing data is not erased.
5. Open pethub\config\config.php in Notepad or VS Code.
   Default local XAMPP settings:
     host = 127.0.0.1, port = 3306, database = pethub,
     username = root, password = blank.
   If your MySQL uses port 3307, change port to 3307.
   If root has a password, enter it in the password field.
6. Copy the setup_key value in the same config file.
7. Open http://localhost/pethub/setup.php
   Paste the setup key and choose your admin name, email and password.
   Admin password must have at least 12 characters. No default admin exists.
8. Sign in using the email/password you just created.
9. Add real content from the admin navigation:
   - Providers: create business details, services, fees and a login account.
     Share those credentials privately with that provider.
   - Adoptions: add a real pet photo, contact person/organisation, city and
     WhatsApp number. Use 0771234567 or +94771234567 for Sri Lankan numbers.
     Other countries: use the full international number with country code.
     Each AVAILABLE listing opens a chat to its own saved number, with a
     message naming that pet. WhatsApp must be registered to that number.
     Reserved/adopted listings do not invite new applications or chats.
     To remove a listing from the public page, set its status to Hidden.
   - Products: add your actual products, prices, stock and photos.
   - Organisations: add real rescue groups, needs and contact information.
   - Settings: enter your actual website help desk contact details.
10. Owners and care providers use Join PetHub to register themselves.
    Providers choose Vet, Groomer, Trainer or Boarding, then enter their
    business and professional details. Their account waits for admin review.
11. Admin opens Providers -> Provider registrations and approves or rejects
    each application. Rejections require a reason shown to the applicant.
    Pending/rejected profiles cannot appear publicly or accept bookings.

SINHALA SETUP SUMMARY
1. ZIP eka extract karala pethub folder eka C:\xampp\htdocs athulata danna.
2. XAMPP eke Apache saha MySQL Start karanna.
3. phpMyAdmin open karala database/pethub.sql Import karanna.
4. config/config.php eke database password saha port hariyata danna.
5. setup_key eka copy karala localhost/pethub/setup.php open karanna.
6. Obage admin email/password ekak hadanna. Demo login ekak naha.
7. Admin eken real adoption pets, WhatsApp numbers, providers, products danna.
8. Website eka localhost/pethub walin open karanna.

WHAT WORKS
- Database-backed registration, password-hashed login, account editing,
  role checks, CSRF protection and sign-in attempt limits.
- Owner pet profiles, photos, vaccination entries and deletion.
- Provider login, appointment acceptance/cancellation/completion and
  availability controls; administrator profile/account management.
- Live date/time availability lookup. Pending and confirmed appointments
  reserve the provider's slot. Concurrent writes are serialized in MySQL.
- Adoption photos, per-listing WhatsApp chat, application submission,
  admin review and adoption status; applicant dashboard tracking.
- Cash-on-delivery shop orders with delivery address and phone, stock
  deduction, fulfilment updates and stock restoration on cancellation.
- Community questions and real replies.
- Reviews from completed appointments, displayed on the provider profile.
- Support pledges, volunteer requests and admin follow-up. A pledge does
  not increase received money. Only an admin marking it Received does.
- Passport codes with 24-hour backend expiry; redemption requires a
  provider/admin login. Owners can access only their own passports.
- Emergency contacts come from administrator-published veterinary records.

PAYMENTS AND CONTACTS
Bookings are paid directly to the provider. Orders use Cash on Delivery.
Support forms record a pledge; arrange transfer directly with the organisation.
This package does not collect card payments or send automatic WhatsApp/email
notifications. The WhatsApp button opens a chat; the visitor sends the message.
Applications and volunteer requests go to the PetHub administrator for review.

DATABASE / DEVELOPMENT
PHP 8.1+ with PDO MySQL, Fileinfo and Sessions; MySQL 8+ or MariaDB 10.4+.
Apache reads the packaged .htaccess files. Make uploads writable by PHP.
The previous local JSON file is removed; no sample people, sample business
contacts, sample orders or default passwords are imported.
The original Pet Town visual design is retained.
Tables are organized by entity (users, pets, providers, appointments, orders,
adoptions, etc.). Each row stores that record as validated JSON in a payload
column, preserving the original project's flexible field structure. Vaccines,
order line items and provider services are nested within their parent record.
This is a small-site persistence layer, not a normalized large-scale schema:
mutations lock app_lock, write entity records transactionally and commit.
A high-traffic service should migrate to targeted row writes and indexed
relational fields before scaling.
Example phpMyAdmin query:
  SELECT JSON_UNQUOTE(JSON_EXTRACT(payload, '$.email')) AS email FROM users;
Do not edit the database payload manually unless you understand the schema.

HOSTING
Upload the pethub folder to a PHP/MySQL host. Create a database and a dedicated
DB user, import the SQL (change/remove CREATE DATABASE and USE statements when
using a host-assigned database), and set config/config.php accordingly.
Use HTTPS, replace the local root DB account with your host's restricted DB
account, verify Apache access rules, keep uploads writable, and remove setup.php
once your admin account exists. Back up BOTH the database and uploads folder.
All real business contacts, prices, verification decisions and images must be
entered by you before inviting customers.

TROUBLESHOOTING
Database not ready: start MySQL; import SQL; check config host/port/password.
Access denied: use the database account/password configured in your MySQL.
Apache port changed: include it in the URL, e.g. localhost:8080/pethub/.
Blank lists: this is a fresh database; publish records from your admin account.
Image upload: only JPG, PNG, WEBP and GIF, at most 5 MB; ensure PHP upload limits
and folder permissions allow it. PHP must have Fileinfo enabled.
WhatsApp wrong recipient: edit that adoption listing's WhatsApp number.
No available booking time: choose another date; reserved slots are disabled.

Organisation self-registration is available through Join PetHub > Organisation.
Admin reviews applications under Organisations; see UPDATE_ORGANISATIONS.txt.
