/var/www/hkosl.com/oneMotorChunHing_delete20240201/html/html/html/pdf_old/quotation.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?php
require_once('./config/lang/eng.php');
require_once(
'./tcpdf.php');

$quotationno $_GET['quotationno'];;


// Set some content to print

require("../inc/configure.php");

$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'};
}

// create new PDF document
//$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

    
//Page header
    
public function Header() {
        
// Logo
        //$image_file = K_PATH_IMAGES.'logo_example.jpg';
        //$this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
        // Set font
        //$this->SetFont('adobemingstd-lighti', 'B', 20);
        // Title
        //$this->Cell(0, 15, '駿興汽車(香港)有限公司<br>CHUN HING MOTORS(HK)LIMITED', 0, false, 'C', 0, '', 0, false, 'M', 'M');

        //$this->Cell(0, 15, 'Chun Hing Motors (HK) Limited', 0, false, 'C', 0, '', 0, false, 'M', 'M');
        //$this->Cell(0, 15, K_PATH_IMAGES, 0, false, 'C', 0, 'http://www.onesolution.com.hk', 0, false, 'M', 'M');
        
        
$tc "一二";
        
$html '<table with="800">
                    <tr><td width="150">'
.$tc.'Name:</td><td width="250">'.$GLOBALS['custnameeng'].'</td>
                        <td width="150">姓名 Quotation no:</td><td width="250">'
.$GLOBALS['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>
                <table with="650" border="1" cellspacing="0" cellpadding="1">
                    <tr><td width="50">No</td>
                        <td width="300">Product name</td>
                        <td width="60">Qty</td>
                        <td width="80">UOM</td>
                        <td width="80">Unit price</td>
                        <td width="80">Amount</td></tr></table>'
;
                        
                        
                        
                        
                        
$sql "select * from OM_QUOTATION_DTL
        where quotationno = 100003 
        order by lineno"
;
$result mysql_query($sql);
$row mysql_fetch_array($result,MYSQL_ASSOC);

    
$prodname        $row{'prodname'};
                        
                        
                        
        
//$sql2 =    "select data from header order by num";
        //$result2 = mysql_query($sql2);
        
        
        //$row2 = mysql_fetch_array($result2, MYSQL_NUM);
        
        

        
$i 0;
        
//$test = $row2[0];
        
        
$test .= $prodname;
        
$this->writeHTML($testtruefalsetruefalse'');
                        
        
//$this->writeHTML($html, true, false, true, false, '');
    
}

    
// Page footer
    
public function Footer() {
        
// Position at 15 mm from bottom
        
$this->SetY(-15);
        
// Set font
        
$this->SetFont('adobemingstd-lighti''I'8);
        
// Page number
        
$this->Cell(010'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0false'C'0''0false'T''M');
    }
}

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

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Man Fok');
$pdf->SetTitle('Quotation');
$pdf->SetSubject('Quotation');
$pdf->SetKeywords('One Solution, oneMotor');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGOPDF_HEADER_LOGO_WIDTH'Quotation'.'''');

// 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();




/*
$html = '<br><br><br><br><br><br><table with="800">
            <tr><td width="150">姓名 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($html, true, false, true, false, '');

$html = '<table with="650" border="1" cellspacing="0" cellpadding="1">
            <tr><td width="50">No</td>
                <td width="300">Product name</td>
                <td width="60">Qty</td>
                <td width="80">UOM</td>
                <td width="80">Unit price</td>
                <td width="80">Amount</td></tr>';
*/
$html '<table with="650" border="1" cellspacing="0" cellpadding="1">';
$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 width="50">'.$lineno.'</td>
            <td width="300">'
.$prodid.' '.$prodname.'</td>
            <td width="60">'
.round($qty,0).'</td>
            <td width="80">'
.$uom.'</td>
            <td width="80" align="right">'
.number_format($price,2).'</td>
            <td width="80" align="right">'
.number_format($amount,2).'</td></tr>';
    
    
$subamount += $amount;
}
$html .= '<tr><td colspan="2">CHECKED BY</td><td colspan="2"></td><td align="right">TOTAL</td><td align="right">'.number_format($subamount,2).'</td></tr>';
$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
//===========================================================+


?>