Mini Shell
<?php
include 'mpdf/mpdf.php';
include 'db/database.php';
ob_start();
?>
<link rel="icon" type="image/x-icon" href="icon1.ico" />
<link rel="apple-touch-icon" sizes="76x76" href="assets/img/logo1.gif" />
<html lang="en">
<head>
</head>
<body>
<?php
$sahakorn= $_GET['sahakorn'];
$year= $_GET['year'];
if(empty($year)){
}else{
//ดึงข้อมูลจากตารางมาแสดง
$sql_report2 = "SELECT * FROM calculate_remaining AS t1 LEFT JOIN sahakorn AS t2 ON (t1.sahakornID = t2.sahakornID) LEFT JOIN formula AS t3 ON (t1.formulaID = t3.formulaID) WHERE t1.sahakornID = $sahakorn AND t1.year = $year ";
$result_report2 = mysqli_query($link, $sql_report2);
//ดึงข้อมูลแสดงสวนหัว
$sql_name = "SELECT * FROM sahakorn WHERE sahakornID = $sahakorn ";
$result_name = mysqli_query($link, $sql_name);
$name_sahakorn = mysqli_fetch_assoc($result_name);
?>
<h3 class="text-center"><strong><?php echo $name_sahakorn['name']; ?> </strong></h3>
<h4 class="text-center"><strong>รายงานการคำนวนปุ๋ยผสมคงเหลือ ปีบัญชี <?php echo $year; ?></strong></h4>
<section class="content">
<div class="col-md-8 col-md-offset-2">
<div class="table-responsive">
<table align="center"id="mytable" class="table table-bordered">
<thead >
<tr class="active">
<th class="text-center">สูตรปุ๋ยที่ผสม</th>
<th class="text-right">ปุ๋ยผสมคงเหลือยกมาต้นปี</th>
<th class="text-right">รับจาการผลิต</th>
<th class="text-right">รวม</th>
<th class="text-right">ขายปุ๋ยผสม</th>
<th class="text-right">เบิกใช้</th>
<th class="text-right">ปุ๋ยผสมคงเหลือสิ้นปี</th>
<th class="text-right">คิดเป็นกระสอบ</th>
<th class="text-right">ปริมาณนับได้</th>
<th class="text-right">ขาด/เกิน</th>
</tr>
</thead>
<tbody>
<?php
$le = 0.00;
$cq = 0.00;
$tis = 0.00;
$cfr = 0.00;
$wd = 0.00;
$smf = 0.00;
$sum_sum_sum = 0.00;
$rfp = 0.00;
$mfr = 0.00;
$sum_sum11 = 0.00;
while ($row_report2 = mysqli_fetch_array($result_report2)) {
$sum_sum11 = $row_report2['remaining_pui']+$row_report2['from_production'];
//ผลรวมแถวล่างสุด
$mfr = $mfr + $row_report2['remaining_pui'];
$rfp = $rfp + $row_report2['from_production'];
$sum_sum_sum = $sum_sum_sum + $sum_sum11;
$smf = $smf + $row_report2['sell_pui'];
$wd = $wd + $row_report2['use'];
$cfr = $cfr + $row_report2['pui_year_balance'];
$tis = $tis + $row_report2['sack_R'];
$cq = $cq + $row_report2['countable_R'];
$le = $le + $row_report2['tooshort_R'];
?>
<tr>
<td class="text-center"><?php echo $row_report2['name_formula']; ?></td>
<td class="text-right"><?php echo number_format($row_report2['remaining_pui'],2); ?></td>
<td class="text-right"><?php echo number_format($row_report2['from_production'],2); ?></td>
<td class="text-right"><?php echo number_format($sum_sum11,2); ?></td>
<td class="text-right"><?php echo number_format($row_report2['sell_pui'],2); ?></td>
<td class="text-right"><?php echo number_format($row_report2['use'],2); ?></td>
<td class="text-right"><?php echo number_format($row_report2['pui_year_balance'],2); ?></td>
<td class="text-right"><?php echo number_format($row_report2['sack_R'],2); ?></td>
<td class="text-right"><?php echo number_format($row_report2['countable_R'],2); ?></td>
<td class="text-right"><?php echo number_format($row_report2['tooshort_R'],2); ?></td>
</tr>
<?php } ?>
<tr>
<td class="text-center">ผลรวม</td>
<td class="text-right"><?php echo number_format($mfr,2); ?></td>
<td class="text-right"><?php echo number_format($rfp,2); ?></td>
<td class="text-right"><?php echo number_format($sum_sum_sum,2); ?></td>
<td class="text-right"><?php echo number_format($smf,2); ?></td>
<td class="text-right"><?php echo number_format($wd,2); ?></td>
<td class="text-right"><?php echo number_format($cfr,2); ?></td>
<td class="text-right"><?php echo number_format($tis,2); ?></td>
<td class="text-right"><?php echo number_format($cq,2); ?></td>
<td class="text-right"><?php echo number_format($le,2); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<?php } ?>
<?php
include 'function_datethai.php';
date_default_timezone_set("Asia/Bangkok");
$eng_date=time();
$html = ob_get_contents();
ob_end_clean();
$mpdf=new mPDF('utf-8','A4-L');
$mpdf->margin_header = 9;
$mpdf->SetHeader(' | รายงานการคำนวนปุ๋ยผสมคงเหลือ | ออกรายงานเมื่อ: '.thai_date($eng_date));
$mpdf->margin_footer = 9;
$mpdf->SetFooter('หน้าที่ {PAGENO}');
// Define a Landscape page size/format by name
//$mpdf=new mPDF('utf-8', 'A4-L');
// Define a page size/format by array - page will be 190mm wide x 236mm height
//$mpdf=new mPDF('utf-8', array(190,236));
$stylesheet = file_get_contents('assets/css/printpdf.css');
//$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html,2);
//$mpdf->Output();
$mpdf->Output(time().'.pdf','I');
exit;
?>
</body>
</html>
Zerion Mini Shell 1.0