# 🚀 Panduan Upload ke Hosting - DSP Report

## 📋 **Checklist Sebelum Upload**

### 1. **Persiapan File**
- ✅ Pastikan semua file telah diupdate dengan `hosting_config.php`
- ✅ Upload file `hosting_diagnostic.php` untuk testing
- ✅ Backup file original sebelum upload

### 2. **Struktur File yang Harus Diupload**
```
public_html/
├── config/
│   ├── hosting_config.php (NEW)
│   └── (other config files)
├── pgn/
│   └── module/
│       └── report/
│           ├── ajax_shipment_detail.php (UPDATED)
│           └── shipment_detail.php
├── rwl/
│   └── module/
│       └── report/
│           ├── ajax_shipment_detail.php (UPDATED)
│           └── shipment_detail.php
├── asset/
│   └── (all CSS, JS files)
├── hosting_diagnostic.php (FOR TESTING)
└── (other files)
```

## 🔧 **Langkah-langkah Upload**

### **Step 1: Test Environment**
1. **Upload file `hosting_diagnostic.php`** ke root folder hosting
2. **Akses via browser**: `https://yourdomain.com/hosting_diagnostic.php`
3. **Periksa hasil test**:
   - ✅ PHP Version (minimal 7.4)
   - ✅ SQLSRV Extension
   - ✅ Database Connection
   - ✅ File Permissions
   - ✅ HTTPS Protocol

### **Step 2: Upload File Utama**
1. **Upload folder `config/`** dengan file `hosting_config.php`
2. **Upload file AJAX yang sudah diupdate**:
   - `pgn/module/report/ajax_shipment_detail.php`
   - `rwl/module/report/ajax_shipment_detail.php`
3. **Upload semua file asset** (CSS, JS, fonts)

### **Step 3: Konfigurasi Hosting**
1. **Cek base URL** di `hosting_config.php`
2. **Sesuaikan path** jika diperlukan
3. **Test database connection**

## ⚠️ **Masalah Umum & Solusi**

### **1. SQLSRV Extension Tidak Tersedia**
**Masalah**: Extension SQLSRV tidak tersedia di hosting
**Solusi**: 
- Hubungi hosting provider untuk mengaktifkan SQLSRV
- Alternatif: Gunakan PDO_SQLSRV
- Backup: Buat API gateway di server yang support SQLSRV

### **2. Mixed Content Error (HTTPS/HTTP)**
**Masalah**: Resource dimuat via HTTP di situs HTTPS
**Solusi**:
```php
// Di hosting_config.php sudah diatur otomatis
// Semua resource akan menggunakan protocol yang sama
```

### **3. Path Issues**
**Masalah**: File tidak ditemukan (404)
**Solusi**:
```php
// Sesuaikan base_url di hosting_config.php
'base_url' => '/dsp-report/', // Jika di subfolder
'base_url' => '/',            // Jika di root domain
```

### **4. Database Connection Timeout**
**Masalah**: Connection timeout di hosting
**Solusi**:
```php
// Di hosting_config.php sudah diatur:
'ConnectionPooling' => false,
'MultipleActiveResultSets' => false
```

### **5. Memory Limit**
**Masalah**: PHP memory limit terlalu kecil
**Solusi**:
- Tambahkan di `.htaccess`:
```apache
php_value memory_limit 256M
php_value max_execution_time 300
```

## 🔍 **Testing Setelah Upload**

### **1. Test Basic Functionality**
1. **Akses halaman utama**: `https://yourdomain.com/`
2. **Test PGN**: `https://yourdomain.com/pgn/media.php?module=shipment_detail`
3. **Test RWL**: `https://yourdomain.com/rwl/media.php?module=rwl_shipment_detail`

### **2. Test AJAX Functionality**
1. **Buka Developer Tools** (F12)
2. **Pilih salah satu shipment** dan klik expand
3. **Periksa Console** untuk error
4. **Periksa Network tab** untuk status response

### **3. Test Database Connection**
1. **Coba filter data** dengan date range
2. **Periksa apakah data muncul**
3. **Test expand detail** beberapa shipment

## 🛠️ **Troubleshooting Tools**

### **1. Diagnostic Tool**
```
https://yourdomain.com/hosting_diagnostic.php
```

### **2. Error Logs**
- Periksa error logs hosting
- Aktifkan debug mode sementara jika perlu

### **3. Browser Developer Tools**
- Console tab: JavaScript errors
- Network tab: AJAX request/response
- Elements tab: Resource loading

## 📝 **Konfigurasi Khusus Hosting**

### **1. Shared Hosting**
```php
// Di hosting_config.php
'options' => [
    'TrustServerCertificate' => true,
    'CharacterSet' => 'UTF-8',
    'ConnectionPooling' => false,
    'MultipleActiveResultSets' => false,
    'ConnectRetryCount' => 3,
    'ConnectRetryInterval' => 1
]
```

### **2. VPS/Dedicated**
```php
// Lebih fleksibel, bisa gunakan pooling
'options' => [
    'TrustServerCertificate' => true,
    'CharacterSet' => 'UTF-8',
    'ConnectionPooling' => true,
    'MultipleActiveResultSets' => true
]
```

## ✅ **Checklist Setelah Upload**

- [ ] Hosting diagnostic menunjukkan semua ✅
- [ ] Halaman utama bisa diakses
- [ ] PGN shipment detail berfungsi
- [ ] RWL shipment detail berfungsi
- [ ] Filter tanggal bekerja
- [ ] Expand detail bekerja
- [ ] Sorting berdasarkan GateInTime DESC
- [ ] Tidak ada error di console
- [ ] AJAX response format JSON valid
- [ ] Database connection stable

## 🎯 **Tips Optimasi**

1. **Gunakan CDN** untuk asset static
2. **Compress** file CSS/JS
3. **Enable caching** di hosting
4. **Optimize database queries**
5. **Monitor memory usage**

---

**💡 Catatan Penting:**
- Selalu backup file sebelum upload
- Test di staging environment dulu jika ada
- Monitor performance setelah upload
- Siapkan rollback plan jika ada masalah

**🚀 Selamat mencoba upload ke hosting!**
