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