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