commitall
This commit is contained in:
128
account/application/libraries/Fpdflib.php
Normal file
128
account/application/libraries/Fpdflib.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once APPPATH . "/third_party/pdf/fpdm.php";
|
||||
|
||||
class fpdflib
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function createPDF()
|
||||
{
|
||||
echo "COW";
|
||||
$pdf = new FPDM\FPDM(APPPATH."/../pdf/voucher1.pdf");
|
||||
/*
|
||||
$result = 'SELECT * FROM report WHERE time BETWEEN "' . $_POST["fromdate"] . '" AND "' . $_POST["todate"] . '"';
|
||||
$link = $db->prepare($result);
|
||||
$link->execute();
|
||||
$resultset = $link->fetchAll();
|
||||
$count = $link->rowCount();
|
||||
$pdf = new PDF();
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->SetTitle("Report");
|
||||
$pdf->AddPage();
|
||||
|
||||
$row_height = 10;
|
||||
$y_axis = 30;
|
||||
|
||||
|
||||
$pdf->SetY($y_axis);
|
||||
$pdf->SetX(25);
|
||||
$pdf->Cell(30, 10, "", 0, 0, 1);
|
||||
$y_axis = $y_axis + $row_height;
|
||||
|
||||
|
||||
|
||||
$pdf->SetDrawColor(128, 0, 0);
|
||||
$pdf->SetTextColor(102, 68, 34);
|
||||
$pdf->SetFont('Arial', 'B', 10);
|
||||
$pdf->SetY($y_axis);
|
||||
$pdf->SetX(11);
|
||||
$pdf->Cell(34, 10, 'Order ID', 1, 0, 'C');
|
||||
$pdf->Cell(35, 10, 'Name', 1, 0, 'C');
|
||||
$pdf->Cell(30, 10, 'TID', 1, 0, 'C');
|
||||
$pdf->Cell(20, 10, 'Quantity', 1, 0, 'C');
|
||||
$pdf->Cell(20, 10, 'Date', 1, 0, 'C');
|
||||
$pdf->Cell(20, 10, 'Time', 1, 0, 'C');
|
||||
$pdf->Cell(30, 10, 'Bill Amount', 1, 0, 'C');
|
||||
$y_axis = $y_axis + $row_height;
|
||||
$total = 0;
|
||||
foreach ($resultset as $row) {
|
||||
$len = strlen($row['name']);
|
||||
if ($len > 21) {
|
||||
$name = substr($row['name'], 0, 19) . "..";
|
||||
} else {
|
||||
$name = $row['name'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$oid = $row['order_id'];
|
||||
|
||||
$tid = $row['t_id'];
|
||||
$qty = $row['quantity'];
|
||||
$date = $row['date'];
|
||||
$time = $row['time'];
|
||||
$amt = $row['bill_amount'];
|
||||
|
||||
$total = $total + $amt;
|
||||
|
||||
$pdf->SetDrawColor(128, 0, 0);
|
||||
$pdf->SetTextColor(0);
|
||||
$pdf->SetFont('Arial', '', 9);
|
||||
$pdf->SetY($y_axis);
|
||||
$pdf->SetX(11);
|
||||
$pdf->Cell(34, 10, $oid, 1, 0, 'L');
|
||||
$pdf->Cell(35, 10, $name, 1, 0, 'L');
|
||||
$pdf->Cell(30, 10, $tid, 1, 0, 'C');
|
||||
$pdf->Cell(20, 10, $qty, 1, 0, 'C');
|
||||
$pdf->Cell(20, 10, $date, 1, 0, 'C');
|
||||
$pdf->Cell(20, 10, $time, 1, 0, 'C');
|
||||
$pdf->Cell(30, 10, $amt, 1, 0, 'R');
|
||||
|
||||
$y_axis = $y_axis + $row_height;
|
||||
$pdf->SetY(10);
|
||||
$pdf->SetX(170);
|
||||
}
|
||||
|
||||
$totalre = $total - $r_amt;
|
||||
$pdf->SetDrawColor(128, 0, 0);
|
||||
$pdf->SetTextColor(0);
|
||||
$pdf->SetFont('Arial', 'B', 11);
|
||||
$pdf->SetY($y_axis);
|
||||
$pdf->SetX(137);
|
||||
$pdf->Cell(42, 10, 'Total', 0, 0, 'C');
|
||||
$pdf->SetTextColor(255, 0, 0);
|
||||
$pdf->Cell(25, 10, $totalre, 0, 0, 'C');
|
||||
$y_axis = $y_axis + $row_height;
|
||||
$pdf->SetAutoPageBreak(false, 20);
|
||||
$pdf->Output();
|
||||
*/
|
||||
}
|
||||
|
||||
function Header()
|
||||
{
|
||||
$this->Image('picture.png', 10, 6, 30);
|
||||
$this->SetFont('Arial', 'B', 15);
|
||||
// Move to the right
|
||||
$this->Cell(80);
|
||||
// Title
|
||||
$this->SetTextColor(255, 119, 0);
|
||||
$this->Cell(30, 10, 'Report', 0, 0, 'C');
|
||||
// Line break
|
||||
$this->Line(10, 22, 210 - 10, 22);
|
||||
$this->Ln(20);
|
||||
}
|
||||
|
||||
// Page footer
|
||||
function Footer()
|
||||
{
|
||||
$this->Line(10, 280, 210 - 10, 280);
|
||||
$this->SetY(-15);
|
||||
$this->SetFont('Arial', 'I', 8);
|
||||
// Page number
|
||||
$this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user