# Meeting Scheduler

A professional meeting scheduling system with calendar interface, security verification, and email/Telegram notifications.

## Files Created

- `meeting.html` - Interactive calendar and scheduling interface
- `meeting_handler.php` - Backend meeting processing
- `config_meeting.php` - Configuration settings
- `.htaccess` - Security rules
- `README.md` - This documentation

## Setup Instructions

### 1. Configure Settings

Edit `config_meeting.php`:

```php
// Email Configuration
define('MEETING_RECIPIENT_EMAIL', 'your-email@example.com'); // Your email
define('MEETING_FROM_EMAIL', 'noreply@yourdomain.com'); // Your domain

// Telegram Configuration
define('TELEGRAM_BOT_TOKEN', 'YOUR_BOT_TOKEN'); // Get from @BotFather
define('TELEGRAM_CHAT_ID', 'YOUR_CHAT_ID'); // Your Telegram chat ID
```

### 2. Business Hours Configuration

Customize business hours in `config_meeting.php`:

```php
// Weekday hours (9:00 AM - 5:00 PM)
define('WEEKDAY_START_HOUR', 9);
define('WEEKDAY_END_HOUR', 17);

// Weekend hours (10:00 AM - 2:00 PM)
define('WEEKEND_START_HOUR', 10);
define('WEEKEND_END_HOUR', 14);
```

### 3. Meeting Types

Configure available meeting types:

```php
$meetingTypes = [
    'consultation' => [
        'name' => 'Consultation',
        'duration' => 30,
        'description' => 'Initial consultation'
    ],
    'demo' => [
        'name' => 'Product Demo',
        'duration' => 45,
        'description' => 'Live demonstration'
    ]
    // Add more types as needed
];
```

## Features

### Calendar Interface
- **Interactive calendar** with month navigation
- **Date selection** with business day validation
- **Time slot selection** based on business hours
- **Time zone detection** and display
- **Weekend restrictions** (limited hours)

### Meeting Types
- **Consultation** (30 minutes)
- **Product Demo** (45 minutes)
- **Technical Support** (30 minutes)
- **Sales Discussion** (30 minutes)
- **Other** (30 minutes)

### Security Features
- **Token verification** using existing antibot system
- **Form validation** and sanitization
- **Business hours enforcement**
- **Future date validation**
- **Spam protection**

### Notifications
- **Email notifications** to admin with meeting details
- **Telegram notifications** with formatted message
- **User confirmation** email with meeting details
- **Meeting ID** for tracking

## Usage

### For Clients
1. **Visit scheduling link**: `https://yoursite.com/pages/schedule/meeting.html?ref=client@example.com`
2. **Select date** from available calendar days
3. **Choose time slot** based on business hours
4. **Fill meeting details** (name, email, meeting type)
5. **Complete security verification**
6. **Receive confirmation** via email

### For Admin
1. **Receive notifications** via email and Telegram
2. **Review meeting details** in notifications
3. **Confirm meeting** with client
4. **Add to calendar** (manual or automatic)

## Business Hours

### Weekdays (Monday - Friday)
- **Available**: 9:00 AM - 5:00 PM
- **Time slots**: Every hour (9:00, 10:00, 11:00, etc.)

### Weekends (Saturday - Sunday)
- **Available**: 10:00 AM - 2:00 PM
- **Time slots**: Every hour (10:00, 11:00, 12:00, 13:00)

### Restrictions
- **Past dates** disabled
- **Weekend evenings** disabled
- **Late evenings** disabled
- **Invalid time slots** disabled

## Meeting Data Storage

Meetings are stored in `meetings.json`:

```json
[
  {
    "id": "MTG-ABC123DEF-4567",
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "+1234567890",
    "type": "consultation",
    "message": "Need to discuss project requirements",
    "datetime": "2024-01-15 14:00:00",
    "status": "scheduled",
    "created_at": "2024-01-10 09:30:00"
  }
]
```

## Notification Examples

### Email Notification
```
Subject: New Meeting Scheduled: MTG-ABC123DEF-4567

A new meeting has been scheduled:

Meeting ID: MTG-ABC123DEF-4567
Name: John Doe
Email: john@example.com
Phone: +1234567890
Type: Consultation
Date/Time: 2024-01-15 14:00
Message: Need to discuss project requirements

Please confirm this meeting with the client.
```

### Telegram Notification
```
📅 New Meeting Scheduled

• ID: `MTG-ABC123DEF-4567`
• Name: John Doe
• Email: john@example.com
• Phone: +1234567890
• Type: Consultation
• Time: 2024-01-15 14:00
• Message: Need to discuss project requirements
```

## Integration

The meeting scheduler uses the same:
- **Antibot verification** as your file upload system
- **Token validation** system
- **Security twist** (real humans get "denied" token)
- **Email/Telegram notification** patterns

## Customization

### Add New Meeting Types
Edit `config_meeting.php`:

```php
'custom' => [
    'name' => 'Custom Meeting',
    'duration' => 60,
    'description' => 'Custom meeting type'
]
```

### Modify Business Hours
Update the constants in `config_meeting.php`:

```php
define('WEEKDAY_START_HOUR', 8); // Start at 8 AM
define('WEEKDAY_END_HOUR', 18);   // End at 6 PM
```

### Customize Time Slots
Modify the time slot generation in `meeting.html`:

```javascript
// Add 30-minute intervals
for (let hour = 9; hour <= 16; hour++) {
  timeSlots.push(`${hour}:00`);
  timeSlots.push(`${hour}:30`);
}
```

## Troubleshooting

### Meetings Not Saving
- Check file permissions for `meetings.json`
- Verify JSON format is valid
- Check error logs for detailed messages

### No Email Notifications
- Verify SMTP settings on your server
- Check recipient email address
- Verify sender email domain

### No Telegram Notifications
- Verify bot token is correct
- Verify chat ID is correct
- Ensure bot can send messages

### Calendar Not Working
- Check JavaScript console for errors
- Verify date/time formats
- Check browser compatibility

## Security

- **Token verification** prevents automated submissions
- **Input sanitization** prevents XSS attacks
- **Business hour validation** prevents unauthorized times
- **File access restrictions** via .htaccess
- **Rate limiting** can be added as needed

## API Integration

The system can be extended to integrate with:
- **Google Calendar** API
- **Microsoft Outlook** API
- **Zoom** meeting creation
- **CRM systems** (Salesforce, HubSpot)

The meeting data structure supports easy API integration for advanced scheduling features.
