【php开源代码栏目提醒】:本文主要为网学会员提供AdminReport.php,希望对需要AdminReport.php网友有所帮助,学习一下!
<?php
require_once("common/common.php");
require_once("common/page.php");
require_once("Store.php");
//**********************************************************
class CThisPage extends CPhpPage
{
public $m_stores;
public $m_kind = 'I';
public $m_date;
public function __construct()
{
parent::__construct(__FILE__);
$this->Dispatch();
}
public function OnLoad($para)
{
parent::setPageTitle('库存管理');
$this->vsSet('toExport', 'no');
if($this->IsPostBack()) {
$this->m_kind = trim($_POST['kind']);
$this->m_date = trim($_POST['date']);
}
return true;
}
public function OnFinalize()
{
if(!$this->validate()) return;
$this->m_date = empty($this->m_date) ? date("Y-m-d") : $this->m_date;
$from = $this->m_date . ' 00:00:00';
$to = addDate($this->m_date, 1) . ' 00:00:00';
Store::getAll($this->m_stores, $this->m_kind, $from, $to);
//--------------------------------------
$this->vsSet('kindExport', $this->m_kind);
$this->vsSet('dateExport', $this->m_date);
}
public function btnSearch_click($para = null)
{
}
public function btnExport_click($para = null)
{
$this->vsSet('toExport', 'yes');
}
// 服务器端数据验证函数
public function validate()
{
// ... 实现略
return true;
}
}
$page = new CThisPage();
require_once('common/header.inc.php');
?>
<form name='frmSubmit' method='post' action='AdminReport.php'>
<?$page->vsLocate();?>
<script language="javascript">
<!--
function doSearchCheck(){
//...验证略
return true;
}
-->
</script>
<table border='0' cellpadding='0' cellspacing='0' width='100%' class='content_block_border'>
<tr><td class='content_block_title' align='center'>
<?echo $page->m_kind == 'I' ? '入库' : '出库';?>日报表 [<?echo $page->m_date;?>]</td></tr>
<tr><td>
<table border='1' cellpadding='3' cellspacing='0' width='100%' bordercolor='skyblue' style='border-collapse:collapse'>
<tr class='caption_bg'><th width='50%'>品名</th><th>数量</th><th>单位</th><th width='25%'>时间</th></tr>
<?php
for($i = 0; $i < count($page->m_stores); ++$i) {
$store = $page->m_stores[$i];
$color = $i % 2 ? '#eeeeee' : 'ffffff';
echo "<tr bgcolor='$color'>";
echo "<td>{$store->m_name}</td>";
echo "<td>{$store->m_quantity}</td>";
echo "<td>" . $store->getUnitString() . "</td>";
echo "<td>" . reformat_date($store->m_record_time) . "</td>";
}
?>
</table>
</td></tr>
</table><br/>
<div id='frmAdd'>
<table border='0' cellpadding='5' cellspacing='0' width='400px'>
<tr><td align='center'><input type='radio' id='kind1' name='kind' value='I' <?checkIt($page->m_kind=='I');?> />入库<span style='width:10px'></span>
<input type='radio' id='kind2' name='kind' value='O' <?checkIt($page->m_kind=='O');?> />出库
</td></tr>
<tr><td align='center'>日期:
<input type='text' id='date' name='date' style='width:80px' <?outputV($page->m_date);?> />(格式如:2007-01-01)
</td></tr>
<tr><td align='center'><a class='link_btn' href="javascript:VsEvent('btnSearch_click()', doSearchCheck);">
查询</a>
<a class='link_btn' style='width:150px' href="javascript:VsEvent('btnExport_click()', doSearchCheck);">输出为Excel报表</a>
</td></tr>
</table><br/>
</div>
</form>
<IFRAME ID='downFrame' FRAMEBORDER='0' SCROLLING='NO' HEIGHT='1px' SRC=""></IFRAME>
<script language='javascript'>
var vs = new ViewState();
var ex = vs.getValue("toExport");
if(ex == "yes") {
var kind = vs.getValue('kindExport');
var dt = vs.getValue('dateExport');
var hr = 'export.php?kind=' + kind + '&date=' + dt;
document.all.downFrame.src = hr;
}
</script>
<?php
require_once('common/footer.inc.php');
?>