PluginProbe
Welcart e-Commerce / 2.12.3
Welcart e-Commerce v2.12.3
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 1.4.13 All 291 releases
usc-e-shop / includes / order_print.php

order_print.php in Welcart e-Commerce 2.12.3, at includes/order_print.php

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