PHP 8.0.30
Preview: factor.php Size: 9.41 KB
/home/ostadcom/public_html/panel/factor.php

<?php
include "requirements.php";
include "../management/php/number2word.php";
$number = new Number2Word;
$code = intval($_GET['code']);
$factor = $connect -> prepare("select * from `tbl_factor` where `user_id` = ".$userId." and `code` = ".$code);
$factor -> execute();
$factorRow = $factor -> fetch(PDO::FETCH_ASSOC);
$a = explode(" ",$factorRow['create_date']);
$date = miladiToJalali3($a[0]);
?>
<!DOCTYPE html>
<html lang="fa">
<head>
    <meta charset="UTF-8">
    <title>فاکتور فروش <?php echo $factorRow['code']; ?></title>
    <link rel="icon" type="image/x-icon" href="assets/img/favicon.png"/>
    <link rel="stylesheet" href="assets/css/factor.css"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
    <style>
        #invoice{
            padding:0 10px;
        }
        @media print {
          @page {
            size: landscape;
            margin: 0; /* نزدیک‌ترین حالت به 'Minimum' */
          }
    
          body {
            transform: scale(0.95); /* شبیه‌سازی scale 90% */
            transform-origin: top center;
            margin: 0;
            padding: 0;
          }
        }
        tr,td{
            padding:3px !important;
        }
        .logo img {
            max-width: 85px !important;
        }
        .logo {
            height: 65px !important;
        }
    </style>
</head>
<body style="padding-top:0; margin-top:0;">
    
<div id="invoice">
    <table style="table-layout: fixed; margin-top:0">
        <tr>
            <td colspan="3" style="border:0;">
                 <div class="logo"><img src="assets/img/logo.png"> </div>
            </td>
            <td colspan="3" style="border:0;">
                <h2 style="text-align:center">پیش فاکتور فروش کالا و خدمات</h2>
            </td>
            <td colspan="3" style="border:0; text-align:left">
                <p style="margin: 0 0 6px 0;">شماره پیش فاکتور : <?php echo $factorRow['code']; ?></p>
                <p style="margin: 0">تاریخ صدور : <?php echo $date; ?></p>
            </td>
        </tr>
        <tr>
            <td colspan="9">
                <p style="margin:0; font-weight:bold; text-align:center;">مشخصات فروشنده</p>
            </td>
        </tr>
         <tr>
            <td colspan="3" style="text-align: right; border-left: unset; width: 400px;border-bottom: unset;">
                <p style="margin-top:-5px; margin-bottom:0;">نام فروشنده: گروه صنعتی استاد</p>
                <p style="margin-bottom: 0;margin-top: 5px;">شناسه ملی: 0083792546</p>
            </td>
            <td colspan="3" style="text-align: right; border-right: unset; border-left: unset;border-bottom: unset;">
                <p style="margin-top:-5px; margin-bottom:0;">شماره اقتصادی: 00834925460005</p>
                <p style="margin-bottom: 0; margin-top: 5px;">کد پستی: 3319184374</p>
            </td>
            <td colspan="3" style="text-align: right; border-right: unset;border-bottom: unset;">
                <p style="margin-top:-5px; margin-bottom:0">تلفن: <span>4-55287043</span></p>
                <p style="margin-bottom: 0; margin-top: 5px;">فکس: </p>
            </td>
        </tr>
        <tr>
            <td colspan="9" style="border-top: unset; text-align:right; padding-top: 0 !important;">آدرس: تهران، بزرگراه آیت الله سعیدی، نرسیده به ورودی اصلی شهرک صنعتی چهاردانگه، رو به روی مصلا، پلاک 285</td>
        </tr>
        <tr>
            <td colspan="9">
                <p style="margin:0; font-weight:bold; text-align:center;">مشخصات خریدار</p>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: right; border-left: unset; width: 400px;border-bottom: unset;">
                <p style="margin-top:-5px; margin-bottom:0;">نام خریدار: <?php echo $factorRow['name']; ?> </p>
                <p style="margin-bottom: 0; margin-top: 5px;">تلفن: <?php echo $factorRow['cellPhone']; ?> </p>
            </td>
            <td colspan="3" style="text-align: right; border-right: unset; border-left: unset;border-bottom: unset;">
                <p style="margin-top:-5px; margin-bottom:0">شماره اقتصادی: </p>
                <p style="margin-bottom: 0; margin-top: 5px;">کد پستی: </p>
            </td>
            <td colspan="3" style="text-align: right; border-right: unset;border-bottom: unset;vertical-align: unset;">
                <p style="margin-top:-5px; margin-bottom:0">شماره ثبت/شماره ملی: </p>
            </td>
        </tr>
        <tr>
            <td colspan="9" style="border-top: unset; text-align:right; padding-top: 0 !important;">
                <?php echo $factorRow['address']; ?>
            </td>
        </tr>
        <tr>
            <td colspan="9">
                <p style="margin:0; font-weight:bold; text-align:center;">مشخصات کالا یا خدمات مورد معامله</p>
            </td>
        </tr>
        <tr>
            <th>ردیف</th>
            <th>کد کالا</th>
            <th colspan="3">شرح کالا / خدمت</th>
            <th>تعداد/مقدار</th>
            <th>واحد</th>
            <th>مبلغ واحد <span style="font-size: 13px; color: #555; font-weight: normal;">(تومان)</span></th>
            <th>مبلغ کل <span style="font-size: 13px; color: #555; font-weight: normal;">(تومان)</span></th>
        </tr>
        <?php
        $count=0;
        $order = $connect -> prepare("select * from `tbl_order` where `factor_id` = ".$factorRow['id']);
        $order -> execute();
        while ($orderRows = $order -> fetch(PDO::FETCH_ASSOC)){
            $count++;
        ?>
        <tr>
            <td><?php echo $count; ?></td>
            <td><?php echo $orderRows['code']; ?></td>
            <td colspan="3" style="text-align:right"><?php echo $orderRows['product']; ?></td>
            <td><?php echo $orderRows['count']; ?></td>
            <td>عدد</td>
            <td><?php echo number_format($orderRows['price']); ?></td>
            <td><?php echo number_format($orderRows['total_pice']); ?></td>
        </tr>
        <?php
        }
        ?>
        <tr>
            <td colspan="5" rowspan="5">
                <?php echo $number->numberToWords($factorRow['totalPrice']); ?> تومان
            </td>
            <td colspan="2">جمع کل</td>
            <td colspan="2"><?php echo number_format($factorRow['price']); ?> تومان</td>
        </tr>
        <tr>
            <td colspan="2">اضافات</td>
            <td colspan="2"></td>
        </tr>
        <tr>
            <td colspan="2">تخفیف</td>
            <td colspan="2"></td>
        </tr>
        <tr>
            <td colspan="2">مالیات و عوارض</td>
            <td colspan="2"><?php echo number_format($factorRow['tax']); ?> تومان</td>
        </tr>
        <tr>
            <td colspan="2">مبلغ پرداختی</td>
            <td colspan="2"><?php echo number_format($factorRow['totalPrice']); ?> تومان</td>
        </tr>
        <tr>
            <td colspan="5" style="padding:0 !important">
                شرایط و نحوه فروش:  
                <span style="margin-right: 35px; margin-left: 50px;"><span style="width: 17px; height: 17px; display: inline-block; border: 1px solid #333; position: relative; top: 6px; left: 7px;"></span>نقدی</span>
                <span><span style="width: 17px; height: 17px; display: inline-block; border: 1px solid #333; position: relative; top: 6px; left: 7px;"></span>غیرنقدی</span>
            </td>
            <td colspan="4"></td>
        </tr>
        <tr style="vertical-align:unset">
            <td colspan="9" style="text-align:right">
                <div style="min-height:50px;">
                <p style="margin:0;">توضیحات</p>
                </div>
            </td>
        </tr>
        <tr style="vertical-align:unset">
            <td colspan="5" style="text-align:right; height:50px;">مهر و امضای فروشنده</td>
            <td colspan="4" style="text-align:right; height:50px;">مهر و امضای خریدار</td>
        </tr>
    </table>
