# Desh Internet Admin - PHP API

## Setup Instructions

### 1. Database Setup

1. Import `database.sql` into your MySQL/MariaDB server:
   ```bash
   mysql -u root -p < database.sql
   ```
2. Edit `config.php` and update the database credentials:
   ```php
   define('DB_HOST', 'localhost');
   define('DB_NAME', 'edhyvrad_ticket');
   define('DB_USER', 'root');
   define('DB_PASS', '');
   ```

### 2. Default Admin Login

- **Email:** `admin@deshinternet.com`
- **Password:** `admin123`

### 3. Deploy

Upload the `admin/` folder to your server under the path that matches:

```
https://yourdomain.com/api/ticket/api/
```

---

## API Endpoints

| #   | File                             | Method | Description                      |
| --- | -------------------------------- | ------ | -------------------------------- |
| 1   | `login-admin.php`                | POST   | Admin login (email, password)    |
| 2   | `get-dashboard.php`              | GET    | Dashboard stats + recent tickets |
| 3   | `users.php?limit=20&page=1`      | GET    | Paginated user list              |
| 4   | `users.php`                      | POST   | Update user info                 |
| 5   | `get-last-user.php`              | GET    | Last user import timestamp       |
| 6   | `add-users.php`                  | POST   | Bulk import users (JSON body)    |
| 7   | `get-all-lineman.php`            | GET    | All line men list                |
| 8   | `add-line-man.php`               | POST   | Add new line man                 |
| 9   | `update-line-man.php`            | POST   | Update line man (JSON body)      |
| 10  | `delete_lineman.php?id=X`        | DELETE | Delete line man                  |
| 11  | `user_info.php`                  | GET    | All users (for autocomplete)     |
| 12  | `all_problem.php`                | GET    | All issues/problems list         |
| 13  | `add_ticket.php`                 | POST   | Create new ticket                |
| 14  | `all_ticket.php`                 | GET    | All tickets                      |
| 15  | `ticket_details.php`             | POST   | Single ticket details (id)       |
| 16  | `all_line_man.php`               | GET    | Line man names (for dropdown)    |
| 17  | `update-_ticket.php`             | POST   | Update ticket                    |
| 18  | `get-user-tickets.php?user_id=X` | GET    | Tickets for specific user        |
| 19  | `get-all-salse-query.php`        | GET    | All sales queries                |
| 20  | `update_query.php`               | POST   | Close sales query (id)           |
| 21  | `add_issue.php`                  | POST   | Add new issue (title)            |
| 22  | `update_issues.php`              | POST   | Update issue (id, title)         |
| 23  | `delete_issue.php`               | POST   | Delete issue (id)                |
| 24  | `setting.php`                    | POST   | Get app settings/notice          |
| 25  | `update_notice.php`              | POST   | Update notice text               |

## Database Tables (edhyvrad_ticket)

| Table       | Purpose                                                              |
| ----------- | -------------------------------------------------------------------- |
| `admins`    | Admin users (id, name, mail, password, role)                         |
| `users`     | ISP customers (recharge_id, user_id, username, name, address, phone) |
| `line_man`  | Field technicians (name, phone, password, role)                      |
| `ticket`    | Support tickets with full lifecycle tracking                         |
| `marketing` | New connection sales queries                                         |
| `issue`     | Issue/problem categories                                             |
| `setting`   | App settings (notice, version, url_lineman)                          |
