{% load i18n %}



{% comment %}
<!--
  Copyright (C) 2011 University of Dundee & Open Microscopy Environment.
  All rights reserved.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
{% endcomment %}

    <script type="text/javascript">
        $(document).ready(function() {
            $("#prevMonth").click(function() { 
                $("div#history_calendar").html('<p>{% trans "Loading calendar... please wait" %} <img src ="{% static "webgateway/img/spinner.gif" %}"/></p>');
                $("div#history_calendar").load('{% url 'load_calendar' controller.last_month.year controller.last_month.month %}');     
                $("div#content_details").empty();
                OME.table_selection_changed();    // clear selection - E.g. right-hand panel 
            });
            $("#nextMonth").click(function() { 
                $("div#history_calendar").html('<p>{% trans "Loading calendar... please wait" %} <img src ="{% static "webgateway/img/spinner.gif" %}"/></p>');
                $("div#history_calendar").load('{% url 'load_calendar' controller.next_month.year controller.next_month.month %}');
                $("div#content_details").empty();
                OME.table_selection_changed();    // clear selection - E.g. right-hand panel 
            });
        })
        
        if (typeof OME === "undefined"){ OME={}; }
        OME.load_details = function(y,m,d) {
            $("div#content_details").html('<p>{% trans "Loading data... please wait" %} <img src ="{% static "webgateway/img/spinner.gif" %}"/></p>');
            $("div#content_details").load('{% url 'load_history' %}'+y+'/'+m+'/'+d+'/');
            OME.table_selection_changed();    // clear selection - E.g. right-hand panel 
        }
    </script>
	
<div class="cal_nav left_panel_top">
   
   	<h1><strong>{{ controller.month_name }}</strong> {{ controller.year }}</h1>
	
	
    <input id="prevMonth" class="button" type="button" alt="{{ controller.last_month_name}}">
    <input id="nextMonth" class="button" type="button" alt="{{ controller.next_month_name }}" >
	
	
	{% comment %}
    <input id="prevMonth" class="button" type="button" alt="{{ controller.last_month_name}}" value="{{ controller.last_month_name }}" >
    <input id="nextMonth" class="button" type="button" alt="{{ controller.next_month_name }}" value="{{ controller.next_month_name }}">
    {% endcomment %}
	
</div>

<div class="calendar" style="position: absolute; top:30px; left:0; bottom:0; right:0">

	<div class="left_panel_calendar">
    
		<table>
	        <thead>
	        {% for day_label in  controller.week_day_labels %}
	            <th class="calendar_day">{{ day_label }}</th>
	        {% endfor %}
	        </thead>
	        <tbody>
	        {% for week in controller.cal_weeks %}
	        <tr class="calendar_week">
	            {% for day in week %}
	                {% if not day.cell.day %}
						<td class="not_calendar_day"></td>
               
				    {% else %}
	                    <td class="calendar_day">
                       
						   	<a href="#" onClick="OME.load_details('{{ controller.year }}', '{{ controller.month }}', '{{ day.cell.day }}')" > 
   
								<div class="calendar_numerical_day">
									<span>{{ day.cell.day }}</span>
								</div>
						
						
								<div class="calendar_items">
		                            {% if day.cell.counter.imgCounter or day.cell.counter.dsCounter or  day.cell.counter.prCounter or day.cell.counter.rdCounter %}
									<table>
		                                <tr>
											<td>
												{% if day.cell.counter.imgCounter %}
												<img src="{% static "webclient/image/image16.png" %}" />
												<span>{{ day.cell.counter.imgCounter }}</span>
												{% endif %}
											</td>
										</tr>
		                                <tr>
											<td>
												{% if day.cell.counter.dsCounter %}
												<img src="{% static "webclient/image/folder_image16.png" %}" />
												<span>{{ day.cell.counter.dsCounter }}</span>
												{% endif %}
											</td>
										</tr>
		                                <tr>
											<td>
												{% if day.cell.counter.prCounter %}
												<img src="{% static "webclient/image/folder16.png" %}" />
												<span>{{ day.cell.counter.prCounter }}</span>
												{% endif %}
											</td>
										</tr>
		                            </table>
									{% endif %}
		                        </div>

							</a>
                	
						</td>
	                {% endif %}
	            {% endfor %}
	        </tr>
	        {% endfor %}</tbody>
	    </table>
    </div>
    
</div>
