aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/account/booking_list.html
blob: ed59b810eb0740175baa24be2a3cc37862679570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{% extends "base.html" %}
{% block content %}
<h2>Bookings I Own</h2>
    <div class="card_container">
    {% for booking in bookings %}
        <div class="detail_card">
            <div>
                <h3>Booking {{booking.id}}</h3>
                <ul class="list-group">
                    <li class="list-group-item">id: {{booking.id}}</li>
                    <li class="list-group-item">lab: {{booking.lab}}</li>
                    <li class="list-group-item">resource: {{booking.resource.template.name}}</li>
                    <li class="list-group-item">start: {{booking.start}}</li>
                    <li class="list-group-item">end: {{booking.end}}</li>
                    <li class="list-group-item">purpose: {{booking.purpose}}</li>
                </ul>
            </div>
            <div class="detail_button_container">
                <a class="btn btn-primary" href="/booking/detail/{{booking.id}}/">Details</a>
                <button
                    class="btn btn-danger"
                    onclick='cancel_booking({{booking.id}});'
                    data-toggle="modal"
                    data-target="#resModal"
                >Cancel</button>
            </div>
        </div>
    {% endfor %}
    </div>
<h2>Bookings I Collaborate On</h2>
    <div class="card_container">
    {% for booking in collab_bookings %}
        <div class="detail_card">
            <div>
                <h3>Booking {{booking.id}}</h3>
                <ul class="list-group">
                    <li class="list-group-item">id: {{booking.id}}</li>
                    <li class="list-group-item">lab: {{booking.lab}}</li>
                    <li class="list-group-item">resource: {{booking.resource.template.name}}</li>
                    <li class="list-group-item">start: {{booking.start}}</li>
                    <li class="list-group-item">end: {{booking.end}}</li>
                    <li class="list-group-item">purpose: {{booking.purpose}}</li>
                </ul>
            </div>
            <a class="btn btn-primary" href="/booking/detail/{{booking.id}}/">Details</a>
        </div>
    {% endfor %}
    </div>

    <h2>Expired Bookings
        <i class="fa fa-fw fa-caret-down" onclick='toggle_display("expired_bookings");'></i>
    </h2>
    <div id="expired_bookings" class="card_container" style="display:none;">
    {% for booking in expired_bookings %}
        <div class="detail_card">
            <div>
                <h3>Booking {{booking.id}}</h3>
                <ul class="list-group">
                    <li class="list-group-item">id: {{booking.id}}</li>
                    <li class="list-group-item">lab: {{booking.lab}}</li>
                    <li class="list-group-item">resource: {{booking.resource.template.name}}</li>
                    <li class="list-group-item">start: {{booking.start}}</li>
                    <li class="list-group-item">end: {{booking.end}}</li>
                    <li class="list-group-item">purpose: {{booking.purpose}}</li>
                    <li class="list-group-item">owner: {{booking.owner.userprofile.email_addr}}</li>
                </ul>
            </div>
            <a class="btn btn-primary" href="/booking/detail/{{booking.id}}/">Details</a>
        </div>
    {% endfor %}
    </div>
<script>
    var current_booking_id = -1;
    function cancel_booking(booking_id) {
        current_booking_id = booking_id;
        document.getElementById('modal_warning').style['max-height'] = '0px';
    }

    function submit_cancel_form() {
        var ajaxForm = $("#booking_cancel_form");
        var formData = ajaxForm.serialize();
        req = new XMLHttpRequest();
        var url = "cancel/" + current_booking_id;
        req.open("POST", url, true);
        req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        req.onerror = function() { alert("problem submitting form"); }
        req.send(formData);
    }

    function toggle_display(elem_id){
        var e = document.getElementById(elem_id);
        if (e.style.display === "none"){
            e.style.display = "grid";
        } else {
            e.style.display = "none";
        }
    }
</script>
<div class="modal fade" id="resModal" tabindex="-1" role="dialog" aria-labelledby="my_modal" aria-hidden="true">
    <div class="modal-dialog" style="width: 450px;" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="my_modal" style="display: inline; float: left;">Cancel Booking?</h4>
                <p>Everthing on your machine(s) will be lost</p>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="booking_cancel_form">
                {% csrf_token %}
            </form>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" onclick="document.getElementById('modal_warning').style['max-height'] = '500px';">Cancel Booking</button>
            </div>
            <div id="modal_warning" class="modal-footer" style="max-height:0px;" >
                <div style="text-align:center; margin: 5px">
                    <h3>Are You Sure?</h3>
                    <p>This cannot be undone</p>
                    <button class="btn" onclick="document.getElementById('modal_warning').style['max-height'] = '0px';">Nevermind</button>
                    <button class="btn btn-danger" id="confirm_cancel_button" data-dismiss="modal" onclick="submit_cancel_form();">I'm Sure</button>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}