{% extends "base.html" %}

{% block title %}Simple Fileupload{% endblock %}

{% block content %}

{% if user.username %}
<h2>Wallet {{wallet}} - edit settings or upload a file</h2>
{% else %}
<h2>Wallet {{wallet}}</h2>
{% endif %}

    <form method ='post' style="text-align: center">
        {% csrf_token %}              
          <button  class="fancybutton"  style="padding: 0.5em 25px; font-size: 80%;" type = "submit" value = "Go to" >
              Go directly to this wallet: &rarr;
           </button>
           <input 
           label = "WalletGoto" name = "walletgoto" size="7"
           title="Wallet name to go to directly"
           placeholder="2022#nn"  value="2022#" /> 
          
                
    </form>
<p style="font-family: monospace; font-weight: bold; font-size: 130%; text-align: center">
<a style="font-weight: normal;" href="/scanupload/{{prevy}}:01">{{prevy}}</a>
&nbsp;...&nbsp;
<a href="/scanupload/{{year}}:{{prev}}">{{year}}:{{prev}}</a> 
&larr; {{wallet}} &rarr; 
<a href="/scanupload/{{year}}:{{next}}">{{year}}:{{next}}</a>
&nbsp;...&nbsp;
<a style="font-weight: normal;" href="/scanupload/{{nexty}}:01">{{nexty}}</a>
</p>  

 
<div style = "max-width:35%; margin-left:20%; text-align: center; " >
    <form method ='post' enctype ="multipart/form-data">
        {% csrf_token %}              
            <br>{% if user.username %}
                   <input class="fancybutton"   type = "file" multiple="multiple"  
                   name = "uploadfiles" id="uploadfiles"  />
                   <br><br><br>
                   <button  class="fancybutton"  style="padding: 0.5em 25px; margin-left: 155px" type = "submit" value = "Upload" >
                      Upload
                   </button>
                {% endif %}
    </form>
</div>
<div style = "max-width:29%; margin-left:20%; text-align: left" >
    {% if filesaved %}
        <p>
        <b>File(s) saved as <br>
        {% for f in actual_saved %}
        <em>{{f}}</em> <br></b>
        {% endfor %}
        </p>
    {% endif %}

<p>
{% for f in files %}
<a href="/expofiles/surveyscans/{{year}}/{{wallet|urlencode}}/{{f}}">{{ f}}</a><br />
    {% empty %}
    <p>&lt;No files in this wallet. (Sub-folders here are not supported by troggle in 2022.)&gt;
{% endfor %}
</p>
    {% if create %}
    This online wallet does not yet exist.
        {% if user.username %}
        <br>It will be created and initialised automatically when you upload a file, and then edit the date in the form below and save it.
        {% else %}
        <br>It will be created and initialised automatically when you upload a file, and then edit the date in the form below and save it.
        <br>But you need to log in first <a href=/accounts/login/>Log In </a>
        {% endif %}
    {% include 'wallet_new.html' %}
    {% endif %}

<p><em>
<a href="/wallets/year/{{year}}">Wallet index for {{year}}</a> 
<br />
<a href="/expedition/{{year}}">Logbook entries, people, Survex files for {{year}}</a>
<br /><br />
<a href="/handbook/survey/newwallet.html#onlinew">HELP with using this form</a>
</em>



</div> 
{% if complaints %}
<h3 style="text-align: left; color: red">Complaints</h3>
    <ul style="list-style-type: disc; color: red">
    {% for cmp in complaints%}
    <li>{{cmp}}
    {% endfor %}
    </ul>

{% if user.username %}
{% else %}
<p>You will need to log in to the website (top right menu bar) to be able to edit the settings on this wallet.
{% endif %}

