Statistics
| Branch: | Tag: | Revision:

root / djnro / templates / edumanage / contacts.html @ 4772922a

History | View | Annotate | Download (4.9 kB)

1
{% extends "edumanage/welcome.html"%}
2
{% load i18n %}
3
{% load staticfiles %}
4

    
5

    
6
{% block homeactive %}{% endblock %}
7
{% block contactsactive %}class="active"{% endblock %}
8
{% block management_content %}
9
<h4>{% trans "Contacts" %}</h4>
10
<hr>
11
  {% if messages %}
12
    <table class="table table-condensed">
13
        {% for message in messages %}
14
        <tr {% if  %} class="{{ message.tags }}"{% endif %}><td>{{ message }}<td></tr>
15
        {% endfor %}
16
    </table>
17
{% endif %}
18
  {% if contacts %}
19
  <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="table">
20
        <thead>
21
        <tr>
22
                <th>{% trans "Name" %}</th>
23
                <th>{% trans "Email" %}</th>
24
                <th>{% trans "Phone" %}</th>
25
                <th style="text-align: center;">{% trans "Action" %}</th>
26
        </tr>
27
        </thead>
28

    
29
        <tbody>
30
    {% for contact in contacts %}
31
          <tr class="GradeC">
32
            <td>{{contact.name}}</td>
33
            <td>{{contact.email}}</td>
34
            <td>{{contact.phone}}</td>
35
            <td style="text-align: center;"><a href="{% url edit-contacts contact.pk %}" class="btn btn-small">{% trans "edit" %}</a> <a href="#" id="del_contact_{{contact.pk}}" data-contactname="{{contact.name}}" class="btn btn-small btn-warning">{% trans "delete" %}</a></td>
36
    </tr>
37
          {% endfor %}
38
          </tbody>
39
  </table>
40
  {% endif %}
41
<div><a href="{% url edit-contacts %}" class="btn btn-primary">{% trans "Add new contact" %}</a></div>
42
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
43
        <div class="modal-dialog">
44
            <div class="modal-content">
45
                        <div class="modal-header">
46
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
47
                                <h3 id="myModalLabel">{% trans "Delete contact" %}</h3>
48
                        </div>
49
                        <div class="modal-body" id="mymodalbody"></div>
50
                        <div class="modal-footer">
51
                                <button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>
52
                                <a class="btn btn-warning" id="delcontactSubmit" href="#">{% trans "Delete" %}</a>
53
                        </div>
54
                </div>
55
        </div>
56
</div>
57
{% endblock %}
58

    
59

    
60

    
61
{% block extrajs %}
62
<script type="text/javascript" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
63
<script type="text/javascript" src="//cdn.datatables.net/plug-ins/505bef35b56/integration/bootstrap/1/dataTables.bootstrap.js"></script>
64
<script type="text/javascript">
65
$(document).ready(function(){
66
         {% if contacts %}
67
var oTable = $('#table')
68
        .on( 'init.dt', function () {
69
                       $('.pagination ul').addClass('pagination');
70
            })
71
        .dataTable({
72
                "sPaginationType": "bootstrap",
73
                "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
74
                "aoColumns": [{
75
                "bSearchable": true,
76
                "bSortable": true
77
            }, {
78
                "bSearchable": true,
79
                "bSortable": true
80
            }, {
81
                "bSearchable": true,
82
                "bSortable": true
83
            }, {
84
                "bVisible": true,
85
                "bSearchable": false,
86
                "bSortable": false
87
            }],
88
            "aaSorting": [[0, 'desc']],
89
            "iDisplayLength": 25,
90
            "oSearch": {"bSmart": false, "bRegex":true},
91
            "oLanguage": {
92
                    "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "contacts" %}',
93
                "sProcessing":   "Processing...",
94
                "sZeroRecords": '{% trans "No records to display" %}',
95
                "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
96
                "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
97
                "sInfoFiltered": "(filtered from _MAX_ total entries)",
98
                "sInfoPostFix":  "",
99
                "sSearch":       '{% trans "Search:" %}',
100
                "sUrl":          "",
101
                "oPaginate": {
102
                    "sFirst":    '{% trans "First" %}',
103
                    "sPrevious": '{% trans "Previous" %}',
104
                    "sNext":     '{% trans "Next" %}',
105
                    "sLast":     '{% trans "Last" %}'
106
                }
107
            }
108
        });
109

110
        oTable.fnDraw();
111

112
$('[id^=del_contact_]').click(function(){
113
        contact_id = (this.id).replace("del_contact_", '');
114
        name = this.getAttribute("data-contactname");
115
        $("#mymodalbody").html("{% trans 'You are about to delete contact' %}: <b>"+name+"</b><br>{% trans 'Press Delete to proceed or Cancel to cancel deletion' %}");
116
        $("#myModalLabel").html("{% trans 'Delete contact' %} "+name);
117
        $('#myModal').modal('show');
118
        $(".modal-footer").show();
119
        $("#contact_name_del").html(name)
120
        return false;
121
});
122

123
$("#delcontactSubmit").click(function(){
124
        $.ajax({
125
                url:"{% url del-contact %}/?contact_pk="+contact_id,
126
                type: "GET",
127
                success: function(data){
128
                        if (data.error){
129
                                $(".modal-footer").hide();
130
                                $("#mymodalbody").html("<font style='color:#B94A48'>"+data.error+"</font>");
131
                        }
132
                        if (data.success){
133
                                $(".modal-footer").hide();
134
                                $("#mymodalbody").html("contact "+name+" successfully deleted");
135
                                window.setTimeout('location.reload()', 1000);
136

137
                        }
138
                        }
139
                });
140
});
141

142
{% endif %}
143
});
144
</script>
145
{% endblock %}