{% extends "base.html" %}

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

{% block content %}

{% if date %}
<h2>Edit Logbook Entry on {{date}}</h2>
{% else %}
<h2>New Logbook Entry in {{year}}</h2>
{% endif %}
    {% 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 />                 
       
           <span {% if dateflag %}style="color:red"{% endif %}>
           <label for="date">Date of the activity</label>
           <input {% if not user.username %} disabled{% 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 %}placeholder="2023-08-12"{% 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 %} 
           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 /><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...{% 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 /> 
       <button  class="fancybutton2"  style="padding: 0.5em 25px; margin-left: 110px" type = "submit" value = "save" >
          Update logbook entry
       </button>
    </form>

    <br /><br /><br />
                 Full logbook for this year: <a href="/years/{{year}}/logbook.html"><em>Logbook {{year}}</em></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 %}