public static function define_columns()
 {
     if (wc2_is_membersystem_point()) {
         $columns = array('cb' => '<input type="checkbox" />', 'ID' => __('Membership ID', 'wc2'), 'mem_account' => __('Account', 'wc2'), 'mem_name' => __('Name', 'wc2'), 'mem_address' => __('Address', 'wc2'), 'mem_tel' => __('Phone number', 'wc2'), 'mem_email' => __('E-mail', 'wc2'), 'mem_rank' => __('Rank', 'wc2'), 'mem_point' => __('Holdings points', 'wc2'), 'mem_registered' => __('Started date', 'wc2'));
     } else {
         $columns = array('cb' => '<input type="checkbox" />', 'ID' => __('Membership ID', 'wc2'), 'mem_account' => __('Account', 'wc2'), 'mem_name' => __('Name', 'wc2'), 'mem_address' => __('Address', 'wc2'), 'mem_tel' => __('Phone number', 'wc2'), 'mem_email' => __('E-mail', 'wc2'), 'mem_rank' => __('Rank', 'wc2'), 'mem_registered' => __('Started date', 'wc2'));
     }
     do_action('wc2_action_member_list_defaine_columns', $columns);
     return $columns;
 }
    public function member_history_rows()
    {
        $wc2_db_member = WC2_DB_Member::get_instance();
        $wc2_order = WC2_DB_Order::get_instance();
        $wc2_item = WC2_DB_Item::get_instance();
        if (is_admin()) {
            $member_id = $wc2_db_member->get_member_id();
        } else {
            if (wc2_is_login() && 0 != $_SESSION[WC2]['member']['ID']) {
                $member_id = $_SESSION[WC2]['member']['ID'];
            } else {
                return false;
            }
        }
        $member_history = $wc2_order->get_member_history($member_id);
        $colspan = wc2_is_membersystem_point() ? 9 : 7;
        $html = '<div class="history-area">
					<table>';
        if (!count($member_history)) {
            $html .= '<tr>
			<td>' . __('There is no your purchase history.', 'wc2') . '</td>
			</tr>';
        }
        foreach ($member_history as $umhs) {
            $cart = $umhs['cart'];
            $history_member_head = '<tr>
				<th class="historyrow">' . __('Order number', 'wc2') . '</th>
				<th class="historyrow">' . __('Order status', 'wc2') . '</th>
				<th class="historyrow">' . __('Purchase date', 'wc2') . '</th>
				<th class="historyrow">' . __('Purchase amount', 'wc2') . '</th>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<th class="historyrow">' . __('Used points', 'wc2') . '</th>';
            }
            $history_member_head .= '<th class="historyrow">' . apply_filters('wc2_filter_discount_label', __('Discount', 'wc2'), $umhs) . '</th>
				<th class="historyrow">' . __('Shipping charges', 'wc2') . '</th>
				<th class="historyrow">' . apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2')) . '</th>
				<th class="historyrow">' . __('Consumption tax', 'wc2') . '</th>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<th class="historyrow">' . __('Acquired points', 'wc2') . '</th>';
            }
            $history_member_head .= '</tr>
				<tr>
				<td class="rightnum"><a href="' . WC2_ADMIN_URL . '?page=wc2_order&action=edit&target=' . $umhs['ID'] . '">' . $umhs['dec_order_id'] . '</a></td>
				<td class="aleft">' . wc2_get_order_status_name($umhs['order_status']) . '</td>
				<td class="date">' . $umhs['order_date'] . '</td>
				<td class="rightnum">' . wc2_crform($umhs['item_total_price'] - $umhs['usedpoint'] + $umhs['discount'] + $umhs['shipping_charge'] + $umhs['cod_fee'] + $umhs['tax'], true, false) . '</td>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<td class="rightnum">' . number_format($umhs['usedpoint']) . '</td>';
            }
            $history_member_head .= '<td class="rightnum">' . wc2_crform($umhs['discount'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['shipping_charge'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['cod_fee'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['tax'], true, false) . '</td>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<td class="rightnum">' . number_format($umhs['getpoint']) . '</td>';
            }
            $history_member_head .= '</tr>';
            $html .= apply_filters('wc2_filter_history_member_head', $history_member_head, $umhs);
            $html .= apply_filters('wc2_filter_member_history_header', NULL, $umhs);
            $html .= '<tr>
				<td class="retail" colspan="' . $colspan . '">
					<table id="retail_table_' . $umhs['ID'] . '" class="retail">';
            $history_cart_head = '<tr>
					<th scope="row" class="num">No.</th>
					<th class="thumbnail">&nbsp;</th>
					<th>' . __('Items', 'wc2') . '</th>
					<th class="price ">' . __('Unit price', 'wc2') . '(' . wc2_crcode() . ')' . '</th>
					<th class="quantity">' . __('Quantity', 'wc2') . '</th>
					<th class="subtotal">' . __('Amount', 'wc2') . '(' . wc2_crcode() . ')' . '</th>
					</tr>';
            $html .= apply_filters('wc2_filter_history_cart_head', $history_cart_head, $umhs);
            $i = 1;
            foreach ($cart as $cart_row) {
                $ordercart_id = $cart_row['cart_id'];
                $post_id = $cart_row['post_id'];
                $item_id = $cart_row['item_id'];
                $sku_id = $cart_row['sku_id'];
                $quantity = $cart_row['quantity'];
                $options = isset($cart_row['options']) ? $cart_row['options'] : '';
                //$options = wc2_get_ordercart_meta_value( 'option', $ordercart_id );
                //$options = wc2_get_ordercart_meta( 'option', $ordercart_id );
                $item_name = $cart_row['item_name'];
                $item_code = $cart_row['item_code'];
                $sku_name = $cart_row['sku_name'];
                $sku_code = $cart_row['sku_code'];
                $cart_item_name = wc2_get_cart_item_name($item_name, $item_code, $sku_name, $sku_code);
                $skuPrice = $cart_row['price'];
                $pictid = (int) $wc2_item->get_mainpictid($item_code);
                $optstr = '';
                if (is_array($options) && count($options) > 0) {
                    $optstr = '';
                    foreach ($options as $key => $value) {
                        if (!empty($key)) {
                            $key = urldecode($key);
                            $value = maybe_unserialize($value);
                            if (is_array($value)) {
                                $c = '';
                                $optstr .= esc_html($key) . ' : ';
                                foreach ($value as $v) {
                                    $optstr .= $c . nl2br(esc_html(urldecode($v)));
                                    $c = ', ';
                                }
                                $optstr .= "<br />\n";
                            } else {
                                $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
                            }
                        }
                    }
                    $optstr = apply_filters('wc2_filter_option_history', $optstr, $options);
                }
                $optstr = apply_filters('wc2_filter_option_info_history', $optstr, $umhs, $cart_row, $i);
                $permalink = apply_filters('wc2_filter_link_item_history', get_permalink($post_id), $cart_row);
                $history_cart_row = '<tr>
					<td>' . $i . '</td>
					<td>';
                if ($pictid) {
                    $cart_thumbnail = '<a href="' . esc_url($permalink) . '">' . wp_get_attachment_image($pictid, array(60, 60), true) . '</a>';
                } else {
                    $cart_thumbnail = '<p>' . wc2_no_image() . '</p>';
                }
                $history_cart_row .= apply_filters('wc2_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
                $history_cart_row .= '</td>
					<td class="aleft"><a href="' . esc_url($permalink) . '">' . esc_html($cart_item_name) . '<br />' . $optstr . '</a>' . apply_filters('wc2_filter_history_item_name', NULL, $umhs, $cart_row, $i) . '</td>
					<td class="rightnum">' . wc2_crform($skuPrice, true, false) . '</td>
					<td class="rightnum">' . number_format($cart_row['quantity']) . '</td>
					<td class="rightnum">' . wc2_crform($skuPrice * $cart_row['quantity'], true, false) . '</td>
					</tr>';
                $materials = compact('cart_thumbnail', 'post_id', 'pictid', 'cart_item_name', 'optstr');
                $html .= apply_filters('wc2_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i, $materials);
                $i++;
            }
            $html .= '</table>
				</td>
				</tr>';
        }
        $html .= '</table>
		</div>';
        $html = apply_filters('wc2_filter_member_history_rows', $html, $member_id, $member_history, $colspan);
        return $html;
    }
Exemple #3
0
function wc2_cart_confirm_table( $slug = '' ) {
	$wc2_cart = WC2_Cart::get_instance( $slug );
	$cart = $wc2_cart->get_cart( $slug );
	$cart_num = count($cart);
	$entry_data = wc2_get_entry();
	$num = 0;

	ob_start();
?>
	<table class="cart-table">
		<thead>
		<tr>
<?php
	$cart_header = '
			<th scope="row" class="num">No.</th>
			<th class="thumbnail">&nbsp;&nbsp;</th>
			<th class="name">'.__('Items','wc2').'</th>
			<th class="price">'.__('Unit price','wc2').'</th>
			<th class="quantity">'.__('Quantity','wc2').'</th>
			<th class="subtotal">'.__('Amount','wc2').'</th>';
	$cart_header = apply_filters( 'wc2_filter_cart_confirm_header', $cart_header, $cart, $slug );
	echo $cart_header;
?>
		</tr>
		</thead>
		<tbody>
	<?php foreach( $cart as $idx => $row ): ?>
		<tr>
<?php
			$post_id = $row['post_id'];
			$item_id = $row['item_id'];
			$item_name = $row['item_name'];
			$item_code = $row['item_code'];
			$sku_name = $row['sku_name'];
			$sku_code = $row['sku_code'];
			$sku_id = $row['sku_id'];
			$quantity = $row['quantity'];
			$price = $row['price'];
			$subtotal = $row['quantity'] * $row['price'];

			//$item_sku_data = wc2_get_item_sku_data( $item_id, $sku_id );
			//$stock_status = $item_sku_data['stock_status'];
			//$stock = $item_sku_data['sku_stock'];
			$pictid = wc2_get_mainpictid( $item_code );
			$cart_thumbnail = ( !empty($pictid ) ) ? wc2_the_item_image( 0, 60, 60, $post_id ) : wc2_no_image();
			$cart_thumbnail = apply_filters( 'wc2_filter_cart_confirm_row_thumbnail', $cart_thumbnail, $post_id, $pictid, $idx, $row, $slug );

			$cart_item_name = wc2_get_cart_item_name( $item_name, $item_code, $sku_name, $sku_code );
			$cart_options = '';
			$cart_options = apply_filters( 'wc2_filter_cart_confirm_row_options', $cart_options, $idx, $row, $slug );

			$num++;
			$cart_row = '
			<td class="num">'.$num.'</td>
			<td class="thumbnail">'.$cart_thumbnail.'</td>
			<td class="name">'.$cart_item_name.$cart_options.'</td>
			<td class="price">'.wc2_crform( $price, false, false ).'</td>
			<td class="quantity">'.wc2_crform( $quantity, false, false ).'</td>
			<td class="subtotal">'.wc2_crform( $subtotal, false, false ).'</td>';
			$cart_row = apply_filters( 'wc2_filter_cart_confirm_row', $cart_row, $idx, $row );
			echo $cart_row;
?>
		</tr>
	<?php endforeach; ?>
		</tbody>
		<tfoot>
		<tr>
			<th colspan="5"><?php _e('Total amount of items', 'wc2'); ?></th>
			<th class="total-items-price"><?php wc2_crform_e( $entry_data['order']['item_total_price'], true, false ); ?></th>
		</tr>
<?php if( !empty($entry_data['order']['discount']) ) : ?>
		<tr>
			<td colspan="5"><?php echo apply_filters( 'wc2_filter_discount_label', __('Discount', 'wc2') ); ?></td>
			<td class="discount"><?php wc2_crform_e($entry_data['order']['discount'], true, false); ?></td>
		</tr>
<?php endif; ?>
<?php if( 0.00 < (float)$entry_data['order']['tax'] && 'products' == wc2_get_tax_target() ) : ?>
		<tr>
			<td colspan="5"><?php wc2_tax_label_e(); ?></td>
			<td class="tax"><?php wc2_tax_e( $entry_data['order'] ) ?></td>
		</tr>
<?php endif; ?>
		<tr>
			<td colspan="5"><?php _e('Shipping charges', 'wc2'); ?></td>
			<td class="aright"><?php wc2_crform_e( $entry_data['order']['shipping_charge'], true, false ); ?></td>
		</tr>
<?php if( !empty($entry_data['order']['cod_fee']) ) : ?>
		<tr>
			<td colspan="5"><?php echo apply_filters( 'wc2_filter_cod_label', __('COD fee', 'wc2') ); ?></td>
			<td class="aright"><?php wc2_crform_e( $entry_data['order']['cod_fee'], true, false ); ?></td>
		</tr>
<?php endif; ?>
<?php if( 0.00 < (float)$entry_data['order']['tax'] && 'all' == wc2_get_tax_target() ) : ?>
		<tr>
			<td colspan="5"><?php wc2_tax_label_e(); ?></td>
			<td class="tax"><?php wc2_tax_e( $entry_data['order'] ) ?></td>
		</tr>
<?php endif; ?>
<?php if( wc2_is_membersystem_state() && wc2_is_membersystem_point() && !empty($entry_data['order']['usedpoint']) ) : ?>
		<tr>
			<td colspan="5"><?php _e('Used points', 'wc2'); ?></td>
			<td class="usedpoint"><?php echo number_format( $entry_data['order']['usedpoint'] ); ?></td>
		</tr>
<?php endif; ?>
		<tr>
			<th colspan="5"><?php _e('Total amount', 'wc2'); ?></th>
			<th class="total_price"><?php wc2_crform_e( $entry_data['order']['total_price'], true, false ); ?></th>
		</tr>
		</tfoot>
	</table>
<?php if( wc2_is_membersystem_state() && wc2_is_membersystem_point() &&  wc2_is_login() ) : 
		$member_id = wc2_memberinfo( 'ID' );
		$point = wc2_get_member_data_value( $member_id, $key ); ?>
	<form id="cart-form-confirm-point" action="<?php wc2_cart_url_e( 'point' ); ?>" method="post">
	<table id="point-table">
		<tr>
			<td><?php _e('Current holdings points', 'wc2'); ?></td>
			<td><span class="point"><?php echo $point; ?></span><?php _e('Points', 'wc2'); ?></td>
		</tr>
		<tr>
			<td><?php _e('Point to use', 'wc2'); ?></td>
			<td><input name="offer[usedpoint]" class="used_point" type="text" value="<?php esc_attr_e($entry_data['order']['usedpoint']); ?>" /><?php _e('Points', 'wc2'); ?></td>
		</tr>
			<tr>
			<td colspan="2"><input name="use_point" type="button" class="use_point_button" value="<?php _e('Use the points', 'wc2'); ?>" /></td>
		</tr>
	</table>
	<?php do_action( 'wc2_action_confirm_point_page_form_inside' ); ?>
	</form>
	<?php do_action( 'wc2_action_confirm_point_page_form_outside' ); ?>
<?php endif; ?>
	<?php do_action( 'wc2_action_confirm_cart_footer' ); ?>
<?php
	$html = ob_get_contents();
	ob_end_clean();
	$html = apply_filters( 'wc2_filter_cart_confirm_table', $html, $slug );
	return $html;
}
Exemple #4
0
	/**
	 * Shipping destination check
	 *
	 */
	public function delivery_process() {
		wc2_set_entry();
		$mes = $this->stock_check();
		if( 0 < count($mes) ) {
			foreach( $mes as $error )
				$this->set_error( $error, 'delivery_process' );
			$this->current_page_type = 'cart';
			$this->current_page = 'top';
			$this->page_redirect();
		}

		$mes = $this->delivery_check();
		if( 0 < count($mes) ) {
			foreach( $mes as $error )
				$this->set_error( $error, 'delivery_process' );
			$this->current_page_type = 'cart';
			$this->current_page = 'delivery';
			$this->page_redirect();
		}

		wc2_set_order_price();

		if( wc2_is_membersystem_state() && wc2_is_membersystem_point() && $this->is_member_logged_in() ) {
			$mem_point = wc2_get_member_data_value( $_SESSION[WC2]['member']['ID'], MEMBER_POINT );
			$_SESSION[WC2]['member']['point'] = $mem_point;
		}
	}
Exemple #5
0
?>
" />
							<input name="order_id" id="order_id" type="hidden" value="<?php 
esc_attr_e($order_id);
?>
" />
							<input name="member_id" id="member_id" type="hidden" value="<?php 
esc_attr_e($data[ORDER_MEMBER_ID]);
?>
" />
							<input name="cart_row" id="cart_row" type="hidden" value="<?php 
echo $cart_row;
?>
" />
							<?php 
if (wc2_is_membersystem_state() && wc2_is_membersystem_point()) {
    ?>
							<input name="old_usedpoint" type="hidden" value="<?php 
    echo $usedpoint;
    ?>
" />
							<input name="old_getpoint" type="hidden" value="<?php 
    echo $getpoint;
    ?>
" />
							<?php 
} else {
    ?>
							<input name="offer[usedpoint]" id="usedpoint" type="hidden" value="0" />
							<input name="offer[getpoint]" id="getpoint" type="hidden" value="0" />
							<?php 
 function acting_get_point($order_id, $add = true)
 {
     global $wpdb;
     if (!apply_filters('wc2_action_acting_getpoint_switch', true, $order_id, $add)) {
         return;
     }
     $general = wc2_get_option('general');
     if ($general['point_assign'] != 0) {
         if (wc2_is_membersystem_state() && wc2_is_membersystem_point()) {
             $query = $wpdb->prepare("SELECT member_id, getpoint FROM {$this->order_table} WHERE ID = %d", $order_id);
             $row = $wpdb->get_row($query, ARRAY_A);
             $member_id = $row[ORDER_MEMBER_ID];
             $getpoint = $row[ORDER_GETPOINT];
             if (!empty($member_id) && 0 < $getpoint) {
                 $calc = $add ? '+' : '-';
                 $query = $wpdb->prepare("UPDATE {$this->member_table} SET mem_point = ( mem_point " . $calc . " %d ) WHERE ID = %d", $getpoint, $member_id);
                 $wpdb->query($query);
                 if (array_key_exists('point', $_SESSION[WC2]['member'])) {
                     $query = $wpdb->prepare("SELECT mem_point FROM {$this->member_table} WHERE ID = %d", $member_id);
                     $point = $wpdb->get_var($query);
                     $_SESSION[WC2]['member']['point'] = $point;
                 }
             }
         }
     }
     do_action('wc2_action_acting_getpoint', $order_id, $add);
 }
Exemple #7
0
 public function pdfSetFooter($pdf, $data)
 {
     global $wc2;
     $wc2_options = wc2_get_option();
     $font = $this->font;
     $border = 0;
     list($fontsize, $lineheight, $linetop) = $this->set_font_size(9);
     $pdf->SetFont($font, '', $fontsize);
     // Body label
     $pdf->SetXY(15.5, 94.90000000000001);
     $pdf->MultiCell(87.8, $lineheight, $this->conv_enc(__('Item name', 'wc2')), $border, 'C');
     $pdf->SetXY(103.7, 94.90000000000001);
     $pdf->MultiCell(11.4, $lineheight, $this->conv_enc(__('Quantity', 'wc2')), $border, 'C');
     $pdf->SetXY(115.8, 94.90000000000001);
     $pdf->MultiCell(11.0, $lineheight, $this->conv_enc(__('Unit', 'wc2')), $border, 'C');
     $pdf->SetXY(127.2, 94.90000000000001);
     $pdf->MultiCell(15.0, $lineheight, $this->conv_enc(__('Price', 'wc2')), $border, 'C');
     $pdf->SetXY(142.9, 94.90000000000001);
     $pdf->MultiCell(22.4, $lineheight, $this->conv_enc(__('Amount', 'wc2') . '(' . __(wc2_crcode(), 'wc2') . ')'), $border, 'C');
     // Footer label
     $labeldata = array('order_condition' => $data['order_condition'], 'order_item_total_price' => $data['item_total_price'], 'order_discount' => $data['discount'], 'order_shipping_charge' => $data['shipping_charge'], 'order_cod_fee' => $data['cod_fee']);
     $pdf->SetXY(104.3, 198.8);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc(__('Total amount of items', 'wc2')), $border, 'C');
     $pdf->SetXY(104.3, 204.8);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc(apply_filters('wc2_filter_discount_label', __('Discount', 'wc2'), $data)), $border, 'C');
     if ('products' == wc2_get_tax_target()) {
         $data_1 = apply_filters('wc2_filter_tax_label', wc2_tax_label($labeldata));
         $data_2 = apply_filters('wc2_filter_shipping_label', __('Shipping charges', 'wc2'));
         $data_3 = apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2'));
     } else {
         $data_1 = apply_filters('wc2_filter_shipping_label', __('Shipping charges', 'wc2'));
         $data_2 = apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2'));
         $data_3 = apply_filters('wc2_filter_tax_label', wc2_tax_label($labeldata));
     }
     $pdf->SetXY(104.3, 210.8);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc($data_1), $border, 'C');
     $pdf->SetXY(104.3, 216.7);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc($data_2), $border, 'C');
     $pdf->SetXY(104.3, 222.7);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc($data_3), $border, 'C');
     if (wc2_is_membersystem_point()) {
         $pdf->SetXY(104.3, 228.6);
         $pdf->MultiCell(37.7, $lineheight, $this->conv_enc(apply_filters('wc2_filter_point_label', __('Used points', 'wc2'))), $border, 'C');
         $pdf->SetXY(104.3, 235.8);
         $pdf->MultiCell(37.77, $lineheight, $this->conv_enc(__('Total Amount', 'wc2')), $border, 'C');
     } else {
         $pdf->SetXY(104.3, 235.8);
         $pdf->MultiCell(37.77, $lineheight * 2, $this->conv_enc(__('Total Amount', 'wc2')), $border, 'C');
     }
     list($fontsize, $lineheight, $linetop) = $this->set_font_size(8);
     $pdf->SetFont($font, '', $fontsize);
     // Footer value
     $payment = wc2_get_payment($data['payment_method']);
     $transfers = apply_filters('wc2_filter_pdf_transfer', array('BT'), $data);
     if ('invoice' == $_REQUEST['type'] && in_array($payment['settlement'], $transfers)) {
         $transferee = __('Transfer', 'wc2') . " : \r\n";
         $transferee .= wc2_get_option('transferee_info') . "\r\n";
         $note_text = apply_filters('wc2_filter_mail_transferee', $transferee, $data, 'pdf', $payment);
     } else {
         $note_text = $data['note'];
     }
     $pdf->SetXY(16.1, 198.8);
     $pdf->MultiCell(86.59999999999999, $lineheight, $this->conv_enc(apply_filters('wc2_filter_pdf_note', $note_text, $data, $_REQUEST['type'])), $border, 'J');
     list($fontsize, $lineheight, $linetop) = $this->set_font_size(9);
     $pdf->SetFont($font, '', $fontsize);
     $pdf->SetXY(142.9, 198.8);
     $total_price = $data['item_total_price'] - $data['usedpoint'] + $data['discount'] + $data['shipping_charge'] + $data['cod_fee'] + $data['tax'];
     $pdf->MultiCell(22.6, $lineheight, wc2_get_currency($data['item_total_price']), $border, 'R');
     $materials = array('total_price' => $data['item_total_price'], 'discount' => $data['discount'], 'shipping_charge' => $data['shipping_charge'], 'cod_fee' => $data['cod_fee']);
     if ('include' == $wc2_options['general']['tax_mode']) {
         $tax = '(' . wc2_internal_tax($materials) . ')';
     } else {
         $tax = wc2_get_currency($data['tax']);
     }
     if ('products' == wc2_get_tax_target()) {
         $datav_1 = apply_filters('wc2_filter_tax_value', $tax, $data);
         $datav_2 = apply_filters('wc2_filter_shipping_value', wc2_get_currency($data['shipping_charge']), $data);
         $datav_3 = apply_filters('wc2_filter_cod_value', wc2_get_currency($data['cod_fee']), $data);
     } else {
         $datav_1 = apply_filters('wc2_filter_shipping_value', wc2_get_currency($data['shipping_charge']), $data);
         $datav_2 = apply_filters('wc2_filter_cod_value', wc2_get_currency($data['cod_fee']), $data);
         $datav_3 = apply_filters('wc2_filter_tax_value', $tax, $data);
     }
     $pdf->SetXY(142.9, 204.8);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc(apply_filters('wc2_filter_discount_value', wc2_get_currency($data['discount']), $data)), $border, 'R');
     $pdf->SetXY(142.9, 210.8);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc($datav_1), $border, 'R');
     $pdf->SetXY(142.9, 216.7);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc($datav_2), $border, 'R');
     $pdf->SetXY(142.9, 222.7);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc($datav_3), $border, 'R');
     if (wc2_is_membersystem_point()) {
         $pdf->SetXY(142.9, 228.6);
         $pdf->MultiCell(22.6, $lineheight, $this->conv_enc(apply_filters('wc2_filter_point_value', wc2_get_currency($data['usedpoint']), $data)), $border, 'R');
         $pdf->SetXY(142.9, 235.8);
         $pdf->MultiCell(22.67, $lineheight, $this->conv_enc(wc2_get_currency($total_price)), $border, 'R');
     } else {
         $pdf->SetXY(142.9, 235.8);
         $pdf->MultiCell(22.67, $lineheight, $this->conv_enc(wc2_get_currency($total_price)), $border, 'R');
     }
     do_action('wc2_action_order_print_footer', $pdf, $data);
 }
    public function admin_page_scripts()
    {
        if (!isset($this->plugin_screen_hook_suffix)) {
            return;
        }
        $screen = get_current_screen();
        if ($this->plugin_screen_hook_suffix != $screen->id) {
            return;
        }
        $delivery_options = wc2_get_option('delivery');
        $delivery_method = isset($delivery_options['delivery_method']) ? $delivery_options['delivery_method'] : array();
        $phrase = wc2_get_option('phrase');
        ?>
<script type="text/javascript">
jQuery(function($) {
<?php 
        //受注リスト画面
        if ($this->page == 'order-list') {
            $startdate = !empty($_SESSION[WC2][$this->page]['startdate']) ? ', setDate: "' . $_SESSION[WC2][$this->page]['startdate'] . '", defaultDate: "' . $_SESSION[WC2][$this->page]['startdate'] . '"' : '';
            $enddate = !empty($_SESSION[WC2][$this->page]['enddate']) ? ', setDate: "' . $_SESSION[WC2][$this->page]['enddate'] . '", defaultDate: "' . $_SESSION[WC2][$this->page]['enddate'] . '"' : '';
            ?>
	//$("#navi-box").css("display", "none");
	//$("#navi-box-link").click(function() {
	//	$("#navi-box").toggle();
	//});

	//batch
	$(".action").click( function() {
		var idname = $(this).attr("id");
		var pos = ( idname.substr(-1,1) == "2" ) ? "bottom" : "top";
		if( "-1" == $("#bulk-action-selector-"+pos+" option:selected").val() ){
			alert("操作を選択してください。");
			return false;
		}
		if( "delete_batch" == $("#bulk-action-selector-"+pos+" option:selected").val() ) {
			if( $("input[name='order_tag[]']:checked").length > 0 ) {
				if( !confirm("チェックしたデータを削除します。よろしいですか?") ) {
					return false;
				}
			} else {
				alert("削除するデータをチェックしてください。");
				return false;
			}
		}
	});

	//delete
	$(".delete-order").click( function() {
		var delete_id = $(this).attr("id").replace("delete-", "");
		if( !confirm("注文番号 " + delete_id + " を削除します。よろしいですか?") ) {
			return false;
		}
	});

	//search
	$("#search-in").click( function() {
		var search_column = $("#search-column option:selected").val();
		switch( search_column ) {
		case "none":
			alert("検索項目を選択してください。");
			return false;
			break;
		case "order_status":
		case "receipt_status":
		case "order_type":
			break;
		default:
			if( "" == $("#search-word-keyword").val() ) {
				alert("検索するキーワードを入力してください。");
				return false;
			}
		}
	});

	$("#search-column").change( function() {
		var search_column = $("#search-column option:selected").val();
		orderList.selectSearchColumn(search_column);
	});

	//受注明細データ出力
	$("#dlOrderDetailListDialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 400,
		width: 700,
		resizable: true,
		modal: true,
		buttons: {
			"<?php 
            _e('Close');
            ?>
": function() {
				$(this).dialog("close");
			}
		},
		close: function() {
		}
	});

	$("#dl-detail").click(function() {
<?php 
            ob_start();
            ?>
		var search_column = $("#search-column option:selected").val();
		var search_word = "";
		switch( search_column ) {
		case "order_status":
			search_word = $("#search-word-order_status option:selected").val();
			break;
		case "receipt_status":
			search_word = $("#search-word-receipt_status option:selected").val();
			break;
		case "order_type":
			search_word = $("#search-word-order_type option:selected").val();
			break;
		default:
			search_word = $("#search-word-keyword").val();
		}
		var args = "&search[column]="+search_column
			+"&search[word]="+search_word
			+"&search[period]="+$("#search-period option:selected").val()
			+"&search[startdate]="+$("#startdate").val()
			+"&search[enddate]="+$("#enddate").val();
<?php 
            $admin_order_detail_list_args_script = ob_get_contents();
            ob_end_clean();
            echo apply_filters('wc2_filter_admin_order_detail_list_args_script', $admin_order_detail_list_args_script);
            ?>
		$(".check-detail").each(function(i) {
			if( $(this).attr("checked") ) {
				args += "&check["+$(this).val()+"]=on";
			}
		});
		location.href = "<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=dl_orderdetail_list&noheader=true"+args+"&wc2_nonce=<?php 
            echo wp_create_nonce('wc2_dl_orderdetail_list');
            ?>
";
	});

	$("#dl-orderdetail-list").click(function() {
		$("#dlOrderDetailListDialog").dialog("open");
	});

	//受注データ出力
	$("#dlOrderListDialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 600,
		width: 700,
		resizable: true,
		modal: true,
		buttons: {
			"<?php 
            _e('Close');
            ?>
": function() {
				$(this).dialog("close");
			}
		},
		close: function() {
		}
	});

	$("#dl-order").click(function() {
<?php 
            ob_start();
            ?>
		var search_column = $("#search-column option:selected").val();
		var search_word = "";
		switch( search_column ) {
		case "order_status":
			search_word = $("#search-word-order_status option:selected").val();
			break;
		case "receipt_status":
			search_word = $("#search-word-receipt_status option:selected").val();
			break;
		case "order_type":
			search_word = $("#search-word-order_type option:selected").val();
			break;
		default:
			search_word = $("#search-word-keyword").val();
		}
		var args = "&search[column]="+search_column
			+"&search[word]="+search_word
			+"&search[period]="+$("#search-period option:selected").val()
			+"&search[startdate]="+$("#startdate").val()
			+"&search[enddate]="+$("#enddate").val();
<?php 
            $admin_order_list_args_script = ob_get_contents();
            ob_end_clean();
            echo apply_filters('wc2_filter_admin_order_list_args_script', $admin_order_list_args_script);
            ?>
		$(".check-order").each(function(i) {
			if( $(this).attr("checked") ) {
				args += "&check["+$(this).val()+"]=on";
			}
		});
		location.href = "<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=dl_order_list&noheader=true"+args+"&wc2_nonce=<?php 
            echo wp_create_nonce('wc2_dl_order_list');
            ?>
";
	});

	$("#dl-order-list").click(function() {
		$("#dlOrderListDialog").dialog("open");
	});

	$("#startdate").datepicker({
		dateFormat: "yy-mm-dd"<?php 
            echo $startdate;
            ?>
	});

	$("#enddate").datepicker({
		dateFormat: "yy-mm-dd"<?php 
            echo $enddate;
            ?>
	});

	$("#search-period").change(function() {
		var period = $("#search-period option:selected").val();
		if( period == 5 ) {
			$("#period-specified").css("display", "inline-block");
		} else {
			$("#period-specified").css("display", "none");
		}
	});
	//$("#search-period").triggerHandler("change");

	orderList = {
		selectSearchColumn : function( search_column ) {
			switch( search_column ) {
			case "order_status":
				$("#search-label").css("display", "none");
				$("#search-word-keyword").css("display", "none");
				$("#search-word-order_status").css("display", "inline-block");
				$("#search-word-receipt_status").css("display", "none");
				$("#search-word-order_type").css("display", "none");
				break;
			case "receipt_status":
				$("#search-label").css("display", "none");
				$("#search-word-keyword").css("display", "none");
				$("#search-word-order_status").css("display", "none");
				$("#search-word-receipt_status").css("display", "inline-block");
				$("#search-word-order_type").css("display", "none");
				break;
			case "order_type":
				$("#search-label").css("display", "none");
				$("#search-word-keyword").css("display", "none");
				$("#search-word-order_status").css("display", "none");
				$("#search-word-receipt_status").css("display", "none");
				$("#search-word-order_type").css("display", "inline-block");
				break;
			default:
				$("#search-label").css("display", "inline-block");
				$("#search-word-keyword").css("display", "inline-block");
				$("#search-word-order_status").css("display", "none");
				$("#search-word-receipt_status").css("display", "none");
				$("#search-word-order_type").css("display", "none");
			}
		}
	};
