PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / includes / order_print_ex.php

order_print_ex.php in Welcart e-Commerce 2.12.4, at includes/order_print_ex.php

1,519 lines 70.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Output PDF.
4 * (For reduced tax rate)
5 *
6 * @package Welcart
7 */
8
9 global $usces;
10
11 require_once USCES_PLUGIN_DIR . '/pdf/tcpdf/tcpdf.php';
12 require_once USCES_PLUGIN_DIR . '/classes/orderData.class.php';
13
14 define( 'USCES_PDF_FONT_FILE_NAME', 'msgothic.php' );
15
16 $pdf = new TCPDF( PDF_PAGE_ORIENTATION, PDF_UNIT, 'B5', true, 'UTF-8' );
17 $usces_pdfo = new orderDataObject( $_REQUEST['order_id'] );
18 $usces_pdfo = apply_filters( 'usces_filter_pdf_order_data', $usces_pdfo );
19 do_action( 'usces_action_order_print_start' );
20
21 usces_pdf_out( $pdf, $usces_pdfo );
22 die();
23
24 /**
25 * Convert encoding
26 *
27 * @param string $str Text.
28 * @return string
29 */
30 function usces_conv_euc( $str ) {
31 $str = apply_filters( 'usces_filter_pdf_conv_enc', $str );
32 return $str;
33 }
34
35 /**
36 * Output PDF
37 *
38 * @param object $pdf TCPDF.
39 * @param array $data Order data.
40 */
41 function usces_pdf_out( $pdf, $data ) {
42 global $usces;
43 $usces_tax = Welcart_Tax::get_instance();
44
45 $type = ( isset( $_REQUEST['type'] ) ) ? wp_unslash( $_REQUEST['type'] ) : '';
46
47 $pdf->setPrintHeader( false );
48 $pdf->setPrintFooter( false );
49
50 /* Template file */
51 // if ( isset( $usces->options['print_size'] ) && 'A4' === $usces->options['print_size'] ) {
52 // $tplfile = USCES_PLUGIN_DIR . '/images/orderform_A4.pdf';
53 // } else {
54 // $tplfile = USCES_PLUGIN_DIR . '/images/orderform_B5.pdf';
55 // }
56 // $tplfile = apply_filters( 'usces_filter_pdf_template', $tplfile );
57
58 $pdf->SetLeftMargin( 0 );
59 $pdf->SetTopMargin( 0 );
60 $pdf->addPage();
61
62 /* Add font */
63 $font_ob = new TCPDF_FONTS();
64 $font_file_name = apply_filters( 'usces_filter_pdf_font_file_name', USCES_PDF_FONT_FILE_NAME ); // Set font file and assign font name. This method is new.
65 $font = $font_ob->addTTFfont( USCES_PLUGIN_DIR . '/pdf/tcpdf/fonts/' . $font_file_name );
66 $font = apply_filters( 'usces_filter_pdf_cfont', $font, $font_ob ); // custom addTTFfont.
67
68 /* PDF type */
69 $creator_name = apply_filters( 'usces_filter_pdf_creator_name', html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ) );
70 $author_name = apply_filters( 'usces_filter_pdf_author_name', html_entity_decode( $usces->options['company_name'], ENT_COMPAT ) );
71 $pdf->SetCreator( $creator_name );
72 $pdf->SetAuthor( $author_name );
73 switch ( $type ) {
74 case 'mitumori':
75 $pdf->SetTitle( 'estimate' );
76 $filename = 'estimate_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
77 break;
78
79 case 'nohin':
80 $pdf->SetTitle( 'invoice' );
81 $filename = 'invoice_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
82 break;
83
84 case 'receipt':
85 $pdf->SetTitle( 'receipt' );
86 $filename = 'receipt_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
87 break;
88
89 case 'bill':
90 $pdf->SetTitle( 'bill' );
91 $filename = 'bill_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
92 break;
93
94 default:
95 $title = apply_filters( 'usces_filter_pdf_title', $type );
96 $pdf->SetTitle( $title );
97 $filename = trim( $type ) . '_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
98 }
99 $filename = apply_filters( 'usces_filter_pdf_filename', $filename, $type, $data );
100
101 $pdf->SetDisplayMode( 'real', 'continuous' );
102
103 $pdf->getAliasNbPages();
104
105 $pdf->SetAutoPageBreak( true, 5 );
106
107 $pdf->SetFillColor( 255, 255, 255 );
108
109 /* Initial page number */
110 $page = 1;
111
112 /* Output header */
113 usces_pdfSetHeader( $pdf, $data, $page, $font );
114
115 $border = 0;
116
117 $pdf->SetLeftMargin( 19.8 );
118 $x = 15.8;
119 $y = 101;
120 $onep = apply_filters( 'usces_filter_pdf_page_height', 185 );
121 $pdf->SetXY( $x, $y );
122 $next_y = $y;
123 $line_y = $next_y;
124 $cart = usces_get_ordercartdata( $data->order['ID'] );
125 $cart = apply_filters( 'usces_filter_pdf_cart_data', $cart, $data->order['ID'] );
126 $materials = array(
127 'total_items_price' => $data->order['item_total_price'],
128 'discount' => $data->order['discount'],
129 'shipping_charge' => $data->order['shipping_charge'],
130 'cod_fee' => $data->order['cod_fee'],
131 'use_point' => $data->order['usedpoint'],
132 'carts' => $cart,
133 'condition' => $data->condition,
134 'order_id' => $data->order['ID'],
135 );
136 $usces_tax->get_order_tax( $materials );
137
138 $condition = $data->condition;
139 $tax_display = ( isset( $condition['tax_display'] ) ) ? $condition['tax_display'] : usces_get_tax_display();
140 $tax_target = ( isset( $condition['tax_target'] ) ) ? $condition['tax_target'] : $usces->options['tax_target'];
141 $tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : $usces->options['tax_mode'];
142
143 $fontsizes = array(
144 'item_name' => 8,
145 'item_name_receipt' => 8,
146 'details' => 8,
147 'quantity' => 7,
148 'unit' => 7,
149 'unitprice' => 7,
150 'row_price' => 7,
151 );
152 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['item_name'] );
153 $index = 0;
154
155 $count_cart_standard = count( $usces_tax->cart_standard );
156 $count_cart_reduced = count( $usces_tax->cart_reduced );
157 $count_cart = $count_cart_standard + $count_cart_reduced;
158
159 if ( 0 <= $usces_tax->subtotal_standard && 0 < $count_cart_standard ) {
160
161 foreach ( $usces_tax->cart_standard as $cart_row ) {
162 if ( $onep < $next_y ) { // Page break.
163
164 $pdf->addPage();
165 $page++;
166
167 /* Output header */
168 usces_pdfSetHeader( $pdf, $data, $page, $font );
169
170 $x = 15.8;
171 $y = 101;
172 $pdf->SetXY( $x, $y );
173 $next_y = $y;
174 }
175
176 /* Output detail */
177 $next_y = usces_pdfSetDetail( $pdf, $data, $page, $font, $x, $y, $onep, $next_y, $border, $index, $cart, $cart_row, $fontsizes );
178 $index++;
179 }
180
181 if ( $onep < $next_y ) { // Page break.
182
183 $pdf->addPage();
184 $page++;
185
186 /* Output header */
187 usces_pdfSetHeader( $pdf, $data, $page, $font );
188
189 $x = 15.8;
190 $y = 101;
191 $pdf->SetXY( $x, $y );
192 $next_y = $y;
193 }
194
195 if ( 'activate' === $tax_display && 'products' === $tax_target ) {
196 $subtotal_label = sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard );
197 $subtotal_tax_label = sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard );
198 if ( 'include' === $tax_mode ) {
199 $subtotal_tax_standard = '(' . $usces->get_currency( $usces_tax->tax_standard ) . ')';
200 } else {
201 $subtotal_tax_standard = $usces->get_currency( $usces_tax->tax_standard );
202 }
203
204 $line_left = 103.5;
205 // $line_left = 15.4;
206 $line_right = 165.5;
207
208 $line_y = $next_y - 1;
209 $pdf->SetLineWidth( 0.04 );
210 $pdf->Line( $line_left, $line_y, $line_right, $line_y );
211
212 $line_y += 0.4;
213 $pdf->SetXY( 104.3, $line_y );
214 $pdf->MultiCell( 37.7, $lineheight, usces_conv_euc( $subtotal_label ), 0, 'C' );
215 $pdf->SetXY( 142.9, $line_y );
216 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $usces->get_currency( $usces_tax->subtotal_standard + $usces_tax->discount_standard ) ), 0, 'R' );
217
218 $line_y += 3.8;
219 $pdf->SetLineWidth( 0.04 );
220 $pdf->Line( $line_left, $line_y, $line_right, $line_y );
221
222 $line_y += 0.4;
223 $pdf->SetXY( 104.3, $line_y );
224 $pdf->MultiCell( 37.7, $lineheight, usces_conv_euc( $subtotal_tax_label ), 0, 'C' );
225 $pdf->SetXY( 142.9, $line_y );
226 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $subtotal_tax_standard ), 0, 'R' );
227
228 $line_y += 3.8;
229 $pdf->SetLineWidth( 0.1 );
230 $pdf->Line( 15.4, $line_y, $line_right, $line_y );
231
232 $next_y = $pdf->GetY() + 2;
233 }
234 }
235
236 if ( 0 <= $usces_tax->subtotal_reduced && 0 < $count_cart_reduced ) {
237
238 foreach ( $usces_tax->cart_reduced as $cart_row ) {
239 if ( $onep < $next_y ) { // Page break.
240
241 $pdf->addPage();
242 $page++;
243
244 /* Output header */
245 usces_pdfSetHeader( $pdf, $data, $page, $font );
246
247 $x = 15.8;
248 $y = 101;
249 $pdf->SetXY( $x, $y );
250 $next_y = $y;
251 }
252
253 /* Output detail */
254 $next_y = usces_pdfSetDetail( $pdf, $data, $page, $font, $x, $y, $onep, $next_y, $border, $index, $cart, $cart_row, $fontsizes, $usces_tax->reduced_taxrate_mark );
255 $index++;
256 }
257
258 if ( $onep < $next_y ) { // Page break.
259
260 $pdf->addPage();
261 $page++;
262
263 /* Output header */
264 usces_pdfSetHeader( $pdf, $data, $page, $font );
265
266 $x = 15.8;
267 $y = 101;
268 $pdf->SetXY( $x, $y );
269 $next_y = $y;
270 }
271
272 if ( 'activate' === $tax_display && 'products' === $tax_target ) {
273 $subtotal_label = sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced );
274 $subtotal_tax_label = sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced );
275 if ( 'include' === $tax_mode ) {
276 $subtotal_tax_reduced = '(' . $usces->get_currency( $usces_tax->tax_reduced ) . ')';
277 } else {
278 $subtotal_tax_reduced = $usces->get_currency( $usces_tax->tax_reduced );
279 }
280
281 $line_left = 103.5;
282 // $line_left = 15.4;
283 $line_right = 165.5;
284
285 $line_y = $next_y;
286 $pdf->SetLineWidth( 0.04 );
287 $pdf->Line( $line_left, $line_y, $line_right, $line_y );
288
289 $line_y += 0.4;
290 $pdf->SetXY( 104.3, $line_y );
291 $pdf->MultiCell( 37.7, $lineheight, usces_conv_euc( $subtotal_label ), 0, 'C' );
292 $pdf->SetXY( 142.9, $line_y );
293 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $usces->get_currency( $usces_tax->subtotal_reduced + $usces_tax->discount_reduced ) ), 0, 'R' );
294
295 $line_y += 3.8;
296 $pdf->SetLineWidth( 0.04 );
297 $pdf->Line( $line_left, $line_y, $line_right, $line_y );
298
299 $line_y += 0.4;
300 $pdf->SetXY( 104.3, $line_y );
301 $pdf->MultiCell( 37.7, $lineheight, usces_conv_euc( $subtotal_tax_label ), 0, 'C' );
302 $pdf->SetXY( 142.9, $line_y );
303 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $subtotal_tax_reduced ), 0, 'R' );
304
305 // $line_y += 3.8;
306 // $pdf->SetLineWidth( 0.04 );
307 // $pdf->Line( $line_left, $line_y, $line_right, $line_y );
308 }
309 }
310
311 if ( $onep < $next_y ) { // Page break.
312
313 $pdf->addPage();
314 $page++;
315
316 /* Output header */
317 usces_pdfSetHeader( $pdf, $data, $page, $font );
318
319 $x = 15.8;
320 $y = 101;
321 $pdf->SetXY( $x, $y );
322 $next_y = $y;
323 }
324
325 /* Output footer */
326 usces_pdfSetFooter( $pdf, $data, $font, $usces_tax );
327
328 @ob_end_clean();
329
330 /* Output */
331 $pdf->Output( $filename, 'I' );
332 }
333
334 /**
335 * Header
336 *
337 * @param object $pdf TCPDF.
338 * @param object $data Order data.
339 * @param int $page Page.
340 * @param object $font Font.
341 * @return void
342 */
343 function usces_pdfSetHeader( $pdf, $data, $page, $font ) {
344 global $usces;
345
346 $type = ( isset( $_REQUEST['type'] ) ) ? wp_unslash( $_REQUEST['type'] ) : '';
347
348 $fontsizes = array(
349 'numbering_label' => 9,
350 'title' => 15,
351 'date' => 9,
352 'page_no' => 13,
353 'customer_company' => 12,
354 'customer_attn' => 8,
355 'customer_address' => 8,
356 'total_price' => 20,
357 'message' => 9,
358 'statement_label' => 10,
359 'delivery_label' => 8,
360 'delivery_address' => 6,
361 'order_date' => 10,
362 'publisher' => 9,
363 'company_name' => 8,
364 'details_label' => 8,
365 );
366 $fontsizes = apply_filters( 'useces_filter_order_pdfheader_fontsize', $fontsizes, $data );
367 $fontsizes = apply_filters( 'usces_filter_pdf_header_fontsize', $fontsizes, $data ); // alias.
368
369 switch ( $type ) {
370 case 'mitumori':
371 $title = apply_filters( 'usces_filter_pdf_estimate_title', __( 'Quotation', 'usces' ), $data );
372 $message = sprintf( __( "Thank you for using '%s'. We estimate as follows.", 'usces' ), apply_filters( 'usces_filter_publisher', html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ) ) );
373 $message = apply_filters( 'usces_filter_pdf_estimate_message', $message, $data );
374 $juchubi = apply_filters( 'usces_filter_pdf_estimate_validdays', __( 'Valid:7days', 'usces' ), $data );
375 $siharai = ' ';
376 $sign_image = apply_filters( 'usces_filter_pdf_estimate_sign', null );
377 $effective_date = date_i18n( __( 'M j, Y', 'usces' ), strtotime( $data->order['date'] ) );
378 break;
379
380 case 'nohin':
381 $title = apply_filters( 'usces_filter_pdf_invoice_title', __( 'Delivery Statement', 'usces' ), $data );
382 $message = sprintf( __( "Thank you for using '%s'. We will deliver as follows.", 'usces' ), apply_filters( 'usces_filter_publisher', html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ) ) );
383 $message = apply_filters( 'usces_filter_pdf_invoice_message', $message, $data );
384 $juchubi = __( 'date of your order', 'usces' ) . ' : ' . date_i18n( __( 'M j, Y', 'usces' ), strtotime( $data->order['date'] ) );
385 $siharai = __( 'your payment method', 'usces' ) . ' : ' . apply_filters( 'usces_filter_pdf_payment_name', $data->order['payment_name'], $data );
386 $sign_image = apply_filters( 'usces_filter_pdf_invoice_sign', null );
387
388 if ( ! empty( $data->order['delidue_date'] ) && '#none#' !== $data->order['delidue_date'] ) {
389 $effective_date = date_i18n( __( 'M j, Y', 'usces' ), strtotime( $data->order['delidue_date'] ) );
390 } else {
391 if ( empty( $data->order['modified'] ) ) {
392 $effective_date = date_i18n( __( 'M j, Y', 'usces' ), current_time( 'timestamp', 0 ) );
393 } else {
394 $effective_date = date_i18n( __( 'M j, Y', 'usces' ), strtotime( $data->order['modified'] ) );
395 }
396 }
397 break;
398
399 case 'receipt':
400 $title = apply_filters( 'usces_filter_pdf_receipt_title', __( 'Receipt', 'usces' ), $data );
401 $message = apply_filters( 'usces_filter_pdf_receipt_message', __( 'Your payment has been received.', 'usces' ), $data );
402 $juchubi = __( 'date of your order', 'usces' ) . ' : ' . date_i18n( __( 'M j, Y', 'usces' ), strtotime( $data->order['date'] ) );
403 $siharai = __( 'your payment method', 'usces' ) . ' : ' . apply_filters( 'usces_filter_pdf_payment_name', $data->order['payment_name'], $data );
404 $sign_image = apply_filters( 'usces_filter_pdf_receipt_sign', null );
405
406 $payment = $usces->getPayments( $data->order['payment_name'] );
407 if ( 'COD' === $payment['settlement'] ) {
408 if ( '' === $data->order['modified'] ) {
409 $receipted_date = current_time( 'Y-m-d' );
410 } else {
411 $receipted_date = $data->order['modified'];
412 }
413 } else {
414 $receipted_date = $usces->get_order_meta_value( 'receipted_date', $data->order['ID'] );
415 }
416
417 if ( empty( $receipted_date ) ) {
418 $effective_date = date_i18n( __( 'M j, Y', 'usces' ), current_time( 'timestamp', 0 ) );
419 } else {
420 $effective_date = date_i18n( __( 'M j, Y', 'usces' ), strtotime( $receipted_date ) );
421 }
422 break;
423
424 case 'bill':
425 $title = apply_filters( 'usces_filter_pdf_bill_title', __( 'Invoice', 'usces' ), $data );
426 $message = apply_filters( 'usces_filter_pdf_bill_message', __( 'Please remit payment at your earliest convenience.', 'usces' ), $data );
427 $juchubi = __( 'date of your order', 'usces' ) . ' : ' . date_i18n( __( 'M j, Y', 'usces' ), strtotime( $data->order['date'] ) );
428 $siharai = __( 'your payment method', 'usces' ) . ' : ' . apply_filters( 'usces_filter_pdf_payment_name', $data->order['payment_name'], $data );
429 $sign_image = apply_filters( 'usces_filter_pdf_bill_sign', null );
430 $effective_date = date_i18n( __( 'M j, Y', 'usces' ), current_time( 'timestamp', 0 ) );
431 break;
432 }
433 $effective_date = apply_filters( 'usces_filter_pdf_effective_date', $effective_date, $type, $data );
434 $numbering_label = apply_filters( 'usces_filter_pdf_numbering_label', 'No.', $type, $data );
435 $order_number = apply_filters( 'usces_filter_pdf_order_number', usces_get_deco_order_id( $data->order['ID'] ), $type, $data );
436 $juchubi = apply_filters( 'usces_filter_pdf_purchase_date', $juchubi, $type, $data );
437 $free_note = apply_filters( 'usces_filter_pdf_free_note', '', $type, $data );
438 $siharai = apply_filters( 'usces_filter_pdf_payment_method', $siharai, $type, $data );
439
440 $pdf->SetLineWidth( 0.4 );
441 $pdf->Line( 65, 23, 110, 23 );
442 $pdf->SetLineWidth( 0.1 );
443 $pdf->Line( 124, 19, 167, 19 );
444 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['numbering_label'] );
445 $pdf->SetFont( $font, '', $fontsize );
446 $pdf->SetXY( 125, 15.0 );
447 $pdf->Write( $lineheight, $numbering_label );
448
449 /* Title */
450 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['title'] );
451 $pdf->SetFont( $font, '', $fontsize );
452 $pdf->SetXY( 63, 16 );
453 $pdf->MultiCell( 50, $lineheight, usces_conv_euc( $title ), 0, 'C' );
454
455 /* Date */
456 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['date'] );
457 $pdf->SetFont( $font, '', $fontsize );
458 $pdf->SetXY( 64, 24.2 );
459 $pdf->MultiCell( 45.5, $lineheight, usces_conv_euc( $effective_date ), 0, 'C' );
460
461 /* Order No. */
462 $pdf->SetXY( 131, 15 );
463 $pdf->MultiCell( 36, $lineheight, $order_number, 0, 'R' );
464
465 /* Page No. */
466 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['page_no'] );
467 $pdf->SetFont( $font, '', $fontsize );
468 $pdf->SetXY( 15.5, 15.4 );
469 $pdf->Cell( 20, 7, ' ' . $page . '/ ' . $pdf->getAliasNbPages(), 1 );
470
471 $width = 80;
472 $leftside = 15;
473 $pdf->SetLeftMargin( $leftside );
474
475 $person_honor = ( 'JP' === $usces->options['system']['currency'] ) ? '' : '';
476 $company_honor = ( 'JP' === $usces->options['system']['currency'] ) ? '御中' : '';
477 $currency_post = ( 'JP' === $usces->options['system']['currency'] ) ? '-' : '';
478
479 if ( 'receipt' === $type ) {
480 $top = 40;
481
482 $company = usces_get_pdf_company( $data->order['ID'], 'customer' );
483 $company = apply_filters( 'usces_filter_pdf_customer_company', $company, $data->order['ID'] );
484 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_company'] );
485 $pdf->SetFont( $font, '', $fontsize );
486 $pdf->SetXY( $leftside, $top );
487
488 if ( empty( $company ) ) {
489 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( usces_get_pdf_name( $data ) ), 0, 'L' );
490 $x = $leftside + $width;
491 $y = $pdf->GetY() - $lineheight;
492 $pdf->SetXY( $x, $y );
493 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ) ) );
494 $y = $pdf->GetY() + $lineheight + $linetop + 1;
495 $pdf->SetLineWidth( 0.1 );
496 $pdf->Line( $leftside, $y, $leftside + $width + 7, $y );
497 } else {
498 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $company ), 0, 'L' );
499 $x = $leftside + $width;
500 $y = $pdf->GetY() - $lineheight;
501 $pdf->SetXY( $x, $y );
502 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor, $type, $data, 'customer' ) ) );
503 $y = $pdf->GetY() + $lineheight + $linetop;
504 $pdf->SetLineWidth( 0.1 );
505 $pdf->Line( $leftside, $y, $leftside + $width + 7, $y );
506 $y = $pdf->GetY() + $lineheight + $linetop + 1;
507 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_attn'] );
508 $pdf->SetFont( $font, '', $fontsize );
509 $pdf->SetXY( $leftside, $y );
510 $person = apply_filters( 'usces_filter_pdf_contact_person', __( 'Attn', 'usces' ) . ' : ' . usces_conv_euc( usces_get_pdf_name( $data ) ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ), $type, $company, $data->order['ID'] );
511 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $person ), 0, 'L' );
512 $y = $pdf->GetY() + $linetop + 1;
513 }
514
515 /* Total */
516 $y = $pdf->GetY() + $lineheight + 7;
517 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['total_price'] );
518 $pdf->SetFont( $font, '', $fontsize );
519 $pdf->SetXY( $leftside + 2, $y );
520 $pdf->MultiCell( $width, $lineheight + 2, usces_conv_euc( $usces->get_currency( $data->order['total_full_price'], true, false ) . apply_filters( 'usces_filters_pdf_currency_post', $currency_post ) ), 1, 'C' );
521
522 /* Message */
523 $y = $pdf->GetY() + $lineheight;
524 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['message'] );
525 $pdf->SetFont( $font, '', $fontsize );
526 $pdf->SetXY( $leftside, $y );
527 $pdf->MultiCell( $width + 70, $lineheight, usces_conv_euc( $message ), 0, 'L' );
528
529 /* Label */
530 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['statement_label'] );
531 $pdf->SetFont( $font, '', $fontsize );
532 $y = 89;
533 $pdf->SetXY( $leftside, $y );
534 $pdf->MultiCell( 75, $lineheight, usces_conv_euc( __( 'Statement', 'usces' ) ), 0, 'L' );
535
536 /* Payment method */
537 $pdf->SetXY( $leftside + 68, $y );
538 $pdf->Cell( 75, $lineheight, usces_conv_euc( $siharai ), 0, 1, 'L' );
539
540 } elseif ( 'nohin' === $type ) {
541 /* 「�
542 �送�
543 �を宛名とする」 */
544 if ( 1 === (int) $usces->options['system']['pdf_delivery'] ) {
545 $top = 30;
546
547 /* �
548 �送�
549 ��
550 報が揃っていない場合、購�
551 ��
552
553 報を表示 */
554 if ( 0 === strlen( $data->deliveri['name1'] ) || 0 === strlen( $data->deliveri['address1'] ) || 0 === strlen( $data->deliveri['address2'] ) ) {
555 $company = usces_get_pdf_company( $data->order['ID'], 'customer' );
556 $company = apply_filters( 'usces_filter_pdf_customer_company', $company, $data->order['ID'] );
557 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_company'] );
558 $pdf->SetFont( $font, '', $fontsize );
559 $pdf->SetXY( $leftside, $top );
560
561 if ( empty( $company ) ) {
562 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( usces_get_pdf_name( $data ) ), 0, 'L' );
563 $x = $leftside + $width;
564 $y = $pdf->GetY() - $lineheight;
565 $pdf->SetXY( $x, $y );
566 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ) ) );
567 $y = $pdf->GetY() + $lineheight + $linetop + 2;
568 } else {
569 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $company ), 0, 'L' );
570 $x = $leftside + $width;
571 $y = $pdf->GetY() - $lineheight;
572 $pdf->SetXY( $x, $y );
573 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor, $type, $data, 'customer' ) ) );
574 $y = $pdf->GetY() + $lineheight + $linetop;
575 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_attn'] );
576 $pdf->SetFont( $font, '', $fontsize );
577 $pdf->SetXY( $leftside, $y );
578 $person = apply_filters( 'usces_filter_pdf_contact_person', __( 'Attn', 'usces' ) . ' : ' . usces_conv_euc( usces_get_pdf_name( $data ) ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ), $type, $company, $data->order['ID'] );
579 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $person ), 0, 'L' );
580 $y = $pdf->GetY() + $linetop + 2;
581 }
582
583 /* Address */
584 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_address'] );
585 $pdf->SetFont( $font, '', $fontsize );
586
587 usces_get_pdf_address( $pdf, $data, $y, $linetop, $leftside, $width, $lineheight );
588
589 if ( ! empty( $data->customer['tel'] ) ) {
590 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'TEL ' . $data->customer['tel'] ), 0, 'L' );
591 }
592 if ( ! empty( $data->customer['fax'] ) ) {
593 $y = $pdf->GetY() + $linetop;
594 $pdf->SetXY( $leftside, $y );
595 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'FAX ' . $data->customer['fax'] ), 0, 'L' );
596 }
597
598 } else {
599 $delivery_company = usces_get_pdf_company( $data->order['ID'], 'delivery' );
600 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_company'] );
601 $pdf->SetFont( $font, '', $fontsize );
602 $pdf->SetXY( $leftside, $top );
603
604 if ( empty( $delivery_company ) ) {
605 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( usces_get_pdf_shipping_name( $data ) ), 0, 'L' );
606 $x = $leftside + $width;
607 $y = $pdf->GetY() - $lineheight;
608 $pdf->SetXY( $x, $y );
609 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'delivery' ) ) );
610 $y = $pdf->GetY() + $lineheight + $linetop + 2;
611 } else {
612 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $delivery_company ), 0, 'L' );
613 $x = $leftside + $width;
614 $y = $pdf->GetY() - $lineheight;
615 $pdf->SetXY( $x, $y );
616 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor, $type, $data, 'delivery' ) ) );
617 $y = $pdf->GetY() + $lineheight + $linetop;
618 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_attn'] );
619 $pdf->SetFont( $font, '', $fontsize );
620 $pdf->SetXY( $leftside, $y );
621 $person = apply_filters( 'usces_filter_pdf_contact_person', __( 'Attn', 'usces' ) . ' : ' . usces_conv_euc( usces_get_pdf_shipping_name( $data ) ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'delivery' ), $type, $delivery_company, $data->order['ID'] );
622 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $person ), 0, 'L' );
623 $y = $pdf->GetY() + $linetop + 2;
624 }
625
626 /* Address */
627 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_address'] );
628 $pdf->SetFont( $font, '', $fontsize );
629
630 usces_get_pdf_shipping_address( $pdf, $data, $y, $linetop, $leftside, $width, $lineheight );
631
632 if ( ! empty( $data->deliveri['tel'] ) ) {
633 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'TEL ' . $data->deliveri['tel'] ), 0, 'L' );
634 }
635 if ( ! empty( $data->deliveri['fax'] ) ) {
636 $y = $pdf->GetY() + $linetop;
637 $pdf->SetXY( $leftside, $y );
638 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'FAX ' . $data->deliveri['fax'] ), 0, 'L' );
639 }
640 }
641
642 /* 「購�
643 ��
644
645 報を宛名とする」 */
646 } else {
647 $top = 30;
648
649 $company = usces_get_pdf_company( $data->order['ID'], 'customer' );
650 $company = apply_filters( 'usces_filter_pdf_customer_company', $company, $data->order['ID'] );
651 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_company'] );
652 $pdf->SetFont( $font, '', $fontsize );
653 $pdf->SetXY( $leftside, $top );
654
655 if ( empty( $company ) ) {
656 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( usces_get_pdf_name( $data ) ), 0, 'L' );
657 $x = $leftside + $width;
658 $y = $pdf->GetY() - $lineheight;
659 $pdf->SetXY( $x, $y );
660 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ) ) );
661 $y = $pdf->GetY() + $lineheight + $linetop + 2;
662 } else {
663 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $company ), 0, 'L' );
664 $x = $leftside + $width;
665 $y = $pdf->GetY() - $lineheight;
666 $pdf->SetXY( $x, $y );
667 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor, $type, $data, 'customer' ) ) );
668 $y = $pdf->GetY() + $lineheight + $linetop;
669 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_attn'] );
670 $pdf->SetFont( $font, '', $fontsize );
671 $pdf->SetXY( $leftside, $y );
672 $person = apply_filters( 'usces_filter_pdf_contact_person', __( 'Attn', 'usces' ) . ' : ' . usces_conv_euc( usces_get_pdf_name( $data ) ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ), $type, $company, $data->order['ID'] );
673 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $person ), 0, 'L' );
674 $y = $pdf->GetY() + $linetop + 2;
675 }
676
677 /* Address */
678 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_address'] );
679 $pdf->SetFont( $font, '', $fontsize );
680
681 usces_get_pdf_address( $pdf, $data, $y, $linetop, $leftside, $width, $lineheight );
682
683 if ( ! empty( $data->customer['tel'] ) ) {
684 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'TEL ' . $data->customer['tel'] ), 0, 'L' );
685 }
686 if ( ! empty( $data->customer['fax'] ) ) {
687 $y = $pdf->GetY() + $linetop;
688 $pdf->SetXY( $leftside, $y );
689 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'FAX ' . $data->customer['fax'] ), 0, 'L' );
690 }
691
692 /* �
693 �送�
694 ��
695 */
696 $customer_name = trim( $data->customer['name1'] ) . trim( $data->customer['name2'] );
697 $deliveri_name = trim( $data->deliveri['name1'] ) . trim( $data->deliveri['name2'] );
698 $customer_zip = trim( $data->customer['zip'] );
699 $deliveri_zip = trim( $data->deliveri['zipcode'] );
700 $customer_address = trim( $data->customer['address1'] ) . trim( $data->customer['address2'] ) . trim( $data->customer['address3'] );
701 $deliveri_address = trim( $data->deliveri['address1'] ) . trim( $data->deliveri['address2'] ) . trim( $data->deliveri['address3'] );
702
703 /* 発送�
704 ��
705 報があるか */
706 if ( ! empty( $deliveri_address ) ) {
707 /* 購�
708 ��
709 と発送�
710 �の�
711 報が異なる */
712 if ( $customer_name != $deliveri_name || $customer_zip != $deliveri_zip || $customer_address != $deliveri_address ) {
713 /* Line */
714 $y = $pdf->GetY() + $linetop;
715 $pdf->SetLineWidth( 0.1 );
716 $pdf->Line( $leftside, $y, $leftside + $width + 5, $y );
717
718 /* 【�
719 �送�
720 �】タイトル */
721 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['delivery_label'] );
722 $y = $pdf->GetY() + $linetop + 1;
723 $pdf->SetFont( $font, '', $fontsize );
724 $pdf->SetXY( $leftside, $y );
725 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( __( '** A shipping address **', 'usces' ) ), 0, 'L' );
726
727 /* �
728 �送�
729 �宛名 */
730 $delivery_company = usces_get_pdf_company( $data->order['ID'], 'delivery' );
731 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['delivery_address'] );
732 $y = $pdf->GetY() + $linetop;
733 $pdf->SetFont( $font, '', $fontsize );
734 $pdf->SetXY( $leftside, $y );
735 if ( empty( $delivery_company ) ) {
736 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( usces_get_pdf_shipping_name( $data ) ), 0, 'L' );
737 $x = $leftside + $width;
738 $y = $pdf->GetY() - $lineheight - $linetop;
739 $pdf->SetXY( $x, $y );
740 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'delivery' ) ) ); // 様.
741 $y = $pdf->GetY() + $lineheight + $linetop;
742 } else {
743 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $delivery_company ), 0, 'L' );
744 $x = $leftside + $width;
745 $y = $pdf->GetY() - $lineheight;
746 $pdf->SetXY( $x, $y );
747 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor, $type, $data, 'delivery' ) ) ); // 御中.
748 $y = $pdf->GetY() + $lineheight + $linetop;
749 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['delivery_address'] );
750 $pdf->SetFont( $font, '', $fontsize );
751 $pdf->SetXY( $leftside, $y );
752 $person = apply_filters( 'usces_filter_pdf_contact_person', __( 'Attn', 'usces' ) . ' : ' . usces_conv_euc( usces_get_pdf_shipping_name( $data ) ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'delivery' ), $type, $delivery_company, $data->order['ID'] );
753 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $person ), 0, 'L' );
754 $y = $pdf->GetY() + $linetop;
755 }
756
757 /* �
758 �送�
759 �住所 */
760 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['delivery_address'] );
761 $pdf->SetFont( $font, '', $fontsize );
762 usces_get_pdf_shipping_address( $pdf, $data, $y, $linetop, $leftside, $width, $lineheight );
763
764 /* �
765 �送�
766 �電話番号 */
767 if ( ! empty( $data->deliveri['tel'] ) ) {
768 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'TEL ' . $data->deliveri['tel'] ), 0, 'L' );
769 }
770 }
771 }
772 }
773 $y = $pdf->GetY() + $linetop + 0.5;
774
775 $pdf->SetLineWidth( 0.1 );
776 $pdf->Line( $leftside, $y, $leftside + $width + 5, $y );
777
778 /* Message */
779 $y = 80;
780 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['message'] );
781 $pdf->SetFont( $font, '', $fontsize );
782 $pdf->SetXY( $leftside, $y );
783 $pdf->MultiCell( $width + 70, $lineheight, usces_conv_euc( $message ), 0, 'L' );
784
785 /* Order date */
786 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['order_date'] );
787 $pdf->SetFont( $font, '', $fontsize );
788 $y = 89;
789 $pdf->SetXY( $leftside, $y );
790 $pdf->MultiCell( 75, $lineheight, usces_conv_euc( $juchubi ), 0, 'L' );
791
792 /* Payment method */
793 $pdf->SetXY( $leftside + 68, $y );
794 $pdf->Cell( 75, $lineheight, usces_conv_euc( $siharai ), 0, 1, 'L' );
795
796 } else {
797 $top = 30;
798
799 $company = usces_get_pdf_company( $data->order['ID'], 'customer' );
800 $company = apply_filters( 'usces_filter_pdf_customer_company', $company, $data->order['ID'] );
801 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_company'] );
802 $pdf->SetFont( $font, '', $fontsize );
803 $pdf->SetXY( $leftside, $top );
804
805 if ( empty( $company ) ) {
806 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( usces_get_pdf_name( $data ) ), 0, 'L' );
807 $x = $leftside + $width;
808 $y = $pdf->GetY() - $lineheight;
809 $pdf->SetXY( $x, $y );
810 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ) ) );
811 $y = $pdf->GetY() + $lineheight + $linetop + 2;
812 } else {
813 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $company ), 0, 'L' );
814 $x = $leftside + $width;
815 $y = $pdf->GetY() - $lineheight;
816 $pdf->SetXY( $x, $y );
817 $pdf->Write( $lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor, $type, $data, 'customer' ) ) );
818 $y = $pdf->GetY() + $lineheight + $linetop;
819 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_attn'] );
820 $pdf->SetFont( $font, '', $fontsize );
821 $pdf->SetXY( $leftside, $y );
822 $person = apply_filters( 'usces_filter_pdf_contact_person', __( 'Attn', 'usces' ) . ' : ' . usces_conv_euc( usces_get_pdf_name( $data ) ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor, $type, $data, 'customer' ), $type, $company, $data->order['ID'] );
823 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $person ), 0, 'L' );
824 $y = $pdf->GetY() + $linetop + 2;
825 }
826
827 /* Address */
828 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['customer_address'] );
829 $pdf->SetFont( $font, '', $fontsize );
830
831 usces_get_pdf_address( $pdf, $data, $y, $linetop, $leftside, $width, $lineheight );
832
833 if ( ! empty( $data->customer['tel'] ) ) {
834 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'TEL ' . $data->customer['tel'] ), 0, 'L' );
835 }
836 if ( ! empty( $data->customer['fax'] ) ) {
837 $y = $pdf->GetY() + $linetop;
838 $pdf->SetXY( $leftside, $y );
839 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( 'FAX ' . $data->customer['fax'] ), 0, 'L' );
840 }
841 $y = $pdf->GetY() + $linetop + 0.5;
842
843 $pdf->SetLineWidth( 0.1 );
844 $pdf->Line( $leftside, $y, $leftside + $width + 5, $y );
845
846 /* Message */
847 $y = 80;
848 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['message'] );
849 $pdf->SetFont( $font, '', $fontsize );
850 $pdf->SetXY( $leftside, $y );
851 $pdf->MultiCell( $width + 70, $lineheight, usces_conv_euc( $message ), 0, 'L' );
852
853 /* Order date */
854 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['order_date'] );
855 $pdf->SetFont( $font, '', $fontsize );
856 $y = 89;
857 $pdf->SetXY( $leftside, $y );
858 $pdf->MultiCell( 75, $lineheight, usces_conv_euc( $juchubi ), 0, 'L' );
859
860 /* Payment method */
861 $pdf->SetXY( $leftside + 68, $y );
862 $pdf->Cell( 75, $lineheight, usces_conv_euc( $siharai ), 0, 1, 'L' );
863 }
864
865 /* Free note */
866 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['order_date'] );
867 $pdf->SetFont( $font, '', $fontsize );
868 $y = 85;
869 $pdf->SetXY( $leftside, $y );
870 $pdf->MultiCell( 150, $lineheight, usces_conv_euc( $free_note ), 0, 'L' );
871
872 /* My company */
873 if ( ! empty( $sign_image ) ) {
874 $sign_data = apply_filters( 'usces_filter_pdf_sign_data', array( 140, 40, 25, 25 ) );
875 $pdf->Image( $sign_image, $sign_data[0], $sign_data[1], $sign_data[2], $sign_data[3] );
876 }
877 $x = 110;
878 $y = 45;
879 $pdf->SetLeftMargin( $x );
880 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['publisher'] );
881 $pdf->SetFont( $font, '', $fontsize );
882 $pdf->SetXY( $x, $y );
883 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_publisher', html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ) ) ), 0, 'L' );
884 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['company_name'] );
885 $pdf->SetFont( $font, '', $fontsize );
886 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_pdf_mycompany', $usces->options['company_name'] ) ), 0, 'L' );
887 usces_get_pdf_myaddress( $pdf, $lineheight );
888 if ( ! empty( $usces->options['tel_number'] ) ) {
889 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_pdf_mycompany_tel', 'TEL: ' . $usces->options['tel_number'] ) ), 0, 'L' );
890 }
891 if ( ! empty( $usces->options['fax_number'] ) ) {
892 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_pdf_mycompany_fax', 'FAX: ' . $usces->options['fax_number'] ) ), 0, 'L' );
893 }
894 if ( ! empty( $usces->options['business_registration_number'] ) ) {
895 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_pdf_business_registration_number', __( 'Business registration number', 'usces' ) . ': ' . $usces->options['business_registration_number'] ) ), 0, 'L' );
896 }
897
898 do_action( 'usces_action_pdf_header', $pdf, $data, $font );
899
900 /* Body label */
901 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['details_label'] );
902 $pdf->SetFont( $font, '', $fontsize );
903 $pdf->SetXY( 15.5, 94.9 );
904 $pdf->MultiCell( 87.8, $lineheight, usces_conv_euc( __( 'item name', 'usces' ) ), 0, 'C' );
905 $pdf->SetXY( 103.7, 94.9 );
906 $pdf->MultiCell( 11.4, $lineheight, usces_conv_euc( __( 'Quant', 'usces' ) ), 0, 'C' );
907 $pdf->SetXY( 115.8, 94.9 );
908 $pdf->MultiCell( 11.0, $lineheight, usces_conv_euc( __( 'Unit', 'usces' ) ), 0, 'C' );
909 $pdf->SetXY( 127.2, 94.9 );
910 $pdf->MultiCell( 15.0, $lineheight, usces_conv_euc( __( 'Price', 'usces' ) ), 0, 'C' );
911 $pdf->SetXY( 142.9, 94.9 );
912 $pdf->MultiCell( 22.4, $lineheight, usces_conv_euc( __( 'Amount', 'usces' ) . '(' . __( usces_crcode( 'return' ), 'usces' ) . ')' ), 0, 'C' );
913
914 /* Horizontal lines */
915 $pdf->SetLineWidth( 0.5 );
916 $pdf->Line( 15.4, 100, 165.5, 100 );
917 }
918
919 /**
920 * Detail
921 *
922 * @param object $pdf TCPDF.
923 * @param object $data Order data.
924 * @param int $page Page no.
925 * @param object $font Font.
926 * @param float $x X axis.
927 * @param float $y Y axis.
928 * @param float $onep Page height.
929 * @param float $next_y Next Y axis.
930 * @param array $border Border.
931 * @param int $index Index.
932 * @param array $cart Cart data.
933 * @param array $cart_row Cart data.
934 * @param array $fontsizes Font size.
935 * @param string $mark Reduced taxrate mark.
936 */
937 function usces_pdfSetDetail( $pdf, $data, $page, $font, $x, $y, $onep, $next_y, $border, $index, $cart, $cart_row, $fontsizes, $mark = '' ) {
938 global $usces;
939
940 $type = ( isset( $_REQUEST['type'] ) ) ? wp_unslash( $_REQUEST['type'] ) : '';
941 $post_id = $cart_row['post_id'];
942 $sku = urldecode( $cart_row['sku'] );
943 $cart_item_name = $usces->getCartItemName_byOrder( $cart_row );
944 $optstr = '';
945 if ( isset( $cart_row['options'] ) && is_array( $cart_row['options'] ) && count( $cart_row['options'] ) > 0 ) {
946 foreach ( $cart_row['options'] as $key => $value ) {
947 if ( ! empty( $key ) ) {
948 $key = urldecode( $key );
949 $value = wel_safe_maybe_unserialize( $value );
950 if ( is_array( $value ) ) {
951 $c = '';
952 $optstr .= $key . ' = ';
953 foreach ( $value as $v ) {
954 $optstr .= $c . rawurldecode( $v );
955 $c = ', ';
956 }
957 $optstr .= "\n";
958 } else {
959 $optstr .= $key . ' = ' . rawurldecode( $value ) . "\n";
960 }
961 }
962 }
963 $optstr = apply_filters( 'usces_filter_option_pdf', $optstr, $cart_row['options'] );
964 }
965 $optstr = apply_filters( 'usces_filter_all_option_pdf', $optstr, $cart_row['options'], $post_id, $sku, $cart_row['advance'], $cart_row );
966
967 $output_options = ( 'receipt' === $type ) ? apply_filters( 'usces_filter_pdf_output_options_receipt', true, $data ) : true;
968
969 $args = compact( 'cart', 'cart_row', 'post_id', 'sku', 'index' );
970 $fontsizes = apply_filters( 'useces_filter_order_pdfbody_fontsize', $fontsizes, $args, $data );
971 $fontsizes = apply_filters( 'usces_filter_pdf_body_fontsize', $fontsizes, $args, $data ); // alias.
972
973 $line_y = $next_y;
974
975 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['item_name'] );
976 $pdf->SetFont( $font, '', $fontsize );
977 $pdf->SetXY( $x - 0.2, $line_y );
978 $pdf->MultiCell( 4, $lineheight, '*', 0, 'C' );
979 $pdf->SetXY( $x + 3.0, $line_y );
980 $pdf->MultiCell( 84.6, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_cart_item_name_nl', $cart_item_name . $mark, $args ) ), 0, 'L' );
981
982 if ( ! empty( $optstr ) && $output_options ) {
983 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['details'] );
984 $pdf->SetFont( $font, '', $fontsize );
985 $pdf->SetXY( $x + 6.0, $pdf->GetY() + $linetop );
986 $pdf->MultiCell( 81.6, $lineheight - 0.2, usces_conv_euc( $optstr ), 0, 'L' );
987 }
988
989 $pdf_args = compact( 'page', 'x', 'y', 'onep', 'next_y', 'border', 'index', 'cart_row', 'fontsizes', 'lineheight', 'linetop', 'font' );
990 do_action( 'usces_action_order_print_cart_row', $pdf, $data, $pdf_args );
991 $next_y = $pdf->GetY() + 2;
992
993 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['quantity'] );
994 $pdf->SetFont( $font, '', $fontsize );
995 $pdf->SetXY( $x + 88.0, $line_y );
996 $pdf->MultiCell( 11.5, $lineheight, usces_conv_euc( $cart_row['quantity'] ), 0, 'R' );
997 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['unit'] );
998 $pdf->SetFont( $font, '', $fontsize );
999 $pdf->SetXY( $x + 99.6, $line_y );
1000 $pdf->MultiCell( 11.5, $lineheight, usces_conv_euc( $usces->getItemSkuUnit( $post_id, $sku ) ), 0, 'C' );
1001 $pdf->SetXY( $x + 111.5, $line_y );
1002 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['unitprice'] );
1003 $pdf->SetFont( $font, '', $fontsize );
1004 $pdf->MultiCell( 15.2, $lineheight, apply_filters( 'usces_filter_cart_row_unitprice_pdf', usces_conv_euc( $usces->get_currency( $cart_row['price'] ) ), $cart_row ), 0, 'R' );
1005 $pdf->SetXY( $x + 126.9, $line_y );
1006 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['row_price'] );
1007 $pdf->SetFont( $font, '', $fontsize );
1008 $pdf->MultiCell( 22.8, $lineheight, apply_filters( 'usces_filter_cart_row_price_pdf', usces_conv_euc( $usces->get_currency( $cart_row['price'] * $cart_row['quantity'] ) ), $cart_row ), 0, 'R' );
1009
1010 $pdf->SetXY( $x, $next_y );
1011 return $next_y;
1012 }
1013
1014 /**
1015 * Footer
1016 *
1017 * @param object $pdf TCPDF.
1018 * @param object $data Order data.
1019 * @param object $font Font.
1020 * @param object $usces_tax Tax.
1021 */
1022 function usces_pdfSetFooter( $pdf, $data, $font, $usces_tax ) {
1023 global $usces;
1024
1025 $type = ( isset( $_REQUEST['type'] ) ) ? wp_unslash( $_REQUEST['type'] ) : '';
1026 $condition = $data->condition;
1027 $tax_display = ( isset( $condition['tax_display'] ) ) ? $condition['tax_display'] : usces_get_tax_display();
1028 $tax_target = ( isset( $condition['tax_target'] ) ) ? $condition['tax_target'] : $usces->options['tax_target'];
1029 $tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : $usces->options['tax_mode'];
1030 $member_system = ( isset( $condition['membersystem_state'] ) ) ? $condition['membersystem_state'] : $usces->options['membersystem_state'];
1031 $member_system_point = ( isset( $condition['membersystem_point'] ) ) ? $condition['membersystem_point'] : $usces->options['membersystem_point'];
1032 $point_coverage = ( isset( $condition['point_coverage'] ) ) ? $condition['point_coverage'] : $usces->options['point_coverage'];
1033
1034 $fontsizes = array(
1035 'footer_label' => 9,
1036 'footer_value' => 8,
1037 'footer_note' => 8,
1038 );
1039 $fontsizes = apply_filters( 'useces_filter_order_pdffooter_fontsize', $fontsizes, $data );
1040 $fontsizes = apply_filters( 'usces_filter_pdf_footer_fontsize', $fontsizes, $data ); // alias.
1041
1042 $y = $pdf->GetY() + 2;
1043
1044 $label_data = array();
1045 $value_data = array();
1046 $cart = usces_get_ordercartdata( $data->order['ID'] );
1047 $cart = apply_filters( 'usces_filter_pdf_cart_data', $cart, $data->order['ID'] );
1048 $shipped = usces_have_shipped( $cart );
1049
1050 $pdf->Rect( 14, 197.8, 153, 45, 'F' ); // Footer field.
1051
1052 $label_data[] = apply_filters( 'usces_filter_pdf_item_total_price_label', __( 'total items', 'usces' ) );
1053 $value_data[] = apply_filters( 'usces_filter_pdf_item_total_price_value', $usces->get_currency( $data->order['item_total_price'] ) );
1054 $label_data[] = apply_filters( 'usces_filter_pdf_discount_label', apply_filters( 'usces_filter_disnount_label', __( 'Campaign discount', 'usces' ), $data ), $data );
1055 $value_data[] = apply_filters( 'usces_filter_pdf_discount_value', apply_filters( 'usces_filter_disnount_vlue', $usces->get_currency( $data->order['discount'] ) ) );
1056
1057 if ( 'activate' === $tax_display ) {
1058 if ( 'include' === $tax_mode ) {
1059 $include_tax_standard = '(' . usces_crform( $usces_tax->tax_standard, false, false, 'return', true ) . ')';
1060 $include_tax_reduced = '(' . usces_crform( $usces_tax->tax_reduced, false, false, 'return', true ) . ')';
1061 $tax = '(' . $usces->get_currency( $usces_tax->tax_standard + $usces_tax->tax_reduced ) . ')';
1062 } else {
1063 $tax = $usces->get_currency( $data->order['tax'] );
1064 }
1065
1066 $labeldata = array(
1067 'order_condition' => $data->condition,
1068 'order_item_total_price' => $data->order['item_total_price'],
1069 'order_discount' => $data->order['discount'],
1070 'order_shipping_charge' => $data->order['shipping_charge'],
1071 'order_cod_fee' => $data->order['cod_fee'],
1072 );
1073
1074 if ( 'activate' === $member_system && 'activate' === $member_system_point ) {
1075 if ( 1 === (int) $point_coverage ) {
1076 if ( 'products' === $tax_target ) {
1077 $label_data[] = apply_filters( 'usces_filter_pdf_tax_label', usces_tax_label( $labeldata, 'return' ) );
1078 $value_data[] = apply_filters( 'usces_filter_pdf_tax_value', apply_filters( 'usces_filter_tax_vlue', $tax, $data ), $data );
1079 if ( $shipped ) {
1080 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1081 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1082 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1083 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1084 }
1085 } else {
1086 if ( $shipped ) {
1087 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1088 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1089 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1090 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1091 }
1092 $label_data[] = apply_filters( 'usces_filter_pdf_tax_label', usces_tax_label( $labeldata, 'return' ) );
1093 $value_data[] = apply_filters( 'usces_filter_pdf_tax_value', apply_filters( 'usces_filter_tax_vlue', $tax, $data ), $data );
1094 }
1095 $label_data[] = apply_filters( 'usces_filter_pdf_point_label', apply_filters( 'usces_filter_point_label', __( 'Used points', 'usces' ) ) );
1096 $value_data[] = apply_filters( 'usces_filter_pdf_point_value', apply_filters( 'usces_filter_point_vlue', $usces->get_currency( $data->order['usedpoint'] ) ), $data );
1097 } else {
1098 if ( 'products' === $tax_target ) {
1099 $label_data[] = apply_filters( 'usces_filter_pdf_tax_label', usces_tax_label( $labeldata, 'return' ) );
1100 $value_data[] = apply_filters( 'usces_filter_pdf_tax_value', apply_filters( 'usces_filter_tax_vlue', $tax, $data ), $data );
1101 $label_data[] = apply_filters( 'usces_filter_pdf_point_label', apply_filters( 'usces_filter_point_label', __( 'Used points', 'usces' ) ) );
1102 $value_data[] = apply_filters( 'usces_filter_pdf_point_value', apply_filters( 'usces_filter_point_vlue', $usces->get_currency( $data->order['usedpoint'] ) ), $data );
1103 if ( $shipped ) {
1104 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1105 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1106 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1107 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1108 }
1109 } else {
1110 $label_data[] = apply_filters( 'usces_filter_pdf_point_label', apply_filters( 'usces_filter_point_label', __( 'Used points', 'usces' ) ) );
1111 $value_data[] = apply_filters( 'usces_filter_pdf_point_value', apply_filters( 'usces_filter_point_vlue', $usces->get_currency( $data->order['usedpoint'] ) ), $data );
1112 if ( $shipped ) {
1113 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1114 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1115 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1116 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1117 }
1118 $label_data[] = apply_filters( 'usces_filter_pdf_tax_label', usces_tax_label( $labeldata, 'return' ) );
1119 $value_data[] = apply_filters( 'usces_filter_pdf_tax_value', apply_filters( 'usces_filter_tax_vlue', $tax, $data ), $data );
1120 }
1121 }
1122 } else {
1123 if ( 'products' === $tax_target ) {
1124 $label_data[] = apply_filters( 'usces_filter_pdf_tax_label', usces_tax_label( $labeldata, 'return' ) );
1125 $value_data[] = apply_filters( 'usces_filter_pdf_tax_value', apply_filters( 'usces_filter_tax_vlue', $tax, $data ), $data );
1126 if ( $shipped ) {
1127 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1128 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1129 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1130 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1131 }
1132 } else {
1133 if ( $shipped ) {
1134 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1135 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1136 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1137 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1138 }
1139 $label_data[] = apply_filters( 'usces_filter_pdf_tax_label', usces_tax_label( $labeldata, 'return' ) );
1140 $value_data[] = apply_filters( 'usces_filter_pdf_tax_value', apply_filters( 'usces_filter_tax_vlue', $tax, $data ), $data );
1141 }
1142 }
1143 } else {
1144 if ( 'activate' === $member_system && 'activate' === $member_system_point ) {
1145 if ( 1 === (int) $point_coverage ) {
1146 if ( $shipped ) {
1147 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1148 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1149 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1150 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1151 }
1152 $label_data[] = apply_filters( 'usces_filter_pdf_point_label', apply_filters( 'usces_filter_point_label', __( 'Used points', 'usces' ) ) );
1153 $value_data[] = apply_filters( 'usces_filter_pdf_point_value', apply_filters( 'usces_filter_point_vlue', $usces->get_currency( $data->order['usedpoint'] ) ), $data );
1154 } else {
1155 $label_data[] = apply_filters( 'usces_filter_pdf_point_label', apply_filters( 'usces_filter_point_label', __( 'Used points', 'usces' ) ) );
1156 $value_data[] = apply_filters( 'usces_filter_pdf_point_value', apply_filters( 'usces_filter_point_vlue', $usces->get_currency( $data->order['usedpoint'] ) ), $data );
1157 if ( $shipped ) {
1158 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1159 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1160 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1161 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1162 }
1163 }
1164 } else {
1165 if ( $shipped ) {
1166 $label_data[] = apply_filters( 'usces_filter_pdf_shipping_label', apply_filters( 'usces_filter_shipping_label', __( 'Shipping', 'usces' ) ) );
1167 $value_data[] = apply_filters( 'usces_filter_pdf_shipping_value', apply_filters( 'usces_filter_shipping_vlue', $usces->get_currency( $data->order['shipping_charge'] ) ), $data );
1168 $label_data[] = apply_filters( 'usces_filter_pdf_cod_label', apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $data->order['ID'] ), $data );
1169 $value_data[] = apply_filters( 'usces_filter_pdf_cod_value', apply_filters( 'usces_filter_cod_vlue', $usces->get_currency( $data->order['cod_fee'] ) ), $data );
1170 }
1171 }
1172 }
1173
1174 $payment = $usces->getPayments( $data->order['payment_name'] );
1175 $transfers = apply_filters( 'usces_filter_pdf_transfer', array( 'transferAdvance', 'transferDeferred' ), $data );
1176 $note_text = '';
1177 if ( 'bill' === $type && in_array( $payment['settlement'], $transfers ) ) {
1178 $transferee = '';
1179 if ( ! empty( $usces->options['transferee'] ) ) {
1180 $transferee = __( 'Transfer', 'usces' ) . " : \r\n";
1181 $transferee .= $usces->options['transferee'] . "\r\n";
1182 }
1183 $note_text = apply_filters( 'usces_filter_mail_transferee', $transferee, $payment );
1184 } else {
1185 if ( ! empty( $data->order['note'] ) ) {
1186 if ( false === strpos( $data->order['note'], "\r\n" ) ) {
1187 $note_text = mb_substr( $data->order['note'], 0, 360, 'UTF-8' );
1188 } else {
1189 $line = 0;
1190 $note_line = explode( "\r\n", $data->order['note'] );
1191 foreach ( $note_line as $note ) {
1192 $len = mb_strlen( $note, 'UTF-8' );
1193 $cnt = ceil( $len / 30 );
1194 if ( 0 === $cnt ) {
1195 $cnt = 1;
1196 }
1197 if ( 12 >= $line + $cnt ) {
1198 $note_text .= $note . "\r\n";
1199 } else {
1200 $more = 12 - $line;
1201 $note_text .= mb_substr( $note, 0, $more * 30, 'UTF-8' ) . "\r\n";
1202 }
1203 $line += $cnt;
1204 if ( 12 < $line ) {
1205 break;
1206 }
1207 }
1208 }
1209 }
1210 }
1211 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['footer_note'] );
1212 $pdf->SetFont( $font, '', $fontsize );
1213 $line_y = $y;
1214 $pdf->SetXY( 16, $line_y );
1215 $pdf->MultiCell( 86.8, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_pdf_note', $note_text, $data, $type ) ), 0, 'J' );
1216
1217 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['footer_label'] );
1218 $pdf->SetFont( $font, '', $fontsize );
1219 $label_data = apply_filters( 'usces_filter_pdf_footer_label', $label_data, $data );
1220 $line_y = $y;
1221 foreach ( $label_data as $label ) {
1222 $pdf->SetXY( 104.3, $line_y );
1223 $pdf->MultiCell( 37.7, $lineheight, usces_conv_euc( $label ), 0, 'C' );
1224 $line_y += 6;
1225 }
1226 $line_y += 0.6;
1227 $pdf->SetXY( 104.3, $line_y );
1228 $pdf->MultiCell( 37.77, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_pdf_total_full_price_label', __( 'Total Amount', 'usces' ) ) ), 0, 'C' );
1229
1230 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['footer_label'] );
1231 $pdf->SetFont( $font, '', $fontsize );
1232 $value_data = apply_filters( 'usces_filter_pdf_footer_value', $value_data, $data );
1233 $line_y = $y;
1234 foreach ( $value_data as $value ) {
1235 $pdf->SetXY( 142.9, $line_y );
1236 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $value ), 0, 'R' );
1237 $line_y += 6;
1238 }
1239 $line_y += 0.6;
1240 $pdf->SetXY( 142.9, $line_y );
1241 $pdf->MultiCell( 22.67, $lineheight, usces_conv_euc( apply_filters( 'usces_filter_pdf_total_full_price_value', apply_filters( 'usces_filter_total_full_price_value', $usces->get_currency( $data->order['total_full_price'] ) ), $data ) ), 0, 'R' );
1242
1243 /* Horizontal lines */
1244 $line_left = 15.4;
1245 $line_right = $line_left + 150.1;
1246
1247 $line_y = $y - 1;
1248 $pdf->SetLineWidth( 0.5 );
1249 $pdf->Line( $line_left, $line_y, $line_right, $line_y );
1250 $pdf->SetLineWidth( 0.04 );
1251 $line_count = count( $value_data );
1252 for ( $l = 0; $l < $line_count; $l++ ) {
1253 $pdf->Line( 103.5, $line_y, $line_right, $line_y );
1254 $line_y += 6;
1255 }
1256 $pdf->SetLineWidth( 0.5 );
1257 // $line_y += 6;
1258 $pdf->Line( 103.5, $line_y, $line_right, $line_y );
1259 $line_y += 7.2;
1260 $pdf->Line( 103.5, $line_y, $line_right, $line_y );
1261 // $pdf->Line( 15.4, $line_y, $line_right, $line_y );
1262
1263 $reduced_output_even_empty = apply_filters( 'usces_filter_pdf_reduced_output_even_empty', false, $usces_tax, $type, $tax_mode );
1264
1265 if ( 'activate' === $tax_display && 'all' === $tax_target ) {
1266 $line_y += 1;
1267 if ( 'include' === $tax_mode ) {
1268 $po = '(';
1269 $pc = ')';
1270 } else {
1271 $po = '';
1272 $pc = '';
1273 }
1274 $pdf->SetXY( 53, $line_y );
1275 $pdf->MultiCell( 5, $lineheight, usces_conv_euc( '(' ), 0, 'C' );
1276 $pdf->SetXY( 44.3, $line_y );
1277 $pdf->MultiCell( 40.7, $lineheight, usces_conv_euc( sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) ), 0, 'C' );
1278 $pdf->SetXY( 82.9, $line_y );
1279 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $usces->get_currency( $usces_tax->subtotal_standard + $usces_tax->discount_standard ) ), 0, 'R' );
1280 $pdf->SetXY( 104.3, $line_y );
1281 $standard_tax_label = apply_filters( 'usces_filter_pdf_standard_tax_label', sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ), $usces_tax, $type, $tax_mode );
1282 $pdf->MultiCell( 40.7, $lineheight, usces_conv_euc( $standard_tax_label ), 0, 'C' );
1283 $pdf->SetXY( 142.9, $line_y );
1284 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $po . $usces->get_currency( $usces_tax->tax_standard ) . $pc ), 0, 'R' );
1285 $pdf->SetXY( 163.5, $line_y );
1286 $pdf->MultiCell( 5, $lineheight, usces_conv_euc( ')' ), 0, 'C' );
1287 if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) {
1288 $line_y += 5.2;
1289 $pdf->SetXY( 53, $line_y );
1290 $pdf->MultiCell( 5, $lineheight, usces_conv_euc( '(' ), 0, 'C' );
1291 $pdf->SetXY( 44.3, $line_y );
1292 $reduced_applies_label = apply_filters( 'usces_filter_pdf_reduced_applies_label', sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ), $usces_tax, $type, $tax_mode );
1293 $pdf->MultiCell( 40.7, $lineheight, usces_conv_euc( $reduced_applies_label ), 0, 'C' );
1294 $pdf->SetXY( 82.9, $line_y );
1295 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $usces->get_currency( $usces_tax->subtotal_reduced + $usces_tax->discount_reduced ) ), 0, 'R' );
1296 $pdf->SetXY( 104.3, $line_y );
1297 $reduced_tax_label = apply_filters( 'usces_filter_pdf_reduced_tax_label', sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ), $usces_tax, $type, $tax_mode );
1298 $pdf->MultiCell( 40.7, $lineheight, usces_conv_euc( $reduced_tax_label ), 0, 'C' );
1299 $pdf->SetXY( 142.9, $line_y );
1300 $pdf->MultiCell( 22.6, $lineheight, usces_conv_euc( $po . $usces->get_currency( $usces_tax->tax_reduced ) . $pc ), 0, 'R' );
1301 $pdf->SetXY( 163.5, $line_y );
1302 $pdf->MultiCell( 5, $lineheight, usces_conv_euc( ')' ), 0, 'C' );
1303 }
1304 $line_y += 3.2;
1305 }
1306
1307 if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) {
1308 $line_y += 1;
1309 list( $fontsize, $lineheight, $linetop ) = usces_set_font_size( $fontsizes['footer_note'] );
1310 $pdf->SetFont( $font, '', $fontsize );
1311 $pdf->SetXY( 125.5, $line_y );
1312 $reduced_comment_label = apply_filters( 'usces_filter_pdf_reduced_comment_label', $usces_tax->reduced_taxrate_mark . __( ' is reduced tax rate', 'usces' ), $usces_tax, $type, $tax_mode );
1313 $pdf->MultiCell( 40, $lineheight, usces_conv_euc( $reduced_comment_label ), 0, 'R' );
1314 }
1315
1316 do_action( 'usces_action_order_print_footer', $pdf, $data, 'end' );
1317 do_action( 'usces_action_pdf_footer', $pdf, $data, $font, 'end' );
1318 }
1319
1320 /**
1321 * Set font size
1322 *
1323 * @param float $size Font size.
1324 * @return array
1325 */
1326 function usces_set_font_size( $size ) {
1327 $lineheight = $size / 2.6;
1328 $linetop = $lineheight / 12;
1329 return array( $size, $lineheight, $linetop );
1330 }
1331
1332 /**
1333 * Customer name
1334 *
1335 * @param object $data Order data.
1336 * @return string
1337 */
1338 function usces_get_pdf_name( $data ) {
1339 $options = get_option( 'usces' );
1340 $applyform = usces_get_apply_addressform( $options['system']['addressform'] );
1341 $name = '';
1342
1343 switch ( $applyform ) {
1344 case 'JP':
1345 $name = $data->customer['name1'] . ' ' . $data->customer['name2'];
1346 break;
1347 case 'US':
1348 default:
1349 $name = $data->customer['name2'] . ' ' . $data->customer['name1'];
1350 }
1351 $name = apply_filters( 'usces_filter_pdf_customer_name', $name, $data );
1352 return $name;
1353 }
1354
1355 /**
1356 * Shipping name
1357 *
1358 * @param object $data Order data.
1359 * @return string
1360 */
1361 function usces_get_pdf_shipping_name( $data ) {
1362 $options = get_option( 'usces' );
1363 $applyform = usces_get_apply_addressform( $options['system']['addressform'] );
1364 $name = '';
1365
1366 switch ( $applyform ) {
1367 case 'JP':
1368 $name = $data->deliveri['name1'] . ' ' . $data->deliveri['name2'];
1369 break;
1370 case 'US':
1371 default:
1372 $name = $data->deliveri['name2'] . ' ' . $data->deliveri['name1'];
1373 }
1374 $name = apply_filters( 'usces_filter_pdf_shipping_name', $name, $data );
1375 return $name;
1376 }
1377
1378 /**
1379 * Customer address
1380 *
1381 * @param object $pdf TCPDF.
1382 * @param object $data Order data.
1383 * @param float $y Y axis.
1384 * @param float $linetop Line top.
1385 * @param float $leftside Left side.
1386 * @param float $width Width.
1387 * @param float $lineheight Line height.
1388 */
1389 function usces_get_pdf_address( $pdf, $data, $y, $linetop, $leftside, $width, $lineheight ) {
1390 $options = get_option( 'usces' );
1391 $applyform = usces_get_apply_addressform( $options['system']['addressform'] );
1392 $name = '';
1393 $pref = ( __( '-- Select --', 'usces' ) == $data->customer['pref'] || '-- Select --' == $data->customer['pref'] ) ? '' : $data->customer['pref'];
1394
1395 switch ( $applyform ) {
1396 case 'JP':
1397 $pdf->SetXY( $leftside, $y );
1398 if ( ! empty( $data->customer['zip'] ) ) {
1399 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( __( 'zip code', 'usces' ) . ' ' . $data->customer['zip'] ), 0, 'L' );
1400 }
1401 if ( ! empty( $pref ) || ! empty( $data->customer['address1'] ) || ! empty( $data->customer['address2'] ) || ! empty( $data->customer['address3'] ) ) {
1402 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $pref . $data->customer['address1'] . $data->customer['address2'] ) . ' ' . $data->customer['address3'], 0, 'L' );
1403 }
1404 break;
1405 case 'US':
1406 default:
1407 $pdf->SetXY( $leftside, $y );
1408 if ( ! empty( $pref ) || ! empty( $data->customer['address1'] ) || ! empty( $data->customer['address2'] ) || ! empty( $data->customer['address3'] ) ) {
1409 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $data->customer['address2'] . ' ' . $data->customer['address3'] . ' ' . $data->customer['address1'] . ' ' . $pref . ' ' . $data->customer['country'] ), 0, 'L' );
1410 }
1411 $y = $pdf->GetY() + $linetop;
1412 $pdf->SetXY( $leftside, $y );
1413 if ( ! empty( $data->customer['zip'] ) ) {
1414 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( __( 'zip code', 'usces' ) . ' ' . $data->customer['zip'] ), 0, 'L' );
1415 }
1416 break;
1417 }
1418 }
1419
1420 /**
1421 * Shipping address
1422 *
1423 * @param object $pdf TCPDF.
1424 * @param object $data Order data.
1425 * @param float $y Y axis.
1426 * @param float $linetop Line top.
1427 * @param float $leftside Left side.
1428 * @param float $width Width.
1429 * @param float $lineheight Line height.
1430 */
1431 function usces_get_pdf_shipping_address( $pdf, $data, $y, $linetop, $leftside, $width, $lineheight ) {
1432 $options = get_option( 'usces' );
1433 $applyform = usces_get_apply_addressform( $options['system']['addressform'] );
1434 $name = '';
1435 $pref = ( __( '-- Select --', 'usces' ) == $data->deliveri['pref'] || '-- Select --' == $data->deliveri['pref'] ) ? '' : $data->deliveri['pref'];
1436
1437 switch ( $applyform ) {
1438 case 'JP':
1439 $pdf->SetXY( $leftside, $y );
1440 if ( ! empty( $data->deliveri['zipcode'] ) ) {
1441 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( __( 'zip code', 'usces' ) . ' ' . $data->deliveri['zipcode'] ), 0, 'L' );
1442 }
1443 if ( ! empty( $pref ) || ! empty( $data->deliveri['address1'] ) || ! empty( $data->deliveri['address2'] ) || ! empty( $data->deliveri['address3'] ) ) {
1444 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $pref . $data->deliveri['address1'] . $data->deliveri['address2'] . ' ' . $data->deliveri['address3'] ), 0, 'L' );
1445 }
1446 break;
1447 case 'US':
1448 default:
1449 $pdf->SetXY( $leftside, $y );
1450 if ( ! empty( $pref ) || ! empty( $data->deliveri['address1'] ) || ! empty( $data->deliveri['address2'] ) || ! empty( $data->deliveri['address3'] ) ) {
1451 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( $data->deliveri['address2'] . ' ' . $data->deliveri['address3'] . ' ' . $data->deliveri['address1'] . ' ' . $pref . ' ' . $data->deliveri['country'] ), 0, 'L' );
1452 }
1453 $y = $pdf->GetY() + $linetop;
1454 $pdf->SetXY( $leftside, $y );
1455 if ( ! empty( $data->deliveri['zipcode'] ) ) {
1456 $pdf->MultiCell( $width, $lineheight, usces_conv_euc( __( 'zip code', 'usces' ) . ' ' . $data->deliveri['zipcode'] ), 0, 'L' );
1457 }
1458 break;
1459 }
1460 }
1461
1462 /**
1463 * My address
1464 *
1465 * @param object $pdf TCPDF.
1466 * @param float $lineheight Line height.
1467 */
1468 function usces_get_pdf_myaddress( $pdf, $lineheight ) {
1469 $options = get_option( 'usces' );
1470 $applyform = usces_get_apply_addressform( $options['system']['addressform'] );
1471 $name = '';
1472
1473 switch ( $applyform ) {
1474 case 'JP':
1475 $address = ( empty( $options['address2'] ) ) ? $options['address1'] : $options['address1'] . "\n" . $options['address2'];
1476 $address = apply_filters( 'usces_filter_pdf_mycompany_address', $address );
1477 if ( ! empty( $options['zip_code'] ) ) {
1478 $zip_code = apply_filters( 'usces_filter_pdf_mycompany_zip', __( 'zip code', 'usces' ) . ' ' . $options['zip_code'] );
1479 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( $zip_code ), 0, 'L' );
1480 }
1481 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( $address ), 0, 'L' );
1482 break;
1483 case 'US':
1484 default:
1485 $address = ( empty( $options['address2'] ) ) ? $options['address1'] : $options['address2'] . "\n" . $options['address1'];
1486 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( $address ), 0, 'L' );
1487 if ( ! empty( $options['zip_code'] ) ) {
1488 $pdf->MultiCell( 60, $lineheight, usces_conv_euc( __( 'zip code', 'usces' ) . ' ' . $options['zip_code'] ), 0, 'L' );
1489 }
1490 break;
1491 }
1492 }
1493
1494 /**
1495 * Company name
1496 *
1497 * @param int $order_id Order ID.
1498 * @param string $type Custom field type.
1499 * @return string
1500 */
1501 function usces_get_pdf_company( $order_id, $type ) {
1502 global $usces;
1503
1504 if ( 'customer' === $type ) {
1505 $company_pre = 'cscs_';
1506 } elseif ( 'delivery' === $type ) {
1507 $company_pre = 'csde_';
1508 } else {
1509 return '';
1510 }
1511 $company_key = apply_filters( 'usces_filter_pdf_company_key', 'company' );
1512 $company = $usces->get_order_meta_value( $company_pre . $company_key, $order_id );
1513 $meta = usces_has_custom_field_meta( $type );
1514 if ( ! isset( $meta[ $company_key ] ) ) {
1515 $company = '';
1516 }
1517 return $company;
1518 }
1519