Hi
I have a issue in print data directly from clicking print button.
Below is my code and working fine. if click print button system sends the data to another page not to printer directly. pls help me
HTML page
<style type="text/css"></style>
<?php
include '../templete/header.php';
?>
<Script Language="javascript">
function change_action()
{
var frm_obj=document.getElementById("frm");
frm_obj.action="data.php";
}
</Script>
<table class="tbl_table" align="center">
<form action="" method="POST" id="frm" >
<tr>
<td class="td_title" colspan="2"><strong>Outstanding Balance Report</strong></td>
</tr>
<tr>
<td class="td_class_right">Until:</td>
<td><input class="textdesign" type="text" id="datepicker1" name="datefrom" /></td>
</tr>
<tr>
<td class="td_button" colspan="2">
<input class="buttondesign" type="submit" value="Search" name="search" onclick="change_action()">
<input class="buttondesign" type="submit" value="print" name="print" onclick="change_action()">
</td>
</tr>
</form>
</table>
data.php
<?php
include_once '../inc/connection.inc.php';
?>
<?php
if (isset($_POST['search']) && $_POST['search'] != "" )
{
$datefrom=$_POST["datefrom"];
$s = $dbh->prepare("EXECUTE usp_OutStanding_Balance ?");
$s->bindParam(1, $datefrom, PDO::PARAM_STR);
$stmt = $s->execute();
$stmt = $dbh->query("SELECT * FROM vw_OutStanding_Balance ORDER BY MVName");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
include 'view.html.php';
}
?>
<?php
if (isset($_POST['print']) && $_POST['print'] != "" )
{
$datefrom=$_POST["datefrom"];
$s = $dbh->prepare("EXECUTE usp_OutStanding_Balance ?");
$s->bindParam(1, $datefrom, PDO::PARAM_STR);
$stmt = $s->execute();
$stmt = $dbh->query("SELECT * FROM vw_OutStanding_Balance ORDER BY MVName");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
include 'print.html.php';
}
?>
print.html.php
<?php
include '../templete/print_head.php';
?>
<?php
$groupby = '';
$displaySubTotal = FALSE;
$subTotal = 0;
$grandTotal = 0;
$sub_debit=0; // maideen
$grn_debit=0; // maideen
$sub_credit=0; // maideen
$grn_credit=0; // maideen
$sub_bal=0; // maideen
$grn_bal=0; // maideen
?>
<div class="title">Outstanding Report</div>
<table width="100%" align="center" cellpadding="4" cellspacing="1" class=tbl_table">
<tr><td colspan="6"><hr /></td></tr>
<tr>
<td class="tdempty"></td>
<td class="tbl_header">MV CODE</td>
<td class="tbl_header">MV NAME</td>
<td class="tbl_header_right">DEBIT</td>
<td class="tbl_header_right">CREDIT</td>
<td class="tbl_header_right">BALANCE</td>
<td class="tdempty"></td>
</tr>
<tr><td colspan="6"><hr /></td></tr>
<?php if(isset($stmt))
{
while($row = $stmt->fetch()):
if($groupby!=$row['MVName']):
if($displaySubTotal): ?>
<?php
$grn_debit += $sub_debit;
$sub_debit=0;
$grn_credit += $sub_credit;
$sub_credit=0;
$grn_bal += $sub_bal;
$sub_bal=0;
else:
$displaySubTotal = TRUE;
endif;
$groupby = $row['MVName'];
endif;
?>
<tr>
<td class="tdempty"></td>
<td class="tbl_content"><?php echo $row['MVcode'];?></td>
<td class="tbl_content"><?php echo $row['MVName'];?></td>
<td class="tbl_content_right"><?php echo number_format($row['Debit'],2) ;?></td>
<td class="tbl_content_right"><?php echo number_format($row['Credit'],2) ;?></td>
<td class="tbl_content_right"><?php echo number_format($row['Balance'],2) ;?></td>
<td class="tdempty"></td>
</td>
<?php
$sub_debit += $row['Debit'];
$sub_credit += $row['Credit'];
$sub_bal += $row['Balance'];
endwhile;
$grn_debit += $sub_debit;
$grn_credit += $sub_credit;
$grn_bal += $sub_bal;
?>
<tr><td colspan="6"><hr /></td></tr>
<tr>
<td colspan="2">
<td class="tbl_subtotal_left"><b>Grand Total</b></td>
<td class="tbl_subtotal_right"><b><?php echo number_format($grn_debit,2); ?></b></td>
<td class="tbl_subtotal_right"><b><?php echo number_format($grn_credit,2); ?></b></td>
<td class="tbl_subtotal_right"><b><?php echo number_format($grn_bal,2); ?></b></td>
</tr>
<tr><td colspan="6"><hr /></td></tr>
<?php }?>
</table>
<?php unset($dbh); unset($stmt); ?>
Pls help me
Maideen