{% extends "base.html" %}

{% block content %}
<div class="row">
	<div class="col-md-8 col-md-offset-2">

         {% if user.is_authenticated %}
            <p role="button" class="btn btn-success btn-xs">Witaj, <strong>{{ user.get_username }}</strong>. Dziękujemy za zalogowanie.</p>
         {% else %}
            <p>Welcome, new user. Please log in.</p>
         {% endif %}
         <p role="button" class="btn btn-success btn-xs"><strong>Dzisiaj jest {%now 'Y-m-j'%}</strong></p>
		<a href="{% url 'logout'%}" role="button" class="btn btn-danger btn-xs">Wyloguj</a>
<br/>

    <form method="post" >
    {% csrf_token %}
        <table class="table table-striped table-bordered">
            <thead>
				<tr>	
					<th class="info"></th>
					<th class="info">OPIS PÓL</th>
					<th class="info">POLA DO UZUPEŁNIENIA</th>
					<th class="info">OPERACJA </th>
				</tr>
			</thead>
				<td rowspan="10"><img src="/media/image/logo.png" alt="logo"/></td>
				<td></td>
				<td></td>
				<td rowspan="10"><button type="submit" class="btn btn-primary btn-lg" data-toggle="modal" data-target=".bs-example-modal-sm" name='_add'>Zapisz</button></td>
				{{form.as_table}}
        </table>
    </form>
	</div>
</div>


 <div id='date_menu'> 
    <form method = 'post' id='date_menu'>
     {% csrf_token %}
     <button type="submit" onclick="pokaz();" class="btn btn-primary btn-lg" data-toggle="modal" data-target=".bs-example-modal-sm" name='_arch'>Archiwum</button>
    </form>

  <form method = 'post' id='date_menu'>
     {% csrf_token %}
     <button type="submit" class="btn btn-primary btn-lg" data-toggle="modal" data-target=".bs-example-modal-sm" name='_today'>Dzisiejsze</button>
 </form>

 <form method = 'post' id='date_menu'>
     {% csrf_token %}
     <button type="submit" class="btn btn-primary btn-lg" data-toggle="modal" data-target=".bs-example-modal-sm" name='_tomorrow'>Przyszłe</button>
 </form>
</div>

	
	<table class="table table-striped">
        <tr>
            <th>Data wizyty</th>
            <th>Imię i nazwisko</th>
			<th>Firma</th>
            <th>Do kogo</th>
			<th>Godzina wizyty</th>
            <th>Godzina przyjazdu</th>
			<th>Godzina wyjazdu</th>
            <th>Komentarz</th>
			<th>Wpisujący</th>
			<th>Kawa</th>
			<th>Lunch</th>
            <th>Operacja</th>
        </tr>
        {% for data_of_visit in page_filter %}
        <tr>
            <td>{{data_of_visit.visit_date}}</td>
            <td>{{data_of_visit.guest}}</td>
            <td>{{data_of_visit.company}}</td>
            <td>{{data_of_visit.visit_host}}</td>
            <td>{{data_of_visit.plan_hour}}</td>
            <td><strong>{{data_of_visit.arrive_hour|default_if_none:"Nie wpisano"}}</strong></td>
            <td><strong>{{data_of_visit.exit_hour|default_if_none:"Nie wpisano"}}</strong></td>
            <td>{{data_of_visit.comment}}</td>
            <td>{{data_of_visit.key_in_user}}</td>
            <td>{{data_of_visit.coffe|yesno:"Tak,Nie"}}</td>
            <td>{{data_of_visit.lunch|yesno:"Tak,Nie"}}</td>
      <td><a href="{% url 'update' pk=data_of_visit.id %}" role="button" class="btn btn-success btn-xs">Aktualizuj</a><br /><a href="{% url 'delete' pk=data_of_visit.id %}"  role="button" class="btn btn-danger btn-xs">Usuń</a><td>
        </tr>
    {% endfor %}

	</table>
	
<div class="pagination">
   <span class="step-links">
        {% if page_filter.has_previous %}
            <a href="?page={{ page_filter.previous_page_number }}">poprzednia</a>
        {% endif %}

        <span class="current">
            Strona {{ page_filter.number }} z {{ page_filter.paginator.num_pages }}
        </span>

        {% if page_filter.has_next %}
            <a href="?page={{ page_filter.next_page_number }}">następna</a>
        {% endif %}
    </span>
</div>
{% endblock %}