| Direktori : /var/www/vhosts/ccp.ac.th/smtp.ccp.ac.th/httpdocs/fertilizer/ |
| Current File : /var/www/vhosts/ccp.ac.th/smtp.ccp.ac.th/httpdocs/fertilizer/report3.php |
<!doctype html>
<html lang="en">
<!-- head -->
<?php include 'head.php'; ?>
<body>
<div class="wrapper">
<!-- เมนูด้านซ้าย -->
<?php include 'leftside.php'; ?>
<div class="main-panel">
<!-- ส่วนหัว -->
<?php include 'header.php'; ?>
<?php include 'db/database.php';
?>
<div class="content">
<div class="container-fluid">
<div class="col-md-6">
<div class="card">
<div class="card-header card-header-icon" data-background-color="rose">
<i class="material-icons"><i class="fas fa-chalkboard-teacher"></i></i>
</div>
<div class="card-content">
<h4 class="card-title">รายงานการคำนวนปุ๋ยผสมคงเหลือ</h4>
<form class="form-horizontal" id="form_home" method="get">
<div class="row">
<label class="col-md-4 label-on-left">กรุณาเลือกสหกรณ์</label>
<div class="col-md-8">
<?php
$sql = mysqli_query($link,'SELECT * FROM sahakorn') or die('Error query #12');
?>
<div class="form-group label-floating is-empty">
<label class="control-label"></label>
<select name="sahakorn" id="sahakorn" class="selectpicker" data-live-search="true" title="กรุณาเลือกสหกรณ์">
<?php
while ($Result = mysqli_fetch_array($sql)) {
?>
<option value="<?php echo $Result['sahakornID']; ?>">
<?php echo $Result['name']; ?>
</option>
<?php
}
?>
</select>
</div>
</div>
</div>
<div class="row">
<label class="col-md-4 label-on-left">กรุณาเลือกปีบัญชี</label>
<div class="col-md-8">
<?php
$year4=(date("Y")+543);
$year1=(date("Y")+543-1);
$year2=(date("Y")+543-2);
$year3=(date("Y")+543+1);
?>
<div class="form-group label-floating is-empty">
<label class="control-label"></label>
<select name="year" id="year" class="form-control" title="กรุณาเลือกปีบัญชี" required>
<option value="">กรุณาเลือก...</option>
<?php
echo '<option value="'.$year4.'" '.$selected.'>'.$year4.'</option>'."\n";
echo '<option value="'.$year1.'" '.$selected.'>'.$year1.'</option>'."\n";
echo '<option value="'.$year2.'" '.$selected.'>'.$year2.'</option>'."\n";
echo '<option value="'.$year3.'" '.$selected.'>'.$year3.'</option>'."\n";
?>
</select>
</div>
</div>
</div>
<div class="row">
<label class="col-md-3"></label>
<div class="col-md-9">
<div class="form-group form-button">
<button type="submit" class="btn btn-fill btn-rose">แสดง</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<?php
$sahakorn = isset($_GET['sahakorn'])? $_GET['sahakorn'] : '';
$year = isset($_GET['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);
?>
<div class="col-lg-11 col-md-12">
<div class="card">
<div class="card-header card-header-tabs" data-background-color="rose">
<h4 class="card-title">รายงานการคำนวนปุ๋ยผสมคงเหลือ <?php echo $name_sahakorn['name']; ?> ปี <?php echo $year; ?></h4>
</div>
<div class="card-content table-responsive">
<table id="datatables" class="table table-hover">
<thead class="text-success">
<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>
</thead>
<?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'];
?>
<tbody>
<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 class="row">
<label class="col-md-1"></label>
<div class="col-md-10">
<div class="form-group form-button">
<a id="submit1" type="button" class="btn btn-fill btn-rose" href="report_pdf3.php?sahakorn=<?php echo $sahakorn; ?>&year=<?php echo $year; ?>" target="_blank"><i class="fas fa-print"></i> พิมพ์รายงาน</a>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<!-- footer1 -->
<?php include 'footer1.php'; ?>
</div>
</div>
<!-- footer2 -->
<?php include 'footer2.php'; ?>
<!-- Mirrored from demos.creative-tim.com/material-dashboard-pro/examples/dashboard.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 20 Mar 2017 21:32:16 GMT -->
</html>