<!DOCTYPE html>
<html>
<head>
    <script>
    function del_staff(elt)
    {
        // alert(elt.id);
        elt.parentNode.parentNode.removeChild(elt.parentNode);
    }
    </script>
</head>
<body>
    <p>{{ id }}</p>
    <p>{{ message }}</p>
    <form method='post'>
    	{% csrf_token %}
        {% if mode == 'add' or mode == 'edit' %}
		<label>Занят</label>
    	{% for f in form_occupied %}
    		<p id={{ f.prefix }} > {{ f }} <span onclick='del_staff(this)'>Delete</span></p>
    	{% endfor %}
    	<p id='occupied-new0'>
            Staff:<input value="" name="occupied-new0-staff" id="occupied-new0-staff"> <!-- это имя - то что видит юзер -->
            Staff id:<input name="occupied-new0-staff__value" value=""> <!-- это логин, то что надо мне -->
            Staff type:<input name="occupied-new0-staff__type" value="staff">
            <span onclick='del_staff(this)'>Delete</span>
    	</p>
        {% endif %}
        {% if reserve %}
        <label>Резерв</label>

        {% for f in form_reserved %}
            <p id={{ f.prefix }}> {{ f }} <span onclick='del_staff(this)'>Delete</span></p>
        {% endfor %}

        <p id='reserved-new0'>
        Entity:
        <input id="id_reserved-new0-entity" name="reserved-new0-entity">
        Entity value:
        <input id="id_reserved-new0-entity__value" value="" name="reserved-new0-entity__value">
        Entity type:
        <input id="id_reserved-new0-entity__type" value="" name="reserved-new0-entity__type">
        Description:
        <input id="id_reserved-new0-description" value="" name="reserved-new0-description">
        <span onclick='del_staff(this)'>Delete</span>

        </p>
        {% endif %}
        {% if book %}
        <label>Бронь</label>

        {% for f in form_booked %}
            <p id={{ f.prefix }}> {{ f }} <span onclick='del_staff(this)'>Delete</span></p>
        {% endfor %}
        <p id="booked-new0">
        Staff:
        <input id="id_booked-new0-staff" name="booked-new0-staff">
        Staff id:
        <input id="id_booked-new0-staff__value" value="" name="booked-new0-staff__value">
        Staff staff:
        <input id="id_booked-new0-staff__type" value="staff" name="booked-new0-staff__type">
        Date from:
        <input id="id_booked-new0-date_from" name="booked-new0-date_from">
        Date to:
        <input id="id_booked-new0-date_to" value="" name="booked-new0-date_to">
        Description:
        <input id="id_booked-new0-description" value="" name="booked-new0-description">
        <span onclick='del_staff(this)'>Delete</span>
        </p>
        {% endif %}
        {{ form.as_p }}
        <!-- {{ form_reserved.as_p }} -->
        <button type='submit' name='action_ok'>Ok</button>

    </form>
    {% if id %}
        <p>
        <form method='post' action = {% url 'map.edit.views.delete_table' id %}>
            {% csrf_token %}
            <button type='submit' >Delete</button>
        </form>
        </p>
    {% endif %}
</body>
