# PawJoy Pet Management Platform

A comprehensive pet management and subscription SaaS platform built with PHP, MySQL, and Bootstrap 5.

## Features

### Core Features
- **User Management**: Registration, authentication, and subscription management
- **Pet Management**: Complete pet profiles with medical and grooming history
- **Schedule Management**: Healthcare, grooming, and other appointment scheduling
- **Automated Reminders**: Email notifications 3 days before and on the day of appointments
- **PawGram**: Social gallery for pet photos with likes and captions
- **Subscription System**: Free trial, monthly, and yearly plans with Midtrans payment integration
- **Admin Panel**: Complete admin dashboard for user and package management

### Technical Features
- **PHP 8.x** with modern coding standards
- **MySQL** database with prepared statements for security
- **Bootstrap 5** responsive design
- **Midtrans** payment gateway integration
- **Cron job** support for automated reminders
- **Clean MVC** architecture
- **SQL Injection** protection
- **Responsive** mobile-first design

## Installation

### Prerequisites
- PHP 8.x or higher
- MySQL 5.7 or higher
- Apache/Nginx web server
- Composer (optional, for future package management)

### Setup Instructions

1. **Database Setup**
   ```bash
   # Import the database schema
   mysql -u root -p pawjoy_db < database_migration.sql
   ```

2. **Configuration**
   ```bash
   # Update database credentials in config/database.php
   # Update Midtrans credentials in config/midtrans.php
   ```

3. **File Permissions**
   ```bash
   # Set write permissions for upload directories
   chmod 755 uploads/
   chmod 755 uploads/pets/
   chmod 755 uploads/gallery/
   ```

4. **Web Server Configuration**
   
   **Apache (.htaccess)**
   ```apache
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php [QSA,L]
   ```
   
   **Nginx**
   ```nginx
   location / {
       try_files $uri $uri/ /index.php?$query_string;
   }
   ```

5. **Cron Job Setup**
   ```bash
   # Add to crontab for daily reminders at 9:00 AM
   0 9 * * * /usr/bin/php /path/to/pawjoy/cron/reminder.php
   ```

## Directory Structure

```
/
|--------------------------------------------------------------------------
| PawJoy Pet Management Platform
|--------------------------------------------------------------------------
|
| assets/
|   css/          # Custom stylesheets
|   js/           # JavaScript files
|   images/       # Static images
|
| config/
|   database.php  # Database configuration
|   midtrans.php  # Payment gateway configuration
|
| controllers/
|   Auth/         # Authentication controller
|   Pet/          # Pet management controller
|   Schedule/     # Schedule management controller
|   Payment/      # Payment processing controller
|   Admin/        # Admin panel controller
|
| views/
|   auth/         # Authentication views
|   dashboard/    # Dashboard views
|   gallery/      # PawGram gallery views
|   admin/        # Admin panel views
|   layout/       # Layout templates
|
| uploads/
|   pets/         # Pet photo uploads
|   gallery/      # Gallery image uploads
|
| cron/
|   reminder.php  # Email reminder cron job
|
| index.php       # Main router and entry point
| database_migration.sql  # Database schema
```

## Database Schema

### Tables Overview

- **users**: User accounts with subscription levels
- **packages**: Subscription packages and pricing
- **pets**: Pet profiles and information
- **schedules**: Appointment scheduling with reminder flags
- **gallery**: Social photo gallery
- **payment_transactions**: Payment history and status
- **gallery_likes**: Like tracking for gallery posts

### Key Features

- **Subscription Levels**: free_trial, monthly, yearly
- **Schedule Categories**: Healthcare, Grooming, Others
- **Pet Types**: dog, cat, other
- **Payment Integration**: Midtrans Snap API
- **Automated Notifications**: 3-day and same-day reminders

## Payment Integration

### Midtrans Setup

1. Create a Midtrans account at [midtrans.com](https://midtrans.com)
2. Get your Server Key and Client Key
3. Update `config/midtrans.php` with your credentials
4. Set up webhook endpoints for payment notifications

### Webhook Endpoints

- **POST** `/payment/webhook` - Midtrans payment notifications

## Email Configuration

The reminder system uses PHP's `mail()` function. For production, configure your SMTP settings in `php.ini` or integrate with a service like SendGrid.

## Security Features

- **SQL Injection Protection**: All database queries use prepared statements
- **Input Validation**: Form validation and sanitization
- **Session Management**: Secure session handling
- **File Upload Security**: Restricted file types and upload directories
- **CSRF Protection**: Token-based CSRF protection (to be implemented)

## UI/UX Design

- **Theme**: Minimalist, Professional, Clean
- **Primary Color**: #545BE8 (Mekari Blue)
- **Secondary Color**: #7D2AE8 (Canva Purple)
- **Typography**: Inter font family
- **Components**: Card-based layout with 16px border radius
- **Responsiveness**: Mobile-first design approach

## API Endpoints

### Authentication
- **GET/POST** `/login` - User login
- **GET/POST** `/register` - User registration
- **GET** `/logout` - User logout

### Pet Management
- **GET** `/pets` - List user's pets
- **GET/POST** `/pets/add` - Add new pet
- **GET/POST** `/pets/edit/{id}` - Edit pet
- **POST** `/pets/delete/{id}` - Delete pet

### Schedule Management
- **GET** `/schedules` - List schedules
- **GET/POST** `/schedules/add` - Add schedule
- **GET/POST** `/schedules/edit/{id}` - Edit schedule
- **POST** `/schedules/delete/{id}` - Delete schedule

### Gallery
- **GET** `/gallery` - PawGram gallery
- **GET/POST** `/gallery/add` - Add photo
- **POST** `/gallery/like/{id}` - Like photo
- **POST** `/gallery/delete/{id}` - Delete photo

### Payment
- **GET** `/pricing` - View pricing plans
- **POST** `/payment/create` - Create payment
- **POST** `/payment/webhook` - Midtrans webhook

### Admin
- **GET** `/admin` - Admin dashboard
- **GET** `/admin/users` - User management
- **GET/POST** `/admin/packages` - Package management
- **GET/POST** `/admin/config` - System configuration

## Default Credentials

After database import:

- **Admin Email**: admin@pawjoy.com
- **Admin Password**: admin123

## Support

For issues and support:
1. Check the error logs in your web server
2. Verify database connections and credentials
3. Ensure proper file permissions
4. Test cron job functionality manually

## License

This project is proprietary and confidential.

## Changelog

### Version 1.0.0 (2025-04-11)
- Initial release
- Complete user management system
- Pet management functionality
- Schedule and reminder system
- PawGram social gallery
- Payment integration with Midtrans
- Admin panel
- Responsive design with Bootstrap 5
