Statistics
| Branch: | Tag: | Revision:

root / templates / edumanage / contacts.html @ 36f33c88

History | View | Annotate | Download (5.3 kB)

1
{% extends "edumanage/welcome.html"%}
2
{% load i18n %}
3
                        {% block crumbs %}
4
                                    <li><a href="{% url manage %}">{% trans "Home" %}</a><span class="divider">/</span></li>
5
                                    <li class="active">{% trans "Contacts" %}</li>
6
                                    {% endblock %}
7
{% load i18n %}
8
{% block extrahead %}
9
<script type="text/javascript" src="/static/js/jquery.dataTables.min.js"></script>
10
<script type="text/javascript" src="/static/js/datatables_bootstrap.js"></script>
11
<script type="text/javascript">
12
$(document).ready(function(){
13
         {% if contacts %}
14
var oTable = $('#table').dataTable({
15
        "sPaginationType": "bootstrap",
16
        "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
17
        "aoColumns": [{
18
        "bSearchable": true,
19
        "bSortable": true
20
    }, {
21
        "bSearchable": true,
22
        "bSortable": true
23
    }, {
24
        "bSearchable": true,
25
        "bSortable": true
26
    }, {
27
        "bVisible": true,
28
        "bSearchable": false,
29
        "bSortable": false
30
    }],
31
    "aaSorting": [[0, 'desc']],
32
    "iDisplayLength": 25,
33
    "oSearch": {"bSmart": false, "bRegex":true},
34
    "oLanguage": {
35
            "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "contacts" %}',
36
        "sProcessing":   "Processing...",
37
        "sZeroRecords": '{% trans "No records to display" %}',
38
        "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
39
        "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
40
        "sInfoFiltered": "(filtered from _MAX_ total entries)",
41
        "sInfoPostFix":  "",
42
        "sSearch":       '{% trans "Search:" %}',
43
        "sUrl":          "",
44
        "oPaginate": {
45
            "sFirst":    '{% trans "First" %}',
46
            "sPrevious": '{% trans "Previous" %}',
47
            "sNext":     '{% trans "Next" %}',
48
            "sLast":     '{% trans "Last" %}'
49
        }
50
    }
51
});
52

53
oTable.fnDraw();
54

55
$('[id^=del_contact_]').click(function(){
56
        contact_id = (this.id).replace("del_contact_", '');
57
        name = this.getAttribute("data-contactname");
58
        $("#mymodalbody").html("{% trans 'You are about to delete contact' %}: <b>"+name+"</b><br>{% trans 'Press Delete to proceed or Cancel to cancel deletion' %}");
59
        $("#myModalLabel").html("{% trans 'Delete contact' %} "+name);
60
        $('#myModal').modal('show');
61
        $(".modal-footer").show();
62
        $("#contact_name_del").html(name)        
63
        return false;
64
});
65

66
$("#delcontactSubmit").click(function(){
67
        $.ajax({
68
                url:"{% url del-contact %}/?contact_pk="+contact_id,
69
                type: "GET",
70
                success: function(data){
71
                        if (data.error){
72
                                $(".modal-footer").hide();
73
                                $("#mymodalbody").html("<font style='color:#B94A48'>"+data.error+"</font>");
74
                        }
75
                        if (data.success){
76
                                $(".modal-footer").hide();
77
                                $("#mymodalbody").html("contact "+name+" successfully deleted");
78
                                window.setTimeout('location.reload()', 1000);
79
                                
80
                        }
81
                        }
82
                });
83
});
84

85
{% endif %}
86
});
87
</script>
88
{% endblock %}
89

    
90
        {% block navbar %}
91
                        
92
                    {% endblock %}
93
                    
94
                    {% block homeactive %}{% endblock %}
95
                    {% block contactsactive %}class="active"{% endblock %}
96
            {% block subcontent %}
97

    
98
                            
99
                      <h4>{% trans "Contacts" %}</h4>
100
                      <hr>
101
                      {% if messages %}
102
                    <table class="table table-condensed">
103
                        {% for message in messages %}
104
                        <tr {% if  %} class="{{ message.tags }}"{% endif %}><td>{{ message }}<td></tr>
105
                        {% endfor %}
106
                    </table>
107
                {% endif %}
108
                      <div><a href="{% url edit-contacts %}" class="btn btn-primary">{% trans "Add new contact" %}</a></div>
109
                      <div class="span10"></div>
110
                      {% if contacts %}
111
                      <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="table">
112
                                        <thead>
113
                                        <tr>
114
                                                <th>{% trans "Name" %}</th>
115
                                                <th>{% trans "Email" %}</th>
116
                                                <th>{% trans "Phone" %}</th>
117
                                                <th style="text-align: center;">{% trans "Action" %}</th>
118
                                        </tr>
119
                                        </thead>
120
                                        
121
                                        <tbody>
122
                        {% for contact in contacts %}
123
                              <tr class="GradeC">
124
                                <td>{{contact.name}}</td>
125
                                <td>{{contact.email}}</td>
126
                                <td>{{contact.phone}}</td>
127
                                <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>
128
                        </tr>
129
                              {% endfor %}
130
                              </tbody>
131
                      </table>
132
                      {% endif %}
133
<div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
134
<div class="modal-header">
135
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
136
<h3 id="myModalLabel">{% trans "Delete contact" %}</h3>
137
</div>
138
<div class="modal-body" id="mymodalbody">
139

    
140
</div>
141
<div class="modal-footer">
142
<button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>
143
<a class="btn btn-warning" id="delcontactSubmit" href="#">{% trans "Delete" %}</a>
144
</div>
145
</div>
146
            {% endblock %}
147