Merhaba,
Elinde whmcs fatura tasarımı olan var mı ? invoicepdf.tpl modern ve şık bir tasarım olursa kullanmak isterim.
Teşekkürler.
WHMCS Fatura PDF tasarımı Hak
2
●164
- 01-11-2025, 20:47:45
<?php /** * WHMCS PDF Fatura Tasarımı * * Bu dosya, WHMCS tarafından oluşturulan PDF faturaların görünümünü kontrol eder. * Düzenleme yaparken dikkatli olun. WHMCS'in TCPDF kütüphanesini kullandığını unutmayın. * HTML/CSS burada ÇALIŞMAZ. */ if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } // --- TASARIM AYARLARI --- // Renkleri Tanımla (RGB formatında) $colors = [ 'dark' => [45, 55, 72], // Koyu Metin (Örn: #2d3748) 'gray' => [113, 128, 150], // Normal Metin (Örn: #718096) 'lightgray' => [247, 250, 252], // Tablo Arka Planı (Örn: #f7fafc) 'border' => [226, 232, 240], // Kenarlıklar (Örn: #e2e8f0) 'primary' => [34, 197, 94], // Ana Renk (Yeşil, örn: #22c55e) 'white' => [255, 255, 255] ]; // PDF objesine renkleri atama (kolay erişim için) $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); $pdf->SetDrawColor($colors['border'][0], $colors['border'][1], $colors['border'][2]); $pdf->SetFont('helvetica', '', 10); // --- SAYFA BAŞLIĞI (HEADER) --- // Logo // WHMCS logoyu otomatik olarak $logo değişkenine atar $logoy = $pdf->GetY(); $pdf->Image($logo, 15, $logoy, 60); // (dosya, x, y, genişlik) // Fatura Başlığı (Sağ Taraf) $pdf->SetXY(130, $logoy); $pdf->SetFont('helvetica', 'B', 24); $pdf->SetTextColor($colors['dark'][0], $colors['dark'][1], $colors['dark'][2]); // mb_strtoupper Türkçe karakterleri (İ, Ü vb.) destekler $pdf->Cell(70, 10, mb_strtoupper("{$_L.invoicetitle}", 'UTF-8'), 0, 1, 'R'); // Fatura Numarası $pdf->SetFont('helvetica', '', 10); $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); $pdf->Cell(190, 6, "{$_L.invoicenumber}{$invoicenum}", 0, 1, 'R'); $pdf->Ln(15); // Logodan sonra boşluk bırak // --- FATURA DURUMU (ÖDENDİ / ÖDENMEDİ DAMGASI) --- $status_y_pos = 100; // Damganın dikey konumu if ($status == "Paid") { $pdf->SetFont('helvetica', 'B', 48); $pdf->SetTextColor(56, 161, 105, 15); // Yarı saydam Yeşil (RGBa) $pdf->StartTransform(); $pdf->Rotate(45, 105, $status_y_pos); // Açı, X-merkez, Y-merkez $pdf->Text(70, $status_y_pos, mb_strtoupper("{$_L.invoicespaid}", 'UTF-8')); $pdf->StopTransform(); } elseif ($status == "Unpaid") { $pdf->SetFont('helvetica', 'B', 48); $pdf->SetTextColor(224, 38, 38, 15); // Yarı saydam Kırmızı (RGBa) $pdf->StartTransform(); $pdf->Rotate(45, 105, $status_y_pos); $pdf->Text(50, $status_y_pos, mb_strtoupper("{$_L.invoicesunpaid}", 'UTF-8')); $pdf->StopTransform(); } elseif ($status == "Cancelled") { $pdf->SetFont('helvetica', 'B', 48); $pdf->SetTextColor(113, 128, 150, 15); // Yarı saydam Gri (RGBa) $pdf->StartTransform(); $pdf->Rotate(45, 105, $status_y_pos); $pdf->Text(60, $status_y_pos, mb_strtoupper("{$_L.invoicescancelled}", 'UTF-8')); $pdf->StopTransform(); } // Renkleri ve fontu sıfırla $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); $pdf->SetFont('helvetica', '', 10); // --- FİRMA VE MÜŞTERİ BİLGİLERİ --- $yPos = $pdf->GetY(); // Firma Bilgileri (Sol Taraf) $pdf->SetXY(15, $yPos); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetTextColor($colors['dark'][0], $colors['dark'][1], $colors['dark'][2]); $pdf->Cell(80, 6, "{$_L.invoicesfrom}", 0, 1, 'L'); $pdf->SetFont('helvetica', '', 10); $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); // WHMCS $companyaddress değişkenini otomatik basar $pdf->MultiCell(80, 5, $companyaddress, 0, 'L'); // Müşteri Bilgileri (Sağ Taraf) $pdf->SetXY(115, $yPos); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetTextColor($colors['dark'][0], $colors['dark'][1], $colors['dark'][2]); $pdf->Cell(80, 6, "{$_L.billto}", 0, 1, 'L'); $pdf->SetFont('helvetica', '', 10); $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); // WHMCS $clientname, $clientaddress1 vb. değişkenleri otomatik basar if ($clientname) { $pdf->Cell(80, 5, $clientname, 0, 1, 'L'); } if ($clientaddress1) { $pdf->Cell(80, 5, $clientaddress1, 0, 1, 'L'); } if ($clientaddress2) { $pdf->Cell(80, 5, $clientaddress2, 0, 1, 'L'); } if ($clientcity || $clientstate || $clientpostcode) { $pdf->Cell(80, 5, $clientcity . ", " . $clientstate . " " . $clientpostcode, 0, 1, 'L'); } if ($clientcountryname) { $pdf->Cell(80, 5, $clientcountryname, 0, 1, 'L'); } if ($customfields) { foreach ($customfields as $customfield) { $pdf->Cell(80, 5, $customfield['fieldname'] . ': ' . $customfield['value'], 0, 1, 'L'); } } $pdf->Ln(10); // --- FATURA DETAYLARI (TARİH, SON ÖDEME) --- $yPos = $pdf->GetY(); $pdf->SetFillColor($colors['lightgray'][0], $colors['lightgray'][1], $colors['lightgray'][2]); $pdf->SetTextColor($colors['dark'][0], $colors['dark'][1], $colors['dark'][2]); $pdf->SetDrawColor($colors['border'][0], $colors['border'][1], $colors['border'][2]); $pdf->SetLineWidth(0.2); // Arka plan kutusu $pdf->Rect(15, $yPos, 180, 18, 'DF'); // x, y, w, h, style (Draw, Fill) // Fatura Tarihi $pdf->SetFont('helvetica', 'B', 9); $pdf->SetXY(20, $yPos + 3); $pdf->Cell(60, 5, mb_strtoupper("{$_L.invoicedate}", 'UTF-8'), 0, 1, 'L'); $pdf->SetFont('helvetica', '', 9); $pdf->SetXY(20, $yPos + 9); $pdf->Cell(60, 5, $date, 0, 1, 'L'); // Son Ödeme Tarihi $pdf->SetFont('helvetica', 'B', 9); $pdf->SetXY(80, $yPos + 3); $pdf->Cell(60, 5, mb_strtoupper("{$_L.invoiceduedate}", 'UTF-8'), 0, 1, 'C'); $pdf->SetFont('helvetica', '', 9); $pdf->SetXY(80, $yPos + 9); $pdf->Cell(60, 5, $duedate, 0, 1, 'C'); // Ödeme Yöntemi $pdf->SetFont('helvetica', 'B', 9); $pdf->SetXY(140, $yPos + 3); $pdf->Cell(50, 5, mb_strtoupper("{$_L.paymentmethod}", 'UTF-8'), 0, 1, 'R'); $pdf->SetFont('helvetica', '', 9); $pdf->SetXY(140, $yPos + 9); $pdf->Cell(50, 5, $paymentmethod, 0, 1, 'R'); // --- FATURA KALEMLERİ TABLOSU --- $pdf->Ln(10); // Tablo Başlığı $pdf->SetFont('helvetica', 'B', 10); $pdf->SetFillColor($colors['dark'][0], $colors['dark'][1], $colors['dark'][2]); $pdf->SetTextColor($colors['white'][0], $colors['white'][1], $colors['white'][2]); $pdf->SetDrawColor($colors['dark'][0], $colors['dark'][1], $colors['dark'][2]); $pdf->SetLineWidth(0.3); // Sadece üst ve alt kenarlık (T ve B) veya tümü (1) $borderStyle = 1; $pdf->Cell(150, 8, " {$_L.invoicesdescription}", $borderStyle, 0, 'L', 1); $pdf->Cell(30, 8, "{$_L.invoicesamount} ", $borderStyle, 1, 'R', 1); // Tablo İçeriği $pdf->SetFont('helvetica', '', 9); $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); $pdf->SetFillColor($colors['lightgray'][0], $colors['lightgray'][1], $colors['lightgray'][2]); $pdf->SetDrawColor($colors['border'][0], $colors['border'][1], $colors['border'][2]); $pdf->SetLineWidth(0.2); $fill = 0; // WHMCS $items değişkenini otomatik basar foreach ($items as $item) { $pdf->SetFillColor($fill ? $colors['white'][0] : $colors['lightgray'][0], $fill ? $colors['white'][1] : $colors['lightgray'][1], $fill ? $colors['white'][2] : $colors['lightgray'][2]); // Açıklama hücresi (MultiCell satır atlamasına izin verir) // MultiCell(genişlik, yükseklik, metin, kenarlık, hizalama, dolgu, satır atlama, x, y, ... $pdf->MultiCell(150, 7, " " . $item['description'], 'LR', 'L', 1, 0, 15, $pdf->GetY(), true); // Geçerli Y pozisyonunu al (MultiCell'den sonra) $currentY = $pdf->GetY(); // Son hücrenin yüksekliğini al $cellHeight = $pdf->GetLastCellHeight(); // Tutar hücresi // Açıklama hücresiyle aynı Y pozisyonuna ve yüksekliğe ayarla $pdf->SetY($currentY - $cellHeight); $pdf->SetX(165); // 15 (sol marj) + 150 (açıklama genişliği) $pdf->MultiCell(30, $cellHeight, $item['amount'] . " ", 'LR', 'R', 1, 1, 165, $pdf->GetY(), true); $fill = !$fill; } // Tabloyu kapatan alt çizgi $pdf->Cell(180, 0, '', 'T', 1); // --- TOPLAMLAR BÖLÜMÜ --- $pdf->Ln(5); $pdf->SetFont('helvetica', '', 10); $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); // Ara Toplam $pdf->Cell(130, 6, "{$_L.invoicessubtotal}:", 0, 0, 'R'); $pdf->Cell(50, 6, $subtotal . " ", 0, 1, 'R'); // Vergi Kalemleri if ($taxitems) { foreach ($taxitems as $taxitem) { $pdf->Cell(130, 6, $taxitem['taxrate'] . "% " . $taxitem['taxname'] . ":", 0, 0, 'R'); $pdf->Cell(50, 6, $taxitem['amount'] . " ", 0, 1, 'R'); } } // Kredi (varsa) if ($credit) { $pdf->Cell(130, 6, "{$_L.invoicescredit}:", 0, 0, 'R'); $pdf->Cell(50, 6, $credit . " ", 0, 1, 'R'); } // Genel Toplam (Vurgulu) $pdf->Ln(2); $pdf->SetFont('helvetica', 'B', 12); $pdf->SetFillColor($colors['dark'][0], $colors['dark'][1], $colors['dark'][2]); $pdf->SetTextColor($colors['white'][0], $colors['white'][1], $colors['white'][2]); $pdf->SetX(115); // Sağa yaslamak için X pozisyonunu ayarla $pdf->Cell(40, 10, " {$_L.invoicestotal}:", 0, 0, 'R', 1); $pdf->Cell(45, 10, $total . " ", 0, 1, 'R', 1); // Ödenen Tutar if ($status == "Paid") { $pdf->Ln(2); $pdf->SetFont('helvetica', 'B', 11); $pdf->SetFillColor($colors['primary'][0], $colors['primary'][1], $colors['primary'][2]); $pdf->SetTextColor($colors['white'][0], $colors['white'][1], $colors['white'][2]); $pdf->SetX(115); $pdf->Cell(40, 10, " {$_L.invoicespaid}:", 0, 0, 'R', 1); $pdf->Cell(45, 10, $total . " ", 0, 1, 'R', 1); } // --- ALT BİLGİ (FOOTER) --- // Sayfanın altından 40 birim yukarıya konumlan $pdf->SetY(-40); $pdf->SetFont('helvetica', '', 9); $pdf->SetTextColor($colors['gray'][0], $colors['gray'][1], $colors['gray'][2]); $pdf->SetDrawColor($colors['border'][0], $colors['border'][1], $colors['border'][2]); $pdf->SetLineWidth(0.2); // Üst çizgi $pdf->Cell(180, 0, '', 'T', 1, '', 0, 15); $pdf->Ln(2); // Fatura Notları (varsa) if ($notes) { $pdf->SetFont('helvetica', 'B', 9); $pdf->Cell(180, 6, "{$_L.invoicesnotes}:", 0, 1, 'L', 0, 15); $pdf->SetFont('helvetica', '', 9); $pdf->MultiCell(180, 5, $notes, 0, 'L', 0, 1, 15); $pdf->Ln(5); } // Ödeme/Banka Bilgileri $pdf->SetFont('helvetica', 'B', 9); $pdf->Cell(180, 6, "{$_L.paymentdetails}:", 0, 1, 'L', 0, 15); $pdf->SetFont('helvetica', '', 9); // WHMCS $paymentdetails değişkenini otomatik basar $pdf->MultiCell(180, 5, $paymentdetails, 0, 'L', 0, 1, 15); // Teşekkür Mesajı $pdf->Ln(5); $pdf->SetFont('helvetica', 'I', 10); $pdf->SetTextColor($colors['primary'][0], $colors['primary'][1], $colors['primary'][2]); $pdf->Cell(180, 6, "Bizi tercih ettiğiniz için teşekkür ederiz!", 0, 1, 'C'); ?>denermisin.