/var/www/hkosl.com/oneMotorChunHing_delete20240201/html/html/pdf_old/examples/example_001.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
require_once('../config/lang/eng.php');
require_once(
'../tcpdf.php');

$quotationno '100007';

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue'UTF-8'false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 001');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGOPDF_HEADER_LOGO_WIDTHPDF_HEADER_TITLE.' 001'PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFTPDF_MARGIN_TOPPDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUEPDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------

// set default font subsetting mode
$pdf->setFontSubsetting(true);

// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
//$pdf->SetFont('dejavusans', '', 14, '', true);
$pdf->setFont('adobemingstd-lighti'''10);

// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();

// Set some content to print
$dbh mysql_connect("localhost""man""we11d0ne");

if (!
$dbh) {
   die(
'Could not connect: ' mysql_error());
}
$selected mysql_select_db("oneMOTOR",$dbh
    or die(
"Error");

$sql "SELECT
        a.quotationno, a.custid, a.custno
        , a.custnameeng, a.telno, a.faxno
        , a.email, b.username, a.orderdate
        , a.billaddress, a.discount, paymentmethod
        , paymentterm, sum(c.amount)-a.discount as totalamount
        , a.status, a.attn, licno, modelno, chassisno
        from OM_QUOTATION_HDR a
        left outer join OM_QUOTATION_DTL c
        on a.quotationno = c.quotationno
        , SYS_USER b
        , SYS_PAYMENTMETHOD d
        , SYS_PAYMENTTERM e
        where a.salesid = b.userid
        and a.quotationno = 
$quotationno
        and a.paymentmethodid = d.paymentmethodid
        and a.paymenttermid = e.paymenttermid
        and salesman = 1
        group by 
        a.quotationno, a.custid, a.custno
        , a.custnameeng, a.telno, a.faxno
        , a.orderdate, b.username, a.discount
        , paymentmethod, paymentterm, a.status
        , a.attn"
;
$result mysql_query($sql);
if (
$row mysql_fetch_array($result,MYSQL_ASSOC))
{
    
$custno                $row{'prefix'}.$row{'custno'};
    
$catid                $row{'catid'};
    
$custnameeng        $row{'custnameeng'};
    
$telno                $row{'telno'};
    
$faxno                $row{'faxno'};
    
$email                $row{'email'};
    
$salesman            $row{'username'};
    
$orderdate            $row{'orderdate'};
    
$totalamount        $row{'totalamount'};
    
$billaddress        $row{'billaddress'};
    
$attn                $row{'attn'};

    
$paymentmethodid    $row{'paymentmethodid'};
    
$paymenttermid        $row{'paymenttermid'};

    
$headerdiscount        $row{'discount'};
    
$deliverymethod        $row{'deliverymethod'};
    
$status                $row{'status'};

    
$paymentmethod        $row{'paymentmethod'};
    
$paymentterm        $row{'paymentterm'};

    
$licno                $row{'licno'};
    
$modelno            $row{'modelno'};
    
$chassisno            $row{'chassisno'};
}




$html '<table with="800">
            <tr><td width="150">Customer name:</td><td width="250">'
.$custnameeng.'</td>
                <td width="150">Quotation no:</td><td width="250">'
.$quotationno.'</td></tr>
            <tr><td rowspan="4">Bill address:</td><td rowspan="4">'
.$billaddress.'</td>
                <td>Date:</td><td>'
.$orderdate.'</td></tr>
            <tr><td>From:</td><td>'
.$salesman.'</td></tr>
            <tr><td>Payment Terms::</td><td>'
.$paymentterm.'</td></tr>
            <tr><td>Payment Method::</td><td>'
.$paymentmethod.'</td></tr>
            <tr><td width=100>Phone no:</td><td width=200>'
.$telno.'</td>
                <td width=100></td><td width=200></td></tr>
            <tr><td width=100>Lic no:</td><td width=200>'
.$licno.'</td>
                <td width=100></td><td width=200></td></tr>
            <tr><td width=100>Model no:</td><td width=200>'
.$modelno.'</td>
                <td width=100></td><td width=200></td></tr>
            <tr><td width=100>Chassis no:</td><td width=200>'
.$chassisno.'</td>
                <td width=100></td><td width=200></td></tr>
        </table>'
;

$pdf->writeHTML($htmltruefalsetruefalse'');

$html '<table with="800" border="1" cellspacing="1" cellpadding="1">
            <tr><td width="50">No</td>
                <td width="100">Product code</td>
                <td width="200">Product name</td>
                <td width="70">Qty</td>
                <td width="80">UOM</td>
                <td width="100">Unit price</td>
                <td width="100">Discount</td>
                <td width="100">Cmount</td></tr>'
;
$sql "select * from OM_QUOTATION_DTL
        where quotationno = 
$quotationno 
        order by lineno"
;
$result mysql_query($sql);
while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
{
    
$lineno            $row{'lineno'};
    
$prodid            $row{'prodid'};
    
$barcode        $row{'barcode'};
    
$prodname        $row{'prodname'};
    
$qty            $row{'qty'};
    
$uom            $row{'uom'};
    
$price            $row{'price'};
    
$discount        $row{'discount'};
    
$amount            $row{'amount'};
    
$cost            $row{'cost'};
    
$description    $row{'description'};
        
    
$html .= '<tr><td>'.$lineno.'</td>
            <td>'
.$prodid.'</td>
            <td>'
.$prodname.'</td>
            <td>'
.round($qty,0).'</td>
            <td>'
.$uom.'</td>
            <td align="left">'
.$price.'</td>
            <td aling="right">'
.$discount.'</td>
            <td>'
.$amount.'</td><tr>';
    
    
$subamount += $amount;
}
$html .= '</table>';
$pdf->writeHTML($htmltruefalsetruefalse'');



// Print text using writeHTMLCell()
//$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

// ---------------------------------------------------------

// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output('example_001.pdf''I');

//============================================================+
// END OF FILE
//============================================================+
?>