<% content_for :head do %>
  <%= stylesheet_link_tag "front/mypage" %>
<% end %>

<ol id="bread_list" class="m_btm"><li class="bread_top"><a href="/">トップページ</a></li><li><%= link_to "マイページ", :controller => :accounts, :action => :history_list %></li><li>購入履歴</li></ol>
<h2 class="main_t">マイページ</h2>
<div id="mypage" class="clearfix">
  <!-- マイメニュー -->
  <%= render :partial=> "user/navigation" %>

  <!-- 購入履歴一覧 -->
  <div id="mypage_main">
    <h3><img src="/images/mypage/mypage_t1.gif" width="535" height="44" alt="お届け先設定" /></h3>
    <div class="mypage_box">
      <p class="tb_t">購入履歴詳細</p>
      <table class="tb1 cntr">
        <tr>
          <th width="123">購入日時</th>
          <th width="123">受注番号</th>
          <th width="122">お支払い方法</th>
          <th width="122">お届け時間</th>
        </tr>
        <tr>
          <td><%= date_time(@order.received_at) %></td>
          <td><%=h @order.code %></td>
          <td><%=h @order_delivery.payment && @order_delivery.payment.name %></td>
          <td><%=h @order_delivery.delivery_time_name %></td>
        </tr>
      </table>

      <p class="tb_t">お支払い明細</p>
      <table class="tb1 cntr">
        <tr>
          <th width="223">商品名・商品コード</th>
          <th width="89">単価(税込み)</th>
          <th width="89">個数</th>
          <th width="89">計</th>
        </tr>
        <% @order_delivery.order_details.each do | detail | %>
        <tr>
          <td class="t_left">
            <%= link_to_product detail.product_style.product, detail.product_style_name %><br />
            <%=h detail.product_code %>
          </td>
          <td><%= number_with_delimiter(detail.price) %>円</td>
          <td><%= number_with_delimiter(detail.quantity) %></td>
          <td><%= number_with_delimiter(detail.subtotal) %>円</td>
        </tr>
        <% end %>
        <tr>
          <td colspan="3" class="t_right">小計</td>
          <td><%= number_with_delimiter(@order_delivery.subtotal) %>円</td>
        </tr>
        <tr>
          <td colspan="3" class="t_right">送料</td>
          <td><%= number_with_delimiter((@order_delivery.deliv_fee.blank? ? 0 :@order_delivery.deliv_fee)) %>円</td>
        </tr>
        <tr>
          <td colspan="3" class="t_right">代引手数料</td>
          <td><%= number_with_delimiter(@order_delivery.charge.blank? ? 0 :@order_delivery.charge) %>円</td>
        </tr>
		<tr>
          <td colspan="3" class="t_right">総計</td>
          <td><%= number_with_delimiter(@order_delivery.total) %>円</td>
        </tr>
		<tr>
          <td colspan="3" class="t_right">使用ポイント</td>
          <td>-<%= number_with_delimiter(@order_delivery.use_point) %>Pt</td>
        </tr>
		<tr>
          <td colspan="3" class="t_right">加算されるポイント</td>
          <td>+<%= number_with_delimiter(@order_delivery.add_point) %>Pt</td>
        </tr>
      </table>

      <table class="tb1 total">
        <tr><th>支払金額</th><td><%= number_with_delimiter(@order_delivery.payment_total) %>円</td></tr>
      </table>

      <p class="tb_t">お届け先住所</p>
      <table class="tb2">
        <tr>
          <th width="150" class="t_left">お名前</th>
          <td><%=h @order_delivery.deliv_family_name %> <%=h @order_delivery.deliv_first_name %></td>
        </tr>
        <tr>
          <th class="t_left">お名前（フリガナ）</th>
          <td><%=h @order_delivery.deliv_family_name_kana %> <%=h @order_delivery.deliv_first_name_kana %></td>
        </tr>
        <tr>
          <th class="t_left">郵便番号</th>
          <td>〒<%=h @order_delivery.deliv_zipcode01 %>-<%=h @order_delivery.deliv_zipcode02 %></td>
        </tr>
        <tr>
          <th class="t_left">住所</th>
          <td><%=h @order_delivery.deliv_pref_name %><%=h @order_delivery.deliv_address_city %><%=h @order_delivery.deliv_address_detail %></td>
        </tr>
        <tr>
          <th class="t_left">電話番号</th>
          <td><%=h @order_delivery.deliv_tel01 %>-<%=h @order_delivery.deliv_tel02 %>-<%=h @order_delivery.deliv_tel03 %></td>
        </tr>
      </table>

      <p class="tb_t">注文状況</p>
      <table class="tb2">
        <tr>
          <th width="150" class="t_left">ステータス</th>
          <td><%=h @order_delivery.front_status_view %></td>
        </tr>
		<tr>
          <th class="t_left">発送日</th>
          <td><%= @order_delivery.shipped_at ? date(@order_delivery.shipped_at) : '未発送' %></td>
        </tr>
		<tr>
          <th class="t_left">発送伝票番号</th>
          <td>
          	<% if @order_delivery.delivery_tickets.empty? %>
		  	未発送
    		<% else %>
			<ul>
		     <% @order_delivery.delivery_tickets.each do |ticket| %>
		      <li><%=h ticket.code %></li>
		     <% end %>
		    </ul>
		    <% end %>
		  </td>
        </tr>
      </table>
      <div id="submit"><%= link_to '戻る', :action => 'history' %></div>
    </div><!-- /mypage_box-->
    <div><img src="/images/mypage/mypage_btm.gif" width="535" height="5" alt="" /></div>
  </div><!-- /mypage_main -->
</div><!-- /mypage -->