</div>

<button onclick="printPage()" class="btn printBtn">چاپ فاکتور</button>
<button onclick="generatePDF()" class="btn downloadBtn">دانلود فاکتور</button>
<script>
    function printPage() {
        window.print();
    }
    async function generatePDF() {
        const { jsPDF } = window.jspdf;
        const invoice = document.getElementById("invoice");

        const canvas = await html2canvas(invoice, { scale: 3 });
        const imgData = canvas.toDataURL("image/jpeg");

        const pdf = new jsPDF('p', 'mm', 'a4');
        const pageWidth = pdf.internal.pageSize.getWidth();
        const margin = 10;

        const availableWidth = pageWidth - margin * 2;
        const imgHeight = (canvas.height * availableWidth) / canvas.width;

        pdf.addImage(imgData, 'PNG', margin, 5, availableWidth, imgHeight);
        pdf.save("Invoice.pdf");
    }
</script>
</body>
</html>

Directory Contents

Dirs: 4 × Files: 22

Name Size Perms Modified Actions
assets DIR
- drwxr-xr-x 2025-12-31 12:22:49
Edit Download
fonts DIR
- drwxr-xr-x 2025-12-31 12:24:17
Edit Download
php DIR
- drwxr-xr-x 2026-07-27 02:47:44
Edit Download
upload DIR
- drwxr-xr-x 2025-12-31 12:24:42
Edit Download
1.79 KB lrw-r--r-- 2025-04-06 13:27:34
Edit Download
7.65 KB lrw-r--r-- 2025-04-10 13:07:24
Edit Download
13.41 KB lrw-r--r-- 2025-05-27 08:19:12
Edit Download
16.85 KB lrw-r--r-- 2025-06-10 13:21:48
Edit Download
12.08 KB lrw-r--r-- 2025-06-11 11:37:00
Edit Download
3.93 KB lrw-r--r-- 2025-07-28 12:18:26
Edit Download
13.20 KB lrw-r--r-- 2025-06-11 12:42:38
Edit Download
9.41 KB lrw-r--r-- 2025-07-28 12:27:03
Edit Download
395 B lrw-r--r-- 2025-04-07 08:49:42
Edit Download
1.50 KB lrw-r--r-- 2025-12-31 12:29:08
Edit Download
3.78 KB lrw-r--r-- 2025-05-27 08:25:08
Edit Download
5.87 KB lrw-r--r-- 2025-12-31 12:47:11
Edit Download
3.04 KB lrw-r--r-- 2025-06-12 11:43:14
Edit Download
10.37 KB lrw-r--r-- 2025-04-09 12:14:46
Edit Download
8.22 KB lrw-r--r-- 2025-06-09 09:33:56
Edit Download
14.27 KB lrw-r--r-- 2025-07-23 10:59:49
Edit Download
9.94 KB lrw-r--r-- 2025-04-12 09:04:30
Edit Download
688 B lrw-r--r-- 2025-04-10 11:37:52
Edit Download
7.42 KB lrw-r--r-- 2025-06-12 12:01:02
Edit Download
12.54 KB lrw-r--r-- 2025-04-12 11:12:22
Edit Download
7.76 KB lrw-r--r-- 2025-04-12 11:28:36
Edit Download
9.86 KB lrw-r--r-- 2025-05-27 08:35:32
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).