Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ขอคำแนะนำเรื่องการ show จากวันที่ ถึงวันที่ของข้อมูลที่ออกรายงานใน PDF ครับ



 

ขอคำแนะนำเรื่องการ show จากวันที่ ถึงวันที่ของข้อมูลที่ออกรายงานใน PDF ครับ

 



Topic : 122810



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์




ตัวอย่างไฟล์ PDF คืออยากให้แสดงวันที่ ตามวันที่เราเลือกว่าจะออกรายงานช่วงเวลาไหนครับ

o

หน้า btween-date-product.php (เริ่มที่หน้านี้จะทำการเลือกข้อมูลออกรายงาน)

q

code btween-date-product.php
Code (PHP)
<?php require_once('Connections/MyConnect.php');
mysql_select_db($database_MyConnect, $MyConnect);

 ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "owner/Login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_salesset1 = "-1";
if (isset($_POST['dateStart'])) {
  $colname_salesset1 = $_POST['dateStart'];
}
$colname2_salesset1 = "-1";
if (isset($_POST['dateEnd'])) {
  $colname2_salesset1 = $_POST['dateEnd'];
}

$query_salesset1 = sprintf("SELECT * FROM product
INNER JOIN purchase_detail
ON purchase_detail.product_id = product.product_id 
 WHERE pur_detail_date >= %s and pur_detail_date<=%s Order by pur_detail_date ASC", GetSQLValueString($colname_salesset1, "date"),GetSQLValueString($colname2_salesset1, "date"));
$salesset1 = mysql_query($query_salesset1, $MyConnect) or die(mysql_error());
$row_salesset1 = mysql_fetch_assoc($salesset1);
$totalRows_salesset1 = mysql_num_rows($salesset1);
?>
<!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>btween-product</title>
<script src="js/jquery.js" type="text/javascript"></script>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<style type="text/css">
#MenuBar1 {
	font-size: 230%;
	font-family: "Courier New", Courier, monospace;
}
body p {
	font-size: 18px;
	text-align: center;
	color: #000;
}
body h2 {
	text-align: center;
}
</style>
<script src="jquery.ui-1.5.2/jquery-1.2.6.js" type="text/javascript"></script>
<script src="jquery.ui-1.5.2/ui/ui.datepicker.js" type="text/javascript"></script>
<link href="jquery.ui-1.5.2/themes/ui.datepicker.css" rel="stylesheet" type="text/css" />
</head>

<body class='container'> 
<p><img src="shop.jpg" width="1117" height="149" />
</p>
<h3>ร้านเกสร
</h3>
<p>ระบบจัดการฐานข้อมูลสำหรับร้านค้าปลีก</p>

<div class="btn-group">
  <button class="btn"><a href="sales_detail.php">ขายสินค้า</a></button>
</div>

<div class="btn-group">
  <button class="btn"><a href="edit-owner.php">แก้ไขข้อมูลส่วนตัว</a></button>
</div>
<div class="btn-group">
  <button class="btn">ออกรายงาน</button>
  <button class="btn dropdown-toggle" data-toggle="dropdown">
    <span class="caret"></span>
  </button>   
  <ul class="dropdown-menu">
    <li><a href="btween-date-product.php">รายงานสินค้าคงคลัง</a></li>
    <li><a href="btween-date-sales.php">รายงานการขายสินค้า</a></li>
    <li><a href="btween-date-repayment.php">รายงานลูกหนี้ค้างชำระ</a></li>
    <li> รายงานสินค้าขายดี </li>
    <li> รายงานกำไร </li>
    <!-- dropdown menu links -->
  </ul> 
</div>
<div class="btn-group">
  <button class="btn"><a href="owner/Login.php">ออกจากระบบ</a></button>
</div>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action=""> 
  <p>จากวันที่
    <input type="date" size="30" value="Click to show datepicker" name="dateStart" />  
    ถึงวันที่ 
  <input type="date" size="30" value="Click to show datepicker"  name="dateEnd" />
  <input type="submit" name="btnsearch" id="btnsearch" value="search" />
  </p>
  <p>&nbsp; </p>
 <table class="table table-bordered" width="500" border="1" align="center">
    <tr class="success">
      <td>ชื่อสินค้า</td>
      <td>ราคา</td>
      <td>วันที่ซื้อเข้า</td>
      <td>จำนวนสินค้า</td>
    </tr>
    <?php
	 do { ?>
      <tr>
        <td><?php echo $row_salesset1['product_name']; ?></td>
        <td><?php echo $row_salesset1['product_price']; ?></td>
        <td><?php echo $row_salesset1['pur_detail_date']; ?></td>
        <td><?php echo $row_salesset1['product_qty']; ?></td>
      </tr>
      <?php } while ($row_salesset1 = mysql_fetch_assoc($salesset1)); ?>
  </table>
<p></p>
<script type="text/javascript">
// BeginWebWidget jQuery_UI_Calendar: jQueryUICalendar2
jQuery("#jQueryUICalendar2").datepicker({dateFormat: 'yy-mm-dd'});

// EndWebWidget jQuery_UI_Calendar: jQueryUICalendar2
</script>
<p></p>
  <script type="text/javascript">
// BeginWebWidget jQuery_UI_Calendar: jQueryUICalendar1
jQuery("#jQueryUICalendar1").datepicker({dateFormat: 'yy-mm-dd'});

// EndWebWidget jQuery_UI_Calendar: jQueryUICalendar1
  </script>
</form>
<p>
  <a href="tcpdf/report.php">
  <input type="submit" name="btnreport" id="btnreport" value="ออกรายงาน" /></a>
