/
reportbulkquotationspdf.php
108 lines (86 loc) · 2.83 KB
/
reportbulkquotationspdf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require_once('system-db.php');
require_once('pdfreport.php');
require_once("simple_html_dom.php");
class LeadsCallbackReport extends PDFReport {
function newPage() {
$this->Image("images/logomain2.png", 245.6, 1);
$this->Image("images/footer.png", 134, 190);
$size = $this->addText( 10, 13, "Bulk Quotations", 12, 4, 'B') + 5;
$this->SetFont('Arial','', 6);
$cols = array(
"Customer" => 93,
"Customer Code" => 35,
"Quotation Number" => 35,
"User" => 49,
"Quotation Date" => 37,
"Value" => 28
);
$this->addCols($size, $cols);
$cols = array(
"Customer" => "L",
"Customer Code" => "L",
"Quotation Number" => "L",
"User" => "L",
"Quotation Date" => "L",
"Value" => "R"
);
$this->addLineFormat( $cols);
$this->SetY(30);
}
function AddPage($orientation='', $size='') {
parent::AddPage($orientation, $size);
$this->newPage();
}
function __construct($orientation, $metric, $size, $startdate, $enddate, $userid) {
$dynamicY = 0;
parent::__construct($orientation, $metric, $size);
$this->SetAutoPageBreak(true, 30);
$this->AddPage();
try {
$and = "";
if ($startdate != "") {
$and .= " AND A.metacreateddate >= '$startdate' ";
}
if ($enddate != "") {
$and .= " AND A.metacreateddate <= '$enddate' ";
}
if ($userid != "0") {
$and .= " AND A.takenbyid = $userid ";
}
$sql = "SELECT A.*,
B.name AS customername, B.accountnumber,
C.fullname,
DATE_FORMAT(A.metacreateddate, '%d/%m/%Y %H:%I') AS metacreateddate
FROM {$_SESSION['DB_PREFIX']}quotation A
LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}customer B
ON B.id = A.customerid
LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}members C
ON C.member_id = A.takenbyid
WHERE 1 = 1 $and
ORDER BY B.name, A.metacreateddate";
$result = mysql_query($sql);
if ($result) {
while (($member = mysql_fetch_assoc($result))) {
$line=array(
"Customer" => $member['customername'],
"Customer Code" => $member['accountnumber'],
"Quotation Number" => getSiteConfigData()->bookingprefix . "-" . sprintf("%06d", $member['id']),
"User" => $member['fullname'],
"Quotation Date" => $member['metacreateddate'],
"Value" => number_format($member['total'], 2)
);
$this->addLine( $this->GetY(), $line );
}
} else {
logError($sql . " - " . mysql_error());
}
} catch (Exception $e) {
logError($e->getMessage());
}
}
}
start_db();
$pdf = new LeadsCallbackReport( 'L', 'mm', 'A4', convertStringToDate($_POST['datefrom']), convertStringToDate($_POST['dateto']), $_POST['userid']);
$pdf->Output();
?>