PluginProbe
Welcart e-Commerce / 1.3.16
Welcart e-Commerce v1.3.16
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.php

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

876 lines 35.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 global $usces;
3 require_once(USCES_PLUGIN_DIR.'/pdf/tcpdf/config/lang/jpn.php');
4 require_once(USCES_PLUGIN_DIR.'/pdf/tcpdf/tcpdf.php');
5 require_once(USCES_PLUGIN_DIR.'/pdf/fpdi/fpdi.php');
6 require_once( USCES_PLUGIN_DIR.'/classes/orderData.class.php');
7
8 define ( 'GOTHIC', 'msgothic' );
9
10 //用紙サイズ(B5)
11 // FPDIクラスのインスタンス生成
12 if(isset($usces->options['print_size']) && $usces->options['print_size'] == 'A4')
13 $pdf = new FPDI('P', 'mm', 'A4', true, array(210, 297),'UTF-8');
14 else
15 $pdf = new FPDI('P', 'mm', 'B5', true, array(182, 257),'UTF-8');
16
17 $usces_pdfo = new orderDataObject($_REQUEST['order_id']);
18 usces_pdf_out($pdf, $usces_pdfo);
19 die();
20
21 function usces_conv_euc($str){
22 $str = apply_filters( 'usces_filter_pdf_conv_enc', $str);
23 return $str;
24 }
25
26 function usces_pdf_out($pdf, $data){
27 global $usces;
28
29 $pdf->setPrintHeader( false );
30 $pdf->setPrintFooter( false );
31
32 //PDF出力基本設定
33 //******************************************************
34
35 $border = 0;//セルのボーダー初期値
36
37 // テンプレートファイル
38 if(isset($usces->options['print_size']) && $usces->options['print_size'] == 'A4')
39 $tplfile = USCES_PLUGIN_DIR."/images/orderform_A4.pdf";
40 else
41 $tplfile = USCES_PLUGIN_DIR."/images/orderform_B5.pdf";
42
43 $tplfile = apply_filters( 'usces_filter_pdf_template', $tplfile );
44
45 $pagecount = $pdf->setSourceFile($tplfile);
46 $tplidx = $pdf->importPage(1); //kitamu ImportPage(1) -> importPage(1)に変更
47 $pdf->SetLeftMargin(0);
48 $pdf->SetTopMargin(0);
49 $pdf->addPage();
50
51 // $font = $pdf->addTTFfont( USCES_PLUGIN_DIR .'/pdf/tcpdf/fonts/add_font_name.php');
52 $font = apply_filters( 'usces_filter_pdf_cfont', 'msgothic', $pdf );
53
54 // 文書�
55 報設定
56 $pdf->SetCreator('Welcart');
57 $pdf->SetAuthor('Collne Inc.');
58 switch ($_REQUEST['type'] ){
59 case 'mitumori':
60 $pdf->SetTitle('estimate');
61 $filename = 'estimate_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
62 break;
63
64 case 'nohin':
65 $pdf->SetTitle('invoice');
66 $filename = 'invoice_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
67 break;
68
69 case 'receipt':
70 $pdf->SetTitle('receipt');
71 $filename = 'receipt_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
72 break;
73
74 case 'bill':
75 $pdf->SetTitle('bill');
76 $filename = 'bill_' . usces_get_deco_order_id( $data->order['ID'] ) . '.pdf';
77 break;
78 }
79
80 //表示モードを指定する。
81 $pdf->SetDisplayMode('real', 'continuous');
82
83 // 総ページ数のエイリアスを定義する。
84 // エイリアスはドキュメントをクローズするときに置換する。
85 // '{nb}' で総ページ数が得られる
86
87 //$pdf->AliasNbPages(); //20140107_kitamu getAliasNbPages()へ
88 $pdf->getAliasNbPages();
89
90 //自動改ページモード
91 $pdf->SetAutoPageBreak(true , 5);
92
93 $pdf->SetFillColor(255, 255, 255);
94
95 //**************************************************************
96 $page = 1;//ページ数の初期化
97
98 //--------------------------------------------------------------
99 usces_pdfSetHeader($pdf, $data, $page);
100 //$pdf->SetDrawColor(255,0,0);
101 $border = 0;
102
103 $pdf->SetLeftMargin(19.8);
104 $x = 15.8;
105 $y = 101;
106 $onep = apply_filters( 'usces_filter_pdf_page_height', 190 );
107 $pdf->SetXY($x, $y);
108 $next_y = $y;
109 $line_x = array();
110 for ( $index = 0; $index < count($data->cart); $index++ ) {
111 $cart_row = $data->cart[$index];
112 //if ($cnt > $pageRec-1) {//ページが変わるときの処理
113 if ( $onep < $next_y ) {//ページが変わるときの処理
114
115 $pdf->addPage();
116 //$pdf->useTemplate($tplidx);
117
118 //-----------------------------------------------------
119 usces_pdfSetHeader($pdf, $data, $page);
120
121 $x = 15.8;
122 $y = 101;
123 $pdf->SetXY($x, $y);
124 $next_y = $y;
125 }
126
127 //---------------------------------------------------------
128 $post_id = $cart_row['post_id'];
129 $sku = urldecode($cart_row['sku']);
130 $cartItemName = $usces->getCartItemName($post_id, $sku);
131 $optstr = '';
132 if( is_array($cart_row['options']) && count($cart_row['options']) > 0 ){
133 foreach($cart_row['options'] as $key => $value){
134
135 if( !empty($key) ) {
136 $key = urldecode($key);
137 if(is_array($value)) {
138 $c = '';
139 $optstr .= esc_html($key) . ' = ';
140 foreach($value as $v) {
141 $optstr .= $c.esc_html(urldecode($v));
142 $c = ', ';
143 }
144 $optstr .= "\n";
145 } else {
146 $optstr .= esc_html($key) . ' = ' . esc_html(urldecode($value)) . "\n";
147 }
148 }
149 }
150 $optstr = apply_filters( 'usces_filter_option_pdf', $optstr, $cart_row['options']);
151 }
152 $optstr = apply_filters( 'usces_filter_all_option_pdf', $optstr, $cart_row['options'], $post_id, $sku, $cart_row['advance']);
153
154 $line_y[$index] = $next_y;
155
156 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8); //10->8
157 $pdf->SetFont( $font, '', $fontsize);
158 $pdf->SetXY($x-0.2, $line_y[$index]+0.8); //kitamu +0.8
159 $pdf->MultiCell(4, $lineheight, '*', $border, 'C'); //kitamu 3.6から4へ
160 $pdf->SetXY($x+3.0, $line_y[$index]);
161 $pdf->MultiCell(84.6, $lineheight, usces_conv_euc($cartItemName), $border, 'L');
162 if( 'receipt' != $_REQUEST['type'] ){
163 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
164 $pdf->SetFont($font, '', $fontsize);
165 $pdf->SetXY($x+6.0, $pdf->GetY()+$linetop);
166 $pdf->MultiCell(81.6, $lineheight-0.2, usces_conv_euc($optstr), $border, 'L');
167 }
168
169 $pdf_args = compact( 'page', 'x', 'y', 'onep', 'next_y', 'line_x', 'border', 'index', 'cart_row' );
170 do_action( 'usces_action_order_print_cart_row', $pdf, $data, $pdf_args );
171
172 $next_y = $pdf->GetY()+2;
173 list($fontsize, $lineheight, $linetop) = usces_set_font_size(7); //kitamu 10->7
174 $pdf->SetFont( $font, '', $fontsize);
175 $pdf->SetXY($x+88.0, $line_y[$index]);
176 $pdf->MultiCell(11.5, $lineheight, usces_conv_euc($cart_row['quantity']), $border, 'R');
177 list($fontsize, $lineheight, $linetop) = usces_set_font_size(7); //kitamu 10->7
178 $pdf->SetFont( $font, '', $fontsize);
179 $pdf->SetXY($x+99.6, $line_y[$index]);
180 $pdf->MultiCell(11.5, $lineheight, usces_conv_euc($usces->getItemSkuUnit($post_id, urldecode($cart_row['sku']))), $border, 'C');
181 $pdf->SetXY($x+111.5, $line_y[$index]);
182 list($fontsize, $lineheight, $linetop) = usces_set_font_size(7); //kitamu 7->7
183 $pdf->SetFont( $font, '', $fontsize);
184 $pdf->MultiCell(15.2, $lineheight, usces_conv_euc($usces->get_currency($cart_row['price'])), $border, 'R');
185 $pdf->SetXY($x+126.9, $line_y[$index]);
186 list($fontsize, $lineheight, $linetop) = usces_set_font_size(7); //kitamu 9->7
187 $pdf->SetFont( $font, '', $fontsize);
188 $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), $border, 'R');
189
190 if( $onep < $next_y && 0 < $index ){
191 $pdf->Rect($x, $line_y[$index]-0.4, 149.5, 197.4-$line_y[$index], 'F');
192
193 $pdf->SetXY($x, 193);
194 $pdf->MultiCell(88, $lineheight, usces_conv_euc(__('It continues to next.', 'usces')), $border, 'C');
195
196 usces_pdfSetLine($pdf);
197 usces_pdfSetFooter($pdf, $data);
198 $index--;
199 $page++;
200 }
201 }
202
203 usces_pdfSetLine($pdf);
204 usces_pdfSetFooter($pdf, $data);
205
206 @ob_end_clean(); //error表示を取り除く
207
208 // Output
209 //*****************************************************************
210 $pdf->Output($filename, 'I');
211 }
212
213 //Header
214 function usces_pdfSetHeader($pdf, $data, $page) {
215 global $usces;
216 $border = 0;//border of cells
217
218 // $font = $pdf->addTTFfont( USCES_PLUGIN_DIR .'/pdf/tcpdf/fonts/add_font_name.php');
219 $font = apply_filters( 'usces_filter_pdf_cfont', 'msgothic', $pdf );
220
221 switch ( $_REQUEST['type'] ){
222 case 'mitumori':
223 $title = apply_filters( 'usces_filter_pdf_estimate_title', __('Estimate', 'usces'), $data );
224 $message = sprintf(__("Thank you for choosing '%s' we send you following estimate. ", 'usces'),
225 apply_filters('usces_filter_publisher', get_option('blogname')));
226 $message = apply_filters('usces_filter_pdf_estimate_message', $message, $data);
227 $juchubi = apply_filters( 'usces_filter_pdf_estimate_validdays', __('Valid:7days', 'usces'), $data );
228 $siharai = ' ';
229 $sign_image = apply_filters('usces_filter_pdf_estimate_sign', NULL);
230 $effective_date = date(__('M j, Y', 'usces'), strtotime($data->order['date']));
231 break;
232
233 case 'nohin':
234 $title = apply_filters( 'usces_filter_pdf_invoice_title', __('Delivery Statement', 'usces'), $data );
235 $message = sprintf(__("Thak you for choosing '%s'. We deliver your items as following.", 'usces'),
236 apply_filters('usces_filter_publisher', get_option('blogname')));
237 $message = apply_filters('usces_filter_pdf_invoice_message', $message, $data);
238 $juchubi = __('date of receiving the order', 'usces').' : '.date(__('M j, Y', 'usces'), strtotime($data->order['date']));
239 $siharai = __('payment division', 'usces').' : ' . apply_filters('usces_filter_pdf_payment_name', $data->order['payment_name'], $data);
240 $sign_image = apply_filters('usces_filter_pdf_invoice_sign', NULL);
241
242 if( !empty($data->order['delidue_date']) && '#none#' != $data->order['delidue_date'] ){
243 $effective_date = date(__('M j, Y', 'usces'), strtotime($data->order['delidue_date']));
244 }else{
245 if( empty($data->order['modified']) )
246 $effective_date = date(__('M j, Y', 'usces'), current_time('timestamp', 0));
247 else
248 $effective_date = date(__('M j, Y', 'usces'), strtotime($data->order['modified']));
249 }
250
251 break;
252
253 case 'receipt':
254 $title = apply_filters( 'usces_filter_pdf_receipt_title', __('Receipt', 'usces'), $data );
255 $message = apply_filters('usces_filter_pdf_receipt_message', __("Your payment has been received.", 'usces'), $data);
256 $juchubi = __('date of receiving the order', 'usces').' : '.date(__('M j, Y', 'usces'), strtotime($data->order['date']));
257 $siharai = __('payment division', 'usces').' : ' . apply_filters('usces_filter_pdf_payment_name', $data->order['payment_name'], $data);
258 $sign_image = apply_filters('usces_filter_pdf_receipt_sign', NULL);
259 $receipted_date = $usces->get_order_meta_value('receipted_date', $data->order['ID']);
260 if( empty($receipted_date) )
261 $effective_date = date(__('M j, Y', 'usces'), current_time('timestamp', 0));
262 else
263 $effective_date = date(__('M j, Y', 'usces'), strtotime($receipted_date));
264 break;
265
266 case 'bill':
267 $title = apply_filters( 'usces_filter_pdf_bill_title', __('Invoice', 'usces'), $data );
268 $message = apply_filters('usces_filter_pdf_bill_message', __("Please remit payment at your earliest convenience.", 'usces'), $data);
269 $juchubi = __('date of receiving the order', 'usces').' : '.date(__('M j, Y', 'usces'), strtotime($data->order['date']));
270 $siharai = __('payment division', 'usces').' : ' . apply_filters('usces_filter_pdf_payment_name', $data->order['payment_name'], $data);
271 $sign_image = apply_filters('usces_filter_pdf_bill_sign', NULL);
272 $effective_date = date(__('M j, Y', 'usces'), current_time('timestamp', 0));
273 break;
274 }
275 $effective_date = apply_filters('usces_filter_pdf_effective_date', $effective_date, $_REQUEST['type'], $data);
276
277 $pdf->SetLineWidth(0.4);
278 $pdf->Line(65, 23, 110, 23);
279 $pdf->SetLineWidth(0.1);
280 $pdf->Line(124, 19, 167, 19);
281 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
282 $pdf->SetFont($font, '', $fontsize);
283 $pdf->SetXY(125, 15.0);
284 $pdf->Write(5, 'No.');
285
286 // Title
287 list($fontsize, $lineheight, $linetop) = usces_set_font_size(15);
288 $pdf->SetFont($font, '', $fontsize);
289 $pdf->SetXY(63, 16);
290 $pdf->MultiCell(50, $lineheight, usces_conv_euc($title), $border, 'C');
291
292 // Date
293 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
294 $pdf->SetFont($font, '', $fontsize);
295 $pdf->SetXY(64, 24.2);
296 $pdf->MultiCell(45.5, $lineheight, usces_conv_euc($effective_date), $border, 'C');
297
298 // Order No.
299 $pdf->SetXY(131, 15);
300 $pdf->MultiCell(36, $lineheight, usces_get_deco_order_id( $data->order['ID'] ), $border, 'R');
301
302 // Page No.
303 list($fontsize, $lineheight, $linetop) = usces_set_font_size(13);
304 $pdf->SetFont($font, '', $fontsize);
305 $pdf->SetXY(15.5, 15.4);
306
307 $pdf->Cell( 20, 7, ' ' . $page . '/ ' . $pdf->getAliasNbPages(), 1);
308
309 $width = 80;
310 $leftside = 15;
311 $pdf->SetLeftMargin($leftside);
312
313 $person_honor = ( 'JP' == $usces->options['system']['currency'] ) ? "" : '';
314 $company_honor = ( 'JP' == $usces->options['system']['currency'] ) ? "御中" : '';
315 $currency_post = ( 'JP' == $usces->options['system']['currency'] ) ? "-" : '';
316
317 if( 'receipt' == $_REQUEST['type'] ){
318 $top = 40;
319
320 $meta = usces_has_custom_field_meta('customer');
321 $company = $usces->get_order_meta_value('cscs_company', $data->order['ID']);
322 list($fontsize, $lineheight, $linetop) = usces_set_font_size(12);
323 $pdf->SetFont($font, '', $fontsize);
324 $pdf->SetXY($leftside, $top);
325
326 if( empty( $company ) || !isset( $meta['company'] ) ){
327 $pdf->MultiCell($width, $lineheight, usces_conv_euc(usces_get_pdf_name( $data )), $border, 'L');
328 $x = $leftside + $width;
329 $y = $pdf->GetY() - $lineheight;
330 $pdf->SetXY($x, $y);
331 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ));
332 }else{
333 $pdf->MultiCell($width, $lineheight, usces_conv_euc($company), $border, 'L');
334 $x = $leftside + $width;
335 $y = $pdf->GetY() - $lineheight;
336 $pdf->SetXY($x, $y);
337 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor) ));
338 }
339 $y = $pdf->GetY() + $lineheight + $linetop;
340 $pdf->SetLineWidth(0.1);
341 $pdf->Line($leftside, $y, $leftside+$width+7, $y);
342
343 //Total
344 $y = $pdf->GetY() + $lineheight + 7;
345 list($fontsize, $lineheight, $linetop) = usces_set_font_size(20);
346 $pdf->SetFont($font, '', $fontsize);
347 $pdf->SetXY($leftside+2, $y);
348 $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');
349
350 // Message
351 $y = $pdf->GetY() + $lineheight;
352 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
353 $pdf->SetFont($font, '', $fontsize);
354 $pdf->SetXY($leftside, $y);
355 $pdf->MultiCell($width+70, $lineheight, usces_conv_euc($message), $border, 'L');
356
357 // Label
358 list($fontsize, $lineheight, $linetop) = usces_set_font_size(10);
359 $pdf->SetFont($font, '', $fontsize);
360 $y = 89;
361 $pdf->SetXY($leftside, $y);
362 $pdf->MultiCell(75, $lineheight, usces_conv_euc(__('Statement', 'usces')), $border, 'L');
363
364
365 }elseif( 'nohin' == $_REQUEST['type'] ){
366 //「�
367 �送�
368 �を宛名とする」
369 if( $usces->options['system']['pdf_delivery'] == 1 ){
370 $top = 30;
371
372 $meta = usces_has_custom_field_meta('delivery');
373 $deliveri_company = $usces->get_order_meta_value('csde_company', $data->order['ID']);
374 list($fontsize, $lineheight, $linetop) = usces_set_font_size(12);
375 $pdf->SetFont($font, '', $fontsize);
376 $pdf->SetXY($leftside, $top);
377
378 if( empty( $deliveri_company ) || !isset( $meta['company'] ) ){
379 $pdf->MultiCell($width, $lineheight, usces_conv_euc(usces_get_pdf_shipping_name( $data )), $border, 'L');
380 $x = $leftside + $width;
381 $y = $pdf->GetY() - $lineheight;
382 $pdf->SetXY($x, $y);
383 $pdf->Write($lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ));
384 $y = $pdf->GetY() + $lineheight + $linetop + 2;
385 }else{
386 $pdf->MultiCell($width, $lineheight, usces_conv_euc($deliveri_company), $border, 'L');
387 $x = $leftside + $width;
388 $y = $pdf->GetY() - $lineheight;
389 $pdf->SetXY($x, $y);
390 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor) ));
391 $y = $pdf->GetY() + $lineheight + $linetop;
392 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
393 $pdf->SetFont($font, '', $fontsize);
394 $pdf->SetXY($leftside, $y);
395 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("Attn", 'usces') . ' : ' . usces_get_pdf_shipping_name( $data ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ), $border, 'L');
396 $y = $pdf->GetY() + $linetop + 2;
397 }
398 // Address
399 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
400 $pdf->SetFont($font, '', $fontsize);
401
402 usces_get_pdf_shipping_address($pdf, $data, $y, $linetop, $leftside, $width, $lineheight);
403
404 $pdf->MultiCell($width, $lineheight, usces_conv_euc('TEL ' . $data->deliveri['tel']), $border, 'L');
405
406 if( !empty($data->deliveri['fax']) ){
407 $y = $pdf->GetY() + $linetop;
408 $pdf->SetXY($leftside, $y);
409 $pdf->MultiCell($width, $lineheight, usces_conv_euc('FAX ' . $data->deliveri['fax']), $border, 'L');
410 }
411 //「購�
412 ��
413
414 報を宛名とする」
415 }else{
416 $top = 30;
417
418 $meta = usces_has_custom_field_meta('customer');
419 $company = $usces->get_order_meta_value('cscs_company', $data->order['ID']);
420 list($fontsize, $lineheight, $linetop) = usces_set_font_size(12);
421 $pdf->SetFont($font, '', $fontsize);
422 $pdf->SetXY($leftside, $top);
423
424 if( empty( $company ) || !isset( $meta['company'] ) ){
425 $pdf->MultiCell($width, $lineheight, usces_conv_euc(usces_get_pdf_name( $data )), $border, 'L');
426 $x = $leftside + $width;
427 $y = $pdf->GetY() - $lineheight;
428 $pdf->SetXY($x, $y);
429 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ));
430 $y = $pdf->GetY() + $lineheight + $linetop + 2;
431 }else{
432 $pdf->MultiCell($width, $lineheight, usces_conv_euc($company), $border, 'L');
433 $x = $leftside + $width;
434 $y = $pdf->GetY() - $lineheight;
435 $pdf->SetXY($x, $y);
436 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor) ));
437 $y = $pdf->GetY() + $lineheight + $linetop;
438 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
439 $pdf->SetFont($font, '', $fontsize);
440 $pdf->SetXY($leftside, $y);
441 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("Attn", 'usces') . ' : ' . usces_get_pdf_name( $data ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ), $border, 'L');
442 $y = $pdf->GetY() + $linetop + 2;
443 }
444 // Address
445 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
446 $pdf->SetFont($font, '', $fontsize);
447
448 usces_get_pdf_address($pdf, $data, $y, $linetop, $leftside, $width, $lineheight);
449
450 $pdf->MultiCell($width, $lineheight, usces_conv_euc('TEL ' . $data->customer['tel']), $border, 'L');
451
452 if( !empty($data->customer['fax']) ){
453 $y = $pdf->GetY() + $linetop;
454 $pdf->SetXY($leftside, $y);
455 $pdf->MultiCell($width, $lineheight, usces_conv_euc('FAX ' . $data->customer['fax']), $border, 'L');
456 }
457 //�
458 �送�
459 ��
460
461 $customer_name = trim( $data->customer['name1'] ) . trim( $data->customer['name2'] );
462 $deliveri_name = trim( $data->deliveri['name1'] ) . trim( $data->deliveri['name2'] );
463 $customer_zip = trim( $data->customer['zip'] );
464 $deliveri_zip = trim( $data->deliveri['zipcode'] );
465 $customer_address = trim( $data->customer['address1'] ) . trim( $data->customer['address2']) . trim( $data->customer['address3'] );
466 $deliveri_address = trim( $data->deliveri['address1'] ) . trim( $data->deliveri['address2']) . trim( $data->deliveri['address3'] );
467
468 //発送�
469 �が�
470 �力されているとき
471 if( !empty($deliveri_address) ){
472 //購�
473 ��
474 と発送�
475 ��
476 報が異なるとき
477 if( $customer_name != $deliveri_name || $customer_zip != $deliveri_zip || $customer_address != $deliveri_address){
478 // Line
479 $y = $pdf->GetY() + $linetop;
480 $pdf->SetLineWidth(0.1);
481 $pdf->Line( $leftside, $y, $leftside+$width+5, $y );
482
483 //【�
484 �送�
485 �】タイトル
486 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8); // 10->8
487 $y = $pdf->GetY() + $linetop + 1;
488 $pdf->SetFont($font, '', $fontsize);
489 $pdf->SetXY($leftside, $y);
490 $pdf->MultiCell($width, $lineheight, usces_conv_euc( __( "** A shipping address **", 'usces' ) ), $border, 'L');
491
492 //�
493 �送�
494 �宛名
495 $meta = usces_has_custom_field_meta('delivery');
496 $deliveri_company = $usces->get_order_meta_value( 'csde_company', $data->order['ID'] );
497 list($fontsize, $lineheight, $linetop) = usces_set_font_size(6);
498 $y = $pdf->GetY() + $linetop;
499 $pdf->SetFont($font, '', $fontsize);
500 $pdf->SetXY($leftside, $y);
501 if( empty( $deliveri_company ) || !isset( $meta['company'] ) ){
502 $pdf->MultiCell($width, $lineheight, usces_conv_euc( usces_get_pdf_shipping_name( $data ) ), $border, 'L');
503 $x = $leftside + $width;
504 $y = $pdf->GetY() - $lineheight - $linetop;
505 $pdf->SetXY($x, $y);
506 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor ) )); //
507 $y = $pdf->GetY() + $lineheight + $linetop;
508 }else{
509 $pdf->MultiCell($width, $lineheight, usces_conv_euc($deliveri_company), $border, 'L');
510 $x = $leftside + $width;
511 $y = $pdf->GetY() - $lineheight;
512 $pdf->SetXY($x, $y);
513 $pdf->Write($lineheight, usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor ) )); //御中
514 $y = $pdf->GetY() + $lineheight + $linetop;
515 list($fontsize, $lineheight, $linetop) = usces_set_font_size(6);
516 $pdf->SetFont($font, '', $fontsize);
517 $pdf->SetXY($leftside, $y);
518 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("Attn", 'usces') . ' : ' . usces_get_pdf_shipping_name( $data ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ), $border, 'L');
519 $y = $pdf->GetY() + $linetop;
520 }
521 //�
522 �送�
523 �住所
524 list($fontsize, $lineheight, $linetop) = usces_set_font_size(6);
525 $pdf->SetFont($font, '', $fontsize);
526 usces_get_pdf_shipping_address($pdf, $data, $y, $linetop, $leftside, $width, $lineheight);
527
528 //�
529 �送�
530 �電話番号
531 $pdf->MultiCell($width, $lineheight, usces_conv_euc('TEL ' . $data->deliveri['tel']), $border, 'L');
532 }
533 }
534 }
535 $y = $pdf->GetY() + $linetop + 0.5;
536
537 $pdf->SetLineWidth(0.1);
538 $pdf->Line($leftside, $y, $leftside+$width+5, $y);
539
540 // Message
541 $y = 80;
542 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
543 $pdf->SetFont($font, '', $fontsize);
544 $pdf->SetXY($leftside, $y);
545 $pdf->MultiCell($width+70, $lineheight, usces_conv_euc($message), $border, 'L');
546
547 // Order date
548 list($fontsize, $lineheight, $linetop) = usces_set_font_size(10);
549 $pdf->SetFont($font, '', $fontsize);
550 $y = 89;
551 $pdf->SetXY($leftside, $y);
552 $pdf->MultiCell(75, $lineheight, usces_conv_euc($juchubi), $border, 'L');
553
554 // Payment method
555 $pdf->SetXY($leftside+68, $y);
556 $pdf->Cell(75, $lineheight, usces_conv_euc($siharai), $border, 1, 'L');
557
558 }else{
559 $top = 30;
560
561 $meta = usces_has_custom_field_meta('customer');
562 $company = $usces->get_order_meta_value('cscs_company', $data->order['ID']);
563 list($fontsize, $lineheight, $linetop) = usces_set_font_size(12);
564 $pdf->SetFont($font, '', $fontsize);
565 $pdf->SetXY($leftside, $top);
566
567 if( empty( $company ) || !isset( $meta['company'] ) ){
568 $pdf->MultiCell($width, $lineheight, usces_conv_euc(usces_get_pdf_name( $data )), $border, 'L');
569 $x = $leftside + $width;
570 $y = $pdf->GetY() - $lineheight;
571 $pdf->SetXY($x, $y);
572 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ));
573 $y = $pdf->GetY() + $lineheight + $linetop + 2;
574 }else{
575 $pdf->MultiCell($width, $lineheight, usces_conv_euc($company), $border, 'L');
576 $x = $leftside + $width;
577 $y = $pdf->GetY() - $lineheight;
578 $pdf->SetXY($x, $y);
579 $pdf->Write($lineheight ,usces_conv_euc( apply_filters( 'usces_filters_pdf_company_honor', $company_honor) ));
580 $y = $pdf->GetY() + $lineheight + $linetop;
581 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
582 $pdf->SetFont($font, '', $fontsize);
583 $pdf->SetXY($leftside, $y);
584 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("Attn", 'usces') . ' : ' . usces_get_pdf_name( $data ) . apply_filters( 'usces_filters_pdf_person_honor', $person_honor) ), $border, 'L');
585 $y = $pdf->GetY() + $linetop + 2;
586 }
587 // Address
588 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
589 $pdf->SetFont($font, '', $fontsize);
590
591 usces_get_pdf_address($pdf, $data, $y, $linetop, $leftside, $width, $lineheight);
592
593 $pdf->MultiCell($width, $lineheight, usces_conv_euc('TEL ' . $data->customer['tel']), $border, 'L');
594
595 if( !empty($data->customer['fax']) ){
596 $y = $pdf->GetY() + $linetop;
597 $pdf->SetXY($leftside, $y);
598 $pdf->MultiCell($width, $lineheight, usces_conv_euc('FAX ' . $data->customer['fax']), $border, 'L');
599 }
600 $y = $pdf->GetY() + $linetop + 0.5;
601
602 $pdf->SetLineWidth(0.1);
603 $pdf->Line($leftside, $y, $leftside+$width+5, $y);
604
605 // Message
606 $y = 80;
607 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
608 $pdf->SetFont($font, '', $fontsize);
609 $pdf->SetXY($leftside, $y);
610 $pdf->MultiCell($width+70, $lineheight, usces_conv_euc($message), $border, 'L');
611
612 // Order date
613 list($fontsize, $lineheight, $linetop) = usces_set_font_size(10);
614 $pdf->SetFont($font, '', $fontsize);
615 $y = 89;
616 $pdf->SetXY($leftside, $y);
617 $pdf->MultiCell(75, $lineheight, usces_conv_euc($juchubi), $border, 'L');
618
619 // Payment method
620 $pdf->SetXY($leftside+76, $y);
621 $pdf->MultiCell(75, $lineheight, usces_conv_euc($siharai), $border, 'L');
622 }
623
624 // My company
625 if( !empty($sign_image) ){
626 $sign_data = apply_filters( 'usces_filter_pdf_sign_data', array(140, 40, 25, 25));
627 $pdf->Image($sign_image, $sign_data[0], $sign_data[1], $sign_data[2], $sign_data[3]);
628 }
629 $x = 110;
630 $y = 45;
631 $pdf->SetLeftMargin($x);
632 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
633 $pdf->SetFont($font, '', $fontsize);
634 $pdf->SetXY($x, $y);
635 $pdf->MultiCell(60, $lineheight, usces_conv_euc(apply_filters('usces_filter_publisher', get_option('blogname'))), 0, 'L');
636 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
637 $pdf->SetFont($font, '', $fontsize);
638 $pdf->MultiCell(60, $lineheight, usces_conv_euc(apply_filters('usces_filter_pdf_mycompany', $usces->options['company_name'])), 0, 'L');
639 usces_get_pdf_myaddress($pdf, $lineheight );
640 $pdf->MultiCell(60, $lineheight, usces_conv_euc('TEL:'.$usces->options['tel_number']), 0, 'L');
641 $pdf->MultiCell(60, $lineheight, usces_conv_euc('FAX:'.$usces->options['fax_number']), 0, 'L');
642 }
643
644 //Footer
645 function usces_pdfSetFooter($pdf, $data) {
646 global $usces;
647
648 // $font = $pdf->addTTFfont( USCES_PLUGIN_DIR .'/pdf/tcpdf/fonts/add_font_name.php');
649 $font = apply_filters( 'usces_filter_pdf_cfont', 'msgothic', $pdf );
650
651 $border = 0;
652 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
653 $pdf->SetFont($font, '', $fontsize);
654
655 // Body label
656 $pdf->SetXY(15.5, 94.9);
657 $pdf->MultiCell(87.8, $lineheight, usces_conv_euc(__('item name','usces')), $border, 'C');
658 $pdf->SetXY(103.7, 94.9);
659 $pdf->MultiCell(11.4, $lineheight, usces_conv_euc(__('Quant','usces')), $border, 'C');
660 $pdf->SetXY(115.8, 94.9);
661 $pdf->MultiCell(11.0, $lineheight, usces_conv_euc(__('Unit', 'usces')), $border, 'C');
662 $pdf->SetXY(127.2, 94.9);
663 $pdf->MultiCell(15.0, $lineheight, usces_conv_euc(__('Price','usces')), $border, 'C');
664 $pdf->SetXY(142.9, 94.9);
665 $pdf->MultiCell(22.4, $lineheight, usces_conv_euc(__('Amount','usces').'('.__(usces_crcode( 'return' ), 'usces').')'), $border, 'C');
666
667 // Footer label
668 $pdf->SetXY(104.3, 198.8);
669 $pdf->MultiCell(37.7, $lineheight, usces_conv_euc(__('total items', 'usces')), $border, 'C');
670 $pdf->SetXY(104.3, 204.8);
671 $pdf->MultiCell(37.7, $lineheight, usces_conv_euc(apply_filters('usces_filter_point_label', __('Used points', 'usces'))), $border, 'C');
672 $pdf->SetXY(104.3, 210.8);
673 $pdf->MultiCell(37.7, $lineheight, usces_conv_euc(apply_filters('usces_filter_disnount_label', __('Campaign disnount', 'usces'))), $border, 'C');
674 $pdf->SetXY(104.3, 216.7);
675 $pdf->MultiCell(37.7, $lineheight, usces_conv_euc(apply_filters('usces_filter_shipping_label', __('Shipping', 'usces'))), $border, 'C');
676 $pdf->SetXY(104.3, 222.7);
677 $pdf->MultiCell(37.7, $lineheight, usces_conv_euc(apply_filters('usces_filter_cod_label', __('COD fee', 'usces'))), $border, 'C');
678 $pdf->SetXY(104.3, 228.6);
679 $pdf->MultiCell(37.7, $lineheight, usces_conv_euc(apply_filters('usces_filter_tax_label', __('consumption tax', 'usces'))), $border, 'C');
680 $pdf->SetXY(104.3, 235.8);
681 $pdf->MultiCell(37.77, $lineheight, usces_conv_euc(__('Total Amount', 'usces')), $border, 'C');
682
683 list($fontsize, $lineheight, $linetop) = usces_set_font_size(8);
684 $pdf->SetFont($font, '', $fontsize);
685 // Footer value
686 $pdf->SetXY(16.1, 198.8);
687 $pdf->MultiCell(86.6, $lineheight, usces_conv_euc( apply_filters('usces_filter_pdf_note', $data->order['note'], $data, $_REQUEST['type'])), $border, 'J');
688 list($fontsize, $lineheight, $linetop) = usces_set_font_size(9);
689 $pdf->SetFont($font, '', $fontsize);
690 $pdf->SetXY(142.9, 198.8);
691 $pdf->MultiCell(22.6, $lineheight, usces_conv_euc($usces->get_currency($data->order['item_total_price'])), $border, 'R');
692 $pdf->SetXY(142.9, 204.8);
693 $pdf->MultiCell(22.6, $lineheight, usces_conv_euc(apply_filters('usces_filter_point_vlue', $usces->get_currency($data->order['usedpoint']))), $border, 'R');
694 $pdf->SetXY(142.9, 210.8);
695 $pdf->MultiCell(22.6, $lineheight, usces_conv_euc(apply_filters('usces_filter_disnount_vlue', $usces->get_currency($data->order['discount']))), $border, 'R');
696 $pdf->SetXY(142.9, 216.7);
697 $pdf->MultiCell(22.6, $lineheight, usces_conv_euc(apply_filters('usces_filter_shipping_vlue', $usces->get_currency($data->order['shipping_charge']))), $border, 'R');
698 $pdf->SetXY(142.9, 222.7);
699 $pdf->MultiCell(22.6, $lineheight, usces_conv_euc(apply_filters('usces_filter_cod_vlue', $usces->get_currency($data->order['cod_fee']))), $border, 'R');
700
701 if( empty($usces->options['tax_rate']) ){
702 $tax = '('.__('In tax', 'usces').')'.$usces->get_currency($data->order['tax']);
703 }else{
704 $tax = $usces->get_currency($data->order['tax']);
705 }
706 $pdf->SetXY(142.9, 228.6);
707 $pdf->MultiCell(22.6, $lineheight, usces_conv_euc(apply_filters('usces_filter_tax_vlue', $tax, $data)), $border, 'R');
708 $pdf->SetXY(142.9, 235.8);
709 $pdf->MultiCell(22.67, $lineheight, usces_conv_euc($usces->get_currency($data->order['total_full_price'])), $border, 'R');
710
711 do_action( 'usces_action_order_print_footer', $pdf, $data);
712 }
713
714 //Line
715 function usces_pdfSetLine($pdf) {
716
717 $pdf->Rect(14, 197.8, 153, 45, 'F');//Footer field
718 $line_top = 93.5;
719 $line_left = 15.4;
720 $line_right = $line_left + 150.1;
721 $line_bottom = $line_top + 147.9;
722 $line_footertop = 197.5;
723
724 // Horizontal lines
725 $pdf->SetLineWidth(0.5);
726 $pdf->Line($line_left, $line_top, $line_right, $line_top);
727 $pdf->Line($line_left, $line_top+6.5, $line_right, $line_top+6.5);
728 $pdf->Line($line_left, $line_top+104.0, $line_right, $line_top+104.0);
729 $pdf->SetLineWidth(0.04);
730 $pdf->Line(103.5, $line_footertop+5.9, $line_right, $line_footertop+5.9);
731 $pdf->Line(103.5, $line_footertop+5.9*2, $line_right, $line_footertop+5.9*2);
732 $pdf->Line(103.5, $line_footertop+5.9*3, $line_right, $line_footertop+5.9*3);
733 $pdf->Line(103.5, $line_footertop+5.9*4, $line_right, $line_footertop+5.9*4);
734 $pdf->SetLineWidth(0.5);
735 $pdf->Line(103.5, $line_footertop+5.9*5, $line_right, $line_footertop+5.9*5);
736 $pdf->Line(103.5, $line_footertop+5.9*6, $line_right, $line_footertop+5.9*6);
737 $pdf->Line($line_left, $line_bottom, $line_right, $line_bottom);
738
739 // Perpendicular lines
740 $pdf->SetLineWidth(0.5);
741 $pdf->Line($line_left, $line_top, $line_left, $line_bottom);
742 $pdf->SetLineWidth(0.04);
743 $pdf->Line(103.5, $line_top, 103.5, $line_footertop);
744 $pdf->SetLineWidth(0.5);
745 $pdf->Line(103.5, $line_footertop, 103.5, $line_bottom);
746 $pdf->SetLineWidth(0.04);
747 $pdf->Line(115.5, $line_top, 115.5, $line_footertop);
748 $pdf->Line(127, $line_top, 127, $line_footertop);
749 $pdf->Line(142.5, $line_top, 142.5, $line_bottom);
750 $pdf->SetLineWidth(0.5);
751 $pdf->Line($line_right, $line_top, $line_right, $line_bottom);
752 }
753
754 function usces_set_font_size( $size ){
755 $lineheight = $size / 2.6;
756 $linetop = $lineheight / 12;
757 return array($size, $lineheight, $linetop);
758 }
759
760 function usces_get_pdf_name( $data ){
761 global $usces, $usces_settings;
762 $options = get_option('usces');
763 $applyform = usces_get_apply_addressform($options['system']['addressform']);
764 $name = '';
765 switch ($applyform){
766 case 'JP':
767 $name = $data->customer['name1'] . ' ' . $data->customer['name2'];
768 break;
769 case 'US':
770 default:
771 $name = $data->customer['name2'] . ' ' . $data->customer['name1'];
772 }
773 return $name;
774 }
775
776 //20140107_kitamu_start �
777 �送�
778 �の名前を取得
779 function usces_get_pdf_shipping_name( $data ){
780 global $usces, $usces_settings;
781 $options = get_option('usces');
782 $applyform = usces_get_apply_addressform($options['system']['addressform']);
783 $name = '';
784 switch ($applyform){
785 case 'JP':
786 $name = $data->deliveri['name1'] . ' ' . $data->deliveri['name2'];
787 break;
788 case 'US':
789 default:
790 $name = $data->deliveri['name2'] . ' ' . $data->deliveri['name1'];
791 }
792
793 return $name;
794 }
795 //20140107_kitamu_end
796
797 function usces_get_pdf_address($pdf, $data, $y, $linetop, $leftside, $width, $lineheight){
798 $options = get_option('usces');
799 $applyform = usces_get_apply_addressform($options['system']['addressform']);
800 $name = '';
801 $border = '';
802 $pref = ( __( '-- Select --','usces') == $data->customer['pref'] ) ? '' : $data->customer['pref'];
803
804 switch ($applyform){
805 case 'JP':
806 $pdf->SetXY($leftside, $y);
807 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("zip code", 'usces') . ' ' . $data->customer['zip']), $border, 'L');
808 $pdf->MultiCell($width, $lineheight, usces_conv_euc($pref . $data->customer['address1'] . $data->customer['address2']) .' '. $data->customer['address3'], $border, 'L');
809 break;
810
811 case 'US':
812 default:
813 $pdf->SetXY($leftside, $y);
814 $pdf->MultiCell($width, $lineheight, usces_conv_euc($data->customer['address2'] . ' ' . $data->customer['address3'] . ' ' . $data->customer['address1'] . ' ' . $pref . ' ' . $data->customer['country']), $border, 'L');
815
816 $y = $pdf->GetY() + $linetop;
817 $pdf->SetXY($leftside, $y);
818 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("zip code", 'usces') . ' ' . $data->customer['zip']), $border, 'L');
819 break;
820 }
821 }
822
823 //20140107_kitamu_start �
824 �送�
825 �が異なる場合の表示
826 function usces_get_pdf_shipping_address($pdf, $data, $y, $linetop, $leftside, $width, $lineheight){
827 $options = get_option('usces');
828 $applyform = usces_get_apply_addressform($options['system']['addressform']);
829 $name = '';
830 $border = '';
831 $pref = ( __( '-- Select --','usces') == $data->deliveri['pref'] ) ? '' : $data->deliveri['pref'];
832
833 switch ($applyform){
834 case 'JP':
835 $pdf->SetXY($leftside, $y);
836 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("zip code", 'usces') . ' ' . $data->deliveri['zipcode']), $border, 'L');
837 $pdf->MultiCell($width, $lineheight, usces_conv_euc($pref . $data->deliveri['address1'] . $data->deliveri['address2'] .' '. $data->deliveri['address3']), $border, 'L');
838
839 break;
840
841 case 'US':
842 default:
843 $pdf->SetXY($leftside, $y);
844 $pdf->MultiCell($width, $lineheight, usces_conv_euc($data->deliveri['address2'] . ' ' . $data->deliveri['address3'] . ' ' . $data->deliveri['address1'] . ' ' . $pref . ' ' . $data->deliveri['country']), $border, 'L');
845
846 $y = $pdf->GetY() + $linetop;
847 $pdf->SetXY($leftside, $y);
848 $pdf->MultiCell($width, $lineheight, usces_conv_euc(__("zip code", 'usces') . ' ' . $data->deliveri['zipcode']), $border, 'L');
849 break;
850 }
851 }
852
853 //20140107_kitamu_end
854
855 function usces_get_pdf_myaddress($pdf, $lineheight){
856 global $usces;
857 $options = get_option('usces');
858 $applyform = usces_get_apply_addressform($options['system']['addressform']);
859 $name = '';
860 switch ($applyform){
861 case 'JP':
862 $address = ( empty($usces->options['address2']) ) ? $usces->options['address1'] : $usces->options['address1'] . "\n" . $usces->options['address2'];
863 $pdf->MultiCell(60, $lineheight, usces_conv_euc(__('zip code', 'usces').' '.$usces->options['zip_code']), 0, 'L');
864 $pdf->MultiCell(60, $lineheight, usces_conv_euc($address), 0, 'L');
865 break;
866
867 case 'US':
868 default:
869 $address = ( empty($usces->options['address2']) ) ? $usces->options['address1'] : $usces->options['address2'] . "\n" . $usces->options['address1'];
870 $pdf->MultiCell(60, $lineheight, usces_conv_euc($address), 0, 'L');
871 $pdf->MultiCell(60, $lineheight, usces_conv_euc(__('zip code', 'usces').' '.$usces->options['zip_code']), 0, 'L');
872 break;
873 }
874 }
875 ?>
876