</p>

</body>
</html>
<?php
mysql_free_result($salesset1);
?>


code reportproduct.php
Code (PHP)
<?php
session_start();
header("Content-type:text/html; charset=UTF-8");                
header("Cache-Control: no-store, no-cache, must-revalidate");               
header("Cache-Control: post-check=0, pre-check=0", false);    
include("db_connect.php");
?>
<style>
td{
        border:1px dashed #CCC;  
}
</style>
    <table width="994" border="0" cellpadding="1" cellspacing="0" style="width:1100px;">  
    	<tr>
        <td width="64" align="center" bgcolor="#F2F2F2">#</td>
        <td width="150" bgcolor="#F2F2F2">&nbsp;ชื่อสินค้า</td>
        <td width="150" bgcolor="#F2F2F2">&nbsp;ราคา</td>
        <td width="145" bgcolor="#F2F2F2">&nbsp;วันที่ซื้อเข้า</td>
        <td width="75" bgcolor="#F2F2F2">&nbsp;จำนวนสินค้า</td>
        </tr>
<?php
        $i=1;
        $q="SELECT pd.product_id, pd.product_name, pd.product_price, pc.pur_detail_date, SUM( pur_detail_productqty ) ttl_pur		
FROM product pd
LEFT JOIN purchase_detail pc ON pd.product_id = pc.product_id
WHERE pur_detail_date BETWEEN '2016-03-04' AND '2016-04-05'
GROUP BY pd.product_id
LIMIT 0 , 30

";
        $qr=@mysql_query($q);	
        while($rs=@mysql_fetch_array($qr)){
?>  
  <tr>
    <td align="center"><?=(($e_page*$chk_page)+$i)?></td>
    <td ><?=$rs['product_name']?></td>
    <td ><?=$rs['product_price']?></td>
    <td ><?=$rs['pur_detail_date']?></td>
    <td ><?=$rs['ttl_pur']?></td>
  </tr>
<?php $i++; } ?>     
    </table>


code report.php
Code (PHP)
<?php
// Include the main TCPDF library (search for installation path).
require_once('tcpdf/tcpdf.php');
include("tcpdf/class/class_curl.php");

// การตั้งค่าข้อความ ที่เกี่ยวข้องให้ดูในไฟล์ 
// tcpdf / config /  tcpdf_config.php 

// เริ่มสร้างไฟล์ pdf
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// กำหนดรายละเอียดของไฟล์ pdf
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('ninenik');
$pdf->SetTitle('TCPDF table report');
$pdf->SetSubject('TCPDF ทดสอบ');
$pdf->SetKeywords('TCPDF, PDF, ทดสอบ,ninenik, guide');

// กำหนดข้อความส่วนแสดง header
$pdf->SetHeaderData(
    PDF_HEADER_LOGO, // โลโก้ กำหนดค่าในไฟล์  tcpdf_config.php 
    PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001',
    PDF_HEADER_STRING, // กำหนดเพิ่มเติมในไฟล์  tcpdf_config.php 
    array(0,0,0),  // กำหนดสีของข้อความใน header rgb 
    array(0,0,0)   // กำหนดสีของเส้นคั่นใน header rgb 
);

$pdf->setFooterData(
    array(0,64,0),  // กำหนดสีของข้อความใน footer rgb 
    array(220,44,44)   // กำหนดสีของเส้นคั่นใน footer rgb 
);

// กำหนดฟอนท์ของ header และ footer  กำหนดเพิ่มเติมในไฟล์  tcpdf_config.php 
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// ำหนดฟอนท์ของ monospaced  กำหนดเพิ่มเติมในไฟล์  tcpdf_config.php 
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// กำหนดขอบเขตความห่างจากขอบ  กำหนดเพิ่มเติมในไฟล์  tcpdf_config.php 
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// กำหนดแบ่่งหน้าอัตโนมัติ
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// กำหนดสัดส่วนของรูปภาพ  กำหนดเพิ่มเติมในไฟล์  tcpdf_config.php 
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// อนุญาตให้สามารถกำหนดรุปแบบ ฟอนท์ย่อยเพิมเติมในหน้าใช้งานได้
$pdf->setFontSubsetting(true);

// กำหนด ฟอนท์
$pdf->SetFont('thsarabun', '', 14, '', true);

// เพิ่มหน้า 
$pdf->AddPage();
// เรียกใช้งาน ฟังก์ชั่นดึงข้อมูลไฟล์มาใช้งาน
$html = curl_get("http://localhost/Project_Retailstore/tcpdf/reportproduct.php");
 // path ไฟล์ 
// ภ้าทดสอบที่เครื่องก็ใช้ http://localhost/data_html.php

// สร้าง pdf ด้วยคำสั่ง writeHTMLCell()
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);

// แสดงไฟล์ pdf
$pdf->Output('table_report.pdf', 'I');
?>




Tag : PHP, MySQL, JavaScript, jQuery, CakePHP, iReport







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-05-08 20:07:12 By : suwidha View : 2015 Reply : 1
 

 

No. 1



โพสกระทู้ ( 752 )
บทความ ( 3 )



สถานะออฟไลน์
Blogger

https://www.thaicreate.com/community/jquery-datepicker.html

อาจจะไม่ต้องใช้ jQuery ก็ได้นะครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-09 09:06:01 By : ALTELMA
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอคำแนะนำเรื่องการ show จากวันที่ ถึงวันที่ของข้อมูลที่ออกรายงานใน PDF ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่