Show Attendance

Daily Wise Subject Wise
Instance URL:
Token:
Student Admission no:
Date:
Output
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Fedena API</title>
        <script src="https://s3.amazonaws.com/api_play/src/js/jquery-2.1.1.min.js"></script>
        <script src="https://s3.amazonaws.com/api_play/src/js/vkbeautify.0.99.00.beta.js"></script>
        <script>
            $(function() {
                $("#delete-attendance").click(function() {
                    var fedena_server = $("#fedena_server").val();
                    var token = $("#token").val();
                    var admission_no = $("#admission_no").val();
                    var date = $("#date").val();
                    var result_div = $("#result");
                    var attendance_type = $("input:radio[name=attendance_type]:checked").val();
                    if (attendance_type=="daily")
                    {
                        delete_day_attendance(fedena_server,token,admission_no,date,result_div);
                    }
                    else
                    {
                        var subject_code = $("#subject_code").val();
                        var class_timing_name = $("#class_timing_name").val();
                        delete_subject_attendance(fedena_server,token,admission_no,date,subject_code,class_timing_name,result_div);
                    }
                });
            });
        </script>
        <script>
            function delete_day_attendance(fedena_server,token,admission_no,date,result_div){
                result_div.html("");
                try
                {
                    var xhr = new XMLHttpRequest();
                    xhr.onreadystatechange = function(evt)
                    {
                        if (xhr.readyState==4)
                        {
                            result_div.html(show_response(evt.target.responseText));
                        }
                    }
                    
                    xhr.open('DELETE', fedena_server+"/api/attendances/" + admission_no + "?date=" + date);
                    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                    xhr.setRequestHeader('Authorization', 'Token token="'+token+'"');
                    xhr.send();
                }
                catch(err)
                {
                    alert(err.message);
                }
            }

            function delete_subject_attendance(fedena_server,token,admission_no,date,subject_code,class_timing_name,result_div){
                result_div.html("");
                try
                {
                    var xhr = new XMLHttpRequest();
                    xhr.onreadystatechange = function(evt)
                    {
                        if (xhr.readyState==4)
                        {
                            result_div.html(show_response(evt.target.responseText));
                        }
                    }

                    xhr.open('DELETE', fedena_server+"/api/attendances/" + admission_no + "?date=" + date + "&subject_code=" + subject_code + "&class_timing_name=" + class_timing_name);
                    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                    xhr.setRequestHeader('Authorization', 'Token token="'+token+'"');
                    xhr.send();
                }
                catch(err)
                {
                    alert(err.message);
                }
            }

            function attendance_type(th_is){
                if (th_is.value=="daily")
                {
                    $(".subject_wise").hide();
                }
                else
                {
                    $(".subject_wise").show();
                }
            }
            
            function show_response(str){
                str = vkbeautify.xml(str,4); /* Optional, To format the XML output*/
                return str.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g,"<br />");
            }
        </script>
    </head>
    <body>
        <h3> Delete Attendance </h3>
        <div>
            <table>
                <tr>
                    <td colspan="2">
                        <input type="radio" name="attendance_type" value="daily" checked="checked" onchange="attendance_type(this)" /> Daily Wise
                        <input type="radio" name="attendance_type" value="subject" onchange="attendance_type(this)" /> Subject Wise
                    </td>
                </tr>
                <tr>
                    <td>
                        Instance URL:
                    </td>
                    <td>
                        <input id="fedena_server" type="text" placeholder="ex: http://myschoolsis.com"  />
                    </td>
                </tr>
                <tr>
                    <td>
                        Token:
                    </td>
                    <td>
                        <input id="token" type="text"  />
                    </td>
                </tr>
                <tr>
                    <td>
                        Student Admission no:
                    </td>
                    <td>
                        <input id="admission_no" type="text" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Date:
                    </td>
                    <td>
                        <input id="date" type="text" placeholder="yyyy-mm-dd" />
                    </td>
                </tr>
                <tr class="subject_wise" style="display: none;">
                    <td>
                        Subject Code:
                    </td>
                    <td>
                        <input id="subject_code" type="text" />
                    </td>
                </tr>
                <tr class="subject_wise" style="display: none;">
                    <td>
                        Class Timing Name:
                    </td>
                    <td>
                        <input id="class_timing_name" type="text" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <button type="button" id="delete-attendance" value="Delete Attendance">Delete Attendance</button>
                    </td>
                </tr>
            </table>
            <pre> <code id="result" style="text-align: left; float: left;"></code></pre>
        </div>
    </body>
</html>
loading..