Drop Down List เวลาเลือกใบสั่งซื้อ พอกด "แสดงผล" มันจะเด้งกลับมาที่เลขใบสั่งซื้อที่ 1 ตลอดเลยค่ะ แล้วเวลาสั่งให้ออกรายงาน มันก็จะส่งใบสั่งซื้อใบแรกมาอย่างเดียวเลยค่ะ พี่ๆ ช่วยหน่อยค่ะ ทำมา 2 วันแล้วยังไม่ได้เลยค่ะ
อันนี้ Code หน้า orderBill ค่ะ
Code (PHP)
<?php
if($_SESSION['comUsernm'] != "" AND $_SESSION['comPrio'] < 1){
?>
<div class="content_box" id="printArea">
<style type="text/css" media="screen">
.pp{
height: 36px;
border: #C0C0C0 1px solid;
background: #FFF url(images/print_icon.png) 98% 50% no-repeat;
margin-bottom: 10px;
}
table{
border-collapse: collapse;
padding: 0px;
margin: 0px;
}
</style>
<style type="text/css" media="report">
.pp{
display: none;
}
table{
border-collapse: collapse;
padding: 0px;
margin: 0px;
}
</style>
<h2>บิลการสั่งซื้อสินค้า</h2>
<?php
//if($p_todo==""){
?>
<div class="space1">
<form id="rptorderbill" method="post" action="index.php?mod=orderBill&path=report">
<?php
$sql = "Select * From tb_orderlist ol left join tb_vender vd on ol.order_vd = vd.vd_id Order By order_sn";
$rs = $myClass->selQuery($sql);
if($rs != null){
echo '<select name="txtOR" class="textfield" >';
$count = 0;
foreach($rs as $key){
$count += 1;
if($count == 1)
echo '<option value="'.$key[order_sn].'" selected="selected">'.$key[order_sn].'</option>';
else
echo '<option value="'.$key[order_sn].'">'.$key[order_sn].'</option>';
}
echo '</select>';
}
?>
<input type="hidden" name="tmp_search" value="search">
<input type="submit" value="แสดงผล" class="btn" />
</form>
</div>
<?php
//}else if($p_todo=="display"){
// if($p_tmp_search=="search"){
echo'<td align="right"><a href="javascript:popups(\'module/report/vieworderBill.php?id='.$key['order_sn'].'\', 600, 768)" title="รายละเอียด"><img src="images/print_icon.png" border="0" alt="รายละเอียด"></a></td> </tr>';
$sql = "Select ol.order_sn , ol.order_date, ol.order_vd, vd.vd_name , vd.vd_tel ,ol.order_price From tb_orderlist ol, tb_itemorderlist iol , tb_vender vd
where ol.order_sn = iol.order_sn
and ol.order_vd = vd.vd_id
and ol.order_sn = '".$p_txtOR."'";
//echo $sql;
$rs = $myClass->selQuery($sql);
if($rs!=null){
echo '<table width="100%" border="1" bordercolor="#C0C0C0" style="margin-bottom: 10px;">
<tr valign="top">
<td style="padding: 10px 5px;"><strong>หมายเลขบิลสั่งของ : </strong>'.$rs[0]['order_sn'].'<br />
ผู้ค้าส่ง : '.$rs[0]['order_vd'].' ชื่อ : '.$rs[0]['vd_name'].' โทร : '.$rs[0]['vd_tel'].'<br />
วันที่สั่งของ : '.$myClass->getDateFormat($rs[0]['order_date']).'<br />
ราคารวม : '.$rs[0]['order_price'].'<br />
</td>
</tr>
</table><br />
<table border="1" width="100%" bordercolor="#AEC703">
<tr align="center" valign="middle" height="25" bgcolor="#AEC703">
<th width="13%">รหัสสินค้า</th>
<th width="25%">ชือสินค้า</th>
<th width="15%">หมวดหมู่</th>
<th width="15%">ชือยี่ห้อ</th>
<th width="10%">จำนวน</th>
<th>ราคา</th>
<th>รวมราคา</th>
</tr>';
$sqlit = "Select * From tb_product pd, tb_category cate, tb_itemorderlist iodl where iodl.prod_id = pd.prod_id and pd.cate_id = cate.cate_id and iodl.order_sn='".$rs[0]['order_sn']."'";
$rsit = $myClass->selQuery($sqlit);
$num= sizeof($rsit);
if($num >= 1){
$count = 1;
$sumPrice = 0;
$total_price = 0;
foreach($rsit as $key){
if($count%2==0)
$color = "#EBEBEB";
else
$color = "#F5F5F5";
$total_price = $key['prod_cost']*$key['list_qty'];
$sum_price += $total_price;
echo '<tr align="left" valign="middle" height="20" bgcolor="'.$color.'">
<td> '.$key['prod_id'].'</td>
<td> <a href="index.php?mod=detail&path=product&id='.$key['prod_id'].'">'.$key['prod_title'].'</a></td>
<td> '.$key['cate_name'].'</td>
<td> '.$key['prod_brand'].'</td>
<td align="center">'.$key['list_qty'].'</td>
<td align="right">฿'.number_format($key['prod_cost']).' </td>
<td align="right">฿'.number_format($total_price).' </td>
</tr>';
$count++;
}
}
echo '</table>';
}
//}
//}
?>
</div>
<?php
}else{
echo "<meta http-equiv='refresh' content='3;url=index.php?mod=error&path=main'>";
}
?>
อันนี้ Code หน้า vieworderBill ค่ะ
Code (PHP)
<?php
session_start();
include_once "../../config.php";
include_once "../../script/function.php";
import_request_variables("pG","p_");
$myClass = new MyClass();
$total = 0;
$sql = "Select * From tb_orderlist ol left join tb_vender vd on ol.order_vd = vd.vd_id Order By order_sn";
$rec = $myClass->selQuery($sql);
if($rec != null){
?>
<?php
$sql = "Select ol.order_sn ,ol.order_date, ol.order_vd, vd.vd_name , vd.vd_tel ,ol.order_price From tb_orderlist ol, tb_itemorderlist iol , tb_vender vd
where ol.order_sn = iol.order_sn
and ol.order_vd = vd.vd_id
and ol.order_sn = '".$p_txtOR."'";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ใบสั่งซื้อสินค้าเข้าร้าน</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style type="text/css" media="print">
.linkx{
color:#FFFFFF;
}
</style>
<style type="text/css" media="screen">
.linkx{
color:#000;
text-decoration: none;
}
.linkx:hover{
font-weight: bold;
}
</style>
</head>
<body>
<div id="content" style="width: 95%; min-height: 1024px; background-color:#FFFFFF" align="left">
<div style="color: #9D0000;font-size:1.5em;font-weight: bold;" align="right"><?=$CONFIG["shop"]?></div>
<div align="right"><?=$CONFIG["shopAddr"]?></div>
<br>
<div class="titleText"><strong>รหัสใบสั่งซื้อ</strong></div><div style="height:25px;line-hieght: 25px;" align="left"><?=$rec[0]['order_sn']?></div><div class="clear"></div>
<div class="titleText"><strong>ชื่อบริษัทจำหน่าย</strong></div><div style="hight:25px;line-hight: 25px;" algn="left"><?=$rec[0]['vd_name']?></div><div class="clear"></div>
<div class="titleText"><strong>วันที่สั่งซื้อเข้าร้าน</strong></div><div style="hieght:25px;line-hight: 25px;" align="left"><?=date("dt, M Y", $rec[0]['order_date']);?></div><div class="clear"></div>
<div align="left"><br/><br>
<table border="1" bordercolor="#626262" cellpadding="3" cellspacing="0" width="98%">
<tr algn="center" valign="middle" height="25">
<td width="12%"><strong><center>รหัสสินค้า</center></strong></td>
<td width="20%"><strong><center>ชื่อสินค้า</center></strong></td>
<td width="15%"><strong><center>หมวดหมู่</center></strong></td>
<td><strong><center>ชื่อยี่ห้อ</center></strong></td>
<td><strong><center>จำนวน</center></strong></td>
<td><strong><center>ราคา</center></strong></td>
<td><strong><center>รวมราคา</center></strong></td>
</tr>
<?php
$sqlit = "Select * From tb_product pd, tb_category cate, tb_itemorderlist iodl where iodl.prod_id = pd.prod_id and pd.cate_id = cate.cate_id and iodl.order_sn='".$rec[0]['order_sn']."'";
$rsit = $myClass->selQuery($sqlit);
$num= sizeof($rsit);
if($num >= 0){
$count = 1;
$sumPrice = 0;
$total_price = 0;
foreach($rsit as $key){
$total_price = $key['prod_cost']*$key['list_qty'];
$sum_price += $total_price;
echo '<tr valign="middle" height="20">
<td> '.$key['prod_id'].'</td>
<td>'.$key['prod_title'].'</td>
<td> '.$key['cate_name'].'</td>
<td> '.$key['prod_brand'].'</td>
<td align="center">'.$key['list_qty'].'</td>
<td align="right">฿'.number_format($key['prod_cost']).' </td>
<td align="right">฿'.number_format($total_price).' </td>
</tr>';
$count++;
}
}
?>
</table>
<div style="margin-top: 10px; margin-bottom: 10px" align="left">
<strong>ราคารวม : <?=number_format($sum_price)?> บาท</strong>
</div>
<div align="center"><a href="javascript: window.print();" class="linkx">[ พิมพ์ ]</a> <a href="javascript: window.close();" class="linkx">[ ปิด ]</a></div>
</div>
</div>
</body>
</html>
<?php
}
?>
Tag : PHP
Date :
2012-04-01 18:47:21
By :
hikarujun
View :
1191
Reply :
1
คุณเอาค่าอะไรมาค้นหา
ค่าจาก id ที่ส่งมารึป่าว
แล้วใช้ $_GET['id'] หรือ $_POST['id']
Date :
2012-04-02 13:40:52
By :
rootElement@kmutnb
Load balance : Server 01