Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_REQUEST['total']))
- $total = $_REQUEST['total'];
- else
- $total = "";
- if(isset($_REQUEST['Rid']))
- $Rid = $_REQUEST['Rid'];
- error_reporting(E_ALL ^ E_DEPRECATED);
- require('fpdf.php');
- $d=date('d_m_Y');
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname= "DOWNTOWN";
- date_default_timezone_set('Asia/Manila');
- $timedate = date("h:i:s A");
- $p_date =date("Y-m-d");
- // Create connection
- $conn = new mysqli($servername, $username, $password , $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT allinvty3.*, barcode.* , sample.*, sum(barcode.qty) as icount ,
- count(barcode.itemcode) - (sample.tqty) as total1
- from barcode
- LEFT JOIN sample on barcode.itemcode = sample.in_code
- INNER JOIN allinvty3 on barcode.itemcode = allinvty3.in_code
- where sample.refnumber='".$Rid."' and barcode.refnumber='".$Rid."' group by barcode.itemcode";
- $result = $conn->query($sql);
- while($row = $result->fetch_assoc()) {
- $date1 =$row['datereceived'];
- $qty =$row['tqty'];
- $icount =$row['icount'];
- }
- class PDF extends FPDF
- {
- function Header()
- {
- $this->SetFont('Helvetica','',25);
- $this->SetFontSize(40);
- //Move to the right
- $this->Cell(80);
- //Line break
- $this->Ln();
- }
- //Page footer
- function Footer()
- {
- }
- //Load data
- function LoadData($file)
- {
- //Read file lines
- $lines=file($file);
- $data=array();
- foreach($lines as $line)
- $data[]=explode(';',chop($line));
- return $data;
- }
- //Simple table
- function BasicTable($header,$data)
- {
- $this->SetFillColor(255,255,255);
- //$this->SetDrawColor(255, 0, 0);
- $w=array(38,21,90,7,12,7);
- //Header
- $this->SetFont('Arial','B',7);
- for($i=0;$i<count($header);$i++)
- $this->Cell($w[$i],7,$header[$i],1,0,'L',true);
- $this->Ln();
- //Data
- $this->SetFont('Arial','',7);
- foreach ($data as $eachResult)
- { //width
- $this->Cell(10);
- $this->Cell(38,6,$eachResult["ecr_desc"],1);
- $this->Cell(21,6,$eachResult["itemcode"],1);
- $this->Cell(90,6,$eachResult["ite_desc"],1);
- $this->Cell(7,6,$eachResult["tqty"],1);
- $this->Cell(12,6,$eachResult["icount"],1);
- $this->Cell(7,6,$eachResult["total1"],1);
- $this->Ln();
- }
- }
- //Better table
- }
- $pdf=new PDF();
- $header=array('Model','Code','Desc','XFR','ACTUAL', 'DIFF');
- //Data loading
- //*** Load MySQL Data ***//
- $objConnect = mysql_connect("localhost","root","") or die("Error:Please check your database username & password");
- $objDB = mysql_select_db("DOWNTOWN");
- $strSQL = "SELECT allinvty3.*, barcode.* , sample.*, sum(barcode.qty) as icount , sum(barcode.qty ) - (sample.tqty) as total1 from barcode
- INNER JOIN sample on barcode.itemcode = sample.in_code
- INNER JOIN allinvty3 on barcode.itemcode = allinvty3.in_code
- where sample.refnumber='".$Rid."' and barcode.refnumber='".$Rid."' group by barcode.itemcode";
- $objQuery = mysql_query($strSQL);
- $resultData = array();
- for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
- $result = mysql_fetch_array($objQuery);
- array_push($resultData,$result);
- }
- //************************//
- //*** Table 1 ***//
- $pdf->AddPage();
- $pdf->SetFont('Helvetica','',14);
- $pdf->Cell(75);
- $pdf->Write(5, 'Stock Receiving');
- $pdf->Ln();
- $pdf->Cell(22);
- $pdf->SetFontSize(8);
- $pdf->Cell(57);
- $result=mysql_query("select date_format(now(), '%W, %M %d, %Y') as date");
- while( $row=mysql_fetch_array($result) )
- {
- $pdf->Write(5,$row['date']);
- }
- $pdf->Ln();
- //count total numbers of visitors
- $sql= "SELECT allinvty3.*, barcode.* , sample.*, sum(barcode.qty) as icount from barcode
- INNER JOIN sample on barcode.itemcode = sample.in_code
- INNER JOIN allinvty3 on barcode.itemcode = allinvty3.in_code
- where sample.refnumber='".$Rid."' and barcode.refnumber='".$Rid."' ";
- $result = $conn->query($sql);
- while($row = $result->fetch_assoc()) {
- $icount= $row['icount'];
- $date= $row['datereceived'];
- }
- $pdf->Cell(0);
- $pdf->Write(3, ' REFERENCE NUMBER: '.$Rid.'');
- $pdf->Ln();
- $pdf->Cell(0);
- $pdf->Write(2, ' DATE RECEIVED: '.$date.'');
- $pdf->Ln();
- $pdf->Cell(0);
- $pdf->Write(2, ' TOTAL ITEM: '.$icount.'');
- $pdf->Ln();
- $pdf->Ln(5);
- $pdf->Ln(0);
- $pdf->Cell(10);
- $pdf->BasicTable($header,$resultData);
- //forme();
- //$pdf->Output("$d.pdf","F");
- $pdf->Output();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement