# NGO MIS — Complete Installation Guide

## ⚡ Admin Credentials
```
URL:      http://yourdomain.com/admin/login
Email:    admin@ngomis.com
Password: Admin@123
```
**Login ke baad immediately password change karo!**

---

## 📁 Project Structure (85 files)

```
NGO_MIS_COMPLETE/
├── app/
│   ├── Http/
│   │   ├── Controllers/
│   │   │   ├── Admin/          (20 controllers)
│   │   │   └── Auth/           (AuthController)
│   │   └── Middleware/
│   │       └── CheckPermission.php
│   ├── Models/                 (19 models)
│   └── helpers.php
├── database/
│   └── NGO_MIS_COMPLETE.sql   ← RUN THIS ONLY
├── resources/views/admin/      (80+ blade views)
├── routes/web.php
├── composer.json
└── .env.example
```

---

## 🚀 Step-by-Step Installation

### Step 1 — Server Requirements
- PHP 8.2+
- MySQL 8.0+
- Composer 2.x
- Apache/Nginx with mod_rewrite

### Step 2 — Laravel Setup
```bash
# New Laravel 11 project banao
composer create-project laravel/laravel ngo-mis

# Project folder mein jao
cd ngo-mis
```

### Step 3 — Files Copy Karo
```bash
# Is zip se files copy karo existing Laravel project mein:
# app/           → app/
# resources/     → resources/
# routes/        → routes/
# database/      → database/
```

### Step 4 — Composer Dependencies
```bash
composer require barryvdh/laravel-dompdf
composer require maatwebsite/excel
```

### Step 5 — Environment Setup
```bash
cp .env.example .env
php artisan key:generate
```

**.env mein ye fill karo:**
```env
APP_NAME="NGO MIS"
APP_URL=http://localhost:8000

DB_DATABASE=ngo_mis
DB_USERNAME=root
DB_PASSWORD=your_password

MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525

RAZORPAY_KEY_ID=rzp_live_xxxxx
RAZORPAY_KEY_SECRET=xxxxx
```

### Step 6 — Database
```bash
# MySQL mein database banao
mysql -u root -p
CREATE DATABASE ngo_mis CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
EXIT;

# SQL file import karo
mysql -u root -p ngo_mis < database/NGO_MIS_COMPLETE.sql
```

### Step 7 — Middleware Register
`bootstrap/app.php` mein add karo:
```php
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'permission' => \App\Http\Middleware\CheckPermission::class,
    ]);
})
```

### Step 8 — Upload Directories
```bash
mkdir -p public/uploads/{users,donations,csr,projects,products,beneficiaries,documents}
chmod -R 775 public/uploads
php artisan storage:link
```

### Step 9 — helpers.php Register
`composer.json` mein already hai:
```json
"autoload": {
    "files": ["app/helpers.php", "app/helpers_additions.php"]
}
```
Phir:
```bash
composer dump-autoload
```

### Step 10 — Run
```bash
php artisan serve
# Open: http://localhost:8000/admin/login
```

---

## 🔑 Default Roles & Access

| Role | Access |
|------|--------|
| **Super Admin** | Everything — no restrictions |
| **Admin** | All modules except audit logs |
| **Manager** | View-only across all modules |
| **CSR Manager** | CSR companies, projects, expenses |
| **Accountant** | Donations, donors, expenses, reports |
| **Volunteer** | Dashboard, notices, projects (view) |
| **Staff** | Dashboard + notices only |

---

## 📦 Phases Completed (1–4)

| Phase | Module |
|-------|--------|
| 1 | DB Schema (29 tables), Auth, Dashboard, Sidebar Layout |
| 2 | Users, Departments, Roles, Permission Matrix |
| 3 | CSR Companies, Projects, Expenses (budget enforcement), Inventory, Donations, Donors, PDF Receipts |
| 4 | Beneficiaries + Assistance, Volunteers, Notice Board, 8 Reports (CSV/PDF/Excel), Settings, Audit Logs, Subscriptions |

---

## 🔮 Remaining Phases — Continuation Prompt

Copy paste this prompt to continue:

---

**CONTINUATION PROMPT FOR PHASE 5+:**

```
Continue building the NGO MIS Laravel 11 project.
Phases 1-4 are complete (DB, Auth, Dashboard, Users, Departments,
CSR Companies, Projects, Expenses, Inventory, Donations, Donors,
Receipts, Beneficiaries, Volunteers, Notice Board, Reports,
Settings, Audit Logs, Subscriptions).

Build Phase 5 — Public Website + Payment Gateway:

1. PUBLIC HOMEPAGE (resources/views/public/)
   - layouts/app.blade.php — public navbar (Home, Donate, Projects, Contact, Search) + footer + social links
   - home/index.blade.php — hero banner, campaign message, donate CTA, NGO info section, causes/projects section
   - HomeController.php — load CMS settings, active public projects, slider

2. PUBLIC DONATE PAGE
   - donate/index.blade.php — full form: Name*, Father Name, Email*, Mobile*, Amount*, DOB, Anniversary,
     Purpose, Aadhaar (upload), PAN (upload), Address, Message
   - DonateController.php — validate, create Donation record (status=pending), initiate Razorpay order,
     handle /donate/payment/callback — verify signature, mark completed, create Donor record if new,
     redirect to /donate/success with receipt
   - donate/success.blade.php — thank you page with receipt download button
   - donate/failed.blade.php — failure page with retry

3. SUBSCRIPTION DONATION PAGE
   - donate/subscription.blade.php — Name, Email, Mobile, Address, Amount, Frequency (Monthly/Quarterly/Half-Yearly/Yearly)
   - DonateController@storeSubscription — create Subscription record + Razorpay subscription

4. PUBLIC CONTACT PAGE
   - contact/index.blade.php — NGO address, phone, email, Google Maps embed, contact form
   - ContactController@store — save to contact_messages table + flash success

5. PUBLIC PROJECTS PAGE
   - public/projects/index.blade.php — cards of is_public=1 projects with title, category, CSR partner, description, impact

6. RAZORPAY INTEGRATION
   - config/razorpay.php
   - app/Services/RazorpayService.php — createOrder(), verifyPayment(), createSubscription()

7. GENERAL EXPENSES CRUD (admin panel)
   - GeneralExpenseController.php — full CRUD
   - resources/views/admin/general-expenses/ — index, create views
   - Expense types: administration, campaign, program, beneficiary, other

8. REMAINING ADMIN VIEWS (stubs needed)
   - admin/donors/edit.blade.php
   - admin/donations/show.blade.php + edit.blade.php
   - admin/notices/show.blade.php + edit.blade.php
   - admin/beneficiaries/create.blade.php + show.blade.php + edit.blade.php
   - admin/volunteers/create.blade.php + show.blade.php + edit.blade.php
   - admin/subscriptions/show.blade.php
   - admin/csr/companies/show.blade.php + edit.blade.php
   - admin/csr/expenses/show.blade.php + edit.blade.php
   - admin/csr/categories/edit.blade.php
   - admin/csr/projects/edit.blade.php
   - admin/inventory/create.blade.php + show.blade.php + edit.blade.php
   - admin/reports/ — expenses, csr, projects, users, beneficiaries, volunteers, products views

9. NOTIFICATION CONTROLLER + VIEW
   - NotificationController.php — index, markRead, markAllRead
   - resources/views/admin/notifications/index.blade.php

Deliver as phase-wise zip. Each file must have real working code.
Follow same Laravel 11 structure used in phases 1-4.
All controllers in App\Http\Controllers\Admin namespace.
All views in resources/views/admin/ or resources/views/public/.
```
