Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/2/17 7:13:41
PHP+CSS实现打印简单数据报表功能_[PHP教程]

PHP+CSS实现打印简单数据报表功能_[PHP教程]


PHP+CSS实现打印简单数据报表功能


功能:实现打印日报表的功能,定义了专门的打印样式,隐藏了不该打印的控件并实现了分页打印功能,表名:rec 字段:rec_id,rec_po,rec_part,rec_plant,rec_vendor,rec_pur_um,rec_req_date,rec_req_qty,rec_rec_qty,rec_iqc_date,rec_notes


完整源代码如下:





Daily Report




define ("SP10" ,'          ');
global re;
function db_link()
{
access_id = "root";
access_pwd = "831025";
db_name = "inv";
@ db = mysql_connect('localhost', access_id, access_pwd) or
die("Could not connect to database. Please contact with IT supporting team ASAP.");
mysql_query("SET NAMES 'GBK'");
mysql_select_db(db_name);
return db;
}
link=db_link();
?>



Program :
bom_report.php

Date/Time :



Plant :
SJ01

User Name :
liuxueping


Receiving Date :


Page :
1

 




No.
Vendor
Part
Description
UM
Require Date
Require Qty
Deliver Qty
Receive Qty
IQC
Remark


rec_sql = "SELECT * FROM rec WHERE rec_plant = 'SJ01' ORDER BY rec_id DESC";
rec_res = mysql_query(rec_sql);
rec_num = mysql_num_rows(rec_res);

if(rec_num>0){
for (i = 0; i < rec_num; i++){
re++;
rec_row = mysql_fetch_array(rec_res);

part_sql = "SELECT pt_desc FROM part WHERE pt_part='".rec_row['rec_part']."' ";
part_res = mysql_query(part_sql);
part_row = mysql_fetch_array(part_res);


echo'
'.(i+1).'
'.rec_row['rec_vendor'].'
'.rec_row['rec_part'].'
'.part_row['pt_desc'].'
'.rec_row['rec_pur_um'].'
'.substr(rec_row['rec_req_date'], 0, 10).'
'.number_format(rec_row['rec_req_qty'], 2).'
'.number_format(rec_row['rec_rec_qty'],2).'
'.number_format(rec_row['rec_rec_qty'],2).'
'.substr(rec_row['rec_iqc_date'], 0 ,10).'
'.rec_row['rec_notes'].'
';

//每页只打印10条记录,如果记录数是10的倍数后,显示'***End of Report***'并开始打印下一页
if(re%10 == 0 and re != rec_num){
echo'

*** End of Report ***

';
//下一页开始打印
echo '

&nbsp;




Program : bom_pro.php'.SP10.'Date/Time : '.date("Y-m-d").'/'.date("H:i:s").'


Plant : SJ01'.SP10.' User Name : lucas


Receiving Date : '.date('Y-m-d').''.SP10.' Page : ';echo re/10+1;echo'


&nbsp;




No.
Vendor
Part
Description
UM
Require Date
Require Qty
Deliver Qty
Receive Qty
IQC
Remark
';
}
}

echo'

*** End of Report ***



onclick="window.print()">


onclick="window.close()">


';
}
else{
echo'


If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759