<?php 
            do_action('wc2_action_admin_order_list_scripts');
            //受注データ編集画面
        } elseif ($this->page == 'order-post') {
            $data = wc2_get_the_order_data();
            //*** LI CUSTOMIZE >>>
            if (empty($data)) {
                $data = $this->get_post_data();
            }
            //*** LI CUSTOMIZE <<<
            ?>
	var selected_delivery_time = "<?php 
            esc_html_e(isset($data['delivery_time']) ? $data['delivery_time'] : '');
            ?>
";
	var delivery_time = [];
<?php 
            foreach ((array) $delivery_method as $dmid => $dm) {
                $lines = explode("\n", $dm['time']);
                ?>
	delivery_time[<?php 
                echo $dm['id'];
                ?>
] = [];
<?php 
                foreach ((array) $lines as $line) {
                    if (trim($line) != '') {
                        ?>
	delivery_time[<?php 
                        echo $dm['id'];
                        ?>
].push("<?php 
                        echo trim($line);
                        ?>
");
<?php 
                    }
                }
            }
            ?>
	$("#addItemDialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 500,
		width: 700,
		resizable: true,
		modal: true,
		appendTo:"#dialog-parent",
		close: function() {
			$("#additem-category").val("-1");
			$("#additem-form").html("");
			$("#additem-select").val("");
		}
	});

	$("#additem").click(function() {
		if( $("#order_id").val() == "" ) {
			alert("<?php 
            _e('「設定を更新」を押して注文Noを確定してください。', 'wc2');
            ?>
");
			return;
		}
		$("#addItemDialog").dialog("open");
	});

	$(document).on( "change", "#additem-category", function() {
		orderItem.getSelectItem( $(this).val() );
	});

	$(document).on( "change", "#additem-select", function() {
		orderItem.getItem( $(this).val() );
	});

	$("#getitem").click(function() {
		if( $("#additem-code").val() == "" ) return;
		orderItem.getItem( encodeURIComponent($("#additem-code").val()) );
	});

	$(document).on( "change", "#additem-code", function() {
		orderItem.getItem( $(this).val() );
	});

//*** LI CUSTOMIZE >>>
	//$("#delivery_method_select").change(function() {
	$(document).on( "change", "#delivery_method_select", function() {
//*** LI CUSTOMIZE <<<
		$("#delivery_name").val($("#delivery_method_select option:selected").text());
		orderFunc.makeDeliveryTime($("#delivery_method_select option:selected").val());
//*** LI CUSTOMIZE >>>
		var p = $("input[name*='sku_price']");
		var q = $("input[name*='quantity']");
		var ci = $("input[name*='cart_id']");
		var cart_ids = "";
		var prices = "";
		var quantities = "";
		for( var i = 0; i < p.length; i++ ) {
			cart_ids += $(ci[i]).val()+"<?php 
            echo WC2_SPLIT;
            ?>
";
			prices += parseFloat($(p[i]).val())+"<?php 
            echo WC2_SPLIT;
            ?>
";
			quantities += $(q[i]).val()+"<?php 
            echo WC2_SPLIT;
            ?>
";
		}

		$.ajax({
			url: ajaxurl,
			type: "POST",
			data: {
				action: "order_edit_ajax",
				mode: "get-shipping-charge",
				delivery_method: $("#delivery_method_select option:selected").val(),
				delivery_pref: $("#delivery_pref option:selected").val(),
				order_id: $("#order_id").val(),
				cart_ids: cart_ids,
				prices: prices,
				quantities: quantities
			}
		}).done(function( retVal, dataType ) {
			var data = retVal.split("<?php 
            echo WC2_SPLIT;
            ?>
");
			if( data[0] == "OK" ) {
				$("#shipping_charge").val(data[1]);
				orderFunc.sumPrice(null);
			}
		}).fail(function( retVal ) {
		});
		return false;
//*** LI CUSTOMIZE <<<
	});

	$("#payment_method_select").change(function() {
		$("#payment_name").val($("#payment_method_select option:selected").text());
	});

	$(document).on("click", ".additem-sku", function() {
		var idname = $(this).attr("id");
		var ids = idname.split("-");
		var id = ids[2];
		var additem = $("#additem-item_id-"+id).val();
		var addsku = $("#additem-sku_id-"+id).val();
		var addquantity = $("#additem-quantity-"+id).val();
		orderItem.add2cart( additem, addsku, addquantity );
	});

	$("#sendMailDialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 650,
		width: 700,
		resizable: true,
		modal: true,
		buttons: {
			"<?php 
            _e('Close');
            ?>
": function() {
				$(this).dialog("close");
			}
		},
		appendTo:"#dialog-parent",
		close: function() {
			$("#sendmail-message").html("");
			$("#sendmail-address").val("");
		}
	});

	$("#sendMailAlert").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 200,
		width: 200,
		resizable: false,
		appendTo: "#sendMailDialog",
		modal: false
	});

	$("#sendmail").click(function() {
		orderMail.sendMail();
	});

	$("#mail-completion").click(function() {
		orderMail.getMailMessage("mail_completion");
		$("#sendmail-address").val($("input[name='customer[email]']").val());
		$("#sendmail-name").val($("input[name='customer[name1]']").val()+$("input[name='customer[name2]']").val());
		$("#sendmail-subject").val("<?php 
            echo esc_js(apply_filters('wc2_filter_admin_order_mail_subject', $phrase['title']['completionmail'], $data, 'mail_completion'));
            ?>
");
		$("#mail-checked").val("mail_completion");
		$("#sendMailDialog").dialog("option", "title", "<?php 
            _e('発送完了メール', 'wc2');
            ?>
");
		$("#sendMailDialog").dialog("open");
	});

	$("#mail-order").click(function() {
		orderMail.getMailMessage("mail_order");
		$("#sendmail-address").val($("input[name='customer[email]']").val());
		$("#sendmail-name").val($("input[name='customer[name1]']").val()+$("input[name='customer[name2]']").val());
		$("#sendmail-subject").val("<?php 
            echo esc_js(apply_filters('wc2_filter_admin_order_mail_subject', $phrase['title']['ordermail'], $data, 'mail_order'));
            ?>
");
		$("#mail-checked").val("mail_order");
		$("#sendMailDialog").dialog("option", "title", "<?php 
            _e('注文確認メール', 'wc2');
            ?>
");
		$("#sendMailDialog").dialog("open");
	});

	$("#mail-change").click(function() {
		orderMail.getMailMessage("mail_change");
		$("#sendmail-address").val($("input[name='customer[email]']").val());
		$("#sendmail-name").val($("input[name='customer[name1]']").val()+$("input[name='customer[name2]']").val());
		$("#sendmail-subject").val("<?php 
            echo esc_js(apply_filters('wc2_filter_admin_order_mail_subject', $phrase['title']['changemail'], $data, 'mail_change'));
            ?>
");
		$("#mail-checked").val("mail_change");
		$("#sendMailDialog").dialog("option", "title", "<?php 
            _e('変更確認メール', 'wc2');
            ?>
");
		$("#sendMailDialog").dialog("open");
	});

	$("#mail-receipt").click(function() {
		orderMail.getMailMessage("mail_receipt");
		$("#sendmail-address").val($("input[name='customer[email]']").val());
		$("#sendmail-name").val($("input[name='customer[name1]']").val()+$("input[name='customer[name2]']").val());
		$("#sendmail-subject").val("<?php 
            echo esc_js(apply_filters('wc2_filter_admin_order_mail_subject', $phrase['title']['receiptmail'], $data, 'mail_receipt'));
            ?>
");
		$("#mail-checked").val("mail_receipt");
		$("#sendMailDialog").dialog("option", "title", "<?php 
            _e('入金確認メール', 'wc2');
            ?>
");
		$("#sendMailDialog").dialog("open");
	});

	$("#mail-estimate").click(function() {
		orderMail.getMailMessage("mail_estimate");
		$("#sendmail-address").val($("input[name='customer[email]']").val());
		$("#sendmail-name").val($("input[name='customer[name1]']").val()+$("input[name='customer[name2]']").val());
		$("#sendmail-subject").val("<?php 
            echo esc_js(apply_filters('wc2_filter_admin_order_mail_subject', $phrase['title']['estimatemail'], $data, 'mail_estimate'));
            ?>
");
		$("#mail-checked").val("mail_estimate");
		$("#sendMailDialog").dialog("option", "title", "<?php 
            _e('見積メール', 'wc2');
            ?>
");
		$("#sendMailDialog").dialog("open");
	});

	$("#mail-cancel").click(function() {
		orderMail.getMailMessage("mail_cancel");
		$("#sendmail-address").val($("input[name='customer[email]']").val());
		$("#sendmail-name").val($("input[name='customer[name1]']").val()+$("input[name='customer[name2]']").val());
		$("#sendmail-subject").val("<?php 
            echo esc_js(apply_filters('wc2_filter_admin_order_mail_subject', $phrase['title']['cancelmail'], $data, 'mail_cancel'));
            ?>
");
		$("#mail-checked").val("mail_cancel");
		$("#sendMailDialog").dialog("option", "title", "<?php 
            _e('キャンセルメール', 'wc2');
            ?>
");
		$("#sendMailDialog").dialog("open");
	});

	$("#mail-other").click(function() {
		orderMail.getMailMessage("mail_other");
		$("#sendmail-address").val($("input[name='customer[email]']").val());
		$("#sendmail-name").val($("input[name='customer[name1]']").val()+$("input[name='customer[name2]']").val());
		$("#sendmail-subject").val("<?php 
            echo esc_js(apply_filters('wc2_filter_admin_order_mail_subject', $phrase['title']['othermail'], $data, 'mail_other'));
            ?>
");
		$("#mail-checked").val("mail_other");
		$("#sendMailDialog").dialog("option", "title", "<?php 
            _e('その他のメール', 'wc2');
            ?>
");
		$("#sendMailDialog").dialog("open");
	});

	$("#PDFDialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 820,
		width: 700,
		resizable: true,
		modal: true,
		appendTo: "#dialog-parent",
		buttons: {
			"<?php 
            _e('Close');
            ?>
": function() {
				$(this).dialog('close');
			}
		},
		close: function() {
			$("#new-pdf").html("");
		}
	});

	$("#print-estimate").click(function() {
		window.open('<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=estimate');
/*
		$("#new-pdf").html('<iframe src="<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=estimate" align="center" width="660" height=670" border="1" marginheight="0" marginwidth="0"></iframe>');
		$("#PDFDialog").dialog("option", "title", "<?php 
            _e('見積書印刷', 'wc2');
            ?>
");
		$("#PDFDialog").dialog("open");
*/
		orderMail.checkPost("print_estimate");
	});

	$("#print-deliveryslip").click(function() {
		window.open('<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=deliveryslip');
/*
		$("#new-pdf").html('<iframe src="<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=deliveryslip" align="center" width="660" height=670" border="1" marginheight="0" marginwidth="0"></iframe>');
		$("#PDFDialog").dialog("option", "title", "<?php 
            _e('納品書印刷', 'wc2');
            ?>
");
		$("#PDFDialog").dialog("open");
*/
		orderMail.checkPost("print_deliveryslip");
	});

	$("#print-invoice").click(function() {
		window.open('<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=invoice');
/*
		$("#new-pdf").html('<iframe src="<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=invoice" align="center" width="660" height=670" border="1" marginheight="0" marginwidth="0"></iframe>');
		$("#PDFDialog").dialog("option", "title", "<?php 
            _e('請求書印刷', 'wc2');
            ?>
");
		$("#PDFDialog").dialog("open");
*/
		orderMail.checkPost("print_invoice");
	});

	$("#print-receipt").click(function() {
		window.open('<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=receipt');
/*
		$("#new-pdf").html('<iframe src="<?php 
            echo WC2_ADMIN_URL;
            ?>
?page=wc2_order&action=pdfout_order&order_id='+$("#order_id").val()+'&type=receipt" align="center" width="660" height=670" border="1" marginheight="0" marginwidth="0"></iframe>');
		$("#PDFDialog").dialog("option", "title", "<?php 
            _e('領収書印刷', 'wc2');
            ?>
");
		$("#PDFDialog").dialog("open");
*/
		orderMail.checkPost("print_receipt");
	});

	orderItem = {
		add2cart : function( additem, addsku, addquantity ) {
			//var newoptob = $("input[name*='optNEWCode[" + additem + "][" + addsku + "]']");
			//var newoptvalue = "";
			var mes = "";
/*
			for( var n = 0; n < newoptob.length; n++ ) {
				newoptvalue = $(":input[name='itemNEWOption[" + additem + "][" + addsku + "][" + $(newoptob[n]).val() + "]']").val();
				var newoptclass = $(":input[name='itemNEWOption[" + additem + "][" + addsku + "][" + $(newoptob[n]).val() + "]']").attr("class");
				var essential = $(":input[name='optNEWEssential[" + additem + "][" + addsku + "][" + $(newoptob[n]).val() + "]']").val();
				switch(newoptclass) {
				case "iopt_select_multiple":
					var sel = 0;
					if( essential == 1 ) {
						$(":input[name='itemNEWOption[" + additem + "][" + addsku + "][" + $(newoptob[n]).val() + "]'] option:selected").each(function(idx, obj) {
							if( "<?php 
            echo WC2_UNSELECTED;
            ?>
" != $(this).val() ) {
								sel++;
							}
						});
						if( sel == 0 ) {
							mes += decodeURIComponent($(newoptob[n]).val())+"を選択してください\n";
						}
					}
					$(":input[name='itemNEWOption[" + additem + "][" + addsku + "][" + $(newoptob[n]).val() + "]'] option:selected").each(function(idx, obj) {
						if( "<?php 
            echo WC2_UNSELECTED;
            ?>
" != $(this).val() ) {
							query += "&itemOption[" + $(newoptob[n]).val() + "][" + encodeURIComponent($(this).val()) + "]="+encodeURIComponent($(this).val());
						}
					});
					break;
				case "iopt_select":
					if( essential == 1 && newoptvalue == "<?php 
            echo WC2_UNSELECTED;
            ?>
" ) {
						mes += decodeURIComponent($(newoptob[n]).val())+"を選択してください\n";
					} else {
						query += "&itemOption[" + $(newoptob[n]).val() + "]="+encodeURIComponent(newoptvalue);
					}
					break;
				case "iopt_text":
				case "iopt_textarea":
					if( essential == 1 && newoptvalue == "" ) {
						mes += decodeURIComponent($(newoptob[n]).val())+"を入力してください\n";
					} else {
						query += "&itemOption[" + $(newoptob[n]).val() + "]="+encodeURIComponent(newoptvalue);
					}
					break;
				}
			}
*/
			if( mes != '' ) {
				alert(mes);
				return;
			}

			var cart_row = $("#cart_row").val();
			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: "add2cart",
					order_id: $("#order_id").val(),
					item_id: additem,
					sku_id: addsku,
					quantity: addquantity,
//*** LI CUSTOMIZE >>>
			<?php 
            $edit_mode = isset($_REQUEST['edit_mode']) ? $_REQUEST['edit_mode'] : 'display';
            if ($edit_mode == 'update') {
                ?>
					delivery_method: $("#delivery_method_select option:selected").val(),
					delivery_pref: $("#delivery_pref option:selected").val(),
			<?php 
            } else {
                ?>
					delivery_method: $("#delivery_method_select").val(),
					delivery_pref: $('input[name="delivery[pref]"]').val(),
			<?php 
            }
            ?>
//*** LI CUSTOMIZE <<<
					cart_row: cart_row
				}
			}).done(function( retVal, dataType ) {
//*** LI CUSTOMIZE >>>
				//$("#order-cart-items").html("");
				//$("#order-cart-items").html( retVal );
				//orderFunc.sumPrice(null);
				//$("#cart_row").val(parseInt(cart_row)+1);
				var data = retVal.split("<?php 
            echo WC2_SPLIT;
            ?>
");
				if( data[0] == "OK" ) {
					$("#order-cart-items").html("");
					$("#order-cart-items").html(data[1]);
					$("#status-history tbody").html("");
					$("#status-history tbody").html(data[2]);
					orderFunc.sumPrice(null);
					$("#cart_row").val(parseInt(cart_row)+1);
				}
//*** LI CUSTOMIZE <<<
			}).fail(function( retVal ) {
			});
			return false;
		},

		getSelectItem : function( cat_id ) {
			if( cat_id == "-1" ) {
				$("#additem-select").html("");
				return false;
			}
			$("#additem-loading").html('<img src="'+WC2L10n.loading_gif+'" />');

			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: "get_select_item",
					cat_id: cat_id
				}
			}).done(function( retVal, dataType ) {
				$("#additem-loading").html("");
				$("#additem-select").html( retVal );
			}).fail(function( retVal ) {
			});
			return false;
		},

		getItem : function( item_code ) {
			if( item_code == "-1" ) {
				$("#additem-form").html("");
				return false;
			}
			$("#additem-loading").html('<img src="'+WC2L10n.loading_gif+'" />');

			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: "get_add_item",
					item_code: item_code
				}
			}).done(function( retVal, dataType ) {
				$("#additem-loading").html("");
				$("#additem-form").html( retVal );
			}).fail(function( retVal ) {
			});
			return false;
		}
	};

	orderFunc = {
		sumPrice : function( obj ) {
			if( obj != null ) {
				if( !WC2Util.checkNumMinus(obj.val()) ) {
					alert("<?php 
            _e('数値で入力してください', 'wc2');
            ?>
");
					obj.focus();
					return false;
				}
			}
			var total = 0;
			var itemtotal = <?php 
            echo apply_filters('wc2_filter_admin_order_item_total_price', 0, $data);
            ?>
;
			$("input[name*='sku_price']").each(function() {
				var idname = $(this).attr("id");
				var ids = idname.split("-");
				var id = ids[1];
//*** LI CUSTOMIZE >>>
				var round = $('input[name="meta_key['+id+'][round]"]').val();
				//var subtotal = parseFloat($(this).val()) * $("#quantity-"+id).val();
				var subtotal = LiUtil.toFixed( parseFloat($(this).val()) * $("#quantity-"+id).val(), round, 0 );
//*** LI CUSTOMIZE <<<
				$("#subtotal-"+id).html(WC2Util.addComma(subtotal+''));
				itemtotal += subtotal;
			});
			$("#item_total_price").val(itemtotal);
			$("#item-total").html(WC2Util.addComma(itemtotal+''));
			var usedpoint = $("#usedpoint").val()*1;
			var discount = parseFloat($("#discount").val());
			var shipping_charge = parseFloat($("#shipping_charge").val());
			var cod_fee = parseFloat($("#cod_fee").val());
//*** LI CUSTOMIZE >>>
			//var tax = parseFloat($("#tax").val());
			//total = itemtotal - usedpoint + discount + shipping_charge + cod_fee + tax;
			total = itemtotal - usedpoint + discount + shipping_charge + cod_fee;
//*** LI CUSTOMIZE <<<
			$("#total").html(WC2Util.addComma(total+''));
			$("#total-top").html(WC2Util.addComma(total+''));
			<?php 
            do_action('wc2_action_admin_order_total_price', $data);
            ?>
		},

		makeDeliveryTime : function(selected) {
			var option = '';
			if( selected == -1 || delivery_time[selected] == undefined || 0 == delivery_time[selected].length ) {
				option += '<option value=""><?php 
            _e('指定しない', 'wc2');
            ?>
</option>';
			} else {
				for( var i=0; i<delivery_time[selected].length; i++ ) {
					if( delivery_time[selected][i] == selected_delivery_time ) {
						option += '<option value="' + delivery_time[selected][i] + '" selected="selected">' + delivery_time[selected][i] + '</option>';
					} else {
						option += '<option value="' + delivery_time[selected][i] + '">' + delivery_time[selected][i] + '</option>';
					}
				}
			}
			$("#delivery_time_select").html(option);
		},

		getMember : function( email ) {
			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: "get_member",
					email: encodeURIComponent(email)
				}
			}).done(function( retVal, dataType ) {
				var data = retVal.split("<?php 
            echo WC2_SPLIT;
            ?>
");
				if( data[0] == "OK" ) {
					for( var i = 1; i < data.length; i++ ) {
						var value = data[i].split("=");
						if( value[0] == "member_id" ) {
							$(".member-id-value").html(value[1]);
							$("#member_id").val(value[1]);
						} else {
							$(":input[name='"+value[0]+"']").val(value[1]);
						}
					}
				} else if( data[0] == "NG" ) {
					alert("<?php 
            _e('該当する会員情報は存在しません。', 'wc2');
            ?>
");
				} else {
					alert("ERROR");
				}
			}).fail(function( retVal ) {
			});
			return false;
		},

		recalculation : function() {
<?php 
            ob_start();
            ?>
			var p = $("input[name*='sku_price']");
			var q = $("input[name*='quantity']");
			var pi = $("input[name*='postId']");
			var item_ids = "";
			var skus = "";
			var prices = "";
			var quantities = "";
			for( var i = 0; i < p.length; i++) {
				item_ids += $(pi[i]).val()+"<?php 
            echo WC2_SPLIT;
            ?>
";
				prices += parseFloat($(p[i]).val())+"<?php 
            echo WC2_SPLIT;
            ?>
";
				quantities += $(q[i]).val()+"<?php 
            echo WC2_SPLIT;
            ?>
";
			}
			var usedpoint = $("#usedpoint").val()*1;
			var shipping_charge = parseFloat($("#shipping_charge").val());
			var cod_fee = parseFloat($("#cod_fee").val());

			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: "recalculation",
					order_id: $("#order_id").val(),
					member_id: $("#member_id").val(),
					item_ids: item_ids,
					skus: skus,
					prices: prices,
					quantities: quantities,
					usedpoint: usedpoint,
					shipping_charge: shipping_charge,
					cod_fee: cod_fee
				}
			}).done(function( retVal, dataType ) {
				var data = retVal.split("<?php 
            echo WC2_SPLIT;
            ?>
");
				if( data[0] == "OK" ) {
					$("#discount").val(data[1]);
//*** LI CUSTOMIZE >>>
					//$("#tax").val(data[2]);
//*** LI CUSTOMIZE <<<
					$("#getpoint").val(data[3]);
					$("#total").html(WC2Util.addComma(data[4]+""));
					$("#total-top").html(WC2Util.addComma(data[4]+""));
				}
			}).fail(function( retVal ) {
			});
			return false;
<?php 
            $script_recalculation = ob_get_contents();
            ob_end_clean();
            echo apply_filters('wc2_filter_admin_order_recalculation', $script_recalculation, $data);
            ?>
		}
	};

	orderMail = {
		sendMail : function() {
			if($("#sendmail-address").val() == "") return;

			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: "sendmail",
					mailaddress: encodeURIComponent($("#sendmail-address").val()),
					message: encodeURIComponent($("#sendmail-message").val()),
					name: encodeURIComponent($("#sendmail-name").val()),
					subject: encodeURIComponent($("#sendmail-subject").val()),
					order_id: $("#order_id").val(),
					checked: $("#mail-checked").val()
				}
			}).done(function( retVal, dataType ) {
				if( retVal == "OK" ) {
					checked = $("#mail-checked").val().replace("_", "-");
					$("li."+checked).removeClass("status-no");
					$("li."+checked).addClass("status-yes dashicons-before dashicons-yes");
					<?php 
            do_action('wc2_action_admin_order_check_mail_scripts');
            ?>

					$("#sendMailAlert").dialog("option", "buttons", {
						"OK": function() {
							$(this).dialog("close");
							$('#sendMailDialog').dialog("close");
						}
					});
					$("#sendMailAlert").dialog("option", "title", "SUCCESS");
					$("#sendMailAlert fieldset").html("<p><?php 
            _e('メールを送信しました。', 'wc2');
            ?>
</p>");
					$("#sendMailAlert").dialog("open");

				} else if( retVal == "NG" ) {
					$("#sendMailAlert").dialog("option", "buttons", {
						"OK": function() {
							$(this).dialog("close");
						}
					});
					$("#sendMailAlert").dialog("option", "title", "ERROR");
					$("#sendMailAlert fieldset").html("<p><?php 
            _e('メールを送信できませんでした。', 'wc2');
            ?>
</p>");
					$("#sendMailAlert").dialog("open");
				}
			}).fail(function( retVal ) {
				$("#sendMailAlert").dialog("option", "buttons", {
					"OK": function() {
						$(this).dialog("close");
					}
				});
				$("#sendMailAlert").dialog("option", "title", "ERROR");
				$("#sendMailAlert fieldset").html("<p><?php 
            _e('メールを送信できませんでした。', 'wc2');
            ?>
</p>");
				$("#sendMailAlert").dialog("open");
			});
			return false;
		},

		checkPost : function( checked ) {
			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: "checkpost",
					order_id: $("#order_id").val(),
					checked: checked
				}
			}).done(function( retVal, dataType ) {
				if( retVal == checked ) {
					checked = checked.replace("_", "-");
					$("li."+checked).removeClass("status-no");
					$("li."+checked).addClass("status-yes dashicons-before dashicons-yes");
				}
			}).fail(function( retVal ) {
			});
			return false;
		},

		getMailMessage : function( checked ) {
			$("#sendmail").attr("disabled", "disabled");
			$("#sendmail-message").val( WC2L10n.now_loading );
			$.ajax({
				url: ajaxurl,
				type: "POST",
				data: {
					action: "order_edit_ajax",
					mode: checked,
					order_id: $("#order_id").val()
				}
			}).done(function( retVal, dataType ) {
				$("#sendmail").removeAttr("disabled");
				$("#sendmail-message").val( retVal );
			}).fail(function( retVal ) {
			});
			return false;
		}
	};

	$(".update").click(function() {
		var error = 0;

		<?php 
            if (wc2_is_membersystem_state() && wc2_is_membersystem_point()) {
                ?>
		if( !WC2Util.checkNum( $("#usedpoint").val() ) ) {
			error++;
			$("#usedpoint").css({"background-color": "#FFA"}).click(function() {
				$(this).css({"background-color": "#FFF"});
			});
		}
		if( !WC2Util.checkNum( $("#getdpoint").val() ) ) {
			error++;
			$("#getdpoint").css({"background-color": "#FFA"}).click(function() {
				$(this).css({"background-color": "#FFF"});
			});
		}
		<?php 
            }
            ?>
		if( !WC2Util.checkPrice( $("#discount").val() ) ) {
			error++;
			$("#discount").css({"background-color": "#FFA"}).click(function() {
				$(this).css({"background-color": "#FFF"});
			});
		}
		if( !WC2Util.checkPrice( $("#shipping_charge").val() ) ) {
			error++;
			$("#shipping_charge").css({"background-color": "#FFA"}).click(function() {
				$(this).css({"background-color": "#FFF"});
			});
		}
		if( !WC2Util.checkPrice( $("#cod_fee").val() ) ) {
			error++;
			$("#cod_fee").css({"background-color": "#FFA"}).click(function() {
				$(this).css({"background-color": "#FFF"});
			});
		}
//*** LI CUSTOMIZE >>>
		//if( !WC2Util.checkPrice( $("#tax").val() ) ) {
		//	error++;
		//	$("#tax").css({"background-color": "#FFA"}).click(function() {
		//		$(this).css({"background-color": "#FFF"});
		//	});
		//}
//*** LI CUSTOMIZE <<<
		<?php 
            do_action('wc2_action_admin_order_check_update_scripts', $data, $this->mode);
            ?>
		if( 0 < error ) {
			$("#aniboxStatus").attr("class", "error");
			$("#info_image").attr("src", WC2L10n.error_info);
			$("#info_message").html("データに不備があります");
			$("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
			return false;
		}

		if( ("completion" == $("#order_status option:selected").val() || "continuation" == $("#order_status option:selected").val()) && "<?php 
            echo wc2_get_today_format();
            ?>
" != $("#modified").val() ) {
			if( confirm("<?php 
            _e('更新日を今日の日付に変更しますか?', 'wc2');
            ?>
\n<?php 
            _e('更新日を変更せずに更新する場合はキャンセルを押してください。', 'wc2');
            ?>
") ) {
				$("#up_modified").val("update");
			} else {
				$("#up_modified").val("");
			}
		}

		$("#order-edit-form").submit();
	});
<?php 
            do_action('wc2_action_admin_order_post_scripts', $data, $this->mode);
            ?>
});
jQuery(document).ready(function($) {
	$("#navi-box").css("display", "none");
	$("#navi-box-link").click(function() {
		$("#navi-box").toggle();
	});

	orderFunc.sumPrice(null);

	$(document).on( "change", "input[name*='sku_price']", function() {orderFunc.sumPrice($(this));});
//*** LI CUSTOMIZE >>>
	//$(document).on( "change", "input[name*='quantity']", function() {orderFunc.sumPrice($(this));});
	$(document).on( "change", "input[name*='quantity']", function() {
		var p = $("input[name*='sku_price']");
		var q = $("input[name*='quantity']");
		var ci = $("input[name*='cart_id']");
		var cart_ids = "";
		var prices = "";
		var quantities = "";
		for( var i = 0; i < p.length; i++ ) {
			cart_ids += $(ci[i]).val()+"<?php 
            echo WC2_SPLIT;
            ?>
";
			prices += parseFloat($(p[i]).val())+"<?php 
            echo WC2_SPLIT;
            ?>
";
			quantities += $(q[i]).val()+"<?php 
            echo WC2_SPLIT;
            ?>
";
		}

		var idname = $(this).attr("id");
		var ids = idname.split("-");
		var id = ids[1];

		$.ajax({
			url: ajaxurl,
			type: "POST",
			data: {
				action: "order_edit_ajax",
				mode: "get-shipping-charge",
		<?php 
            $edit_mode = isset($_REQUEST['edit_mode']) ? $_REQUEST['edit_mode'] : 'display';
            if ($edit_mode == 'update') {
                ?>
				delivery_method: $("#delivery_method_select option:selected").val(),
				delivery_pref: $("#delivery_pref option:selected").val(),
		<?php 
            } else {
                ?>
				delivery_method: $("#delivery_method_select").val(),
				delivery_pref: $('input[name="delivery[pref]"]').val(),
		<?php 
            }
            ?>
				order_id: $("#order_id").val(),
				cart_ids: cart_ids,
				prices: prices,
				quantities: quantities,
				id: id
			}
		}).done(function( retVal, dataType ) {
			var data = retVal.split("<?php 
            echo WC2_SPLIT;
            ?>
");
			if( data[0] == "OK" ) {
				$("#shipping_charge").val(data[1]);
				if( data[2] != "0" ) $("#sku_price-"+id).val(data[2]);
				orderFunc.sumPrice(null);
			}
		}).fail(function( retVal ) {
		});
		return false;
	});
//*** LI CUSTOMIZE <<<
	$(document).on( "change", "#usedpoint", function() {orderFunc.sumPrice($("#usedpoint"));});
	$(document).on( "change", "#discount", function() {orderFunc.sumPrice($("#discount"));});
	$(document).on( "change", "#shipping_charge", function() {orderFunc.sumPrice($("#shipping_charge"));});
	$(document).on( "change", "#cod_fee", function() {orderFunc.sumPrice($("#cod_fee"));});
//*** LI CUSTOMIZE >>>
	//$(document).on( "change", "#tax", function() {orderFunc.sumPrice($("#tax"));});
//*** LI CUSTOMIZE <<<

	$(document).on( "click", ".cart-remove", function() {
		if( !confirm("<?php 
            _e('明細から商品を削除します。よろしいですか?', 'wc2');
            ?>
") ) {
			return false;
		}
		var idname = $(this).attr("id");
		var ids = idname.split("-");
		var cart_id = ids[2];

		$.ajax({
			url: ajaxurl,
			type: "POST",
			data: {
				action: "order_edit_ajax",
				mode: "cart_remove",
				order_id: $("#order_id").val(),
//*** LI CUSTOMIZE >>>
		<?php 
            $edit_mode = isset($_REQUEST['edit_mode']) ? $_REQUEST['edit_mode'] : 'display';
            if ($edit_mode == 'update') {
                ?>
				delivery_method: $("#delivery_method_select option:selected").val(),
				delivery_pref: $("#delivery_pref option:selected").val(),
		<?php 
            } else {
                ?>
				delivery_method: $("#delivery_method_select").val(),
				delivery_pref: $('input[name="delivery[pref]"]').val(),
		<?php 
            }
            ?>
//*** LI CUSTOMIZE <<<
				cart_id: cart_id
			}
		}).done(function( retVal, dataType ) {
//*** LI CUSTOMIZE >>>
			//$("#order-cart-items").html("");
			//$("#order-cart-items").html( retVal );
			//orderFunc.sumPrice(null);
			var data = retVal.split("<?php 
            echo WC2_SPLIT;
            ?>
");
			if( data[0] == "OK" ) {
				$("#order-cart-items").html("");
				$("#order-cart-items").html(data[1]);
				$("#status-history tbody").html("");
				$("#status-history tbody").html(data[2]);
				orderFunc.sumPrice(null);
			}
//*** LI CUSTOMIZE <<<
		}).fail(function( retVal ) {
		});
		return false;
	});

<?php 
            $order_delivery_method = isset($data['delivery_method']) ? $data['delivery_method'] : -1;
            ?>
	orderFunc.makeDeliveryTime(<?php 
            echo $order_delivery_method;
            ?>
);

	$("#get-member").click(function() {
		if( "" == $("input[name='customer[email]']").val() ) {
			alert("<?php 
            _e('メールアドレスを入力してください。', 'wc2');
            ?>
");
			return;
		}
		if( $("input[name='customer[name1]']").val() || "" != $("input[name='delivery[name1]']").val() ) {
			if( !confirm("<?php 
            _e('注文者住所を配送先住所に上書きします。よろしいですか?', 'wc2');
            ?>
") ) {
				return false;
			}
		}
		orderFunc.getMember($("input[name='customer[email]']").val());
	});

	<?php 
            if ($this->mode == 'new') {
                ?>
	$("#costomer-copy").click(function() {
		if( "" != $("input[name='delivery[name1]']").val() || 
			"" != $("input[name='delivery[name2]']").val() || 
			"" != $("input[name='delivery[name3]']").val() || 
			"" != $("input[name='delivery[name4]']").val() || 
			"" != $("input[name='delivery[zipcode]']").val() || 
			"" != $("input[name='delivery[address1]']").val() || 
			"" != $("input[name='delivery[address2]']").val() || 
			"" != $("input[name='delivery[tel]']").val() || 
			"" != $("input[name='delivery[fax]']").val() ) {
			if( !confirm("<?php 
                _e('注文者住所を配送先住所に上書きします。よろしいですか?', 'wc2');
                ?>
") )
				return;
		}
		$("input[name='delivery[name1]']").val($("input[name='customer[name1]']").val());
		$("input[name='delivery[name2]']").val($("input[name='customer[name2]']").val());
		$("input[name='delivery[name3]']").val($("input[name='customer[name3]']").val());
		$("input[name='delivery[name4]']").val($("input[name='customer[name4]']").val());
		$("input[name='delivery[zipcode]']").val($("input[name='customer[zipcode]']").val());
		$("#delivery_country").val($("#customer_country option:selected").val());
		$("#delivery_pref").val($("#customer_pref option:selected").val());
		$("input[name='delivery[address1]']").val($("input[name='customer[address1]']").val());
		$("input[name='delivery[address2]']").val($("input[name='customer[address2]']").val());
		$("input[name='delivery[tel]']").val($("input[name='customer[tel]']").val());
		$("input[name='delivery[fax]']").val($("input[name='customer[fax]']").val());
	});
	<?php 
            }
            ?>

	$("#recalc").click(function() {orderFunc.recalculation();});
<?php 
        }
        ?>
});
</script>
<?php 
    }