|
|
|
รบกวนผู้รู้ช่วยดูให้หน่อยค่ะ ว่าทำไมถึงแสดงรายงานหน้าpdf เดียวกัน |
|
|
|
|
|
|
|
Code (PHP)
<?
if ($send == null){
?>
<body bgcolor = #F5F5DC>
<meta http-equiv=content-type content="text/html; charset=windows-874">
<script language="javascript">
function LogoutSystem() //ประยุกใช้เอาตามสถานการณ์นะครับ
{
parent.location.replace("logout.php"); }
var timer1;
function Ehandler()
{
clearTimeout(timer1);
timer1 = setTimeout("LogoutSystem()", 1000*60*1);
return true;
}
Ehandler();
if(!document.all){window.captureEvents(Event.CLICK | Event.KEYPRESS);}
window.onclick = Ehandler;
window.onkeypress = Ehandler;
</script>
</body>
<form method="post" action="<? echo $PHP_SELF ?>">
<center>
<h3>ค้นหาข้อมูลTaxi</h3><p>
<select name="testlb" id="testlb">
<option value="">:: เลือกการค้นหา ::</option>
<option value="ค้นหาตามวันที่(ทุกรหัส)">ค้นหาตามวันที่(ทุกรหัส)</option>
<option value="ค้นหาตามวันที่(เฉพาะรหัส)">ค้นหาตามวันที่(เฉพาะรหัส)</option>
<option value="ค้นหาตามสหกรณ์">ค้นหาตามสหกรณ์</option>
</select>
<p> <?
$id = array(':: เลือกสหกรณ์ ::','ไชโย','ส่วนบุคคล','สหกรณ์สหมิตรแท็กซี่ จก.','บ.บางมดแท็กซี่ จก. ','สหกรณ์บวรแท็กซี่ จก. ');
$name1 = array('กรุณกรอกสหกรณ์','ไชโย','ส่วนบุคคล','สหกรณ์สหมิตรแท็กซี่ จก.','บ.บางมดแท็กซี่ จก. ','สหกรณ์บวรแท็กซี่ จก. ');
?>
<script>
var name_array = new Array();
</script>
<select id="select_id"onchange="change_id(this)">
<?
for($n=0;$n<count($id);$n++)
{
?>
<option value="<?=$id[$n]?>"><?=$id[$n]?></option>
<script>name_array['<?=$id[$n]?>'] = '<?=$name1[$n]?>';</script>
<?
}
?>
</select>
<input type="hidden" name="txtcategory" style="width:200px" value="<?php echo $_POST['textfield']; ?>">
<script>
function change_id(obj)
{
document.getElementById('txtcategory').value=name_array
[document.getElementById(obj.id).value];
}
</script>
<p>
<select name="testday1" id="testday1">
<option value="">:: เลือกวัน ::</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="testmonth1" id="testmonth1">
<option value="">:: เลือกเดือน ::</option>
<option value="01">มกราคม</option>
<option value="02">กุมภาพันธ์</option>
<option value="03">มีนาคม</option>
<option value="04">เมษายน</option>
<option value="05">พฤษภาคม</option>
<option value="06">มิถุนายน</option>
<option value="07">กรกฎาคม</option>
<option value="08">สิงหาคม</option>
<option value="09">กันยายน</option>
<option value="10">ตุลาคม</option>
<option value="11">พฤศจิกายน</option>
<option value="12">ธันวาคม</option>
</select>
<select name="testyesh1" id="testyesh1">
<option value="">:: เลือกปี ::</option>
<option value="2554">2554</option>
<option value="2555">2555</option>
<option value="2556">2556</option>
<option value="2557">2557</option>
<option value="2558">2558</option>
<option value="2559">2559</option>
</select>
ถึง
<select name="testday2" id="testday2">
<option value="">:: เลือกวัน ::</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="testmonth2" id="testmonth2">
<option value="">:: เลือกเดือน ::</option>
<option value="01">มกราคม</option>
<option value="02">กุมภาพันธ์</option>
<option value="03">มีนาคม</option>
<option value="04">เมษายน</option>
<option value="05">พฤษภาคม</option>
<option value="06">มิถุนายน</option>
<option value="07">กรกฎาคม</option>
<option value="08">สิงหาคม</option>
<option value="09">กันยายน</option>
<option value="10">ตุลาคม</option>
<option value="11">พฤศจิกายน</option>
<option value="12">ธันวาคม</option>
</select>
<select name="testyesh2" id="testyesh2">
<option value="">:: เลือกปี ::</option>
<option value="2554">2554</option>
<option value="2555">2555</option>
<option value="2556">2556</option>
<option value="2557">2557</option>
<option value="2558">2558</option>
<option value="2559">2559</option>
</select>
<p>
</script>
กรุณากรอกรหัสที่ต้องการ
<input type="text" name="id_val" maxlength="5" style="width:60px"><p>
<input type="submit" name="send" value="ตกลง">
</center>
</form>
<?
///////////////////////////////////////////////////////////////////////////////////////////////////
}
else { echo "<font size=3>";
$datestart = $testyesh1.$testmonth1.$testday1;
$datestop = $testyesh2.$testmonth2.$testday2;
$datestart2 = $testday1.-$testmonth1.-$testyesh1;
$datestop2 = $testday2.-$testmonth2.-$testyesh2;
switch ($testlb)
{
case "":
if($id_val == null){ //if null
define('FPDF_FONTPATH','font/');
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->AddFont('angsana','','angsana.php');
$pdf->AddFont('angsana','B','angsanab.php');
$pdf->SetFont('angsana','',14);
echo "<body bgcolor = #F5F5DC></body>";
$link = mysql_connect("localhost", "root", "1234");
$sql = "use taxi";
$result = mysql_query($sql);
mysql_query("SET NAMES 'tis620' ");
$sql = "select add_newmember.idmember, add_newmember.name, add_newmember.lastname, add_newmember.category, SUM(add_tourit.adult) as sumadult, SUM(add_tourit.children) as sumchi, SUM(add_tourit.total) as total From add_newmember,add_tourit where add_newmember.idmember=add_tourit.idtourist group by add_newmember.idmember order by SUM(add_tourit.total) DESC,SUM(add_tourit.adult) DESC;";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == "")
{
echo "ไม่พบข้อมูลที่ค้นหา"."<p>";
echo "<a href=showtaxipdf.php>กลับหน้าแสดงข้อมูล</a></br>";
}
else {
echo"<a href=idasc.php>เรียงตามรหัส<br></a>";
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<center>
<td><B>รหัส</B></td>
<td><B>ชื่อ</B></td>
<td><B>นามสกุล</B></td>
<td><B>สหกรณ์</B></td>
<td><B>จำนวนผู้ใหญ่</B></td>
<td><B>จำนวนเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>จำนวนเงินทั้งหมด</B></td>
</center>
</tr>";
//$pdf->SetXY(30,20);
$pdf->SetFillColor(224,235,255);
$pdf->Cell(20,8,'รหัส',1,0,"C",true);
$pdf->Cell(20,8,'ชื่อ',1,0,"C",true);
$pdf->Cell(20,8,'นามสกุล',1,0,"C",true);
$pdf->Cell(45,8,'สหกรณ์',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเด็ก',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนทั้งหมด',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเงิน',1,0,"C",true);
$pdf->Ln();
while ($dbarr = mysql_fetch_array($result))
{$badult=($dbarr["sumadult"]*150)+($dbarr["sumchi"]*100);
//$bchildren=$dbarr["sumchi"]*100;
//$sumtotal=$badult+$bchildren;
echo "
<tr>
<td><a href=testpdf.php?id_val=$dbarr[idmember]>$dbarr[idmember]</a></td>
<td>$dbarr[name]</td>
<td>$dbarr[lastname]</td>
<td>$dbarr[category]</td>
<td>$dbarr[sumadult]</td>
<td>$dbarr[sumchi]</td>
<td>$dbarr[total]</td>
<td>$badult</td>
</tr>";
$pdf->Cell(20,8,$dbarr["idmember"],1,0,'C');
$pdf->Cell(20,8,$dbarr["name"],1,0,"C");
$pdf->Cell(20,8,$dbarr["lastname"],1,0,"C");
$pdf->Cell(45,8,$dbarr["category"],1,0,"C");
$pdf->Cell(20,8,$dbarr["sumadult"],1,0,"C");
$pdf->Cell(20,8,$dbarr["sumchi"],1,0,"C");
$pdf->Cell(30,8,$dbarr["total"],1,0,"C");
$pdf->Cell(20,8,$badult,1,0,"C");
$pdf->Ln();
}
$pdf->Output("MyPDF.pdf","F");
echo"</table>";
}
mysql_close($link);
echo"<br>PDF Created Click <a href=MyPDF.pdf target=_blank>here</a> to Download </br>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
///////////////////////////////////////////////////////////////////////////////////////////////////
else {
define('FPDF_FONTPATH','font/');
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddFont('angsana','','angsana.php');
$pdf->AddFont('angsana','B','angsanab.php');
$pdf->AddPage();
$pdf->SetFont('angsana','',14);
echo "<body bgcolor = #F5F5DC></body>";
$link = mysql_connect("localhost", "root", "1234");
$sql = "use taxi";
$result = mysql_query($sql);
mysql_query("SET NAMES 'tis620' ");
$sql = "select add_newmember.idmember, add_newmember.name, add_newmember.lastname, add_newmember.category, add_tourit.date, add_tourit.adult, add_tourit.children, add_tourit.total From add_newmember, add_tourit where add_newmember.idmember ='$id_val' and add_newmember.idmember=add_tourit.idtourist order by add_tourit.date DESC;";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == "")
{
echo "ไม่พบข้อมูลที่ค้นหา"."<p>";
echo "<a href=showtaxipdf.php>กลับหน้าแสดงข้อมูล</a></br>";
}
else {
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<tr>
<center><td><B>วันที่</B></td>
<td><B>รหัส</B></td>
<td><B>ชื่อ</B></td>
<td><B>นามสกุล</B></td>
<td><B>สหกรณ์</B></td>
<td><B>จำนวนผู้ใหญ่</B></td>
<td><B>จำนวนเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>จำนวนเงิน</B></td>
</center>
</tr>";
$pdf->SetFillColor(224,235,255);
$pdf->Cell(20,8,'วันที่',1,0,"C",true);
$pdf->Cell(20,8,'รหัส',1,0,"C",true);
$pdf->Cell(20,8,'ชื่อ',1,0,"C",true);
$pdf->Cell(20,8,'นามสกุล',1,0,"C",true);
$pdf->Cell(45,8,'สหกรณ์',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเด็ก',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนทั้งหมด',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเงิน',1,0,"C",true);
$pdf->Ln();
while ($dbarr = mysql_fetch_array($result))
{
$bdate =($dbarr["adult"]*150)+($dbarr["children"]*100);
$btotal =$btotal+$bdate;
//$totaladult=$totaladult+$dbarr["adult"];
//$totalchi=$totalchi+$dbarr["children"];
// $total2=$totaladult+$totalchi;
echo "<tr>
<td>$dbarr[date]</td>
<td>$dbarr[idmember]</td>
<td>$dbarr[name]</td>
<td>$dbarr[lastname]</td>
<td>$dbarr[category]</td>
<td>$dbarr[adult]</td>
<td>$dbarr[children]</td>
<td>$dbarr[total]</td>
<td>$bdate</td>
</tr>";
$pdf->Cell(20,8,$dbarr["date"],1,0,"C");
$pdf->Cell(20,8,$dbarr["idmember"],1,0,"C");
$pdf->Cell(20,8,$dbarr["name"],1,0,"C");
$pdf->Cell(20,8,$dbarr["lastname"],1,0,"C");
$pdf->Cell(45,8,$dbarr["category"],1,0,"C");
$pdf->Cell(20,8,$dbarr["adult"],1,0,"C");
$pdf->Cell(20,8,$dbarr["children"],1,0,"C");
$pdf->Cell(30,8,$dbarr["total"],1,0,"C");
$pdf->Cell(20,8,$bdate,1,0,"C");
$pdf->Ln();
}
echo"</table>"."<br>";
$pdf->Ln();
$pdf->SetFillColor(224,235,255);
$pdf->Cell(40,8,'รวมจำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนเด็ก',1,0,"C",true);
$pdf->Cell(40,8,'รวมจำนวนคนทั้งหมด',1,0,"C",true);
$pdf->Cell(30,8,'จำนวนเงินทั้งหมด',1,0,"C",true);
$pdf->Ln();
$result = mysql_query($sql);
$sql = "SELECT SUM(adult) AS tadult, SUM(children) AS tchildren,SUM(total) AS ttotal FROM add_tourit where idtourist = '$id_val';";
$result = mysql_query($sql);
$dbarr = mysql_fetch_array($result);
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<tr>
<center><td><B>ผลรวมผู้ใหญ่</B></td>
<td><B>ผลรวมเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>รวมเงินทั้งหมด</B></td>
</center>
</tr>";
echo "
<tr>
<td>$dbarr[tadult]</td>
<td>$dbarr[tchildren]</td>
<td>$dbarr[ttotal]</td>
<td>$btotal</td>
</tr>";
$pdf->Cell(40,8,$dbarr["tadult"],1,0,"C");
$pdf->Cell(30,8,$dbarr["tchildren"],1,0,"C");
$pdf->Cell(40,8,$dbarr["ttotal"],1,0,"C");
$pdf->Cell(30,8,$btotal,1,0,"C");
echo"</table>";
$pdf->Output("MyPDF.pdf","F");
mysql_close($link);
echo"<br>PDF Created Click <a href=MyPDF.pdf target=_blank>here</a> to Download </br>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
}
break;
///////////////////////////////////////////////////////////////////////////////////////////////////
case "ค้นหาตามวันที่(ทุกรหัส)":
define('FPDF_FONTPATH','font/');
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddFont('angsana','','angsana.php');
$pdf->AddFont('angsana','B','angsanab.php');
$pdf->AddPage();
$pdf->SetFont('angsana','',14);
echo "<body bgcolor = #F5F5DC></body>";
$link = mysql_connect("localhost", "root", "1234");
$sql = "use taxi";
$result = mysql_query($sql);
mysql_query("SET NAMES 'tis620' ");
$sql = "select add_newmember.idmember, add_newmember.name, add_newmember.lastname, add_newmember.category, SUM(add_tourit.adult) as sumadult, SUM(add_tourit.children) as sumchi, SUM(add_tourit.total) as total From add_newmember,add_tourit where add_newmember.idmember=add_tourit.idtourist AND add_tourit.date between $datestart and $datestop group by add_newmember.idmember order by SUM(add_tourit.total) DESC,SUM(add_tourit.adult) DESC;";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == "")
{
echo "ไม่พบข้อมูลที่ค้นหา"."<p>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
else {
echo "$datestart2";
echo" ถึงวันที่ ";
echo "$datestart2 ";
echo"<a href=dateidasc.php?datestop=$datestop&datestart=$datestart&id_val=$dbarr[idmember]&datestart2=$datestart2&datestop2=$datestop2>เรียงตามรหัส</a>";
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<center>
<td><B>รหัส</B></td>
<td><B>ชื่อ</B></td>
<td><B>นามสกุล</B></td>
<td><B>สหกรณ์</B></td>
<td><B>จำนวนผู้ใหญ่</B></td>
<td><B>จำนวนเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>จำนวนเงินทั้งหมด</B></td>
</center>
</tr>";
//$pdf->SetXY(30,20);
$pdf->Cell(20,8,$datestart2,0,0,"C");
$pdf->Cell(20,8,'ถึงวันที่',0,0,"C");
$pdf->Cell(20,8,$datestop2,0,0,"C");
$pdf->Ln();
$pdf->SetFillColor(224,235,255);
$pdf->Cell(20,8,'รหัส',1,0,"C",true);
$pdf->Cell(20,8,'ชื่อ',1,0,"C",true);
$pdf->Cell(20,8,'นามสกุล',1,0,"C",true);
$pdf->Cell(45,8,'สหกรณ์',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเด็ก',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนทั้งหมด',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเงิน',1,0,"C",true);
$pdf->Ln();
while ($dbarr = mysql_fetch_array($result))
{$badult=($dbarr["sumadult"]*150)+($dbarr["sumchi"]*100);
//$bchildren=$dbarr["sumchi"]*100;
//$sumtotal=$badult+$bchildren;
echo "
<tr>
<td><a href=showtaxismall.php?datestop=$datestop&datestart=$datestart&id_val=$dbarr[idmember]>$dbarr[idmember]</a></td>
<td>$dbarr[name]</td>
<td>$dbarr[lastname]</td>
<td>$dbarr[category]</td>
<td>$dbarr[sumadult]</td>
<td>$dbarr[sumchi]</td>
<td>$dbarr[total]</td>
<td>$badult</td>
</tr>
";
$pdf->Cell(20,8,$dbarr["idmember"],1,0,'C');
$pdf->Cell(20,8,$dbarr["name"],1,0,"C");
$pdf->Cell(20,8,$dbarr["lastname"],1,0,"C");
$pdf->Cell(45,8,$dbarr["category"],1,0,"C");
$pdf->Cell(20,8,$dbarr["sumadult"],1,0,"C");
$pdf->Cell(20,8,$dbarr["sumchi"],1,0,"C");
$pdf->Cell(30,8,$dbarr["total"],1,0,"C");
$pdf->Cell(20,8,$badult,1,0,"C");
$pdf->Ln();
}
$pdf->Output("MyPDF.pdf","F");
echo"</table>";
mysql_close($link);
echo"<br>PDF Created Click <a href=MyPDF.pdf target=_blank>here</a> to Download </br>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
break;
///////////////////////////////////////////////////////////////////////////////////////////////////
case "ค้นหาตามวันที่(เฉพาะรหัส)":
define('FPDF_FONTPATH','font/');
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddFont('angsana','','angsana.php');
$pdf->AddFont('angsana','B','angsanab.php');
$pdf->AddPage();
$pdf->SetFont('angsana','',14);
echo "<body bgcolor = #F5F5DC></body>";
$link = mysql_connect("localhost", "root", "1234");
$sql = "use taxi";
$result = mysql_query($sql);
mysql_query("SET NAMES 'tis620' ");
$sql = "select add_newmember.idmember, add_newmember.name,add_newmember.lastname,add_newmember.category, add_tourit.date,add_tourit.adult,add_tourit.children,add_tourit.total From add_newmember,add_tourit where add_newmember.idmember ='$id_val' and add_newmember.idmember=add_tourit.idtourist AND add_tourit.date between $datestart and $datestop order by add_tourit.date DESC;";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == "")
{
echo "ไม่พบข้อมูลที่ค้นหา"."<p>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
else {
echo "$datestart2";
echo" ถึงวันที่ ";
echo "$datestop2";
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<center>
<td><B>วันที่</B></td>
<td><B>รหัส</B></td>
<td><B>ชื่อ</B></td>
<td><B>นามสกุล</B></td>
<td><B>สหกรณ์</B></td>
<td><B>จำนวนผู้ใหญ่</B></td>
<td><B>จำนวนเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>จำนวนเงินทั้งหมด</B></td>
</center>
</tr>";
//$pdf->SetXY(30,20);
$pdf->SetFillColor(224,235,255);
$pdf->Cell(20,8,'วันที่',1,0,"C",true);
$pdf->Cell(20,8,'รหัส',1,0,"C",true);
$pdf->Cell(20,8,'ชื่อ',1,0,"C",true);
$pdf->Cell(20,8,'นามสกุล',1,0,"C",true);
$pdf->Cell(45,8,'สหกรณ์',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเด็ก',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนทั้งหมด',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเงิน',1,0,"C",true);
$pdf->Ln();
while ($dbarr = mysql_fetch_array($result))
{$bdate =($dbarr["adult"]*150)+($dbarr["children"]*100);
$btotal =$btotal+$bdate;
//$bchildren=$dbarr["sumchi"]*100;
//$sumtotal=$badult+$bchildren;
echo "
<tr>
<td>$dbarr[date]</td>
<td>$dbarr[idmember]</td>
<td>$dbarr[name]</td>
<td>$dbarr[lastname]</td>
<td>$dbarr[category]</td>
<td>$dbarr[adult]</td>
<td>$dbarr[children]</td>
<td>$dbarr[total]</td>
<td>$bdate</td>
</tr>
";
$pdf->Cell(20,8,$dbarr["date"],1,0,"C");
$pdf->Cell(20,8,$dbarr["idmember"],1,0,'C');
$pdf->Cell(20,8,$dbarr["name"],1,0,"C");
$pdf->Cell(20,8,$dbarr["lastname"],1,0,"C");
$pdf->Cell(45,8,$dbarr["category"],1,0,"C");
$pdf->Cell(20,8,$dbarr["adult"],1,0,"C");
$pdf->Cell(20,8,$dbarr["children"],1,0,"C");
$pdf->Cell(30,8,$dbarr["total"],1,0,"C");
$pdf->Cell(20,8,$bdate,1,0,"C");
$pdf->Ln();
}
echo"</table>"."<br>";
$pdf->Ln();
$pdf->SetFillColor(224,235,255);
$pdf->Cell(40,8,'รวมจำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนเด็ก',1,0,"C",true);
$pdf->Cell(40,8,'รวมจำนวนคนทั้งหมด',1,0,"C",true);
$pdf->Cell(30,8,'จำนวนเงินทั้งหมด',1,0,"C",true);
$pdf->Ln();
$result = mysql_query($sql);
$sql = "SELECT SUM(adult) AS tadult, SUM(children) AS tchildren,SUM(total) AS ttotal FROM add_tourit where idtourist = '$id_val' AND add_tourit.date between $datestart and $datestop order by add_tourit.date DESC;";
$result = mysql_query($sql);
$dbarr = mysql_fetch_array($result);
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<tr>
<center><td><B>ผลรวมผู้ใหญ่</B></td>
<td><B>ผลรวมเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>รวมเงินทั้งหมด</B></td>
</center>
</tr>";
echo "
<tr>
<td>$dbarr[tadult]</td>
<td>$dbarr[tchildren]</td>
<td>$dbarr[ttotal]</td>
<td>$btotal</td>
</tr>
";
$pdf->Cell(40,8,$dbarr["tadult"],1,0,"C");
$pdf->Cell(30,8,$dbarr["tchildren"],1,0,"C");
$pdf->Cell(40,8,$dbarr["ttotal"],1,0,"C");
$pdf->Cell(30,8,$btotal,1,0,"C");
echo"</table>";
$pdf->Output("MyPDF.pdf","F");
mysql_close($link);
echo"<br>PDF Created Click <a href=MyPDF.pdf target=_blank>here</a> to Download </br>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
break;
///////////////////////////////////////////////////////////////////////////////////////////////////
case "ค้นหาตามสหกรณ์":
define('FPDF_FONTPATH','font/');
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddFont('angsana','','angsana.php');
$pdf->AddFont('angsana','B','angsanab.php');
$pdf->AddPage();
$pdf->SetFont('angsana','',14);
echo "<body bgcolor = #F5F5DC></body>";
$link = mysql_connect("localhost", "root", "1234");
$sql = "use taxi";
$result = mysql_query($sql);
mysql_query("SET NAMES 'tis620' ");
/*$sql = "select add_newmember.idmember, add_newmember.name,add_newmember.lastname,add_newmember.category,add_tourit.date,add_tourit.adult,add_tourit.children,add_tourit.total From add_newmember,add_tourit where add_newmember.idmember ='$id_val' and add_newmember.idmember=add_tourit.idtourist AND add_tourit.date between $datestart and $datestop order by add_tourit.date DESC;";*/
$sql = "select * from add_newmember where (category LIKE '%".$_POST["txtcategory"]."%')";
$sql = "SELECT add_newmember.idmember,
add_newmember.name,
add_newmember.lastname,
add_newmember.category,
add_tourit.`date`,
add_tourit.adult,
add_tourit.children,
add_tourit.total,
add_tourit.idmember
FROM add_newmember
Inner Join add_tourit ON add_newmember.idmember = add_tourit.idmember
where (category LIKE '%".$_POST["txtcategory"]."%') and
add_tourit.date between $datestart and $datestop order by add_tourit.date ASC;";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == "")
{
echo "ไม่พบข้อมูลที่ค้นหา"."<p>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
else {
echo "$datestart2";
echo" ถึงวันที่ ";
echo "$datestop2";
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<center>
<td><B>วันที่</B></td>
<td><B>รหัส</B></td>
<td><B>ชื่อ</B></td>
<td><B>นามสกุล</B></td>
<td><B>สหกรณ์</B></td>
<td><B>จำนวนผู้ใหญ่</B></td>
<td><B>จำนวนเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>จำนวนเงินทั้งหมด</B></td>
</center>
</tr>";
//$pdf->SetXY(30,20);
$pdf->SetFillColor(224,235,255);
$pdf->Cell(20,8,'วันที่',1,0,"C",true);
$pdf->Cell(20,8,'รหัส',1,0,"C",true);
$pdf->Cell(20,8,'ชื่อ',1,0,"C",true);
$pdf->Cell(20,8,'นามสกุล',1,0,"C",true);
$pdf->Cell(45,8,'สหกรณ์',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเด็ก',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนทั้งหมด',1,0,"C",true);
$pdf->Cell(20,8,'จำนวนเงิน',1,0,"C",true);
$pdf->Ln();
while ($dbarr = mysql_fetch_array($result))
{$aadult=($dbarr["adult"]);
$cchildren=($dbarr["children"]);
$totall=$aadult+$cchildren;
$tadult= $tadult+$aadult ;
$tchildren=$tchildren+$cchildren;
$ttotal= $ttotal+$totall ;
$bdate =($dbarr["adult"]*150)+($dbarr["children"]*100);
$btotal =$btotal+$bdate;
//$bchildren=$dbarr["sumchi"]*100;
//$sumtotal=$badult+$bchildren;
echo "<tr>
<td>$dbarr[date]</td>
<td><a href=showtaxismall.php?datestop=$datestop&datestart=$datestart&id_val=$dbarr[idmember]>$dbarr[idmember]</a></td>
<td>$dbarr[name]</td>
<td>$dbarr[lastname]</td>
<td>$dbarr[category]</td>
<td>$dbarr[adult]</td>
<td>$dbarr[children]</td>
<td>$dbarr[total]</td>
<td>$bdate</td>
</tr>";
$pdf->Cell(20,8,$dbarr["date"],1,0,"C");
$pdf->Cell(20,8,$dbarr["idmember"],1,0,'C');
$pdf->Cell(20,8,$dbarr["name"],1,0,"C");
$pdf->Cell(20,8,$dbarr["lastname"],1,0,"C");
$pdf->Cell(45,8,$dbarr["category"],1,0,"C");
$pdf->Cell(20,8,$dbarr["adult"],1,0,"C");
$pdf->Cell(20,8,$dbarr["children"],1,0,"C");
$pdf->Cell(30,8,$dbarr["total"],1,0,"C");
$pdf->Cell(20,8,$bdate,1,0,"C");
$pdf->Ln();
}
echo"</table>"."<br>";
$pdf->Ln();
$pdf->SetFillColor(224,235,255);
$pdf->Cell(40,8,'รวมจำนวนผู้ใหญ่',1,0,"C",true);
$pdf->Cell(30,8,'รวมจำนวนเด็ก',1,0,"C",true);
$pdf->Cell(40,8,'รวมจำนวนคนทั้งหมด',1,0,"C",true);
$pdf->Cell(30,8,'จำนวนเงินทั้งหมด',1,0,"C",true);
$pdf->Ln();
$result = mysql_query($sql);
//////////////
$sql = "SELECT SUM(adult) AS tadult, SUM(children) AS tchildren,SUM(total) AS ttotal FROM add_tourit where category = '$txtcategory' from add_newmember;";
$result = mysql_query($sql);
//$dbarr = mysql_fetch_array($result);
echo "<table border = 1 bordercolor= #F90 width= 1000 height= 20 >
<tr>
<center><td><B>ผลรวมผู้ใหญ่</B></td>
<td><B>ผลรวมเด็ก</B></td>
<td><B>จำนวนทั้งหมด</B></td>
<td><B>รวมเงินทั้งหมด</B></td>
</center>
</tr>";
echo "<tr>
<td>$tadult</td>
<td>$tchildren</td>
<td>$ttotal</td>
<td>$btotal</td>
</tr>";
$pdf->Cell(40,8,$tadult,1,0,"C");
$pdf->Cell(30,8,$tchildren,1,0,"C");
$pdf->Cell(40,8,$ttotal,1,0,"C");
$pdf->Cell(30,8,$btotal,1,0,"C");
echo"</table>"."<br>";
$pdf->Output("MyPDF.pdf","F");
echo"PDF Created Click <a href=MyPDF.pdf target=_blank>here</a> to Download </br>";
echo "<a href=showtaxipdf.php>กลับหน้ารายงาน</a></br>";
}
break;
}
}
?>
Tag : PHP, MySQL, JavaScript
|
|
|
|
|
|
Date :
2011-05-21 15:40:55 |
By :
าฟะัำ |
View :
772 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่มีใครช่วยเลยหรอค่ะ
|
|
|
|
|
Date :
2011-05-21 15:47:32 |
By :
กะต่าย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|