<% if @from.nil? then %>
  <%= form_tag({:controller => "pool", :action => "transfer_metadata"}, :method => "get") do %>
  <%= hidden_field_tag :to, @to.id %>
  <%= t('.from.from_number') %>
  <%= text_field_tag :from, "", :class => "fp", :size => 5, :tabindex => 1 %>
  <br>
  <%= submit_tag t('.from.transfer'), :tabindex => 2 %>
  <%= button_to_function t('buttons.cancel'), "history.back()", :tabindex => 2 %>
  <script type="text/javascript">$("from").focus()</script>
<% end %>

<% else %>
<h3>
  <%=
    t('.title_html',
      :from => link_to(@from.pretty_name, :action => :show, :id => @from.id),
      :to => link_to(@to.pretty_name, :action => :show, :id => @to.id))
  %>
</h3>

<div>
  <%= t('.info_what') %>
</div>
<% if @truncated then %>
<div>
 <%= t('.info_truncated') %>
 <b><%= t('.info_truncated_warning') %></b>
</div>
<% end %>

<div><%= t('.reverse_text_html', :reverse => link_to(t('.reverse'), { :action => "transfer_metadata", :from => @to.id, :to => @from.id})) %></div>

<%= form_tag(:controller => "post", :action => "update_batch") do %>
<%= hidden_field_tag "url", (url_for :controller => "pool", :action => "show", :id => @to.id) %>
  <table>
    <thead>
      <tr>
        <th><%= t('.table.from') %></th>
        <th><%= t('.table.to') %></th>
        <th><%= t('.table.tags') %></th>
      </tr>
    </thead>
    <tbody>
      <% @posts.each do |pp| %>
        <% fp = pp[:from]; tp = pp[:to] %>
        <tr>
          <td>
            <% if fp.can_be_seen_by?(@current_user) %>
              <%= link_to(image_tag(fp.preview_url, :width => fp.preview_dimensions[0], :height => fp.preview_dimensions[1]), {:controller => "post", :action => "show", :id => fp.id}, :title => fp.cached_tags)%>
            <% end %>
          </td>
          <td>
            <% if tp.can_be_seen_by?(@current_user) %>
              <%= link_to(image_tag(tp.preview_url, :width => tp.preview_dimensions[0], :height => tp.preview_dimensions[1]), {:controller => "post", :action => "show", :id => tp.id}, :title => tp.cached_tags)%>
            <% end %>
          </td>
          <td>
            <%= hidden_field_tag "post[#{tp.id}][old_tags]", tp.tags %>
            <%= text_field_tag "post[#{tp.id}][tags]", pp[:tags], :class => "fp", :size => 45, :tabindex => 1 %>
          </td>
        </tr>
      <% end %>
    </tbody>
    <tfoot>
      <tr>
        <td colspan="2"><%= submit_tag t('.table.transfer'), :tabindex => 2 %> <%= button_to_function t('buttons.cancel'), "history.back()", :tabindex => 2 %></td>
      </tr>
    </tfoot>
  </table>
<% end %>
<% end %>
