# 🦈 Shark CRM

A full-featured multi-tenant CRM system built with PHP, MySQL, HTML, CSS, and vanilla JavaScript.

## Setup Instructions

### 1. Database Setup
Import the SQL schema:
```bash
mysql -u root -p < shark_crm_schema.sql
```

### 2. Configure Database
Edit `connect.php` and update your database credentials:
```php
define('DB_HOST', 'localhost');
define('DB_USER', 'your_username');
define('DB_PASS', 'your_password');
define('DB_NAME', 'shark_crm');
```

### 3. Deploy
Place the `/sharkcrm` folder inside your web server root (e.g., `htdocs` or `www`).

### 4. Login
- URL: `http://localhost/sharkcrm/`
- Email: `admin@sharkcrm.com`
- Password: `admin123`

---

## Features

| Module | Features |
|--------|----------|
| Dashboard | Stats, pipeline overview, upcoming reminders |
| Leads | CRUD, stage tracking, opportunity %, priority stars |
| Pipeline | Kanban drag-and-drop, stage management |
| Customers | CRUD, multiple contacts per customer |
| Items | Products & services with types |
| Reminders | Link to leads/customers, activity types |
| Settings | Account info, users, lost reasons, password |
| Activities | Log calls, meetings, emails, WhatsApp, SMS |
| Follow-ups | Comment timeline per lead |

## Folder Structure
```
/sharkcrm
├── connect.php          # Database connection
├── index.php            # Main router + layout
├── shark_crm_schema.sql # Database schema + seed
├── /pages               # Page files
│   ├── login.php
│   ├── dashboard.php
│   ├── leads.php
│   ├── pipeline.php
│   ├── customers.php
│   ├── items.php
│   ├── reminders.php
│   └── settings.php
├── /handlers            # AJAX handlers (return JSON)
│   ├── customers.php
│   ├── leads.php
│   ├── items.php
│   ├── stages.php
│   ├── reminders.php
│   └── settings.php
└── /assets
    ├── /css/style.css   # Main stylesheet
    └── /js
        ├── main.js      # Core JS utilities
        └── pipeline.js  # Kanban drag & drop
```

## 2026-06-01 Improvements Added

Before using the updated files on an existing database, import:

```bash
mysql -u USER -p DATABASE_NAME < migrations/2026_06_01_improvements.sql
```

Added:
- `config/pages.php` central pages/actions array for permissions.
- Per-user permissions in Settings → Permissions.
- Activities page showing all lead actions and communication logs.
- Dashboard connection health cards for WhatsApp/SMS/Email.
- Dashboard reminder numbers for today/overdue/upcoming.
- Customer and lead “Added By” tracking.
- Lead page renamed “Activities” tab to “Take Action” with action date and comment.
- Stage movement now records a dated activity.
- Email sender selection reads from `accounts_email`, default first.
