<a href="../../print_cashiermain_ar_cropEnterprises_data.php" class="btn btn-success pull-right"><span
class="glyphicon glyphicon-print"></span> Print</a>
eto yung Print button ko from ar.php
pag clinick ko to dapat mapiprint nya yung nasa screen.
ang problema, may selection ako sa screen na kung saan magseselect ka ng month and kung ano lang yung data para sa month na yun is yun lang dapat yung mapiprint. pano kaya yun
eto yung ar.php
<div id="cropEnterprises" class="hidden table-container">
<!-- Button for exporting -->
<a href="../../print_cashiermain_ar_cropEnterprises_data.php" class="btn btn-success pull-right"><span
class="glyphicon glyphicon-print"></span> Print</a>
<a href="#" onclick="exportCropEnterprisesToExcel('Crop_Enterprises_AR.xlsx')" data-toggle="modal"
class="btn btn-success pull-right" style="margin-bottom: 10px; margin-right:5px;"><i
class="glyphicon glyphicon-file"></i> Export</a>
<!-- Your table code here -->
<table id="cropEnterprisesTable" class="table table-bordered table-striped table-hover">
<thead class="table ">
<tr>
<th>Name</th>
<th>Date
<select id="selectMonth" class="form-select form-control" onchange="filterData()">
<option disabled selected>All Months</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</th>
<th>Particulars</th>
<th>Business Enterprise</th>
<th>Code</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
</tr>
</thead>
<tbody id="monthlyData">
<?php
// Example SQL to fetch data for a particular month and year from cash orders
// SELECT * FROM cash_order WHERE MONTH(created_at) = 11 AND YEAR(created_at) = 2023;
$query = "SELECT * FROM credit_order WHERE business_enterprise='Crop Enterprises' ORDER BY created_at DESC";
$query_run = mysqli_query($conn, $query);
if (mysqli_num_rows($query_run) > 0) {
foreach ($query_run as $data) {
?>
<tr>
<td>
<?= $data['fullname']; ?>
</td>
<td>
<?= date('F', strtotime($data['created_at'])); ?>
</td>
<td>
<?= $data['product_name']; ?>
</td>
<td>
<?= $data['business_enterprise']; ?>
</td>
<td>
<?= $data['code']; ?>
</td>
<td>
<?= $data['quantity']; ?>
</td>
<td>
<?= number_format($data['amount'], 2, '.', ','); ?>
</td>
<td>
<?= number_format($data['totalAmount'], 2, '.', ','); ?>
</td>
</tr>
<?php
}
} else {
// echo "<h5> No Record Found </h5>";
}
?>
</tbody>
</table>
<script>
// Function to export table data to Excel
function exportCropEnterprisesToExcel(filename) {
var wb = XLSX.utils.table_to_book(document.getElementById('cropEnterprisesTable'), { sheet: "Sheet JS" });
// Modify the text of the date column
wb.Sheets["Sheet JS"]["B1"].v = "Dates";
// Save the workbook
return XLSX.writeFile(wb, filename);
}
</script>
<script>
function filterData() {
var selectedMonth = document.getElementById("selectMonth").value;
$.ajax({
type: "POST",
url: "../collectionsAR/fetch_monthly_data.php", // Replace with the actual filename where you put the PHP code
data: { selectedMonth: selectedMonth },
success: function (response) {
$("#monthlyData").html(response);
}
});
}
</script>
</div>
eto naman yung code ng nakalink sa pdf button
<?php
function generateRow()
{
$contents = '';
include_once('database.php');
$sql = "SELECT * FROM credit_order WHERE business_enterprise='Crop Enterprises' ORDER BY created_at DESC";
// use for MySQLi OOP
$query = $conn->query($sql);
while ($row = $query->fetch_assoc()) {
$contents .= "
<tr>
<td>" . $row['fullname'] . "</td>
<td>" . $row['created_at'] . "</td>
<td>" . $row['product_name'] . "</td>
<td>" . $row['business_enterprise'] . "</td>
<td>" . $row['code'] . "</td>
<td>" . $row['quantity'] . "</td>
<td>" . number_format($row['amount'], 2, '.', ',') . "</td> <!-- Add formatting here -->
<td>" . number_format($row['totalAmount'], 2, '.', ',') . "</td> <!-- Add formatting here -->
</tr>
";
}
return $contents;
}
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // 'L' for landscape
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle("Generated PDF using TCPDF");
$pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont('helvetica');
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetMargins('5', '10', '5');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetAutoPageBreak(TRUE, 10);
$pdf->SetFont('helvetica', '', 11);
$pdf->AddPage();
$content = '';
$content .= '
<h2 align="center">Cashier</h2>
<h4>Members Table</h4>
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th>Name</th>
<th>Date</th>
<th>Particulars</th>
<th>Business Enterprise</th>
<th>Code</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total Amount</th>
</tr>
';
$content .= generateRow();
$content .= '</table>';
$pdf->writeHTML($content);
$pdf->Output('members.pdf', 'I');
?>
pano gagawin ko?
class="glyphicon glyphicon-print"></span> Print</a>
eto yung Print button ko from ar.php
pag clinick ko to dapat mapiprint nya yung nasa screen.
ang problema, may selection ako sa screen na kung saan magseselect ka ng month and kung ano lang yung data para sa month na yun is yun lang dapat yung mapiprint. pano kaya yun
eto yung ar.php
<div id="cropEnterprises" class="hidden table-container">
<!-- Button for exporting -->
<a href="../../print_cashiermain_ar_cropEnterprises_data.php" class="btn btn-success pull-right"><span
class="glyphicon glyphicon-print"></span> Print</a>
<a href="#" onclick="exportCropEnterprisesToExcel('Crop_Enterprises_AR.xlsx')" data-toggle="modal"
class="btn btn-success pull-right" style="margin-bottom: 10px; margin-right:5px;"><i
class="glyphicon glyphicon-file"></i> Export</a>
<!-- Your table code here -->
<table id="cropEnterprisesTable" class="table table-bordered table-striped table-hover">
<thead class="table ">
<tr>
<th>Name</th>
<th>Date
<select id="selectMonth" class="form-select form-control" onchange="filterData()">
<option disabled selected>All Months</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</th>
<th>Particulars</th>
<th>Business Enterprise</th>
<th>Code</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
</tr>
</thead>
<tbody id="monthlyData">
<?php
// Example SQL to fetch data for a particular month and year from cash orders
// SELECT * FROM cash_order WHERE MONTH(created_at) = 11 AND YEAR(created_at) = 2023;
$query = "SELECT * FROM credit_order WHERE business_enterprise='Crop Enterprises' ORDER BY created_at DESC";
$query_run = mysqli_query($conn, $query);
if (mysqli_num_rows($query_run) > 0) {
foreach ($query_run as $data) {
?>
<tr>
<td>
<?= $data['fullname']; ?>
</td>
<td>
<?= date('F', strtotime($data['created_at'])); ?>
</td>
<td>
<?= $data['product_name']; ?>
</td>
<td>
<?= $data['business_enterprise']; ?>
</td>
<td>
<?= $data['code']; ?>
</td>
<td>
<?= $data['quantity']; ?>
</td>
<td>
<?= number_format($data['amount'], 2, '.', ','); ?>
</td>
<td>
<?= number_format($data['totalAmount'], 2, '.', ','); ?>
</td>
</tr>
<?php
}
} else {
// echo "<h5> No Record Found </h5>";
}
?>
</tbody>
</table>
<script>
// Function to export table data to Excel
function exportCropEnterprisesToExcel(filename) {
var wb = XLSX.utils.table_to_book(document.getElementById('cropEnterprisesTable'), { sheet: "Sheet JS" });
// Modify the text of the date column
wb.Sheets["Sheet JS"]["B1"].v = "Dates";
// Save the workbook
return XLSX.writeFile(wb, filename);
}
</script>
<script>
function filterData() {
var selectedMonth = document.getElementById("selectMonth").value;
$.ajax({
type: "POST",
url: "../collectionsAR/fetch_monthly_data.php", // Replace with the actual filename where you put the PHP code
data: { selectedMonth: selectedMonth },
success: function (response) {
$("#monthlyData").html(response);
}
});
}
</script>
</div>
eto naman yung code ng nakalink sa pdf button
<?php
function generateRow()
{
$contents = '';
include_once('database.php');
$sql = "SELECT * FROM credit_order WHERE business_enterprise='Crop Enterprises' ORDER BY created_at DESC";
// use for MySQLi OOP
$query = $conn->query($sql);
while ($row = $query->fetch_assoc()) {
$contents .= "
<tr>
<td>" . $row['fullname'] . "</td>
<td>" . $row['created_at'] . "</td>
<td>" . $row['product_name'] . "</td>
<td>" . $row['business_enterprise'] . "</td>
<td>" . $row['code'] . "</td>
<td>" . $row['quantity'] . "</td>
<td>" . number_format($row['amount'], 2, '.', ',') . "</td> <!-- Add formatting here -->
<td>" . number_format($row['totalAmount'], 2, '.', ',') . "</td> <!-- Add formatting here -->
</tr>
";
}
return $contents;
}
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // 'L' for landscape
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle("Generated PDF using TCPDF");
$pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont('helvetica');
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetMargins('5', '10', '5');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetAutoPageBreak(TRUE, 10);
$pdf->SetFont('helvetica', '', 11);
$pdf->AddPage();
$content = '';
$content .= '
<h2 align="center">Cashier</h2>
<h4>Members Table</h4>
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th>Name</th>
<th>Date</th>
<th>Particulars</th>
<th>Business Enterprise</th>
<th>Code</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total Amount</th>
</tr>
';
$content .= generateRow();
$content .= '</table>';
$pdf->writeHTML($content);
$pdf->Output('members.pdf', 'I');
?>
pano gagawin ko?