{% extends "sopds_main.html" %}
{% load i18n %}

{% block body %}
<script>
       function del_bsbook(b_id, b_t) {
           $('#DeleteBook_btnYes').attr("href","{% url "web:bsdel" %}?book="+b_id);
           $('#DeleteBook_image').attr("src","{% url "opds:covertmpl" %}"+b_id+"/");
           $('#DeleteBook_title').text(b_t);
           $('#DeleteBookModal').foundation('open');
       }
</script>
           
<div id="DeleteBookModal" class="reveal tiny text-center" data-reveal>
  <h5 id="DeleteBookModalTitle">{% trans "Confirm the deletion of the book to your bookshelf." %}</h5>
  <table><tr>	
  <td width="100px" style="padding:0rem 0rem;">
      <img src="" id="DeleteBook_image" style="max-height: 100px; max-width: 100px">
  </td> 
  <td style="font-size:100%; padding:3px">
      <p id="DeleteBook_title"></p>
  </td>
  </tr>
  </table>
  <p class="text-center"><a href="#" class="secondary button" id="DeleteBook_btnYes">{% trans "Delete" %}</a>
                         &nbsp;&nbsp;&nbsp;<a class="close button" data-close>{% trans "Cancel" %}</a></p>
  <button class="close-button" data-close aria-label="Close modal" type="button">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

 {% if isbookshelf %}
 <div id="ConfirmModal" class="reveal tiny text-center" data-reveal>
  <h5 id="ConfirmModalTitle">{% trans "Confirm to clear your bookshelf." %}</h5>
  <p></p>
  <p class="text-center"><a href="{% url "web:bsclear" %}" class="secondary button" id="Confirm_btnYes">{% trans "Clear" %}</a>
                         &nbsp;&nbsp;&nbsp;<a class="close button" data-close>{% trans "Cancel" %}</a></p>
  <button class="close-button" data-close aria-label="Close modal" type="button">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

 <a class="alert button small" data-open="ConfirmModal">{%  trans "Clear bookshelf" %}</a>
 {% endif %}

{%  for b in books %}
		<div class="large-12 column">
			<b>{{ b.title }}</b>
			<i style="font-size:80%;">{% trans "Download:" %} </i>
			<i><a href="{% url 'opds_catalog:download' b.id 0 %}"><span class="label small">{{b.format}}</span></a></i>&nbsp;
			<i><a href="{% url 'opds_catalog:download' b.id 1 %}"><span class="label small">{{b.format}}+zip</span></a></i>&nbsp;
			{% if b.format == 'fb2' and fb2toepub %}
			   <i><a href="{% url 'opds_catalog:convert' b.id 'epub' %}"><span class="label small">epub</span></a></i>&nbsp;
			{% endif %}
			{% if b.format == 'fb2' and fb2tomobi %}
			   <i><a href="{% url 'opds_catalog:convert' b.id 'mobi' %}"><span class="label small">mobi</span></a></i>&nbsp;
			{% endif %}			
			{% if isbookshelf %}
			&nbsp;&nbsp;<i><a href="#" onclick="del_bsbook({{ b.id }},'{{b.title}}');"><span class="secondary label small">&nbsp;{% trans "Delete from bookshelf" %}&nbsp;</span></a></i>
		    {% endif %}
		</div>
		
		<div class="large-12 column">
		    <table><tr>	
		    <td width="100px" style="padding:0rem 0rem;">
			     <img src="{% url 'opds_catalog:thumb' b.id %}" type="image/jpeg" width="80px">
			</td>
			<td style="font-size:80%; padding:1rem 1rem;">
				<b>{% trans "Book title:" %}</b> {{ b.title }} <br>
				{% if b.authors.count > 0 %}
				   <b>{% trans "Authors:" %}</b>{% for a in b.authors %} <a href="{% url "web:searchbooks" %}?searchtype=a&searchterms={{a.id}}">{{a.full_name}}</a>{% if not forloop.last %},{%endif%} {%endfor%}<br>
				{% endif %}
				{% if b.genres.count > 0 %}
				   <b>{% trans "Genres" %}</b>{% for g in b.genres %} <a href="{% url "web:searchbooks" %}?searchtype=g&searchterms={{g.id}}">{{g.subsection}}</a>{% if not forloop.last %},{%endif%} {%endfor%} <br>
				{% endif %}
				{% if b.series.count > 0 %}
				   <b>{% trans "Series" %}</b> {% for s in b.series %} <a href="{% url "web:searchbooks" %}?searchtype=s&searchterms={{s.id}}">{{s.ser}}</a>{% if not forloop.last %},{%endif%} {%endfor%} <br>
				{% endif %}
				<b>{% trans "File:" %}</b> {{ b.path }}/{{ b.filename }} <br>
				<b>{% trans "File size:" %}</b> {{ b.filesize }}Кб.<br>
				<b>{% trans "Changes date:" %}</b> {{ b.docdate }} <br>	
				{% if b.doubles > 0 %}
				<b>{% trans "Doubles for book:" %}</b> <a href="{% url "web:searchbooks" %}?searchtype=d&searchterms={{b.id}}">{{ b.title }} ({{b.doubles}}шт.)</a>
				{% endif %}
			</td>
			</tr>
			<tr>
			<td colspan="2">
			    <p style="font-size:80%;"> {{ b.annotation }} </p>
			</td>
			</tr></table>
		</div>			
{% endfor %}

{% if paginator.num_pages > 1 %}
<ul class="pagination" role="navigation" aria-label="Pagination">
  <li class="pagination-previous {% if not paginator.has_previous %}disabled{%endif%}">
      {% if paginator.has_previous %}<a href="{% url "web:searchbooks" %}?searchtype={{searchtype}}&searchterms={{searchterms}}&page={{paginator.previous_page_number}}" aria-label="Previous page"> {%endif%}
         {% trans "Previous page" %}
      {% if paginator.has_previous %}</a>{%endif%}
  </li>
  
  {% for pn in paginator.page_range %}
     {% if paginator.number == pn %}
        <li class="current">{{pn}}</li>
     {% else %}
        <li><a href="{% url "web:searchbooks" %}?searchtype={{searchtype}}&searchterms={{searchterms}}&page={{pn}}" aria-label="Page {{pn}}">{{pn}}</a></li>
     {% endif %}   
        {# <li class="ellipsis" aria-hidden="true"></li> #}
  {% endfor %}
  
  <li class="pagination-next" {% if not paginator.has_next %}disabled{%endif%}>
      {% if paginator.has_next %}<a href="{% url "web:searchbooks" %}?searchtype={{searchtype}}&searchterms={{searchterms}}&page={{paginator.next_page_number}}" aria-label="Next page">{%endif%}
         {% trans "Next page" %}
      {% if paginator.has_next %}</a>{%endif%}
  </li>
</ul>
{% endif %}

{% endblock %}  {# body #}