/var/www/hkosl.com/oneMotorChunHing_delete20240201/html/quo.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
<?php
error_reporting
(1);
//ini_set('display_errors', '1');
require_once('pdf/config/lang/eng.php');
require_once(
'pdf/tcpdf.php');

$quotationno $_GET['quotationno'];
//$quotationno = 100001;

require("inc/configure.php");

$sql "SELECT
        a.quotationno, a.custid, a.custno, a.mileage
        , 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'};
    
$mileage            $row['mileage'];
}

$r0 $r1 $r2 $r3 $x_main $y_main 0;
/*var_dump($row);
echo"hi";
exit;*/
$sc substr_count($billaddress"\n");

class 
quotation extends TCPDF{
    
//Page header
    
public function Header(){
        
        
$image_file 'quotation.jpg';
        
$this->Image($image_file11010''150);
        
        
$temp $GLOBALS['licno'];
        
$result5 mysql_query("select caryear, mileage from CM_CAR where licno = '$temp'");
        
$row5 mysql_fetch_assoc($result5);
        
        
$this->SetFont('stsongstdlight'''12);    // bold
        
$this->SetXY(400,130);
        
$this->Cell(900'Quotation No.:  '00'R');
        
$this->Cell(800$GLOBALS['quotationno'], 01'L');
        
$this->SetX(400);
        
$this->Cell(900'Date:  '00'R');
        
$this->Cell(800$GLOBALS['orderdate'], 01'L');
        
$this->SetCellPadding(5);
        
        
$this->Cell(2700'客戶資料 Customer Detail'10);
        
$this->Cell(2700'車輛資料 Vehicle Data'11);
        
        
$tmp_left '姓名Name: '.html_entity_decode($GLOBALS['custnameeng']).PHP_EOL.
        
'地址Addrs: '.html_entity_decode($GLOBALS['billaddress']).PHP_EOL.
        
'電話Tel: '.html_entity_decode($GLOBALS['telno']).PHP_EOL.
        
'傳真Fax: '.html_entity_decode($GLOBALS['faxno']).PHP_EOL;
    
        
$tmp_right '車牌Lic No.: '.html_entity_decode($GLOBALS['licno'])." 年款Year: ".html_entity_decode($row5['caryear']).PHP_EOL.
        
'型號Model: '.html_entity_decode($GLOBALS['modelno']).PHP_EOL.
        
'車身Chas No.: '.html_entity_decode($GLOBALS['chassisno']).PHP_EOL.
        
'里數Mileage: '.html_entity_decode($row5['mileage']).PHP_EOL;
        
        
$height_2row max$this->getStringHeight(250$tmp_left), $this->getStringHeight(270$tmp_right) )+5
        
        
$this->MultiCell(270$height_2row
        
$tmp_left,
        
1'L'00);
        
$this->MultiCell(270$height_2row
        
$tmp_right,
        
1'L');
        
        
$height_2row=35;
        
$GLOBALS['r0']= $this->GetX();
        
$this->MultiCell(300$height_2row
        
'項目'.PHP_EOL.'Particulars',
        
1'C'00);
        
//$this->Cell(300, 0, 'Particulars', 1, 0, 'C');
        
$GLOBALS['r1']= $this->GetX();
        
$this->MultiCell(80$height_2row
        
'單價'.PHP_EOL.'Unit price',
        
1'C'00);
        
//$this->Cell(80, 0, 'Unit Price', 1, 0, 'R');
        
$this->MultiCell(80$height_2row
        
'數量'.PHP_EOL.'Qty',
        
1'C'00);
        
$GLOBALS['r2']= $this->GetX();
        
//$this->Cell(80, 0, 'Quantity', 1, 0, 'R');
        
$this->MultiCell(80$height_2row
        
'金額'.PHP_EOL.'Total',
        
1'C'0);
        
$GLOBALS['r3']= $this->GetX();
        
//$this->Cell(80, 0, 'Amount', 1, 1, 'R');
        
        
$GLOBALS['x_main']= $this->GetX();
        
$GLOBALS['y_main']= $this->GetY();
    }

    
// Page footer
    
public function Footer(){
        
        
$this->SetY(-10);
        
// Set font
        
$this->SetFont('helvetica''I'8);
        
// Page number
        
$this->Cell(010'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0false'C'0''0false'T''M');
    }
}

// create new PDF document
$pdf = new quotation('P''pt''A4'true'UTF-8'false);
// set document information
$pdf->SetCreator('One Solution');
$pdf->SetAuthor('One Solution');
$pdf->SetTitle('One Solution');
$pdf->SetSubject('One Solution');
$pdf->SetKeywords('One Solution');
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 008', PDF_HEADER_STRING);
// set header and footer fonts
//$pdf->setHeaderFont(Array(stsongstdlight, '', 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_LEFT75PDF_MARGIN_RIGHT);    // left, top, right
$pdf->SetHeaderMargin(10);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetCellPadding(5);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE50);
//set image scale factor
$pdf->setImageScale(1.3333);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// set font
$pdf->SetFont('stsongstdlight'''12);    // bold
// add a page
$pdf->AddPage();

$pdf->SetTopMargin($y_main);
        
$sql "select * from OM_QUOTATION_DTL
        where quotationno = 
$quotationno 
        order by lineno"
;
$result mysql_query($sql);

$subamount=0;
while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
{
    
$lineno            $row{'lineno'};
    
$prodid            $row{'prodid'};
    
$prodno            $row{'prodno'};
    
$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'};
    
    
$maxheight$pdf->getStringHeight(240$prodname);
    if(
$pdf->GetY()+$maxheight>770){
        
// add a page
        
$pdf->AddPage();
    }
    
    
//$pdf->MultiCell(50, $maxheight, $pdf->GetY(), 1, 'L', 0, 0);
    
$pdf->MultiCell(50$maxheight$prodno'L''L'00);
    
$pdf->MultiCell(250$maxheight$prodname'R''L'00);
    
$pdf->MultiCell(80$maxheightnumber_format($price,2), 'LR''R'00);    
    
$pdf->MultiCell(80$maxheightround($qty,1), 'LR''C'00);
    
$pdf->MultiCell(80$maxheightnumber_format($amount,2), 'LR''R'0);
    
    if(
$pdf->GetY()+$maxheight>770){
        
$pdf->MultiCell(5405'''T''R'0);
    }
    
    
$subamount += $amount;
}
$height_2row=40;
    
$pdf->MultiCell(300$height_2row
'本報價單有效期為30天'.PHP_EOL.'Quotation validity is 30 days from date of issue',
1'L'00);
$pdf->MultiCell(160$height_2row
''.PHP_EOL.'總數 Total:',
1'R'00);
$pdf->MultiCell(80$height_2row
PHP_EOL.number_format($subamount,2),
1'R'0);
                
$pdf->Ln(20);

$pdf->MultiCell(25080
' '.PHP_EOL.PHP_EOL.'經手人'.PHP_EOL.'Issued by:',
'B''L'0);                
                
//Close and output PDF document
$pdf->Output("quotation_$quotationno.pdf"'I');
?>