1 <?php
2 error_reporting(0);
3 include_once('connect.php');
4
5 $sql = "SELECT `asset_code`, `date_purchased`, `estimated_value`, `location`, `mode_make`, `serial_number`,`asset_condition`, `quantity` FROM `inventory` WHERE active='no'";
6 $resultset = mysqli_query($db, $sql) or die("database error:". mysqli_error($db));
7
8 $sql2 = "SELECT * FROM inventory ";
9 $resultset2 = mysqli_query($db, $sql2) or die("database error:". mysqli_error($db));
10 while($users3=mysqli_fetch_array($resultset2))
11 {
12 $asset_code=$users3['asset_code'];
13 $date_purchased=$users3['date_purchased'];
14 $estimated_value=$users3['estimated_value'];
15 $location=$users3['location'];
16 $mode_make=$users3['mode_make'];
17 $purchase_price=$users3['purchase_price'];
18 $serial_number=$users3['serial_number'];
19 $asset_condition=$users3['asset_condition'];
20 $quantity=$users3['quantity'];
21 }
22
23
24 require('fpdf/fpdf.php');
25 class PDF extends FPDF
26 {
27
28 // Page footer
29 function Footer()
30 {
31 // Position at 1.5 cm from bottom
32 $this->SetY(-10);
33 // Arial italic 8
34 $this->SetFont('Arial','I',8);
35 // Page number
36 $this->Line(0, 600, 210,600);
37 $this->Cell(0,5,'Page '.$this->PageNo().'/{nb}',0,0,'L');
38 // $tDate=date('l \t\h\e jS');
39 //$this->Cell(0, 10, 'Date : '.$tDate, 0, false, 'C', 0, '', 0, false, 'T', 'M');
40 }
41 }
42
43
44 $pdf = new PDF();
45 $pdf->SetAuthor('John Muthama');
46 $pdf->AliasNbPages();
47 //set font for the entire document
48 $pdf->SetFont('Arial','B',20);
49 $pdf->SetTextColor(0,0,0);
50 //set up a page. Code L for landscape and P FOR Portrait
51 $pdf->AddPage('L');
52 //$pdf->SetDisplayMode(real,'default');
53 //insert an image and make it a link
54
55 //display the title with a border around it
56 $pdf->SetXY(100,25);
57 $pdf->Cell(100,5,'Inventory[Disposed Items]',0,0,'C',0);
58 //C MEANS CENTERED
59 //Set x and y position for the main text, reduce font size and write content
60 $pdf->SetXY (10,50);
61 $pdf->SetFontSize(10);
62
63 //for($i=1;$i<=40;$i++)
64 // $pdf->Cell(0,10,'Printing line number '.$i,0,1);
65
66 //This is teh date included in the submited form i.e printinvloice.php
67 // X[WIDTH] is the first value Y[HEIGHT] is the SECOND VALUE
68
69 $pdf->SetXY(100, 25);
70 $pdf->SetFontSize(10);
71 $pdf->Cell(0,10,'Date Printed :'.date('d-m-Y') ,0,0,'R',0);
72
73 //Put a line here
74
75 $pdf->Ln(4); //break
76 $pdf->Ln(4); //break
77 $pdf->Line(0, 35, 297, 35); //Set the line
78 $pdf->Ln(4); //line Break
79 $pdf->Ln(4); //break
80
81 //populate the table with data fetched using the resultset
82 while ($field_info = mysqli_fetch_field($resultset)) {
83 $pdf->Cell(32,8,$field_info->name,1);
84 }
85 while($rows = mysqli_fetch_assoc($resultset)){
86 $pdf->SetFont('Arial','',8);
87 $pdf->Ln();
88
89 foreach($rows as $column) {
90 $pdf->Cell(32,8,$column,1);
91 }
92 }
93
94 $pdf->Output();
95 ?>