PNG  IHDR* pHYs+ IDATx]n#; cdLb Ǚ[at¤_:uP}>!Usă cag޿ ֵNu`ݼTâabO7uL&y^wFٝA"l[|ŲHLN밪4*sG3|Dv}?+y߉{OuOAt4Jj.u]Gz*҉sP'VQKbA1u\`& Af;HWj hsO;ogTu uj7S3/QzUr&wS`M$X_L7r2;aE+ώ%vikDA:dR+%KzƉo>eOth$z%: :{WwaQ:wz%4foɹE[9<]#ERINƻv溂E%P1i01 |Jvҗ&{b?9g=^wζXn/lK::90KwrюO\!ջ3uzuGv^;騢wq<Iatv09:tt~hEG`v;3@MNZD.1]L:{ծI3`L(÷ba")Y.iljCɄae#I"1 `3*Bdz>j<fU40⨬%O$3cGt]j%Fߠ_twJ;ABU8vP3uEԑwQ V:h%))LfraqX-ۿX]v-\9I gl8tzX ]ecm)-cgʒ#Uw=Wlێn(0hPP/ӨtQ“&J35 $=]r1{tLuǮ*i0_;NƝ8;-vݏr8+U-kruȕYr0RnC]*ެ(M:]gE;{]tg(#ZJ9y>utRDRMdr9㪩̞zֹb<ģ&wzJM"iI( .ꮅX)Qw:9,i좜\Ԛi7&N0:asϓc];=ΗOӣ APqz93 y $)A*kVHZwBƺnWNaby>XMN*45~ղM6Nvm;A=jֲ.~1}(9`KJ/V F9[=`~[;sRuk]rєT!)iQO)Y$V ی ۤmzWz5IM Zb )ˆC`6 rRa}qNmUfDsWuˤV{ Pݝ'=Kֳbg,UҘVz2ﴻnjNgBb{? ߮tcsͻQuxVCIY۠:(V뺕 ٥2;t`@Fo{Z9`;]wMzU~%UA蛚dI vGq\r82iu +St`cR.6U/M9IENDB` REDROOM
PHP 5.6.40
Preview: BrevoService.php Size: 57.47 KB
/home/ankaservis/public_html/includes/BrevoService.php

<?php

/**
 * Brevo (Sendinblue) API Configuration
 * Professional Email Service Integration
 */

// UTF-8 Encoding
mb_internal_encoding('UTF-8');

class BrevoService {
    private $apiKey;
    private $apiUrl = 'https://api.brevo.com/v3/';
    private $adminEmail;
    
    public function __construct() {
        $this->apiKey = defined('BREVO_API_KEY') ? BREVO_API_KEY : '';
        $this->adminEmail = defined('CONTACT_EMAIL') ? CONTACT_EMAIL : 'servis@ankaservis.com';
    }
    
    /**
     * Send professional service request notification
     */
    public function sendServiceNotification($formData) {
        try {
            // Takip numarası oluştur
            $trackingNumber = 'ST' . str_pad(rand(100000, 999999), 6, '0', STR_PAD_LEFT);
            $formData['tracking_number'] = $trackingNumber;
            
            // Müşteriye onay e-postası gönder (e-posta varsa)
            if (!empty($formData['email'])) {
                $this->sendCustomerServiceConfirmation($formData);
            }
            
            $subject = $this->generateEmailSubject($formData);
            $htmlContent = $this->generateProfessionalEmailTemplate($formData);
            
            // Alıcı listesini config'den al
            $toEmails = [];
            if (defined('FORM_NOTIFICATION_EMAILS') && is_array(FORM_NOTIFICATION_EMAILS)) {
                foreach (FORM_NOTIFICATION_EMAILS as $email) {
                    $toEmails[] = [
                        'email' => $email,
                        'name' => 'Servis Bildirimi'
                    ];
                }
            } else {
                // Fallback
                $toEmails[] = [
                    'email' => $this->adminEmail,
                    'name' => 'Admin'
                ];
            }
            
            $emailData = [
                'sender' => [
                    'email' => defined('NOREPLY_EMAIL') ? NOREPLY_EMAIL : 'noreply@ankaservis.com',
                    'name' => defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis'
                ],
                'to' => $toEmails,
                'subject' => $subject,
                'htmlContent' => $htmlContent,
                'textContent' => strip_tags($htmlContent)
            ];
            
            $result = $this->sendTransactionalEmail($emailData);
            
            return $result;
            
        } catch (Exception $e) {
            if (defined('DEBUG_MODE') && DEBUG_MODE) {
                error_log('BrevoService Error: ' . $e->getMessage());
            }
            return false;
        }
    }
    
