PluginProbe
Welcart e-Commerce / 1.4.1
Welcart e-Commerce v1.4.1
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.4.1, at includes/order_print.php

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