-
Notifications
You must be signed in to change notification settings - Fork 0
/
bao-gia-doc.php
388 lines (365 loc) · 15.5 KB
/
bao-gia-doc.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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?php
/**
* Vân Thiên Hùng chuyên lừa đảo, lợi dụng tín nhiệm lừa tiền anh em lập trình.
* Hứa hẹn thanh toán, tới ngày thì than thở kêu chưa thu được tiền từ năm này qua tháng nọ, hẹn tới hẹn lui không có hồi kết.
* Tới lúc bị anh em Dev đòi thì xoá Zalo, đổi pass server nhằm chặn anh em Dev vào phá.
* Đã quỵt tiền 2 người tổng cộng 70 triệu
* Chúc may mắn cho anh em nào đang làm tiếp với Vân Thiên Hùng ^^!.
*/
if (!isset($_SESSION)) {
session_start();
}
function convert_number_to_words($number) {
$hyphen = ' ';
$conjunction = ' ';
$separator = ' ';
$negative = 'âm ';
$decimal = ' phẩy ';
$dictionary = array(
0 => 'Không',
1 => 'Một',
2 => 'Hai',
3 => 'Ba',
4 => 'Bốn',
5 => 'Năm',
6 => 'Sáu',
7 => 'Bảy',
8 => 'Tám',
9 => 'Chín',
10 => 'Mười',
11 => 'Mười một',
12 => 'Mười hai',
13 => 'Mười ba',
14 => 'Mười bốn',
15 => 'Mười năm',
16 => 'Mười sáu',
17 => 'Mười bảy',
18 => 'Mười tám',
19 => 'Mười chín',
20 => 'Hai mươi',
30 => 'Ba mươi',
40 => 'Bốn mươi',
50 => 'Năm mươi',
60 => 'Sáu mươi',
70 => 'Bảy mươi',
80 => 'Tám mươi',
90 => 'Chín mươi',
100 => 'trăm',
1000 => 'ngàn',
1000000 => 'triệu',
1000000000 => 'tỷ',
1000000000000 => 'nghìn tỷ',
1000000000000000 => 'ngàn triệu triệu',
1000000000000000000 => 'tỷ tỷ',
);
if (!is_numeric($number)) {
return false;
}
if (($number >= 0 && (int) $number < 0) || (int) $number < 0 - PHP_INT_MAX) {
// overflow
trigger_error('convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING);
return false;
}
if ($number < 0) {
return $negative . convert_number_to_words(abs($number));
}
$string = $fraction = null;
if (strpos($number, '.') !== false) {
list($number, $fraction) = explode('.', $number);
}
switch (true) {
case $number < 21:
$string = $dictionary[$number];
break;
case $number < 100:
$tens = ((int) ($number / 10)) * 10;
$units = $number % 10;
$string = $dictionary[$tens];
if ($units) {
$string .= $hyphen . $dictionary[$units];
}
break;
case $number < 1000:
$hundreds = $number / 100;
$remainder = $number % 100;
$string = $dictionary[$hundreds] . ' ' . $dictionary[100];
if ($remainder) {
$string .= $conjunction . convert_number_to_words($remainder);
}
break;
default:
$baseUnit = pow(1000, floor(log($number, 1000)));
$numBaseUnits = (int) ($number / $baseUnit);
$remainder = $number % $baseUnit;
$string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
if ($remainder) {
$string .= $remainder < 100 ? $conjunction : $separator;
$string .= convert_number_to_words($remainder);
}
break;
}
if (null !== $fraction && is_numeric($fraction)) {
$string .= $decimal;
$words = array();
foreach (str_split((string) $fraction) as $number) {
$words[] = $dictionary[$number];
}
$string .= implode(' ', $words);
}
return $string;
}
define('__ROOT_PATH', dirname(__FILE__));
define('_lib', './admin/lib/');
define('_source', './sources/');
@include_once _lib . "config.php";
@include_once _lib . "function.php";
global $d;
global $lang;
include _source . "lang.php";
include _source . "language_" . $_SESSION['lang'] . ".php";
$d = new func_index($config['database']);
date_default_timezone_set('Asia/Ho_Chi_Minh');
$cacheFile = __ROOT_PATH . '/tmp/html/' . md5('information') . '.cache'; // Cache file path
if (file_exists($cacheFile) && (time() - filemtime($cacheFile)) < 3600) {
$information = unserialize(file_get_contents($cacheFile));
} else {
$information = $d->simple_fetch("select * from #_thongtin limit 0,1");
// Cache the result
file_put_contents($cacheFile, serialize($information));
}
$SETTINGS = $d->getAllSettings();
$tax = $information['tax'] ? $information['tax'] : 8;
$tax = $tax / 100;
?>
<style type="text/css">
@page {
size: A4;
margin: 0;
}
@media print {
.page {
margin: 0;
border: initial;
border-radius: initial;
width: initial;
min-height: initial;
box-shadow: initial;
background: initial;
page-break-after: always;
}
}
* {
box-sizing: border-box;
}
table.page_header {width: 100%; border: none; background-color: #245e8a; padding: 2mm; color: white; }
table.page_footer {width: 100%; border: none; background-color: #245e8a; padding: 2mm; color: white;}
table.table { border: 1px solid #333; width: 100% }
div.note {color: #333; width: 100%; padding: 0 15px; box-sizing: border-box; }
ul.main { width: 95%; list-style-type: square; }
ul.main li { padding-bottom: 2mm; }
h3 { text-align: center; font-size: 14mm}
p { margin: 5px 0; }
table.page_footer a, table.page_header a { text-decoration: none; color: white;}
table.table {
font-family: freeserif, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
box-sizing: border-box;
max-width: 100%;
}
table.table td, table.table th {
border: 1px solid #ddd;
padding: 8px;
}
table.table tr:nth-child(even){background-color: #f2f2f2;}
table.table tr:hover {background-color: #ddd;}
table.table th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #1c3e95;
color: white;
}
img.logo {
}
pre {
font-family: freeserif, Helvetica, sans-serif;
}
</style>
<link href="<?=URLPATH . "img_data/icon/" . $information['favicon'];?>" rel="shortcut icon" type="image/x-icon" />
<page backbottom="14mm" style="font-size: 12pt; font-family: freeserif; width: 100%">
<page_footer>
<table class="page_footer">
<tr>
<td style="width: 33%; text-align: left;">
<a href="<?php echo getenv('APP_URL'); ?>/"><?php echo getenv('APP_URL'); ?></a>
</td>
<td style="width: 34%; text-align: center">
Page [[page_cu]]/[[page_nb]]
</td>
<td style="width: 33%; text-align: right">
<?php echo date('d.m.Y h.m.sA'); ?>
</td>
</tr>
</table>
</page_footer>
<div style="background:url(img_data/images/<?php echo $SETTINGS['rorate_logo']['value']; ?>) no-repeat scroll center top;width: 96%;padding-left:20px;padding-right:20px;box-sizing: border-box;">
<table style="width: 100%;margin-bottom:35px;">
<tr>
<td align="center" style="vertical-align: middle; width: 260px; white-space: nowrap; overflow: hidden; position: relative">
<img src="img_data/images/<?php echo $SETTINGS['website_logo']['value']; ?>" width=161 height=80 hspace=1 vspace=2 style="margin-top: 30px; margin-right: -100px;" class="logo">
<img src="img_data/images/<?php echo $SETTINGS['company_stamp']['value']; ?>" width=137 height=120 hspace=2 vspace=4 class="con dau" style="margin-left: -150px; z-index: 2; opacity: 0.9; margin-top: -20px">
</td>
<td align="center" style="width: auto;text-align:center;">
<p style="pading-left: 35px;">
<b>
<font face="Times New Roman" color="#0000FF"><?php echo $information['company_vn']; ?></font>
</b>
</p>
<p style="pading-left: 35px;">
<i>
<font face="Times New Roman" color="#0000FF"><?php echo $information['address']; ?></font>
</i>
</p>
<p style="pading-left: 35px;">
<font face="Times New Roman" color="#0000FF">Email: <?php echo $information['email']; ?>, Website: <?php echo $SETTINGS['website']['value']; ?> </font>
</p>
<p style="pading-left: 35px;">
<font face="Times New Roman" color="#0000FF">Tell/Zalo: <?php echo $SETTINGS['zalo']['value']; ?></font>
</p>
</td>
</tr>
</table>
<h1 style="text-align: center">BÁO GIÁ</h1>
<p style="text-align: center"><?php echo 'Ngày ' . date('d') . ' tháng ' . date('m') . ' năm ' . date('Y'); ?></p>
<div class="note" style="width:100%;padding-top:35px;">
<p>Kính gửi: <strong>Quý khách <?php echo !empty($_GET['name']) ? $_GET['name'] : ''; ?></strong></p>
<p>
<?php
if (!empty($_GET['phone'])): ?>
<span>Điện thoại: <strong><?php echo $_GET['phone']; ?></strong></span>
<?php
endif;
if (!empty($_GET['email'])): ?>
<span style="margin-left: 150px">Email: <strong><?php echo $_GET['email']; ?></strong></span>
<?php
endif;
?>
</p>
<p style="margin-bottom: 15px;"><?php echo $SETTINGS['welcome_message']['value']; ?></p>
<?php if (isset($_SESSION['cart'])): ?>
<table style="width: 100%;" class="table table-hover table-bordered">
<tr>
<th style="width: 8%; text-align: center;">STT</th>
<th style="width: 40%; text-align: center;"><?= _namepro ?></th>
<th style="width: 22%; text-align: center;"><?= _price ?></th>
<th style="width: 8%; text-align: center;">SL</th>
<th style="width: 22%; text-align: center;"><?= _money ?></th>
</tr>
<?php
$stt = 0;
$deliveryFee = 0;
$tongtien = 0;
$cartProducts = [];
$sumQuantity = 0;
$total = 0;
if (count($_SESSION['cart']) > 0) {
foreach ($_SESSION['cart'] as $key => $value) {
//$product = $d->simple_fetch("select `id`, `category_id`, `alias_vi`, `alias_en`, `alias_ch`, `code`, `code_2`, `code_3`, `name_vi`, `name_en`, `name_ch`, `description_vi`, `description_en`, `description_ch`, `image_path`, `price`, `promotion_price`, `ngay_dang`, `is_hot`, `sp_moi`, `sp_hot`, `title_vi`, `title_en`, `title_ch`, `keyword`, `des`, `view`, `thanh_pho`, `quan`, `hien_thi`, `gear_type`, `group_pos`, `group_quantity`, `group_quantity`, `extra4`, `extra5`, `extra6`, `extra7`, `extra8`, `extra9`, `extra10`, `con_hang`, `so_thu_tu`, `style`, `specification`, `model`, `brand`, `loai`, `weight`, `nang_cao`, `khung_nang`, `mfg_year`, `gio_su_dung`, `xuat_xu`, `part_number`, `tinh_trang_hang`, `banh_sau`, `chieu_dai_cang`, `nang_thap_nhat`, `mat_ban`, `chieu_rong`, `bao_hanh`, `is_completed`, `cong_suat`, `ti_so_truyen`, `nguon_dien`, `kieu_dang` from #_sanpham where id={$key}");
$product = $d->simple_fetch("select * from #_sanpham where id={$key}");
$cartProducts[] = $product;
if (!empty($product)) {
$id_product = $product['id'];
$price = $product['price'];
if ($product['promotion_price'] > 0) {
$price = $product['promotion_price'];
}
if (!is_string($deliveryFee) && !empty($product['weight']) && $product['weight'] !== 0 && !empty($_SESSION['delivery_area']['price'])) {
$fee = $product['weight'] * $value['so_luong'] * $_SESSION['delivery_area']['price'];
$deliveryFee += $fee;
$tongtien += $fee;
} else {
$deliveryFee = 'Thông báo sau!';
}
$sumQuantity += $value['so_luong'];
$tongtien += $price * $value['so_luong'];
$total += $price * $value['so_luong'];
$stt++;
?>
<tr>
<td style="text-align: center;"><?=$stt?></td>
<td style="width: 240px;">
<a href="<?=URLPATH . $product['alias_' . $_SESSION['lang']]?>.html" style="text-decoration: none;">
<?php echo trim(@$product['name_' . $_SESSION['lang']]); ?>
</a>
</td>
<td align="right" style="font-size: 15px;"><?=@$d->vnd($price)?></td>
<td align="center" style="font-size: 15px;">
<?=$value['so_luong']?>
</td>
<td align="right" style="font-size: 15px;">
<?php echo $d->vnd($price * $value['so_luong']); ?>
</td>
</tr>
<?php
}
}
}
?>
<?php if (!empty($_SESSION['delivery_area'])) {
$tongtien += $_SESSION['delivery_area']['price'];
?>
<tr>
<td colspan="4">Phí vận chuyển</td>
<td colspan="1" style="text-align: right; font-size: 15px;"><?php echo $d->vnd($_SESSION['delivery_area']['price']); ?></td>
</tr>
<?php } ?>
<tr>
<td colspan="4">Cộng</td>
<td colspan="1" style="text-align: right; font-size: 15px;"><?php echo $d->vnd($tongtien); ?></td>
</tr>
<tr>
<td colspan="4">Thuế VAT <?php echo $information['tax']; ?>%</td>
<td colspan="1" style="text-align: right; font-size: 15px;"><?php echo $d->vnd($total * $tax); ?></td>
</tr>
<tr>
<td colspan="4">
<b>Tổng tiền:</b>
</td>
<td colspan="1" style="text-align: right; font-size: 17px;">
<b><?php echo $d->vnd($tongtien + ($total * $tax)); ?></b>
</td>
</tr>
</table>
<p style="margin: 15px 0;">
<b><font face="Times New Roman" size="3" color="#0000FF">Bằng chữ: <?php echo convert_number_to_words($tongtien + ($total * $tax)); ?> nghìn đồng</font></b>
</p>
<?php endif;?>
</div>
<div class="note" style="width:100%;">
<table style="margin-top: 30px; width: 100%;">
<tr>
<td style="width: 50%;">
<b><u>Ghi chú:</u></b>
<i>
<pre><?php echo $SETTINGS['price_quote_note']['value']; ?></pre>
</i>
<p>
<b style="font-size: 13px">XÁC NHẬN CỦA QUÝ KHÁCH HÀNG</b>
</p>
</td>
<td style="width: 50%" align="center">
<p style="text-align: center; color: #0000FF;">
Người báo giá
</p>
<img src="img_data/images/<?php echo $SETTINGS['ceo_sign']['value']; ?>" width="287" height="82" hspace="5" vspace="1">
<p><?php echo $SETTINGS['ceo_name']['value']; ?></p>
</td>
</tr>
</table>
</div>
<div class="note" style="width:100%;">
<hr style="border: 1px solid #333; border-bottom: none;">
</div>
</div>
</page>