    /**
     * Generate professional email subject
     */
    private function generateEmailSubject($formData) {
        date_default_timezone_set('Europe/Istanbul');
        
        $deviceType = $formData['device_type'] ?? 'Genel';
        $city = $formData['city'] ?? '';
        $priority = '🚨 DİKKAT';
        
        $cityText = $city ? " - {$city}" : '';
        
        return "{$priority} ACİL SERVİS TALEBİ: {$deviceType}{$cityText} | " . date('d.m.Y H:i');
    }
    
    /**
     * Generate professional HTML email template
     */
    private function generateProfessionalEmailTemplate($formData) {
        date_default_timezone_set('Europe/Istanbul');
        
        $deviceType = $formData['device_type'] ?? 'Genel';
        $urgentBadge = $this->getUrgencyBadge();
        
        $html = '
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
        </head>
        <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f5f5f5;">
            <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5;">
                <tr>
                    <td align="center" style="padding: 20px;">
                        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border: 1px solid #ddd;">
                            
                            <!-- Header -->
                            <tr>
                                <td style="background-color: #e55a2b; color: white; padding: 20px; text-align: center;">
                                    <h1 style="margin: 0; font-size: 24px;">🚨 YENİ SERVİS TALEBİ</h1>
                                    <p style="margin: 5px 0 0 0; font-size: 16px;">' . htmlspecialchars($deviceType) . ' • ' . date('d.m.Y H:i') . '</p>
                                </td>
                            </tr>
                            
                            <!-- Content -->
                            <tr>
                                <td style="padding: 20px;">
                                    
                                    <!-- Telefon -->
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #e55a2b; color: white; padding: 15px; text-align: center;">
                                                <h3 style="margin: 0; font-size: 18px;">📞 Hemen Arayın</h3>
                                                <a href="tel:' . htmlspecialchars($formData['phone'] ?? '') . '" style="font-size: 24px; font-weight: bold; text-decoration: none; color: white;">' . htmlspecialchars($formData['phone'] ?? '') . '</a>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <!-- Takip Numarası -->
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">🔍 Takip Numarası</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px; text-align: center;">
                                                <div style="font-size: 20px; font-weight: bold; color: #e55a2b;">' . htmlspecialchars($formData['tracking_number'] ?? 'ST000000') . '</div>
                                                <p style="margin: 5px 0 0 0; font-size: 12px; color: #666;">Bu numarayı saklayın, takip için kullanabilirsiniz</p>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    ' . $this->generateCallTimeAlert($formData) . '
                                    
                                    <!-- Müşteri Bilgileri -->
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">👤 Müşteri Bilgileri</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="30%" style="padding: 5px 0; font-weight: bold;">Ad Soyad:</td>
                                                        <td width="70%" style="padding: 5px 0;">' . htmlspecialchars($formData['name'] ?? '') . '</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Telefon:</td>
                                                        <td style="padding: 5px 0;">' . htmlspecialchars($formData['phone'] ?? '') . '</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">E-posta:</td>
                                                        <td style="padding: 5px 0;">' . htmlspecialchars($formData['email'] ?? 'Belirtilmemiş') . '</td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <!-- Konum Bilgileri -->
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">📍 Konum Bilgileri</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="30%" style="padding: 5px 0; font-weight: bold;">Adres:</td>
                                                        <td width="70%" style="padding: 5px 0;">' . htmlspecialchars($formData['address'] ?? 'Adres belirtilmemiş') . '</td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <!-- Cihaz Bilgileri -->
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">🔧 Cihaz Bilgileri</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="30%" style="padding: 5px 0; font-weight: bold;">Cihaz Tipi:</td>
                                                        <td width="70%" style="padding: 5px 0;">' . htmlspecialchars($formData['device_type'] ?? 'Belirtilmemiş') . '</td>
                                                    </tr>
                                                    ' . (!empty($formData['device_brand']) ? '<tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Marka:</td>
                                                        <td style="padding: 5px 0;">' . htmlspecialchars($formData['device_brand']) . '</td>
                                                    </tr>' : '') . '
                                                    ' . (!empty($formData['device_model']) ? '<tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Model:</td>
                                                        <td style="padding: 5px 0;">' . htmlspecialchars($formData['device_model']) . '</td>
                                                    </tr>' : '') . '
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <!-- Arıza Detayı -->
                                    ' . (!empty($formData['problem_description']) ? '<table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">📝 Arıza Detayı</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                ' . nl2br(htmlspecialchars($formData['problem_description'])) . '
                                            </td>
                                        </tr>
                                    </table>' : '') . '
                                    
                                </td>
                            </tr>
                            
                            <!-- Footer -->
                            <tr>
                                <td style="background-color: #f8f9fa; padding: 15px; text-align: center; border-top: 1px solid #ddd;">
                                    <p style="margin: 0; font-size: 12px; color: #666;">Bu email otomatik olarak ' . (defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis') . ' sistemi tarafından gönderilmiştir.</p>
                                    <p style="margin: 5px 0 0 0; font-size: 12px; color: #999;">© ' . date('Y') . ' ' . (defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis') . '</p>
                                </td>
                            </tr>
                            
                        </table>
                    </td>
                </tr>
            </table>
        </body>
        </html>';
        
        return $html;
    }
    
    /**
     * Send contact form notification
     */
    public function sendContactFormNotification($formData) {
        try {
            date_default_timezone_set('Europe/Istanbul');
            
            $subject = '📧 Yeni İletişim Formu Mesajı - ' . date('d.m.Y H:i');
            $htmlContent = $this->generateContactFormEmailTemplate($formData);
            
            $toEmails = [];
            if (defined('FORM_NOTIFICATION_EMAILS') && is_array(FORM_NOTIFICATION_EMAILS)) {
                foreach (FORM_NOTIFICATION_EMAILS as $email) {
                    $toEmails[] = [
                        'email' => $email,
                        'name' => 'İletişim Bildirimi'
                    ];
                }
            } else {
                $toEmails[] = [
                    'email' => $this->adminEmail,
                    'name' => 'Admin'
                ];
            }
            
            $emailData = [
                'sender' => [
                    'email' => defined('NOREPLY_EMAIL') ? NOREPLY_EMAIL : 'noreply@ankaservis.com',
                    'name' => defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis'
                ],
                'to' => $toEmails,
                'subject' => $subject,
                'htmlContent' => $htmlContent,
                'textContent' => strip_tags($htmlContent)
            ];
            
            return $this->sendTransactionalEmail($emailData);
            
        } catch (Exception $e) {
            if (defined('DEBUG_MODE') && DEBUG_MODE) {
                error_log('BrevoService Contact Form Error: ' . $e->getMessage());
            }
            return false;
        }
    }
    
    /**
     * Generate contact form email template
     */
    private function generateContactFormEmailTemplate($formData) {
        $html = '
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
        </head>
        <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f5f5f5;">
            <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5;">
                <tr>
                    <td align="center" style="padding: 20px;">
                        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border: 1px solid #ddd;">
                            <tr>
                                <td style="background-color: #e55a2b; color: white; padding: 20px; text-align: center;">
                                    <h1 style="margin: 0; font-size: 24px;">📧 YENİ İLETİŞİM MESAJI</h1>
                                    <p style="margin: 5px 0 0 0; font-size: 16px;">' . date('d.m.Y H:i') . '</p>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding: 20px;">
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">👤 Gönderen Bilgileri</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="30%" style="padding: 5px 0; font-weight: bold;">Ad Soyad:</td>
                                                        <td width="70%" style="padding: 5px 0;">' . htmlspecialchars($formData['name'] ?? '') . '</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">E-posta:</td>
                                                        <td style="padding: 5px 0;"><a href="mailto:' . htmlspecialchars($formData['email'] ?? '') . '">' . htmlspecialchars($formData['email'] ?? '') . '</a></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Telefon:</td>
                                                        <td style="padding: 5px 0;"><a href="tel:' . htmlspecialchars($formData['phone'] ?? '') . '">' . htmlspecialchars($formData['phone'] ?? '') . '</a></td>
                                                    </tr>
                                                    ' . (!empty($formData['subject']) ? '<tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Konu:</td>
                                                        <td style="padding: 5px 0;">' . htmlspecialchars($formData['subject']) . '</td>
                                                    </tr>' : '') . '
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">📝 Mesaj</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                ' . nl2br(htmlspecialchars($formData['message'] ?? '')) . '
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td style="background-color: #f8f9fa; padding: 15px; text-align: center; border-top: 1px solid #ddd;">
                                    <p style="margin: 0; font-size: 12px; color: #666;">Bu email otomatik olarak ' . (defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis') . ' sistemi tarafından gönderilmiştir.</p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </body>
        </html>';
        
        return $html;
    }
    
    /**
     * Send price quote request notification
     */
    public function sendPriceQuoteNotification($formData) {
        try {
            date_default_timezone_set('Europe/Istanbul');
            
            $subject = '💰 Yeni Fiyat Teklifi Talebi - ' . date('d.m.Y H:i');
            $htmlContent = $this->generatePriceQuoteEmailTemplate($formData);
            
            $toEmails = [];
            if (defined('FORM_NOTIFICATION_EMAILS') && is_array(FORM_NOTIFICATION_EMAILS)) {
                foreach (FORM_NOTIFICATION_EMAILS as $email) {
                    $toEmails[] = [
                        'email' => $email,
                        'name' => 'Fiyat Teklifi Bildirimi'
                    ];
                }
            } else {
                $toEmails[] = [
                    'email' => $this->adminEmail,
                    'name' => 'Admin'
                ];
            }
            
            $emailData = [
                'sender' => [
                    'email' => defined('NOREPLY_EMAIL') ? NOREPLY_EMAIL : 'noreply@ankaservis.com',
                    'name' => defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis'
                ],
                'to' => $toEmails,
                'subject' => $subject,
                'htmlContent' => $htmlContent,
                'textContent' => strip_tags($htmlContent)
            ];
            
            return $this->sendTransactionalEmail($emailData);
            
        } catch (Exception $e) {
            if (defined('DEBUG_MODE') && DEBUG_MODE) {
                error_log('BrevoService Price Quote Error: ' . $e->getMessage());
            }
            return false;
        }
    }
    
    /**
     * Generate price quote email template
     */
    private function generatePriceQuoteEmailTemplate($formData) {
        $html = '
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
        </head>
        <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f5f5f5;">
            <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5;">
                <tr>
                    <td align="center" style="padding: 20px;">
                        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border: 1px solid #ddd;">
                            <tr>
                                <td style="background-color: #e55a2b; color: white; padding: 20px; text-align: center;">
                                    <h1 style="margin: 0; font-size: 24px;">💰 YENİ FİYAT TEKLİFİ TALEBİ</h1>
                                    <p style="margin: 5px 0 0 0; font-size: 16px;">' . date('d.m.Y H:i') . '</p>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding: 20px;">
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">👤 Müşteri Bilgileri</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="30%" style="padding: 5px 0; font-weight: bold;">Ad Soyad:</td>
                                                        <td width="70%" style="padding: 5px 0;">' . htmlspecialchars($formData['name'] ?? '') . '</td>
                                                    </tr>
                                                    <tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">E-posta:</td>
                                                        <td style="padding: 5px 0;"><a href="mailto:' . htmlspecialchars($formData['email'] ?? '') . '">' . htmlspecialchars($formData['email'] ?? '') . '</a></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Telefon:</td>
                                                        <td style="padding: 5px 0;"><a href="tel:' . htmlspecialchars($formData['phone'] ?? '') . '">' . htmlspecialchars($formData['phone'] ?? '') . '</a></td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">🔧 Cihaz Bilgileri</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="30%" style="padding: 5px 0; font-weight: bold;">Cihaz Tipi:</td>
                                                        <td width="70%" style="padding: 5px 0;">' . htmlspecialchars($formData['device_type'] ?? 'Belirtilmemiş') . '</td>
                                                    </tr>
                                                    ' . (!empty($formData['device_brand']) ? '<tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Marka:</td>
                                                        <td style="padding: 5px 0;">' . htmlspecialchars($formData['device_brand']) . '</td>
                                                    </tr>' : '') . '
                                                    ' . (!empty($formData['device_model']) ? '<tr>
                                                        <td style="padding: 5px 0; font-weight: bold;">Model:</td>
                                                        <td style="padding: 5px 0;">' . htmlspecialchars($formData['device_model']) . '</td>
                                                    </tr>' : '') . '
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    ' . (!empty($formData['problem_description']) ? '<table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 10px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">📝 Arıza Açıklaması</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                ' . nl2br(htmlspecialchars($formData['problem_description'])) . '
                                            </td>
                                        </tr>
                                    </table>' : '') . '
                                </td>
                            </tr>
                            <tr>
                                <td style="background-color: #f8f9fa; padding: 15px; text-align: center; border-top: 1px solid #ddd;">
                                    <p style="margin: 0; font-size: 12px; color: #666;">Bu email otomatik olarak ' . (defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis') . ' sistemi tarafından gönderilmiştir.</p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </body>
        </html>';
        
        return $html;
    }
    
    /**
     * Send transactional email via Brevo API
     */
    private function sendTransactionalEmail($emailData) {
        try {
            if (empty($this->apiKey)) {
                return false;
            }
            
            $ch = curl_init();
            
            if (!$ch) {
                return false;
            }
            
            curl_setopt_array($ch, [
                CURLOPT_URL => $this->apiUrl . 'smtp/email',
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_POST => true,
                CURLOPT_POSTFIELDS => json_encode($emailData),
                CURLOPT_HTTPHEADER => [
                    'Content-Type: application/json',
                    'api-key: ' . $this->apiKey,
                    'Accept: application/json'
                ],
                CURLOPT_TIMEOUT => 30,
                CURLOPT_SSL_VERIFYPEER => true
            ]);
            
            $response = curl_exec($ch);
            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            $error = curl_error($ch);
            
            curl_close($ch);
            
            if ($error) {
                if (defined('DEBUG_MODE') && DEBUG_MODE) {
                    error_log('BrevoService cURL Error: ' . $error);
                }
                return false;
            }
            
            if ($httpCode >= 200 && $httpCode < 300) {
                $decodedResponse = json_decode($response, true);
                return $decodedResponse ?: ['success' => true];
            } else {
                if (defined('DEBUG_MODE') && DEBUG_MODE) {
                    error_log('BrevoService HTTP Error: ' . $httpCode . ' - ' . $response);
                }
                return false;
            }
            
        } catch (Exception $e) {
            if (defined('DEBUG_MODE') && DEBUG_MODE) {
                error_log('BrevoService Exception: ' . $e->getMessage());
            }
            return false;
        }
    }
    
    /**
     * Generate call time alert for staff
     */
    private function generateCallTimeAlert($formData) {
        date_default_timezone_set('Europe/Istanbul');
        $currentHour = (int)date('H');
        $currentMinute = (int)date('i');
        $currentTime = $currentHour + ($currentMinute / 60);
        
        $brandPhone = defined('CONTACT_PHONE') ? CONTACT_PHONE : '0312 466 0 667';
        
        // Mesai saatleri: 08:30 - 20:00
        $workStart = 8.5; // 08:30
        $workEnd = 20.0;   // 20:00
        
        if ($currentTime >= $workStart && $currentTime < $workEnd) {
            // Mesai saatleri içinde
            $timeDisplay = date('H:i') . ' - ' . date('H:i', strtotime('+30 minutes'));
            $alertText = '⏰ DİKKAT: Müşteriyi ' . $timeDisplay . ' saatleri arasında MUTLAKA arayın!';
            $subText = 'Mesai saatleri içinde - 30 dakika içinde arama yapılmalı';
            $alertColor = '#28a745';
        } else {
            // Mesai saatleri dışında
            if ($currentTime >= $workEnd) {
                $nextWorkDay = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
            } else {
                $nextWorkDay = date('Y-m-d') . ' 08:30:00';
            }
            $timeDisplay = date('d.m.Y H:i', strtotime($nextWorkDay));
            $alertText = '🕐 DİKKAT: Müşteriyi ' . $timeDisplay . ' saatinde MUTLAKA arayın!';
            $subText = 'Mesai dışı talep - İlk mesai saatinde arama yapılmalı';
            $alertColor = '#ffc107';
        }
        
        return '
        <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px; border: 1px solid #ddd;">
            <tr>
                <td style="background-color: #fff3cd; padding: 15px; border-left: 4px solid ' . $alertColor . ';">
                    <h4 style="margin: 0 0 10px 0; font-size: 16px; color: #856404;">' . $alertText . '</h4>
                    <p style="margin: 0 0 10px 0; font-size: 14px; color: #856404;">' . $subText . '</p>
                    <p style="margin: 0 0 5px 0; font-size: 13px; font-weight: bold; color: #856404;">
                        👨‍💼 Sorumlu: Çağrı Merkezi Personeli
                    </p>
                    <p style="margin: 0 0 5px 0; font-size: 14px; font-weight: bold; color: #856404;">
                        📱 ' . $brandPhone . '
                    </p>
                    <p style="margin: 0; font-size: 12px; color: #856404;">
                        ⚠️ Müşteriyi bu numaradan aramayı unutmayın!
                    </p>
                </td>
            </tr>
        </table>';
    }
    
    /**
     * Get urgency badge
     */
    private function getUrgencyBadge() {
        $hour = (int)date('H');
        
        if ($hour >= 8 && $hour <= 20) {
            return '🔥 URGENT - WORKING HOURS';
        } else {
            return '🌙 AFTER HOURS REQUEST';
        }
    }
    
    /**
     * Müşteriye servis talebi onay e-postası gönder
     */
    public function sendCustomerServiceConfirmation($formData) {
        try {
            if (empty($formData['email'])) {
                return false;
            }
            
            date_default_timezone_set('Europe/Istanbul');
            $trackingNumber = $formData['tracking_number'] ?? 'ST000000';
            
            $subject = '✅ Servis Talebiniz Alındı - Takip No: ' . $trackingNumber;
            $htmlContent = $this->generateCustomerServiceConfirmationTemplate($formData);
            
            $emailData = [
                'sender' => [
                    'email' => defined('CONTACT_EMAIL') ? CONTACT_EMAIL : 'servis@ankaservis.com',
                    'name' => defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis'
                ],
                'to' => [[
                    'email' => $formData['email'],
                    'name' => $formData['name'] ?? 'Müşteri'
                ]],
                'subject' => $subject,
                'htmlContent' => $htmlContent,
                'textContent' => strip_tags($htmlContent)
            ];
            
            return $this->sendTransactionalEmail($emailData);
            
        } catch (Exception $e) {
            if (defined('DEBUG_MODE') && DEBUG_MODE) {
                error_log('BrevoService Customer Confirmation Error: ' . $e->getMessage());
            }
            return false;
        }
    }
    
    /**
     * Müşteriye iletişim formu onay e-postası gönder
     */
    public function sendCustomerContactConfirmation($formData) {
        try {
            if (empty($formData['email'])) {
                return false;
            }
            
            date_default_timezone_set('Europe/Istanbul');
            
            $subject = '✅ Mesajınız Alındı - ' . (defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis');
            $htmlContent = $this->generateCustomerContactConfirmationTemplate($formData);
            
            $emailData = [
                'sender' => [
                    'email' => defined('CONTACT_EMAIL') ? CONTACT_EMAIL : 'servis@ankaservis.com',
                    'name' => defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis'
                ],
                'to' => [[
                    'email' => $formData['email'],
                    'name' => $formData['name'] ?? 'Müşteri'
                ]],
                'subject' => $subject,
                'htmlContent' => $htmlContent,
                'textContent' => strip_tags($htmlContent)
            ];
            
            return $this->sendTransactionalEmail($emailData);
            
        } catch (Exception $e) {
            if (defined('DEBUG_MODE') && DEBUG_MODE) {
                error_log('BrevoService Customer Contact Confirmation Error: ' . $e->getMessage());
            }
            return false;
        }
    }
    
    /**
     * Müşteriye fiyat teklifi onay e-postası gönder
     */
    public function sendCustomerPriceQuoteConfirmation($formData) {
        try {
            if (empty($formData['email'])) {
                return false;
            }
            
            date_default_timezone_set('Europe/Istanbul');
            
            $subject = '✅ Fiyat Teklifi Talebiniz Alındı - ' . (defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis');
            $htmlContent = $this->generateCustomerPriceQuoteConfirmationTemplate($formData);
            
            $emailData = [
                'sender' => [
                    'email' => defined('CONTACT_EMAIL') ? CONTACT_EMAIL : 'servis@ankaservis.com',
                    'name' => defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis'
                ],
                'to' => [[
                    'email' => $formData['email'],
                    'name' => $formData['name'] ?? 'Müşteri'
                ]],
                'subject' => $subject,
                'htmlContent' => $htmlContent,
                'textContent' => strip_tags($htmlContent)
            ];
            
            return $this->sendTransactionalEmail($emailData);
            
        } catch (Exception $e) {
            if (defined('DEBUG_MODE') && DEBUG_MODE) {
                error_log('BrevoService Customer Price Quote Confirmation Error: ' . $e->getMessage());
            }
            return false;
        }
    }
    
    /**
     * Müşteri servis onay e-posta şablonu
     */
    private function generateCustomerServiceConfirmationTemplate($formData) {
        $trackingNumber = $formData['tracking_number'] ?? 'ST000000';
        $contactPhone = defined('CONTACT_PHONE') ? CONTACT_PHONE : '0312 466 0 667';
        $companyName = defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis';
        
        $html = '
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
        </head>
        <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f5f5f5;">
            <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5;">
                <tr>
                    <td align="center" style="padding: 20px;">
                        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border: 1px solid #ddd;">
                            <tr>
                                <td style="background-color: #e55a2b; color: white; padding: 30px; text-align: center;">
                                    <h1 style="margin: 0; font-size: 28px;">✅ Talebiniz Alındı!</h1>
                                    <p style="margin: 10px 0 0 0; font-size: 18px;">En kısa sürede size dönüş yapacağız</p>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding: 30px;">
                                    <p style="font-size: 16px; color: #333; margin: 0 0 20px 0;">Sayın <strong>' . htmlspecialchars($formData['name'] ?? '') . '</strong>,</p>
                                    
                                    <p style="font-size: 16px; color: #333; line-height: 1.6; margin: 0 0 20px 0;">
                                        Servis talebiniz başarıyla alınmıştır. Ekibimiz en kısa sürede sizinle iletişime geçecektir.
                                    </p>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin: 30px 0; border: 2px solid #e55a2b; border-radius: 8px;">
                                        <tr>
                                            <td style="background-color: #fff3cd; padding: 20px; text-align: center;">
                                                <h2 style="margin: 0 0 10px 0; font-size: 20px; color: #856404;">🔍 Takip Numarası</h2>
                                                <div style="font-size: 32px; font-weight: bold; color: #e55a2b; letter-spacing: 2px;">' . htmlspecialchars($trackingNumber) . '</div>
                                                <p style="margin: 10px 0 0 0; font-size: 14px; color: #666;">Bu numarayı saklayın, takip için kullanabilirsiniz</p>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin: 20px 0; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 15px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">📋 Talep Detayları</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="40%" style="padding: 8px 0; font-weight: bold; color: #666;">Cihaz Tipi:</td>
                                                        <td width="60%" style="padding: 8px 0; color: #333;">' . htmlspecialchars($formData['device_type'] ?? 'Belirtilmemiş') . '</td>
                                                    </tr>
                                                    ' . (!empty($formData['device_brand']) ? '<tr>
                                                        <td style="padding: 8px 0; font-weight: bold; color: #666;">Marka:</td>
                                                        <td style="padding: 8px 0; color: #333;">' . htmlspecialchars($formData['device_brand']) . '</td>
                                                    </tr>' : '') . '
                                                    ' . (!empty($formData['device_model']) ? '<tr>
                                                        <td style="padding: 8px 0; font-weight: bold; color: #666;">Model:</td>
                                                        <td style="padding: 8px 0; color: #333;">' . htmlspecialchars($formData['device_model']) . '</td>
                                                    </tr>' : '') . '
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin: 30px 0; background-color: #e55a2b; border-radius: 8px;">
                                        <tr>
                                            <td style="padding: 20px; text-align: center;">
                                                <h3 style="margin: 0 0 10px 0; font-size: 18px; color: white;">📞 Acil Durumda Bize Ulaşın</h3>
                                                <a href="tel:' . htmlspecialchars($contactPhone) . '" style="font-size: 24px; font-weight: bold; color: white; text-decoration: none; display: inline-block; padding: 10px 20px; background-color: rgba(255,255,255,0.2); border-radius: 5px;">' . htmlspecialchars($contactPhone) . '</a>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <p style="font-size: 14px; color: #666; line-height: 1.6; margin: 20px 0 0 0;">
                                        <strong>Not:</strong> Bu e-posta otomatik olarak gönderilmiştir. Lütfen bu e-postaya yanıt vermeyin. 
                                        Sorularınız için yukarıdaki telefon numarasını kullanabilirsiniz.
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td style="background-color: #f8f9fa; padding: 20px; text-align: center; border-top: 1px solid #ddd;">
                                    <p style="margin: 0; font-size: 14px; color: #666;">' . htmlspecialchars($companyName) . '</p>
                                    <p style="margin: 5px 0 0 0; font-size: 12px; color: #999;">© ' . date('Y') . ' Tüm hakları saklıdır.</p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </body>
        </html>';
        
        return $html;
    }
    
    /**
     * Müşteri iletişim formu onay e-posta şablonu
     */
    private function generateCustomerContactConfirmationTemplate($formData) {
        $contactPhone = defined('CONTACT_PHONE') ? CONTACT_PHONE : '0312 466 0 667';
        $companyName = defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis';
        
        $html = '
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
        </head>
        <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f5f5f5;">
            <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5;">
                <tr>
                    <td align="center" style="padding: 20px;">
                        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border: 1px solid #ddd;">
                            <tr>
                                <td style="background-color: #e55a2b; color: white; padding: 30px; text-align: center;">
                                    <h1 style="margin: 0; font-size: 28px;">✅ Mesajınız Alındı!</h1>
                                    <p style="margin: 10px 0 0 0; font-size: 18px;">En kısa sürede size dönüş yapacağız</p>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding: 30px;">
                                    <p style="font-size: 16px; color: #333; margin: 0 0 20px 0;">Sayın <strong>' . htmlspecialchars($formData['name'] ?? '') . '</strong>,</p>
                                    
                                    <p style="font-size: 16px; color: #333; line-height: 1.6; margin: 0 0 20px 0;">
                                        İletişim formunuzdan gönderdiğiniz mesaj başarıyla alınmıştır. Ekibimiz en kısa sürede size dönüş yapacaktır.
                                    </p>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin: 30px 0; background-color: #e55a2b; border-radius: 8px;">
                                        <tr>
                                            <td style="padding: 20px; text-align: center;">
                                                <h3 style="margin: 0 0 10px 0; font-size: 18px; color: white;">📞 Acil Durumda Bize Ulaşın</h3>
                                                <a href="tel:' . htmlspecialchars($contactPhone) . '" style="font-size: 24px; font-weight: bold; color: white; text-decoration: none; display: inline-block; padding: 10px 20px; background-color: rgba(255,255,255,0.2); border-radius: 5px;">' . htmlspecialchars($contactPhone) . '</a>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <p style="font-size: 14px; color: #666; line-height: 1.6; margin: 20px 0 0 0;">
                                        <strong>Not:</strong> Bu e-posta otomatik olarak gönderilmiştir. Lütfen bu e-postaya yanıt vermeyin. 
                                        Sorularınız için yukarıdaki telefon numarasını kullanabilirsiniz.
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td style="background-color: #f8f9fa; padding: 20px; text-align: center; border-top: 1px solid #ddd;">
                                    <p style="margin: 0; font-size: 14px; color: #666;">' . htmlspecialchars($companyName) . '</p>
                                    <p style="margin: 5px 0 0 0; font-size: 12px; color: #999;">© ' . date('Y') . ' Tüm hakları saklıdır.</p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </body>
        </html>';
        
        return $html;
    }
    
    /**
     * Müşteri fiyat teklifi onay e-posta şablonu
     */
    private function generateCustomerPriceQuoteConfirmationTemplate($formData) {
        $contactPhone = defined('CONTACT_PHONE') ? CONTACT_PHONE : '0312 466 0 667';
        $companyName = defined('COMPANY_NAME') ? COMPANY_NAME : 'Anka Servis';
        
        $html = '
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
        </head>
        <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f5f5f5;">
            <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5;">
                <tr>
                    <td align="center" style="padding: 20px;">
                        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border: 1px solid #ddd;">
                            <tr>
                                <td style="background-color: #e55a2b; color: white; padding: 30px; text-align: center;">
                                    <h1 style="margin: 0; font-size: 28px;">✅ Fiyat Teklifi Talebiniz Alındı!</h1>
                                    <p style="margin: 10px 0 0 0; font-size: 18px;">En kısa sürede size dönüş yapacağız</p>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding: 30px;">
                                    <p style="font-size: 16px; color: #333; margin: 0 0 20px 0;">Sayın <strong>' . htmlspecialchars($formData['name'] ?? '') . '</strong>,</p>
                                    
                                    <p style="font-size: 16px; color: #333; line-height: 1.6; margin: 0 0 20px 0;">
                                        Fiyat teklifi talebiniz başarıyla alınmıştır. Ekibimiz en kısa sürede size özel fiyat teklifi hazırlayacak ve sizinle iletişime geçecektir.
                                    </p>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin: 20px 0; border: 1px solid #ddd;">
                                        <tr>
                                            <td style="background-color: #f8f9fa; padding: 15px; border-bottom: 1px solid #ddd;">
                                                <h3 style="margin: 0; font-size: 16px;">📋 Talep Detayları</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding: 15px;">
                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="40%" style="padding: 8px 0; font-weight: bold; color: #666;">Cihaz Tipi:</td>
                                                        <td width="60%" style="padding: 8px 0; color: #333;">' . htmlspecialchars($formData['device_type'] ?? 'Belirtilmemiş') . '</td>
                                                    </tr>
                                                    ' . (!empty($formData['device_brand']) ? '<tr>
                                                        <td style="padding: 8px 0; font-weight: bold; color: #666;">Marka:</td>
                                                        <td style="padding: 8px 0; color: #333;">' . htmlspecialchars($formData['device_brand']) . '</td>
                                                    </tr>' : '') . '
                                                    ' . (!empty($formData['device_model']) ? '<tr>
                                                        <td style="padding: 8px 0; font-weight: bold; color: #666;">Model:</td>
                                                        <td style="padding: 8px 0; color: #333;">' . htmlspecialchars($formData['device_model']) . '</td>
                                                    </tr>' : '') . '
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <table width="100%" cellpadding="0" cellspacing="0" style="margin: 30px 0; background-color: #e55a2b; border-radius: 8px;">
                                        <tr>
                                            <td style="padding: 20px; text-align: center;">
                                                <h3 style="margin: 0 0 10px 0; font-size: 18px; color: white;">📞 Acil Durumda Bize Ulaşın</h3>
                                                <a href="tel:' . htmlspecialchars($contactPhone) . '" style="font-size: 24px; font-weight: bold; color: white; text-decoration: none; display: inline-block; padding: 10px 20px; background-color: rgba(255,255,255,0.2); border-radius: 5px;">' . htmlspecialchars($contactPhone) . '</a>
                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <p style="font-size: 14px; color: #666; line-height: 1.6; margin: 20px 0 0 0;">
                                        <strong>Not:</strong> Bu e-posta otomatik olarak gönderilmiştir. Lütfen bu e-postaya yanıt vermeyin. 
                                        Sorularınız için yukarıdaki telefon numarasını kullanabilirsiniz.
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td style="background-color: #f8f9fa; padding: 20px; text-align: center; border-top: 1px solid #ddd;">
                                    <p style="margin: 0; font-size: 14px; color: #666;">' . htmlspecialchars($companyName) . '</p>
                                    <p style="margin: 5px 0 0 0; font-size: 12px; color: #999;">© ' . date('Y') . ' Tüm hakları saklıdır.</p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </body>
        </html>';
        
        return $html;
    }
}

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
337 B lrw-r--r-- 2025-11-17 19:50:58
Edit Download
57.47 KB lrw-r--r-- 2025-11-17 19:50:58
Edit Download
4.49 KB lrw-r--r-- 2025-11-17 19:50:59
Edit Download
9.98 KB lrw-r--r-- 2025-11-17 19:50:59
Edit Download
8.82 KB lrw-r--r-- 2025-11-17 19:50:59
Edit Download
1.62 KB lrw-r--r-- 2025-11-17 19:50:59
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 REDROOM — Secure File Manager. All rights reserved. Built with ❤️ & Red Dark UI