NCAP - Nesatech Central Admission Portal
=========================================

Three portals in one system:
  1. Applicants   - search schools, apply to one or many, upload documents, pay, track, accept offers
  2. Schools      - register, set programmes/fees/dates/places, review, shortlist, offer, export lists
  3. Nesatech     - approve schools, subscriptions and charges, revenue, reports, ads, content, system

---------------------------------------------------------------
A. INSTALL ON UBUNTU (own server / VPS)
---------------------------------------------------------------
  unzip ncap.zip
  cd ncap
  sudo bash install.sh

The script installs Apache, MariaDB and PHP, copies the files to /var/www/html/ncap,
creates the database ncap_db with its own password, and adds the daily job.
Open:  http://your-server/ncap/

Update later (data, settings and uploads are kept, a backup is made first):
  sudo bash update.sh /path/ncap.zip

---------------------------------------------------------------
B. INSTALL ON cPANEL HOSTING
---------------------------------------------------------------
 1. File Manager: upload ncap.zip to public_html (or a sub-folder) and Extract.
 2. MySQL Databases: create a database and a user, give the user ALL PRIVILEGES.
 3. phpMyAdmin: select the database -> Import -> database/ncap_db.sql
 4. Edit application/config/database.php: put the database name, user and password.
 5. Folders uploads/logos, uploads/ads, uploads/private, application/cache and
    application/logs must be writable (755 is usually enough on cPanel).
 6. PHP version 8.1 or newer (Select PHP Version). Extensions: mysqli, mbstring, gd, curl.
 7. Cron Jobs: add once a day:
      15 0 * * *  php /home/USER/public_html/ncap/index.php cli daily
    (expires offers past their deadline; on the 1st of the month makes the bills to schools)

---------------------------------------------------------------
C. FIRST LOGIN
---------------------------------------------------------------
  Nesatech admin:  nesatech  /  Nesatech@2026
  You must choose a new password at once.
  Forgot it on the server?   php index.php cli nesatech_password

Then go to Nesatech -> Settings:
  - platform name, phone, email, admission year
  - charge per application, commission %, monthly / yearly plan, trial days
  - payment instructions shown to applicants and schools (M-Pesa / Tigo Pesa / bank)
  - SMS gateway (username, key, sender ID) and press "Send test SMS"

Schools register themselves at  /join  (with their registration certificate).
They can prepare their profile and programmes, but nothing is public until Nesatech approves them.
Applicants register at  /register  with their phone number.

---------------------------------------------------------------
D. HOW FEES AND CHARGES WORK
---------------------------------------------------------------
 - The applicant pays the school's application fee by mobile money or bank and types the
   reference number. The school checks its statement and confirms or rejects it.
   An offer can only be made after the fee is confirmed.
 - Nesatech charges each school per submitted application (+ % of the fee, if set)
   and/or a monthly or yearly subscription. Bills are made on the 1st of each month
   (or by "Make bills" in Revenue). Marking a subscription bill paid extends the school.
 - Online payment gateways have settings prepared but are not live yet.

---------------------------------------------------------------
E. PHONE INSTALL
---------------------------------------------------------------
 On Android (Chrome) the "Install app" button appears. On iPhone use Safari -> Share ->
 Add to Home Screen. The site must be on https (free certificate: sudo certbot --apache).

---------------------------------------------------------------
F. SECURITY
---------------------------------------------------------------
 - Uploaded documents are in uploads/private, blocked from the web and shown only to the
   applicant, the school applied to, and Nesatech.
 - A secret key is created automatically on first run (application/config/secret_key.php);
   keep it, do not share it.
 - Back up the database regularly (update.sh does it each time).