{% endif %}
<hr />

    {% if not create %}
    <br>
    <span style="font-family: monospace;  font-size: 150%; ">
    {% if cave %}<u>Cave ID</u>: 
        {% if caveobject %}<b>{{cave}}</b></a> which implies "<a href="/{{caveobject.url}}">{{caveobject}}</a>"<br> 
        {% else %}
        <b>{{cave}}</b><br> 
        {% endif %}   
    {% endif %}
    {% if psg %}<u>Survey area</u>: <b>{{psg}}</b><br>{% endif %}
    {% if svxfiles %}<u>Survex files</u>: 
            {% for svx in svxfiles %}
            <a href="/survexfile/{{svx}}">{{svx}}</a>
            {% endfor %}
            <br>
    {% endif %}

   
    </span>
    <span style="font-family: monospace;  font-size: 130%; ">
    
    </span>
    <style>
    input {font-family: monospace; font-weight: bold; font-size: 100%; padding: 0.5em;  }
    </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 %}
           <label for="date">Date of the survey trip</label>
           <input 
           label = "Date" name = "date" size="12"
           title="Date of the trip in ISO format: 2020-08-17"
           placeholder="{{date}}" value="{{date}}" required /> 
    <br>        
           <label for="cave">Cave ID (only needed if no survex file yet)</label>
           <input 
           label = "Cave" name = "cave" size="12"
           title="Cave id e.g. 2017-DM-01 or 1623/256"
           placeholder="{{cave}}" value="{{cave}}"  /> 
    <br>        
           <label for="psg">Survey area (wallet name)</label>
           <input 
           label = "Survey area" name = "psg" size ="{{psgsize}}"
           title="Survey area, e.g. White Elephant or Nieder Augst Eck"
           placeholder="{{psg}}" value="{{psg}}"  /> 
    <br>        
           <label for="freetext">Free text for comments</label>
           <input 
           label = "Free text" name = "freetext" size ="{{freetextsize}}"
           title="e.g. scans for plan are in another wallet #99"
           placeholder="{{freetext}}" value="{{freetext}}"  /> 
    <br>        
           <label for="plannr">Plan not required ?</label>
           <input type="checkbox" name="plannr" id="plannr" value=" True" {% if "plan not required" in checked %}checked{% endif %}>
    <br>
           <label for="elevnr">Elevation not required ?</label>
           <input type="checkbox" name="elevnr" id="elevnr" value="True" {% if "elev not required" in checked %}checked{% endif %}>
    <br>
           <label for="survexnr">Survex file not required ?</label>
           <input type="checkbox" name="survexnr" id="survexnr" value="True" {% if "survex not required" in checked %}checked{% endif %}>
    <br>
           <label for="pland">Plan drawn ?</label>
           <input type="checkbox" name="pland" id="pland" value="True" {{chkpland}} {% if "plan drawn" in checked %}checked{% endif %}>
    <br>
           <label for="elevd">Elevation drawn ?</label>
           <input type="checkbox" name="elevd" id="elevd" value="True" {% if "elev drawn" in checked %}checked{% endif %}>
    <br>
           <label for="descriptionw">Cave description written (or nothing recorded) ?</label>
           <input type="checkbox" name="descriptionw" id="descriptionw" value="True" {% if "description written" in checked %}checked{% endif %}>
    <br>
           <label for="qmsw">QMs written (or none seen) ?</label>
           <input type="checkbox" name="qmsw" id="qmsw" value="True" {% if "qms written" in checked %}checked{% endif %}>
    <br>
           <label for="websiteupt">Website updated ?</label>
           <input type="checkbox" name="websiteupt" id="websiteupt" value="True" {% if "website updated" in checked %}checked{% endif %}>
    <br>
           <label for="electronic">Electronic survey ?</label>
           <input type="checkbox" name="electronic" id="electronic" value="True" {% if "electronic survey" in checked %}checked{% endif %}>
    <br>
           <label for="people">List of people on the survey trip(s)</label>
           <input 
           label = "People" name = "people" size ="{{peoplesize}}"
           title="List of people on the survey trip"
           placeholder="{{people}}" value="{{people}}" /> 

    <br>
           <label for="survex">List of survex files</label>
           <input 
           label = "survex" name = "survex" size ="{{survexsize}}"
           title="List of survex files using this data"
           placeholder="caves-1623/264/side_balkon/siriuscyberlift.svx" value="{{survex}}"  /> 
    <br><br>{% if user.username %}
            <button  class="fancybutton"  style="padding: 0.5em 25px; margin-left: 155px; font-size: 90%; " 
            type = "submit" value = "Edit" >
            Submit changes
            </button>{% endif %}
        </form>
    </div>
    <span style="font-family: monospace;  font-size: 150%; ">

        {% if trips %}<u>Logbook trips</u> on this date:<br>
            <span style="font-size: 70%; ">
            {% for item in trips %}
            {% if item.isLogbookEntry %}&nbsp;&nbsp;&nbsp;&nbsp;<a href="{{item.get_absolute_url}}">{{item.title|safe}}</a><br/>{% endif %}
            {% empty %}
            <em>None found for this date, bit there should be..</em><br>
            {% endfor %}
            </span>
    {% else %}
        <em>No Logbook trips found for this date.</em><br>
    {% endif %}
    {% if svxothers %}<u>Other survex files</u> on this date:<br>
            <span style="font-size: 70%; ">
            {% for item in svxothers %}
            {% if item.isSurvexBlock %}&nbsp;&nbsp;&nbsp;&nbsp;<a href="/survexfile/{{item.survexfile.path}}">{{item.survexfile.path|safe}}</a><br/>{% endif %}
            {% empty %}
            <em>None found for this date, bit there should be..</em><br>
            {% endfor %}
            </span>
    {% else %}
        <em>No other survex files found for this date.</em><br>
    {% endif %}
    {% if metadataurl %}<u>Debug</u>:
        <span style="font-size: 70%; ">
        <a href="{{metadataurl}}">json file</a><br> {% endif %}
        </span>
    </span>
    {% endif %} <!-- not create -->
{% endblock %}