{% extends "base.html" %}

{% block title %}New Logbook Entry form{% endblock %}

{% block content %}

{% if date %}
<h2 title="id = {{slug}}">Edit Existing Logbook Entry on {{date}}</h2>
{% else %}
<h2>New Logbook Entry in {{year}}</h2>
{% endif %}
<div align=center>
{% if date %}<p>Link to <em><a href="/logbookentry/{{date}}/{{slug}}#">this entry</a></em> &nbsp;&nbsp;{% endif %}
&nbsp;&nbsp;<a href="/logreport/{{year}}">logbook report {{year}}</a>&nbsp;&nbsp;
<a href="/handbook/logbooks.html#form">How to use this form</a>
</div>
    {% if save_bad %}
    <p style="font-family: monospace; font-weight: bold; color: red; font-size: 130%; text-align: center">

    Cannot save to '{{save_bad}}' as a file of that name already exists here.
    </p>
    {% endif %}
    <style>
    input, textarea, pre {font-family: monospace; font-weight: bold; text-align:center; font-size: 100%; padding: 0.5em;  }
    textarea {text-align:left }
    pre {text-align:left; font-size: 120%  }
    textarea {text-align:left }
    </style>  
    <div style = "max-width:100%; margin-left:15%; font-family: monospace; font-weight: bold; font-size: 150%; text-align: right; " >
    
    <form method ='post' >
       {% csrf_token %}              
    <br />                 
           <input name="prev_slug" id="prev_slug" value="{{slug}}" type=hidden>

           <span {% if dateflag %}style="color:red"{% endif %}>
           <span {% if yesterday%}style="color:blue"{% endif %}>
           <label for="date">Date of the activity{% if dateflag %} (cannot change year on an existing entry){% endif %}</label>
           <input {% if not user.username %} disabled{% endif %} 
		{% if dateflag %}style="color:red"{% endif %}
		{% if yesterday%}style="color:blue"{% endif %}
           label = "Date" name = "date" size="12"
           title="Date of the activity, a single day,  in ISO format: 2020-08-17"
             {% if date %}value="{{date}}"{% else %}
		{% if yesterday %} value="{{yesterday}}"{% else %}
		placeholder="2025-08-12"{% endif %}{% endif %}
           required /> 
           </span>
          
    <br /><br />     
           <span {% if authorflag %}style="color:red"{% endif %}>    
           <label for="author">Your name (author) <a href="/aliases/{{year}}">[valid authors]</a></label>
           <input {% if not user.username %} disabled{% endif %} 
		{% if authorflag %}style="color:red"{% endif %}
           label = "author" name = "author" size="20"
           title="The person writing the logbook entry"
           {% if author %}value="{{author}}"{% else %}placeholder="Animal"{% endif %}
           required /> 
          </span>
    <br /><br />        
           <label for="others">Other names (comma separated) <a href="/aliases/{{year}}">[valid aliases]</a></label>
           <input {% if not user.username %} disabled{% endif %} 
           label = "others" name = "others" size="{% if lenothers %}{{lenothers}}{% else %}20{% endif %}"
           title="Everyone else involved"
           {% if others %}value="{{others}}"{% else %}placeholder="Phil T, Chas, Planc" {% endif %}
           /> 
    <br /><br />         
           <label for="place">Place: cave name, or 'plateau', 'topcamp' etc.</label>
           <input {% if not user.username %} disabled{% endif %} 
           label = "Place" name = "place" size="15"
           title="Place: cave name, or 'plateau', 'topcamp'  "
           {% if place %}value="{{place}}"{% else %}placeholder="basecamp" {% endif %}
           required /> 
<br>(If any cave is visited at all, put in the cave id and not 'plateau')
    <br /><br />        
           <label for="title">Title</label>
           <input {% if not user.username %} disabled{% endif %} 
           label = "Title" name = "title" size="30"
           title="Title of your activity"
           {% if place %}value="{{title}}"{% else %}placeholder="What we did on our holidays" {% endif %}
           required /> 
    <br /><br /> 
           <textarea {% if not user.username %} disabled{% endif %} 
           rows="{% if textrows%}{{textrows}}{% else %}5{% endif %}" cols="70"
           label = "" name = "text" 
           required />{% if entry %}{{entry}}{% else %}We had a lot of fun in the rain...{% endif %}
           </textarea>
           <br>
           [Type in text in <a href="/handbook/logbooks.html#form">Logbook HTML format</a>.]
    <br /><br />         
           <label for="tu">Time underground (hours)</label>
           <input {% if not user.username %} disabled{% endif %} 
           label = "tu" name = "tu" size="5"
           title="Time underground (hours)"
           {% if tu %}value="{{tu}}"{% else %}placeholder="0.1" {% endif %}
           /> 
    <br /><br /> 
	Identified login 
        <input type="checkbox" name="identified_login" onclick="return false" id="id_identified_login" 
	{% if identified_login %} checked{% endif %} ">
        <br /><br /> 

           <label for="who_are_you">Who are you, editing this logbook entry?</label>
           <input 
           {% if not user.username %} disabled{% endif %} 
	   {% if identified_login %} readonly{% endif %} 
           label = "Who are you" name = "who_are_you" size ="70"
           title="Who are you"
           placeholder="editor's name for version control e.g. 'Animal <mta@gasthof.expo>'" value="{{who_are_you}}" required/>
   <br /><br /> 
       <input  type="hidden" value="{{slug}}" name="slug">
       <button  class="fancybutton2"  style="padding: 0.5em 25px; margin-left: 110px" type = "submit" value = "save" >
          {% if title %}Update this entry<em>"{{title}}"</em>{% else %} Save this entry{% endif %}
       </button>
    </form>

    <br /><br /><br />
	{% if date %}<p>Link to <em><a href="/logbookentry/{{date}}/{{slug}}#">this entry</a></em> &nbsp;&nbsp;{% endif %}
        Full logbook: <a href="/years/{{year}}/logbook.html"><em>Logbook {{year}}</em></a>
&nbsp;&nbsp;&nbsp;&nbsp;{{year}} <a href="/logreport/{{year}}">Logbook report</a>
			
 
</div>

<br />

<hr />

{% if output %}
<details><summary>
Click this triangle to see the HTML which has been put into logbook.html, and below that is the rendered logbook entry.
</summary>
<pre>
{{output}}
</pre>
</details>
<hr>
<style>
.tripdate, .trippeople {
	background-color: #C6E4E3;
	float: left;
	margin: 2px 1px 1px 1px;
	padding: 10px;
	border-bottom-right-radius: 1em;
	}
.trippeople {
	background-color: #fff;
	float: right;
	font-style: italic;
	}
.triptitle {
	border: 1px solid #99CCCC;
	border-top-width: 2px;
	color: #008787;
	font-size: 120%;
	font-weight: bold;
	padding: 45px 10px 20px;
	text-align: center;
	}
.timeug	{
	text-align: right;
	font-weight: bold;
	margin-bottom: 10px;}
    </style>
{{output|safe}}
{% endif %}
{% endblock %}